|
|
@@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.system.domain.vo.SysOssVo;
|
|
|
import org.dromara.system.service.ISysOssService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
@@ -127,6 +128,53 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
public TableDataInfo<TournamentsVo> queryPageList(TournamentsBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<Tournaments> lqw = buildQueryWrapper(bo);
|
|
|
Page<TournamentsVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ List<TournamentsVo> records = result.getRecords();
|
|
|
+ for (TournamentsVo record : records) {
|
|
|
+ Long tournamentId = record.getId();
|
|
|
+ //赛事报名条件
|
|
|
+ TournamentEntryConditionsVo tournamentEntryConditionsVo = tournamentEntryConditionsMapper.selectByTournamentInfo(tournamentId);
|
|
|
+ if(tournamentEntryConditionsVo!=null){
|
|
|
+ record.setItemsId(tournamentEntryConditionsVo.getItemId());
|
|
|
+ record.setItemsNum(tournamentEntryConditionsVo.getRequiredQuantity());
|
|
|
+ record.setItemsName(tournamentEntryConditionsVo.getItemsName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //绑定的盲注信息
|
|
|
+ TournamentBlindStructuresVo tournamentBlindStructuresVo = tournamentBlindStructuresMapper.selectTournamentBlindStructureByTournamentId(tournamentId);
|
|
|
+ if(tournamentBlindStructuresVo!=null){
|
|
|
+ record.setBlindStructureId(tournamentBlindStructuresVo.getBlindStructureId());
|
|
|
+ record.setBlindStructuresName(tournamentBlindStructuresVo.getBlindStructuresName());
|
|
|
+ }
|
|
|
+
|
|
|
+ //排名
|
|
|
+ List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentId(tournamentId);
|
|
|
+ if(prizeDistributionsVos!=null){
|
|
|
+ List<ItemsPrizeDto> itemsPrizeList=new ArrayList<>();
|
|
|
+
|
|
|
+ // 提取并按排名正序排序后,取出 id 列表
|
|
|
+ List<Long> ids = prizeDistributionsVos.stream()
|
|
|
+ .sorted(Comparator.comparing(PrizeDistributionsVo::getPaiming))
|
|
|
+ .map(PrizeDistributionsVo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ int i=0;
|
|
|
+ for (Long id2 : ids) {
|
|
|
+ i++;
|
|
|
+ //奖品
|
|
|
+ PrizeDistributionItemsVo prizeDistributionItemsVos = prizeDistributionItemsMapper.selectByPrizeDistributionId(id2);
|
|
|
+ ItemsPrizeDto itemsPrizeBo = new ItemsPrizeDto();
|
|
|
+ itemsPrizeBo.setRanking(Long.valueOf(i));
|
|
|
+ itemsPrizeBo.setItemId(prizeDistributionItemsVos.getItemId());
|
|
|
+ itemsPrizeBo.setQuantity(prizeDistributionItemsVos.getQuantity());
|
|
|
+ itemsPrizeBo.setItemsName(prizeDistributionItemsVos.getItemsName());
|
|
|
+ itemsPrizeList.add(itemsPrizeBo);
|
|
|
+ }
|
|
|
+ record.setItemsPrizeList(itemsPrizeList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
|
@@ -147,6 +195,7 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
LambdaQueryWrapper<Tournaments> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.orderByAsc(Tournaments::getId);
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getName()), Tournaments::getName, bo.getName());
|
|
|
+ lqw.eq(bo.getId() != null, Tournaments::getId, bo.getId());
|
|
|
lqw.eq(bo.getStartTime() != null, Tournaments::getStartTime, bo.getStartTime());
|
|
|
lqw.eq(bo.getGameType() != null, Tournaments::getGameType, bo.getGameType());
|
|
|
lqw.eq(bo.getStartingChips() != null, Tournaments::getStartingChips, bo.getStartingChips());
|
|
|
@@ -166,11 +215,8 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
* @return 是否新增成功
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean insertByBo(TournamentsDto bo, MultipartFile competitionIcon) {
|
|
|
+ public Boolean insertByBo(TournamentsDto bo) {
|
|
|
try {
|
|
|
- // 初始化 ObjectMapper
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
-
|
|
|
// 转换 BO -> Entity
|
|
|
Tournaments add = new Tournaments();
|
|
|
BeanUtils.copyProperties(bo, add);
|
|
|
@@ -178,24 +224,16 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
|
// 解析 itemsPrizeList JSON 字符串
|
|
|
- List<ItemsPrizeDto> prizeList = parsePrizeList(bo.getItemsPrizeList(), mapper);
|
|
|
+ List<ItemsPrizeDto> prizeList = bo.getItemsPrizeList();
|
|
|
|
|
|
if (CollectionUtils.isEmpty(prizeList)) {
|
|
|
log.error("奖励列表为空");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+ Long userId = LoginHelper.getUserId();
|
|
|
+ add.setCreateUserId(userId);
|
|
|
// 处理开始时间
|
|
|
add.setStartTime(parseDateTime(bo.getStartTime()));
|
|
|
-
|
|
|
- // 上传赛事图标
|
|
|
- if (competitionIcon != null && !competitionIcon.isEmpty()) {
|
|
|
- SysOssVo sysOssVo = this.uploadTournament(competitionIcon);
|
|
|
- if (sysOssVo != null) {
|
|
|
- add.setCompetitionIcon(sysOssVo.getUrl());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 插入赛事主表
|
|
|
boolean flag = baseMapper.insertTournament(add) > 0;
|
|
|
if (!flag) {
|
|
|
@@ -263,10 +301,8 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
* @return 是否修改成功
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean updateByBo(TournamentsDto bo, MultipartFile competitionIcon) {
|
|
|
+ public Boolean updateByBo(TournamentsDto bo) {
|
|
|
try {
|
|
|
- // 初始化 ObjectMapper
|
|
|
- ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
// 转换 BO -> Entity
|
|
|
Tournaments update = new Tournaments();
|
|
|
@@ -274,24 +310,17 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
// 解析 itemsPrizeList JSON 字符串
|
|
|
- List<ItemsPrizeDto> prizeList = parsePrizeList(bo.getItemsPrizeList(), mapper);
|
|
|
+ List<ItemsPrizeDto> prizeList = bo.getItemsPrizeList();
|
|
|
|
|
|
if (CollectionUtils.isEmpty(prizeList)) {
|
|
|
log.error("奖励列表为空");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+ Long userId = LoginHelper.getUserId();
|
|
|
+ update.setUpdateUserId(userId);
|
|
|
// 处理开始时间
|
|
|
update.setStartTime(parseDateTime(bo.getStartTime()));
|
|
|
|
|
|
- // 上传赛事图标
|
|
|
- if (competitionIcon != null && !competitionIcon.isEmpty()) {
|
|
|
- SysOssVo sysOssVo = this.uploadTournament(competitionIcon);
|
|
|
- if (sysOssVo != null) {
|
|
|
- update.setCompetitionIcon(sysOssVo.getUrl());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 插入赛事主表
|
|
|
boolean flag = baseMapper.updateTournamentsById(update) > 0;
|
|
|
if (!flag) {
|
|
|
@@ -314,7 +343,7 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
List<PrizeDistributionsVo> prizeDistributionsVos = prizeDistributionsMapper.selectByTournamentId(tournamentId);
|
|
|
if(prizeDistributionsVos.size()>0){
|
|
|
for (PrizeDistributionsVo prizeDistributionsVo : prizeDistributionsVos) {
|
|
|
- prizeDistributionsMapper.deleteById(prizeDistributionsVo.getId());
|
|
|
+ prizeDistributionsMapper.deleteByIds(prizeDistributionsVo.getId());
|
|
|
}
|
|
|
}
|
|
|
//重新处理奖励分布
|
|
|
@@ -322,7 +351,6 @@ public class TournamentsServiceImpl implements ITournamentsService {
|
|
|
return true;
|
|
|
}catch (Exception e){
|
|
|
log.error("赛事修改过程中发生异常", e);
|
|
|
- e.printStackTrace();
|
|
|
return false;
|
|
|
}
|
|
|
}
|