<?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">
|
<!--
|
* @title: 客户用户表
|
* @description: 自定义sql,请自行实现业务逻辑
|
* @company: hugeinfo
|
* @author: liyj
|
* @time:2024-08-19 20:04:19
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.ctuser.dao.mapper.CtUserMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.ctuser.domain.po.CtUser">
|
<result property="id" column="id"/>
|
<result property="trueName" column="true_name"/>
|
<result property="sex" column="sex"/>
|
<result property="sexName" column="sex_name"/>
|
<result property="mobile" column="mobile"/>
|
<result property="idcard" column="idcard"/>
|
<result property="email" column="email"/>
|
<result property="wechat" column="wechat"/>
|
<result property="qq" column="qq"/>
|
<result property="prov" column="prov"/>
|
<result property="provName" column="prov_name"/>
|
<result property="city" column="city"/>
|
<result property="cityName" column="city_name"/>
|
<result property="area" column="area"/>
|
<result property="areaName" column="area_name"/>
|
<result property="road" column="road"/>
|
<result property="roadName" column="road_name"/>
|
<result property="village" column="village"/>
|
<result property="villageName" column="village_name"/>
|
<result property="addr" column="addr"/>
|
<result property="avatar" column="avatar"/>
|
<result property="unitId" column="unit_id"/>
|
<result property="unitName" column="unit_name"/>
|
<result property="deptId" column="dept_id"/>
|
<result property="deptName" column="dept_name"/>
|
<result property="joinWay" column="join_way"/>
|
<result property="realStatus" column="real_status"/>
|
<result property="status" column="status"/>
|
<result property="goodField" column="good_field"/>
|
<result property="goodFieldName" column="good_field_name"/>
|
<result property="canField" column="can_field"/>
|
<result property="canFieldName" column="can_field_name"/>
|
<result property="findStatus" column="find_status"/>
|
<result property="dispStatus" column="disp_status"/>
|
<result property="deleteStatus" column="delete_status"/>
|
<result property="custId" column="cust_id"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
<!-- 表 -->
|
<sql id='table-name'>dyh_ct_user</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
id,
|
true_name,
|
sex,
|
sex_name,
|
mobile,
|
idcard,
|
email,
|
wechat,
|
qq,
|
prov,
|
prov_name,
|
city,
|
city_name,
|
area,
|
area_name,
|
road,
|
road_name,
|
village,
|
village_name,
|
addr,
|
avatar,
|
unit_id,
|
unit_name,
|
dept_id,
|
dept_name,
|
join_way,
|
real_status,
|
status,
|
good_field,
|
good_field_name,
|
can_field,
|
can_field_name,
|
find_status,
|
disp_status,
|
delete_status,
|
cust_id,
|
create_time,
|
update_time
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.trueName != null">true_name = #{entity.trueName},</if>
|
<if test="entity.sex != null">sex = #{entity.sex},</if>
|
<if test="entity.sexName != null">sex_name = #{entity.sexName},</if>
|
<if test="entity.mobile != null">mobile = #{entity.mobile},</if>
|
<if test="entity.idcard != null">idcard = #{entity.idcard},</if>
|
<if test="entity.email != null">email = #{entity.email},</if>
|
<if test="entity.wechat != null">wechat = #{entity.wechat},</if>
|
<if test="entity.qq != null">qq = #{entity.qq},</if>
|
<if test="entity.prov != null">prov = #{entity.prov},</if>
|
<if test="entity.provName != null">prov_name = #{entity.provName},</if>
|
<if test="entity.city != null">city = #{entity.city},</if>
|
<if test="entity.cityName != null">city_name = #{entity.cityName},</if>
|
<if test="entity.area != null">area = #{entity.area},</if>
|
<if test="entity.areaName != null">area_name = #{entity.areaName},</if>
|
<if test="entity.road != null">road = #{entity.road},</if>
|
<if test="entity.roadName != null">road_name = #{entity.roadName},</if>
|
<if test="entity.village != null">village = #{entity.village},</if>
|
<if test="entity.villageName != null">village_name = #{entity.villageName},</if>
|
<if test="entity.addr != null">addr = #{entity.addr},</if>
|
<if test="entity.avatar != null">avatar = #{entity.avatar},</if>
|
<if test="entity.unitId != null">unit_id = #{entity.unitId},</if>
|
<if test="entity.unitName != null">unit_name = #{entity.unitName},</if>
|
<if test="entity.deptId != null">dept_id = #{entity.deptId},</if>
|
<if test="entity.deptName != null">dept_name = #{entity.deptName},</if>
|
<if test="entity.joinWay != null">join_way = #{entity.joinWay},</if>
|
<if test="entity.realStatus != null">real_status = #{entity.realStatus},</if>
|
<if test="entity.status != null">status = #{entity.status},</if>
|
<if test="entity.goodField != null">good_field = #{entity.goodField},</if>
|
<if test="entity.goodFieldName != null">good_field_name = #{entity.goodFieldName},</if>
|
<if test="entity.canField != null">can_field = #{entity.canField},</if>
|
<if test="entity.canFieldName != null">can_field_name = #{entity.canFieldName},</if>
|
<if test="entity.findStatus != null">find_status = #{entity.findStatus},</if>
|
<if test="entity.dispStatus != null">disp_status = #{entity.dispStatus},</if>
|
<if test="entity.deleteStatus != null">delete_status = #{entity.deleteStatus},</if>
|
<if test="entity.custId != null">cust_id = #{entity.custId},</if>
|
<if test="entity.createTime != null">create_time = #{entity.createTime},</if>
|
<if test="entity.updateTime != null">update_time = #{entity.updateTime}</if>
|
</sql>
|
<!-- 条件 -->
|
<sql id="where-part">
|
<if test="terms != null">
|
<where>
|
<if test="terms.id != null and terms.id !=''">
|
and id = #{terms.id}
|
</if>
|
<if test="terms.trueName != null and terms.trueName !=''">
|
and true_name = #{terms.trueName}
|
</if>
|
<if test="terms.sex != null and terms.sex !=''">
|
and sex = #{terms.sex}
|
</if>
|
<if test="terms.sexName != null and terms.sexName !=''">
|
and sex_name = #{terms.sexName}
|
</if>
|
<if test="terms.mobile != null and terms.mobile !=''">
|
and mobile = #{terms.mobile}
|
</if>
|
<if test="terms.idcard != null and terms.idcard !=''">
|
and idcard = #{terms.idcard}
|
</if>
|
<if test="terms.email != null and terms.email !=''">
|
and email = #{terms.email}
|
</if>
|
<if test="terms.wechat != null and terms.wechat !=''">
|
and wechat = #{terms.wechat}
|
</if>
|
<if test="terms.qq != null and terms.qq !=''">
|
and qq = #{terms.qq}
|
</if>
|
<if test="terms.prov != null and terms.prov !=''">
|
and prov = #{terms.prov}
|
</if>
|
<if test="terms.provName != null and terms.provName !=''">
|
and prov_name = #{terms.provName}
|
</if>
|
<if test="terms.city != null and terms.city !=''">
|
and city = #{terms.city}
|
</if>
|
<if test="terms.cityName != null and terms.cityName !=''">
|
and city_name = #{terms.cityName}
|
</if>
|
<if test="terms.area != null and terms.area !=''">
|
and area = #{terms.area}
|
</if>
|
<if test="terms.areaName != null and terms.areaName !=''">
|
and area_name = #{terms.areaName}
|
</if>
|
<if test="terms.road != null and terms.road !=''">
|
and road = #{terms.road}
|
</if>
|
<if test="terms.roadName != null and terms.roadName !=''">
|
and road_name = #{terms.roadName}
|
</if>
|
<if test="terms.village != null and terms.village !=''">
|
and village = #{terms.village}
|
</if>
|
<if test="terms.villageName != null and terms.villageName !=''">
|
and village_name = #{terms.villageName}
|
</if>
|
<if test="terms.addr != null and terms.addr !=''">
|
and addr = #{terms.addr}
|
</if>
|
<if test="terms.avatar != null and terms.avatar !=''">
|
and avatar = #{terms.avatar}
|
</if>
|
<if test="terms.unitId != null and terms.unitId !=''">
|
and unit_id = #{terms.unitId}
|
</if>
|
<if test="terms.unitName != null and terms.unitName !=''">
|
and unit_name = #{terms.unitName}
|
</if>
|
<if test="terms.deptId != null and terms.deptId !=''">
|
and dept_id = #{terms.deptId}
|
</if>
|
<if test="terms.deptName != null and terms.deptName !=''">
|
and dept_name = #{terms.deptName}
|
</if>
|
<if test="terms.joinWay != null and terms.joinWay !=''">
|
and join_way = #{terms.joinWay}
|
</if>
|
<if test="terms.realStatus != null and terms.realStatus !=''">
|
and real_status = #{terms.realStatus}
|
</if>
|
<if test="terms.status != null and terms.status !=''">
|
and status = #{terms.status}
|
</if>
|
<if test="terms.goodField != null and terms.goodField !=''">
|
and good_field = #{terms.goodField}
|
</if>
|
<if test="terms.goodFieldName != null and terms.goodFieldName !=''">
|
and good_field_name = #{terms.goodFieldName}
|
</if>
|
<if test="terms.canField != null and terms.canField !=''">
|
and can_field = #{terms.canField}
|
</if>
|
<if test="terms.canFieldName != null and terms.canFieldName !=''">
|
and can_field_name = #{terms.canFieldName}
|
</if>
|
<if test="terms.findStatus != null and terms.findStatus !=''">
|
and find_status = #{terms.findStatus}
|
</if>
|
<if test="terms.dispStatus != null and terms.dispStatus !=''">
|
and disp_status = #{terms.dispStatus}
|
</if>
|
<if test="terms.deleteStatus = null and terms.deleteStatus =''">
|
and delete_status = 0
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and delete_status = #{terms.deleteStatus}
|
</if>
|
<if test="terms.custId != null and terms.custId !=''">
|
and cust_id = #{terms.custId}
|
</if>
|
<if test="terms.createTime != null and terms.createTime !=''">
|
and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
|
</if>
|
<if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
|
and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
|
and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
|
</if>
|
<if test="terms.updateTime != null and terms.updateTime !=''">
|
and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
|
</if>
|
<if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
|
and (DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.updateStart}
|
and DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.updateEnd})
|
</if>
|
</where>
|
</if>
|
</sql>
|
<!-- 更新对象 -->
|
<update id="updateCtUser">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
id = #{entity.id}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateCtUserTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteCtUser">
|
delete from
|
<include refid="table-name" />
|
where id = #{id}
|
</delete>
|
<!-- 根据条件查询 -->
|
<select id="listTerms" resultMap="dataResult">
|
select
|
<include refid="column-part"/>
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件统计 -->
|
<select id="countTerms" resultType="java.lang.Long">
|
select
|
COUNT(1)
|
from
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
</select>
|
<!-- 根据条件分页查询 -->
|
<select id="pageTerms" resultMap="dataResult">
|
SELECT
|
<include refid="column-part"/>
|
FROM
|
<include refid="table-name" />
|
<include refid="where-part"/>
|
<if test="page.sort != null">
|
<foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
|
isnull(${s.property}), ${s.property} ${s.direction}
|
</foreach>
|
</if>
|
<if test="page.sort == null">
|
order by isnull(create_time), create_time desc
|
</if>
|
limit #{page.offset}, #{page.size}
|
</select>
|
|
<!-- 根据条件统计 -->
|
<select id="countQueryCtUser" resultType="java.lang.Long">
|
SELECT COUNT(distinct t1.id)
|
FROM dyh_ct_user t1
|
LEFT JOIN dyh_ct_userole t2 on t1.id = t2.user_id
|
<if test="terms != null">
|
<where>
|
<if test="terms.trueName != null and terms.trueName !=''">
|
and t1.true_name like concat('%', #{terms.trueName}, '%')
|
</if>
|
<if test="terms.acc != null and terms.acc !=''">
|
and t1.acc like concat('%', #{terms.acc}, '%')
|
</if>
|
<if test="terms.unitId != null and terms.unitId !=''">
|
and t1.unit_id = #{terms.unitId}
|
</if>
|
<if test="terms.deptId != null and terms.deptId !=''">
|
and t1.dept_id = #{terms.deptId}
|
</if>
|
<if test="terms.status != null and terms.status !=''">
|
and t1.status = #{terms.status}
|
</if>
|
<if test="terms.deleteStatus = null and terms.deleteStatus =''">
|
and t1.delete_status = 0
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and t1.delete_status = #{terms.deleteStatus}
|
</if>
|
<if test="terms.roleId != null and terms.roleId !=''">
|
and t2.role_id = #{terms.roleId}
|
</if>
|
</where>
|
</if>
|
</select>
|
|
<!-- 根据条件分页查询 -->
|
<select id="pageQueryCtUser" resultMap="dataResult">
|
SELECT t1.*
|
FROM dyh_ct_user t1
|
LEFT JOIN dyh_ct_userole t2 on t1.id = t2.user_id
|
<if test="terms != null">
|
<where>
|
<if test="terms.trueName != null and terms.trueName !=''">
|
and t1.true_name like concat('%', #{terms.trueName}, '%')
|
</if>
|
<if test="terms.acc != null and terms.acc !=''">
|
and t1.acc like concat('%', #{terms.acc}, '%')
|
</if>
|
<if test="terms.unitId != null and terms.unitId !=''">
|
and t1.unit_id = #{terms.unitId}
|
</if>
|
<if test="terms.deptId != null and terms.deptId !=''">
|
and t1.dept_id = #{terms.deptId}
|
</if>
|
<if test="terms.status != null and terms.status !=''">
|
and t1.status = #{terms.status}
|
</if>
|
<if test="terms.deleteStatus = null and terms.deleteStatus =''">
|
and t1.delete_status = 0
|
</if>
|
<if test="terms.deleteStatus != null and terms.deleteStatus !=''">
|
and t1.delete_status = #{terms.deleteStatus}
|
</if>
|
<if test="terms.roleId != null and terms.roleId !=''">
|
and t2.role_id = #{terms.roleId}
|
</if>
|
<if test="terms.roleCode != null and terms.roleCode !=''">
|
and t2.role_code = #{terms.roleCode}
|
</if>
|
</where>
|
</if>
|
GROUP BY t1.id
|
<if test="page.sort != null">
|
<foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
|
isnull(${s.property}), ${s.property} ${s.direction}
|
</foreach>
|
</if>
|
<if test="page.sort == null">
|
order by isnull(t1.create_time), t1.create_time desc
|
</if>
|
limit #{page.offset}, #{page.size}
|
</select>
|
|
<!-- 根据部门和角色查询 -->
|
<select id="listUserByUnitRoleList" resultMap="dataResult">
|
SELECT t1.id, t1.true_name, t1.dept_id,t1.dept_name
|
FROM dyh_ct_user t1 LEFT JOIN dyh_ct_userole t2 ON t1.id = t2.user_id
|
WHERE
|
t1.delete_status = '0'
|
AND t2.role_code = #{roleCode}
|
AND t1.status = '1'
|
AND t1.unit_id = #{unitId}
|
</select>
|
|
<select id="selectByIdCard" resultMap="dataResult">
|
SELECT * FROM dyh_ct_user
|
WHERE
|
delete_status = '0'
|
and status = '1' and idcard=#{idCard}
|
</select>
|
</mapper>
|