| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?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.yonge.cooleshow.biz.dal.dao.ActivityPlanDao">
- <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.ActivityPlan">
- <result column="id_" property="id" />
- <result column="activity_type_" property="activityType" />
- <result column="activity_client_" property="activityClient" />
- <result column="activity_name_" property="activityName" />
- <result column="describe_" property="describe" />
- <result column="rule_describe_" property="ruleDescribe" />
- <result column="subject_url_" property="subjectUrl" />
- <result column="background_url_" property="backgroundUrl" />
- <result column="activity_url_" property="activityUrl" />
- <result column="share_url_" property="shareUrl" />
- <result column="activity_start_" property="activityStart" />
- <result column="activity_end_" property="activityEnd" />
- <result column="registration_method_" property="registrationMethod" />
- <result column="registration_price_" property="registrationPrice" />
- <result column="share_rate_" property="shareRate" />
- <result column="share_type_" property="shareType" />
- <result column="ranking_" property="ranking" />
- <result column="ranking_rule_" property="rankingRule" />
- <result column="ranking_method_" property="rankingMethod" />
- <result column="ranking_score_" property="rankingScore" />
- <result column="draft_flag_" property="draftFlag" />
- <result column="activity_state_" property="activityState" />
- <result column="create_time_" property="createTime" />
- <result column="create_by_" property="createBy" />
- <result column="update_time_" property="updateTime" />
- <result column="update_by_" property="updateBy" />
- </resultMap>
-
- <!-- 表字段 -->
- <sql id="baseColumns">
- t.id_ as id
- , t.activity_type_ as activityType
- , t.activity_client_ as activityClient
- , t.activity_name_ as activityName
- , t.describe_ as `describe`
- , t.rule_describe_ as ruleDescribe
- , t.subject_url_ as subjectUrl
- , t.background_url_ as backgroundUrl
- , t.share_url_ as shareUrl
- , t.activity_url_ as activityUrl
- , t.activity_start_ as activityStart
- , t.activity_end_ as activityEnd
- , t.registration_method_ as registrationMethod
- , t.registration_price_ as registrationPrice
- , t.share_rate_ as shareRate
- , t.share_type_ as shareType
- , t.ranking_ as ranking
- , t.ranking_rule_ as rankingRule
- , t.ranking_method_ as rankingMethod
- , t.ranking_score_ as rankingScore
- , t.draft_flag_ as draftFlag
- , if(t.activity_state_ = 1, 1, 0) as activityState
- , t.create_time_ as createTime
- , t.create_by_ as createBy
- , t.update_time_ as updateTime
- , t.update_by_ as updateBy
- </sql>
- <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo">
- SELECT
- <include refid="baseColumns"/>
- FROM activity_plan t
- where t.id_ = #{id}
- </select>
-
- <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo">
- SELECT
- <include refid="baseColumns" />
- , u.username_ as updateByName
- /*, (select count(1) from activity_registration r where t.id_ = r.activity_id_) as registrationNum*/
- /*, (select count(distinct r.user_id_) from activity_user_reward r where t.id_ = r.activity_id_) as rewardNum*/
- FROM activity_plan t
- LEFT JOIN sys_user u on t.update_by_ = u.id_
- <where>
- <if test="param.activityName != null and param.activityName != ''">
- and (t.activity_name_ like concat('%',#{param.activityName},'%') <if test="param.activityId != null"> OR t.id_ = #{param.activityId}</if> )
- </if>
- <if test="param.draftFlag != null">
- and t.draft_flag_ = #{param.draftFlag}
- </if>
- <choose>
- <when test="param.activityState != null">
- <if test="param.activityState == 0">
- and (t.activity_state_ = 0 or t.activity_state_ = 2)
- </if>
- <if test="param.activityState == 1">
- and t.activity_state_ = 1
- </if>
- </when>
- <otherwise> AND t.activity_start_ >= -1 </otherwise>
- </choose>
- <if test="param.startTime !=null">
- and t.activity_start_ >= #{param.startTime}
- </if>
- <if test="param.endTime !=null">
- and t.activity_end_ <= #{param.endTime}
- </if>
- <if test="param.activityClient != null">
- and t.activity_client_ = #{param.activityClient}
- </if>
- <if test="param.activityType != null">
- and t.activity_type_ = #{param.activityType}
- </if>
- </where>
- order by t.id_ desc
- </select>
- <select id="selectActivityPlanEvaluation" resultType="java.lang.String">
- select evaluation_difficulty_
- from activity_plan_evaluation
- where id_ = #{activityPlanId}
- </select>
- <select id="activityState" resultType="com.yonge.cooleshow.biz.dal.entity.ActivityPlan">
- select <include refid="baseColumns"/>
- from activity_plan t where draft_flag_ = 0
- and (
- (t.activity_start_ <= now() and t.activity_end_ > now() and activity_state_ = 0)
- or (t.activity_end_ <= now() and activity_state_ = 1)
- )
- </select>
- <select id="selectActivityShare" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityPlanVo">
- select
- <include refid="baseColumns"/>
- from activity_plan t
- left join activity_evaluation ae on t.id_ = ae.activity_id_
- <where>
- activity_state_ = 1 and activity_start_ <= now() and activity_end_ >= now() and activity_type_ = 'SHARE'
- <if test="type != null and type != ''">
- and #{type} = t.share_type_
- </if>
- <if test="userId != null">
- and ae.music_sheet_id_ = #{userId}
- and ae.resource_type_ = 'TEACHER'
- </if>
- </where>
- </select>
- <!--活动参与人数、获奖人数统计-->
- <select id="selectActivityParticipateStatInfo"
- resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
- SELECT t1.activity_id_ AS id, COUNT(DISTINCT t1.id_) AS total FROM activity_registration t1
- <where>
- <if test="activityIds != null">
- AND t1.activity_id_ IN (<foreach collection="activityIds" separator="," item="item">#{item}</foreach>)
- </if>
- </where>
- GROUP BY t1.activity_id_
- </select>
- <select id="selectActivityWinnerStatInfo"
- resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
- SELECT t1.activity_id_ AS id, COUNT(DISTINCT t1.user_id_) AS total FROM activity_user_reward t1
- <where>
- <if test="activityIds != null">
- AND t1.activity_id_ IN (<foreach collection="activityIds" separator="," item="item">#{item}</foreach>)
- </if>
- </where>
- GROUP BY t1.activity_id_
- </select>
- <!--活动参与人数、获奖人数统计-->
- <!--活动总分用户排名-->
- <select id="selectActivityHighestScoreRankingInfo"
- resultType="com.yonge.cooleshow.biz.dal.vo.ActivityRankingVo">
- SELECT
- t1.score_, t1.user_id_, t2.avatar_ AS userAvatar, t2.username_ AS username
- FROM
- activity_evaluation_record t1 LEFT JOIN sys_user t2 ON t1.user_id_ = t2.id_
- WHERE
- t1.activity_id_ = #{activityId} AND t1.resource_id_ = #{subjectId} AND t1.ranking_method_ = 'TOTAL_SCORE' AND t1.score_ > #{rankingScore}
- ORDER BY
- t1.score_ DESC,
- t1.registration_time_ ASC
- LIMIT #{limit}
- </select>
- <!--活动总分用户排名-->
- </mapper>
|