CouponController.java
2.11 KB
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
package com.topdraw.business.basicdata.coupon.rest;
import com.topdraw.annotation.Log;
import com.topdraw.business.basicdata.coupon.domain.Coupon;
import com.topdraw.business.basicdata.coupon.service.CouponService;
import com.topdraw.business.basicdata.coupon.service.dto.CouponQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Coupon管理")
@RestController
@RequestMapping("/api/Coupon")
public class CouponController {
@Autowired
private CouponService CouponService;
@GetMapping
@ApiOperation("查询Coupon")
public ResultInfo getCoupons(CouponQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(CouponService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有Coupon")
public ResultInfo getCoupons(CouponQueryCriteria criteria) {
return ResultInfo.success(CouponService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增Coupon")
public ResultInfo create(@Validated @RequestBody Coupon resources) {
CouponService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改Coupon")
public ResultInfo update(@Validated @RequestBody Coupon resources) {
CouponService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Coupon")
public ResultInfo delete(@PathVariable Long id) {
CouponService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(CouponService.getByCode(code));
}
}