diff --git a/sql/mysql/menu.sql b/sql/mysql/menu.sql new file mode 100644 index 000000000..704979b78 --- /dev/null +++ b/sql/mysql/menu.sql @@ -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。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @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。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @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。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @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。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @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 +); + + diff --git a/sql/mysql/point.sql b/sql/mysql/point.sql new file mode 100644 index 000000000..dfa625940 --- /dev/null +++ b/sql/mysql/point.sql @@ -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'); diff --git a/yudao-module-point/pom.xml b/yudao-module-point/pom.xml new file mode 100644 index 000000000..f0361dd60 --- /dev/null +++ b/yudao-module-point/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + cn.iocoder.boot + yudao + ${revision} + + + yudao-module-point + pom + + yudao-module-point-api + + + + \ No newline at end of file diff --git a/yudao-module-point/yudao-module-point-api/pom.xml b/yudao-module-point/yudao-module-point-api/pom.xml new file mode 100644 index 000000000..83898557f --- /dev/null +++ b/yudao-module-point/yudao-module-point-api/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + cn.iocoder.boot + yudao-module-point + ${revision} + + + yudao-module-point-api + jar + + + + cn.iocoder.boot + yudao-common + + + + + org.springframework.boot + spring-boot-starter-validation + true + + + \ No newline at end of file diff --git a/yudao-module-point/yudao-module-point-api/src/main/java/cn/iocoder/yudao/module/point/enums/ErrorCodeConstants.java b/yudao-module-point/yudao-module-point-api/src/main/java/cn/iocoder/yudao/module/point/enums/ErrorCodeConstants.java new file mode 100644 index 000000000..8d4daf0fc --- /dev/null +++ b/yudao-module-point/yudao-module-point-api/src/main/java/cn/iocoder/yudao/module/point/enums/ErrorCodeConstants.java @@ -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, "用户签到积分不存在"); + + + +} diff --git a/yudao-module-point/yudao-module-point-biz/pom.xml b/yudao-module-point/yudao-module-point-biz/pom.xml new file mode 100644 index 000000000..fc4561441 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/pom.xml @@ -0,0 +1,57 @@ + + + 4.0.0 + + cn.iocoder.boot + yudao-module-point + ${revision} + + + yudao-module-point-biz + jar + + + + cn.iocoder.boot + yudao-module-point-api + ${revision} + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-operatelog + + + + + cn.iocoder.boot + yudao-spring-boot-starter-web + + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + + + cn.iocoder.boot + yudao-spring-boot-starter-test + + + + + cn.iocoder.boot + yudao-spring-boot-starter-excel + + + \ No newline at end of file diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/PointConfigController.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/PointConfigController.java new file mode 100644 index 000000000..137d03050 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/PointConfigController.java @@ -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 createConfig(@Valid @RequestBody PointConfigCreateReqVO createReqVO) { + return success(configService.createConfig(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新积分设置") + @PreAuthorize("@ss.hasPermission('point:config:update')") + public CommonResult 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 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 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> getConfigList(@RequestParam("ids") Collection ids) { + List list = configService.getConfigList(ids); + return success(PointConfigConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得积分设置分页") + @PreAuthorize("@ss.hasPermission('point:config:query')") + public CommonResult> getConfigPage(@Valid PointConfigPageReqVO pageVO) { + PageResult 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 list = configService.getConfigList(exportReqVO); + // 导出 Excel + List datas = PointConfigConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "积分设置.xls", "数据", PointConfigExcelVO.class, datas); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigBaseVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigBaseVO.java new file mode 100644 index 000000000..d1e900cc2 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigBaseVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigCreateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigCreateReqVO.java new file mode 100644 index 000000000..4284f5e34 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigCreateReqVO.java @@ -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 { + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigExcelVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigExcelVO.java new file mode 100644 index 000000000..0d01c7a5c --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigExcelVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigExportReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigExportReqVO.java new file mode 100644 index 000000000..bcc712d29 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigExportReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigPageReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigPageReqVO.java new file mode 100644 index 000000000..cc994837c --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigPageReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigRespVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigRespVO.java new file mode 100644 index 000000000..a8efe57b4 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigRespVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigUpdateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigUpdateReqVO.java new file mode 100644 index 000000000..9b50f259d --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointconfig/vo/PointConfigUpdateReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/PointRecordController.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/PointRecordController.java new file mode 100644 index 000000000..14c115a35 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/PointRecordController.java @@ -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 createRecord(@Valid @RequestBody PointRecordCreateReqVO createReqVO) { + return success(recordService.createRecord(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新用户积分记录") + @PreAuthorize("@ss.hasPermission('point:record:update')") + public CommonResult 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 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 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> getRecordList(@RequestParam("ids") Collection ids) { + List list = recordService.getRecordList(ids); + return success(PointRecordConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得用户积分记录分页") + @PreAuthorize("@ss.hasPermission('point:record:query')") + public CommonResult> getRecordPage(@Valid PointRecordPageReqVO pageVO) { + PageResult 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 list = recordService.getRecordList(exportReqVO); + // 导出 Excel + List datas = PointRecordConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "用户积分记录.xls", "数据", PointRecordExcelVO.class, datas); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordBaseVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordBaseVO.java new file mode 100644 index 000000000..0337aac8e --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordBaseVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordCreateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordCreateReqVO.java new file mode 100644 index 000000000..7062109d2 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordCreateReqVO.java @@ -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 { + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordExcelVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordExcelVO.java new file mode 100644 index 000000000..3db1573fc --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordExcelVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordExportReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordExportReqVO.java new file mode 100644 index 000000000..d57ade55a --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordExportReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordPageReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordPageReqVO.java new file mode 100644 index 000000000..b4570c618 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordPageReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordRespVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordRespVO.java new file mode 100644 index 000000000..d40dee6ee --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordRespVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordUpdateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordUpdateReqVO.java new file mode 100644 index 000000000..d053e0a0e --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/pointrecord/vo/PointRecordUpdateReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/SignInConfigController.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/SignInConfigController.java new file mode 100644 index 000000000..2ca25dd5a --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/SignInConfigController.java @@ -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 createSignInConfig(@Valid @RequestBody SignInConfigCreateReqVO createReqVO) { + return success(signInConfigService.createSignInConfig(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新积分签到规则") + @PreAuthorize("@ss.hasPermission('point:sign-in-config:update')") + public CommonResult 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 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 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> getSignInConfigList(@RequestParam("ids") Collection ids) { + List list = signInConfigService.getSignInConfigList(ids); + return success(SignInConfigConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得积分签到规则分页") + @PreAuthorize("@ss.hasPermission('point:sign-in-config:query')") + public CommonResult> getSignInConfigPage(@Valid SignInConfigPageReqVO pageVO) { + PageResult 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 list = signInConfigService.getSignInConfigList(exportReqVO); + // 导出 Excel + List datas = SignInConfigConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "积分签到规则.xls", "数据", SignInConfigExcelVO.class, datas); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigBaseVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigBaseVO.java new file mode 100644 index 000000000..4c2160dde --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigBaseVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigCreateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigCreateReqVO.java new file mode 100644 index 000000000..39098c192 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigCreateReqVO.java @@ -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 { + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigExcelVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigExcelVO.java new file mode 100644 index 000000000..8d066f2ae --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigExcelVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigExportReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigExportReqVO.java new file mode 100644 index 000000000..473fe1153 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigExportReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigPageReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigPageReqVO.java new file mode 100644 index 000000000..892d1f2e8 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigPageReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigRespVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigRespVO.java new file mode 100644 index 000000000..a78816c3f --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigRespVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigUpdateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigUpdateReqVO.java new file mode 100644 index 000000000..cf6c788e1 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinconfig/vo/SignInConfigUpdateReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/SignInRecordController.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/SignInRecordController.java new file mode 100644 index 000000000..a2a639c5d --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/SignInRecordController.java @@ -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 createSignInRecord(@Valid @RequestBody SignInRecordCreateReqVO createReqVO) { + return success(signInRecordService.createSignInRecord(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新用户签到积分") + @PreAuthorize("@ss.hasPermission('point:sign-in-record:update')") + public CommonResult 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 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 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> getSignInRecordList(@RequestParam("ids") Collection ids) { + List list = signInRecordService.getSignInRecordList(ids); + return success(SignInRecordConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得用户签到积分分页") + @PreAuthorize("@ss.hasPermission('point:sign-in-record:query')") + public CommonResult> getSignInRecordPage(@Valid SignInRecordPageReqVO pageVO) { + PageResult 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 list = signInRecordService.getSignInRecordList(exportReqVO); + // 导出 Excel + List datas = SignInRecordConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "用户签到积分.xls", "数据", SignInRecordExcelVO.class, datas); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordBaseVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordBaseVO.java new file mode 100644 index 000000000..9cefa4a18 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordBaseVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordCreateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordCreateReqVO.java new file mode 100644 index 000000000..9635b3076 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordCreateReqVO.java @@ -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 { + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordExcelVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordExcelVO.java new file mode 100644 index 000000000..de9ebf605 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordExcelVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordExportReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordExportReqVO.java new file mode 100644 index 000000000..673042306 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordExportReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordPageReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordPageReqVO.java new file mode 100644 index 000000000..49218aafa --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordPageReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordRespVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordRespVO.java new file mode 100644 index 000000000..d4180d1b1 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordRespVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordUpdateReqVO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordUpdateReqVO.java new file mode 100644 index 000000000..81392d088 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/controller/admin/signinrecord/vo/SignInRecordUpdateReqVO.java @@ -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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/pointconfig/PointConfigConvert.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/pointconfig/PointConfigConvert.java new file mode 100644 index 000000000..56b96cf75 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/pointconfig/PointConfigConvert.java @@ -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 convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/pointrecord/PointRecordConvert.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/pointrecord/PointRecordConvert.java new file mode 100644 index 000000000..556c154f8 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/pointrecord/PointRecordConvert.java @@ -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 convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/signinconfig/SignInConfigConvert.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/signinconfig/SignInConfigConvert.java new file mode 100644 index 000000000..a602fd399 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/signinconfig/SignInConfigConvert.java @@ -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 convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/signinrecord/SignInRecordConvert.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/signinrecord/SignInRecordConvert.java new file mode 100644 index 000000000..6c3b434cb --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/convert/signinrecord/SignInRecordConvert.java @@ -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 convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/pointconfig/PointConfigDO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/pointconfig/PointConfigDO.java new file mode 100644 index 000000000..ee30a27d1 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/pointconfig/PointConfigDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/pointrecord/PointRecordDO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/pointrecord/PointRecordDO.java new file mode 100644 index 000000000..74197e70d --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/pointrecord/PointRecordDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/signinconfig/SignInConfigDO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/signinconfig/SignInConfigDO.java new file mode 100644 index 000000000..9eb07c929 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/signinconfig/SignInConfigDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/signinrecord/SignInRecordDO.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/signinrecord/SignInRecordDO.java new file mode 100644 index 000000000..d75a852d3 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/dataobject/signinrecord/SignInRecordDO.java @@ -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") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 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; + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/pointconfig/PointConfigMapper.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/pointconfig/PointConfigMapper.java new file mode 100644 index 000000000..5d11f9b5b --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/pointconfig/PointConfigMapper.java @@ -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 { + + default PageResult selectPage(PointConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(PointConfigDO::getTradeDeductEnable, reqVO.getTradeDeductEnable()) + .orderByDesc(PointConfigDO::getId)); + } + + default List selectList(PointConfigExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(PointConfigDO::getTradeDeductEnable, reqVO.getTradeDeductEnable()) + .orderByDesc(PointConfigDO::getId)); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/pointrecord/PointRecordMapper.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/pointrecord/PointRecordMapper.java new file mode 100644 index 000000000..005056a30 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/pointrecord/PointRecordMapper.java @@ -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 { + + default PageResult selectPage(PointRecordPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .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 selectList(PointRecordExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .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)); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/signinconfig/SignInConfigMapper.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/signinconfig/SignInConfigMapper.java new file mode 100644 index 000000000..6188d3fef --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/signinconfig/SignInConfigMapper.java @@ -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 { + + default PageResult selectPage(SignInConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(SignInConfigDO::getDay, reqVO.getDay()) + .orderByAsc(SignInConfigDO::getDay)); + } + + default List selectList(SignInConfigExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(SignInConfigDO::getDay, reqVO.getDay()) + .orderByDesc(SignInConfigDO::getId)); + } + + // + default long selectSameDayNotSelf(SignInConfigUpdateReqVO reqVO){ + return selectCount(new LambdaQueryWrapperX () + .ne(SignInConfigDO::getId, reqVO.getId()) + .eq(SignInConfigDO::getDay,reqVO.getDay()) + ); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/signinrecord/SignInRecordMapper.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/signinrecord/SignInRecordMapper.java new file mode 100644 index 000000000..9d0c1c6eb --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/dal/mysql/signinrecord/SignInRecordMapper.java @@ -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 { + + default PageResult selectPage(SignInRecordPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(SignInRecordDO::getUserId, reqVO.getUserId()) + .eqIfPresent(SignInRecordDO::getDay, reqVO.getDay()) + .betweenIfPresent(SignInRecordDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(SignInRecordDO::getId)); + } + + default List selectList(SignInRecordExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(SignInRecordDO::getUserId, reqVO.getUserId()) + .eqIfPresent(SignInRecordDO::getDay, reqVO.getDay()) + .betweenIfPresent(SignInRecordDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(SignInRecordDO::getId)); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigService.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigService.java new file mode 100644 index 000000000..d579b7b9d --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigService.java @@ -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 getConfigList(Collection ids); + + /** + * 获得积分设置分页 + * + * @param pageReqVO 分页查询 + * @return 积分设置分页 + */ + PageResult getConfigPage(PointConfigPageReqVO pageReqVO); + + /** + * 获得积分设置列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 积分设置列表 + */ + List getConfigList(PointConfigExportReqVO exportReqVO); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigServiceImpl.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigServiceImpl.java new file mode 100644 index 000000000..5cc8185d8 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigServiceImpl.java @@ -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 getConfigList(Collection ids) { + return configMapper.selectBatchIds(ids); + } + + @Override + public PageResult getConfigPage(PointConfigPageReqVO pageReqVO) { + return configMapper.selectPage(pageReqVO); + } + + @Override + public List getConfigList(PointConfigExportReqVO exportReqVO) { + return configMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordService.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordService.java new file mode 100644 index 000000000..99833ff8d --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordService.java @@ -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 getRecordList(Collection ids); + + /** + * 获得用户积分记录分页 + * + * @param pageReqVO 分页查询 + * @return 用户积分记录分页 + */ + PageResult getRecordPage(PointRecordPageReqVO pageReqVO); + + /** + * 获得用户积分记录列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 用户积分记录列表 + */ + List getRecordList(PointRecordExportReqVO exportReqVO); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordServiceImpl.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordServiceImpl.java new file mode 100644 index 000000000..a2c0d1ab9 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordServiceImpl.java @@ -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 getRecordList(Collection ids) { + return recordMapper.selectBatchIds(ids); + } + + @Override + public PageResult getRecordPage(PointRecordPageReqVO pageReqVO) { + return recordMapper.selectPage(pageReqVO); + } + + @Override + public List getRecordList(PointRecordExportReqVO exportReqVO) { + return recordMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigService.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigService.java new file mode 100644 index 000000000..486f08f49 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigService.java @@ -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 getSignInConfigList(Collection ids); + + /** + * 获得积分签到规则分页 + * + * @param pageReqVO 分页查询 + * @return 积分签到规则分页 + */ + PageResult getSignInConfigPage(SignInConfigPageReqVO pageReqVO); + + /** + * 获得积分签到规则列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 积分签到规则列表 + */ + List getSignInConfigList(SignInConfigExportReqVO exportReqVO); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigServiceImpl.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigServiceImpl.java new file mode 100644 index 000000000..ac4947ddc --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigServiceImpl.java @@ -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 getSignInConfigList(Collection ids) { + return signInConfigMapper.selectBatchIds(ids); + } + + @Override + public PageResult getSignInConfigPage(SignInConfigPageReqVO pageReqVO) { + return signInConfigMapper.selectPage(pageReqVO); + } + + @Override + public List getSignInConfigList(SignInConfigExportReqVO exportReqVO) { + return signInConfigMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordService.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordService.java new file mode 100644 index 000000000..8910eec7f --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordService.java @@ -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 getSignInRecordList(Collection ids); + + /** + * 获得用户签到积分分页 + * + * @param pageReqVO 分页查询 + * @return 用户签到积分分页 + */ + PageResult getSignInRecordPage(SignInRecordPageReqVO pageReqVO); + + /** + * 获得用户签到积分列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 用户签到积分列表 + */ + List getSignInRecordList(SignInRecordExportReqVO exportReqVO); + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordServiceImpl.java b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordServiceImpl.java new file mode 100644 index 000000000..00ff4967e --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordServiceImpl.java @@ -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 getSignInRecordList(Collection ids) { + return signInRecordMapper.selectBatchIds(ids); + } + + @Override + public PageResult getSignInRecordPage(SignInRecordPageReqVO pageReqVO) { + return signInRecordMapper.selectPage(pageReqVO); + } + + @Override + public List getSignInRecordList(SignInRecordExportReqVO exportReqVO) { + return signInRecordMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/pointconfig/PointConfigMapper.xml b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/pointconfig/PointConfigMapper.xml new file mode 100644 index 000000000..963afd6c8 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/pointconfig/PointConfigMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/pointrecord/PointRecordMapper.xml b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/pointrecord/PointRecordMapper.xml new file mode 100644 index 000000000..cc09cce4b --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/pointrecord/PointRecordMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/signinconfig/SignInConfigMapper.xml b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/signinconfig/SignInConfigMapper.xml new file mode 100644 index 000000000..2e665c01a --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/signinconfig/SignInConfigMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/signinrecord/SignInRecordMapper.xml b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/signinrecord/SignInRecordMapper.xml new file mode 100644 index 000000000..bd9d58976 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/main/resources/mapper/signinrecord/SignInRecordMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigServiceImplTest.java b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigServiceImplTest.java new file mode 100644 index 000000000..d012d03fe --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/pointconfig/PointConfigServiceImplTest.java @@ -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 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 list = configService.getConfigList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbConfig, list.get(0)); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordServiceImplTest.java b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordServiceImplTest.java new file mode 100644 index 000000000..32a7740f0 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/pointrecord/PointRecordServiceImplTest.java @@ -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 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 list = recordService.getRecordList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbRecord, list.get(0)); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigServiceImplTest.java b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigServiceImplTest.java new file mode 100644 index 000000000..e0bd5a2b2 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/signinconfig/SignInConfigServiceImplTest.java @@ -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 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 list = signInConfigService.getSignInConfigList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbSignInConfig, list.get(0)); + } + +} diff --git a/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordServiceImplTest.java b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordServiceImplTest.java new file mode 100644 index 000000000..267bfcd40 --- /dev/null +++ b/yudao-module-point/yudao-module-point-biz/src/test/java/cn/iocoder/yudao/module/point/service/signinrecord/SignInRecordServiceImplTest.java @@ -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 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 list = signInRecordService.getSignInRecordList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbSignInRecord, list.get(0)); + } + +} diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 11cab44f4..f38a73ce9 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -54,11 +54,11 @@ - - cn.iocoder.boot - yudao-module-pay-biz - ${revision} - + + + + + @@ -68,19 +68,25 @@ + + + + + + + + + + + + + + + + cn.iocoder.boot - yudao-module-promotion-biz - ${revision} - - - cn.iocoder.boot - yudao-module-product-biz - ${revision} - - - cn.iocoder.boot - yudao-module-trade-biz + yudao-module-point-biz ${revision}