| New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_store_coupon") |
| | | public class StoreCoupon extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("store_id") |
| | | /** 店铺id */ |
| | | private Long storeId; |
| | | |
| | | @TableField("store_name") |
| | | /** 店铺名称 */ |
| | | private Long storeName; |
| | | |
| | | @TableField("coupon_id") |
| | | /** 优惠卷id */ |
| | | private Long couponId; |
| | | |
| | | @TableField("coupon_name") |
| | | /** 优惠卷名称 */ |
| | | private String couponName; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_store_coupon_claim_record") |
| | | public class StoreCouponClaimRecord extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableField("store_name") |
| | | /** 店铺名称 */ |
| | | private String storeName; |
| | | |
| | | @TableField("coupon_id") |
| | | /** 优惠卷id */ |
| | | private Long couponId; |
| | | |
| | | @TableField("coupon_name") |
| | | /** 优惠卷名称 */ |
| | | private String couponName; |
| | | |
| | | @TableField("store_id") |
| | | /** 店铺id */ |
| | | private Long storeId; |
| | | |
| | | @TableField("user_id") |
| | | /** 用户id */ |
| | | private Long userId; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCouponClaimRecord; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "StoreCouponClaimRecord表单", description = "店铺优惠卷领取记录表单") |
| | | public class StoreCouponClaimRecordForm extends AbsForm { |
| | | |
| | | @NotBlank(message = "店铺名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("店铺名称") |
| | | private String storeName; |
| | | |
| | | @NotNull(message = "优惠卷id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("优惠卷id") |
| | | private Long couponId; |
| | | |
| | | @NotBlank(message = "优惠卷名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("优惠卷名称") |
| | | private String couponName; |
| | | |
| | | @NotNull(message = "店铺id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("店铺id") |
| | | private Long storeId; |
| | | |
| | | @NotNull(message = "用户id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("用户id") |
| | | private Long userId; |
| | | |
| | | public static StoreCouponClaimRecord getEntityByForm(@NonNull StoreCouponClaimRecordForm form, StoreCouponClaimRecord entity) { |
| | | if(entity == null) { |
| | | entity = new StoreCouponClaimRecord(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | import cn.lili.group.Update; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCoupon; |
| | | import org.springframework.beans.BeanUtils; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import org.springframework.lang.NonNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系表单 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "StoreCoupon表单", description = "店铺优惠卷对应关系表单") |
| | | public class StoreCouponForm extends AbsForm { |
| | | |
| | | @NotNull(message = "店铺id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("店铺id") |
| | | private Long storeId; |
| | | |
| | | @NotNull(message = "店铺名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("店铺名称") |
| | | private Long storeName; |
| | | |
| | | @NotNull(message = "优惠卷id不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("优惠卷id") |
| | | private Long couponId; |
| | | |
| | | @NotBlank(message = "优惠卷名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty("优惠卷名称") |
| | | private String couponName; |
| | | |
| | | public static StoreCoupon getEntityByForm(@NonNull StoreCouponForm form, StoreCoupon entity) { |
| | | if(entity == null) { |
| | | entity = new StoreCoupon(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "StoreCouponClaimRecord查询参数", description = "店铺优惠卷领取记录查询参数") |
| | | public class StoreCouponClaimRecordQuery extends AbsQuery { |
| | | } |
| | | |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系查询 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "StoreCoupon查询参数", description = "店铺优惠卷对应关系查询参数") |
| | | public class StoreCouponQuery extends AbsQuery { |
| | | } |
| | | |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCouponClaimRecord; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "店铺优惠卷领取记录响应数据", description = "店铺优惠卷领取记录响应数据") |
| | | public class StoreCouponClaimRecordVO extends AbsVo { |
| | | |
| | | /** 店铺名称 */ |
| | | @ApiModelProperty("店铺名称") |
| | | private String storeName; |
| | | |
| | | /** 优惠卷id */ |
| | | @ApiModelProperty("优惠卷id") |
| | | private Long couponId; |
| | | |
| | | /** 优惠卷名称 */ |
| | | @ApiModelProperty("优惠卷名称") |
| | | private String couponName; |
| | | |
| | | /** 店铺id */ |
| | | @ApiModelProperty("店铺id") |
| | | private Long storeId; |
| | | |
| | | /** 用户id */ |
| | | @ApiModelProperty("用户id") |
| | | private Long userId; |
| | | |
| | | public static StoreCouponClaimRecordVO getVoByEntity(@NonNull StoreCouponClaimRecord entity, StoreCouponClaimRecordVO vo) { |
| | | if(vo == null) { |
| | | vo = new StoreCouponClaimRecordVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCoupon; |
| | | import java.util.List; |
| | | import org.springframework.lang.NonNull; |
| | | import org.springframework.beans.BeanUtils; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系展示 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "店铺优惠卷对应关系响应数据", description = "店铺优惠卷对应关系响应数据") |
| | | public class StoreCouponVO extends AbsVo { |
| | | |
| | | /** 店铺id */ |
| | | @ApiModelProperty("店铺id") |
| | | private Long storeId; |
| | | |
| | | /** 店铺名称 */ |
| | | @ApiModelProperty("店铺名称") |
| | | private Long storeName; |
| | | |
| | | /** 优惠卷id */ |
| | | @ApiModelProperty("优惠卷id") |
| | | private Long couponId; |
| | | |
| | | /** 优惠卷名称 */ |
| | | @ApiModelProperty("优惠卷名称") |
| | | private String couponName; |
| | | |
| | | public static StoreCouponVO getVoByEntity(@NonNull StoreCoupon entity, StoreCouponVO vo) { |
| | | if(vo == null) { |
| | | vo = new StoreCouponVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.StoreCouponClaimRecord; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.StoreCouponClaimRecordVO; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponClaimRecordForm; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponClaimRecordQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Mapper |
| | | public interface StoreCouponClaimRecordMapper extends BaseMapper<StoreCouponClaimRecord> { |
| | | |
| | | /** |
| | | * id查找店铺优惠卷领取记录 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | StoreCouponClaimRecordVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") StoreCouponClaimRecordQuery query); |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.StoreCoupon; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import cn.lili.modules.lmk.domain.vo.StoreCouponVO; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponForm; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponQuery; |
| | | import java.util.List; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系 Mapper 接口 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Mapper |
| | | public interface StoreCouponMapper extends BaseMapper<StoreCoupon> { |
| | | |
| | | /** |
| | | * id查找店铺优惠卷对应关系 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | StoreCouponVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") StoreCouponQuery query); |
| | | |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.StoreCouponClaimRecord; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponClaimRecordForm; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponClaimRecordQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | public interface StoreCouponClaimRecordService extends IService<StoreCouponClaimRecord> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(StoreCouponClaimRecordForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(StoreCouponClaimRecordForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(StoreCouponClaimRecordQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.StoreCoupon; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponForm; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponQuery; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系 服务类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | public interface StoreCouponService extends IService<StoreCoupon> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(StoreCouponForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(StoreCouponForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(StoreCouponQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCouponClaimRecord; |
| | | import cn.lili.modules.lmk.mapper.StoreCouponClaimRecordMapper; |
| | | import cn.lili.modules.lmk.service.StoreCouponClaimRecordService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponClaimRecordForm; |
| | | import cn.lili.modules.lmk.domain.vo.StoreCouponClaimRecordVO; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponClaimRecordQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 店铺优惠卷领取记录 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class StoreCouponClaimRecordServiceImpl extends ServiceImpl<StoreCouponClaimRecordMapper, StoreCouponClaimRecord> implements StoreCouponClaimRecordService { |
| | | |
| | | private final StoreCouponClaimRecordMapper storeCouponClaimRecordMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(StoreCouponClaimRecordForm form) { |
| | | StoreCouponClaimRecord entity = StoreCouponClaimRecordForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(StoreCouponClaimRecordForm form) { |
| | | StoreCouponClaimRecord entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(StoreCouponClaimRecordQuery query) { |
| | | IPage<StoreCouponClaimRecordVO> page = PageUtil.getPage(query, StoreCouponClaimRecordVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | StoreCouponClaimRecordVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<StoreCouponClaimRecord> entities = baseMapper.selectList(null); |
| | | List<StoreCouponClaimRecordVO> vos = entities.stream() |
| | | .map(entity -> StoreCouponClaimRecordVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import cn.lili.modules.lmk.domain.entity.StoreCoupon; |
| | | import cn.lili.modules.lmk.mapper.StoreCouponMapper; |
| | | import cn.lili.modules.lmk.service.StoreCouponService; |
| | | import cn.lili.base.Result; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import cn.lili.modules.lmk.domain.form.StoreCouponForm; |
| | | import cn.lili.modules.lmk.domain.vo.StoreCouponVO; |
| | | import cn.lili.modules.lmk.domain.query.StoreCouponQuery; |
| | | import org.springframework.stereotype.Service; |
| | | import lombok.RequiredArgsConstructor; |
| | | import cn.lili.utils.PageUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.util.Assert; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 店铺优惠卷对应关系 服务实现类 |
| | | * |
| | | * @author peng |
| | | * @since 2025-09-25 |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class StoreCouponServiceImpl extends ServiceImpl<StoreCouponMapper, StoreCoupon> implements StoreCouponService { |
| | | |
| | | private final StoreCouponMapper storeCouponMapper; |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result add(StoreCouponForm form) { |
| | | StoreCoupon entity = StoreCouponForm.getEntityByForm(form, null); |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result update(StoreCouponForm form) { |
| | | StoreCoupon entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result removeById(String id) { |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result page(StoreCouponQuery query) { |
| | | IPage<StoreCouponVO> page = PageUtil.getPage(query, StoreCouponVO.class); |
| | | baseMapper.getPage(page, query); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result detail(String id) { |
| | | StoreCouponVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result all() { |
| | | List<StoreCoupon> entities = baseMapper.selectList(null); |
| | | List<StoreCouponVO> vos = entities.stream() |
| | | .map(entity -> StoreCouponVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.StoreCouponClaimRecordMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.StoreCouponClaimRecordVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="store_name" property="storeName" /> |
| | | <result column="coupon_id" property="couponId" /> |
| | | <result column="coupon_name" property="couponName" /> |
| | | <result column="store_id" property="storeId" /> |
| | | <result column="user_id" property="userId" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LSCCR.store_name, |
| | | LSCCR.coupon_id, |
| | | LSCCR.coupon_name, |
| | | LSCCR.store_id, |
| | | LSCCR.user_id, |
| | | LSCCR.id |
| | | FROM |
| | | lmk_store_coupon_claim_record LSCCR |
| | | WHERE |
| | | LSCCR.id = #{id} AND LSCCR.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LSCCR.store_name, |
| | | LSCCR.coupon_id, |
| | | LSCCR.coupon_name, |
| | | LSCCR.store_id, |
| | | LSCCR.user_id, |
| | | LSCCR.id |
| | | FROM |
| | | lmk_store_coupon_claim_record LSCCR |
| | | WHERE |
| | | LSCCR.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.lili.modules.lmk.mapper.StoreCouponMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.StoreCouponVO"> |
| | | <id column="id" property="id"/> |
| | | <result column="store_id" property="storeId" /> |
| | | <result column="store_name" property="storeName" /> |
| | | <result column="coupon_id" property="couponId" /> |
| | | <result column="coupon_name" property="couponName" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LSC.store_id, |
| | | LSC.store_name, |
| | | LSC.coupon_id, |
| | | LSC.coupon_name, |
| | | LSC.id |
| | | FROM |
| | | lmk_store_coupon LSC |
| | | WHERE |
| | | LSC.id = #{id} AND LSC.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LSC.store_id, |
| | | LSC.store_name, |
| | | LSC.coupon_id, |
| | | LSC.coupon_name, |
| | | LSC.id |
| | | FROM |
| | | lmk_store_coupon LSC |
| | | WHERE |
| | | LSC.delete_flag = 0 |
| | | </select> |
| | | |
| | | </mapper> |