ProblemList.xml 6.18 KB
<?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="cn.fw.rp.dao.ProblemListDao">

    <!-- 查询数量 -->
    <select id="selectCount" parameterType="QueryCriterion" resultType="java.lang.Integer">
        select count(1) from problem_list
        <include refid="core.where_condition"/>
    </select>

    <!-- 查询,根据主键 -->
    <select id="selectById" parameterType="Integer" resultMap="problemListMap">
        select *
        from problem_list
        where id = #{id}
    </select>

    <select id="getFiles" resultMap="fileListMap">
        SELECT
        b.*
        FROM
        problem_file a
        JOIN file_list b ON a.file_id = b.file_id
        WHERE
        1 = 1
        <if test="flag !=null">
            AND b.flag = #{flag}
        </if>
        <if test="problemId !=null">
            AND a.problem_id = #{problemId}
        </if>
        order by b.upload_time desc
    </select>

    <select id="fileCount" parameterType="Integer" resultType="java.util.Map">
        select flag,
               count(b.file_id) as count
        from problem_file a
                 join file_list b on a.file_id = b.file_id
        where problem_id = #{problemId}
        GROUP BY flag
    </select>


    <!-- 查询列表,根据条件 -->
    <select id="selectList" parameterType="QueryCriterion" resultMap="problemListMap">
        select * from problem_list
        <include refid="core.where_condition"/>
        <include refid="core.page_condition"/>
    </select>

    <!-- 更新,根据主键 -->
    <update id="updateById" parameterType="ProblemList">
        update problem_list
        <include refid="update_columns"/>
        where id = #{t.id}
    </update>

    <!-- 更新列表,根据条件 -->
    <update id="updateList">
        update marketing_comment
        <include refid="update_columns"/>
        <include refid="core.where_condition_pre_con"/>
    </update>

    <!-- 新增 -->
    <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="ProblemList">
        insert into problem_list
        (system_ref,
         module_ref,
         title,
         content,
         purpose,
         question,
         scenarios,
         logic,
         status,
         create_time,
         update_time,
         create_user,
         update_user)
        values (#{systemRef},
                #{moduleRef},
                #{title},
                #{content},
                #{purpose},
                #{question},
                #{scenarios},
                #{logic},
                #{status},
                now(),
                #{updateTime},
                #{createUser},
                #{updateUser})
    </insert>

    <!-- 删除,根据主键 -->
    <delete id="deleteById" parameterType="Long">
        delete
        from problem_list
        where id = #{id}
    </delete>

    <!-- 删除列表,根据条件 -->
    <delete id="deleteList" parameterType="QueryCriterion">
        delete from problem_list
        <include refid="core.where_condition"/>
    </delete>

    <!-- 查询结果集 -->
    <resultMap id="problemListMap" type="ProblemList">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="system_ref" jdbcType="VARCHAR" property="systemRef"/>
        <result column="module_ref" jdbcType="VARCHAR" property="moduleRef"/>
        <result column="title" jdbcType="VARCHAR" property="title"/>
        <result column="content" jdbcType="VARCHAR" property="content"/>
        <result column="purpose" jdbcType="VARCHAR" property="purpose"/>
        <result column="question" jdbcType="VARCHAR" property="question"/>
        <result column="scenarios" jdbcType="VARCHAR" property="scenarios"/>
        <result column="logic" jdbcType="VARCHAR" property="logic"/>
        <result column="status" jdbcType="INTEGER" property="status"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
        <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
    </resultMap>

    <!-- 查询结果集 -->
    <resultMap id="fileListMap" type="FileList">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="file_id" jdbcType="INTEGER" property="fileId"/>
        <result column="file_name" jdbcType="VARCHAR" property="fileName"/>
        <result column="content_type" jdbcType="VARCHAR" property="contentType"/>
        <result column="upload_time" jdbcType="VARCHAR" property="uploadTime"/>
        <result column="upload_user" jdbcType="VARCHAR" property="uploadUser"/>
        <result column="file_path" jdbcType="VARCHAR" property="filePath"/>
        <result column="flag" jdbcType="INTEGER" property="flag"/>
        <result column="file_length" jdbcType="INTEGER" property="fileLength"/>
    </resultMap>


    <!-- 更新字段列表 -->
    <sql id="update_columns">
        <set>
            <if test="t.systemRef != null"><![CDATA[system_ref =  #{t.systemRef},]]></if>
            <if test="t.moduleRef != null"><![CDATA[module_ref =  #{t.moduleRef},]]></if>
            <if test="t.title != null"><![CDATA[title=#{t.title},]]></if>
            <if test="t.content != null"><![CDATA[content = #{t.content},]]></if>
            <if test="t.purpose != null"><![CDATA[purpose = #{t.purpose},]]></if>
            <if test="t.question != null"><![CDATA[question = #{t.question},]]></if>
            <if test="t.scenarios != null"><![CDATA[scenarios = #{t.scenarios},]]></if>
            <if test="t.logic != null"><![CDATA[logic = #{t.logic},]]></if>
            <if test="t.status != null"><![CDATA[status = #{t.status},]]></if>
            <if test="t.createTime != null"><![CDATA[create_time = #{t.createTime},]]></if>
            <if test="t.updateTime != null"><![CDATA[update_time = #{t.updateTime},]]></if>
            <if test="t.createUser != null"><![CDATA[create_user = #{t.createUser},]]></if>
            <if test="t.updateUser != null"><![CDATA[update_user = #{t.updateUser},]]></if>
        </set>
    </sql>
</mapper>