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

241 lines
8.4 KiB
XML

2 years ago
<?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
2 years ago
<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}, '%'))
2 years ago
</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
2 years ago
<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
2 years ago
(pid, code, name, advanceType, isDefault,
status, updateTime, remark, thirdSysFk)
values (#{pid},
#{code},
#{name},
#{advanceType},
#{isDefault},
#{status},
#{updateTime},
#{remark},
#{thirdSysFk})
2 years ago
</insert>
<insert id="insertThrInvWarehouses" parameterType="java.util.List">
replace INTO thr_dept
(pid, code, name, advanceType, isDefault,
status, updateTime, remark, thirdSysFk)
2 years ago
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})
2 years ago
</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>
2 years ago
</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}
2 years ago
</select>
<select id="selectMaxCode" resultType="com.glxp.api.entity.thrsys.ThrDeptEntity">
select max(code) as code
from thr_dept
2 years ago
<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">
2 years ago
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)
2 years ago
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})
2 years ago
</foreach>
</insert>
<update id="insertOrUpdate" parameterType="com.glxp.api.entity.thrsys.ThrDeptEntity">
<selectKey keyProperty="id" resultType="Integer" order="BEFORE">
select id
from thr_dept
where id = #{id}
</selectKey>
<if test="id != null">
update thr_dept
set pId = #{pid},
name = #{name},
code = #{code},
advanceType = #{advanceType},
isDefault = #{isDefault},
status = #{status},
updateTime = #{updateTime},
remark = #{remark},
level = #{level},
pcode = #{pcode},
thirdSysFk = #{thirdSysFk}
where id = #{id};
</if>
<if test="id == null">
insert into thr_dept(id, pId, code, name, advanceType, isDefault, status, updateTime, remark, level, pcode,
thirdSysFk)
values (#{id}, #{pid}, #{code}, #{name}, #{advanceType}, #{isDefault}, #{status}, #{updateTime}, #{remark},
#{level}, #{pcode}, #{thirdSysFk})
</if>
</update>
2 years ago
</mapper>