diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index e487dcd3..d3e916f7 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -1,5 +1,7 @@ package com.bweb.controller; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -28,6 +30,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Date; +import java.util.HashMap; +import java.util.Map; /** * @Auther: 胡锐 @@ -183,7 +187,7 @@ public class HighCouponController { } } - @RequestMapping(value="/upShelfApprove",method = RequestMethod.POST) + @RequestMapping(value="/upShelfApprove",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷上架审批") public ResponseData upShelfApprove(@RequestParam(name = "id", required = true) Long id, HttpServletRequest request) { @@ -222,7 +226,7 @@ public class HighCouponController { } } - @RequestMapping(value="/ofShelfApprove",method = RequestMethod.POST) + @RequestMapping(value="/ofShelfApprove",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "卡卷下架") public ResponseData ofShelfApprove(@RequestParam(name = "id", required = true) Long id) { @@ -237,4 +241,40 @@ public class HighCouponController { } } + @RequestMapping(value="/getCouponById",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据id 查询卡卷") + public ResponseData getCouponById(@RequestParam(name = "id", required = true) Long id) { + try { + + return ResponseMsgUtil.success(highCouponService.getCouponById(id)); + + } catch (Exception e) { + log.error("HighCouponController -> getCouponById() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getCouponList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "卡卷列表") + public ResponseData getCouponList(@RequestParam(name = "couponName", required = false) String couponName, + @RequestParam(name = "couponType", required = false) Integer couponType, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + Map map = new HashMap<>(); + map.put("couponName", couponName); + map.put("couponType", couponType); + map.put("status", status); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map))); + } catch (Exception e) { + log.error("HighCouponController -> getCouponList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/service/HighCouponService.java b/hai-service/src/main/java/com/hai/service/HighCouponService.java index 4bcd07f9..04dd6bb7 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -3,6 +3,9 @@ package com.hai.service; import com.hai.entity.HighCoupon; import com.hai.model.HighCouponModel; +import java.util.List; +import java.util.Map; + /** * @Auther: 胡锐 * @Description: @@ -53,4 +56,11 @@ public interface HighCouponService { **/ HighCouponModel getCouponById(Long id); + /** + * @Author 胡锐 + * @Description 获取卡卷集合 + * @Date 2021/3/15 23:12 + **/ + List getCouponList(Map map); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index 3cecb208..c352bc54 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -5,23 +5,25 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.dao.HighCouponHandselMapper; import com.hai.dao.HighCouponMapper; -import com.hai.entity.HighCoupon; -import com.hai.entity.HighCouponCode; -import com.hai.entity.HighCouponHandsel; -import com.hai.entity.HighGoodsPriceRefer; +import com.hai.entity.*; import com.hai.model.HighCouponHandselModel; import com.hai.model.HighCouponModel; import com.hai.service.HighCouponCodeService; import com.hai.service.HighCouponService; import com.hai.service.HighGoodsPriceReferService; +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; +import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; /** * @Auther: 胡锐 @@ -147,7 +149,6 @@ public class HighCouponServiceImpl implements HighCouponService { // 卡卷价格全部失效。但保留当前生效的价格 highGoodsPriceReferService.couponAllInvalidKeepCurrent(coupon.getId()); - } @Override @@ -162,4 +163,30 @@ public class HighCouponServiceImpl implements HighCouponService { return model; } + + @Override + public List getCouponList(Map map) { + HighCouponExample example = new HighCouponExample(); + HighCouponExample.Criteria criteria = example.createCriteria(); + + if (StringUtils.isNotBlank(MapUtils.getString(map, "couponName"))) { + criteria.andCouponNameLike("%" + MapUtils.getString(map, "couponName") + "%"); + } + + if (MapUtils.getInteger(map, "couponType") != null) { + criteria.andCouponTypeEqualTo(MapUtils.getInteger(map, "couponType")); + } + + if (MapUtils.getInteger(map, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); + } + + List coupons = highCouponMapper.selectByExample(example); + if (coupons != null && coupons.size() > 0) { + List list = new ArrayList<>(); + BeanUtils.copyProperties(coupons, list); + return list; + } + return new ArrayList<>(); + } }