后端:用户优惠劵分页列表接口
This commit is contained in:
@@ -11,9 +11,13 @@ public interface CouponCardMapper {
|
||||
|
||||
CouponCardDO selectById(@Param("id") Integer id);
|
||||
|
||||
List<CouponCardDO> selectListByPage(@Param("status") Integer status);
|
||||
List<CouponCardDO> selectListByPage(@Param("userId") Integer userId,
|
||||
@Param("status") Integer status,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
Integer selectCountByPage(@Param("status") Integer status);
|
||||
Integer selectCountByPage(@Param("userId") Integer userId,
|
||||
@Param("status") Integer status);
|
||||
|
||||
int selectCountByUserIdAndTemplateId(@Param("userId") Integer userId,
|
||||
@Param("templateId") Integer templateId);
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.iocoder.common.framework.util.ServiceExceptionUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.promotion.api.CouponService;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponCardBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponCardPageBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplateBO;
|
||||
import cn.iocoder.mall.promotion.api.bo.CouponTemplatePageBO;
|
||||
import cn.iocoder.mall.promotion.api.constant.*;
|
||||
@@ -176,6 +177,20 @@ public class CouponServiceImpl implements CouponService {
|
||||
|
||||
// ========== 优惠劵 ==========
|
||||
|
||||
@Override
|
||||
public CommonResult<CouponCardPageBO> getCouponCardPage(CouponCardPageDTO couponCardPageDTO) {
|
||||
CouponCardPageBO pageBO = new CouponCardPageBO();
|
||||
// 查询分页数据
|
||||
int offset = (couponCardPageDTO.getPageNo() - 1) * couponCardPageDTO.getPageSize();
|
||||
pageBO.setList(CouponCardConvert.INSTANCE.convertToBO(couponCardMapper.selectListByPage(
|
||||
couponCardPageDTO.getUserId(), couponCardPageDTO.getStatus(),
|
||||
offset, couponCardPageDTO.getPageSize())));
|
||||
// 查询分页总数
|
||||
pageBO.setTotal(couponCardMapper.selectCountByPage(
|
||||
couponCardPageDTO.getUserId(), couponCardPageDTO.getStatus()));
|
||||
return CommonResult.success(pageBO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CommonResult<CouponCardBO> addCouponCard(Integer userId, Integer couponTemplateId) {
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
<include refid="FIELDS" />
|
||||
FROM coupon_card
|
||||
<where>
|
||||
<if test="userId != null">
|
||||
AND user_id = #{userId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
@@ -50,6 +53,9 @@
|
||||
COUNT(1)
|
||||
FROM coupon_card
|
||||
<where>
|
||||
<if test="userId != null">
|
||||
AND user_id = #{userId}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user