优惠券管理代码

master
王皓雯 6 years ago
parent 2454b6e124
commit 089f3ea1ec

@ -0,0 +1,76 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.SmsCouponParam;
import com.macro.mall.model.SmsCoupon;
import com.macro.mall.service.SmsCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Controller
*/
@Controller
@Api(tags = "SmsCouponController", description = "优惠券管理")
@RequestMapping("/coupon")
public class SmsCouponController {
@Autowired
private SmsCouponService couponService;
@ApiOperation("添加优惠券")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public Object add(@RequestBody SmsCouponParam couponParam) {//添加
int count = couponService.create(couponParam);//优惠券服务
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("删除优惠券")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public Object delete(@PathVariable Long id) {
int count = couponService.delete(id);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("修改优惠券")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id,@RequestBody SmsCouponParam couponParam) {
int count = couponService.update(id,couponParam);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("根据优惠券名称和类型分页获取优惠券列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "type",required = false) Integer type,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsCoupon> couponList = couponService.list(name,type,pageSize,pageNum);
return new CommonResult().pageSuccess(couponList);
}
@ApiOperation("获取单个优惠券的详细信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id) {//获取信息
SmsCouponParam couponParam = couponService.getItem(id);
return new CommonResult().success(couponParam);
}
}

@ -0,0 +1,37 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.SmsCouponHistory;
import com.macro.mall.service.SmsCouponHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* Controller
*/
@Controller
@Api(tags = "SmsCouponHistoryController",description = "优惠券领取记录管理")
@RequestMapping("/couponHistory")
public class SmsCouponHistoryController {
@Autowired
private SmsCouponHistoryService historyService;
@ApiOperation("根据优惠券id使用状态订单编号分页获取领取记录")
@RequestMapping(value = "/list",method = RequestMethod.GET)
@ResponseBody
public Object list(@RequestParam(value = "couponId",required = false) Long couponId,
@RequestParam(value = "useStatus",required = false) Integer useStatus,//使用状态
@RequestParam(value = "orderSn",required = false) String orderSn,//订单编号
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
List<SmsCouponHistory> historyList = historyService.list(couponId,useStatus,orderSn,pageSize,pageNum);
return new CommonResult().pageSuccess(historyList);
}
}
Loading…
Cancel
Save