|
|
@@ -22,9 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="answerStatus" column="answer_status"/>
|
|
|
<result property="answerTime" column="answer_time"/>
|
|
|
<result property="totalQuestions" column="total_questions"/>
|
|
|
+ <result property="question" column="question"/>
|
|
|
<result property="answeredQuestions" column="answered_questions"/>
|
|
|
<result property="unansweredQuestions" column="unanswered_questions"/>
|
|
|
<result property="completionRate" column="completion_rate"/>
|
|
|
+ <result property="questionTypeStr" column="questionTypeStr"/>
|
|
|
<result property="sortOrder" column="sort_order" />
|
|
|
<result property="questionText" column="question_text" />
|
|
|
<result property="questionType" column="question_type" />
|
|
|
@@ -47,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="fcBrandName" column="fc_brand_name"/>
|
|
|
<result property="businessTypeCode" column="business_type_code"/>
|
|
|
<result property="businessTypeName" column="business_type_name" />
|
|
|
+ <result property="businessTypeCode" column="businessTypeCode" />
|
|
|
<result property="regionCode" column="region_code" />
|
|
|
<result property="regionName" column="region_name" />
|
|
|
<result property="parentRegionName" column="parent_region_name" />
|
|
|
@@ -64,6 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="parentRegionCode" column="parent_region_code" />
|
|
|
<result property="currentAreaName" column="current_area_name"/>
|
|
|
<result property="avgTransaction" column="avg_transaction"/>
|
|
|
+ <result property="region" column="region"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectYmdfSurveyVo">
|
|
|
@@ -269,6 +273,108 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
+ <select id="selectYmdfSurveyDetail" parameterType="YmdfSurvey" resultMap="YmdfSurveyResult">
|
|
|
+ SELECT
|
|
|
+ s.title,
|
|
|
+ s.description,
|
|
|
+ s.public_mode,
|
|
|
+ s.public_start_time,
|
|
|
+ s.public_end_time,
|
|
|
+ brand.brand_codes AS brand_code,
|
|
|
+ business_type.business_type_codes AS businessTypeCode,
|
|
|
+ region.region_codes AS region_code,
|
|
|
+ region.region_objects AS region,
|
|
|
+ JSON_ARRAYAGG(question_json) AS question
|
|
|
+ FROM
|
|
|
+ ymdf_survey s
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ survey_id,
|
|
|
+ JSON_ARRAYAGG(brand_code) AS brand_codes
|
|
|
+ FROM ymdf_survey_brand
|
|
|
+ GROUP BY survey_id
|
|
|
+ ) brand ON s.survey_id = brand.survey_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ survey_id,
|
|
|
+ JSON_ARRAYAGG(business_type_code) AS business_type_codes
|
|
|
+ FROM ymdf_survey_business_type
|
|
|
+ GROUP BY survey_id
|
|
|
+ ) business_type ON s.survey_id = business_type.survey_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ survey_id,
|
|
|
+ JSON_ARRAYAGG(region_code) AS region_codes,
|
|
|
+ JSON_ARRAYAGG(JSON_OBJECT('regionCode', region_code)) AS region_objects
|
|
|
+ FROM ymdf_survey_region
|
|
|
+ GROUP BY survey_id
|
|
|
+ ) region ON s.survey_id = region.survey_id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ q.survey_id,
|
|
|
+ q.question_id,
|
|
|
+ JSON_OBJECT(
|
|
|
+ 'questionText', q.question_text,
|
|
|
+ 'questionType', q.question_type,
|
|
|
+ 'questionTypeStr', CASE q.question_type
|
|
|
+ WHEN 1 THEN 'INPUT_BOX_50'
|
|
|
+ WHEN 2 THEN 'INPUT_BOX_100'
|
|
|
+ WHEN 3 THEN 'RADIO_BUTTON'
|
|
|
+ WHEN 4 THEN 'CHECK_BOX'
|
|
|
+ WHEN 5 THEN 'NUMBER_SELECT'
|
|
|
+ ELSE ''
|
|
|
+ END,
|
|
|
+ 'sortOrder', q.sort_order,
|
|
|
+ 'questionUnit', q.question_unit,
|
|
|
+ -- 单选框选项
|
|
|
+ 'radioItems', CASE WHEN q.question_type = 3 THEN
|
|
|
+ CONCAT(
|
|
|
+ '[',
|
|
|
+ GROUP_CONCAT(
|
|
|
+ JSON_OBJECT(
|
|
|
+ 'optionText', o.option_text,
|
|
|
+ 'sortOrder', o.sort_order,
|
|
|
+ 'value', CONCAT('option', o.sort_order)
|
|
|
+ )
|
|
|
+ ORDER BY o.sort_order ASC SEPARATOR ','
|
|
|
+ ),
|
|
|
+ ']'
|
|
|
+ )
|
|
|
+ END,
|
|
|
+ -- 复选框选项
|
|
|
+ 'checkboxItems', CASE WHEN q.question_type = 4 THEN
|
|
|
+ CONCAT(
|
|
|
+ '[',
|
|
|
+ GROUP_CONCAT(
|
|
|
+ JSON_OBJECT(
|
|
|
+ 'optionText', o.option_text,
|
|
|
+ 'sortOrder', o.sort_order,
|
|
|
+ 'checked', FALSE
|
|
|
+ )
|
|
|
+ ORDER BY o.sort_order ASC SEPARATOR ','
|
|
|
+ ),
|
|
|
+ ']'
|
|
|
+ )
|
|
|
+ END,
|
|
|
+ 'numberSelectStart', CASE WHEN q.question_type = 5 THEN
|
|
|
+ MIN(CAST(o.option_text AS UNSIGNED))
|
|
|
+ END,
|
|
|
+ 'numberSelectEnd', CASE WHEN q.question_type = 5 THEN
|
|
|
+ MAX(CAST(o.option_text AS UNSIGNED))
|
|
|
+ END
|
|
|
+ ) AS question_json
|
|
|
+ FROM
|
|
|
+ ymdf_survey_question q
|
|
|
+ LEFT JOIN ymdf_survey_option o
|
|
|
+ ON q.question_id = o.question_id
|
|
|
+ GROUP BY
|
|
|
+ q.question_id, q.survey_id, q.question_text,
|
|
|
+ q.question_type, q.sort_order, q.question_unit
|
|
|
+ ) AS sub_question ON s.survey_id = sub_question.survey_id
|
|
|
+ WHERE
|
|
|
+ s.survey_id = #{surveyId}
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="selectYmdfSurveyById" parameterType="String" resultMap="YmdfSurveyResult">
|
|
|
<include refid="selectYmdfSurveyVo"/>
|
|
|
where id = #{id}
|