liyanqi
2022-09-15 34de42f43fd75a31fe0c0d51adf30fb554ad5fa6
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
63
64
65
66
package com.ycl.controller.store;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.api.CommonPage;
import com.ycl.api.CommonResult;
import com.ycl.entity.platform.store.StoreScoreRule;
import com.ycl.service.platform.store.StoreScoreRuleService;
import com.ycl.vo.store.StoreScoreRuleVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 * 商铺积分规则管理 前端控制器
 * </p>
 *
 * @author lyq
 * @since 2022-09-14
 */
@RestController
@RequestMapping("/store/scorerule")
@Api(tags = "积分管理")
public class StoreScoreRuleController {
    private StoreScoreRuleService storeScoreRuleService;
 
    @Autowired
    public void setStoreScoreRuleService(StoreScoreRuleService storeScoreRuleService) {
        this.storeScoreRuleService = storeScoreRuleService;
    }
 
 
    @ApiOperation("获取分页的积分信息")
    @RequestMapping(value = "page", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<StoreScoreRule>> page(@RequestParam(value = "keyword", required = false) String keyword,
                                                         @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                         @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        Page<StoreScoreRule> storeScoreRules = storeScoreRuleService.list(keyword, pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(storeScoreRules));
    }
 
    @ApiOperation("添加积分信息")
    @RequestMapping(value = "add", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<StoreScoreRule>> add(@Validated @RequestBody StoreScoreRuleVO.AddScoreVO addScoreVO) {
        storeScoreRuleService.add(addScoreVO);
        return CommonResult.success(null);
    }
 
    @ApiOperation("删除积分信息")
    @RequestMapping(value = "delete/{id}", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<CommonPage<StoreScoreRule>> delete(@PathVariable Integer id) {
        boolean success = storeScoreRuleService.removeById(id);
        if (success) {
            return CommonResult.success(null);
        } else {
            return CommonResult.failed();
        }
    }
 
}