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.
 
 
 
 
 

72 lines
2.5 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.ApiImplicitParam;
  12. import io.swagger.annotations.ApiImplicitParams;
  13. import io.swagger.annotations.ApiOperation;
  14. @RestController
  15. @RequestMapping("wxCoupon")
  16. public class WxCouponController extends BaseController
  17. {
  18. @Autowired
  19. private WxCouponService wxCouponService;
  20. private Logger logger = Logger.getLogger(WxCouponController.class);
  21. @ApiOperation("分页列表接口")
  22. @GetMapping("list")
  23. @ApiImplicitParams({
  24. @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true),
  25. @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)})
  26. public ResultData list(@ModelAttribute WxCoupon wxCoupon,Integer pageNum, Integer pageSize) {
  27. if (null == wxCoupon) wxCoupon = new WxCoupon();
  28. final PageInfo<WxCoupon> page = wxCouponService.listAsPage(wxCoupon, pageNum, pageSize);
  29. return new ResultData(page);
  30. }
  31. @ApiOperation("新增接口")
  32. @PostMapping("add")
  33. public ResultData add(@RequestBody WxCoupon wxCoupon) {
  34. //Assert.notNull(wxCoupon.getName(), "角色名不能为空");
  35. //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名");
  36. wxCouponService.saveOrUpdate(wxCoupon);
  37. return new ResultData();
  38. }
  39. @ApiOperation("根据id更新接口")
  40. @PostMapping("update")
  41. public ResultData update(@RequestBody WxCoupon wxCoupon) {
  42. wxCouponService.saveOrUpdate(wxCoupon);
  43. return new ResultData();
  44. }
  45. @ApiOperation("根据id删除接口")
  46. @GetMapping("/del")
  47. @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
  48. public ResultData delete(Long id) {
  49. wxCouponService.deleteById(id);
  50. return new ResultData(Result.SUCCESS, "删除成功", null);
  51. }
  52. @ApiOperation("根据id查询接口")
  53. @GetMapping("/findById")
  54. @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true)
  55. public ResultData findById(Long id) {
  56. return new ResultData(Result.SUCCESS,"查询成功",wxCouponService.getById(id));
  57. }
  58. }