You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

75 lines
2.6 KiB

  1. package com.simple.controller;
  2. import org.apache.log4j.Logger;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.util.Assert;
  5. import org.springframework.web.bind.annotation.*;
  6. import com.github.pagehelper.PageInfo;
  7. import com.simple.common.Result;
  8. import com.simple.common.ResultData;
  9. import com.simple.domain.po.WxCoupon;
  10. import com.simple.service.WxCouponService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiImplicitParam;
  13. import io.swagger.annotations.ApiImplicitParams;
  14. import io.swagger.annotations.ApiOperation;
  15. @RestController
  16. @RequestMapping("wxCoupon")
  17. @Api(description="优惠券相关接口")
  18. public class WxCouponController extends BaseController
  19. {
  20. @Autowired
  21. private WxCouponService wxCouponService;
  22. private Logger logger = Logger.getLogger(WxCouponController.class);
  23. @ApiOperation("分页列表接口")
  24. @GetMapping("list")
  25. @ApiImplicitParams({
  26. @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
  27. @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
  28. public ResultData list(@ModelAttribute WxCoupon wxCoupon,Integer pageNum, Integer pageSize) {
  29. if (null == wxCoupon) wxCoupon = new WxCoupon();
  30. final PageInfo<WxCoupon> page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize);
  31. return new ResultData(page);
  32. }
  33. @ApiOperation("新增接口")
  34. @PostMapping("add")
  35. public ResultData add(@RequestBody WxCoupon wxCoupon) {
  36. //Assert.notNull(wxCoupon.getName(), "角色名不能为空");
  37. //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
  38. wxCouponService.saveOrUpdate(wxCoupon);
  39. return new ResultData();
  40. }
  41. @ApiOperation("根据id更新接口")
  42. @PostMapping("update")
  43. public ResultData update(@RequestBody WxCoupon wxCoupon) {
  44. wxCouponService.saveOrUpdate(wxCoupon);
  45. return new ResultData();
  46. }
  47. @ApiOperation("根据id删除接口")
  48. @GetMapping("/del")
  49. @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
  50. public ResultData delete(Long id) {
  51. wxCouponService.deleteById(id);
  52. return new ResultData(Result.SUCCESS, "删除成功", null);
  53. }
  54. @ApiOperation("根据id查询接口")
  55. @GetMapping("/findById")
  56. @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
  57. public ResultData findById(Long id) {
  58. return new ResultData(Result.SUCCESS,"查询成功",wxCouponService.getById(id));
  59. }
  60. }