fuliqi
2024-04-01 d60aee1468e17e2deeb21a228791ad36ca535f3f
ycl-server/src/main/resources/mapper/zgyw/CheckResultMapper.xml
@@ -1,54 +1,88 @@
<?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">
<?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.ycl.platform.mapper.CheckResultMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.platform.domain.vo.CheckResultVO">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="unit_name" property="checkUnitName" />
        <result column="examine_name" property="examineName" />
        <result column="check_score" property="checkScore" />
        <result column="system_score" property="systemScore" />
        <result column="manual_score" property="manualScore" />
        <result column="check_time" property="checkTime" />
        <result column="frequency" property="frequency" />
        <result column="examine_range" property="examineRange" />
        <result column="publish" property="publish" />
    <resultMap type="com.ycl.platform.domain.entity.CheckResult" id="CheckResultResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="publishId"    column="publish_id"    />
        <result property="examineCategory"    column="examine_category"    />
        <result property="checkScore"    column="check_score"    />
        <result property="publish"    column="publish"    />
        <result property="checkTime"    column="check_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deleted"    column="deleted"    />
    </resultMap>
    <select id="page" resultMap="BaseResultMap">
        SELECT
               tcr.id,
               tyu.unit_name,
               tcp.examine_name,
               tcp.examine_range,
               tcp.frequency,
               tcr.check_time,
               tcr.check_score,
               tcr.system_score,
               tcr.manual_score,
               tcr.publish
        FROM
             t_check_result tcr
                 INNER JOIN t_check_publish tcp ON tcr.check_publish_id = tcp.id
                 INNER JOIN t_yw_unit tyu ON tcr.check_unit_id = tyu.id
        <where>
                AND tcr.deleted = 0
            <if test="query.checkUnitName != null and query.checkUnitName != ''">
                AND tyu.unit_name like concat('%', #{query.checkUnitName}, '%')
            </if>
            <if test="query.frequency != null and query.frequency != ''">
                AND tcp.frequency = #{query.frequency}
            </if>
            <if test="query.frequency != null and query.frequency != ''">
                AND tcp.examine_range = #{query.examineRange}
            </if>
            <if test="query.start != null and query.end != null">
                AND tcr.check_time BETWEEN #{query.start} AND #{query.end}
            </if>
    <sql id="selectCheckResultVo">
        select id, dept_id, publish_id, examine_category, check_score, publish, check_time, update_time, deleted from t_check_result
    </sql>
    <select id="selectCheckResultList" resultMap="CheckResultResult">
        <include refid="selectCheckResultVo"/>
        <where>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="publishId != null "> and publish_id = #{publishId}</if>
            <if test="examineCategory != null "> and examine_category = #{examineCategory}</if>
            <if test="publish != null "> and publish = #{publish}</if>
            <if test="checkTime != null "> and check_time = #{checkTime}</if>
        </where>
    </select>
    <select id="selectCheckResultById"  resultMap="CheckResultResult">
        <include refid="selectCheckResultVo"/>
        where id = #{id}
    </select>
    <insert id="insertCheckResult" useGeneratedKeys="true" keyProperty="id">
        insert into t_check_result
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="publishId != null">publish_id,</if>
            <if test="examineCategory != null">examine_category,</if>
            <if test="checkScore != null">check_score,</if>
            <if test="publish != null">publish,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deleted != null">deleted,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="publishId != null">#{publishId},</if>
            <if test="examineCategory != null">#{examineCategory},</if>
            <if test="checkScore != null">#{checkScore},</if>
            <if test="publish != null">#{publish},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deleted != null">#{deleted},</if>
         </trim>
    </insert>
</mapper>
    <update id="updateCheckResult" >
        update t_check_result
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="publishId != null">publish_id = #{publishId},</if>
            <if test="examineCategory != null">examine_category = #{examineCategory},</if>
            <if test="checkScore != null">check_score = #{checkScore},</if>
            <if test="publish != null">publish = #{publish},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deleted != null">deleted = #{deleted},</if>
        </trim>
        where id = #{id}
    </update>
    <delete id="deleteCheckResultById" >
        delete from t_check_result where id = #{id}
    </delete>
    <delete id="deleteCheckResultByIds" >
        delete from t_check_result where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>