<?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:47
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.ctuser.dao.mapper.CtUsepostMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.ctuser.domain.po.CtUsepost">
|
<result property="id" column="id"/>
|
<result property="userId" column="user_id"/>
|
<result property="postId" column="post_id"/>
|
<result property="postName" column="post_name"/>
|
<result property="unitId" column="unit_id"/>
|
<result property="deptId" column="dept_id"/>
|
<result property="matchType" column="match_type"/>
|
<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_usepost</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
id,
|
user_id,
|
post_id,
|
post_name,
|
unit_id,
|
dept_id,
|
match_type,
|
cust_id,
|
create_time,
|
update_time
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.userId != null">user_id = #{entity.userId},</if>
|
<if test="entity.postId != null">post_id = #{entity.postId},</if>
|
<if test="entity.postName != null">post_name = #{entity.postName},</if>
|
<if test="entity.unitId != null">unit_id = #{entity.unitId},</if>
|
<if test="entity.deptId != null">dept_id = #{entity.deptId},</if>
|
<if test="entity.matchType != null">match_type = #{entity.matchType},</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.userId != null and terms.userId !=''">
|
and user_id = #{terms.userId}
|
</if>
|
<if test="terms.postId != null and terms.postId !=''">
|
and post_id = #{terms.postId}
|
</if>
|
<if test="terms.postName != null and terms.postName !=''">
|
and post_name = #{terms.postName}
|
</if>
|
<if test="terms.unitId != null and terms.unitId !=''">
|
and unit_id = #{terms.unitId}
|
</if>
|
<if test="terms.deptId != null and terms.deptId !=''">
|
and dept_id = #{terms.deptId}
|
</if>
|
<if test="terms.matchType != null and terms.matchType !=''">
|
and match_type = #{terms.matchType}
|
</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="updateCtUsepost">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
id = #{entity.id}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateCtUsepostTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteCtUsepost">
|
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>
|