!506 积分模块

Merge pull request !506 from QingX/feature/mall_product
This commit is contained in:
芋道源码 2023-06-17 09:41:41 +00:00 committed by Gitee
commit 798e322f08
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
67 changed files with 3482 additions and 16 deletions

230
sql/mysql/menu.sql Normal file
View File

@ -0,0 +1,230 @@
-- 菜单 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'积分设置管理', '', 2, 0, 2162,
'config', '', 'point/config/index', 0, 'PointConfig'
);
-- 按钮父菜单ID
-- 暂时只支持 MySQL如果你是 OraclePostgreSQLSQLServer 的话需要手动修改 @parentId 的部分的代码
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分设置查询', 'point:config:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分设置创建', 'point:config:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分设置更新', 'point:config:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分设置删除', 'point:config:delete', 3, 4, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分设置导出', 'point:config:export', 3, 5, @parentId,
'', '', '', 0
);
-- 菜单 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'积分签到规则管理', '', 2, 0, 2162,
'sign-in-config', '', 'point/signInConfig/index', 0, 'SignInConfig'
);
-- 按钮父菜单ID
-- 暂时只支持 MySQL如果你是 OraclePostgreSQLSQLServer 的话需要手动修改 @parentId 的部分的代码
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分签到规则查询', 'point:sign-in-config:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分签到规则创建', 'point:sign-in-config:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分签到规则更新', 'point:sign-in-config:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分签到规则删除', 'point:sign-in-config:delete', 3, 4, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'积分签到规则导出', 'point:sign-in-config:export', 3, 5, @parentId,
'', '', '', 0
);
-- 菜单 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'用户积分记录管理', '', 2, 0, 2162,
'record', '', 'point/record/index', 0, 'PointRecord'
);
-- 按钮父菜单ID
-- 暂时只支持 MySQL如果你是 OraclePostgreSQLSQLServer 的话需要手动修改 @parentId 的部分的代码
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户积分记录查询', 'point:record:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户积分记录创建', 'point:record:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户积分记录更新', 'point:record:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户积分记录删除', 'point:record:delete', 3, 4, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户积分记录导出', 'point:record:export', 3, 5, @parentId,
'', '', '', 0
);
-- 菜单 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'用户签到积分管理', '', 2, 0, 2162,
'sign-in-record', '', 'point/signInRecord/index', 0, 'SignInRecord'
);
-- 按钮父菜单ID
-- 暂时只支持 MySQL如果你是 OraclePostgreSQLSQLServer 的话需要手动修改 @parentId 的部分的代码
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户签到积分查询', 'point:sign-in-record:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户签到积分创建', 'point:sign-in-record:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户签到积分更新', 'point:sign-in-record:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户签到积分删除', 'point:sign-in-record:delete', 3, 4, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'用户签到积分导出', 'point:sign-in-record:export', 3, 5, @parentId,
'', '', '', 0
);

152
sql/mysql/point.sql Normal file
View File

@ -0,0 +1,152 @@
/*
Navicat Premium Data Transfer
Source Server : docer-master-root(3308)
Source Server Type : MySQL
Source Server Version : 80030
Source Host : 10.211.55.5:3308
Source Schema : mall
Target Server Type : MySQL
Target Server Version : 80030
File Encoding : 65001
Date: 10/06/2023 20:13:57
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for member_point_config
-- ----------------------------
DROP TABLE IF EXISTS `member_point_config`;
CREATE TABLE `member_point_config` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`trade_deduct_enable` int DEFAULT NULL COMMENT '1 开启积分抵扣\n0 关闭积分抵扣',
`trade_deduct_unit_price` decimal(10,2) DEFAULT NULL COMMENT '积分抵扣抵扣最低为分 以0.01表示 1积分抵扣0.01元(单位)',
`trade_deduct_max_price` bigint DEFAULT NULL COMMENT '积分抵扣最大值',
`trade_give_point` bigint DEFAULT NULL COMMENT '1元赠送多少分',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
`deleted` int DEFAULT '0' COMMENT '是否被删除 0 未删除 1已删除',
`creator` varchar(255) DEFAULT NULL COMMENT '创建人',
`updater` varchar(255) DEFAULT NULL COMMENT '更新人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='积分设置';
-- ----------------------------
-- Records of member_point_config
-- ----------------------------
BEGIN;
INSERT INTO `member_point_config` (`id`, `trade_deduct_enable`, `trade_deduct_unit_price`, `trade_deduct_max_price`, `trade_give_point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (1, 1, 0.01, 10000, 1, '2023-06-10 10:57:22', '2023-06-10 03:06:58', '1', 1, '1', '1');
INSERT INTO `member_point_config` (`id`, `trade_deduct_enable`, `trade_deduct_unit_price`, `trade_deduct_max_price`, `trade_give_point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (2, 1, 0.01, 10000, 10, '2023-06-10 11:07:12', '2023-06-10 11:07:12', '1', 0, '1', '1');
INSERT INTO `member_point_config` (`id`, `trade_deduct_enable`, `trade_deduct_unit_price`, `trade_deduct_max_price`, `trade_give_point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (3, 1, 12.00, 12, 12, '2023-06-10 16:09:26', '2023-06-10 08:10:53', '1', 1, '1', '1');
COMMIT;
-- ----------------------------
-- Table structure for member_point_record
-- ----------------------------
DROP TABLE IF EXISTS `member_point_record`;
CREATE TABLE `member_point_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增主键',
`biz_id` varchar(255) DEFAULT NULL COMMENT '业务编码',
`biz_type` varchar(255) DEFAULT NULL COMMENT '业务类型',
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '1增加 0扣减',
`title` varchar(255) DEFAULT NULL COMMENT '积分标题',
`description` varchar(5000) DEFAULT NULL COMMENT '积分描述',
`point` int DEFAULT NULL COMMENT '积分',
`total_point` int NOT NULL COMMENT '变动后的积分',
`status` int DEFAULT NULL COMMENT '状态1-订单创建2-冻结期3-完成4-失效订单退款\n',
`user_id` int DEFAULT NULL COMMENT '用户id',
`freezing_time` datetime DEFAULT NULL COMMENT '冻结时间',
`thawing_time` datetime DEFAULT NULL COMMENT '解冻时间',
`create_time` datetime DEFAULT NULL COMMENT '发生时间',
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户',
`deleted` int DEFAULT '0' COMMENT '是否删除',
`creator` varchar(255) DEFAULT NULL COMMENT '创建用户',
`updater` varchar(255) DEFAULT NULL COMMENT '更新用户',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `index_userId` (`user_id`),
KEY `index_title` (`title`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户积分记录';
-- ----------------------------
-- Records of member_point_record
-- ----------------------------
BEGIN;
INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (1, '1', '1', '1', '12', NULL, 212, 12, 1, 12, '2023-06-13 00:00:00', '2023-06-20 00:00:00', '2023-06-10 12:38:48', '1', 1, '1', '1', '2023-06-10 04:42:24');
INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (2, '12', '1', '0', NULL, NULL, 1212, 12, 2, 12, '2023-06-28 00:00:00', NULL, '2023-06-10 12:42:48', '1', 0, '1', '1', '2023-06-10 12:43:04');
INSERT INTO `member_point_record` (`id`, `biz_id`, `biz_type`, `type`, `title`, `description`, `point`, `total_point`, `status`, `user_id`, `freezing_time`, `thawing_time`, `create_time`, `tenant_id`, `deleted`, `creator`, `updater`, `update_time`) VALUES (3, '12', '1', '1', '12', NULL, 12, 12, 1, 12, '2023-06-27 00:00:00', '2023-06-23 00:00:00', '2023-06-10 20:06:48', '1', 0, '1', '1', '2023-06-10 20:06:48');
COMMIT;
-- ----------------------------
-- Table structure for member_sign_in_config
-- ----------------------------
DROP TABLE IF EXISTS `member_sign_in_config`;
CREATE TABLE `member_sign_in_config` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '规则自增主键',
`day` int DEFAULT NULL COMMENT '签到第x天',
`point` int DEFAULT NULL COMMENT '签到天数对应分数',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
`deleted` int DEFAULT '0' COMMENT '是否删除',
`creator` varchar(255) DEFAULT NULL COMMENT '创建人',
`updater` varchar(255) DEFAULT NULL COMMENT '变更人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='积分签到规则';
-- ----------------------------
-- Records of member_sign_in_config
-- ----------------------------
BEGIN;
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (1, 1, 10, '2023-06-10 11:34:43', '2023-06-10 11:34:43', '1', 0, '1', '1');
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (2, 2, 20, '2023-06-10 11:34:59', '2023-06-10 03:55:35', '1', 1, '1', '1');
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (3, 7, 1001, '2023-06-10 17:47:45', '2023-06-10 19:54:37', '1', 0, '1', '1');
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (4, 6, 12121, '2023-06-10 17:47:55', '2023-06-10 19:48:37', '1', 0, '1', '1');
INSERT INTO `member_sign_in_config` (`id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (5, 2, 12, '2023-06-10 19:54:52', '2023-06-10 19:54:52', '1', 0, '1', '1');
COMMIT;
-- ----------------------------
-- Table structure for member_sign_in_record
-- ----------------------------
DROP TABLE IF EXISTS `member_sign_in_record`;
CREATE TABLE `member_sign_in_record` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '签到自增id',
`user_id` int DEFAULT NULL COMMENT '签到用户',
`day` int DEFAULT NULL COMMENT '第几天签到',
`point` int DEFAULT NULL COMMENT '签到的分数',
`create_time` datetime DEFAULT NULL COMMENT '签到时间',
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '变更时间',
`tenant_id` varchar(255) DEFAULT NULL COMMENT '租户id',
`deleted` int DEFAULT '0' COMMENT '是否删除',
`creator` varchar(255) DEFAULT NULL COMMENT '创建人',
`updater` varchar(255) DEFAULT NULL COMMENT '更新人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='用户签到积分';
-- ----------------------------
-- Records of member_sign_in_record
-- ----------------------------
BEGIN;
INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (1, 121, 1, 123, '2023-06-10 12:58:18', '2023-06-10 04:59:00', '1', 1, '1', '1');
INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (2, 12, 12, 12, '2023-06-10 19:56:39', '2023-06-10 11:56:45', '1', 1, '1', '1');
INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (3, 12, 12, 1212, '2023-06-10 20:01:17', '2023-06-10 12:01:23', '1', 1, '1', '1');
INSERT INTO `member_sign_in_record` (`id`, `user_id`, `day`, `point`, `create_time`, `update_time`, `tenant_id`, `deleted`, `creator`, `updater`) VALUES (4, 12, 12, 1212, '2023-06-10 20:01:27', '2023-06-10 20:01:27', '1', 0, '1', '1');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
INSERT INTO `mall`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ( '积分业务类型', 'point_biz_type', 0, '', '1', '2023-06-10 12:15:00', '1', '2023-06-10 04:25:07', b'0', '1970-01-01 00:00:00');
INSERT INTO `mall`.`system_dict_type` ( `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ( '积分订单状态', 'point_status', 0, '', '1', '2023-06-10 12:16:27', '1', '2023-06-10 12:16:27', b'0', '1970-01-01 00:00:00');
INSERT INTO `mall`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 1, '购物', '1', 'point_biz_type', 0, '', '', '', '1', '2023-06-10 12:15:27', '1', '2023-06-10 04:25:15', b'0');
INSERT INTO `mall`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 2, '签到', '2', 'point_biz_type', 0, '', '', '', '1', '2023-06-10 12:15:48', '1', '2023-06-10 04:25:18', b'0');
INSERT INTO `mall`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 1, '订单创建', '1', 'point_status', 0, '', '', '', '1', '2023-06-10 12:16:42', '1', '2023-06-10 12:16:42', b'0');
INSERT INTO `mall`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 2, '冻结期', '2', 'point_status', 0, '', '', '', '1', '2023-06-10 12:16:58', '1', '2023-06-10 12:16:58', b'0');
INSERT INTO `mall`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 3, '完成', '3', 'point_status', 0, '', '', '', '1', '2023-06-10 12:17:07', '1', '2023-06-10 12:17:07', b'0');
INSERT INTO `mall`.`system_dict_data` ( `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES ( 4, '失效(订单退款)', '4', 'point_status', 0, '', '', '', '1', '2023-06-10 12:17:21', '1', '2023-06-10 12:17:21', b'0');

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-point</artifactId>
<packaging>pom</packaging>
<modules>
<module>yudao-module-point-api</module>
</modules>
</project>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-point</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-point-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.point.enums;
import cn.iocoder.yudao.framework.common.exception.ErrorCode;
/**
* Pay 错误码 Core 枚举类
*
* pay 系统使用 1-007-000-000
*/
public interface ErrorCodeConstants {
ErrorCode CONFIG_NOT_EXISTS = new ErrorCode(499, "积分设置不存在");
ErrorCode CONFIG_EXISTS = new ErrorCode(499, "积分设置已存在,只允配置一条记录");
ErrorCode SIGN_IN_CONFIG_NOT_EXISTS = new ErrorCode(499, "签到天数规则不存在");
ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(499, "签到天数规则已存在");
ErrorCode RECORD_NOT_EXISTS = new ErrorCode( 499, "用户积分记录不存在");
ErrorCode SIGN_IN_RECORD_NOT_EXISTS = new ErrorCode(499, "用户签到积分不存在");
}

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-point</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-point-biz</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-point-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig;
import org.springframework.web.bind.annotation.*;
import javax.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 javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointconfig.PointConfigDO;
import cn.iocoder.yudao.module.point.convert.pointconfig.PointConfigConvert;
import cn.iocoder.yudao.module.point.service.pointconfig.PointConfigService;
@Tag(name = "管理后台 - 积分设置")
@RestController
@RequestMapping("/point/config")
@Validated
public class PointConfigController {
@Resource
private PointConfigService configService;
@PostMapping("/create")
@Operation(summary = "创建积分设置")
@PreAuthorize("@ss.hasPermission('point:config:create')")
public CommonResult<Integer> createConfig(@Valid @RequestBody PointConfigCreateReqVO createReqVO) {
return success(configService.createConfig(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新积分设置")
@PreAuthorize("@ss.hasPermission('point:config:update')")
public CommonResult<Boolean> updateConfig(@Valid @RequestBody PointConfigUpdateReqVO updateReqVO) {
configService.updateConfig(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除积分设置")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('point:config:delete')")
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Integer id) {
configService.deleteConfig(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得积分设置")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('point:config:query')")
public CommonResult<PointConfigRespVO> getConfig(@RequestParam("id") Integer id) {
PointConfigDO config = configService.getConfig(id);
return success(PointConfigConvert.INSTANCE.convert(config));
}
@GetMapping("/list")
@Operation(summary = "获得积分设置列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('point:config:query')")
public CommonResult<List<PointConfigRespVO>> getConfigList(@RequestParam("ids") Collection<Integer> ids) {
List<PointConfigDO> list = configService.getConfigList(ids);
return success(PointConfigConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得积分设置分页")
@PreAuthorize("@ss.hasPermission('point:config:query')")
public CommonResult<PageResult<PointConfigRespVO>> getConfigPage(@Valid PointConfigPageReqVO pageVO) {
PageResult<PointConfigDO> pageResult = configService.getConfigPage(pageVO);
return success(PointConfigConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出积分设置 Excel")
@PreAuthorize("@ss.hasPermission('point:config:export')")
@OperateLog(type = EXPORT)
public void exportConfigExcel(@Valid PointConfigExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<PointConfigDO> list = configService.getConfigList(exportReqVO);
// 导出 Excel
List<PointConfigExcelVO> datas = PointConfigConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "积分设置.xls", "数据", PointConfigExcelVO.class, datas);
}
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* 积分设置 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class PointConfigBaseVO {
@Schema(description = "1 开启积分抵扣 0 关闭积分抵扣", example = "1")
private Integer tradeDeductEnable;
@Schema(description = "积分抵扣,抵扣最低为分 以0.01表示 1积分抵扣0.01元(单位:元)", example = "13506")
private BigDecimal tradeDeductUnitPrice;
@Schema(description = "积分抵扣最大值", example = "32428")
private Long tradeDeductMaxPrice;
@Schema(description = "1元赠送多少分")
private Long tradeGivePoint;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 积分设置创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointConfigCreateReqVO extends PointConfigBaseVO {
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
/**
* 积分设置 Excel VO
*
* @author QingX
*/
@Data
public class PointConfigExcelVO {
@ExcelProperty("自增主键")
private Integer id;
@ExcelProperty(value = "1 开启积分抵扣 0 关闭积分抵扣", converter = DictConvert.class)
@DictFormat("infra_boolean_string") // TODO 代码优化建议设置到对应的 XXXDictTypeConstants 枚举类中
private Integer tradeDeductEnable;
@ExcelProperty("积分抵扣,抵扣最低为分 以0.01表示 1积分抵扣0.01元(单位:元)")
private BigDecimal tradeDeductUnitPrice;
@ExcelProperty("积分抵扣最大值")
private Long tradeDeductMaxPrice;
@ExcelProperty("1元赠送多少分")
private Long tradeGivePoint;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@ExcelProperty("变更时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 积分设置 Excel 导出 Request VO参数和 PointConfigPageReqVO 是一致的")
@Data
public class PointConfigExportReqVO {
@Schema(description = "1 开启积分抵扣 0 关闭积分抵扣", example = "1")
private Integer tradeDeductEnable;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 积分设置分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointConfigPageReqVO extends PageParam {
@Schema(description = "1 开启积分抵扣 0 关闭积分抵扣", example = "1")
private Integer tradeDeductEnable;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 积分设置 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointConfigRespVO extends PointConfigBaseVO {
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20937")
private Integer id;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "变更时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 积分设置更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointConfigUpdateReqVO extends PointConfigBaseVO {
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20937")
@NotNull(message = "自增主键不能为空")
private Integer id;
}

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord;
import org.springframework.web.bind.annotation.*;
import javax.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 javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointrecord.PointRecordDO;
import cn.iocoder.yudao.module.point.convert.pointrecord.PointRecordConvert;
import cn.iocoder.yudao.module.point.service.pointrecord.PointRecordService;
@Tag(name = "管理后台 - 用户积分记录")
@RestController
@RequestMapping("/point/record")
@Validated
public class PointRecordController {
@Resource
private PointRecordService recordService;
@PostMapping("/create")
@Operation(summary = "创建用户积分记录")
@PreAuthorize("@ss.hasPermission('point:record:create')")
public CommonResult<Long> createRecord(@Valid @RequestBody PointRecordCreateReqVO createReqVO) {
return success(recordService.createRecord(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新用户积分记录")
@PreAuthorize("@ss.hasPermission('point:record:update')")
public CommonResult<Boolean> updateRecord(@Valid @RequestBody PointRecordUpdateReqVO updateReqVO) {
recordService.updateRecord(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除用户积分记录")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('point:record:delete')")
public CommonResult<Boolean> deleteRecord(@RequestParam("id") Long id) {
recordService.deleteRecord(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得用户积分记录")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('point:record:query')")
public CommonResult<PointRecordRespVO> getRecord(@RequestParam("id") Long id) {
PointRecordDO record = recordService.getRecord(id);
return success(PointRecordConvert.INSTANCE.convert(record));
}
@GetMapping("/list")
@Operation(summary = "获得用户积分记录列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('point:record:query')")
public CommonResult<List<PointRecordRespVO>> getRecordList(@RequestParam("ids") Collection<Long> ids) {
List<PointRecordDO> list = recordService.getRecordList(ids);
return success(PointRecordConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得用户积分记录分页")
@PreAuthorize("@ss.hasPermission('point:record:query')")
public CommonResult<PageResult<PointRecordRespVO>> getRecordPage(@Valid PointRecordPageReqVO pageVO) {
PageResult<PointRecordDO> pageResult = recordService.getRecordPage(pageVO);
return success(PointRecordConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出用户积分记录 Excel")
@PreAuthorize("@ss.hasPermission('point:record:export')")
@OperateLog(type = EXPORT)
public void exportRecordExcel(@Valid PointRecordExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<PointRecordDO> list = recordService.getRecordList(exportReqVO);
// 导出 Excel
List<PointRecordExcelVO> datas = PointRecordConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "用户积分记录.xls", "数据", PointRecordExcelVO.class, datas);
}
}

View File

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* 用户积分记录 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class PointRecordBaseVO {
@Schema(description = "业务编码", example = "22706")
@NotNull(message = "业务编码不能为空")
private String bizId;
@Schema(description = "业务类型", example = "1")
@NotNull(message = "业务类型不能为空")
private String bizType;
@Schema(description = "1增加 0扣减", example = "1")
@NotNull(message = "操作类型不能为空")
private String type;
@Schema(description = "积分标题")
@NotNull(message = "积分标题不能为空")
private String title;
@Schema(description = "积分描述", example = "你猜")
private String description;
@Schema(description = "积分")
@NotNull(message = "操作积分不能为空")
private Integer point;
@Schema(description = "变动后的积分", requiredMode = Schema.RequiredMode.REQUIRED)
// @NotNull(message = "变动后的积分不能为空")
private Integer totalPoint;
@Schema(description = "状态1-订单创建2-冻结期3-完成4-失效(订单退款) ", example = "1")
@NotNull(message = "积分状态不能为空")
private Integer status;
@Schema(description = "用户id", example = "31169")
@NotNull(message = "用户ID不能为空")
private Integer userId;
@Schema(description = "冻结时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@NotNull(message = "冻结时间不能为空")
private LocalDateTime freezingTime;
@Schema(description = "解冻时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@NotNull(message = "解冻时间不能为空")
private LocalDateTime thawingTime;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 用户积分记录创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointRecordCreateReqVO extends PointRecordBaseVO {
}

View File

@ -0,0 +1,65 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
/**
* 用户积分记录 Excel VO
*
* @author QingX
*/
@Data
public class PointRecordExcelVO {
@ExcelProperty("自增主键")
private Long id;
@ExcelProperty("业务编码")
private String bizId;
@ExcelProperty(value = "业务类型", converter = DictConvert.class)
@DictFormat("biz_type") // TODO 代码优化建议设置到对应的 XXXDictTypeConstants 枚举类中
private String bizType;
@ExcelProperty("1增加 0扣减")
private String type;
@ExcelProperty("积分标题")
private String title;
@ExcelProperty("积分描述")
private String description;
@ExcelProperty("积分")
private Integer point;
@ExcelProperty("变动后的积分")
private Integer totalPoint;
@ExcelProperty(value = "状态1-订单创建2-冻结期3-完成4-失效(订单退款) ", converter = DictConvert.class)
@DictFormat("point_status") // TODO 代码优化建议设置到对应的 XXXDictTypeConstants 枚举类中
private Integer status;
@ExcelProperty("用户id")
private Integer userId;
@ExcelProperty("冻结时间")
private LocalDateTime freezingTime;
@ExcelProperty("解冻时间")
private LocalDateTime thawingTime;
@ExcelProperty("发生时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 用户积分记录 Excel 导出 Request VO参数和 PointRecordPageReqVO 是一致的")
@Data
public class PointRecordExportReqVO {
@Schema(description = "业务编码", example = "22706")
private String bizId;
@Schema(description = "业务类型", example = "1")
private String bizType;
@Schema(description = "1增加 0扣减", example = "1")
private String type;
@Schema(description = "积分标题")
private String title;
@Schema(description = "状态1-订单创建2-冻结期3-完成4-失效(订单退款) ", example = "1")
private Integer status;
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 用户积分记录分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointRecordPageReqVO extends PageParam {
@Schema(description = "业务编码", example = "22706")
private String bizId;
@Schema(description = "业务类型", example = "1")
private String bizType;
@Schema(description = "1增加 0扣减", example = "1")
private String type;
@Schema(description = "积分标题")
private String title;
@Schema(description = "状态1-订单创建2-冻结期3-完成4-失效(订单退款) ", example = "1")
private Integer status;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 用户积分记录 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointRecordRespVO extends PointRecordBaseVO {
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457")
private Long id;
@Schema(description = "发生时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 用户积分记录更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PointRecordUpdateReqVO extends PointRecordBaseVO {
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31457")
@NotNull(message = "自增主键不能为空")
private Long id;
}

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig;
import org.springframework.web.bind.annotation.*;
import javax.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 javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinconfig.SignInConfigDO;
import cn.iocoder.yudao.module.point.convert.signinconfig.SignInConfigConvert;
import cn.iocoder.yudao.module.point.service.signinconfig.SignInConfigService;
@Tag(name = "管理后台 - 积分签到规则")
@RestController
@RequestMapping("/point/sign-in-config")
@Validated
public class SignInConfigController {
@Resource
private SignInConfigService signInConfigService;
@PostMapping("/create")
@Operation(summary = "创建积分签到规则")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:create')")
public CommonResult<Integer> createSignInConfig(@Valid @RequestBody SignInConfigCreateReqVO createReqVO) {
return success(signInConfigService.createSignInConfig(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新积分签到规则")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:update')")
public CommonResult<Boolean> updateSignInConfig(@Valid @RequestBody SignInConfigUpdateReqVO updateReqVO) {
signInConfigService.updateSignInConfig(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除积分签到规则")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('point:sign-in-config:delete')")
public CommonResult<Boolean> deleteSignInConfig(@RequestParam("id") Integer id) {
signInConfigService.deleteSignInConfig(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得积分签到规则")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
public CommonResult<SignInConfigRespVO> getSignInConfig(@RequestParam("id") Integer id) {
SignInConfigDO signInConfig = signInConfigService.getSignInConfig(id);
return success(SignInConfigConvert.INSTANCE.convert(signInConfig));
}
@GetMapping("/list")
@Operation(summary = "获得积分签到规则列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
public CommonResult<List<SignInConfigRespVO>> getSignInConfigList(@RequestParam("ids") Collection<Integer> ids) {
List<SignInConfigDO> list = signInConfigService.getSignInConfigList(ids);
return success(SignInConfigConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得积分签到规则分页")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:query')")
public CommonResult<PageResult<SignInConfigRespVO>> getSignInConfigPage(@Valid SignInConfigPageReqVO pageVO) {
PageResult<SignInConfigDO> pageResult = signInConfigService.getSignInConfigPage(pageVO);
return success(SignInConfigConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出积分签到规则 Excel")
@PreAuthorize("@ss.hasPermission('point:sign-in-config:export')")
@OperateLog(type = EXPORT)
public void exportSignInConfigExcel(@Valid SignInConfigExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<SignInConfigDO> list = signInConfigService.getSignInConfigList(exportReqVO);
// 导出 Excel
List<SignInConfigExcelVO> datas = SignInConfigConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "积分签到规则.xls", "数据", SignInConfigExcelVO.class, datas);
}
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* 积分签到规则 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class SignInConfigBaseVO {
@Schema(description = "签到第x天", example = "7")
private Integer day;
@Schema(description = "签到天数对应分数", example = "10")
private Integer point;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 积分签到规则创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInConfigCreateReqVO extends SignInConfigBaseVO {
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* 积分签到规则 Excel VO
*
* @author QingX
*/
@Data
public class SignInConfigExcelVO {
@ExcelProperty("签到第x天")
private Integer day;
@ExcelProperty("签到天数对应分数")
private Integer point;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 积分签到规则 Excel 导出 Request VO参数和 SignInConfigPageReqVO 是一致的")
@Data
public class SignInConfigExportReqVO {
@Schema(description = "签到第x天", example = "7")
private Integer day;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@Schema(description = "管理后台 - 积分签到规则分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInConfigPageReqVO extends PageParam {
@Schema(description = "签到第x天", example = "7")
private Integer day;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 积分签到规则 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInConfigRespVO extends SignInConfigBaseVO {
@Schema(description = "自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20937")
private Integer id;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 积分签到规则更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInConfigUpdateReqVO extends SignInConfigBaseVO {
@Schema(description = "规则自增主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "13653")
@NotNull(message = "规则自增主键不能为空")
private Integer id;
}

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord;
import org.springframework.web.bind.annotation.*;
import javax.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 javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinrecord.SignInRecordDO;
import cn.iocoder.yudao.module.point.convert.signinrecord.SignInRecordConvert;
import cn.iocoder.yudao.module.point.service.signinrecord.SignInRecordService;
@Tag(name = "管理后台 - 用户签到积分")
@RestController
@RequestMapping("/point/sign-in-record")
@Validated
public class SignInRecordController {
@Resource
private SignInRecordService signInRecordService;
@PostMapping("/create")
@Operation(summary = "创建用户签到积分")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:create')")
public CommonResult<Long> createSignInRecord(@Valid @RequestBody SignInRecordCreateReqVO createReqVO) {
return success(signInRecordService.createSignInRecord(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新用户签到积分")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:update')")
public CommonResult<Boolean> updateSignInRecord(@Valid @RequestBody SignInRecordUpdateReqVO updateReqVO) {
signInRecordService.updateSignInRecord(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除用户签到积分")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('point:sign-in-record:delete')")
public CommonResult<Boolean> deleteSignInRecord(@RequestParam("id") Long id) {
signInRecordService.deleteSignInRecord(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得用户签到积分")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
public CommonResult<SignInRecordRespVO> getSignInRecord(@RequestParam("id") Long id) {
SignInRecordDO signInRecord = signInRecordService.getSignInRecord(id);
return success(SignInRecordConvert.INSTANCE.convert(signInRecord));
}
@GetMapping("/list")
@Operation(summary = "获得用户签到积分列表")
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
public CommonResult<List<SignInRecordRespVO>> getSignInRecordList(@RequestParam("ids") Collection<Long> ids) {
List<SignInRecordDO> list = signInRecordService.getSignInRecordList(ids);
return success(SignInRecordConvert.INSTANCE.convertList(list));
}
@GetMapping("/page")
@Operation(summary = "获得用户签到积分分页")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:query')")
public CommonResult<PageResult<SignInRecordRespVO>> getSignInRecordPage(@Valid SignInRecordPageReqVO pageVO) {
PageResult<SignInRecordDO> pageResult = signInRecordService.getSignInRecordPage(pageVO);
return success(SignInRecordConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
@Operation(summary = "导出用户签到积分 Excel")
@PreAuthorize("@ss.hasPermission('point:sign-in-record:export')")
@OperateLog(type = EXPORT)
public void exportSignInRecordExcel(@Valid SignInRecordExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
List<SignInRecordDO> list = signInRecordService.getSignInRecordList(exportReqVO);
// 导出 Excel
List<SignInRecordExcelVO> datas = SignInRecordConvert.INSTANCE.convertList02(list);
ExcelUtils.write(response, "用户签到积分.xls", "数据", SignInRecordExcelVO.class, datas);
}
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import javax.validation.constraints.*;
/**
* 用户签到积分 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*/
@Data
public class SignInRecordBaseVO {
@Schema(description = "签到用户", example = "6507")
private Integer userId;
@Schema(description = "第几天签到")
private Integer day;
@Schema(description = "签到的分数")
private Integer point;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 用户签到积分创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInRecordCreateReqVO extends SignInRecordBaseVO {
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
/**
* 用户签到积分 Excel VO
*
* @author 芋道源码
*/
@Data
public class SignInRecordExcelVO {
@ExcelProperty("签到自增id")
private Long id;
@ExcelProperty("签到用户")
private Integer userId;
@ExcelProperty("第几天签到")
private Integer day;
@ExcelProperty("签到的分数")
private Integer point;
@ExcelProperty("签到时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 用户签到积分 Excel 导出 Request VO参数和 SignInRecordPageReqVO 是一致的")
@Data
public class SignInRecordExportReqVO {
@Schema(description = "签到用户", example = "6507")
private Integer userId;
@Schema(description = "第几天签到")
private Integer day;
@Schema(description = "签到时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 用户签到积分分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInRecordPageReqVO extends PageParam {
@Schema(description = "签到用户", example = "6507")
private Integer userId;
@Schema(description = "第几天签到")
private Integer day;
@Schema(description = "签到时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 用户签到积分 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInRecordRespVO extends SignInRecordBaseVO {
@Schema(description = "签到自增id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11903")
private Long id;
@Schema(description = "签到时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 用户签到积分更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SignInRecordUpdateReqVO extends SignInRecordBaseVO {
@Schema(description = "签到自增id", requiredMode = Schema.RequiredMode.REQUIRED, example = "11903")
@NotNull(message = "签到自增id不能为空")
private Long id;
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.point.convert.pointconfig;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointconfig.PointConfigDO;
/**
* 积分设置 Convert
*
* @author QingX
*/
@Mapper
public interface PointConfigConvert {
PointConfigConvert INSTANCE = Mappers.getMapper(PointConfigConvert.class);
PointConfigDO convert(PointConfigCreateReqVO bean);
PointConfigDO convert(PointConfigUpdateReqVO bean);
PointConfigRespVO convert(PointConfigDO bean);
List<PointConfigRespVO> convertList(List<PointConfigDO> list);
PageResult<PointConfigRespVO> convertPage(PageResult<PointConfigDO> page);
List<PointConfigExcelVO> convertList02(List<PointConfigDO> list);
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.point.convert.pointrecord;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointrecord.PointRecordDO;
/**
* 用户积分记录 Convert
*
* @author QingX
*/
@Mapper
public interface PointRecordConvert {
PointRecordConvert INSTANCE = Mappers.getMapper(PointRecordConvert.class);
PointRecordDO convert(PointRecordCreateReqVO bean);
PointRecordDO convert(PointRecordUpdateReqVO bean);
PointRecordRespVO convert(PointRecordDO bean);
List<PointRecordRespVO> convertList(List<PointRecordDO> list);
PageResult<PointRecordRespVO> convertPage(PageResult<PointRecordDO> page);
List<PointRecordExcelVO> convertList02(List<PointRecordDO> list);
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.point.convert.signinconfig;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinconfig.SignInConfigDO;
/**
* 积分签到规则 Convert
*
* @author QingX
*/
@Mapper
public interface SignInConfigConvert {
SignInConfigConvert INSTANCE = Mappers.getMapper(SignInConfigConvert.class);
SignInConfigDO convert(SignInConfigCreateReqVO bean);
SignInConfigDO convert(SignInConfigUpdateReqVO bean);
SignInConfigRespVO convert(SignInConfigDO bean);
List<SignInConfigRespVO> convertList(List<SignInConfigDO> list);
PageResult<SignInConfigRespVO> convertPage(PageResult<SignInConfigDO> page);
List<SignInConfigExcelVO> convertList02(List<SignInConfigDO> list);
}

View File

@ -0,0 +1,34 @@
package cn.iocoder.yudao.module.point.convert.signinrecord;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinrecord.SignInRecordDO;
/**
* 用户签到积分 Convert
*
* @author 芋道源码
*/
@Mapper
public interface SignInRecordConvert {
SignInRecordConvert INSTANCE = Mappers.getMapper(SignInRecordConvert.class);
SignInRecordDO convert(SignInRecordCreateReqVO bean);
SignInRecordDO convert(SignInRecordUpdateReqVO bean);
SignInRecordRespVO convert(SignInRecordDO bean);
List<SignInRecordRespVO> convertList(List<SignInRecordDO> list);
PageResult<SignInRecordRespVO> convertPage(PageResult<SignInRecordDO> page);
List<SignInRecordExcelVO> convertList02(List<SignInRecordDO> list);
}

View File

@ -0,0 +1,51 @@
package cn.iocoder.yudao.module.point.dal.dataobject.pointconfig;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 积分设置 DO
*
* @author QingX
*/
@TableName("member_point_config")
@KeySequence("member_point_config_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PointConfigDO extends BaseDO {
/**
* 自增主键
*/
@TableId
private Integer id;
/**
* 1 开启积分抵扣
0 关闭积分抵扣
*
* 枚举 {@link TODO infra_boolean_string 对应的类}
*/
private Integer tradeDeductEnable;
/**
* 积分抵扣抵扣最低为分 以0.01表示 1积分抵扣0.01元(单位)
*/
private BigDecimal tradeDeductUnitPrice;
/**
* 积分抵扣最大值
*/
private Long tradeDeductMaxPrice;
/**
* 1元赠送多少分
*/
private Long tradeGivePoint;
}

View File

@ -0,0 +1,82 @@
package cn.iocoder.yudao.module.point.dal.dataobject.pointrecord;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 用户积分记录 DO
*
* @author QingX
*/
@TableName("member_point_record")
@KeySequence("member_point_record_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PointRecordDO extends BaseDO {
/**
* 自增主键
*/
@TableId
private Long id;
/**
* 业务编码
*/
private String bizId;
/**
* 业务类型
*
* 枚举 {@link TODO biz_type 对应的类}
*/
private String bizType;
/**
* 1增加 0扣减
*/
private String type;
/**
* 积分标题
*/
private String title;
/**
* 积分描述
*/
private String description;
/**
* 积分
*/
private Integer point;
/**
* 变动后的积分
*/
private Integer totalPoint;
/**
* 状态1-订单创建2-冻结期3-完成4-失效订单退款
*
* 枚举 {@link TODO point_status 对应的类}
*/
private Integer status;
/**
* 用户id
*/
private Integer userId;
/**
* 冻结时间
*/
private LocalDateTime freezingTime;
/**
* 解冻时间
*/
private LocalDateTime thawingTime;
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.point.dal.dataobject.signinconfig;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 积分签到规则 DO
*
* @author QingX
*/
@TableName("member_sign_in_config")
@KeySequence("member_sign_in_config_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SignInConfigDO extends BaseDO {
/**
* 规则自增主键
*/
@TableId
private Integer id;
/**
* 签到第x天
*/
private Integer day;
/**
* 签到天数对应分数
*/
private Integer point;
}

View File

@ -0,0 +1,43 @@
package cn.iocoder.yudao.module.point.dal.dataobject.signinrecord;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 用户签到积分 DO
*
* @author 芋道源码
*/
@TableName("member_sign_in_record")
@KeySequence("member_sign_in_record_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SignInRecordDO extends BaseDO {
/**
* 签到自增id
*/
@TableId
private Long id;
/**
* 签到用户
*/
private Integer userId;
/**
* 第几天签到
*/
private Integer day;
/**
* 签到的分数
*/
private Integer point;
}

View File

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.point.dal.mysql.pointconfig;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.point.dal.dataobject.pointconfig.PointConfigDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo.*;
/**
* 积分设置 Mapper
*
* @author QingX
*/
@Mapper
public interface PointConfigMapper extends BaseMapperX<PointConfigDO> {
default PageResult<PointConfigDO> selectPage(PointConfigPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PointConfigDO>()
.eqIfPresent(PointConfigDO::getTradeDeductEnable, reqVO.getTradeDeductEnable())
.orderByDesc(PointConfigDO::getId));
}
default List<PointConfigDO> selectList(PointConfigExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<PointConfigDO>()
.eqIfPresent(PointConfigDO::getTradeDeductEnable, reqVO.getTradeDeductEnable())
.orderByDesc(PointConfigDO::getId));
}
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.point.dal.mysql.pointrecord;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.point.dal.dataobject.pointrecord.PointRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo.*;
/**
* 用户积分记录 Mapper
*
* @author QingX
*/
@Mapper
public interface PointRecordMapper extends BaseMapperX<PointRecordDO> {
default PageResult<PointRecordDO> selectPage(PointRecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PointRecordDO>()
.eqIfPresent(PointRecordDO::getBizId, reqVO.getBizId())
.eqIfPresent(PointRecordDO::getBizType, reqVO.getBizType())
.eqIfPresent(PointRecordDO::getType, reqVO.getType())
.eqIfPresent(PointRecordDO::getTitle, reqVO.getTitle())
.eqIfPresent(PointRecordDO::getStatus, reqVO.getStatus())
.orderByDesc(PointRecordDO::getId));
}
default List<PointRecordDO> selectList(PointRecordExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<PointRecordDO>()
.eqIfPresent(PointRecordDO::getBizId, reqVO.getBizId())
.eqIfPresent(PointRecordDO::getBizType, reqVO.getBizType())
.eqIfPresent(PointRecordDO::getType, reqVO.getType())
.eqIfPresent(PointRecordDO::getTitle, reqVO.getTitle())
.eqIfPresent(PointRecordDO::getStatus, reqVO.getStatus())
.orderByDesc(PointRecordDO::getId));
}
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.point.dal.mysql.signinconfig;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.point.dal.dataobject.signinconfig.SignInConfigDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo.*;
/**
* 积分签到规则 Mapper
*
* @author QingX
*/
@Mapper
public interface SignInConfigMapper extends BaseMapperX<SignInConfigDO> {
default PageResult<SignInConfigDO> selectPage(SignInConfigPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<SignInConfigDO>()
.eqIfPresent(SignInConfigDO::getDay, reqVO.getDay())
.orderByAsc(SignInConfigDO::getDay));
}
default List<SignInConfigDO> selectList(SignInConfigExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SignInConfigDO>()
.eqIfPresent(SignInConfigDO::getDay, reqVO.getDay())
.orderByDesc(SignInConfigDO::getId));
}
//
default long selectSameDayNotSelf(SignInConfigUpdateReqVO reqVO){
return selectCount(new LambdaQueryWrapperX <SignInConfigDO>()
.ne(SignInConfigDO::getId, reqVO.getId())
.eq(SignInConfigDO::getDay,reqVO.getDay())
);
}
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.point.dal.mysql.signinrecord;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.point.dal.dataobject.signinrecord.SignInRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo.*;
/**
* 用户签到积分 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface SignInRecordMapper extends BaseMapperX<SignInRecordDO> {
default PageResult<SignInRecordDO> selectPage(SignInRecordPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<SignInRecordDO>()
.eqIfPresent(SignInRecordDO::getUserId, reqVO.getUserId())
.eqIfPresent(SignInRecordDO::getDay, reqVO.getDay())
.betweenIfPresent(SignInRecordDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(SignInRecordDO::getId));
}
default List<SignInRecordDO> selectList(SignInRecordExportReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<SignInRecordDO>()
.eqIfPresent(SignInRecordDO::getUserId, reqVO.getUserId())
.eqIfPresent(SignInRecordDO::getDay, reqVO.getDay())
.betweenIfPresent(SignInRecordDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(SignInRecordDO::getId));
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.point.service.pointconfig;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointconfig.PointConfigDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 积分设置 Service 接口
*
* @author QingX
*/
public interface PointConfigService {
/**
* 创建积分设置
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createConfig(@Valid PointConfigCreateReqVO createReqVO);
/**
* 更新积分设置
*
* @param updateReqVO 更新信息
*/
void updateConfig(@Valid PointConfigUpdateReqVO updateReqVO);
/**
* 删除积分设置
*
* @param id 编号
*/
void deleteConfig(Integer id);
/**
* 获得积分设置
*
* @param id 编号
* @return 积分设置
*/
PointConfigDO getConfig(Integer id);
/**
* 获得积分设置列表
*
* @param ids 编号
* @return 积分设置列表
*/
List<PointConfigDO> getConfigList(Collection<Integer> ids);
/**
* 获得积分设置分页
*
* @param pageReqVO 分页查询
* @return 积分设置分页
*/
PageResult<PointConfigDO> getConfigPage(PointConfigPageReqVO pageReqVO);
/**
* 获得积分设置列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 积分设置列表
*/
List<PointConfigDO> getConfigList(PointConfigExportReqVO exportReqVO);
}

View File

@ -0,0 +1,92 @@
package cn.iocoder.yudao.module.point.service.pointconfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointconfig.PointConfigDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.point.convert.pointconfig.PointConfigConvert;
import cn.iocoder.yudao.module.point.dal.mysql.pointconfig.PointConfigMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
/**
* 积分设置 Service 实现类
*
* @author QingX
*/
@Service
@Validated
public class PointConfigServiceImpl implements PointConfigService {
@Autowired
private PointConfigMapper configMapper;
@Override
public Integer createConfig(PointConfigCreateReqVO createReqVO) {
// 插入
PointConfigDO config = PointConfigConvert.INSTANCE.convert(createReqVO);
//每个租户只允许存在一条记录
validateConfigExistsOne();
configMapper.insert(config);
// 返回
return config.getId();
}
@Override
public void updateConfig(PointConfigUpdateReqVO updateReqVO) {
// 校验存在
validateConfigExists(updateReqVO.getId());
// 更新
PointConfigDO updateObj = PointConfigConvert.INSTANCE.convert(updateReqVO);
configMapper.updateById(updateObj);
}
@Override
public void deleteConfig(Integer id) {
// 校验存在
validateConfigExists(id);
// 删除
configMapper.deleteById(id);
}
private void validateConfigExists(Integer id) {
if (configMapper.selectById(id) == null) {
throw exception(CONFIG_NOT_EXISTS);
}
}
private void validateConfigExistsOne() {
if (configMapper.selectCount() > 0) {
throw exception(CONFIG_EXISTS);
}
}
@Override
public PointConfigDO getConfig(Integer id) {
return configMapper.selectById(id);
}
@Override
public List<PointConfigDO> getConfigList(Collection<Integer> ids) {
return configMapper.selectBatchIds(ids);
}
@Override
public PageResult<PointConfigDO> getConfigPage(PointConfigPageReqVO pageReqVO) {
return configMapper.selectPage(pageReqVO);
}
@Override
public List<PointConfigDO> getConfigList(PointConfigExportReqVO exportReqVO) {
return configMapper.selectList(exportReqVO);
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.point.service.pointrecord;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointrecord.PointRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 用户积分记录 Service 接口
*
* @author QingX
*/
public interface PointRecordService {
/**
* 创建用户积分记录
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createRecord(@Valid PointRecordCreateReqVO createReqVO);
/**
* 更新用户积分记录
*
* @param updateReqVO 更新信息
*/
void updateRecord(@Valid PointRecordUpdateReqVO updateReqVO);
/**
* 删除用户积分记录
*
* @param id 编号
*/
void deleteRecord(Long id);
/**
* 获得用户积分记录
*
* @param id 编号
* @return 用户积分记录
*/
PointRecordDO getRecord(Long id);
/**
* 获得用户积分记录列表
*
* @param ids 编号
* @return 用户积分记录列表
*/
List<PointRecordDO> getRecordList(Collection<Long> ids);
/**
* 获得用户积分记录分页
*
* @param pageReqVO 分页查询
* @return 用户积分记录分页
*/
PageResult<PointRecordDO> getRecordPage(PointRecordPageReqVO pageReqVO);
/**
* 获得用户积分记录列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 用户积分记录列表
*/
List<PointRecordDO> getRecordList(PointRecordExportReqVO exportReqVO);
}

View File

@ -0,0 +1,82 @@
package cn.iocoder.yudao.module.point.service.pointrecord;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointrecord.PointRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.point.convert.pointrecord.PointRecordConvert;
import cn.iocoder.yudao.module.point.dal.mysql.pointrecord.PointRecordMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
/**
* 用户积分记录 Service 实现类
*
* @author QingX
*/
@Service
@Validated
public class PointRecordServiceImpl implements PointRecordService {
@Resource
private PointRecordMapper recordMapper;
@Override
public Long createRecord(PointRecordCreateReqVO createReqVO) {
// 插入
PointRecordDO record = PointRecordConvert.INSTANCE.convert(createReqVO);
recordMapper.insert(record);
// 返回
return record.getId();
}
@Override
public void updateRecord(PointRecordUpdateReqVO updateReqVO) {
// 校验存在
validateRecordExists(updateReqVO.getId());
// 更新
PointRecordDO updateObj = PointRecordConvert.INSTANCE.convert(updateReqVO);
recordMapper.updateById(updateObj);
}
@Override
public void deleteRecord(Long id) {
// 校验存在
validateRecordExists(id);
// 删除
recordMapper.deleteById(id);
}
private void validateRecordExists(Long id) {
if (recordMapper.selectById(id) == null) {
throw exception(RECORD_NOT_EXISTS);
}
}
@Override
public PointRecordDO getRecord(Long id) {
return recordMapper.selectById(id);
}
@Override
public List<PointRecordDO> getRecordList(Collection<Long> ids) {
return recordMapper.selectBatchIds(ids);
}
@Override
public PageResult<PointRecordDO> getRecordPage(PointRecordPageReqVO pageReqVO) {
return recordMapper.selectPage(pageReqVO);
}
@Override
public List<PointRecordDO> getRecordList(PointRecordExportReqVO exportReqVO) {
return recordMapper.selectList(exportReqVO);
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.point.service.signinconfig;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinconfig.SignInConfigDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 积分签到规则 Service 接口
*
* @author QingX
*/
public interface SignInConfigService {
/**
* 创建积分签到规则
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createSignInConfig(@Valid SignInConfigCreateReqVO createReqVO);
/**
* 更新积分签到规则
*
* @param updateReqVO 更新信息
*/
void updateSignInConfig(@Valid SignInConfigUpdateReqVO updateReqVO);
/**
* 删除积分签到规则
*
* @param id 编号
*/
void deleteSignInConfig(Integer id);
/**
* 获得积分签到规则
*
* @param id 编号
* @return 积分签到规则
*/
SignInConfigDO getSignInConfig(Integer id);
/**
* 获得积分签到规则列表
*
* @param ids 编号
* @return 积分签到规则列表
*/
List<SignInConfigDO> getSignInConfigList(Collection<Integer> ids);
/**
* 获得积分签到规则分页
*
* @param pageReqVO 分页查询
* @return 积分签到规则分页
*/
PageResult<SignInConfigDO> getSignInConfigPage(SignInConfigPageReqVO pageReqVO);
/**
* 获得积分签到规则列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 积分签到规则列表
*/
List<SignInConfigDO> getSignInConfigList(SignInConfigExportReqVO exportReqVO);
}

View File

@ -0,0 +1,102 @@
package cn.iocoder.yudao.module.point.service.signinconfig;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinconfig.SignInConfigDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.point.convert.signinconfig.SignInConfigConvert;
import cn.iocoder.yudao.module.point.dal.mysql.signinconfig.SignInConfigMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
/**
* 积分签到规则 Service 实现类
*
* @author QingX
*/
@Service
@Validated
public class SignInConfigServiceImpl implements SignInConfigService {
@Resource
private SignInConfigMapper signInConfigMapper;
@Override
public Integer createSignInConfig(SignInConfigCreateReqVO createReqVO) {
// 插入
SignInConfigDO signInConfig = SignInConfigConvert.INSTANCE.convert(createReqVO);
//判断是否重复插入签到天数
validateSignInConfigExistsDay(signInConfig.getDay());
signInConfigMapper.insert(signInConfig);
// 返回
return signInConfig.getId();
}
@Override
public void updateSignInConfig(SignInConfigUpdateReqVO updateReqVO) {
// 校验存在
validateSignInConfigExists(updateReqVO.getId());
//判断是否重复插入签到天数
validateSignInConfigSameDayNotSelf(updateReqVO);
// 判断更新的
SignInConfigDO updateObj = SignInConfigConvert.INSTANCE.convert(updateReqVO);
signInConfigMapper.updateById(updateObj);
}
@Override
public void deleteSignInConfig(Integer id) {
// 校验存在
validateSignInConfigExists(id);
// 删除
signInConfigMapper.deleteById(id);
}
private void validateSignInConfigExists(Integer id) {
if (signInConfigMapper.selectById(id) == null) {
throw exception(SIGN_IN_CONFIG_NOT_EXISTS);
}
}
//根据签到天数判断是否存在一个相同的天数
private void validateSignInConfigExistsDay(Integer day) {
if (signInConfigMapper.selectCount(SignInConfigDO::getDay,day)>0) {
throw exception(SIGN_IN_CONFIG_EXISTS);
}
}
//更新天数时判断是否有重复的天数需要去除自己
private void validateSignInConfigSameDayNotSelf(SignInConfigUpdateReqVO reqVO) {
if (signInConfigMapper.selectSameDayNotSelf(reqVO)>0) {
throw exception(SIGN_IN_CONFIG_EXISTS);
}
}
@Override
public SignInConfigDO getSignInConfig(Integer id) {
return signInConfigMapper.selectById(id);
}
@Override
public List<SignInConfigDO> getSignInConfigList(Collection<Integer> ids) {
return signInConfigMapper.selectBatchIds(ids);
}
@Override
public PageResult<SignInConfigDO> getSignInConfigPage(SignInConfigPageReqVO pageReqVO) {
return signInConfigMapper.selectPage(pageReqVO);
}
@Override
public List<SignInConfigDO> getSignInConfigList(SignInConfigExportReqVO exportReqVO) {
return signInConfigMapper.selectList(exportReqVO);
}
}

View File

@ -0,0 +1,70 @@
package cn.iocoder.yudao.module.point.service.signinrecord;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinrecord.SignInRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
/**
* 用户签到积分 Service 接口
*
* @author 芋道源码
*/
public interface SignInRecordService {
/**
* 创建用户签到积分
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createSignInRecord(@Valid SignInRecordCreateReqVO createReqVO);
/**
* 更新用户签到积分
*
* @param updateReqVO 更新信息
*/
void updateSignInRecord(@Valid SignInRecordUpdateReqVO updateReqVO);
/**
* 删除用户签到积分
*
* @param id 编号
*/
void deleteSignInRecord(Long id);
/**
* 获得用户签到积分
*
* @param id 编号
* @return 用户签到积分
*/
SignInRecordDO getSignInRecord(Long id);
/**
* 获得用户签到积分列表
*
* @param ids 编号
* @return 用户签到积分列表
*/
List<SignInRecordDO> getSignInRecordList(Collection<Long> ids);
/**
* 获得用户签到积分分页
*
* @param pageReqVO 分页查询
* @return 用户签到积分分页
*/
PageResult<SignInRecordDO> getSignInRecordPage(SignInRecordPageReqVO pageReqVO);
/**
* 获得用户签到积分列表, 用于 Excel 导出
*
* @param exportReqVO 查询条件
* @return 用户签到积分列表
*/
List<SignInRecordDO> getSignInRecordList(SignInRecordExportReqVO exportReqVO);
}

View File

@ -0,0 +1,82 @@
package cn.iocoder.yudao.module.point.service.signinrecord;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.*;
import cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinrecord.SignInRecordDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.point.convert.signinrecord.SignInRecordConvert;
import cn.iocoder.yudao.module.point.dal.mysql.signinrecord.SignInRecordMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
/**
* 用户签到积分 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class SignInRecordServiceImpl implements SignInRecordService {
@Resource
private SignInRecordMapper signInRecordMapper;
@Override
public Long createSignInRecord(SignInRecordCreateReqVO createReqVO) {
// 插入
SignInRecordDO signInRecord = SignInRecordConvert.INSTANCE.convert(createReqVO);
signInRecordMapper.insert(signInRecord);
// 返回
return signInRecord.getId();
}
@Override
public void updateSignInRecord(SignInRecordUpdateReqVO updateReqVO) {
// 校验存在
validateSignInRecordExists(updateReqVO.getId());
// 更新
SignInRecordDO updateObj = SignInRecordConvert.INSTANCE.convert(updateReqVO);
signInRecordMapper.updateById(updateObj);
}
@Override
public void deleteSignInRecord(Long id) {
// 校验存在
validateSignInRecordExists(id);
// 删除
signInRecordMapper.deleteById(id);
}
private void validateSignInRecordExists(Long id) {
if (signInRecordMapper.selectById(id) == null) {
throw exception(SIGN_IN_RECORD_NOT_EXISTS);
}
}
@Override
public SignInRecordDO getSignInRecord(Long id) {
return signInRecordMapper.selectById(id);
}
@Override
public List<SignInRecordDO> getSignInRecordList(Collection<Long> ids) {
return signInRecordMapper.selectBatchIds(ids);
}
@Override
public PageResult<SignInRecordDO> getSignInRecordPage(SignInRecordPageReqVO pageReqVO) {
return signInRecordMapper.selectPage(pageReqVO);
}
@Override
public List<SignInRecordDO> getSignInRecordList(SignInRecordExportReqVO exportReqVO) {
return signInRecordMapper.selectList(exportReqVO);
}
}

View File

@ -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="cn.iocoder.yudao.module.point.dal.mysql.pointconfig.PointConfigMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -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="cn.iocoder.yudao.module.point.dal.mysql.pointrecord.PointRecordMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -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="cn.iocoder.yudao.module.point.dal.mysql.signinconfig.SignInConfigMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -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="cn.iocoder.yudao.module.point.dal.mysql.signinrecord.SignInRecordMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@ -0,0 +1,152 @@
package cn.iocoder.yudao.module.point.service.pointconfig;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.point.controller.admin.pointconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointconfig.PointConfigDO;
import cn.iocoder.yudao.module.point.dal.mysql.pointconfig.PointConfigMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link PointConfigServiceImpl} 的单元测试类
*
* @author QingX
*/
@Import(PointConfigServiceImpl.class)
public class PointConfigServiceImplTest extends BaseDbUnitTest {
@Resource
private PointConfigServiceImpl configService;
@Resource
private PointConfigMapper configMapper;
@Test
public void testCreateConfig_success() {
// 准备参数
PointConfigCreateReqVO reqVO = randomPojo(PointConfigCreateReqVO.class);
// 调用
Integer configId = configService.createConfig(reqVO);
// 断言
assertNotNull(configId);
// 校验记录的属性是否正确
PointConfigDO config = configMapper.selectById(configId);
assertPojoEquals(reqVO, config);
}
@Test
public void testUpdateConfig_success() {
// mock 数据
PointConfigDO dbConfig = randomPojo(PointConfigDO.class);
configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据
// 准备参数
PointConfigUpdateReqVO reqVO = randomPojo(PointConfigUpdateReqVO.class, o -> {
o.setId(dbConfig.getId()); // 设置更新的 ID
});
// 调用
configService.updateConfig(reqVO);
// 校验是否更新正确
PointConfigDO config = configMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, config);
}
@Test
public void testUpdateConfig_notExists() {
// 准备参数
PointConfigUpdateReqVO reqVO = randomPojo(PointConfigUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> configService.updateConfig(reqVO), CONFIG_NOT_EXISTS);
}
@Test
public void testDeleteConfig_success() {
// mock 数据
PointConfigDO dbConfig = randomPojo(PointConfigDO.class);
configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据
// 准备参数
Integer id = dbConfig.getId();
// 调用
configService.deleteConfig(id);
// 校验数据不存在了
assertNull(configMapper.selectById(id));
}
@Test
public void testDeleteConfig_notExists() {
// 准备参数
Integer id = RandomUtils.randomInteger();
// 调用, 并断言异常
assertServiceException(() -> configService.deleteConfig(id), CONFIG_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetConfigPage() {
// mock 数据
PointConfigDO dbConfig = randomPojo(PointConfigDO.class, o -> { // 等会查询到
o.setTradeDeductEnable(null);
});
configMapper.insert(dbConfig);
// 测试 tradeDeductEnable 不匹配
configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setTradeDeductEnable(null)));
// 准备参数
PointConfigPageReqVO reqVO = new PointConfigPageReqVO();
reqVO.setTradeDeductEnable(null);
// 调用
PageResult<PointConfigDO> pageResult = configService.getConfigPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbConfig, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetConfigList() {
// mock 数据
PointConfigDO dbConfig = randomPojo(PointConfigDO.class, o -> { // 等会查询到
o.setTradeDeductEnable(null);
});
configMapper.insert(dbConfig);
// 测试 tradeDeductEnable 不匹配
configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setTradeDeductEnable(null)));
// 准备参数
PointConfigExportReqVO reqVO = new PointConfigExportReqVO();
reqVO.setTradeDeductEnable(null);
// 调用
List<PointConfigDO> list = configService.getConfigList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbConfig, list.get(0));
}
}

View File

@ -0,0 +1,183 @@
package cn.iocoder.yudao.module.point.service.pointrecord;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.point.controller.admin.pointrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.pointrecord.PointRecordDO;
import cn.iocoder.yudao.module.point.dal.mysql.pointrecord.PointRecordMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link PointRecordServiceImpl} 的单元测试类
*
* @author QingX
*/
@Import(PointRecordServiceImpl.class)
public class PointRecordServiceImplTest extends BaseDbUnitTest {
@Resource
private PointRecordServiceImpl recordService;
@Resource
private PointRecordMapper recordMapper;
@Test
public void testCreateRecord_success() {
// 准备参数
PointRecordCreateReqVO reqVO = randomPojo(PointRecordCreateReqVO.class);
// 调用
Long recordId = recordService.createRecord(reqVO);
// 断言
assertNotNull(recordId);
// 校验记录的属性是否正确
PointRecordDO record = recordMapper.selectById(recordId);
assertPojoEquals(reqVO, record);
}
@Test
public void testUpdateRecord_success() {
// mock 数据
PointRecordDO dbRecord = randomPojo(PointRecordDO.class);
recordMapper.insert(dbRecord);// @Sql: 先插入出一条存在的数据
// 准备参数
PointRecordUpdateReqVO reqVO = randomPojo(PointRecordUpdateReqVO.class, o -> {
o.setId(dbRecord.getId()); // 设置更新的 ID
});
// 调用
recordService.updateRecord(reqVO);
// 校验是否更新正确
PointRecordDO record = recordMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, record);
}
@Test
public void testUpdateRecord_notExists() {
// 准备参数
PointRecordUpdateReqVO reqVO = randomPojo(PointRecordUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> recordService.updateRecord(reqVO), RECORD_NOT_EXISTS);
}
@Test
public void testDeleteRecord_success() {
// mock 数据
PointRecordDO dbRecord = randomPojo(PointRecordDO.class);
recordMapper.insert(dbRecord);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbRecord.getId();
// 调用
recordService.deleteRecord(id);
// 校验数据不存在了
assertNull(recordMapper.selectById(id));
}
@Test
public void testDeleteRecord_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> recordService.deleteRecord(id), RECORD_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetRecordPage() {
// mock 数据
PointRecordDO dbRecord = randomPojo(PointRecordDO.class, o -> { // 等会查询到
o.setBizId(null);
o.setBizType(null);
o.setType(null);
o.setTitle(null);
o.setStatus(null);
});
recordMapper.insert(dbRecord);
// 测试 bizId 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setBizId(null)));
// 测试 bizType 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setBizType(null)));
// 测试 type 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setType(null)));
// 测试 title 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setTitle(null)));
// 测试 status 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setStatus(null)));
// 准备参数
PointRecordPageReqVO reqVO = new PointRecordPageReqVO();
reqVO.setBizId(null);
reqVO.setBizType(null);
reqVO.setType(null);
reqVO.setTitle(null);
reqVO.setStatus(null);
// 调用
PageResult<PointRecordDO> pageResult = recordService.getRecordPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbRecord, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetRecordList() {
// mock 数据
PointRecordDO dbRecord = randomPojo(PointRecordDO.class, o -> { // 等会查询到
o.setBizId(null);
o.setBizType(null);
o.setType(null);
o.setTitle(null);
o.setStatus(null);
});
recordMapper.insert(dbRecord);
// 测试 bizId 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setBizId(null)));
// 测试 bizType 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setBizType(null)));
// 测试 type 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setType(null)));
// 测试 title 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setTitle(null)));
// 测试 status 不匹配
recordMapper.insert(cloneIgnoreId(dbRecord, o -> o.setStatus(null)));
// 准备参数
PointRecordExportReqVO reqVO = new PointRecordExportReqVO();
reqVO.setBizId(null);
reqVO.setBizType(null);
reqVO.setType(null);
reqVO.setTitle(null);
reqVO.setStatus(null);
// 调用
List<PointRecordDO> list = recordService.getRecordList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbRecord, list.get(0));
}
}

View File

@ -0,0 +1,152 @@
package cn.iocoder.yudao.module.point.service.signinconfig;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.point.controller.admin.signinconfig.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinconfig.SignInConfigDO;
import cn.iocoder.yudao.module.point.dal.mysql.signinconfig.SignInConfigMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link SignInConfigServiceImpl} 的单元测试类
*
* @author QingX
*/
@Import(SignInConfigServiceImpl.class)
public class SignInConfigServiceImplTest extends BaseDbUnitTest {
@Resource
private SignInConfigServiceImpl signInConfigService;
@Resource
private SignInConfigMapper signInConfigMapper;
@Test
public void testCreateSignInConfig_success() {
// 准备参数
SignInConfigCreateReqVO reqVO = randomPojo(SignInConfigCreateReqVO.class);
// 调用
Integer signInConfigId = signInConfigService.createSignInConfig(reqVO);
// 断言
assertNotNull(signInConfigId);
// 校验记录的属性是否正确
SignInConfigDO signInConfig = signInConfigMapper.selectById(signInConfigId);
assertPojoEquals(reqVO, signInConfig);
}
@Test
public void testUpdateSignInConfig_success() {
// mock 数据
SignInConfigDO dbSignInConfig = randomPojo(SignInConfigDO.class);
signInConfigMapper.insert(dbSignInConfig);// @Sql: 先插入出一条存在的数据
// 准备参数
SignInConfigUpdateReqVO reqVO = randomPojo(SignInConfigUpdateReqVO.class, o -> {
o.setId(dbSignInConfig.getId()); // 设置更新的 ID
});
// 调用
signInConfigService.updateSignInConfig(reqVO);
// 校验是否更新正确
SignInConfigDO signInConfig = signInConfigMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, signInConfig);
}
@Test
public void testUpdateSignInConfig_notExists() {
// 准备参数
SignInConfigUpdateReqVO reqVO = randomPojo(SignInConfigUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> signInConfigService.updateSignInConfig(reqVO), SIGN_IN_CONFIG_NOT_EXISTS);
}
@Test
public void testDeleteSignInConfig_success() {
// mock 数据
SignInConfigDO dbSignInConfig = randomPojo(SignInConfigDO.class);
signInConfigMapper.insert(dbSignInConfig);// @Sql: 先插入出一条存在的数据
// 准备参数
Integer id = dbSignInConfig.getId();
// 调用
signInConfigService.deleteSignInConfig(id);
// 校验数据不存在了
assertNull(signInConfigMapper.selectById(id));
}
@Test
public void testDeleteSignInConfig_notExists() {
// 准备参数
Integer id = RandomUtils.randomInteger();
// 调用, 并断言异常
assertServiceException(() -> signInConfigService.deleteSignInConfig(id), SIGN_IN_CONFIG_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetSignInConfigPage() {
// mock 数据
SignInConfigDO dbSignInConfig = randomPojo(SignInConfigDO.class, o -> { // 等会查询到
o.setDay(null);
});
signInConfigMapper.insert(dbSignInConfig);
// 测试 day 不匹配
signInConfigMapper.insert(cloneIgnoreId(dbSignInConfig, o -> o.setDay(null)));
// 准备参数
SignInConfigPageReqVO reqVO = new SignInConfigPageReqVO();
reqVO.setDay(null);
// 调用
PageResult<SignInConfigDO> pageResult = signInConfigService.getSignInConfigPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbSignInConfig, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetSignInConfigList() {
// mock 数据
SignInConfigDO dbSignInConfig = randomPojo(SignInConfigDO.class, o -> { // 等会查询到
o.setDay(null);
});
signInConfigMapper.insert(dbSignInConfig);
// 测试 day 不匹配
signInConfigMapper.insert(cloneIgnoreId(dbSignInConfig, o -> o.setDay(null)));
// 准备参数
SignInConfigExportReqVO reqVO = new SignInConfigExportReqVO();
reqVO.setDay(null);
// 调用
List<SignInConfigDO> list = signInConfigService.getSignInConfigList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbSignInConfig, list.get(0));
}
}

View File

@ -0,0 +1,167 @@
package cn.iocoder.yudao.module.point.service.signinrecord;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import javax.annotation.Resource;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.point.controller.admin.signinrecord.vo.*;
import cn.iocoder.yudao.module.point.dal.dataobject.signinrecord.SignInRecordDO;
import cn.iocoder.yudao.module.point.dal.mysql.signinrecord.SignInRecordMapper;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import javax.annotation.Resource;
import org.springframework.context.annotation.Import;
import java.util.*;
import java.time.LocalDateTime;
import static cn.hutool.core.util.RandomUtil.*;
import static cn.iocoder.yudao.module.point.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
/**
* {@link SignInRecordServiceImpl} 的单元测试类
*
* @author 芋道源码
*/
@Import(SignInRecordServiceImpl.class)
public class SignInRecordServiceImplTest extends BaseDbUnitTest {
@Resource
private SignInRecordServiceImpl signInRecordService;
@Resource
private SignInRecordMapper signInRecordMapper;
@Test
public void testCreateSignInRecord_success() {
// 准备参数
SignInRecordCreateReqVO reqVO = randomPojo(SignInRecordCreateReqVO.class);
// 调用
Long signInRecordId = signInRecordService.createSignInRecord(reqVO);
// 断言
assertNotNull(signInRecordId);
// 校验记录的属性是否正确
SignInRecordDO signInRecord = signInRecordMapper.selectById(signInRecordId);
assertPojoEquals(reqVO, signInRecord);
}
@Test
public void testUpdateSignInRecord_success() {
// mock 数据
SignInRecordDO dbSignInRecord = randomPojo(SignInRecordDO.class);
signInRecordMapper.insert(dbSignInRecord);// @Sql: 先插入出一条存在的数据
// 准备参数
SignInRecordUpdateReqVO reqVO = randomPojo(SignInRecordUpdateReqVO.class, o -> {
o.setId(dbSignInRecord.getId()); // 设置更新的 ID
});
// 调用
signInRecordService.updateSignInRecord(reqVO);
// 校验是否更新正确
SignInRecordDO signInRecord = signInRecordMapper.selectById(reqVO.getId()); // 获取最新的
assertPojoEquals(reqVO, signInRecord);
}
@Test
public void testUpdateSignInRecord_notExists() {
// 准备参数
SignInRecordUpdateReqVO reqVO = randomPojo(SignInRecordUpdateReqVO.class);
// 调用, 并断言异常
assertServiceException(() -> signInRecordService.updateSignInRecord(reqVO), SIGN_IN_RECORD_NOT_EXISTS);
}
@Test
public void testDeleteSignInRecord_success() {
// mock 数据
SignInRecordDO dbSignInRecord = randomPojo(SignInRecordDO.class);
signInRecordMapper.insert(dbSignInRecord);// @Sql: 先插入出一条存在的数据
// 准备参数
Long id = dbSignInRecord.getId();
// 调用
signInRecordService.deleteSignInRecord(id);
// 校验数据不存在了
assertNull(signInRecordMapper.selectById(id));
}
@Test
public void testDeleteSignInRecord_notExists() {
// 准备参数
Long id = randomLongId();
// 调用, 并断言异常
assertServiceException(() -> signInRecordService.deleteSignInRecord(id), SIGN_IN_RECORD_NOT_EXISTS);
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetSignInRecordPage() {
// mock 数据
SignInRecordDO dbSignInRecord = randomPojo(SignInRecordDO.class, o -> { // 等会查询到
o.setUserId(null);
o.setDay(null);
o.setCreateTime(null);
});
signInRecordMapper.insert(dbSignInRecord);
// 测试 userId 不匹配
signInRecordMapper.insert(cloneIgnoreId(dbSignInRecord, o -> o.setUserId(null)));
// 测试 day 不匹配
signInRecordMapper.insert(cloneIgnoreId(dbSignInRecord, o -> o.setDay(null)));
// 测试 createTime 不匹配
signInRecordMapper.insert(cloneIgnoreId(dbSignInRecord, o -> o.setCreateTime(null)));
// 准备参数
SignInRecordPageReqVO reqVO = new SignInRecordPageReqVO();
reqVO.setUserId(null);
reqVO.setDay(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
PageResult<SignInRecordDO> pageResult = signInRecordService.getSignInRecordPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbSignInRecord, pageResult.getList().get(0));
}
@Test
@Disabled // TODO 请修改 null 为需要的值然后删除 @Disabled 注解
public void testGetSignInRecordList() {
// mock 数据
SignInRecordDO dbSignInRecord = randomPojo(SignInRecordDO.class, o -> { // 等会查询到
o.setUserId(null);
o.setDay(null);
o.setCreateTime(null);
});
signInRecordMapper.insert(dbSignInRecord);
// 测试 userId 不匹配
signInRecordMapper.insert(cloneIgnoreId(dbSignInRecord, o -> o.setUserId(null)));
// 测试 day 不匹配
signInRecordMapper.insert(cloneIgnoreId(dbSignInRecord, o -> o.setDay(null)));
// 测试 createTime 不匹配
signInRecordMapper.insert(cloneIgnoreId(dbSignInRecord, o -> o.setCreateTime(null)));
// 准备参数
SignInRecordExportReqVO reqVO = new SignInRecordExportReqVO();
reqVO.setUserId(null);
reqVO.setDay(null);
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
// 调用
List<SignInRecordDO> list = signInRecordService.getSignInRecordList(reqVO);
// 断言
assertEquals(1, list.size());
assertPojoEquals(dbSignInRecord, list.get(0));
}
}

View File

@ -54,11 +54,11 @@
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<!-- 支付服务 -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-pay-biz</artifactId>
<version>${revision}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-pay-biz</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<!-- 微信公众号模块。默认注释,保证编译速度 -->
<!-- <dependency>-->
@ -68,19 +68,25 @@
<!-- </dependency>-->
<!-- 商城相关模块。默认注释,保证编译速度 -->
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-promotion-biz</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-product-biz</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-trade-biz</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-promotion-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-product-biz</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-trade-biz</artifactId>
<artifactId>yudao-module-point-biz</artifactId>
<version>${revision}</version>
</dependency>