!238 fix: 优化统一接口返回值

Merge pull request !238 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-09-21 08:34:52 +00:00 committed by Gitee
commit 8b0823f504
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 14 additions and 18 deletions

View File

@ -48,8 +48,8 @@ public class GoodsManagerController {
@ApiOperation(value = "分页获取")
@GetMapping(value = "/list")
public IPage<Goods> getByPage(GoodsSearchParams goodsSearchParams) {
return goodsService.queryByParams(goodsSearchParams);
public ResultMessage<IPage<Goods>> getByPage(GoodsSearchParams goodsSearchParams) {
return ResultUtil.data(goodsService.queryByParams(goodsSearchParams));
}
@ApiOperation(value = "分页获取商品列表")
@ -60,10 +60,9 @@ public class GoodsManagerController {
@ApiOperation(value = "分页获取待审核商品")
@GetMapping(value = "/auth/list")
public IPage<Goods> getAuthPage(GoodsSearchParams goodsSearchParams) {
public ResultMessage<IPage<Goods>> getAuthPage(GoodsSearchParams goodsSearchParams) {
goodsSearchParams.setAuthFlag(GoodsAuthEnum.TOBEAUDITED.name());
return goodsService.queryByParams(goodsSearchParams);
return ResultUtil.data(goodsService.queryByParams(goodsSearchParams));
}
@PreventDuplicateSubmissions
@ -104,7 +103,7 @@ public class GoodsManagerController {
@ApiImplicitParam(name = "goodsId", value = "商品ID", required = true, allowMultiple = true)
})
public ResultMessage<Object> unpGoods(@PathVariable List<String> goodsId) {
if (goodsService.updateGoodsMarketAble(goodsId, GoodsStatusEnum.UPPER, "")) {
if (Boolean.TRUE.equals(goodsService.updateGoodsMarketAble(goodsId, GoodsStatusEnum.UPPER, ""))) {
return ResultUtil.success();
}
throw new ServiceException(ResultCode.GOODS_UPPER_ERROR);

View File

@ -1,13 +1,13 @@
package cn.lili.controller.goods;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.mybatis.util.PageUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Specification;
import cn.lili.modules.goods.service.SpecificationService;
import cn.lili.mybatis.util.PageUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
@ -37,17 +37,16 @@ public class SpecificationManagerController {
@GetMapping("/all")
@ApiOperation(value = "获取所有可用规格")
public List<Specification> getAll() {
List<Specification> list = specificationService.list();
return list;
public ResultMessage<List<Specification>> getAll() {
return ResultUtil.data(specificationService.list());
}
@GetMapping
@ApiOperation(value = "搜索规格")
public Page<Specification> page(String specName, PageVO page) {
public ResultMessage<Page<Specification>> page(String specName, PageVO page) {
LambdaQueryWrapper<Specification> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.like(StringUtils.isNotEmpty(specName), Specification::getSpecName, specName);
return specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper);
lambdaQueryWrapper.like(CharSequenceUtil.isNotEmpty(specName), Specification::getSpecName, specName);
return ResultUtil.data(specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper));
}
@PostMapping
@ -61,15 +60,13 @@ public class SpecificationManagerController {
@ApiOperation(value = "更改规格")
public ResultMessage<Object> update(@Valid Specification specification, @PathVariable String id) {
specification.setId(id);
specificationService.saveOrUpdate(specification);
return ResultUtil.success();
return ResultUtil.data(specificationService.saveOrUpdate(specification));
}
@DeleteMapping("/{ids}")
@ApiImplicitParam(name = "ids", value = "规格ID", required = true, dataType = "String", allowMultiple = true, paramType = "path")
@ApiOperation(value = "批量删除")
public ResultMessage<Object> delAllByIds(@PathVariable List<String> ids) {
specificationService.deleteSpecification(ids);
return ResultUtil.success();
return ResultUtil.data(specificationService.deleteSpecification(ids));
}
}