This commit is contained in:
gzlv
2021-07-12 19:25:23 +08:00
parent 4a16a4273c
commit 3261b76127
2 changed files with 55 additions and 33 deletions

View File

@ -110,6 +110,7 @@ public class StoreSeckillController {
YxSystemGroupDataQueryCriteria queryCriteria = new YxSystemGroupDataQueryCriteria();
queryCriteria.setGroupName(ShopConstants.YSHOP_SECKILL_TIME);
queryCriteria.setStatus(1);
List<YxSystemGroupData> yxSystemGroupDataList = yxSystemGroupDataService.queryAll(queryCriteria);
List<SeckillTimeDto> list = new ArrayList<>();

View File

@ -1,12 +1,12 @@
/**
* Copyright (C) 2018-2021
* All rights reserved, Designed By www.yixiang.co
*/
package co.yixiang.modules.shop.rest;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import co.yixiang.constant.ShopConstants;
import co.yixiang.exception.BadRequestException;
import co.yixiang.logging.aop.log.Log;
@ -16,6 +16,7 @@ import co.yixiang.modules.shop.service.YxSystemGroupDataService;
import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cache.annotation.CacheEvict;
@ -25,14 +26,10 @@ import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @author hupeng
@ -79,6 +76,16 @@ public class SystemGroupDataController {
yxSystemGroupData.setStatus(jsonObject.getInteger("status"));
yxSystemGroupData.setSort(jsonObject.getInteger("sort"));
List<YxSystemGroupData> yshop_seckill_time = yxSystemGroupDataService.list(Wrappers.<YxSystemGroupData>lambdaQuery()
.eq(YxSystemGroupData::getGroupName, "yshop_seckill_time"));
if (yxSystemGroupData.getStatus() == 1) {
yshop_seckill_time.forEach(item -> {
Map map = JSONUtil.toBean(item.getValue(), Map.class);
if (jsonObject.getInteger("time").equals(map.get("time"))) {
throw new BadRequestException("不能同时开启同一时间点");
}
});
}
return new ResponseEntity<>(yxSystemGroupDataService.save(yxSystemGroupData), HttpStatus.CREATED);
}
@ -98,6 +105,19 @@ public class SystemGroupDataController {
yxSystemGroupData.setGroupName(jsonObject.get("groupName").toString());
jsonObject.remove("groupName");
yxSystemGroupData.setValue(jsonObject.toJSONString());
yxSystemGroupData.setStatus(jsonObject.getInteger("status"));
List<YxSystemGroupData> yshop_seckill_time = yxSystemGroupDataService.list(Wrappers.<YxSystemGroupData>lambdaQuery()
.eq(YxSystemGroupData::getGroupName, "yshop_seckill_time"));
if (yxSystemGroupData.getStatus() == 1) {
yshop_seckill_time.forEach(item -> {
Map map = JSONUtil.toBean(item.getValue(), Map.class);
if (jsonObject.getInteger("time").equals(map.get("time"))) {
throw new BadRequestException("不能同时开启同一时间点");
}
});
}
if (jsonObject.getInteger("status") == null) {
yxSystemGroupData.setStatus(1);
} else {
@ -128,6 +148,7 @@ public class SystemGroupDataController {
/**
* 检测参数
*
* @param jsonObject
*/
private void checkParam(JSONObject jsonObject) {