完成会员卡管理模块

This commit is contained in:
gxwebsoft
2024-04-24 20:50:10 +08:00
parent b821008f88
commit 0a6a0c5f21
15 changed files with 887 additions and 3 deletions
@@ -0,0 +1,115 @@
package com.gxwebsoft.booking.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.booking.service.CardService;
import com.gxwebsoft.booking.entity.Card;
import com.gxwebsoft.booking.param.CardParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 会员卡控制器
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Api(tags = "会员卡管理")
@RestController
@RequestMapping("/api/booking/card")
public class CardController extends BaseController {
@Resource
private CardService cardService;
@ApiOperation("分页查询会员卡")
@GetMapping("/page")
public ApiResult<PageResult<Card>> page(CardParam param) {
// 使用关联查询
return success(cardService.pageRel(param));
}
@ApiOperation("查询全部会员卡")
@GetMapping()
public ApiResult<List<Card>> list(CardParam param) {
// 使用关联查询
return success(cardService.listRel(param));
}
@PreAuthorize("hasAuthority('booking:card:list')")
@ApiOperation("根据id查询会员卡")
@GetMapping("/{id}")
public ApiResult<Card> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(cardService.getByIdRel(id));
}
@ApiOperation("添加会员卡")
@PostMapping()
public ApiResult<?> save(@RequestBody Card card) {
// 记录当前登录用户id
// User loginUser = getLoginUser();
// if (loginUser != null) {
// card.setUserId(loginUser.getUserId());
// }
if (cardService.save(card)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改会员卡")
@PutMapping()
public ApiResult<?> update(@RequestBody Card card) {
if (cardService.updateById(card)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除会员卡")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (cardService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加会员卡")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<Card> list) {
if (cardService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改会员卡")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Card> batchParam) {
if (batchParam.update(cardService, "card_id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除会员卡")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (cardService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -0,0 +1,115 @@
package com.gxwebsoft.booking.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.booking.service.CardPlanService;
import com.gxwebsoft.booking.entity.CardPlan;
import com.gxwebsoft.booking.param.CardPlanParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 会员卡类型控制器
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Api(tags = "会员卡类型管理")
@RestController
@RequestMapping("/api/booking/card-plan")
public class CardPlanController extends BaseController {
@Resource
private CardPlanService cardPlanService;
@ApiOperation("分页查询会员卡类型")
@GetMapping("/page")
public ApiResult<PageResult<CardPlan>> page(CardPlanParam param) {
// 使用关联查询
return success(cardPlanService.pageRel(param));
}
@ApiOperation("查询全部会员卡类型")
@GetMapping()
public ApiResult<List<CardPlan>> list(CardPlanParam param) {
// 使用关联查询
return success(cardPlanService.listRel(param));
}
@PreAuthorize("hasAuthority('booking:cardPlan:list')")
@ApiOperation("根据id查询会员卡类型")
@GetMapping("/{id}")
public ApiResult<CardPlan> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(cardPlanService.getByIdRel(id));
}
@ApiOperation("添加会员卡类型")
@PostMapping()
public ApiResult<?> save(@RequestBody CardPlan cardPlan) {
// 记录当前登录用户id
// User loginUser = getLoginUser();
// if (loginUser != null) {
// cardPlan.setUserId(loginUser.getUserId());
// }
if (cardPlanService.save(cardPlan)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改会员卡类型")
@PutMapping()
public ApiResult<?> update(@RequestBody CardPlan cardPlan) {
if (cardPlanService.updateById(cardPlan)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除会员卡类型")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (cardPlanService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加会员卡类型")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<CardPlan> list) {
if (cardPlanService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改会员卡类型")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<CardPlan> batchParam) {
if (batchParam.update(cardPlanService, "card_plan_id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除会员卡类型")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (cardPlanService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -0,0 +1,87 @@
package com.gxwebsoft.booking.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 会员卡
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Card对象", description = "会员卡")
@TableName("booking_card")
public class Card implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "card_id", type = IdType.AUTO)
private Integer cardId;
@ApiModelProperty(value = "会员卡名称")
private String cardName;
@ApiModelProperty(value = "会员卡标识")
private String cardCode;
@ApiModelProperty(value = "会员卡图片")
private String image;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "次数")
private Integer number;
@ApiModelProperty(value = "月份")
private Integer month;
@ApiModelProperty(value = "折扣")
private BigDecimal discount;
@ApiModelProperty(value = "老师介绍")
private String content;
@ApiModelProperty(value = "关联用户")
private Integer userId;
@ApiModelProperty(value = "商户ID")
private Integer merchantId;
@ApiModelProperty(value = "商户类型")
private String merchantType;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "状态")
private Integer status;
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "商户ID")
@TableField(exist = false)
private String merchantName;
}
@@ -0,0 +1,54 @@
package com.gxwebsoft.booking.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 会员卡类型
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "CardPlan对象", description = "会员卡类型")
@TableName("booking_card_plan")
public class CardPlan implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@TableId(value = "card_plan_id", type = IdType.AUTO)
private Integer cardPlanId;
@ApiModelProperty(value = "会员卡名称")
private String name;
@ApiModelProperty(value = "标识")
private String code;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "状态")
private Integer status;
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "创建时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.booking.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.booking.entity.Card;
import com.gxwebsoft.booking.param.CardParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 会员卡Mapper
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
public interface CardMapper extends BaseMapper<Card> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<Card>
*/
List<Card> selectPageRel(@Param("page") IPage<Card> page,
@Param("param") CardParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<Card> selectListRel(@Param("param") CardParam param);
}
@@ -0,0 +1,37 @@
package com.gxwebsoft.booking.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.booking.entity.CardPlan;
import com.gxwebsoft.booking.param.CardPlanParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 会员卡类型Mapper
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
public interface CardPlanMapper extends BaseMapper<CardPlan> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<CardPlan>
*/
List<CardPlan> selectPageRel(@Param("page") IPage<CardPlan> page,
@Param("param") CardPlanParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<CardPlan> selectListRel(@Param("param") CardPlanParam param);
}
@@ -0,0 +1,79 @@
<?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="com.gxwebsoft.booking.mapper.CardMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*,b.merchant_name
FROM booking_card a
LEFT JOIN shop_merchant b ON a.merchant_id = b.merchant_id
<where>
<if test="param.cardId != null">
AND a.card_id = #{param.cardId}
</if>
<if test="param.cardName != null">
AND a.card_name LIKE CONCAT('%', #{param.cardName}, '%')
</if>
<if test="param.cardCode != null">
AND a.card_code = #{param.cardCode}
</if>
<if test="param.merchantType != null">
AND a.merchant_type = #{param.merchantType}
</if>
<if test="param.image != null">
AND a.image LIKE CONCAT('%', #{param.image}, '%')
</if>
<if test="param.price != null">
AND a.price = #{param.price}
</if>
<if test="param.number != null">
AND a.number = #{param.number}
</if>
<if test="param.month != null">
AND a.month = #{param.month}
</if>
<if test="param.discount != null">
AND a.discount = #{param.discount}
</if>
<if test="param.content != null">
AND a.content LIKE CONCAT('%', #{param.content}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.merchantId != null">
AND a.merchant_id = #{param.merchantId}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.booking.entity.Card">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.booking.entity.Card">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -0,0 +1,51 @@
<?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="com.gxwebsoft.booking.mapper.CardPlanMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM booking_card_plan a
<where>
<if test="param.cardPlanId != null">
AND a.card_plan_id = #{param.cardPlanId}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.booking.entity.CardPlan">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.booking.entity.CardPlan">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -0,0 +1,82 @@
package com.gxwebsoft.booking.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 会员卡查询参数
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "CardParam对象", description = "会员卡查询参数")
public class CardParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@QueryField(type = QueryType.EQ)
private Integer cardId;
@ApiModelProperty(value = "会员卡名称")
private String cardName;
@ApiModelProperty(value = "会员卡标识")
@QueryField(type = QueryType.EQ)
private String cardCode;
@ApiModelProperty(value = "会员卡图片")
private String image;
@ApiModelProperty(value = "价格")
@QueryField(type = QueryType.EQ)
private BigDecimal price;
@ApiModelProperty(value = "次数")
@QueryField(type = QueryType.EQ)
private Integer number;
@ApiModelProperty(value = "月份")
@QueryField(type = QueryType.EQ)
private Integer month;
@ApiModelProperty(value = "折扣")
@QueryField(type = QueryType.EQ)
private BigDecimal discount;
@ApiModelProperty(value = "老师介绍")
private String content;
@ApiModelProperty(value = "关联用户")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "商户ID")
@QueryField(type = QueryType.EQ)
private Integer merchantId;
@ApiModelProperty(value = "商户类型")
@QueryField(type = QueryType.EQ)
private String merchantType;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "状态")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.booking.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 会员卡类型查询参数
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "CardPlanParam对象", description = "会员卡类型查询参数")
public class CardPlanParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
@QueryField(type = QueryType.EQ)
private Integer cardPlanId;
@ApiModelProperty(value = "会员卡名称")
private String name;
@ApiModelProperty(value = "标识")
private String code;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "状态")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.booking.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.booking.entity.CardPlan;
import com.gxwebsoft.booking.param.CardPlanParam;
import java.util.List;
/**
* 会员卡类型Service
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
public interface CardPlanService extends IService<CardPlan> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<CardPlan>
*/
PageResult<CardPlan> pageRel(CardPlanParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<CardPlan>
*/
List<CardPlan> listRel(CardPlanParam param);
/**
* 根据id查询
*
* @param cardPlanId ID
* @return CardPlan
*/
CardPlan getByIdRel(Integer cardPlanId);
}
@@ -0,0 +1,42 @@
package com.gxwebsoft.booking.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.booking.entity.Card;
import com.gxwebsoft.booking.param.CardParam;
import java.util.List;
/**
* 会员卡Service
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
public interface CardService extends IService<Card> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<Card>
*/
PageResult<Card> pageRel(CardParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<Card>
*/
List<Card> listRel(CardParam param);
/**
* 根据id查询
*
* @param cardId ID
* @return Card
*/
Card getByIdRel(Integer cardId);
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.booking.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.booking.mapper.CardPlanMapper;
import com.gxwebsoft.booking.service.CardPlanService;
import com.gxwebsoft.booking.entity.CardPlan;
import com.gxwebsoft.booking.param.CardPlanParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 会员卡类型Service实现
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Service
public class CardPlanServiceImpl extends ServiceImpl<CardPlanMapper, CardPlan> implements CardPlanService {
@Override
public PageResult<CardPlan> pageRel(CardPlanParam param) {
PageParam<CardPlan, CardPlanParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<CardPlan> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<CardPlan> listRel(CardPlanParam param) {
List<CardPlan> list = baseMapper.selectListRel(param);
// 排序
PageParam<CardPlan, CardPlanParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public CardPlan getByIdRel(Integer cardPlanId) {
CardPlanParam param = new CardPlanParam();
param.setCardPlanId(cardPlanId);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -0,0 +1,47 @@
package com.gxwebsoft.booking.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.booking.mapper.CardMapper;
import com.gxwebsoft.booking.service.CardService;
import com.gxwebsoft.booking.entity.Card;
import com.gxwebsoft.booking.param.CardParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 会员卡Service实现
*
* @author 科技小王子
* @since 2024-04-24 18:39:18
*/
@Service
public class CardServiceImpl extends ServiceImpl<CardMapper, Card> implements CardService {
@Override
public PageResult<Card> pageRel(CardParam param) {
PageParam<Card, CardParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<Card> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<Card> listRel(CardParam param) {
List<Card> list = baseMapper.selectListRel(param);
// 排序
PageParam<Card, CardParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public Card getByIdRel(Integer cardId) {
CardParam param = new CardParam();
param.setCardId(cardId);
return param.getOne(baseMapper.selectListRel(param));
}
}