<?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">
|
<!--
|
namespace:必须与对应的接口全类名一致
|
id:必须与对应接口的某个对应的方法名一致
|
|
-->
|
<mapper namespace="com.basic.x01.securityCheck.mapper.SecurityCheckMapper">
|
<resultMap id="TbSecurityType" type="TbSecurityType">
|
<id property="typeId" column="type_id" />
|
<result property="orgId" column="org_id" />
|
<result property="typeName" column="type_name" />
|
<result property="createTime" column="create_time" />
|
<result property="itemCount" column="item_count" />
|
</resultMap>
|
|
<resultMap id="TbSecurityCheckItem" type="TbSecurityCheckItem">
|
<id property="itemId" column="item_id" />
|
<result property="typeId" column="type_id" />
|
<result property="orgId" column="org_id" />
|
<result property="typeName" column="type_name" />
|
<result property="itemName" column="item_name" />
|
<result property="itemContent" column="item_content" />
|
<result property="createTime" column="create_time" />
|
<result property="checkWay" column="check_way" />
|
</resultMap>
|
|
<delete id="deleteUnusedTbSecurityCheckItem">
|
delete from tb_security_check_item
|
where org_id=#{orgId} and item_id=#{itemId}
|
</delete>
|
<update id="updateTbSecurityCheckItem" parameterType="TbSecurityCheckItem">
|
update tb_security_check_item
|
set type_id=#{typeId}, item_name=#{itemName},
|
item_content=#{itemContent}, check_way=#{checkWay}
|
where item_id=#{itemId} and org_id=#{orgId}
|
</update>
|
<select id="getTbSecurityCheckItem" resultMap="TbSecurityCheckItem">
|
select i.*, (select type_name from tb_security_type where type_id=i.type_id limit 1)
|
as type_name
|
from tb_security_check_item i
|
where i.item_id=#{0}
|
</select>
|
<select id="checkSameTbSecurityCheckItem" parameterType="TbSecurityCheckItem" resultType="int">
|
select count(0) from tb_security_check_item
|
where org_id=#{orgId} and type_id=#{typeId} and item_name=#{itemName}
|
<if test="itemId !=null and itemId !=''">
|
and item_id !=#{itemId}
|
</if>
|
</select>
|
|
<insert id="insertTbSecurityCheckItem" parameterType="TbSecurityCheckItem">
|
<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="itemId">
|
select replace(uuid(), '-', '') as itemId
|
</selectKey>
|
insert into tb_security_check_item(item_id, type_id, org_id,
|
item_name, item_content, create_time, check_way,
|
create_user_id)
|
values (#{itemId}, #{typeId}, #{orgId}, #{itemName}, #{itemContent},
|
date_format(now(),'%Y-%m-%d %H:%i:%S'), #{checkWay},
|
#{createUserId}
|
)
|
</insert>
|
|
<select id="checkSameTbSeucrityType" parameterType="TbSecurityType" resultType="int">
|
select count(0) from tb_security_type
|
where org_id=#{orgId} and type_name=#{typeName}
|
<if test="typeId !=null and typeId !='' ">
|
and type_id != #{typeId}
|
</if>
|
</select>
|
|
<insert id="insertTbSecurityType" parameterType="TbSecurityType">
|
<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="typeId">
|
select replace(uuid(), '-', '') as typeId
|
</selectKey>
|
|
insert into tb_security_type(type_id, org_id, type_name, create_time,
|
create_user_id
|
)
|
values(#{typeId}, #{orgId}, #{typeName}, date_format(now(),'%Y-%m-%d %H:%i:%S'),
|
#{createUserId}
|
)
|
</insert>
|
|
<update id="updateTbSecurityType" parameterType="TbSecurityType">
|
update tb_security_type
|
set type_name=#{typeName}
|
where type_id=#{typeId} and org_id=#{orgId}
|
</update>
|
|
<delete id="deleteUnusedTbSecurityType">
|
delete from tb_security_type
|
where org_id=#{orgId} and type_id not in
|
<foreach item="item" index="index" collection="typeList"
|
open="(" separator="," close=")">
|
#{item.typeId}
|
</foreach>
|
and not exists (select 1 from tb_security_check_item i
|
where i.type_id=tb_security_type.type_id
|
)
|
</delete>
|
|
<select id="getSecurityType" resultMap="TbSecurityType">
|
select * from tb_security_type
|
where org_id=#{0}
|
order by create_time
|
</select>
|
|
<select id="getSecurityType4Edit" resultMap="TbSecurityType">
|
select t.*, (select count(0) from tb_security_check_item i
|
where i.org_id=t.org_id and i.type_id=t.type_id
|
) as item_count
|
from tb_security_type t
|
where org_id=#{0}
|
order by create_time
|
</select>
|
|
<select id="getSecurityCheckItemList" resultMap="TbSecurityCheckItem">
|
select i.*, (select type_name from tb_security_type where type_id=i.type_id limit 1)
|
as type_name
|
from tb_security_check_item i
|
where org_id=#{orgId}
|
<if test="typeId != null and typeId !=''">
|
and type_id=#{typeId}
|
</if>
|
<if test="itemContent !=null and itemContent !=''">
|
and (instr(item_name, #{itemContent})>0 or
|
instr(item_content, #{itemContent})>0)
|
</if>
|
order by create_time
|
</select>
|
</mapper>
|