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/auth/DeptDao.xml

287 lines
9.7 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.auth.DeptDao">
<select id="filterInvWarehouse" parameterType="com.glxp.api.req.auth.FilterInvWarehouseRequest"
resultType="com.glxp.api.entity.auth.DeptEntity">
select * ,(select name from auth_dept WHERE a.pcode = code) pName
FROM auth_dept a
<where>
<if test="id != '' and id != null">
AND a.id = #{id}
</if>
<if test="pid != '' and pid != null">
AND a.pid = #{pid}
</if>
<if test="code != '' and code != null">
AND a.code = #{code}
</if>
<if test="name != '' and name != null">
AND a.name like concat('%',#{name},'%')
</if>
<if test="advanceType != null">
AND a.advanceType = #{advanceType}
</if>
<if test="status != null">
AND a.status = #{status}
</if>
<if test="isDefault != null">
AND a.isDefault = #{isDefault}
</if>
<if test="pcode != null">
AND a.pcode = #{pcode}
</if>
<if test="level != null">
AND a.level = #{level}
</if>
<if test="spUse != null">
AND a.spUse = #{spUse}
</if>
</where>
</select>
<select id="filterAllByUser" parameterType="com.glxp.api.req.auth.FilterInvWarehouseRequest"
resultType="com.glxp.api.entity.auth.DeptEntity">
select auth_dept.* from auth_dept INNER JOIN auth_warehouse
on auth_dept.`code` =auth_warehouse.parentId
INNER JOIN auth_warehouse_user on auth_warehouse_user.`code` = auth_warehouse.code
<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 auth_dept.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="userId != null">
AND auth_warehouse_user.userId = #{userId}
</if>
<if test="level != null">
AND `level` = #{level}
</if>
<if test="spUse != null">
AND auth_dept.spUse = #{spUse}
</if>
</where>
group by auth_dept.code
</select>
<select id="selectById" parameterType="Map"
resultType="com.glxp.api.entity.auth.DeptEntity">
SELECT *
FROM auth_dept
WHERE id = #{id}
</select>
<select id="selectMaxCode" parameterType="com.glxp.api.req.auth.FilterInvWarehouseRequest"
resultType="com.glxp.api.entity.auth.DeptEntity">
select max(code) as code from auth_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>
</where>
</select>
<select id="filterGroupInvWarehouse" parameterType="com.glxp.api.req.auth.FilterInvWarehouseRequest"
resultType="com.glxp.api.entity.auth.DeptEntity">
SELECT * FROM auth_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="pcode != null">
AND pcode = #{pcode}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="spUse != null">
AND spUse = #{spUse}
</if>
<if test="updateTime!=null and updateTime!=''">
<![CDATA[ and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S')>= DATE_FORMAT(#{updateTime}, '%Y-%m-%d %H:%i:%S') ]]>
</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>
</where>
</select>
<select id="getNameByCode" resultType="java.lang.String">
select name
from auth_dept
where code = #{fromCorpId}
</select>
<select id="getIdByCode" resultType="java.lang.Long">
select id
from auth_dept
where id = #{fromCorpId}
</select>
<insert id="insertInvWarehouse" keyProperty="id"
parameterType="com.glxp.api.entity.auth.DeptEntity">
replace
INTO auth_dept
(pid, code, `name`, advanceType, isDefault,
status, updateTime, remark,`level`,pcode,spUse, thirdId, thirdId1, thirdId2, thirdId3, thirdId4)
values (
#{pid},
#{code},
#{name},
#{advanceType},
#{isDefault},
#{status},
#{updateTime},
#{remark},
#{level},
#{pcode},
#{spUse},
#{thirdId},
#{thirdId1},
#{thirdId2},
#{thirdId3},
#{thirdId4}
)
</insert>
<delete id="deleteById" parameterType="Map">
DELETE
FROM auth_dept
WHERE id = #{id}
</delete>
<update id="updateInvWarehouse" parameterType="com.glxp.api.entity.auth.DeptEntity">
UPDATE auth_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="level != null">level=#{level},</if>
<if test="pcode != null">pcode=#{pcode},</if>
<if test="thirdId != null">remark=#{thirdId},</if>
<if test="thirdId1 != null">remark=#{thirdId1},</if>
<if test="thirdId2 != null">remark=#{thirdId2},</if>
<if test="thirdId3 != null">remark=#{thirdId3},</if>
<if test="thirdId4 != null">remark=#{thirdId4},</if>
<if test="spUse != null">spUse=#{spUse},</if>
</trim>
WHERE id = #{id}
</update>
<insert id="importInvWarehouse" parameterType="java.util.List">
replace into auth_dept (id, pid, code, `name`, advanceType, isDefault, status,
updateTime, remark, `level`, pcode, thirdId, thirdId1, thirdId2, thirdId3,
thirdId4,spUse) values
<foreach collection="invWarehouseEntities" item="item" index="index" separator=",">
(#{item.id},
#{item.pid},
#{item.code},
#{item.name},
#{item.advanceType},
#{item.isDefault},
#{item.status},
#{item.updateTime},
#{item.remark}, #{item.level},
#{item.pcode}, #{item.thirdId},
#{item.thirdId1}, #{item.thirdId2},
#{item.thirdId3}, #{item.thirdId4},#{item.spUse})
</foreach>
</insert>
<update id="updateThridId" parameterType="Map">
update auth_dept
set ${sysId} = #{thridWarehouseId,jdbcType=VARCHAR}
where id = #{id}
</update>
<update id="updateTime" parameterType="Map">
update auth_dept
SET updateTime = #{updateTime}
where code = #{code}
</update>
<select id="selectByThirdSys" resultType="com.glxp.api.entity.auth.DeptEntity">
select *
from auth_dept
where ${thirdIdSys} = #{thirdId}
</select>
<select id="selectByCodeAll" resultType="com.glxp.api.entity.auth.DeptEntity">
select *
from auth_dept
where code = #{code}
</select>
<select id="selectNameByCode" resultType="java.lang.String">
select name from auth_dept where code = #{code}
</select>
</mapper>