Skip to content

Commit

Permalink
fix: 优化统一接口返回值
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Sep 21, 2022
1 parent 88db57c commit 12476fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "分页获取商品列表")
Expand All @@ -60,10 +60,9 @@ public ResultMessage<IPage<GoodsSku>> getSkuByPage(GoodsSearchParams goodsSearch

@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
Expand Down Expand Up @@ -104,7 +103,7 @@ public ResultMessage<Object> auth(@PathVariable List<String> goodsIds, @RequestP
@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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -61,15 +60,13 @@ public ResultMessage<Object> save(@Valid Specification specification) {
@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));
}
}

0 comments on commit 12476fc

Please sign in to comment.