<?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-12-18 11:40:51
|
* @version 1.0.0
|
-->
|
<mapper namespace="cn.huge.module.syncgrid.dao.mapper.ThGridUnitMapper">
|
<!-- 结果集 -->
|
<resultMap id="dataResult" type="cn.huge.module.syncgrid.domain.po.ThGridUnit">
|
<result property="id" column="id"/>
|
<result property="thirdSysId" column="third_sys_id"/>
|
<result property="thirdSysName" column="third_sys_name"/>
|
<result property="thirdUnitId" column="third_unit_id"/>
|
<result property="thirdGridCode" column="third_grid_code"/>
|
<result property="thirdUnitCode" column="third_unit_code"/>
|
<result property="thirdUnitName" column="third_unit_name"/>
|
<result property="thirdParentCode" column="third_parent_code"/>
|
<result property="dyhUnitId" column="dyh_unit_id"/>
|
<result property="unitCode" column="unit_code"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
<!-- 表 -->
|
<sql id='table-name'>dyh_th_grid_unit</sql>
|
<!-- 字段 -->
|
<sql id="column-part">
|
id,
|
third_sys_id,
|
third_sys_name,
|
third_unit_id,
|
third_grid_code,
|
third_unit_code,
|
third_unit_name,
|
third_parent_code,
|
dyh_unit_id,
|
unit_code,
|
create_time,
|
update_time
|
</sql>
|
<!-- 更新实体字段 -->
|
<sql id="set-part">
|
<if test="entity.thirdSysId != null">third_sys_id = #{entity.thirdSysId},</if>
|
<if test="entity.thirdSysName != null">third_sys_name = #{entity.thirdSysName},</if>
|
<if test="entity.thirdUnitId != null">third_unit_id = #{entity.thirdUnitId},</if>
|
<if test="entity.thirdGridCode != null">third_grid_code = #{entity.thirdGridCode},</if>
|
<if test="entity.thirdUnitCode != null">third_unit_code = #{entity.thirdUnitCode},</if>
|
<if test="entity.thirdUnitName != null">third_unit_name = #{entity.thirdUnitName},</if>
|
<if test="entity.thirdParentCode != null">third_parent_code = #{entity.thirdParentCode},</if>
|
<if test="entity.dyhUnitId != null">dyh_unit_id = #{entity.dyhUnitId},</if>
|
<if test="entity.unitCode != null">unit_code = #{entity.unitCode},</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.thirdSysId != null and terms.thirdSysId !=''">
|
and third_sys_id = #{terms.thirdSysId}
|
</if>
|
<if test="terms.thirdSysName != null and terms.thirdSysName !=''">
|
and third_sys_name = #{terms.thirdSysName}
|
</if>
|
<if test="terms.thirdUnitId != null and terms.thirdUnitId !=''">
|
and third_unit_id = #{terms.thirdUnitId}
|
</if>
|
<if test="terms.thirdGridCode != null and terms.thirdGridCode !=''">
|
and third_grid_code = #{terms.thirdGridCode}
|
</if>
|
<if test="terms.thirdUnitCode != null and terms.thirdUnitCode !=''">
|
and third_unit_code = #{terms.thirdUnitCode}
|
</if>
|
<if test="terms.thirdUnitName != null and terms.thirdUnitName !=''">
|
and third_unit_name = #{terms.thirdUnitName}
|
</if>
|
<if test="terms.thirdParentCode != null and terms.thirdParentCode !=''">
|
and third_parent_code = #{terms.thirdParentCode}
|
</if>
|
<if test="terms.dyhUnitId != null and terms.dyhUnitId !=''">
|
and dyh_unit_id = #{terms.dyhUnitId}
|
</if>
|
<if test="terms.unitCode != null and terms.unitCode !=''">
|
and unit_code = #{terms.unitCode}
|
</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="updateThGridUnit">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<where>
|
id = #{entity.id}
|
</where>
|
</update>
|
<!-- 条件更新对象 -->
|
<update id="updateThGridUnitTerms">
|
update
|
<include refid="table-name"/>
|
<set>
|
<include refid="set-part"/>
|
</set>
|
<include refid="where-part"/>
|
</update>
|
<!-- 根据编号物理删除 -->
|
<delete id="deleteThGridUnit">
|
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>
|