MatchDictServiceImpl.java
3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.common.constant.ProjectType;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.match.SelectListPageDTO;
import com.subsidy.model.MatchDictDO;
import com.subsidy.mapper.MatchDictMapper;
import com.subsidy.service.MatchDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.match.MatchDictVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
* 赛事年份管理 服务实现类
* </p>
*
* @author Tuyp
* @since 2025-01-07
*/
@Service
public class MatchDictServiceImpl extends ServiceImpl<MatchDictMapper, MatchDictDO> implements MatchDictService {
public List<MatchDictDO> matches(MatchDictDO matchDictDO) {
return this.baseMapper.matches(matchDictDO.getMatchName());
}
public String addMatch(MatchDictDO matchDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<MatchDictDO>()
.lambda()
.eq(MatchDictDO::getYear, matchDictDO.getYear()));
if (count > 0) {
throw new HttpException(10006);
}
matchDictDO.setStatus(0);
this.baseMapper.insert(matchDictDO);
return ConstantUtils.ADD_SUCCESS;
}
public String deleteMatch(MatchDictDO matchDictDO) {
this.baseMapper.deleteById(matchDictDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
public String updateMatch(MatchDictDO matchDictDO) {
this.baseMapper.updateById(matchDictDO);
return ConstantUtils.SUCCESS_UPDATE;
}
@Transactional(rollbackFor = Exception.class)
public String openMatch(MatchDictDO matchDictDO) {
this.baseMapper.closeMatch();
this.baseMapper.openMatch(matchDictDO.getId());
return ConstantUtils.SUCCESS_UPDATE;
}
public MatchDictDO openedMatch() {
return this.baseMapper.selectOne(new QueryWrapper<MatchDictDO>()
.lambda()
.eq(MatchDictDO::getStatus, "1"));
}
public MatchDictDO openOneMatch(MatchDictDO matchDictDO) {
return this.baseMapper.selectById(matchDictDO.getId());
}
@Override
public IPage getVocationalPage(SelectListPageDTO selectListPageDTO) {
Page page = new Page(selectListPageDTO.getPageNo(), selectListPageDTO.getPageSize());
IPage<MatchDictVO> iPage = this.baseMapper.getSeedTrackMatchPage(page, ProjectType.VOCATIONAL);
// for (MatchDictVO record : iPage.getRecords()) {
// List<MatchScheduleDO> list = matchScheduleService.list(new QueryWrapper<MatchScheduleDO>()
// .lambda()
// .eq(MatchScheduleDO::getMatchId, record.getId()));
// record.setSchedule(list);
// }
return iPage;
}
}