Bonus-Cloud-Material/bonus-modules/bonus-material/src/main/resources/mapper/material/scrap/ScrapReasonMapper.xml

129 lines
4.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.bonus.material.scrap.mapper.ScrapReasonMapper">
<select id="levelTwolist" resultType="com.bonus.material.scrap.domain.ScrapReason">
select type_id as parentId,type_name as parentName
from ma_type mt
where level = 2 and del_flag = 0
</select>
<select id="levelThreelist" resultType="com.bonus.material.scrap.domain.ScrapReason">
select type_id as typeId,type_name as typeName
from ma_type mt
where parent_id = #{parentId} and del_flag = 0
</select>
<select id="selectScrapReasonList" resultType="com.bonus.material.scrap.domain.ScrapReason">
select
sc.id as id,sc.type_id as typeId,mt.type_name as typeName,mt1.type_id as parentId,mt1.type_name as parentName,
sc.update_time as updateTime,su.nick_name as updateBy,sc.reason as reason
from scrap_reason sc
left join ma_type mt on sc.type_id = mt.type_id and mt.del_flag = 0
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = 0
left join sys_user su on sc.update_by = su.user_id and su.del_flag = 0
where sc.del_flag = 0
<if test="keyWord != null and keyWord != ''">
AND (
mt1.type_name LIKE CONCAT('%',#{keyWord},'%')
OR mt.type_name LIKE CONCAT('%',#{keyWord},'%')
)
</if>
</select>
<insert id="insertScrapReasonInfo">
insert into scrap_reason
(
<if test="typeId != null">
type_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="updateBy != null and updateBy != ''">
update_by,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="reason != null and reason != ''">
reason,
</if>
del_flag
)
values (
<if test="typeId != null">
#{typeId},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="updateBy != null and updateBy != ''">
#{updateBy},
</if>
<if test="remark != null and remark != ''">
#{remark},
</if>
<if test="reason != null and reason != ''">
#{reason},
</if>
0
)
</insert>
<select id="selectScrapReasonById" resultType="com.bonus.material.scrap.domain.ScrapReason">
select
sc.id as id,sc.type_id as typeId,mt.type_name as typeName,mt1.type_id as parentId,mt1.type_name as parentName,
sc.update_time as updateTime,sc.update_by as updateBy,sc.reason as reason
from scrap_reason sc
left join ma_type mt on sc.type_id = mt.type_id and mt.del_flag = 0
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = 0
where sc.del_flag = 0
<if test="id != null ">
AND sc.id = #{id}
</if>
</select>
<update id="updateScrapReasonInfo">
update scrap_reason
set type_id = #{typeId},
update_by = #{updateBy},
update_time = #{updateTime},
reason = #{reason}
where id = #{id} and del_flag = 0
</update>
<update id="deleteScrapReasonInfo">
update scrap_reason
set del_flag = 1
where id = #{id} and del_flag = 0
</update>
<!-- <delete id="deleteScrapApplyDetailsById" parameterType="Long">-->
<!-- delete from scrap_apply_details where id = #{id}-->
<!-- </delete>-->
</mapper>