first commit
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
package com.peanut.modules.book.controller;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.peanut.modules.book.entity.CouponHistoryEntity;
|
||||
import com.peanut.modules.book.service.CouponHistoryService;
|
||||
import com.peanut.modules.book.service.CouponProductCategoryRelationService;
|
||||
import com.peanut.modules.book.vo.UserCouponVo;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.peanut.modules.book.entity.CouponEntity;
|
||||
import com.peanut.modules.book.service.CouponService;
|
||||
import com.peanut.common.utils.PageUtils;
|
||||
import com.peanut.common.utils.R;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author yl
|
||||
* @email yl328572838@163.com
|
||||
* @date 2022-10-28 17:38:29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("book/coupon")
|
||||
public class CouponController {
|
||||
@Autowired
|
||||
private CouponService couponService;
|
||||
@Autowired
|
||||
private CouponProductCategoryRelationService couponProductCategoryRelationService;
|
||||
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
// @RequiresPermissions("book:coupon:list")
|
||||
public R list(@RequestParam Map<String, Object> params){
|
||||
PageUtils page = couponService.queryPage(params);
|
||||
|
||||
return R.ok().put("page", page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息
|
||||
*/
|
||||
@RequestMapping("/info/{id}")
|
||||
// @RequiresPermissions("book:coupon:info")
|
||||
public R info(@PathVariable("id") Long id){
|
||||
CouponEntity coupon = couponService.getById(id);
|
||||
|
||||
return R.ok().put("coupon", coupon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
// @RequiresPermissions("book:coupon:save")
|
||||
public R save(@RequestBody CouponEntity coupon){
|
||||
|
||||
if(0 == coupon.getTakeEffectType()){
|
||||
coupon.setTakeEffectDate(new Date());
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
|
||||
coupon.setExpirationDate(cal.getTime());
|
||||
}
|
||||
couponService.save(coupon);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
// @RequiresPermissions("book:coupon:update")
|
||||
public R update(@RequestBody CouponEntity coupon){
|
||||
|
||||
if(0 == coupon.getTakeEffectType()){
|
||||
coupon.setTakeEffectDate(new Date());
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.add(Calendar.DATE,Integer.valueOf(coupon.getValidity()).intValue());
|
||||
coupon.setExpirationDate(cal.getTime());
|
||||
}
|
||||
couponService.updateById(coupon);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
// @RequiresPermissions("book:coupon:delete")
|
||||
public R delete(@RequestBody Long[] ids){
|
||||
couponService.removeByIds(Arrays.asList(ids));
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user