|
@@ -1,9 +1,9 @@
|
|
|
package org.jeecg.modules.system.app.service.impl;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
@@ -18,14 +18,15 @@ import org.jeecg.modules.system.app.mapper.AppGameScheduleMapper;
|
|
|
import org.jeecg.modules.system.app.mapper.AppSiteMapper;
|
|
|
import org.jeecg.modules.system.app.service.IAppGameService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
|
|
|
|
@@ -44,6 +45,14 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
|
|
|
@Resource
|
|
|
private AppSiteMapper siteMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private AppGameMapper appGameMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisTemplate<String, String> redisTemplate;
|
|
|
+
|
|
|
+ private String feignDelete ="feignDelete";
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean saveWitchPriceRules(AppGameDTO gameDTO) {
|
|
@@ -105,7 +114,12 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
|
|
|
appGamePriceRules.setGameId(game.getId());
|
|
|
appGamePriceRules.setOrgCode(game.getOrgCode());
|
|
|
appGamePriceRules.setTenantId(game.getTenantId());
|
|
|
- int savePriceResult = rulesMapper.updateById(appGamePriceRules);
|
|
|
+ int savePriceResult =0;
|
|
|
+ if (StringUtils.isNotEmpty(gameRuleDTO.getId())){
|
|
|
+ savePriceResult = rulesMapper.updateById(appGamePriceRules);
|
|
|
+ }else {
|
|
|
+ savePriceResult = rulesMapper.insert(appGamePriceRules);
|
|
|
+ }
|
|
|
if (savePriceResult < 1) {
|
|
|
throw new JeecgBootException("赛事价格规则保存失败");
|
|
|
}
|
|
@@ -117,7 +131,12 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
|
|
|
appGameSchedule.setGameId(game.getId());
|
|
|
appGameSchedule.setOrgCode(game.getOrgCode());
|
|
|
appGameSchedule.setTenantId(game.getTenantId());
|
|
|
- int saveScheduleResult = scheduleMapper.updateById(appGameSchedule);
|
|
|
+ int saveScheduleResult =0;
|
|
|
+ if (StringUtils.isNotEmpty(scheduleDTO.getId())){
|
|
|
+ saveScheduleResult = scheduleMapper.updateById(appGameSchedule);
|
|
|
+ }else {
|
|
|
+ saveScheduleResult = scheduleMapper.insert(appGameSchedule);
|
|
|
+ }
|
|
|
if (saveScheduleResult < 1) {
|
|
|
throw new JeecgBootException("赛事安排保存失败");
|
|
|
}
|
|
@@ -170,28 +189,35 @@ public class AppGameServiceImpl extends ServiceImpl<AppGameMapper, AppGame> impl
|
|
|
public IPage<AppGameDTO> queryWitchPriceRulesPage(AppGamePageDTO dto) {
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
Page<AppGame> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
|
|
- LambdaQueryWrapper<AppGame> wrapper = Wrappers.<AppGame>lambdaQuery()
|
|
|
- .like(StringUtils.isNotBlank(dto.getName()), AppGame::getName, dto.getName());
|
|
|
+// LambdaQueryWrapper<AppGame> wrapper = Wrappers.<AppGame>lambdaQuery()
|
|
|
+// .like(StringUtils.isNotBlank(dto.getName()), AppGame::getName, dto.getName());
|
|
|
// .eq(AppGame::getOrgCode, loginUser.getOrgCode());
|
|
|
+ dto.setOrgCode(loginUser.getOrgCode());
|
|
|
+ return appGameMapper.findPage(page,dto);
|
|
|
+// IPage<AppGame> resultPage = baseMapper.selectPage(page, wrapper);
|
|
|
+// return resultPage.convert(record -> {
|
|
|
+// AppGameCuDTO cuDTO = new AppGameCuDTO();
|
|
|
+// BeanUtils.copyProperties(cuDTO, record);
|
|
|
+// List<AppGameRuleDTO> priceRulesDTOList = new ArrayList<>();
|
|
|
+// rulesMapper.selectList(Wrappers.<AppGamePriceRules>lambdaQuery().eq(AppGamePriceRules::getGameId, record.getId())).forEach(rule-> {
|
|
|
+// AppGameRuleDTO appGameRuleDTO = new AppGameRuleDTO();
|
|
|
+// BeanUtils.copyProperties(rule, appGameRuleDTO);
|
|
|
+// priceRulesDTOList.add(appGameRuleDTO);
|
|
|
+// });
|
|
|
+// List<AppGameScheduleDTO> scheduleDTOS = new ArrayList<>();
|
|
|
+// scheduleMapper.selectList(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, record.getId())).forEach(schedule-> {
|
|
|
+// AppGameScheduleDTO appGameScheduleDTO = new AppGameScheduleDTO();
|
|
|
+// BeanUtils.copyProperties(schedule, appGameScheduleDTO);
|
|
|
+// scheduleDTOS.add(appGameScheduleDTO);
|
|
|
+// });
|
|
|
+// return new AppGameDTO(cuDTO, priceRulesDTOList, scheduleDTOS);
|
|
|
+// });
|
|
|
+ }
|
|
|
|
|
|
- IPage<AppGame> resultPage = baseMapper.selectPage(page, wrapper);
|
|
|
- return resultPage.convert(record -> {
|
|
|
- AppGameCuDTO cuDTO = new AppGameCuDTO();
|
|
|
- BeanUtils.copyProperties(cuDTO, record);
|
|
|
- List<AppGameRuleDTO> priceRulesDTOList = new ArrayList<>();
|
|
|
- rulesMapper.selectList(Wrappers.<AppGamePriceRules>lambdaQuery().eq(AppGamePriceRules::getGameId, record.getId())).forEach(rule-> {
|
|
|
- AppGameRuleDTO appGameRuleDTO = new AppGameRuleDTO();
|
|
|
- BeanUtils.copyProperties(rule, appGameRuleDTO);
|
|
|
- priceRulesDTOList.add(appGameRuleDTO);
|
|
|
- });
|
|
|
- List<AppGameScheduleDTO> scheduleDTOS = new ArrayList<>();
|
|
|
- scheduleMapper.selectList(Wrappers.<AppGameSchedule>lambdaQuery().eq(AppGameSchedule::getGameId, record.getId())).forEach(schedule-> {
|
|
|
- AppGameScheduleDTO appGameScheduleDTO = new AppGameScheduleDTO();
|
|
|
- BeanUtils.copyProperties(schedule, appGameScheduleDTO);
|
|
|
- scheduleDTOS.add(appGameScheduleDTO);
|
|
|
- });
|
|
|
- return new AppGameDTO(cuDTO, priceRulesDTOList, scheduleDTOS);
|
|
|
- });
|
|
|
+ @Override
|
|
|
+ public void redisSave(String id) {
|
|
|
+ redisTemplate.opsForSet().add(feignDelete, id);
|
|
|
+ redisTemplate.expire(feignDelete, 600, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
/**
|