<?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-10-17 17:31:46
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.ctuser.dao.mapper.CtDeptMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.ctuser.domain.po.CtDept">
|
<result property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="des" column="des"/>
|
<result property="type" column="type"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="unitId" column="unit_id"/>
|
<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="level" column="level"/>
|
<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_dept</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
id,
|
name,
|
des,
|
type,
|
parent_id,
|
unit_id,
|
good_field,
|
good_field_name,
|
can_field,
|
can_field_name,
|
level,
|
delete_status,
|
cust_id,
|
create_time,
|
update_time
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.name != null">name = #{entity.name},</if>
|
<if test="entity.des != null">des = #{entity.des},</if>
|
<if test="entity.type != null">type = #{entity.type},</if>
|
<if test="entity.parentId != null">parent_id = #{entity.parentId},</if>
|
<if test="entity.unitId != null">unit_id = #{entity.unitId},</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.level != null">level = #{entity.level},</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.name != null and terms.name !=''">
|
and name = #{terms.name}
|
</if>
|
<if test="terms.des != null and terms.des !=''">
|
and des = #{terms.des}
|
</if>
|
<if test="terms.type != null and terms.type !=''">
|
and type = #{terms.type}
|
</if>
|
<if test="terms.parentId != null and terms.parentId !=''">
|
and parent_id = #{terms.parentId}
|
</if>
|
<if test="terms.unitId != null and terms.unitId !=''">
|
and unit_id = #{terms.unitId}
|
</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.level != null and terms.level !=''">
|
and level = #{terms.level}
|
</if>
|
<if test="terms.deleteStatus = null and terms.deleteStatus =''">
|
and delete_status = '1'
|
</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="updateCtDept">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
id = #{entity.id}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateCtDeptTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteCtDept">
|
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>
|
|
</mapper>
|