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.*; /** *

* 商铺积分规则管理 前端控制器 *

* * @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> page(@RequestParam(value = "keyword", required = false) String keyword, @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { Page storeScoreRules = storeScoreRuleService.list(keyword, pageSize, pageNum); return CommonResult.success(CommonPage.restPage(storeScoreRules)); } @ApiOperation("添加积分信息") @RequestMapping(value = "add", method = RequestMethod.GET) @ResponseBody public CommonResult> add(@Validated @RequestBody StoreScoreRuleVO.AddScoreVO addScoreVO) { storeScoreRuleService.add(addScoreVO); return CommonResult.success(null); } @ApiOperation("删除积分信息") @RequestMapping(value = "delete/{id}", method = RequestMethod.GET) @ResponseBody public CommonResult> delete(@PathVariable Integer id) { boolean success = storeScoreRuleService.removeById(id); if (success) { return CommonResult.success(null); } else { return CommonResult.failed(); } } }