RuoYi-Cloud/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/CompetitionTeamVsTeamMapper...

460 lines
22 KiB
XML

<?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.ruoyi.system.mapper.CompetitionTeamVsTeamMapper">
<resultMap type="CompetitionTeamVsTeam" id="CompetitionTeamVsTeamResult">
<result property="id" column="id" />
<result property="competitionId" column="competition_id" />
<result property="mainTeamId" column="main_team_id" />
<result property="mainTeamName" column="main_team_name" />
<result property="guestTeamId" column="guest_team_id" />
<result property="guestTeamName" column="guest_team_name" />
<result property="competitionTime" column="competition_time" />
<result property="buildingId" column="building_id" />
<result property="buildingName" column="building_name" />
<result property="competitionAddress" column="competition_address" />
<result property="competitionGroup" column="competition_group" />
<result property="status" column="status" />
<result property="createdTime" column="created_time" />
<result property="lastUpdatedTime" column="last_updated_time" />
<result property="createdBy" column="created_by" />
<result property="modifiedBy" column="modified_by" />
<result property="isDeleted" column="is_deleted" />
<result property="remark" column="remark" />
<result property="mainTeamScore" column="main_team_score" />
<result property="guestTeamScore" column="guest_team_score" />
<result property="vsType" column="vs_type" />
<result property="batchNumber" column="batch_number" />
</resultMap>
<sql id="selectCompetitionTeamVsTeamVo">
select id, competition_id, main_team_id, main_team_name, guest_team_id, guest_team_name, competition_time, DATE_FORMAT(competition_time,'%Y-%m-%d') as competitionDate, building_id, building_name, competition_address, competition_group, status, created_time, last_updated_time, created_by, modified_by, is_deleted, remark, main_team_score, guest_team_score, vs_type, batch_number from competition_team_vs_team
</sql>
<select id="selectCompetitionTeamVsTeamList"
resultType="com.ruoyi.system.domain.vo.CompetitionTeamVsTeamVo">
<include refid="selectCompetitionTeamVsTeamVo"/>
<where>
<if test="competitionId != null "> and competition_id = #{competitionId}</if>
<if test="mainTeamId != null "> and main_team_id = #{mainTeamId}</if>
<if test="mainTeamName != null and mainTeamName != ''"> and main_team_name like concat('%', #{mainTeamName}, '%')</if>
<if test="guestTeamId != null "> and guest_team_id = #{guestTeamId}</if>
<if test="guestTeamName != null and guestTeamName != ''"> and guest_team_name like concat('%', #{guestTeamName}, '%')</if>
<if test="competitionTime != null "> and competition_time = #{competitionTime}</if>
<if test="buildingId != null "> and building_id = #{buildingId}</if>
<if test="buildingName != null and buildingName != ''"> and building_name like concat('%', #{buildingName}, '%')</if>
<if test="competitionAddress != null and competitionAddress != ''"> and competition_address = #{competitionAddress}</if>
<if test="competitionGroup != null and competitionGroup != ''"> and competition_group = #{competitionGroup}</if>
<if test="status != null "> and status = #{status}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="lastUpdatedTime != null "> and last_updated_time = #{lastUpdatedTime}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="modifiedBy != null and modifiedBy != ''"> and modified_by = #{modifiedBy}</if>
<if test="isDeleted != null "> and is_deleted = #{isDeleted}</if>
<if test="mainTeamScore != null "> and main_team_score = #{mainTeamScore}</if>
<if test="guestTeamScore != null "> and guest_team_score = #{guestTeamScore}</if>
<if test="vsType != null and vsType != ''"> and vs_type = #{vsType}</if>
<if test="batchNumber != null and batchNumber != ''"> and batch_number = #{batchNumber}</if>
</where>
</select>
<select id="selectCompetitionTeamVsTeamById"
resultType="com.ruoyi.system.domain.vo.CompetitionTeamVsTeamVo">
<include refid="selectCompetitionTeamVsTeamVo"/>
where id = #{id}
</select>
<select id="getCompetitionById" resultType="com.ruoyi.system.domain.vo.CompetitionTeamVsTeamVo">
select
t.id as id,
t.competition_id as competitionId,
t.main_team_id as mainTeamId,
b1.TEAM_NAME as mainTeamName,
b1.team_logo as mainTeamLogo,
t.guest_team_id as guestTeamId,
b2.TEAM_NAME as guestTeamName,
b2.team_logo as guestTeamLogo,
t.competition_time as competitionTime,
t.building_id as buildingId,
t.building_name as buildingName,
IFNULL(t.competition_address,b.ADDRESS) as competitionAddress,
t.competition_group as competitionGroup,
t.status,
t.vs_type as vsType,
t.created_time as createdTime,
t.last_updated_time as lastUpdatedTime,
t.created_by as createdBy,
t.modified_by as modifiedBy,
t.main_team_score as mainTeamScore,
t.guest_team_score as guestTeamScore,
t.is_deleted as isDeleted,
DATE_FORMAT(t.competition_time,'%Y-%m-%d') as competitionDate,
CASE dayofweek(t.competition_time)
WHEN 1 THEN
'星期日'
WHEN 2 THEN
'星期一'
WHEN 3 THEN
'星期二'
WHEN 4 THEN
'星期三'
WHEN 5 THEN
'星期四'
WHEN 6 THEN
'星期五'
WHEN 7 THEN
'星期六'
END as weekDayName,
CASE t.status
WHEN -1 THEN
'已取消'
WHEN 0 THEN
'报名中'
WHEN 1 THEN
'比赛中'
WHEN 2 THEN
'已结束'
END as statusName,
DATE_FORMAT(t.competition_time,'%H:%i') AS theTime,
t.remark as remark
from competition_team_vs_team t
LEFT JOIN competition_of_team b1 ON b1.id = t.main_team_id
left join competition_of_team b2 on t.guest_team_id=b2.id
left join building_info b on b.id = t.building_id
where 1=1 AND t.id=#{id}
AND t.is_deleted = 0
LIMIT 1;
</select>
<select id="getCompetitionSchedule" resultType="com.ruoyi.system.domain.vo.CompetitionTeamVsTeamVo">
select
t.id as id,
t.competition_id as competitionId,
t.main_team_id as mainTeamId,
b1.TEAM_NAME as mainTeamName,
b1.team_logo as mainTeamLogo,
t.guest_team_id as guestTeamId,
b2.TEAM_NAME as guestTeamName,
b2.team_logo as guestTeamLogo,
t.competition_time as competitionTime,
t.building_id as buildingId,
t.building_name as buildingName,
t.competition_address as competitionAddress,
t.competition_group as competitionGroup,
t.status,
t.vs_type as vsType,
t.created_time as createdTime,
t.last_updated_time as lastUpdatedTime,
t.created_by as createdBy,
t.modified_by as modifiedBy,
t.main_team_score as mainTeamScore,
t.guest_team_score as guestTeamScore,
t.is_deleted as isDeleted,
DATE_FORMAT(t.competition_time,'%Y-%m-%d') as competitionDate,
CASE dayofweek(t.competition_time)
WHEN 1 THEN
'星期日'
WHEN 2 THEN
'星期一'
WHEN 3 THEN
'星期二'
WHEN 4 THEN
'星期三'
WHEN 5 THEN
'星期四'
WHEN 6 THEN
'星期五'
WHEN 7 THEN
'星期六'
END as weekDayName,
CASE t.status
WHEN -1 THEN
'已取消'
WHEN 0 THEN
'报名中'
WHEN 1 THEN
'比赛中'
WHEN 2 THEN
'已结束'
END as statusName,
DATE_FORMAT(t.competition_time,'%H:%i') AS theTime,
t.remark as remark
from competition_team_vs_team t
LEFT JOIN competition_of_team b1 ON b1.id = t.main_team_id
left join competition_of_team b2 on t.guest_team_id=b2.id
where 1=1
<if test="id != null ">
AND t.id=#{id}
</if>
<if test="status != null ">
AND t.status =#{status}
</if>
<if test="isDeleted != null ">
AND t.is_deleted =#{isDeleted}
</if>
<if test="competitionId != null ">
AND t.competition_id=#{competitionId}
</if>
<if test="buildingName != null and buildingName != ''">
AND t.building_name like CONCAT('%',#{buildingName},'%')
</if>
<if test="competitionGroup != null ">
AND t.competition_group = #{competitionGroup}
</if>
<if test="mainTeamName != null and mainTeamName != ''">
AND t.main_team_name like CONCAT('%',#{mainTeamName},'%')
</if>
<if test="guestTeamName != null and guestTeamName != ''">
AND t.guest_team_name like CONCAT('%',#{guestTeamName},'%')
</if>
<if test="competitionAddress != null and competitionAddress != '' ">
AND t.competition_address like CONCAT('%',#{competitionAddress},'%')
</if>
<if test="buildingName != null and buildingName != '' ">
AND t.building_name like CONCAT('%',#{buildingName},'%')
</if>
order by t.competition_time asc
</select>
<select id="getLatelySchedule" resultType="com.ruoyi.system.domain.vo.CompetitionTeamVsTeamVo">
select
cpt.competition_begin_time as theTime,
team1.team_logo as mainTeamLogo,
team2.team_logo as guestTeamLogo,
t.*
from competition cpt
INNER JOIN competition_team_vs_team t on t.competition_id = cpt.id and t.is_deleted=0
LEFT JOIN basketball_team team1 on t.main_team_id = team1.ID and team1.IS_DELETED=0
LEFT JOIN basketball_team team2 on t.main_team_id = team2.ID and team2.IS_DELETED=0
where cpt.is_deleted=0
<if test="mainTeamId != null ">
AND t.main_team_id=#{mainTeamId}
</if>
<if test="guestTeamId != null ">
AND t.guest_team_id =#{guestTeamId}
</if>
order by t.competition_time desc
limit 0,3
</select>
<select id="getCompetitionTeamIntegralListById"
resultType="com.ruoyi.system.domain.vo.CompetitionTeamIntegralVo">
SELECT
ANY_VALUE ( t.team_name ) as teamName,
any_value (team.team_logo) as teamLogo,
t.competition_of_team_id,
sum(IF( t.vs_result = 'win', 1, 0 )) AS win,
sum(IF( t.vs_result = 'fail', 1, 0 )) AS fail,
sum(IFNULL( t.one_node_score, 0 )+ IFNULL( t.two_node_score, 0 )+ IFNULL( t.three_node_score, 0 )+ IFNULL( t.four_node_score, 0 )+ IFNULL( t.five_node_score, 0 )+ IFNULL( t.six_node_score, 0 )) AS totalScore,
sum(t.integral) AS integral
FROM competition_result t left join competition_of_team team on team.id = t.competition_of_team_id
WHERE t.is_deleted = 0 AND t.competition_id = #{id}
GROUP BY t.competition_of_team_id
ORDER BY sum(t.integral) desc
</select>
<select id="getTodaySchedule" resultType="com.ruoyi.system.domain.vo.CompetitionTeamVsTeamVo">
select
t.id as id,
t.competition_id as competitionId,
t.main_team_id as mainTeamId,
b1.TEAM_NAME as mainTeamName,
b1.team_logo as mainTeamLogo,
t.guest_team_id as guestTeamId,
b2.TEAM_NAME as guestTeamName,
b2.team_logo as guestTeamLogo,
t.competition_time as competitionTime,
t.building_id as buildingId,
t.building_name as buildingName,
t.competition_address as competitionAddress,
t.competition_group as competitionGroup,
t.status,
t.vs_type as vsType,
t.created_time as createdTime,
t.last_updated_time as lastUpdatedTime,
t.created_by as createdBy,
t.modified_by as modifiedBy,
t.main_team_score as mainTeamScore,
t.guest_team_score as guestTeamScore,
t.is_deleted as isDeleted,
DATE_FORMAT(t.competition_time,'%Y年%m月%d日') as competitionDate,
CASE dayofweek(t.competition_time)
WHEN 1 THEN
'星期日'
WHEN 2 THEN
'星期一'
WHEN 3 THEN
'星期二'
WHEN 4 THEN
'星期三'
WHEN 5 THEN
'星期四'
WHEN 6 THEN
'星期五'
WHEN 7 THEN
'星期六'
END as weekDayName,
CASE t.status
WHEN -1 THEN
'已取消'
WHEN 0 THEN
'报名中'
WHEN 1 THEN
'比赛中'
WHEN 2 THEN
'已结束'
END as statusName,
DATE_FORMAT(t.competition_time,'%H:%i') AS theTime,
t.remark as remark,
u1.OPENID as guestTeamOpenId,
u2.OPENID as mainTeamOpenId
from competition_team_vs_team t
LEFT JOIN competition_of_team b1 ON b1.id = t.main_team_id
left join user_info u1 on u1.id=b1.created_by
left join competition_of_team b2 on t.guest_team_id=b2.id
left join user_info u2 on u2.id=b2.created_by
where 1=1
<![CDATA[ and to_days(competition_time) <= to_days(now()) ]]>
<if test="comp.id != null ">
AND t.id=#{comp.id}
</if>
<if test="comp.status != null ">
AND t.status =#{comp.status}
</if>
<if test="comp.isDeleted != null ">
AND t.is_deleted =#{comp.isDeleted}
</if>
<if test="comp.competitionId != null ">
AND t.competition_id=#{comp.competitionId}
</if>
<if test="comp.buildingName != null and comp.buildingName != ''">
AND t.building_name like CONCAT('%',#{comp.buildingName},'%')
</if>
<if test="comp.competitionGroup != null ">
AND t.competition_group = #{comp.competitionGroup}
</if>
<if test="comp.mainTeamName != null and comp.mainTeamName != ''">
AND t.main_team_name like CONCAT('%',#{comp.mainTeamName},'%')
</if>
<if test="comp.guestTeamName != null and comp.guestTeamName != ''">
AND t.guest_team_name like CONCAT('%',#{comp.guestTeamName},'%')
</if>
<if test="comp.competitionAddress != null and comp.competitionAddress != '' ">
AND t.competition_address like CONCAT('%',#{comp.competitionAddress},'%')
</if>
<if test="comp.buildingName != null and comp.buildingName != '' ">
AND t.building_name like CONCAT('%',#{comp.buildingName},'%')
</if>
order by t.competition_time asc
</select>
<insert id="insertCompetitionTeamVsTeam" parameterType="CompetitionTeamVsTeam" useGeneratedKeys="true" keyProperty="id">
insert into competition_team_vs_team
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="competitionId != null">competition_id,</if>
<if test="mainTeamId != null">main_team_id,</if>
<if test="mainTeamName != null">main_team_name,</if>
<if test="guestTeamId != null">guest_team_id,</if>
<if test="guestTeamName != null">guest_team_name,</if>
<if test="competitionTime != null">competition_time,</if>
<if test="buildingId != null">building_id,</if>
<if test="buildingName != null">building_name,</if>
<if test="competitionAddress != null">competition_address,</if>
<if test="competitionGroup != null">competition_group,</if>
<if test="status != null">status,</if>
<if test="createdTime != null">created_time,</if>
<if test="lastUpdatedTime != null">last_updated_time,</if>
<if test="createdBy != null">created_by,</if>
<if test="modifiedBy != null">modified_by,</if>
<if test="isDeleted != null">is_deleted,</if>
<if test="remark != null">remark,</if>
<if test="mainTeamScore != null">main_team_score,</if>
<if test="guestTeamScore != null">guest_team_score,</if>
<if test="vsType != null">vs_type,</if>
<if test="batchNumber != null">batch_number,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="competitionId != null">#{competitionId},</if>
<if test="mainTeamId != null">#{mainTeamId},</if>
<if test="mainTeamName != null">#{mainTeamName},</if>
<if test="guestTeamId != null">#{guestTeamId},</if>
<if test="guestTeamName != null">#{guestTeamName},</if>
<if test="competitionTime != null">#{competitionTime},</if>
<if test="buildingId != null">#{buildingId},</if>
<if test="buildingName != null">#{buildingName},</if>
<if test="competitionAddress != null">#{competitionAddress},</if>
<if test="competitionGroup != null">#{competitionGroup},</if>
<if test="status != null">#{status},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="lastUpdatedTime != null">#{lastUpdatedTime},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="modifiedBy != null">#{modifiedBy},</if>
<if test="isDeleted != null">#{isDeleted},</if>
<if test="remark != null">#{remark},</if>
<if test="mainTeamScore != null">#{mainTeamScore},</if>
<if test="guestTeamScore != null">#{guestTeamScore},</if>
<if test="vsType != null">#{vsType},</if>
<if test="batchNumber != null">#{batchNumber},</if>
</trim>
</insert>
<update id="updateCompetitionTeamVsTeam" parameterType="CompetitionTeamVsTeam">
update competition_team_vs_team
<trim prefix="SET" suffixOverrides=",">
<if test="competitionId != null">competition_id = #{competitionId},</if>
<if test="mainTeamId != null">main_team_id = #{mainTeamId},</if>
<if test="mainTeamName != null">main_team_name = #{mainTeamName},</if>
<if test="guestTeamId != null">guest_team_id = #{guestTeamId},</if>
<if test="guestTeamName != null">guest_team_name = #{guestTeamName},</if>
<if test="competitionTime != null">competition_time = #{competitionTime},</if>
<if test="buildingId != null">building_id = #{buildingId},</if>
<if test="buildingName != null">building_name = #{buildingName},</if>
<if test="competitionAddress != null">competition_address = #{competitionAddress},</if>
<if test="competitionGroup != null">competition_group = #{competitionGroup},</if>
<if test="status != null">status = #{status},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="lastUpdatedTime != null">last_updated_time = #{lastUpdatedTime},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="modifiedBy != null">modified_by = #{modifiedBy},</if>
<if test="isDeleted != null">is_deleted = #{isDeleted},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="mainTeamScore != null">main_team_score = #{mainTeamScore},</if>
<if test="guestTeamScore != null">guest_team_score = #{guestTeamScore},</if>
<if test="vsType != null">vs_type = #{vsType},</if>
<if test="batchNumber != null">batch_number = #{batchNumber},</if>
</trim>
where id = #{id}
</update>
<update id="updateCompetitionTeamVsTeamByCondition">
update competition_team_vs_team set is_deleted = 1
<where>
<if test="competitionId != null "> and competition_id = #{competitionId}</if>
<if test="mainTeamId != null "> and main_team_id = #{mainTeamId}</if>
<if test="mainTeamName != null and mainTeamName != ''"> and main_team_name like concat('%', #{mainTeamName}, '%')</if>
<if test="guestTeamId != null "> and guest_team_id = #{guestTeamId}</if>
<if test="guestTeamName != null and guestTeamName != ''"> and guest_team_name like concat('%', #{guestTeamName}, '%')</if>
<if test="competitionTime != null "> and competition_time = #{competitionTime}</if>
<if test="buildingId != null "> and building_id = #{buildingId}</if>
<if test="buildingName != null and buildingName != ''"> and building_name like concat('%', #{buildingName}, '%')</if>
<if test="competitionAddress != null and competitionAddress != ''"> and competition_address = #{competitionAddress}</if>
<if test="competitionGroup != null and competitionGroup != ''"> and competition_group = #{competitionGroup}</if>
<if test="status != null "> and status = #{status}</if>
<if test="lastUpdatedTime != null "> and last_updated_time = #{lastUpdatedTime}</if>
<if test="vsType != null and vsType != ''"> and vs_type = #{vsType}</if>
<if test="batchNumber != null and batchNumber != ''"> and batch_number = #{batchNumber}</if>
</where>
</update>
<update id="competitionVsTeamStatusUpdate">
update competition_team_vs_team set status = 2 where status &lt;&gt; 2 and competition_time <![CDATA[ <= ]]> now()
</update>
<delete id="deleteCompetitionTeamVsTeamById" parameterType="Long">
delete from competition_team_vs_team where id = #{id}
</delete>
<delete id="deleteCompetitionTeamVsTeamByIds" parameterType="String">
delete from competition_team_vs_team where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>