feat(user-purchaserecords): 新增用户内购记录管理功能
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
package com.yolo.keyboard.controller.admin.userpurchaserecords;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import jakarta.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.pojo.CommonResult;
|
||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||
import static com.yolo.keyboard.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.yolo.keyboard.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.yolo.keyboard.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static com.yolo.keyboard.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.yolo.keyboard.controller.admin.userpurchaserecords.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.userpurchaserecords.KeyboardUserPurchaseRecordsDO;
|
||||
import com.yolo.keyboard.service.userpurchaserecords.KeyboardUserPurchaseRecordsService;
|
||||
|
||||
@Tag(name = "管理后台 - 用户内购记录")
|
||||
@RestController
|
||||
@RequestMapping("/keyboard/user-purchase-records")
|
||||
@Validated
|
||||
public class KeyboardUserPurchaseRecordsController {
|
||||
|
||||
@Resource
|
||||
private KeyboardUserPurchaseRecordsService userPurchaseRecordsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户内购记录")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:create')")
|
||||
public CommonResult<Integer> createUserPurchaseRecords(@Valid @RequestBody KeyboardUserPurchaseRecordsSaveReqVO createReqVO) {
|
||||
return success(userPurchaseRecordsService.createUserPurchaseRecords(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新用户内购记录")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:update')")
|
||||
public CommonResult<Boolean> updateUserPurchaseRecords(@Valid @RequestBody KeyboardUserPurchaseRecordsSaveReqVO updateReqVO) {
|
||||
userPurchaseRecordsService.updateUserPurchaseRecords(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除用户内购记录")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:delete')")
|
||||
public CommonResult<Boolean> deleteUserPurchaseRecords(@RequestParam("id") Integer id) {
|
||||
userPurchaseRecordsService.deleteUserPurchaseRecords(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除用户内购记录")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:delete')")
|
||||
public CommonResult<Boolean> deleteUserPurchaseRecordsList(@RequestParam("ids") List<Integer> ids) {
|
||||
userPurchaseRecordsService.deleteUserPurchaseRecordsListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得用户内购记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:query')")
|
||||
public CommonResult<KeyboardUserPurchaseRecordsRespVO> getUserPurchaseRecords(@RequestParam("id") Integer id) {
|
||||
KeyboardUserPurchaseRecordsDO userPurchaseRecords = userPurchaseRecordsService.getUserPurchaseRecords(id);
|
||||
return success(BeanUtils.toBean(userPurchaseRecords, KeyboardUserPurchaseRecordsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得用户内购记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:query')")
|
||||
public CommonResult<PageResult<KeyboardUserPurchaseRecordsRespVO>> getUserPurchaseRecordsPage(@Valid KeyboardUserPurchaseRecordsPageReqVO pageReqVO) {
|
||||
PageResult<KeyboardUserPurchaseRecordsDO> pageResult = userPurchaseRecordsService.getUserPurchaseRecordsPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, KeyboardUserPurchaseRecordsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出用户内购记录 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('keyboard:user-purchase-records:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportUserPurchaseRecordsExcel(@Valid KeyboardUserPurchaseRecordsPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<KeyboardUserPurchaseRecordsDO> list = userPurchaseRecordsService.getUserPurchaseRecordsPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "用户内购记录.xls", "数据", KeyboardUserPurchaseRecordsRespVO.class,
|
||||
BeanUtils.toBean(list, KeyboardUserPurchaseRecordsRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.yolo.keyboard.controller.admin.userpurchaserecords.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.yolo.keyboard.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 用户内购记录分页 Request VO")
|
||||
@Data
|
||||
public class KeyboardUserPurchaseRecordsPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户 ID,关联到用户表,表示是哪位用户购买了产品", example = "21782")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "购买的产品 ID,关联到产品表", example = "10744")
|
||||
private String productId;
|
||||
|
||||
@Schema(description = "购买数量(如内购的金币数量,订阅的时长)")
|
||||
private Integer purchaseQuantity;
|
||||
|
||||
@Schema(description = "实际支付价格", example = "17601")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "货币类型(如美元 $)")
|
||||
private String currency;
|
||||
|
||||
@Schema(description = "购买时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] purchaseTime;
|
||||
|
||||
@Schema(description = "购买类型(如内购,订阅)", example = "1")
|
||||
private String purchaseType;
|
||||
|
||||
@Schema(description = "购买状态(如已支付,待支付,退款)", example = "2")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "支付方式(如信用卡,支付宝等)")
|
||||
private String paymentMethod;
|
||||
|
||||
@Schema(description = "唯一的交易 ID,用于标识该购买操作", example = "14496")
|
||||
private String transactionId;
|
||||
|
||||
@Schema(description = "苹果的原始交易 ID", example = "3666")
|
||||
private String originalTransactionId;
|
||||
|
||||
@Schema(description = "购买的产品 ID 列表(JSON 格式或数组)")
|
||||
private Object productIds;
|
||||
|
||||
@Schema(description = "苹果返回的购买时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] purchaseDate;
|
||||
|
||||
@Schema(description = "苹果返回的过期时间(如果有)")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] expiresDate;
|
||||
|
||||
@Schema(description = "苹果的环境(如 Sandbox 或 Production)")
|
||||
private String environment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.yolo.keyboard.controller.admin.userpurchaserecords.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import cn.idev.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 用户内购记录 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class KeyboardUserPurchaseRecordsRespVO {
|
||||
|
||||
@Schema(description = "主键,自增,唯一标识每条购买记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1239")
|
||||
@ExcelProperty("主键,自增,唯一标识每条购买记录")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "用户 ID,关联到用户表,表示是哪位用户购买了产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "21782")
|
||||
@ExcelProperty("用户 ID,关联到用户表,表示是哪位用户购买了产品")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "购买的产品 ID,关联到产品表", requiredMode = Schema.RequiredMode.REQUIRED, example = "10744")
|
||||
@ExcelProperty("购买的产品 ID,关联到产品表")
|
||||
private String productId;
|
||||
|
||||
@Schema(description = "购买数量(如内购的金币数量,订阅的时长)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("购买数量(如内购的金币数量,订阅的时长)")
|
||||
private Integer purchaseQuantity;
|
||||
|
||||
@Schema(description = "实际支付价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "17601")
|
||||
@ExcelProperty("实际支付价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "货币类型(如美元 $)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("货币类型(如美元 $)")
|
||||
private String currency;
|
||||
|
||||
@Schema(description = "购买时间")
|
||||
@ExcelProperty("购买时间")
|
||||
private LocalDateTime purchaseTime;
|
||||
|
||||
@Schema(description = "购买类型(如内购,订阅)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("购买类型(如内购,订阅)")
|
||||
private String purchaseType;
|
||||
|
||||
@Schema(description = "购买状态(如已支付,待支付,退款)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("购买状态(如已支付,待支付,退款)")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "支付方式(如信用卡,支付宝等)")
|
||||
@ExcelProperty("支付方式(如信用卡,支付宝等)")
|
||||
private String paymentMethod;
|
||||
|
||||
@Schema(description = "唯一的交易 ID,用于标识该购买操作", requiredMode = Schema.RequiredMode.REQUIRED, example = "14496")
|
||||
@ExcelProperty("唯一的交易 ID,用于标识该购买操作")
|
||||
private String transactionId;
|
||||
|
||||
@Schema(description = "苹果的原始交易 ID", example = "3666")
|
||||
@ExcelProperty("苹果的原始交易 ID")
|
||||
private String originalTransactionId;
|
||||
|
||||
@Schema(description = "购买的产品 ID 列表(JSON 格式或数组)")
|
||||
@ExcelProperty("购买的产品 ID 列表(JSON 格式或数组)")
|
||||
private Object productIds;
|
||||
|
||||
@Schema(description = "苹果返回的购买时间")
|
||||
@ExcelProperty("苹果返回的购买时间")
|
||||
private LocalDateTime purchaseDate;
|
||||
|
||||
@Schema(description = "苹果返回的过期时间(如果有)")
|
||||
@ExcelProperty("苹果返回的过期时间(如果有)")
|
||||
private LocalDateTime expiresDate;
|
||||
|
||||
@Schema(description = "苹果的环境(如 Sandbox 或 Production)")
|
||||
@ExcelProperty("苹果的环境(如 Sandbox 或 Production)")
|
||||
private String environment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.yolo.keyboard.controller.admin.userpurchaserecords.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 用户内购记录新增/修改 Request VO")
|
||||
@Data
|
||||
public class KeyboardUserPurchaseRecordsSaveReqVO {
|
||||
|
||||
@Schema(description = "主键,自增,唯一标识每条购买记录", requiredMode = Schema.RequiredMode.REQUIRED, example = "1239")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "用户 ID,关联到用户表,表示是哪位用户购买了产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "21782")
|
||||
@NotNull(message = "用户 ID,关联到用户表,表示是哪位用户购买了产品不能为空")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "购买的产品 ID,关联到产品表", requiredMode = Schema.RequiredMode.REQUIRED, example = "10744")
|
||||
@NotEmpty(message = "购买的产品 ID,关联到产品表不能为空")
|
||||
private String productId;
|
||||
|
||||
@Schema(description = "购买数量(如内购的金币数量,订阅的时长)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "购买数量(如内购的金币数量,订阅的时长)不能为空")
|
||||
private Integer purchaseQuantity;
|
||||
|
||||
@Schema(description = "实际支付价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "17601")
|
||||
@NotNull(message = "实际支付价格不能为空")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "货币类型(如美元 $)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "货币类型(如美元 $)不能为空")
|
||||
private String currency;
|
||||
|
||||
@Schema(description = "购买时间")
|
||||
private LocalDateTime purchaseTime;
|
||||
|
||||
@Schema(description = "购买类型(如内购,订阅)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "购买类型(如内购,订阅)不能为空")
|
||||
private String purchaseType;
|
||||
|
||||
@Schema(description = "购买状态(如已支付,待支付,退款)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "购买状态(如已支付,待支付,退款)不能为空")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "支付方式(如信用卡,支付宝等)")
|
||||
private String paymentMethod;
|
||||
|
||||
@Schema(description = "唯一的交易 ID,用于标识该购买操作", requiredMode = Schema.RequiredMode.REQUIRED, example = "14496")
|
||||
@NotEmpty(message = "唯一的交易 ID,用于标识该购买操作不能为空")
|
||||
private String transactionId;
|
||||
|
||||
@Schema(description = "苹果的原始交易 ID", example = "3666")
|
||||
private String originalTransactionId;
|
||||
|
||||
@Schema(description = "购买的产品 ID 列表(JSON 格式或数组)")
|
||||
private Object productIds;
|
||||
|
||||
@Schema(description = "苹果返回的购买时间")
|
||||
private LocalDateTime purchaseDate;
|
||||
|
||||
@Schema(description = "苹果返回的过期时间(如果有)")
|
||||
private LocalDateTime expiresDate;
|
||||
|
||||
@Schema(description = "苹果的环境(如 Sandbox 或 Production)")
|
||||
private String environment;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.yolo.keyboard.dal.dataobject.userpurchaserecords;
|
||||
|
||||
import com.yolo.keyboard.framework.tenant.core.aop.TenantIgnore;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.yolo.keyboard.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 用户内购记录 DO
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@TableName("keyboard_user_purchase_records")
|
||||
@KeySequence("keyboard_user_purchase_records_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TenantIgnore
|
||||
public class KeyboardUserPurchaseRecordsDO{
|
||||
|
||||
/**
|
||||
* 主键,自增,唯一标识每条购买记录
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户 ID,关联到用户表,表示是哪位用户购买了产品
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 购买的产品 ID,关联到产品表
|
||||
*/
|
||||
private String productId;
|
||||
/**
|
||||
* 购买数量(如内购的金币数量,订阅的时长)
|
||||
*/
|
||||
private Integer purchaseQuantity;
|
||||
/**
|
||||
* 实际支付价格
|
||||
*/
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 货币类型(如美元 $)
|
||||
*/
|
||||
private String currency;
|
||||
/**
|
||||
* 购买时间
|
||||
*/
|
||||
private LocalDateTime purchaseTime;
|
||||
/**
|
||||
* 购买类型(如内购,订阅)
|
||||
*/
|
||||
private String purchaseType;
|
||||
/**
|
||||
* 购买状态(如已支付,待支付,退款)
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 支付方式(如信用卡,支付宝等)
|
||||
*/
|
||||
private String paymentMethod;
|
||||
/**
|
||||
* 唯一的交易 ID,用于标识该购买操作
|
||||
*/
|
||||
private String transactionId;
|
||||
/**
|
||||
* 苹果的原始交易 ID
|
||||
*/
|
||||
private String originalTransactionId;
|
||||
/**
|
||||
* 购买的产品 ID 列表(JSON 格式或数组)
|
||||
*/
|
||||
private Object productIds;
|
||||
/**
|
||||
* 苹果返回的购买时间
|
||||
*/
|
||||
private LocalDateTime purchaseDate;
|
||||
/**
|
||||
* 苹果返回的过期时间(如果有)
|
||||
*/
|
||||
private LocalDateTime expiresDate;
|
||||
/**
|
||||
* 苹果的环境(如 Sandbox 或 Production)
|
||||
*/
|
||||
private String environment;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yolo.keyboard.dal.mysql.userpurchaserecords;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.yolo.keyboard.dal.dataobject.userpurchaserecords.KeyboardUserPurchaseRecordsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import com.yolo.keyboard.controller.admin.userpurchaserecords.vo.*;
|
||||
|
||||
/**
|
||||
* 用户内购记录 Mapper
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Mapper
|
||||
public interface KeyboardUserPurchaseRecordsMapper extends BaseMapperX<KeyboardUserPurchaseRecordsDO> {
|
||||
|
||||
default PageResult<KeyboardUserPurchaseRecordsDO> selectPage(KeyboardUserPurchaseRecordsPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KeyboardUserPurchaseRecordsDO>()
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getUserId, reqVO.getUserId())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getProductId, reqVO.getProductId())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseQuantity, reqVO.getPurchaseQuantity())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getPrice, reqVO.getPrice())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getCurrency, reqVO.getCurrency())
|
||||
.betweenIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseTime, reqVO.getPurchaseTime())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseType, reqVO.getPurchaseType())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getPaymentMethod, reqVO.getPaymentMethod())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getTransactionId, reqVO.getTransactionId())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getOriginalTransactionId, reqVO.getOriginalTransactionId())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getProductIds, reqVO.getProductIds())
|
||||
.betweenIfPresent(KeyboardUserPurchaseRecordsDO::getPurchaseDate, reqVO.getPurchaseDate())
|
||||
.betweenIfPresent(KeyboardUserPurchaseRecordsDO::getExpiresDate, reqVO.getExpiresDate())
|
||||
.eqIfPresent(KeyboardUserPurchaseRecordsDO::getEnvironment, reqVO.getEnvironment())
|
||||
.orderByDesc(KeyboardUserPurchaseRecordsDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yolo.keyboard.service.userpurchaserecords;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import com.yolo.keyboard.controller.admin.userpurchaserecords.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.userpurchaserecords.KeyboardUserPurchaseRecordsDO;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 用户内购记录 Service 接口
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
public interface KeyboardUserPurchaseRecordsService {
|
||||
|
||||
/**
|
||||
* 创建用户内购记录
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createUserPurchaseRecords(@Valid KeyboardUserPurchaseRecordsSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新用户内购记录
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateUserPurchaseRecords(@Valid KeyboardUserPurchaseRecordsSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除用户内购记录
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteUserPurchaseRecords(Integer id);
|
||||
|
||||
/**
|
||||
* 批量删除用户内购记录
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteUserPurchaseRecordsListByIds(List<Integer> ids);
|
||||
|
||||
/**
|
||||
* 获得用户内购记录
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 用户内购记录
|
||||
*/
|
||||
KeyboardUserPurchaseRecordsDO getUserPurchaseRecords(Integer id);
|
||||
|
||||
/**
|
||||
* 获得用户内购记录分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 用户内购记录分页
|
||||
*/
|
||||
PageResult<KeyboardUserPurchaseRecordsDO> getUserPurchaseRecordsPage(KeyboardUserPurchaseRecordsPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.yolo.keyboard.service.userpurchaserecords;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import com.yolo.keyboard.controller.admin.userpurchaserecords.vo.*;
|
||||
import com.yolo.keyboard.dal.dataobject.userpurchaserecords.KeyboardUserPurchaseRecordsDO;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||
import com.yolo.keyboard.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.yolo.keyboard.dal.mysql.userpurchaserecords.KeyboardUserPurchaseRecordsMapper;
|
||||
|
||||
import static com.yolo.keyboard.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.USER_PURCHASE_RECORDS_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 用户内购记录 Service 实现类
|
||||
*
|
||||
* @author ziin
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class KeyboardUserPurchaseRecordsServiceImpl implements KeyboardUserPurchaseRecordsService {
|
||||
|
||||
@Resource
|
||||
private KeyboardUserPurchaseRecordsMapper userPurchaseRecordsMapper;
|
||||
|
||||
@Override
|
||||
public Integer createUserPurchaseRecords(KeyboardUserPurchaseRecordsSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
KeyboardUserPurchaseRecordsDO userPurchaseRecords = BeanUtils.toBean(createReqVO, KeyboardUserPurchaseRecordsDO.class);
|
||||
userPurchaseRecordsMapper.insert(userPurchaseRecords);
|
||||
|
||||
// 返回
|
||||
return userPurchaseRecords.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserPurchaseRecords(KeyboardUserPurchaseRecordsSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateUserPurchaseRecordsExists(updateReqVO.getId());
|
||||
// 更新
|
||||
KeyboardUserPurchaseRecordsDO updateObj = BeanUtils.toBean(updateReqVO, KeyboardUserPurchaseRecordsDO.class);
|
||||
userPurchaseRecordsMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserPurchaseRecords(Integer id) {
|
||||
// 校验存在
|
||||
validateUserPurchaseRecordsExists(id);
|
||||
// 删除
|
||||
userPurchaseRecordsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUserPurchaseRecordsListByIds(List<Integer> ids) {
|
||||
// 删除
|
||||
userPurchaseRecordsMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
|
||||
private void validateUserPurchaseRecordsExists(Integer id) {
|
||||
if (userPurchaseRecordsMapper.selectById(id) == null) {
|
||||
throw exception(USER_PURCHASE_RECORDS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyboardUserPurchaseRecordsDO getUserPurchaseRecords(Integer id) {
|
||||
return userPurchaseRecordsMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KeyboardUserPurchaseRecordsDO> getUserPurchaseRecordsPage(KeyboardUserPurchaseRecordsPageReqVO pageReqVO) {
|
||||
return userPurchaseRecordsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?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.yolo.keyboard.module.keyboard.dal.mysql.userpurchaserecords.KeyboardUserPurchaseRecordsMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
@@ -77,6 +77,8 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode THEME_PURCHASE_NOT_EXISTS = new ErrorCode(1_001_202_003, "皮肤购买记录表(积分支付)不存在");
|
||||
ErrorCode CHARACTER_NOT_EXISTS = new ErrorCode(1_001_202_004, "键盘人设不存在");
|
||||
ErrorCode USER_WALLET_NOT_EXISTS = new ErrorCode(1_001_202_005, "用户钱包不存在");
|
||||
ErrorCode USER_PURCHASE_RECORDS_NOT_EXISTS = new ErrorCode(1_001_202_006, "用户内购记录不存在");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user