You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
8.3 KiB
160 lines
8.3 KiB
|
2 months ago
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
|
<mapper namespace="com.example.web.mapper.CustomerMapper">
|
||
|
|
<resultMap id="ContactsResultMap" type="com.example.web.entity.Contacts">
|
||
|
|
<result column="contact_id" property="contact_id" />
|
||
|
|
<result column="id" property="id" />
|
||
|
|
<result column="nickName" property="nickName" />
|
||
|
|
<result column="phoneNumber" property="phoneNumber" />
|
||
|
|
<result column="wechat" property="wechat" />
|
||
|
|
<result column="account" property="account" />
|
||
|
|
<result column="accountNumber" property="accountNumber" />
|
||
|
|
<result column="bank" property="bank" />
|
||
|
|
<result column="address" property="address" />
|
||
|
|
<result column="followup" property="followup" />
|
||
|
|
<result column="created_at" property="created_at" />
|
||
|
|
<result column="updated_at" property="updated_at" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="EnterpriseResultMap" type="com.example.web.entity.Enterprise">
|
||
|
|
<result column="id" property="id" />
|
||
|
|
<result column="company" property="company" />
|
||
|
|
<result column="region" property="region" />
|
||
|
|
<result column="level" property="level" />
|
||
|
|
<result column="type" property="type" />
|
||
|
|
<result column="demand" property="demand" />
|
||
|
|
<result column="spec" property="spec" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<resultMap id="ManagersResultMap" type="com.example.web.entity.Managers">
|
||
|
|
<result column="manager_id" property="manager_id" />
|
||
|
|
<result column="id" property="id" />
|
||
|
|
<result column="managerId" property="managerId" />
|
||
|
|
<result column="managercompany" property="managercompany" />
|
||
|
|
<result column="managerdepartment" property="managerdepartment" />
|
||
|
|
<result column="organization" property="organization" />
|
||
|
|
<result column="role" property="role" />
|
||
|
|
<result column="root" property="root" />
|
||
|
|
<result column="created_at" property="created_at" />
|
||
|
|
<result column="updated_at" property="updated_at" />
|
||
|
|
<result column="userName" property="userName" />
|
||
|
|
<result column="assistant" property="assistant" />
|
||
|
|
</resultMap>
|
||
|
|
|
||
|
|
<!-- 获取所有联系人信息 -->
|
||
|
|
<select id="getAllContacts" resultMap="ContactsResultMap">
|
||
|
|
SELECT contact_id, id, nickName, phoneNumber, wechat, account, accountNumber, bank, address, followup, created_at, updated_at
|
||
|
|
FROM contacts
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 根据联系人ID获取企业信息 -->
|
||
|
|
<select id="getEnterpriseByContactId" parameterType="String" resultMap="EnterpriseResultMap">
|
||
|
|
SELECT id, company, region, level, type, demand, spec
|
||
|
|
FROM enterprise
|
||
|
|
WHERE id = #{contactId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 根据联系人ID获取负责人信息 -->
|
||
|
|
<select id="getManagerByContactId" parameterType="String" resultMap="ManagersResultMap">
|
||
|
|
SELECT manager_id, id, managerId, managercompany, managerdepartment, organization, role, root, created_at, updated_at, userName, assistant
|
||
|
|
FROM managers
|
||
|
|
WHERE id = #{contactId}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 获取部门公海池数据 -->
|
||
|
|
<select id="getDepartmentSeaPoolContacts" resultMap="ContactsResultMap">
|
||
|
|
SELECT c.contact_id, c.id, c.nickName, c.phoneNumber, c.wechat, c.account, c.accountNumber, c.bank, c.address, c.followup, c.created_at, c.updated_at
|
||
|
|
FROM contacts c
|
||
|
|
LEFT JOIN managers m ON c.id = m.id
|
||
|
|
LEFT JOIN enterprise e ON c.id = e.id
|
||
|
|
WHERE m.managercompany = #{managercompany}
|
||
|
|
AND m.managerdepartment = #{managerdepartment}
|
||
|
|
AND e.level = 'department-sea-pools'
|
||
|
|
AND ((#{role} = 'seller' AND (e.type = 'seller' OR e.type = 'both')) OR (#{role} = 'buyer' AND (e.type = 'buyer' OR e.type = 'both')))
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 获取组织公海池数据 -->
|
||
|
|
<select id="getOrganizationSeaPoolContacts" resultMap="ContactsResultMap">
|
||
|
|
SELECT c.contact_id, c.id, c.nickName, c.phoneNumber, c.wechat, c.account, c.accountNumber, c.bank, c.address, c.followup, c.created_at, c.updated_at
|
||
|
|
FROM contacts c
|
||
|
|
LEFT JOIN managers m ON c.id = m.id
|
||
|
|
LEFT JOIN enterprise e ON c.id = e.id
|
||
|
|
WHERE m.managercompany = #{managercompany}
|
||
|
|
AND m.managerdepartment = #{managerdepartment}
|
||
|
|
AND m.organization = #{organization}
|
||
|
|
AND e.level = 'organization-sea-pools'
|
||
|
|
AND ((#{role} = 'seller' AND (e.type = 'seller' OR e.type = 'both')) OR (#{role} = 'buyer' AND (e.type = 'buyer' OR e.type = 'both')))
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 插入企业信息 -->
|
||
|
|
<insert id="insertEnterprise" parameterType="com.example.web.entity.Enterprise">
|
||
|
|
INSERT INTO enterprise (id, company, region, level, type, demand, spec)
|
||
|
|
VALUES (#{id}, #{company}, #{region}, #{level}, #{type}, #{demand}, #{spec})
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<!-- 插入联系人信息 -->
|
||
|
|
<insert id="insertContacts" parameterType="com.example.web.entity.Contacts">
|
||
|
|
INSERT INTO contacts (contact_id, id, nickName, phoneNumber, wechat, account, accountNumber, bank, address, followup, created_at, updated_at)
|
||
|
|
VALUES (#{contact_id}, #{id}, #{nickName}, #{phoneNumber}, #{wechat}, #{account}, #{accountNumber}, #{bank}, #{address}, #{followup}, #{created_at}, #{updated_at})
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<!-- 插入负责人信息 -->
|
||
|
|
<insert id="insertManagers" parameterType="com.example.web.entity.Managers">
|
||
|
|
INSERT INTO managers (id, managerId, managercompany, managerdepartment, organization, role, root, created_at, updated_at, userName, assistant)
|
||
|
|
VALUES (#{id}, #{managerId}, #{managercompany}, #{managerdepartment}, #{organization}, #{role}, #{root}, #{created_at}, #{updated_at}, #{userName}, #{assistant})
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<!-- 根据角色和登录信息获取客户数据 -->
|
||
|
|
<select id="getCustomersByRole" resultMap="ContactsResultMap">
|
||
|
|
SELECT c.contact_id, c.id, c.nickName, c.phoneNumber, c.wechat, c.account, c.accountNumber, c.bank, c.address, c.followup, c.created_at, c.updated_at
|
||
|
|
FROM contacts c
|
||
|
|
LEFT JOIN managers m ON c.id = m.id
|
||
|
|
LEFT JOIN enterprise e ON c.id = e.id
|
||
|
|
WHERE m.userName = #{userName}
|
||
|
|
AND m.managercompany = #{managercompany}
|
||
|
|
AND m.managerdepartment = #{managerdepartment}
|
||
|
|
AND m.organization = #{organization}
|
||
|
|
AND e.level NOT IN ('department-sea-pools', 'organization-sea-pools')
|
||
|
|
AND ((#{role} = 'seller' AND (e.type = 'seller' OR e.type = 'both')) OR (#{role} = 'buyer' AND (e.type = 'buyer' OR e.type = 'both')))
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 根据电话号码获取联系人信息 -->
|
||
|
|
<select id="getContactsByPhoneNumber" parameterType="String" resultMap="ContactsResultMap">
|
||
|
|
SELECT contact_id, id, nickName, phoneNumber, wechat, account, accountNumber, bank, address, followup, created_at, updated_at
|
||
|
|
FROM contacts
|
||
|
|
WHERE phoneNumber = #{phoneNumber}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 根据ID获取联系人信息 -->
|
||
|
|
<select id="getContactsById" parameterType="String" resultMap="ContactsResultMap">
|
||
|
|
SELECT contact_id, id, nickName, phoneNumber, wechat, account, accountNumber, bank, address, followup, created_at, updated_at
|
||
|
|
FROM contacts
|
||
|
|
WHERE id = #{id}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!-- 更新联系人信息 -->
|
||
|
|
<update id="updateContacts" parameterType="com.example.web.entity.Contacts">
|
||
|
|
UPDATE contacts
|
||
|
|
SET nickName = #{nickName}, wechat = #{wechat}, account = #{account},
|
||
|
|
accountNumber = #{accountNumber}, bank = #{bank}, address = #{address},
|
||
|
|
updated_at = #{updated_at}
|
||
|
|
WHERE contact_id = #{contact_id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!-- 更新企业信息 -->
|
||
|
|
<update id="updateEnterprise" parameterType="com.example.web.entity.Enterprise">
|
||
|
|
UPDATE enterprise
|
||
|
|
SET company = #{company}, region = #{region}, level = #{level},
|
||
|
|
type = #{type}, demand = #{demand}, spec = #{spec}
|
||
|
|
WHERE id = #{id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!-- 更新负责人信息 -->
|
||
|
|
<update id="updateManagers" parameterType="com.example.web.entity.Managers">
|
||
|
|
UPDATE managers
|
||
|
|
SET managercompany = #{managercompany}, managerdepartment = #{managerdepartment},
|
||
|
|
organization = #{organization}, role = #{role}, userName = #{userName},
|
||
|
|
assistant = #{assistant}, updated_at = #{updated_at}
|
||
|
|
WHERE id = #{id}
|
||
|
|
</update>
|
||
|
|
</mapper>
|