|
|
@@ -1,6 +1,5 @@
|
|
|
package com.izouma.dingdong.web;
|
|
|
|
|
|
-import com.izouma.dingdong.service.merchant.MerchantService;
|
|
|
import com.izouma.dingdong.utils.SecurityUtils;
|
|
|
import com.izouma.dingdong.domain.Coupon;
|
|
|
import com.izouma.dingdong.service.CouponService;
|
|
|
@@ -10,6 +9,7 @@ import com.izouma.dingdong.repo.CouponRepo;
|
|
|
import com.izouma.dingdong.utils.ObjUtils;
|
|
|
import com.izouma.dingdong.utils.excel.ExcelUtils;
|
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageImpl;
|
|
|
@@ -26,7 +26,6 @@ import java.util.stream.Collectors;
|
|
|
public class CouponController extends BaseController {
|
|
|
private CouponService couponService;
|
|
|
private CouponRepo couponRepo;
|
|
|
- private MerchantService merchantService;
|
|
|
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
@@ -45,7 +44,7 @@ public class CouponController extends BaseController {
|
|
|
public Page<Coupon> all(PageQuery pageQuery) {
|
|
|
//return couponRepo.findAll(toSpecification(pageQuery,Coupon.class),toPageRequest(pageQuery));
|
|
|
List<Coupon> collect = couponRepo.findAll(toSpecification(pageQuery, Coupon.class)).stream().filter(Coupon::getEnabled).collect(Collectors.toList());
|
|
|
- return new PageImpl<>(collect,toPageRequest(pageQuery),pageQuery.getSize());
|
|
|
+ return new PageImpl<>(collect, toPageRequest(pageQuery), pageQuery.getSize());
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get/{id}")
|
|
|
@@ -65,14 +64,15 @@ public class CouponController extends BaseController {
|
|
|
ExcelUtils.export(response, data);
|
|
|
}
|
|
|
|
|
|
+ ///true所有 false未过期
|
|
|
+ @ApiOperation("是否显示所有")
|
|
|
@GetMapping("/my")
|
|
|
- public List<Coupon> my(){
|
|
|
- Long merchantId = merchantService.findMerchantId(SecurityUtils.getAuthenticatedUser().getId());
|
|
|
- return couponRepo.findAllByMerchantIdAndEnabledTrue(merchantId);
|
|
|
+ public List<Coupon> my(Boolean isAll) {
|
|
|
+ return couponService.my(SecurityUtils.getAuthenticatedUser().getId(), isAll);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/platform")
|
|
|
- public List<Coupon> platform(){
|
|
|
+ public List<Coupon> platform() {
|
|
|
return couponRepo.findAllByMerchantIdNullAndEnabledTrue();
|
|
|
}
|
|
|
}
|