大赛管理功能

This commit is contained in:
tiger_zhou 2024-02-23 16:50:22 +08:00
parent 1cf7397f55
commit 2be04ceca1
13 changed files with 5061 additions and 79 deletions

View File

@ -6,6 +6,8 @@ import club.joylink.rtss.services.race.RacePaperService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperCreateVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperDetailVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperModuleVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperVO;
import club.joylink.rtss.vo.race.RacePaperQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@ -49,6 +52,21 @@ public class RacePaperController {
return racePaperService.pageQuery(queryVO);
}
@PostMapping("/{id}/config")
public void configSeting(@PathVariable("id") Long id, @RequestBody RacePaperModuleVO moduleVO, @RequestAttribute AccountVO user) {
this.racePaperService.configSeting(id, moduleVO, user);
}
@GetMapping("/{id}")
public RacePaperDetailVO detail(@PathVariable("id") Long id) {
return this.racePaperService.detail(id);
}
@PutMapping("/{id}/copy")
public void copy(@PathVariable("id") Long id, @RequestAttribute AccountVO user) {
this.racePaperService.copy(id, user);
}
/**
* 删除
*/

View File

@ -43,7 +43,7 @@ public class RaceScoreRuleController {
this.scoreRuleService.editRule(ruleId, rule, user);
}
@GetMapping(value = "/{id}", produces = {"application/json"})
@GetMapping(value = "/{id}")
public RaceScoringRuleVO detail(@PathVariable("id") Long id) {
return this.scoreRuleService.detail(id);
}

View File

@ -19,7 +19,7 @@ import org.springframework.stereotype.Repository;
public interface RacetrPaperDAO extends MyBatisBaseDao<RacetrPaper, Long, RacetrPaperExample> {
@Select("<script>"
+ " select A.id,A.name,A.`desc`,A.season_id as seasonId ,B.code as seasonName "
+ " select A.id,A.name,A.`desc`,A.season_id as seasonId ,B.code as seasonName,A.support_copy "
+ " ,A.creator_id,A.create_time,A.updater_id,A.update_time,C.nickname as creatorName,D.nickname as updaterName "
+ " from racetr_paper A left join racetr_season B on A.season_id = B.id "
+ " left join sys_account C on A.creator_id = C.id "
@ -28,6 +28,9 @@ public interface RacetrPaperDAO extends MyBatisBaseDao<RacetrPaper, Long, Racetr
+ "<if test='vo.name!= null and vo.name!= \"\"'> "
+ " and A.name like CONCAT('%',#{vo.name},'%') "
+ "</if> "
+ "<if test='vo.id!= null and vo.id >=0'> "
+ " and A.id = #{vo.name}"
+ "</if> "
+ "</script>")
List<RacePaperPageVO> pages(@Param("vo") RacePaperQueryVO vo);
}

View File

@ -23,6 +23,11 @@ public class RacetrPaper implements Serializable {
*/
private String desc;
/**
* 0=不支持;1=支持
*/
private Boolean supportCopy;
/**
* 赛季ID
*/
@ -48,5 +53,10 @@ public class RacetrPaper implements Serializable {
*/
private LocalDateTime updateTime;
/**
* module配置
*/
private byte[] configs;
private static final long serialVersionUID = 1L;
}

View File

@ -325,6 +325,66 @@ public class RacetrPaperExample {
return (Criteria) this;
}
public Criteria andSupportCopyIsNull() {
addCriterion("support_copy is null");
return (Criteria) this;
}
public Criteria andSupportCopyIsNotNull() {
addCriterion("support_copy is not null");
return (Criteria) this;
}
public Criteria andSupportCopyEqualTo(Boolean value) {
addCriterion("support_copy =", value, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyNotEqualTo(Boolean value) {
addCriterion("support_copy <>", value, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyGreaterThan(Boolean value) {
addCriterion("support_copy >", value, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyGreaterThanOrEqualTo(Boolean value) {
addCriterion("support_copy >=", value, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyLessThan(Boolean value) {
addCriterion("support_copy <", value, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyLessThanOrEqualTo(Boolean value) {
addCriterion("support_copy <=", value, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyIn(List<Boolean> values) {
addCriterion("support_copy in", values, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyNotIn(List<Boolean> values) {
addCriterion("support_copy not in", values, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyBetween(Boolean value1, Boolean value2) {
addCriterion("support_copy between", value1, value2, "supportCopy");
return (Criteria) this;
}
public Criteria andSupportCopyNotBetween(Boolean value1, Boolean value2) {
addCriterion("support_copy not between", value1, value2, "supportCopy");
return (Criteria) this;
}
public Criteria andSeasonIdIsNull() {
addCriterion("season_id is null");
return (Criteria) this;

View File

@ -13,6 +13,8 @@ import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.common.ModifyInfo.ModifyInfoVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperCreateVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperDetailVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperModuleVO;
import club.joylink.rtss.vo.race.RacePaper.RacePaperVO;
import club.joylink.rtss.vo.race.RacePaperPageVO;
import club.joylink.rtss.vo.race.RacePaperQueryVO;
@ -26,20 +28,23 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestAttribute;
@Service
@Slf4j
public class RacePaperService extends RaceService {
@Autowired
private RacetrPaperDAO paperDAO;
@Autowired
/*@Autowired
private ISysUserService iSysUserService;
@Autowired
private RacetrModuleDAO moduleDAO;
private RacetrModuleDAO moduleDAO;*/
private RacetrPaper findId(Long id) {
RacetrPaper rp = this.paperDAO.selectByPrimaryKey(id);
@ -57,6 +62,7 @@ public class RacePaperService extends RaceService {
rp.setUpdateTime(now);
rp.setCreatorId(user.getId());
rp.setUpdaterId(user.getId());
rp.setSupportCopy(createVO.getSupportCopy());
this.paperDAO.insertSelective(rp);
}
@ -67,6 +73,7 @@ public class RacePaperService extends RaceService {
rp.setSeasonId(updateVO.getSeasonId());
rp.setUpdateTime(LocalDateTime.now());
rp.setUpdaterId(user.getId());
rp.setSupportCopy(updateVO.getSupportCopy());
this.paperDAO.updateByPrimaryKey(rp);
}
@ -89,6 +96,7 @@ public class RacePaperService extends RaceService {
builder.setModifyInfo(modifyInfoVO);
builder.setSeasonId(rp.getSeasonId());
builder.setSeasonName(Objects.isNull(rp.getSeasonName()) ? "" : rp.getSeasonName());
builder.setSupportCopy(!Objects.isNull(rp.getSupportCopy()) && rp.getSupportCopy());
return builder.build();
}
@ -104,11 +112,58 @@ public class RacePaperService extends RaceService {
}
public void delete(long id) {
RacetrModuleExample moduleExample = new RacetrModuleExample();
moduleExample.createCriteria().andPaperIdEqualTo(id);
List<RacetrModule> modules = this.moduleDAO.selectByExample(moduleExample);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(CollectionUtils.isEmpty(modules),
String.format("已被模块[%s]关联不能删除", modules.stream().map(RacetrModule::getCode).collect(Collectors.joining(","))));
// RacetrModuleExample moduleExample = new RacetrModuleExample();
// moduleExample.createCriteria().andPaperIdEqualTo(id);
// List<RacetrModule> modules = this.moduleDAO.selectByExample(moduleExample);
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(CollectionUtils.isEmpty(modules),
// String.format("已被模块[%s]关联不能删除", modules.stream().map(RacetrModule::getCode).collect(Collectors.joining(","))));
this.paperDAO.deleteByPrimaryKey(id);
}
public RacePaperDetailVO detail(Long id) {
RacePaperQueryVO query = new RacePaperQueryVO();
query.setId(id);
List<RacePaperPageVO> list = this.paperDAO.pages(query);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(!CollectionUtils.isEmpty(list), "未找到对应的试卷");
RacePaperPageVO paper = list.get(0);
RacePaperDetailVO.Builder vo = RacePaperDetailVO.newBuilder();
vo.setId(paper.getId());
vo.setName(paper.getName());
vo.setDesc(paper.getDesc());
vo.setSupportCopy(!Objects.isNull(paper.getSupportCopy()) && paper.getSupportCopy());
vo.setModifyInfo(this.createModifyInfo(paper.getCreatorId(), paper.getCreatorName(), paper.getUpdaterId(), paper.getUpdaterName(), paper.getCreateTime(), paper.getUpdateTime()));
vo.setSeasonId(paper.getSeasonId());
vo.setSeasonName(Objects.isNull(paper.getSeasonName()) ? "" : paper.getSeasonName());
try {
RacePaperModuleVO moduleVO = RacePaperModuleVO.parseFrom(paper.getConfigs());
vo.setModuleVo(moduleVO);
} catch (Exception e) {
log.error("试卷[{}][{}] 配置解析失败 msg:[{}]", paper.getName(), paper.getId(), e.getMessage());
BusinessExceptionAssertEnum.DATA_ERROR.fail("数据配置解析失败");
}
return vo.build();
}
public void configSeting(Long id, RacePaperModuleVO moduleVO, AccountVO user) {
RacetrPaper paper = this.findId(id);
paper.setUpdateTime(LocalDateTime.now());
paper.setUpdaterId(user.getId());
paper.setConfigs(moduleVO.toByteArray());
this.paperDAO.updateByPrimaryKey(paper);
}
public void copy(Long id, AccountVO user) {
RacetrPaper paper = this.findId(id);
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(paper.getSupportCopy(), "此试卷不支持拷贝");
LocalDateTime now = LocalDateTime.now();
paper.setId(null);
paper.setName(String.format("%s_copy", paper.getName()));
paper.setSupportCopy(!Objects.isNull(paper.getSupportCopy()) && paper.getSupportCopy());
paper.setCreatorId(user.getId());
paper.setUpdaterId(user.getId());
paper.setCreateTime(now);
paper.setUpdateTime(now);
this.paperDAO.insert(paper);
}
}

View File

@ -135,10 +135,6 @@ public class RaceSceneService extends RaceService {
}
}
public static void main(String[] args) {
StorageSimulation.Builder ss = StorageSimulation.newBuilder();
ss.addPlayerIds("a");
}
private PublishHereVO createSceneProto(Long TraningPublish) {
DraftTraining2WithBLOBs bs = this.trainingDao.selectByPrimaryKey(TraningPublish);

View File

@ -65,7 +65,6 @@ public class RaceScoreRuleService extends RaceService {
rule.setUpdaterId(user.getId());
rule.setUpdateTime(LocalDateTime.now());
rule.setRule(ruleProto.toByteArray());
//TODO 规则明细
ruleDAO.updateByPrimaryKeySelective(rule);
}

View File

@ -16,6 +16,7 @@ import club.joylink.rtss.vo.race.RaceTask.RaceTaskDetailVO;
import club.joylink.rtss.vo.race.RaceTaskTreeVO;
import com.google.common.collect.Lists;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -128,6 +129,9 @@ public class RaceTaskService extends RaceService {
List<RacetrTask> taskList = this.raceTaskDAO.selectByExample(null);
Map<Long, List<RaceTaskTreeVO>> mapList = taskList.stream().map(RaceTaskTreeVO::new).collect(Collectors.groupingBy(RaceTaskTreeVO::getParentId));
List<RaceTaskTreeVO> rootTaskList = mapList.get(TASK_ROOT_ID);
if (CollectionUtils.isEmpty(rootTaskList)) {
return Collections.emptyList();
}
for (RaceTaskTreeVO rootTask : rootTaskList) {
this.loopFind(rootTask, mapList);
}

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ public class RacePaperPageVO {
private Long id;
private String name;
private String desc;
private Boolean supportCopy;
private Long seasonId;
private String seasonName;
private Long creatorId;
@ -17,4 +18,5 @@ public class RacePaperPageVO {
private LocalDateTime updateTime;
private String creatorName;
private String updaterName;
private byte[] configs;
}

View File

@ -7,5 +7,5 @@ import lombok.Data;
public class RacePaperQueryVO extends PageQueryVO {
private String name;
private Long id;
}

View File

@ -5,12 +5,16 @@
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="desc" jdbcType="VARCHAR" property="desc" />
<result column="support_copy" jdbcType="BIT" property="supportCopy" />
<result column="season_id" jdbcType="BIGINT" property="seasonId" />
<result column="creator_id" jdbcType="BIGINT" property="creatorId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="updater_id" jdbcType="BIGINT" property="updaterId" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="club.joylink.rtss.entity.racetr.RacetrPaper">
<result column="configs" jdbcType="LONGVARBINARY" property="configs" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
@ -70,8 +74,36 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, `desc`, season_id, creator_id, create_time, updater_id, update_time
id, `name`, `desc`, support_copy, season_id, creator_id, create_time, updater_id,
update_time
</sql>
<sql id="Blob_Column_List">
configs
</sql>
<select id="selectByExampleWithBLOBs" parameterType="club.joylink.rtss.entity.racetr.RacetrPaperExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from racetr_paper
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.racetr.RacetrPaperExample" resultMap="BaseResultMap">
select
<if test="distinct">
@ -94,9 +126,11 @@
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from racetr_paper
where id = #{id,jdbcType=BIGINT}
</select>
@ -111,12 +145,14 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.racetr.RacetrPaper" useGeneratedKeys="true">
insert into racetr_paper (`name`, `desc`, season_id,
creator_id, create_time, updater_id,
update_time)
values (#{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{seasonId,jdbcType=BIGINT},
#{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{updaterId,jdbcType=BIGINT},
#{updateTime,jdbcType=TIMESTAMP})
insert into racetr_paper (`name`, `desc`, support_copy,
season_id, creator_id, create_time,
updater_id, update_time, configs
)
values (#{name,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{supportCopy,jdbcType=BIT},
#{seasonId,jdbcType=BIGINT}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{updaterId,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{configs,jdbcType=LONGVARBINARY}
)
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.racetr.RacetrPaper" useGeneratedKeys="true">
insert into racetr_paper
@ -127,6 +163,9 @@
<if test="desc != null">
`desc`,
</if>
<if test="supportCopy != null">
support_copy,
</if>
<if test="seasonId != null">
season_id,
</if>
@ -142,6 +181,9 @@
<if test="updateTime != null">
update_time,
</if>
<if test="configs != null">
configs,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
@ -150,6 +192,9 @@
<if test="desc != null">
#{desc,jdbcType=VARCHAR},
</if>
<if test="supportCopy != null">
#{supportCopy,jdbcType=BIT},
</if>
<if test="seasonId != null">
#{seasonId,jdbcType=BIGINT},
</if>
@ -165,6 +210,9 @@
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="configs != null">
#{configs,jdbcType=LONGVARBINARY},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.racetr.RacetrPaperExample" resultType="java.lang.Long">
@ -185,6 +233,9 @@
<if test="record.desc != null">
`desc` = #{record.desc,jdbcType=VARCHAR},
</if>
<if test="record.supportCopy != null">
support_copy = #{record.supportCopy,jdbcType=BIT},
</if>
<if test="record.seasonId != null">
season_id = #{record.seasonId,jdbcType=BIGINT},
</if>
@ -200,16 +251,36 @@
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.configs != null">
configs = #{record.configs,jdbcType=LONGVARBINARY},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update racetr_paper
set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
`desc` = #{record.desc,jdbcType=VARCHAR},
support_copy = #{record.supportCopy,jdbcType=BIT},
season_id = #{record.seasonId,jdbcType=BIGINT},
creator_id = #{record.creatorId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
updater_id = #{record.updaterId,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
configs = #{record.configs,jdbcType=LONGVARBINARY}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update racetr_paper
set id = #{record.id,jdbcType=BIGINT},
`name` = #{record.name,jdbcType=VARCHAR},
`desc` = #{record.desc,jdbcType=VARCHAR},
support_copy = #{record.supportCopy,jdbcType=BIT},
season_id = #{record.seasonId,jdbcType=BIGINT},
creator_id = #{record.creatorId,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
@ -228,6 +299,9 @@
<if test="desc != null">
`desc` = #{desc,jdbcType=VARCHAR},
</if>
<if test="supportCopy != null">
support_copy = #{supportCopy,jdbcType=BIT},
</if>
<if test="seasonId != null">
season_id = #{seasonId,jdbcType=BIGINT},
</if>
@ -243,13 +317,30 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="configs != null">
configs = #{configs,jdbcType=LONGVARBINARY},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.racetr.RacetrPaper">
update racetr_paper
set `name` = #{name,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR},
support_copy = #{supportCopy,jdbcType=BIT},
season_id = #{seasonId,jdbcType=BIGINT},
creator_id = #{creatorId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
updater_id = #{updaterId,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=TIMESTAMP},
configs = #{configs,jdbcType=LONGVARBINARY}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.racetr.RacetrPaper">
update racetr_paper
set `name` = #{name,jdbcType=VARCHAR},
`desc` = #{desc,jdbcType=VARCHAR},
support_copy = #{supportCopy,jdbcType=BIT},
season_id = #{seasonId,jdbcType=BIGINT},
creator_id = #{creatorId,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP},