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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
@Api(tags = "PmsBrandController", value = "商品品牌管理") @Controller @RequestMapping("/brand") @Slf4j public class PmsBrandController {
@Autowired private PmsBrandService pmsBrandService;
@ApiOperation("获取所有品牌列表") @RequestMapping(value = "/listAll", method = RequestMethod.GET) @ResponseBody public CommonResult<List<PmsBrand>> getBrandList() { log.debug("getBrandList()"); return CommonResult.success(pmsBrandService.listAllBrand()); }
@ApiOperation("添加品牌") @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseBody public CommonResult createBrand(@RequestBody PmsBrand pmsBrand) { CommonResult commonResult = null; int res = pmsBrandService.creatBrand(pmsBrand); if (res == 1) { commonResult = CommonResult.success(pmsBrand); log.debug("creatBrand success:{}", pmsBrand); } else { commonResult = CommonResult.failed("操作失败"); log.debug("creatBrand failed:{}", pmsBrand); } return commonResult; }
@ApiOperation("更新指定id品牌信息") @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) @ResponseBody public CommonResult updateBrand(@PathVariable("id") Long id, @RequestBody PmsBrand pmsBrand, BindingResult result) { CommonResult commonResult = null; int res = pmsBrandService.updateBrand(id, pmsBrand); if (res == 1) { commonResult = CommonResult.success(pmsBrand); log.debug("updateBrand success: id={}", id); } else { commonResult = CommonResult.failed("操作失败"); log.debug("creatBrand failed: id={}", id); } return commonResult; }
@ApiOperation("删除指定id的品牌") @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) @ResponseBody public CommonResult deleteBrand(@PathVariable("id") Long id) { CommonResult commonResult = null; int res = pmsBrandService.deleteBrand(id); if (res == 1) { log.debug("deleteBrand success: id={}", id); commonResult = CommonResult.success(null); } else { log.debug("deleteBrand failed:{}", id); commonResult = CommonResult.failed("操作失败"); } return commonResult; }
@ApiOperation("分页查询品牌列表") @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody public CommonResult<CommonPage<PmsBrand>> listBrand(@RequestParam(value = "pageNum", defaultValue = "1") @ApiParam("页码") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "3") @ApiParam("每页数量") Integer pageSize) { List<PmsBrand> brandList = pmsBrandService.listBrand(pageNum, pageSize); return CommonResult.success(CommonPage.restPage(brandList)); }
@ApiOperation("获取指定id的品牌详情") @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody public CommonResult<PmsBrand> brand(@PathVariable("id") Long id) { return CommonResult.success(pmsBrandService.getBrand(id)); } }
|