|
|
@@ -0,0 +1,86 @@
|
|
|
+package com.goafanti.voucher.controller;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
+import com.goafanti.common.controller.CertifyApiController;
|
|
|
+import com.goafanti.common.model.JtVoucher;
|
|
|
+import com.goafanti.common.model.JtVoucherDetail;
|
|
|
+import com.goafanti.common.utils.StringUtils;
|
|
|
+import com.goafanti.voucher.service.VoucherDetailService;
|
|
|
+import com.goafanti.voucher.service.VoucherService;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "/open/api/admin/voucherDetail")
|
|
|
+public class AdminVoucherDetailController extends CertifyApiController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private VoucherDetailService voucherDetailService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/save" ,method=RequestMethod.POST)
|
|
|
+ public Result saveVoucher(JtVoucherDetail voucher ){
|
|
|
+ Result result=new Result();
|
|
|
+ chack(voucher, result);
|
|
|
+ if (!result.getError().isEmpty()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.data(voucherDetailService.saveVoucherDetail(voucher));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ @RequestMapping(value = "/update" ,method=RequestMethod.POST)
|
|
|
+ public Result updateVoucher(JtVoucherDetail voucher ){
|
|
|
+ Result result=new Result();
|
|
|
+ chack(voucher, result);
|
|
|
+ if (!result.getError().isEmpty()) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ result.data(voucherDetailService.updateVoucherDetail(voucher));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ @RequestMapping(value = "/delect" ,method=RequestMethod.POST)
|
|
|
+ public Result delectVoucher(String id ){
|
|
|
+ Result result=new Result();
|
|
|
+ result.data(voucherDetailService.delectVoucherDetail(id));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ @RequestMapping(value = "/select" ,method=RequestMethod.GET)
|
|
|
+ public Result selectVoucher(String id ){
|
|
|
+ Result result=new Result();
|
|
|
+ result.data(voucherDetailService.selectVoucherDetail(id));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/selectList" ,method=RequestMethod.GET)
|
|
|
+ public Result selectVoucherDetailList(String name,Integer status,String userMobile,Integer source,Integer pageNo,Integer pageSize){
|
|
|
+ Result result=new Result();
|
|
|
+ result.data(voucherDetailService.selectVoucherDetailList(name, status, userMobile,source, pageNo, pageSize));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private Result chack(JtVoucherDetail voucher, Result result) {
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(voucher.getVoucherId())) {
|
|
|
+ result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"抵用券规则","抵用券规则"));return result;
|
|
|
+ }
|
|
|
+ if(voucher.getUseUid()==null) {
|
|
|
+ result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"用户","用户"));return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(voucher.getStatus()==null) {
|
|
|
+ result.getError().add(buildError(ErrorConstants.PARAM_ERROR,"状态","状态"));return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|