btyjj-inspection/src/main/resources/mybatis/mapper/checkitem/checkitem-mapper.xml

174 lines
5.3 KiB
XML
Raw Normal View History

2020-03-26 00:00:48 +08:00
<?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.cm.inspection.dao.checkitem.ICheckItemDao">
<resultMap id="checkItemDTO" type="com.cm.inspection.pojo.dtos.checkitem.CheckItemDTO">
<id column="check_item_id" property="checkItemId"/>
2020-04-14 18:45:30 +08:00
<result column="check_item_parent_id" property="checkItemParentId"/>
<result column="type" property="type"/>
2020-03-26 00:00:48 +08:00
<result column="name" property="name"/>
2020-04-14 18:45:30 +08:00
<result column="parent_name" property="parentName"/>
2020-03-26 00:00:48 +08:00
<result column="summary" property="summary"/>
</resultMap>
2020-04-14 18:45:30 +08:00
<resultMap id="checkItemZTreeDTO" type="com.cm.common.pojo.dtos.ZTreeDTO">
<id property="id" column="check_item_id"/>
<result property="pId" column="check_item_parent_id"/>
<result property="name" column="name"/>
</resultMap>
2020-03-26 00:00:48 +08:00
<!-- 新增检查项 -->
<insert id="saveCheckItem" parameterType="map">
INSERT INTO gen_check_item(
check_item_id,
2020-04-14 18:45:30 +08:00
check_item_parent_id,
type,
2020-03-26 00:00:48 +08:00
name,
summary,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{checkItemId},
2020-04-14 18:45:30 +08:00
#{checkItemParentId},
#{type},
2020-03-26 00:00:48 +08:00
#{name},
#{summary},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除检查项 -->
<update id="removeCheckItem" parameterType="map">
UPDATE
gen_check_item
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
check_item_id IN
<foreach collection="checkItemIds" index="index" open="(" separator="," close=")">
#{checkItemIds[${index}]}
</foreach>
</update>
<!-- 修改检查项 -->
<update id="updateCheckItem" parameterType="map">
UPDATE
gen_check_item
SET
2020-04-14 18:45:30 +08:00
<if test="checkItemParentId != null and checkItemParentId != ''">
check_item_parent_id = #{checkItemParentId},
</if>
<if test="type != null and type != ''">
type = #{type},
</if>
2020-03-26 00:00:48 +08:00
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="summary != null and summary != ''">
summary = #{summary},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
check_item_id = #{checkItemId}
</update>
<!-- 检查项详情 -->
<select id="getCheckItem" parameterType="map" resultMap="checkItemDTO">
SELECT
t1.name,
2020-04-14 18:45:30 +08:00
t2.name parent_name,
2020-03-26 00:00:48 +08:00
t1.summary,
2020-04-14 18:45:30 +08:00
t1.type,
t1.check_item_parent_id,
2020-03-26 00:00:48 +08:00
t1.check_item_id
FROM
gen_check_item t1
2020-04-14 18:45:30 +08:00
LEFT JOIN
gen_check_item t2
ON
t1.check_item_parent_id = t2.check_item_id
2020-03-26 00:00:48 +08:00
WHERE
t1.is_delete = 0
<if test="checkItemId != null and checkItemId != ''">
AND
t1.check_item_id = #{checkItemId}
</if>
</select>
<!-- 检查项列表 -->
<select id="listCheckItem" parameterType="map" resultMap="checkItemDTO">
SELECT
t1.name,
t1.summary,
2020-04-14 18:45:30 +08:00
t1.type,
t1.check_item_parent_id,
2020-03-26 00:00:48 +08:00
t1.check_item_id
FROM
gen_check_item t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
<!-- 这里添加检索关键字 -->
</if>
2020-04-14 18:45:30 +08:00
<if test="checkItemParentId != null and checkItemParentId != ''">
AND
check_item_parent_id = #{checkItemParentId}
</if>
<if test="type != null">
AND
type = #{type}
</if>
2020-03-26 00:00:48 +08:00
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="checkItemIds != null and checkItemIds.size > 0">
AND
t1.check_item_id IN
<foreach collection="checkItemIds" index="index" open="(" separator="," close=")">
#{checkItemIds[${index}]}
</foreach>
</if>
</select>
2020-04-14 18:45:30 +08:00
<!-- ztree列表 -->
<select id="listZTreeCheckItem" parameterType="map" resultMap="checkItemZTreeDTO">
SELECT
*
FROM
gen_check_item
WHERE
is_delete = 0
<if test="checkItemParentId != null and checkItemParentId != ''">
AND
check_item_parent_id = #{checkItemParentId}
</if>
</select>
<!-- 通过上级ID统计下级数量 -->
<select id="countByParentId" parameterType="String" resultType="Integer">
SELECT
COUNT(*)
FROM
gen_check_item
WHERE
is_delete = 0
AND
check_item_parent_id = #{_parameter}
</select>
2020-03-26 00:00:48 +08:00
</mapper>