|
|
@@ -1,7 +1,10 @@
|
|
|
package com.etotem.cfc.controller.admin;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.common.Result;
|
|
|
import com.etotem.cfc.entity.Coupon;
|
|
|
+import com.etotem.cfc.entity.CouponGrantLog;
|
|
|
+import com.etotem.cfc.mapper.CouponGrantLogMapper;
|
|
|
import com.etotem.cfc.mapper.CouponMapper;
|
|
|
import com.etotem.cfc.service.CouponService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -21,6 +24,9 @@ public class AdminCouponController {
|
|
|
@Resource
|
|
|
private CouponMapper couponMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CouponGrantLogMapper couponGrantLogMapper;
|
|
|
+
|
|
|
@PostMapping("/list")
|
|
|
public Result<List<Coupon>> list(@RequestAttribute("role") String role) {
|
|
|
if (!"admin".equals(role)) {
|
|
|
@@ -81,4 +87,23 @@ public class AdminCouponController {
|
|
|
couponMapper.deleteById(id);
|
|
|
return Result.success("删除成功");
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/grant-log")
|
|
|
+ public Result<List<CouponGrantLog>> grantLog(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role)) {
|
|
|
+ return Result.error("无权限");
|
|
|
+ }
|
|
|
+ Long userId = params.get("userId") != null ? Long.valueOf(params.get("userId").toString()) : null;
|
|
|
+ Long couponId = params.get("couponId") != null ? Long.valueOf(params.get("couponId").toString()) : null;
|
|
|
+ LambdaQueryWrapper<CouponGrantLog> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (userId != null) {
|
|
|
+ wrapper.eq(CouponGrantLog::getUserId, userId);
|
|
|
+ }
|
|
|
+ if (couponId != null) {
|
|
|
+ wrapper.eq(CouponGrantLog::getCouponId, couponId);
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(CouponGrantLog::getCreatedAt);
|
|
|
+ return Result.success(couponGrantLogMapper.selectList(wrapper));
|
|
|
+ }
|
|
|
}
|