You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
4.5 KiB

<?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.ccic.safeliab.dao.QuestionMapper">
<!-- 通用查询映射结果 -->
<resultMap id="IndustryResultMap" type="com.ccic.safeliab.entity.Industry">
<id column="industry_id" property="industryId" />
<result column="industry_name" property="industryName" />
</resultMap>
<resultMap id="QuestionCategoriesResultMap" type="com.ccic.safeliab.entity.QuestionCategories">
<id column="id" property="id" />
<result column="question_types" property="questionTypes" />
<result column="industry_id" property="industryId" />
<result column="service_type_id" property="serviceTypeId" />
<result column="question_content" property="questionContent" />
<result column="answer" property="answer" />
<result column="options" property="options" />
<result column="status" property="status" />
<result column="is_deleted" property="isDeleted" />
</resultMap>
<resultMap id="PaperQuestionCategoriesMap" type="com.ccic.safeliab.vo.PageQuestionCategoriesVO">
<id column="id" property="id"/>
<result column="question_types" property="questionTypes"/>
<result column="industry_id" property="industryId"/>
<result column="service_type_id" property="serviceTypeId"/>
<result column="question_content" property="questionContent"/>
<result column="answer" property="answer"/>
<result column="options" property="options"/>
<result column="status" property="status"/>
<result column="question_number" property="questionNumber"/>
</resultMap>
<select id="getList" resultMap="QuestionCategoriesResultMap">
SELECT
id,
question_types,
industry_id,
service_type_id,
question_content,
answer,
options,
status,
is_deleted
FROM
ex_question_categories
<where>
is_deleted = '0'
<if test="industryId!= null and industryId!= ''">
AND industry_id = #{industryId}
</if>
<if test="serviceTypeId!= null and serviceTypeId!= ''">
AND service_type_id = #{serviceTypeId}
</if>
<if test="questionContent!= null and questionContent!= ''">
AND question_content LIKE '%' || #{questionContent} || '%'
</if>
</where>
ORDER BY
id ASC
LIMIT
#{offset}, #{num};
</select>
<select id="getListSize" resultType="int">
SELECT
COUNT(id)
FROM
ex_question_categories
<where>
is_deleted = '0'
<if test="industryId!= null and industryId!= ''">
AND industry_id = #{industryId}
</if>
<if test="serviceTypeId!= null and serviceTypeId!= ''">
AND service_type_id = #{serviceTypeId}
</if>
<if test="questionContent!= null and questionContent!= ''">
AND question_content LIKE '%' || #{questionContent} || '%'
</if>
</where>
</select>
<select id="getIndustry" resultMap="IndustryResultMap">
SELECT
industry_id,
industry_name
FROM
tbl_industry
WHERE
status = 1
</select>
<select id="getQuestionDetail" resultMap="QuestionCategoriesResultMap">
SELECT
id,
question_types,
industry_id,
service_type_id,
question_content,
answer,
options,
status,
is_deleted
FROM
ex_question_categories
<where>
is_deleted = '0'
<if test="id!= null and id!= ''">
AND id = #{id}
</if>
</where>
</select>
<select id="getListByPaperId" resultMap="PaperQuestionCategoriesMap">
SELECT
a.id,
a.question_types,
a.industry_id,
a.service_type_id,
a.question_content,
a.answer,
a.options,
a.status,
b.question_number
FROM ex_question_categories a
LEFT JOIN ex_paper_questions b ON b.question_id = a.id AND b.is_deleted = '0'
<where>
a.is_deleted = '0'
<if test="paperId!= null and paperId!= ''">
AND b.paper_id = #{paperId}
</if>
</where>
ORDER BY b.question_number asc
</select>
</mapper>