|
|
@@ -0,0 +1,212 @@
|
|
|
+package org.dromara.physical.service.impl;
|
|
|
+
|
|
|
+import org.dromara.business.domain.vo.UserRealInfoVo;
|
|
|
+import org.dromara.business.domain.vo.UserVo;
|
|
|
+import org.dromara.business.mapper.UserMapper;
|
|
|
+import org.dromara.business.mapper.UserRealInfoMapper;
|
|
|
+import org.dromara.common.core.utils.MapstructUtils;
|
|
|
+import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+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.physical.domain.PhysicalTournamentsRegistration;
|
|
|
+import org.dromara.physical.domain.bo.PhysicalTournamentsRegistrationBo;
|
|
|
+import org.dromara.physical.domain.vo.PhysicalLeagueTournamentVo;
|
|
|
+import org.dromara.physical.domain.vo.PhysicalTournamentsRegistrationVo;
|
|
|
+import org.dromara.physical.mapper.PhysicalLeagueTournamentMapper;
|
|
|
+import org.dromara.physical.mapper.PhysicalTournamentsRegistrationMapper;
|
|
|
+import org.dromara.physical.service.IPhysicalTournamentsRegistrationService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 预报名Service业务层处理
|
|
|
+ *
|
|
|
+ * @author Lion Li
|
|
|
+ * @date 2026-01-16
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Service
|
|
|
+public class PhysicalTournamentsRegistrationServiceImpl implements IPhysicalTournamentsRegistrationService {
|
|
|
+
|
|
|
+ private final PhysicalTournamentsRegistrationMapper baseMapper;
|
|
|
+
|
|
|
+ private final UserMapper userMapper;
|
|
|
+
|
|
|
+ private final UserRealInfoMapper userRealInfoMapper;
|
|
|
+
|
|
|
+ private final PhysicalLeagueTournamentMapper physicalLeagueTournamentMapper;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询预报名
|
|
|
+ *
|
|
|
+ * @param id 主键
|
|
|
+ * @return 预报名
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public PhysicalTournamentsRegistrationVo queryById(Long id){
|
|
|
+ return baseMapper.selectPhysicalTournamentsRegistrationById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询预报名列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @param pageQuery 分页参数
|
|
|
+ * @return 预报名分页列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public TableDataInfo<PhysicalTournamentsRegistrationVo> queryPageList(PhysicalTournamentsRegistrationBo bo, PageQuery pageQuery) {
|
|
|
+ LambdaQueryWrapper<PhysicalTournamentsRegistration> lqw = buildQueryWrapper(bo);
|
|
|
+ Page<PhysicalTournamentsRegistrationVo> result = baseMapper.selectPhysicalTournamentsRegistrationPage(pageQuery.build(), lqw);
|
|
|
+ List<PhysicalTournamentsRegistrationVo> physicalTournamentsRegistrationVoList = result.getRecords();
|
|
|
+ physicalTournamentsRegistrationVoList.forEach(physicalTournamentsRegistrationVo -> {
|
|
|
+ Long userId=physicalTournamentsRegistrationVo.getUserId();
|
|
|
+ UserVo userVo = userMapper.selectVoByIdInfo(userId);
|
|
|
+ if(userVo!=null){
|
|
|
+ //用户名称
|
|
|
+ physicalTournamentsRegistrationVo.setUserName(userVo.getNickName());
|
|
|
+ }
|
|
|
+ //用户姓名
|
|
|
+ UserRealInfoVo userRealInfoVo = userRealInfoMapper.selectUserRealInfoByUserId(userId);
|
|
|
+ if(userRealInfoVo!=null){
|
|
|
+ physicalTournamentsRegistrationVo.setRealName(userRealInfoVo.getRealName());
|
|
|
+ }
|
|
|
+ PhysicalLeagueTournamentVo physicalLeagueTournamentVo = physicalLeagueTournamentMapper.selectPhysicalLeagueTournamentById(physicalTournamentsRegistrationVo.getId());
|
|
|
+ if(physicalLeagueTournamentVo!=null){
|
|
|
+ physicalTournamentsRegistrationVo.setLeagueTournamentName(physicalLeagueTournamentVo.getTitle());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ return TableDataInfo.build(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询符合条件的预报名列表
|
|
|
+ *
|
|
|
+ * @param bo 查询条件
|
|
|
+ * @return 预报名列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<PhysicalTournamentsRegistrationVo> queryList(PhysicalTournamentsRegistrationBo bo) {
|
|
|
+ LambdaQueryWrapper<PhysicalTournamentsRegistration> lqw = buildQueryWrapper(bo);
|
|
|
+ List<PhysicalTournamentsRegistrationVo> physicalTournamentsRegistrationVoList = baseMapper.selectPhysicalTournamentsRegistrationList(lqw);
|
|
|
+ for (PhysicalTournamentsRegistrationVo physicalTournamentsRegistrationVo : physicalTournamentsRegistrationVoList) {
|
|
|
+ Long userId=physicalTournamentsRegistrationVo.getUserId();
|
|
|
+ UserVo userVo = userMapper.selectVoByIdInfo(userId);
|
|
|
+ if(userVo!=null){
|
|
|
+ //用户名称
|
|
|
+ physicalTournamentsRegistrationVo.setUserName(userVo.getNickName());
|
|
|
+ }
|
|
|
+ //用户姓名
|
|
|
+ UserRealInfoVo userRealInfoVo = userRealInfoMapper.selectUserRealInfoByUserId(userId);
|
|
|
+ if(userRealInfoVo!=null){
|
|
|
+ physicalTournamentsRegistrationVo.setRealName(userRealInfoVo.getRealName());
|
|
|
+ }
|
|
|
+ PhysicalLeagueTournamentVo physicalLeagueTournamentVo = physicalLeagueTournamentMapper.selectPhysicalLeagueTournamentById(physicalTournamentsRegistrationVo.getId());
|
|
|
+ if(physicalLeagueTournamentVo!=null){
|
|
|
+ physicalTournamentsRegistrationVo.setLeagueTournamentName(physicalLeagueTournamentVo.getTitle());
|
|
|
+ }
|
|
|
+ if(physicalTournamentsRegistrationVo.getStatus().equals("approved")){
|
|
|
+ physicalTournamentsRegistrationVo.setStatusText(("已通过"));
|
|
|
+ }else if(physicalTournamentsRegistrationVo.getStatus().equals("pending")){
|
|
|
+ physicalTournamentsRegistrationVo.setStatusText(("待审核"));
|
|
|
+ }else if(physicalTournamentsRegistrationVo.getStatus().equals("rejected")){
|
|
|
+ physicalTournamentsRegistrationVo.setStatusText(("未通过"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return physicalTournamentsRegistrationVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private LambdaQueryWrapper<PhysicalTournamentsRegistration> buildQueryWrapper(PhysicalTournamentsRegistrationBo bo) {
|
|
|
+ Map<String, Object> params = bo.getParams();
|
|
|
+ LambdaQueryWrapper<PhysicalTournamentsRegistration> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.orderByAsc(PhysicalTournamentsRegistration::getCreatedAt);
|
|
|
+ lqw.ge(bo.getCreatedAtStart() != null, PhysicalTournamentsRegistration::getCreatedAt, bo.getCreatedAtStart());
|
|
|
+ lqw.le(bo.getCreatedAtEnd() != null, PhysicalTournamentsRegistration::getCreatedAt, bo.getCreatedAtEnd());
|
|
|
+ lqw.eq(bo.getUserId() != null, PhysicalTournamentsRegistration::getUserId, bo.getUserId());
|
|
|
+ lqw.eq(bo.getLeagueTournamentId() != null, PhysicalTournamentsRegistration::getLeagueTournamentId, bo.getLeagueTournamentId());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getImageUrl()), PhysicalTournamentsRegistration::getImageUrl, bo.getImageUrl());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getStatus()), PhysicalTournamentsRegistration::getStatus, bo.getStatus());
|
|
|
+ /* lqw.eq(bo.getCreatedAt() != null, PhysicalTournamentsRegistration::getCreatedAt, bo.getCreatedAt());*/
|
|
|
+ lqw.eq(bo.getAuditedAt() != null, PhysicalTournamentsRegistration::getAuditedAt, bo.getAuditedAt());
|
|
|
+ lqw.eq(bo.getAuditorId() != null, PhysicalTournamentsRegistration::getAuditorId, bo.getAuditorId());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getAuditorName()), PhysicalTournamentsRegistration::getAuditorName, bo.getAuditorName());
|
|
|
+ return lqw;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增预报名
|
|
|
+ *
|
|
|
+ * @param bo 预报名
|
|
|
+ * @return 是否新增成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBo(PhysicalTournamentsRegistrationBo bo) {
|
|
|
+ PhysicalTournamentsRegistration add = MapstructUtils.convert(bo, PhysicalTournamentsRegistration.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ boolean flag = baseMapper.insertPhysicalTournamentsRegistration(add) > 0;
|
|
|
+ if (flag) {
|
|
|
+ bo.setId(add.getId());
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改预报名
|
|
|
+ *
|
|
|
+ * @param bo 预报名
|
|
|
+ * @return 是否修改成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean updateByBo(PhysicalTournamentsRegistrationBo bo) {
|
|
|
+ PhysicalTournamentsRegistration update = MapstructUtils.convert(bo, PhysicalTournamentsRegistration.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ return baseMapper.updatePhysicalTournamentsRegistration(update) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(PhysicalTournamentsRegistration entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验并批量删除预报名信息
|
|
|
+ *
|
|
|
+ * @param ids 待删除的主键集合
|
|
|
+ * @param isValid 是否进行有效性校验
|
|
|
+ * @return 是否删除成功
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return baseMapper.deletePhysicalTournamentsRegistrationByIds(ids) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean auditTournamentsRegistration(PhysicalTournamentsRegistrationBo bo) {
|
|
|
+ PhysicalTournamentsRegistration update = MapstructUtils.convert(bo, PhysicalTournamentsRegistration.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setAuditedAt(new Date());
|
|
|
+ update.setAuditorName(StringUtils.isEmpty(LoginHelper.getLoginUser().getUsername())?LoginHelper.getLoginUser().getNickname() : LoginHelper.getLoginUser().getUsername());
|
|
|
+ update.setAuditorId(LoginHelper.getLoginUser().getUserId());
|
|
|
+ return baseMapper.updatePhysicalTournamentsRegistration(update) > 0;
|
|
|
+ }
|
|
|
+}
|