删除管理端自定义分词Controller重复问题。限时抢购活动,修改时增加检查秒杀参数校验
This commit is contained in:
parent
c8b2e87570
commit
794a932340
@ -192,6 +192,8 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
|||||||
seckillVO.setEndTime(cn.hutool.core.date.DateUtil.endOfDay(seckillVO.getStartTime()));
|
seckillVO.setEndTime(cn.hutool.core.date.DateUtil.endOfDay(seckillVO.getStartTime()));
|
||||||
}
|
}
|
||||||
PromotionTools.checkPromotionTime(seckillVO.getStartTime().getTime(), seckillVO.getEndTime().getTime());
|
PromotionTools.checkPromotionTime(seckillVO.getStartTime().getTime(), seckillVO.getEndTime().getTime());
|
||||||
|
//检查秒杀活动参数
|
||||||
|
this.checkSeckillParam(seckillVO);
|
||||||
//更新到MYSQL中
|
//更新到MYSQL中
|
||||||
boolean result = this.updateById(seckillVO);
|
boolean result = this.updateById(seckillVO);
|
||||||
//保存到MONGO中
|
//保存到MONGO中
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
package cn.lili.controller.other;
|
package cn.lili.controller.other;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
|
import cn.lili.common.enums.ResultUtil;
|
||||||
import cn.lili.common.exception.ServiceException;
|
import cn.lili.common.exception.ServiceException;
|
||||||
import cn.lili.common.utils.StringUtils;
|
import cn.lili.common.vo.PageVO;
|
||||||
|
import cn.lili.common.vo.ResultMessage;
|
||||||
import cn.lili.modules.permission.SettingKeys;
|
import cn.lili.modules.permission.SettingKeys;
|
||||||
|
import cn.lili.modules.search.entity.dos.CustomWords;
|
||||||
|
import cn.lili.modules.search.entity.vo.CustomWordsVO;
|
||||||
import cn.lili.modules.search.service.CustomWordsService;
|
import cn.lili.modules.search.service.CustomWordsService;
|
||||||
import cn.lili.modules.system.entity.dos.Setting;
|
import cn.lili.modules.system.entity.dos.Setting;
|
||||||
import cn.lili.modules.system.service.SettingService;
|
import cn.lili.modules.system.service.SettingService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,11 +49,11 @@ public class CustomWordsController {
|
|||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public String getCustomWords(String secretKey) {
|
public String getCustomWords(String secretKey) {
|
||||||
if (StringUtils.isEmpty(secretKey)) {
|
if (CharSequenceUtil.isEmpty(secretKey)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
Setting setting = settingService.get(SettingKeys.ES_SIGN.name());
|
Setting setting = settingService.get(SettingKeys.ES_SIGN.name());
|
||||||
if (setting == null || StringUtils.isEmpty(setting.getSettingValue())) {
|
if (setting == null || CharSequenceUtil.isEmpty(setting.getSettingValue())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +65,38 @@ public class CustomWordsController {
|
|||||||
try {
|
try {
|
||||||
return new String(res.getBytes(), StandardCharsets.UTF_8);
|
return new String(res.getBytes(), StandardCharsets.UTF_8);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取分词错误",e);
|
log.error("获取分词错误", e);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "添加自定义分词")
|
||||||
|
@PostMapping
|
||||||
|
public ResultMessage<CustomWordsVO> addCustomWords(@Valid CustomWordsVO customWords) {
|
||||||
|
customWordsService.addCustomWords(customWords);
|
||||||
|
return ResultUtil.data(customWords);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改自定义分词")
|
||||||
|
@PutMapping
|
||||||
|
public ResultMessage<CustomWordsVO> updateCustomWords(@Valid CustomWordsVO customWords) {
|
||||||
|
customWordsService.updateCustomWords(customWords);
|
||||||
|
return ResultUtil.data(customWords);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "删除自定义分词")
|
||||||
|
@ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path")
|
||||||
|
@DeleteMapping("/{id}")
|
||||||
|
public ResultMessage<String> deleteCustomWords(@NotNull @PathVariable String id) {
|
||||||
|
customWordsService.deleteCustomWords(id);
|
||||||
|
return ResultUtil.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "分页获取自定义分词")
|
||||||
|
@ApiImplicitParam(name = "words", value = "分词", required = true, dataType = "String", paramType = "query")
|
||||||
|
@GetMapping("/page")
|
||||||
|
public ResultMessage<IPage<CustomWords>> getCustomWords(@RequestParam String words, PageVO pageVo) {
|
||||||
|
return ResultUtil.data(customWordsService.getCustomWordsByPage(words, pageVo));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
package cn.lili.controller.other;
|
|
||||||
|
|
||||||
import cn.lili.common.enums.ResultUtil;
|
|
||||||
import cn.lili.common.vo.PageVO;
|
|
||||||
import cn.lili.common.vo.ResultMessage;
|
|
||||||
import cn.lili.modules.search.entity.dos.CustomWords;
|
|
||||||
import cn.lili.modules.search.entity.vo.CustomWordsVO;
|
|
||||||
import cn.lili.modules.search.service.CustomWordsService;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 管理端,自定义分词接口
|
|
||||||
*
|
|
||||||
* @author paulG
|
|
||||||
* @since 2020/10/16
|
|
||||||
**/
|
|
||||||
@RestController
|
|
||||||
@Api(tags = "管理端,自定义分词接口")
|
|
||||||
@RequestMapping("/manager/manager/custom-words")
|
|
||||||
public class CustomWordsManagerController {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分词
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private CustomWordsService customWordsService;
|
|
||||||
|
|
||||||
@ApiOperation(value = "添加自定义分词")
|
|
||||||
@PostMapping
|
|
||||||
public ResultMessage<CustomWordsVO> addCustomWords(@Valid CustomWordsVO customWords) {
|
|
||||||
customWordsService.addCustomWords(customWords);
|
|
||||||
return ResultUtil.data(customWords);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "修改自定义分词")
|
|
||||||
@PutMapping
|
|
||||||
public ResultMessage<CustomWordsVO> updateCustomWords(@Valid CustomWordsVO customWords) {
|
|
||||||
customWordsService.updateCustomWords(customWords);
|
|
||||||
return ResultUtil.data(customWords);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "删除自定义分词")
|
|
||||||
@ApiImplicitParam(name = "id", value = "文章ID", required = true, dataType = "String", paramType = "path")
|
|
||||||
@DeleteMapping("/{id}")
|
|
||||||
public ResultMessage<String> deleteCustomWords(@NotNull @PathVariable String id) {
|
|
||||||
customWordsService.deleteCustomWords(id);
|
|
||||||
return ResultUtil.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiOperation(value = "分页获取自定义分词")
|
|
||||||
@ApiImplicitParam(name = "words", value = "分词", required = true, dataType = "String", paramType = "query")
|
|
||||||
@GetMapping
|
|
||||||
public ResultMessage<IPage<CustomWords>> getCustomWords(@RequestParam String words, PageVO pageVo) {
|
|
||||||
return ResultUtil.data(customWordsService.getCustomWordsByPage(words, pageVo));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user