You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udi-spms-java/src/main/resources/mybatis/mapper/thrsys/ThrDeptDao.xml

272 lines
9.2 KiB
XML

<?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.glxp.api.dao.thrsys.ThrDeptDao">
<select id="filterThrInvWarehouse" parameterType="com.glxp.api.req.thrsys.FilterThrDeptRequest"
resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
SELECT *
FROM thr_dept thrInv
left join thr_system thrSys on thrInv.thirdSysFk = thrSys.thirdId
<where>
thrSys.enabled = true
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="pid != '' and pid != null">
AND pid = #{pid}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND name = #{name}
</if>
<if test="advanceType != null">
AND advanceType = #{advanceType}
</if>
<if test="isDefault != null">
AND isDefault = #{isDefault}
</if>
<if test="key != null">
and (code like concat('%', #{key}, '%')
or `name` like concat('%', #{key}, '%'))
</if>
<if test="lastUpdateTime != null and lastUpdateTime != ''">
<![CDATA[
and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S')
]]>
</if>
<if test="thirdSysFk != null">
and thirdSysFk = #{thirdSysFk}
</if>
<if test="status != null">
and status = #{status}
</if>
</where>
</select>
<select id="selectById" parameterType="Map"
resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
SELECT *
FROM thr_dept
WHERE id = #{id}
</select>
<select id="filterThrGroupInvWarehouse" parameterType="com.glxp.api.req.thrsys.FilterThrDeptRequest"
resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
SELECT *
FROM thr_dept
<where>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="pid != '' and pid != null">
AND pid = #{pid}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND name = #{name}
</if>
<if test="advanceType != '' and advanceType != null">
AND advanceType = #{advanceType}
</if>
<if test="isDefault != '' and isDefault != null">
AND isDefault = #{isDefault}
</if>
<if test="thirdSysFk != null">
AND thirdSysFk = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertThrInvWarehouse" keyProperty="id"
parameterType="com.glxp.api.entity.thrsys.ThrDeptEntity">
replace
INTO thr_dept
(id,pid, code, name, advanceType, isDefault,
status, updateTime, remark, thirdSysFk)
values (
#{id},
#{pid},
#{code},
#{name},
#{advanceType},
#{isDefault},
#{status},
#{updateTime},
#{remark},
#{thirdSysFk}
)
</insert>
<insert id="insertThrInvWarehouses" parameterType="java.util.List">
replace INTO thr_dept
(pid, code, name, advanceType, isDefault,
status, updateTime, remark, thirdSysFk)
VALUES
<foreach collection="thrDeptEntities" item="item" index="index"
separator=",">
(#{item.pid}, #{item.code},
#{item.name}, #{item.advanceType}, #{item.isDefault},
#{item.status}, #{item.updateTime},
#{item.remark}, #{item.thirdSysFk})
</foreach>
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM thr_dept
WHERE id = #{id}
</delete>
<update id="updateThrInvWarehouse" parameterType="com.glxp.api.entity.thrsys.ThrDeptEntity">
UPDATE thr_dept
<trim prefix="set" suffixOverrides=",">
<if test="pid != null">
pid=#{pid},
</if>
<if test="name != null">
name=#{name},
</if>
<if test="code != null">
code=#{code},
</if>
<if test="advanceType != null">
advanceType=#{advanceType},
</if>
<if test="isDefault != null">
isDefault=#{isDefault},
</if>
<if test="status != null">
status=#{status},
</if>
<if test="updateTime != null">
updateTime=#{updateTime},
</if>
<if test="remark != null">
remark=#{remark},
</if>
<if test="thirdSysFk != null">
thirdSysFk=#{thirdSysFk},
</if>
</trim>
WHERE id = #{id}
</update>
<select id="selectByCode" resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
select *
from thr_dept
where code = #{code}
and thirdSysFk = #{thirdSysFk}
</select>
<select id="selectMaxCode" resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
select max(code) as code
from thr_dept
<where>
<if test="id != '' and id != null">
AND id = #{id}
</if>
<if test="pid != '' and pid != null">
AND pid = #{pid}
</if>
<if test="code != '' and code != null">
AND code = #{code}
</if>
<if test="name != '' and name != null">
AND name = #{name}
</if>
<if test="advanceType != null">
AND advanceType = #{advanceType}
</if>
<if test="isDefault != null">
AND isDefault = #{isDefault}
</if>
<if test="pcode != null">
AND pcode = #{pcode}
</if>
<if test="level != null">
AND `level` = #{level}
</if>
<if test="thirdSysFk != null">
AND `thirdSysFk` = #{thirdSysFk}
</if>
</where>
</select>
<insert id="insertInvWarehouses">
replace into thr_dept (pid, code, `name`, advanceType, isDefault, status, updateTime, remark, `level`,
pcode,
thirdSysFk)
values
<foreach collection="thrDeptEntities" index="index" item="item" separator=",">
(#{item.pid},
#{item.code},
#{item.name},
#{item.advanceType},
#{item.isDefault},
#{item.status},
#{item.updateTime},
#{item.remark},
#{item.level},
#{item.pcode},
#{item.thirdSysFk})
</foreach>
</insert>
<insert id="insertOrUpdateEntity" keyColumn="id" keyProperty="id" parameterType="com.glxp.api.entity.thrsys.ThrDeptEntity"
useGeneratedKeys="true">
insert into thr_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
pId,
code,
`name`,
advanceType,
isDefault,
`status`,
updateTime,
remark,
`level`,
pcode,
thirdSysFk,
</trim>
values
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
#{pId,jdbcType=INTEGER},
#{code,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR},
#{advanceType,jdbcType=VARCHAR},
#{isDefault,jdbcType=TINYINT},
#{status,jdbcType=TINYINT},
#{updateTime,jdbcType=TIMESTAMP},
#{remark,jdbcType=VARCHAR},
#{level,jdbcType=TINYINT},
#{pcode,jdbcType=VARCHAR},
#{thirdSysFk,jdbcType=VARCHAR},
</trim>
on duplicate key update
<trim suffixOverrides=",">
<if test="id != null">
id = #{id,jdbcType=INTEGER},
</if>
pId = #{pId,jdbcType=INTEGER},
code = #{code,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
advanceType = #{advanceType,jdbcType=VARCHAR},
isDefault = #{isDefault,jdbcType=TINYINT},
`status` = #{status,jdbcType=TINYINT},
updateTime = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR},
`level` = #{level,jdbcType=TINYINT},
pcode = #{pcode,jdbcType=VARCHAR},
thirdSysFk = #{thirdSysFk,jdbcType=VARCHAR},
</trim>
</insert>
</mapper>