|
|
|
|
<?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.CompeteTeamDao">
|
|
|
|
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.ccsens.mt.bean.po.CompeteTeam">
|
|
|
|
|
<id column="id" jdbcType="BIGINT" property="id" />
|
|
|
|
|
<result column="creator" jdbcType="BIGINT" property="creator" />
|
|
|
|
|
<result column="project_id" jdbcType="BIGINT" property="projectId" />
|
|
|
|
|
<result column="compete_time_id" jdbcType="BIGINT" property="competeTimeId" />
|
|
|
|
|
<result column="gender_group" jdbcType="TINYINT" property="genderGroup" />
|
|
|
|
|
<result column="certificate" jdbcType="TINYINT" property="certificate" />
|
|
|
|
|
<result column="qr_code" jdbcType="VARCHAR" property="qrCode" />
|
|
|
|
|
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
|
|
|
|
|
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
|
|
|
|
|
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<resultMap id="getTeamByProjectId" type="com.ccsens.mt.bean.vo.CompeteVo$TeamInfoByProject">
|
|
|
|
|
<id column="teamId" jdbcType="BIGINT" property="teamId" />
|
|
|
|
|
<result column="creatorId" jdbcType="BIGINT" property="creatorId" />
|
|
|
|
|
<result column="creatorName" jdbcType="VARCHAR" property="creatorName" />
|
|
|
|
|
<result column="certificate" jdbcType="TINYINT" property="certificate" />
|
|
|
|
|
<result column="memberNums" jdbcType="INT" property="memberNums" />
|
|
|
|
|
<collection property="members" ofType="com.ccsens.mt.bean.vo.CompeteVo$CompeteTeamProjectMember">
|
|
|
|
|
<id column="memberId" property="memberId"/>
|
|
|
|
|
<result column="memberName" property="memberName"/>
|
|
|
|
|
<result column="captain" property="captain"/>
|
|
|
|
|
</collection>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="countJoinTeam" resultType="java.lang.Long">
|
|
|
|
|
SELECT
|
|
|
|
|
count( t.id )
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_team t,
|
|
|
|
|
t_compete_team_member m
|
|
|
|
|
WHERE
|
|
|
|
|
t.id = m.compete_team_id
|
|
|
|
|
AND t.project_id = #{projectId}
|
|
|
|
|
AND t.compete_time_id = #{competeTimeId}
|
|
|
|
|
AND m.player_id = #{playerId}
|
|
|
|
|
AND t.rec_status = 0
|
|
|
|
|
AND m.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="countJoinProject" resultType="java.lang.Long">
|
|
|
|
|
SELECT
|
|
|
|
|
count( t.id )
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_team t,
|
|
|
|
|
t_compete_project p,
|
|
|
|
|
t_compete_team_member m
|
|
|
|
|
WHERE
|
|
|
|
|
t.project_id = p.id
|
|
|
|
|
AND t.id = m.compete_team_id
|
|
|
|
|
AND t.compete_time_id = #{competeTimeId}
|
|
|
|
|
AND m.player_id = #{playerId}
|
|
|
|
|
AND p.join_rule = 1
|
|
|
|
|
AND t.rec_status = 0
|
|
|
|
|
AND m.rec_status = 0
|
|
|
|
|
AND p.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="queryMembers" resultType="com.ccsens.mt.bean.vo.CompeteVo$CompeteTeamProjectMember">
|
|
|
|
|
SELECT
|
|
|
|
|
p.id AS memberId,
|
|
|
|
|
p.NAME AS memberName,
|
|
|
|
|
m.captain
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_team_member m,
|
|
|
|
|
t_compete_player p
|
|
|
|
|
WHERE
|
|
|
|
|
m.player_id = p.id
|
|
|
|
|
AND m.compete_team_id = #{teamId}
|
|
|
|
|
AND m.rec_status = 0
|
|
|
|
|
AND p.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getQrCodeByTeamId" resultType="java.lang.String">
|
|
|
|
|
SELECT
|
|
|
|
|
qr_code
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_team
|
|
|
|
|
WHERE
|
|
|
|
|
id = #{teamId}
|
|
|
|
|
AND rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="queryTiwn" resultType="com.ccsens.mt.bean.vo.CompeteVo$CompeteTiwnProject">
|
|
|
|
|
SELECT
|
|
|
|
|
pp.id as competeProjectId,
|
|
|
|
|
p2.type,
|
|
|
|
|
p2.name as secondProjectName,
|
|
|
|
|
p1.name as parentProjectName,
|
|
|
|
|
pp.certificate
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_player p,
|
|
|
|
|
t_compete_project_player pp,
|
|
|
|
|
t_compete_project p2,
|
|
|
|
|
t_compete_project p1
|
|
|
|
|
WHERE
|
|
|
|
|
p.id = pp.player_id
|
|
|
|
|
AND pp.project_id = p2.id
|
|
|
|
|
AND p2.parent_id = p1.id
|
|
|
|
|
AND p.user_id = #{userId}
|
|
|
|
|
AND pp.compete_time_id = #{competeTimeId}
|
|
|
|
|
AND p2.team = 0
|
|
|
|
|
and p.rec_status = 0
|
|
|
|
|
and pp.rec_status = 0
|
|
|
|
|
and p1.rec_status = 0
|
|
|
|
|
and p2.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="queryTeam" resultType="com.ccsens.mt.bean.vo.CompeteVo$CompeteTeamProject">
|
|
|
|
|
SELECT
|
|
|
|
|
t.id as teamId,
|
|
|
|
|
p2.type,
|
|
|
|
|
p2.name as secondProjectName,
|
|
|
|
|
p1.name as parentProjectName,
|
|
|
|
|
p2.member_min as memberMin,
|
|
|
|
|
p2.member_max as memberMax,
|
|
|
|
|
t.certificate,
|
|
|
|
|
m.captain as creator,
|
|
|
|
|
if (m.captain = 1, t.qr_code, '') as qrCode
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_player p,
|
|
|
|
|
t_compete_team_member m,
|
|
|
|
|
t_compete_team t,
|
|
|
|
|
t_compete_project p2,
|
|
|
|
|
t_compete_project p1
|
|
|
|
|
WHERE
|
|
|
|
|
p.id = m.player_id
|
|
|
|
|
AND m.compete_team_id = t.id
|
|
|
|
|
AND t.project_id = p2.id
|
|
|
|
|
AND p2.parent_id = p1.id
|
|
|
|
|
AND p.user_id = #{userId}
|
|
|
|
|
AND t.compete_time_id = #{competeTimeId}
|
|
|
|
|
AND p2.team = 1
|
|
|
|
|
AND p.rec_status = 0
|
|
|
|
|
AND m.rec_status = 0
|
|
|
|
|
AND t.rec_status = 0
|
|
|
|
|
AND p1.rec_status = 0
|
|
|
|
|
AND p2.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="countTiwnTeam" resultType="java.lang.Long">
|
|
|
|
|
SELECT
|
|
|
|
|
count(*)
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_project_player pp,
|
|
|
|
|
t_compete_project p
|
|
|
|
|
WHERE
|
|
|
|
|
pp.project_id = p.id
|
|
|
|
|
AND pp.player_id = #{playerId}
|
|
|
|
|
AND pp.compete_time_id = #{competeTimeId}
|
|
|
|
|
AND p.team = 0
|
|
|
|
|
AND p.rec_status = 0
|
|
|
|
|
AND pp.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getTeamByProjectId" resultMap="getTeamByProjectId">
|
|
|
|
|
SELECT
|
|
|
|
|
t.id as teamId,
|
|
|
|
|
t.creator as creatorId,
|
|
|
|
|
(SELECT `name` FROM t_compete_player WHERE id = t.creator) as creatorName,
|
|
|
|
|
t.certificate as certificate,
|
|
|
|
|
(SELECT count(id) FROM t_compete_team_member WHERE compete_team_id = t.id) as memberNums,
|
|
|
|
|
m.id as memberId,
|
|
|
|
|
p.`name` as memberName,
|
|
|
|
|
if(t.creator = p.id , true,false) as captain
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_team t left join t_compete_team_member m on t.id = m.compete_team_id
|
|
|
|
|
LEFT JOIN t_compete_player p on m.player_id = p.id
|
|
|
|
|
WHERE
|
|
|
|
|
t.project_id = #{competeProjectId}
|
|
|
|
|
and t.compete_time_id = #{competeTimeId}
|
|
|
|
|
and t.rec_status = 0
|
|
|
|
|
and m.rec_status = 0
|
|
|
|
|
and p.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getPlayerByProjectId" resultType="com.ccsens.mt.bean.vo.CompeteVo$PlayerInfoByProject">
|
|
|
|
|
SELECT
|
|
|
|
|
p.id as playerId,
|
|
|
|
|
p.`name`,
|
|
|
|
|
p.gender,
|
|
|
|
|
p.phone,
|
|
|
|
|
p.compete_group_id as groupId,
|
|
|
|
|
(SELECT `group_name` FROM t_compete_group WHERE id = p.compete_group_id) as groupName,
|
|
|
|
|
(SELECT `name` FROM t_compete_company WHERE id = p.company_id) as companyName,
|
|
|
|
|
pp.certificate
|
|
|
|
|
FROM
|
|
|
|
|
t_compete_project_player pp left join t_compete_player p on pp.player_id = p.id
|
|
|
|
|
WHERE
|
|
|
|
|
pp.project_id = 9
|
|
|
|
|
and pp.compete_time_id = 1
|
|
|
|
|
and pp.rec_status = 0
|
|
|
|
|
and p.rec_status = 0
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|