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.
102 lines
3.5 KiB
102 lines
3.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.ccsens.mt.persist.dao.TopicDao">
|
|
|
|
<resultMap id="getTopicByLink" type="com.ccsens.mt.bean.vo.TopicVo$TopicInfo">
|
|
<id column="topicId" property="topicId"/>
|
|
<result column="description" property="description"/>
|
|
<result column="answersTrue" property="answersTrue"/>
|
|
<collection property="options" ofType="String">
|
|
<id column="options"/>
|
|
</collection>
|
|
</resultMap>
|
|
<resultMap id="topicByLink" type="com.ccsens.mt.bean.vo.TopicVo$TopicByLink" >
|
|
<id column="topicId" property="topicId"/>
|
|
<result column="description" property="description"/>
|
|
<result column="answersTrue" property="answersTrue"/>
|
|
<result column="hasAnswers" property="hasAnswers"/>
|
|
<collection property="options" ofType="String" column="topicId" select="queryOption">
|
|
</collection>
|
|
</resultMap>
|
|
|
|
|
|
<select id="getTopicByLink" parameterType="java.util.Map" resultMap="getTopicByLink">
|
|
SELECT
|
|
t.id as topicId,
|
|
t.description as description,
|
|
t.answers as answersTrue,
|
|
if(o.`option` is null,'' , concat(o.`option` ,':' ,o.contant)) as options
|
|
FROM
|
|
t_mt_topic t LEFT JOIN t_mt_topic_option o on t.id = o.topic_id
|
|
WHERE
|
|
t.rec_status = 0
|
|
and
|
|
t.link_type = #{linkType}
|
|
and
|
|
t.sequence = #{topicNum}
|
|
ORDER BY o.sequence
|
|
</select>
|
|
<select id="queryTopicAllByLink" resultMap="topicByLink">
|
|
SELECT
|
|
p.id AS topicId,
|
|
p.score AS topicScore,
|
|
p.description as description,
|
|
p.answers as answersTrue,
|
|
IF( gp.id IS NULL, 0, 1 ) as hasAnswers
|
|
FROM
|
|
t_mt_topic p
|
|
LEFT JOIN t_mt_group_topic gp ON p.id = gp.topic_id
|
|
LEFT JOIN t_mt_group g ON gp.group_id = g.id
|
|
WHERE
|
|
p.link_type = #{linkType}
|
|
and p.rec_status = 0
|
|
and (g.project_id = #{projectId} or g.id is null)
|
|
and (gp.rec_status = 0 or gp.id is null)
|
|
and (g.rec_status = 0 or gp.id is null)
|
|
GROUP BY p.id
|
|
LIMIT ${nums}
|
|
</select>
|
|
<select id="queryOption" resultType="java.lang.String">
|
|
SELECT
|
|
concat( o.`option`, ':', o.contant )
|
|
FROM
|
|
t_mt_topic_option o
|
|
WHERE
|
|
o.topic_id = #{topicId}
|
|
</select>
|
|
|
|
<select id="queryGroupByProject" parameterType="java.util.Map" resultType="com.ccsens.mt.bean.vo.TopicVo$GroupInfo">
|
|
SELECT
|
|
id as groupId,
|
|
`name` as groupName
|
|
FROM
|
|
t_mt_group
|
|
WHERE
|
|
rec_status = 0
|
|
and
|
|
project_id = #{projectId}
|
|
and
|
|
advance_status = #{linkType}
|
|
and
|
|
`type` = #{type}
|
|
</select>
|
|
|
|
<select id="queryRanking" parameterType="java.util.Map" resultType="com.ccsens.mt.bean.vo.TopicVo$QueryRanking">
|
|
SELECT
|
|
id as groupId,
|
|
`name` as groupName,
|
|
score as score
|
|
FROM
|
|
t_mt_group g
|
|
WHERE
|
|
rec_status = 0
|
|
and
|
|
project_id = #{projectId}
|
|
and
|
|
advance_status = #{linkType}
|
|
and
|
|
type = 0
|
|
ORDER BY score DESC
|
|
</select>
|
|
|
|
</mapper>
|