123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?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.zhyc.xps.sys.mapper.ChecklistTargetMapper">
- <resultMap id="ChecklistDtoResultMap" type="com.zhyc.xps.common.dto.ChecklistDto">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--单位ID-->
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT" /><!--清单ID-->
- <result column="checklist_cat_id" property="checklistCatId" jdbcType="BIGINT" />
- <result column="checklist_cat_title" property="checklistCatTitle" jdbcType="VARCHAR" />
- <result column="checklist_type_id" property="checklistTypeId" jdbcType="BIGINT" />
- <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
- <result column="checklist_desc" property="checklistDesc" jdbcType="VARCHAR" />
- <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
- <result column="issued_at" property="issuedAt" jdbcType="TIMESTAMP"/>
- <result column="author" property="author" jdbcType="VARCHAR" />
- <result column="status" property="status" jdbcType="BIGINT" />
- <result column="version" property="version" jdbcType="VARCHAR" />
- <result column="issued_account_id" property="issuedAccountId" jdbcType="BIGINT" />
- <result column="issued_account_name" property="issuedAccountName" jdbcType="VARCHAR" />
- </resultMap>
- <sql id="ChecklistDto_Cols">
- A.oc_id,
- A.checklist_id,
- B.checklist_cat_id,
- B.checklist_type_id,
- C.checklist_cat_title,
- B.checklist_desc,
- B.checklist_title,
- B.is_fixed,
- D.account_name AS issued_account_name,
- B.issued_by AS issued_account_id,
- B.issued_at,
- B.author,
- B.status,
- B.version
- </sql>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="ChecklistDtoResultMap">
- SELECT
- <include refid="ChecklistDto_Cols"/>
- FROM checklist_target AS A
- LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- LEFT JOIN checklist_cat AS C ON (B.oc_id = C.oc_id AND B.checklist_cat_id = C.checklist_cat_id)
- LEFT JOIN account AS D ON (B.oc_id = D.oc_id AND B.issued_by = D.account_id)
- WHERE 1 = 1
- <if test="ocId != null">
- AND A.oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId,jdbcType=BIGINT}
- </if>
- <if test="targetId != null">
- AND A.target_id = #{targetId,jdbcType=BIGINT}
- </if>
- <if test="targetType != null">
- AND A.target_type = #{targetType,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND B.checklist_title like "%"#{keywords}"%"
- </if>
- ORDER BY A.checklist_id
- </select>
- <!--获取选择列表-->
- <select id="getBySelect" resultMap="ChecklistDtoResultMap" parameterType="java.util.Map">
- SELECT
- A.oc_id,
- A.checklist_id,
- A.checklist_type_id,
- B.checklist_cat_title,
- A.checklist_desc,
- A.checklist_title,
- A.is_fixed,
- C.account_name AS issued_account_name,
- A.issued_by AS issued_account_id,
- A.issued_at,
- A.author,
- A.status,
- A.version
- FROM checklist AS A
- LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
- LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
- WHERE A.deleted_flag = 0 AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- AND NOT EXISTS (
- SELECT
- *
- FROM checklist_target AS D
- WHERE A.oc_id = D.oc_id AND A.checklist_id = D.checklist_id AND D.target_id = #{targetId ,jdbcType=BIGINT}
- )
- <if test="checklistId !=null">
- AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="keywords != null and keywords != ''">
- AND A.checklist_title like "%"#{keywords}"%"
- </if>
- <if test="checklistTypeId != null">
- AND A.checklist_type_id = #{checklistTypeId ,jdbcType=BIGINT}
- </if>
- <if test="status != null">
- AND A.status = #{status ,jdbcType=BIGINT}
- </if>
- ORDER BY A.checklist_id
- </select>
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.ChecklistTarget">
- INSERT INTO checklist_target
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="checklistId != null">
- checklist_Id,
- </if>
- <if test="targetId != null">
- target_id,
- </if>
- <if test="targetType != null">
- target_type,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId, jdbcType=BIGINT},
- </if>
- <if test="checklistId != null">
- #{checklistId, jdbcType=BIGINT},
- </if>
- <if test="targetId != null">
- #{targetId, jdbcType=BIGINT},
- </if>
- <if test="targetType != null">
- #{targetType, jdbcType=BIGINT},
- </if>
- </trim>
- </insert>
- <!--删除-->
- <delete id="delete" parameterType="java.util.Map">
- DELETE from checklist_target
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_Id = #{ocId ,jdbcType=BIGINT}
- </if>
- <if test="checklistId != null">
- AND checklist_Id = #{checklistId ,jdbcType=BIGINT}
- </if>
- <if test="targetId != null">
- AND target_Id = #{targetId ,jdbcType=BIGINT}
- </if>
- <if test="targetType != null">
- AND target_type = #{targetType ,jdbcType=BIGINT}
- </if>
- </delete>
- </mapper>
|