peng
7 天以前 75f9783d5a70a5f037e3b34dc0e479069e63c0e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package cn.lili.controller.goods;
 
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dos.Parameters;
import cn.lili.modules.goods.service.ParametersService;
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;
 
/**
 * 管理端,分类绑定参数组管理接口
 *
 * @author Bulbasaur
 * @since 2020/11/26 16:15
 */
@RestController
@Api(tags = "管理端,分类绑定参数组管理接口")
@RequestMapping("/manager/goods/parameters")
public class ParameterManagerController {
 
    @Autowired
    private ParametersService parametersService;
 
 
    @ApiOperation(value = "添加参数")
    @PostMapping
    public ResultMessage<Parameters> save(@Valid Parameters parameters) {
 
        if (parametersService.save(parameters)) {
            return ResultUtil.data(parameters);
        }
        throw new ServiceException(ResultCode.PARAMETER_SAVE_ERROR);
 
    }
 
    @ApiOperation(value = "编辑参数")
    @PutMapping
    public ResultMessage<Parameters> update(@Valid Parameters parameters) {
 
        if (parametersService.updateParameter(parameters)) {
            return ResultUtil.data(parameters);
        }
        throw new ServiceException(ResultCode.PARAMETER_UPDATE_ERROR);
    }
 
    @ApiOperation(value = "通过id删除参数")
    @ApiImplicitParam(name = "id", value = "参数ID", required = true, paramType = "path")
    @DeleteMapping(value = "/{id}")
    public ResultMessage<Object> delById(@PathVariable String id) {
        parametersService.removeById(id);
        return ResultUtil.success();
 
    }
 
}