【同步】BOOT 和 CLOUD 的功能
parent
c422a9f88e
commit
4249528d0f
71
README.md
71
README.md
|
@ -5,7 +5,7 @@
|
|||
<img src="https://img.shields.io/github/license/YunaiV/yudao-cloud" alt="Downloads" />
|
||||
</p>
|
||||
|
||||
**严肃声明:现在、未来都不会有商业版本,所有代码全部开源!**
|
||||
**严肃声明:现在、未来都不会有商业版本,所有代码全部开源!!**
|
||||
|
||||
**「我喜欢写代码,乐此不疲」**
|
||||
**「我喜欢做开源,以此为乐」**
|
||||
|
@ -14,6 +14,16 @@
|
|||
|
||||
如果这个项目让你有所收获,记得 Star 关注哦,这对我是非常不错的鼓励与支持。
|
||||
|
||||
可参考 [《迁移文档》](https://cloud.iocoder.cn/migrate-module/) ,只需要 5-10 分钟,即可将【完整版】按需迁移到【精简版】
|
||||
|
||||
## 🐶 新手必读
|
||||
|
||||
* 演示地址【Vue3 + element-plus】:<http://dashboard-vue3.yudao.iocoder.cn>
|
||||
* 演示地址【Vue3 + vben(ant-design-vue)】:<http://dashboard-vben.yudao.iocoder.cn>
|
||||
* 演示地址【Vue2 + element-ui】:<http://dashboard.yudao.iocoder.cn>
|
||||
* 启动文档:<https://cloud.iocoder.cn/quick-start/>
|
||||
* 视频教程:<https://cloud.iocoder.cn/video/>
|
||||
|
||||
## 🐰 版本说明
|
||||
|
||||
| 版本 | JDK 8 + Spring Boot 2.7 | JDK 17/21 + Spring Boot 3.2 |
|
||||
|
@ -26,14 +36,6 @@
|
|||
|
||||
可参考 [《迁移文档》](https://cloud.iocoder.cn/migrate-module/) ,只需要 5-10 分钟,即可将【完整版】按需迁移到【精简版】
|
||||
|
||||
## 🐶 新手必读
|
||||
|
||||
* 演示地址【Vue3 + element-plus】:<http://dashboard-vue3.yudao.iocoder.cn>
|
||||
* 演示地址【Vue3 + vben(ant-design-vue)】:<http://dashboard-vben.yudao.iocoder.cn>
|
||||
* 演示地址【Vue2 + element-ui】:<http://dashboard.yudao.iocoder.cn>
|
||||
* 启动文档:<https://cloud.iocoder.cn/quick-start/>
|
||||
* 视频教程:<https://cloud.iocoder.cn/video/>
|
||||
|
||||
## 🐯 平台简介
|
||||
|
||||
**芋道**,以开发者为中心,打造中国第一流的快速开发平台,全部开源,个人与企业可 100% 免费使用。
|
||||
|
@ -52,7 +54,8 @@
|
|||
* 消息队列可使用 Event、Redis、RabbitMQ、Kafka、RocketMQ 等
|
||||
* 权限认证使用 Spring Security & Token & Redis,支持多终端、多种用户的认证系统,支持 SSO 单点登录
|
||||
* 支持加载动态权限菜单,按钮级别权限控制,Redis 缓存提升性能
|
||||
* 支持 SaaS 多租户系统,可自定义每个租户的权限,提供透明化的多租户底层封装
|
||||
* 支持 SaaS 多租户,可自定义每个租户的权限,提供透明化的多租户底层封装
|
||||
* 工作流使用 Flowable,支持动态表单、在线设计流程、会签 / 或签、多种任务分配方式
|
||||
* 高效率开发,使用代码生成器可以一键生成 Java、Vue 前后端代码、SQL 脚本、接口文档,支持单表、树表、主子表
|
||||
* 实时通信,采用 Spring WebSocket 实现,内置 Token 身份校验,支持 WebSocket 集群
|
||||
* 集成微信小程序、微信公众号、企业微信、钉钉等三方登陆,集成支付宝、微信等支付与退款
|
||||
|
@ -94,7 +97,7 @@
|
|||
|
||||
![开源项目对比](/.image/common/project-vs.png)
|
||||
|
||||
③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,57000 行 Java 代码,22000 行代码注释。
|
||||
③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,113770 行 Java 代码,42462 行代码注释。
|
||||
|
||||
## 🤝 项目外包
|
||||
|
||||
|
@ -112,7 +115,7 @@
|
|||
|
||||
* 通用模块(必选):系统功能、基础设施
|
||||
* 通用模块(可选):工作流程、支付系统、数据报表、会员中心
|
||||
* 业务系统(按需):ERP 系统、CRM 系统、商城系统、微信公众号
|
||||
* 业务系统(按需):ERP 系统、CRM 系统、商城系统、微信公众号、AI 大模型
|
||||
|
||||
> 友情提示:本项目基于 RuoYi-Vue 修改,**重构优化**后端的代码,**美化**前端的界面。
|
||||
>
|
||||
|
@ -173,26 +176,26 @@
|
|||
|
||||
### 基础设施
|
||||
|
||||
| | 功能 | 描述 |
|
||||
|----|-----------|----------------------------------------------|
|
||||
| 🚀 | 代码生成 | 前后端代码的生成(Java、Vue、SQL、单元测试),支持 CRUD 下载 |
|
||||
| 🚀 | 系统接口 | 基于 Swagger 自动生成相关的 RESTful API 接口文档 |
|
||||
| 🚀 | 数据库文档 | 基于 Screw 自动生成数据库文档,支持导出 Word、HTML、MD 格式 |
|
||||
| | 表单构建 | 拖动表单元素生成相应的 HTML 代码,支持导出 JSON、Vue 文件 |
|
||||
| 🚀 | 配置管理 | 对系统动态配置常用参数,支持 SpringBoot 加载 |
|
||||
| ⭐️ | 定时任务 | 在线(添加、修改、删除)任务调度包含执行结果日志 |
|
||||
| 🚀 | 文件服务 | 支持将文件存储到 S3(MinIO、阿里云、腾讯云、七牛云)、本地、FTP、数据库等 |
|
||||
| 🚀 | WebSocket | 提供 WebSocket 接入示例,支持一对一、一对多发送方式 |
|
||||
| 🚀 | API 日志 | 包括 RESTful API 访问日志、异常日志两部分,方便排查 API 相关的问题 |
|
||||
| | MySQL 监控 | 监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈 |
|
||||
| | Redis 监控 | 监控 Redis 数据库的使用情况,使用的 Redis Key 管理 |
|
||||
| 🚀 | 消息队列 | 基于 Redis 实现消息队列,Stream 提供集群消费,Pub/Sub 提供广播消费 |
|
||||
| 🚀 | Java 监控 | 基于 Spring Boot Admin 实现 Java 应用的监控 |
|
||||
| 🚀 | 链路追踪 | 接入 SkyWalking 组件,实现链路追踪 |
|
||||
| 🚀 | 日志中心 | 接入 SkyWalking 组件,实现日志中心 |
|
||||
| 🚀 | 服务保障 | 基于 Redis 实现分布式锁、幂等、限流功能,满足高并发场景 |
|
||||
| 🚀 | 日志服务 | 轻量级日志中心,查看远程服务器的日志 |
|
||||
| 🚀 | 单元测试 | 基于 JUnit + Mockito 实现单元测试,保证功能的正确性、代码的质量等 |
|
||||
| | 功能 | 描述 |
|
||||
|-----|-----------|----------------------------------------------|
|
||||
| 🚀 | 代码生成 | 前后端代码的生成(Java、Vue、SQL、单元测试),支持 CRUD 下载 |
|
||||
| 🚀 | 系统接口 | 基于 Swagger 自动生成相关的 RESTful API 接口文档 |
|
||||
| 🚀 | 数据库文档 | 基于 Screw 自动生成数据库文档,支持导出 Word、HTML、MD 格式 |
|
||||
| | 表单构建 | 拖动表单元素生成相应的 HTML 代码,支持导出 JSON、Vue 文件 |
|
||||
| 🚀 | 配置管理 | 对系统动态配置常用参数,支持 SpringBoot 加载 |
|
||||
| ⭐️ | 定时任务 | 在线(添加、修改、删除)任务调度包含执行结果日志 |
|
||||
| 🚀 | 文件服务 | 支持将文件存储到 S3(MinIO、阿里云、腾讯云、七牛云)、本地、FTP、数据库等 |
|
||||
| 🚀 | WebSocket | 提供 WebSocket 接入示例,支持一对一、一对多发送方式 |
|
||||
| 🚀 | API 日志 | 包括 RESTful API 访问日志、异常日志两部分,方便排查 API 相关的问题 |
|
||||
| | MySQL 监控 | 监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈 |
|
||||
| | Redis 监控 | 监控 Redis 数据库的使用情况,使用的 Redis Key 管理 |
|
||||
| 🚀 | 消息队列 | 基于 Redis 实现消息队列,Stream 提供集群消费,Pub/Sub 提供广播消费 |
|
||||
| 🚀 | Java 监控 | 基于 Spring Boot Admin 实现 Java 应用的监控 |
|
||||
| 🚀 | 链路追踪 | 接入 SkyWalking 组件,实现链路追踪 |
|
||||
| 🚀 | 日志中心 | 接入 SkyWalking 组件,实现日志中心 |
|
||||
| 🚀 | 服务保障 | 基于 Redis 实现分布式锁、幂等、限流功能,满足高并发场景 |
|
||||
| 🚀 | 日志服务 | 轻量级日志中心,查看远程服务器的日志 |
|
||||
| 🚀 | 单元测试 | 基于 JUnit + Mockito 实现单元测试,保证功能的正确性、代码的质量等 |
|
||||
|
||||
![功能图](/.image/common/infra-feature.png)
|
||||
|
||||
|
@ -271,9 +274,11 @@
|
|||
| `yudao-module-bpm` | 工作流程的 Module 模块 |
|
||||
| `yudao-module-pay` | 支付系统的 Module 模块 |
|
||||
| `yudao-module-mall` | 商城系统的 Module 模块 |
|
||||
| `yudao-module-erp` | ERP 系统的 Module 模块 |
|
||||
| `yudao-module-crm` | CRM 系统的 Module 模块 |
|
||||
| `yudao-module-ai` | AI 大模型的 Module 模块 |
|
||||
| `yudao-module-mp` | 微信公众号的 Module 模块 |
|
||||
| `yudao-module-report` | 大屏报表 Module 模块 |
|
||||
| `yudao-module-ai` | AI 大模型 Module 模块 |
|
||||
|
||||
### 框架
|
||||
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
--
|
||||
-- A hint submitted by a user: Oracle DB MUST be created as "shared" and the
|
||||
-- job_queue_processes parameter must be greater than 2
|
||||
-- However, these settings are pretty much standard after any
|
||||
-- Oracle install, so most users need not worry about this.
|
||||
--
|
||||
-- Many other users (including the primary author of Quartz) have had success
|
||||
-- running in dedicated mode, so only consider the above as a hint ;-)
|
||||
--
|
||||
|
||||
drop table if exists qrtz_calendars;
|
||||
drop table if exists qrtz_fired_triggers;
|
||||
drop table if exists qrtz_blob_triggers;
|
||||
drop table if exists qrtz_cron_triggers;
|
||||
drop table if exists qrtz_simple_triggers;
|
||||
drop table if exists qrtz_simprop_triggers;
|
||||
drop table if exists qrtz_triggers;
|
||||
drop table if exists qrtz_job_details;
|
||||
drop table if exists qrtz_paused_trigger_grps;
|
||||
drop table if exists qrtz_locks;
|
||||
drop table if exists qrtz_scheduler_state;
|
||||
|
||||
CREATE TABLE qrtz_job_details
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
JOB_NAME VARCHAR2(200) NOT NULL,
|
||||
JOB_GROUP VARCHAR2(200) NOT NULL,
|
||||
DESCRIPTION VARCHAR2(250) NULL,
|
||||
JOB_CLASS_NAME VARCHAR2(250) NOT NULL,
|
||||
IS_DURABLE VARCHAR2(1) NOT NULL,
|
||||
IS_NONCONCURRENT VARCHAR2(1) NOT NULL,
|
||||
IS_UPDATE_DATA VARCHAR2(1) NOT NULL,
|
||||
REQUESTS_RECOVERY VARCHAR2(1) NOT NULL,
|
||||
JOB_DATA BLOB NULL,
|
||||
CONSTRAINT QRTZ_JOB_DETAILS_PK PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_triggers
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR2(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
JOB_NAME VARCHAR2(200) NOT NULL,
|
||||
JOB_GROUP VARCHAR2(200) NOT NULL,
|
||||
DESCRIPTION VARCHAR2(250) NULL,
|
||||
NEXT_FIRE_TIME NUMBER(19) NULL,
|
||||
PREV_FIRE_TIME NUMBER(19) NULL,
|
||||
PRIORITY NUMBER(13) NULL,
|
||||
TRIGGER_STATE VARCHAR2(16) NOT NULL,
|
||||
TRIGGER_TYPE VARCHAR2(8) NOT NULL,
|
||||
START_TIME NUMBER(19) NOT NULL,
|
||||
END_TIME NUMBER(19) NULL,
|
||||
CALENDAR_NAME VARCHAR2(200) NULL,
|
||||
MISFIRE_INSTR NUMBER(2) NULL,
|
||||
JOB_DATA BLOB NULL,
|
||||
CONSTRAINT QRTZ_TRIGGERS_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
CONSTRAINT QRTZ_TRIGGER_TO_JOBS_FK FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
|
||||
REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_simple_triggers
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR2(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
REPEAT_COUNT NUMBER(7) NOT NULL,
|
||||
REPEAT_INTERVAL NUMBER(12) NOT NULL,
|
||||
TIMES_TRIGGERED NUMBER(10) NOT NULL,
|
||||
CONSTRAINT QRTZ_SIMPLE_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
CONSTRAINT QRTZ_SIMPLE_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_cron_triggers
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR2(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
CRON_EXPRESSION VARCHAR2(120) NOT NULL,
|
||||
TIME_ZONE_ID VARCHAR2(80),
|
||||
CONSTRAINT QRTZ_CRON_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
CONSTRAINT QRTZ_CRON_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_simprop_triggers
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR2(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
STR_PROP_1 VARCHAR2(512) NULL,
|
||||
STR_PROP_2 VARCHAR2(512) NULL,
|
||||
STR_PROP_3 VARCHAR2(512) NULL,
|
||||
INT_PROP_1 NUMBER(10) NULL,
|
||||
INT_PROP_2 NUMBER(10) NULL,
|
||||
LONG_PROP_1 NUMBER(19) NULL,
|
||||
LONG_PROP_2 NUMBER(19) NULL,
|
||||
DEC_PROP_1 NUMERIC(13,4) NULL,
|
||||
DEC_PROP_2 NUMERIC(13,4) NULL,
|
||||
BOOL_PROP_1 VARCHAR2(1) NULL,
|
||||
BOOL_PROP_2 VARCHAR2(1) NULL,
|
||||
TIME_ZONE_ID VARCHAR2(80) NULL,
|
||||
CONSTRAINT QRTZ_SIMPROP_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
CONSTRAINT QRTZ_SIMPROP_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_blob_triggers
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR2(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
BLOB_DATA BLOB NULL,
|
||||
CONSTRAINT QRTZ_BLOB_TRIG_PK PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
|
||||
CONSTRAINT QRTZ_BLOB_TRIG_TO_TRIG_FK FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_calendars
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
CALENDAR_NAME VARCHAR2(200) NOT NULL,
|
||||
CALENDAR BLOB NOT NULL,
|
||||
CONSTRAINT QRTZ_CALENDARS_PK PRIMARY KEY (SCHED_NAME,CALENDAR_NAME)
|
||||
);
|
||||
CREATE TABLE qrtz_paused_trigger_grps
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
CONSTRAINT QRTZ_PAUSED_TRIG_GRPS_PK PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
|
||||
);
|
||||
CREATE TABLE qrtz_fired_triggers
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
ENTRY_ID VARCHAR2(140) NOT NULL,
|
||||
TRIGGER_NAME VARCHAR2(200) NOT NULL,
|
||||
TRIGGER_GROUP VARCHAR2(200) NOT NULL,
|
||||
INSTANCE_NAME VARCHAR2(200) NOT NULL,
|
||||
FIRED_TIME NUMBER(19) NOT NULL,
|
||||
SCHED_TIME NUMBER(19) NOT NULL,
|
||||
PRIORITY NUMBER(13) NOT NULL,
|
||||
STATE VARCHAR2(16) NOT NULL,
|
||||
JOB_NAME VARCHAR2(200) NULL,
|
||||
JOB_GROUP VARCHAR2(200) NULL,
|
||||
IS_NONCONCURRENT VARCHAR2(1) NULL,
|
||||
REQUESTS_RECOVERY VARCHAR2(1) NULL,
|
||||
CONSTRAINT QRTZ_FIRED_TRIGGER_PK PRIMARY KEY (SCHED_NAME,ENTRY_ID)
|
||||
);
|
||||
CREATE TABLE qrtz_scheduler_state
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
INSTANCE_NAME VARCHAR2(200) NOT NULL,
|
||||
LAST_CHECKIN_TIME NUMBER(19) NOT NULL,
|
||||
CHECKIN_INTERVAL NUMBER(13) NOT NULL,
|
||||
CONSTRAINT QRTZ_SCHEDULER_STATE_PK PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
|
||||
);
|
||||
CREATE TABLE qrtz_locks
|
||||
(
|
||||
SCHED_NAME VARCHAR2(120) NOT NULL,
|
||||
LOCK_NAME VARCHAR2(40) NOT NULL,
|
||||
CONSTRAINT QRTZ_LOCKS_PK PRIMARY KEY (SCHED_NAME,LOCK_NAME)
|
||||
);
|
||||
|
||||
create index idx_qrtz_j_req_recovery on qrtz_job_details(SCHED_NAME,REQUESTS_RECOVERY);
|
||||
create index idx_qrtz_j_grp on qrtz_job_details(SCHED_NAME,JOB_GROUP);
|
||||
|
||||
create index idx_qrtz_t_j on qrtz_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP);
|
||||
create index idx_qrtz_t_jg on qrtz_triggers(SCHED_NAME,JOB_GROUP);
|
||||
create index idx_qrtz_t_c on qrtz_triggers(SCHED_NAME,CALENDAR_NAME);
|
||||
create index idx_qrtz_t_g on qrtz_triggers(SCHED_NAME,TRIGGER_GROUP);
|
||||
create index idx_qrtz_t_state on qrtz_triggers(SCHED_NAME,TRIGGER_STATE);
|
||||
create index idx_qrtz_t_n_state on qrtz_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE);
|
||||
create index idx_qrtz_t_n_g_state on qrtz_triggers(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE);
|
||||
create index idx_qrtz_t_next_fire_time on qrtz_triggers(SCHED_NAME,NEXT_FIRE_TIME);
|
||||
create index idx_qrtz_t_nft_st on qrtz_triggers(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME);
|
||||
create index idx_qrtz_t_nft_misfire on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME);
|
||||
create index idx_qrtz_t_nft_st_misfire on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE);
|
||||
create index idx_qrtz_t_nft_st_misfire_grp on qrtz_triggers(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE);
|
||||
|
||||
create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME);
|
||||
create index idx_qrtz_ft_inst_job_req_rcvry on qrtz_fired_triggers(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY);
|
||||
create index idx_qrtz_ft_j_g on qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROUP);
|
||||
create index idx_qrtz_ft_jg on qrtz_fired_triggers(SCHED_NAME,JOB_GROUP);
|
||||
create index idx_qrtz_ft_t_g on qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
|
||||
create index idx_qrtz_ft_tg on qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,170 @@
|
|||
set client_min_messages = WARNING;
|
||||
DROP TABLE IF EXISTS qrtz_fired_triggers;
|
||||
DROP TABLE IF EXISTS qrtz_paused_trigger_grps;
|
||||
DROP TABLE IF EXISTS qrtz_scheduler_state;
|
||||
DROP TABLE IF EXISTS qrtz_locks;
|
||||
DROP TABLE IF EXISTS qrtz_simprop_triggers;
|
||||
DROP TABLE IF EXISTS qrtz_simple_triggers;
|
||||
DROP TABLE IF EXISTS qrtz_cron_triggers;
|
||||
DROP TABLE IF EXISTS qrtz_blob_triggers;
|
||||
DROP TABLE IF EXISTS qrtz_triggers;
|
||||
DROP TABLE IF EXISTS qrtz_job_details;
|
||||
DROP TABLE IF EXISTS qrtz_calendars;
|
||||
set client_min_messages = NOTICE;
|
||||
|
||||
CREATE TABLE qrtz_job_details
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
job_name TEXT NOT NULL,
|
||||
job_group TEXT NOT NULL,
|
||||
description TEXT NULL,
|
||||
job_class_name TEXT NOT NULL,
|
||||
is_durable BOOL NOT NULL,
|
||||
is_nonconcurrent BOOL NOT NULL,
|
||||
is_update_data BOOL NOT NULL,
|
||||
requests_recovery BOOL NOT NULL,
|
||||
job_data BYTEA NULL,
|
||||
PRIMARY KEY (sched_name,job_name,job_group)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_triggers
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
trigger_name TEXT NOT NULL,
|
||||
trigger_group TEXT NOT NULL,
|
||||
job_name TEXT NOT NULL,
|
||||
job_group TEXT NOT NULL,
|
||||
description TEXT NULL,
|
||||
next_fire_time BIGINT NULL,
|
||||
prev_fire_time BIGINT NULL,
|
||||
priority INTEGER NULL,
|
||||
trigger_state TEXT NOT NULL,
|
||||
trigger_type TEXT NOT NULL,
|
||||
start_time BIGINT NOT NULL,
|
||||
end_time BIGINT NULL,
|
||||
calendar_name TEXT NULL,
|
||||
misfire_instr SMALLINT NULL,
|
||||
job_data BYTEA NULL,
|
||||
PRIMARY KEY (sched_name,trigger_name,trigger_group),
|
||||
FOREIGN KEY (sched_name,job_name,job_group)
|
||||
REFERENCES qrtz_job_details(sched_name,job_name,job_group)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_simple_triggers
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
trigger_name TEXT NOT NULL,
|
||||
trigger_group TEXT NOT NULL,
|
||||
repeat_count BIGINT NOT NULL,
|
||||
repeat_interval BIGINT NOT NULL,
|
||||
times_triggered BIGINT NOT NULL,
|
||||
PRIMARY KEY (sched_name,trigger_name,trigger_group),
|
||||
FOREIGN KEY (sched_name,trigger_name,trigger_group)
|
||||
REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE QRTZ_SIMPROP_TRIGGERS
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
trigger_name TEXT NOT NULL ,
|
||||
trigger_group TEXT NOT NULL ,
|
||||
str_prop_1 TEXT NULL,
|
||||
str_prop_2 TEXT NULL,
|
||||
str_prop_3 TEXT NULL,
|
||||
int_prop_1 INTEGER NULL,
|
||||
int_prop_2 INTEGER NULL,
|
||||
long_prop_1 BIGINT NULL,
|
||||
long_prop_2 BIGINT NULL,
|
||||
dec_prop_1 NUMERIC NULL,
|
||||
dec_prop_2 NUMERIC NULL,
|
||||
bool_prop_1 BOOL NULL,
|
||||
bool_prop_2 BOOL NULL,
|
||||
time_zone_id TEXT NULL,
|
||||
PRIMARY KEY (sched_name,trigger_name,trigger_group),
|
||||
FOREIGN KEY (sched_name,trigger_name,trigger_group)
|
||||
REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_cron_triggers
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
trigger_name TEXT NOT NULL,
|
||||
trigger_group TEXT NOT NULL,
|
||||
cron_expression TEXT NOT NULL,
|
||||
time_zone_id TEXT,
|
||||
PRIMARY KEY (sched_name,trigger_name,trigger_group),
|
||||
FOREIGN KEY (sched_name,trigger_name,trigger_group)
|
||||
REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_blob_triggers
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
trigger_name TEXT NOT NULL,
|
||||
trigger_group TEXT NOT NULL,
|
||||
blob_data BYTEA NULL,
|
||||
PRIMARY KEY (sched_name,trigger_name,trigger_group),
|
||||
FOREIGN KEY (sched_name,trigger_name,trigger_group)
|
||||
REFERENCES qrtz_triggers(sched_name,trigger_name,trigger_group) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_calendars
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
calendar_name TEXT NOT NULL,
|
||||
calendar BYTEA NOT NULL,
|
||||
PRIMARY KEY (sched_name,calendar_name)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_paused_trigger_grps
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
trigger_group TEXT NOT NULL,
|
||||
PRIMARY KEY (sched_name,trigger_group)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_fired_triggers
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
entry_id TEXT NOT NULL,
|
||||
trigger_name TEXT NOT NULL,
|
||||
trigger_group TEXT NOT NULL,
|
||||
instance_name TEXT NOT NULL,
|
||||
fired_time BIGINT NOT NULL,
|
||||
sched_time BIGINT NOT NULL,
|
||||
priority INTEGER NOT NULL,
|
||||
state TEXT NOT NULL,
|
||||
job_name TEXT NULL,
|
||||
job_group TEXT NULL,
|
||||
is_nonconcurrent BOOL NOT NULL,
|
||||
requests_recovery BOOL NULL,
|
||||
PRIMARY KEY (sched_name,entry_id)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_scheduler_state
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
instance_name TEXT NOT NULL,
|
||||
last_checkin_time BIGINT NOT NULL,
|
||||
checkin_interval BIGINT NOT NULL,
|
||||
PRIMARY KEY (sched_name,instance_name)
|
||||
);
|
||||
|
||||
CREATE TABLE qrtz_locks
|
||||
(
|
||||
sched_name TEXT NOT NULL,
|
||||
lock_name TEXT NOT NULL,
|
||||
PRIMARY KEY (sched_name,lock_name)
|
||||
);
|
||||
|
||||
create index idx_qrtz_j_req_recovery on qrtz_job_details(requests_recovery);
|
||||
create index idx_qrtz_t_next_fire_time on qrtz_triggers(next_fire_time);
|
||||
create index idx_qrtz_t_state on qrtz_triggers(trigger_state);
|
||||
create index idx_qrtz_t_nft_st on qrtz_triggers(next_fire_time,trigger_state);
|
||||
create index idx_qrtz_ft_trig_name on qrtz_fired_triggers(trigger_name);
|
||||
create index idx_qrtz_ft_trig_group on qrtz_fired_triggers(trigger_group);
|
||||
create index idx_qrtz_ft_trig_nm_gp on qrtz_fired_triggers(sched_name,trigger_name,trigger_group);
|
||||
create index idx_qrtz_ft_trig_inst_name on qrtz_fired_triggers(instance_name);
|
||||
create index idx_qrtz_ft_job_name on qrtz_fired_triggers(job_name);
|
||||
create index idx_qrtz_ft_job_group on qrtz_fired_triggers(job_group);
|
||||
create index idx_qrtz_ft_job_req_recovery on qrtz_fired_triggers(requests_recovery);
|
|
@ -0,0 +1,253 @@
|
|||
-- ----------------------------
|
||||
-- qrtz_blob_triggers
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_blob_triggers
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
trigger_name varchar(190) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
blob_data bytea NULL,
|
||||
PRIMARY KEY (sched_name, trigger_name, trigger_group)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_qrtz_blob_triggers_sched_name ON qrtz_blob_triggers (sched_name, trigger_name, trigger_group);
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_calendars
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_calendars
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
calendar_name varchar(190) NOT NULL,
|
||||
calendar bytea NOT NULL,
|
||||
PRIMARY KEY (sched_name, calendar_name)
|
||||
);
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_cron_triggers
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_cron_triggers
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
trigger_name varchar(190) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
cron_expression varchar(120) NOT NULL,
|
||||
time_zone_id varchar(80) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (sched_name, trigger_name, trigger_group)
|
||||
);
|
||||
|
||||
-- @formatter:off
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
-- @formatter:on
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_fired_triggers
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_fired_triggers
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
entry_id varchar(95) NOT NULL,
|
||||
trigger_name varchar(190) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
instance_name varchar(190) NOT NULL,
|
||||
fired_time int8 NOT NULL,
|
||||
sched_time int8 NOT NULL,
|
||||
priority int4 NOT NULL,
|
||||
state varchar(16) NOT NULL,
|
||||
job_name varchar(190) NULL DEFAULT NULL,
|
||||
job_group varchar(190) NULL DEFAULT NULL,
|
||||
is_nonconcurrent varchar(1) NULL DEFAULT NULL,
|
||||
requests_recovery varchar(1) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (sched_name, entry_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_qrtz_ft_trig_inst_name ON qrtz_fired_triggers (sched_name, instance_name);
|
||||
CREATE INDEX idx_qrtz_ft_inst_job_req_rcvry ON qrtz_fired_triggers (sched_name, instance_name, requests_recovery);
|
||||
CREATE INDEX idx_qrtz_ft_j_g ON qrtz_fired_triggers (sched_name, job_name, job_group);
|
||||
CREATE INDEX idx_qrtz_ft_jg ON qrtz_fired_triggers (sched_name, job_group);
|
||||
CREATE INDEX idx_qrtz_ft_t_g ON qrtz_fired_triggers (sched_name, trigger_name, trigger_group);
|
||||
CREATE INDEX idx_qrtz_ft_tg ON qrtz_fired_triggers (sched_name, trigger_group);
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_job_details
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_job_details
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
job_name varchar(190) NOT NULL,
|
||||
job_group varchar(190) NOT NULL,
|
||||
description varchar(250) NULL DEFAULT NULL,
|
||||
job_class_name varchar(250) NOT NULL,
|
||||
is_durable varchar(1) NOT NULL,
|
||||
is_nonconcurrent varchar(1) NOT NULL,
|
||||
is_update_data varchar(1) NOT NULL,
|
||||
requests_recovery varchar(1) NOT NULL,
|
||||
job_data bytea NULL,
|
||||
PRIMARY KEY (sched_name, job_name, job_group)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_qrtz_j_req_recovery ON qrtz_job_details (sched_name, requests_recovery);
|
||||
CREATE INDEX idx_qrtz_j_grp ON qrtz_job_details (sched_name, job_group);
|
||||
|
||||
-- @formatter:off
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
-- @formatter:on
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_locks
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_locks
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
lock_name varchar(40) NOT NULL,
|
||||
PRIMARY KEY (sched_name, lock_name)
|
||||
);
|
||||
|
||||
-- @formatter:off
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
-- @formatter:on
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_paused_trigger_grps
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_paused_trigger_grps
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
PRIMARY KEY (sched_name, trigger_group)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_scheduler_state
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_scheduler_state
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
instance_name varchar(190) NOT NULL,
|
||||
last_checkin_time int8 NOT NULL,
|
||||
checkin_interval int8 NOT NULL,
|
||||
PRIMARY KEY (sched_name, instance_name)
|
||||
);
|
||||
|
||||
-- @formatter:off
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
-- @formatter:on
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_simple_triggers
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_simple_triggers
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
trigger_name varchar(190) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
repeat_count int8 NOT NULL,
|
||||
repeat_interval int8 NOT NULL,
|
||||
times_triggered int8 NOT NULL,
|
||||
PRIMARY KEY (sched_name, trigger_name, trigger_group)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_simprop_triggers
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_simprop_triggers
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
trigger_name varchar(190) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
str_prop_1 varchar(512) NULL DEFAULT NULL,
|
||||
str_prop_2 varchar(512) NULL DEFAULT NULL,
|
||||
str_prop_3 varchar(512) NULL DEFAULT NULL,
|
||||
int_prop_1 int4 NULL DEFAULT NULL,
|
||||
int_prop_2 int4 NULL DEFAULT NULL,
|
||||
long_prop_1 int8 NULL DEFAULT NULL,
|
||||
long_prop_2 int8 NULL DEFAULT NULL,
|
||||
dec_prop_1 numeric(13, 4) NULL DEFAULT NULL,
|
||||
dec_prop_2 numeric(13, 4) NULL DEFAULT NULL,
|
||||
bool_prop_1 varchar(1) NULL DEFAULT NULL,
|
||||
bool_prop_2 varchar(1) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (sched_name, trigger_name, trigger_group)
|
||||
);
|
||||
|
||||
-- ----------------------------
|
||||
-- qrtz_triggers
|
||||
-- ----------------------------
|
||||
CREATE TABLE qrtz_triggers
|
||||
(
|
||||
sched_name varchar(120) NOT NULL,
|
||||
trigger_name varchar(190) NOT NULL,
|
||||
trigger_group varchar(190) NOT NULL,
|
||||
job_name varchar(190) NOT NULL,
|
||||
job_group varchar(190) NOT NULL,
|
||||
description varchar(250) NULL DEFAULT NULL,
|
||||
next_fire_time int8 NULL DEFAULT NULL,
|
||||
prev_fire_time int8 NULL DEFAULT NULL,
|
||||
priority int4 NULL DEFAULT NULL,
|
||||
trigger_state varchar(16) NOT NULL,
|
||||
trigger_type varchar(8) NOT NULL,
|
||||
start_time int8 NOT NULL,
|
||||
end_time int8 NULL DEFAULT NULL,
|
||||
calendar_name varchar(190) NULL DEFAULT NULL,
|
||||
misfire_instr int2 NULL DEFAULT NULL,
|
||||
job_data bytea NULL,
|
||||
PRIMARY KEY (sched_name, trigger_name, trigger_group)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_qrtz_t_j ON qrtz_triggers (sched_name, job_name, job_group);
|
||||
CREATE INDEX idx_qrtz_t_jg ON qrtz_triggers (sched_name, job_group);
|
||||
CREATE INDEX idx_qrtz_t_c ON qrtz_triggers (sched_name, calendar_name);
|
||||
CREATE INDEX idx_qrtz_t_g ON qrtz_triggers (sched_name, trigger_group);
|
||||
CREATE INDEX idx_qrtz_t_state ON qrtz_triggers (sched_name, trigger_state);
|
||||
CREATE INDEX idx_qrtz_t_n_state ON qrtz_triggers (sched_name, trigger_name, trigger_group, trigger_state);
|
||||
CREATE INDEX idx_qrtz_t_n_g_state ON qrtz_triggers (sched_name, trigger_group, trigger_state);
|
||||
CREATE INDEX idx_qrtz_t_next_fire_time ON qrtz_triggers (sched_name, next_fire_time);
|
||||
CREATE INDEX idx_qrtz_t_nft_st ON qrtz_triggers (sched_name, trigger_state, next_fire_time);
|
||||
CREATE INDEX idx_qrtz_t_nft_misfire ON qrtz_triggers (sched_name, misfire_instr, next_fire_time);
|
||||
CREATE INDEX idx_qrtz_t_nft_st_misfire ON qrtz_triggers (sched_name, misfire_instr, next_fire_time, trigger_state);
|
||||
CREATE INDEX idx_qrtz_t_nft_st_misfire_grp ON qrtz_triggers (sched_name, misfire_instr, next_fire_time, trigger_group,
|
||||
trigger_state);
|
||||
|
||||
-- @formatter:off
|
||||
BEGIN;
|
||||
COMMIT;
|
||||
-- @formatter:on
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- FK: qrtz_blob_triggers
|
||||
-- ----------------------------
|
||||
ALTER TABLE qrtz_blob_triggers
|
||||
ADD CONSTRAINT qrtz_blob_triggers_ibfk_1 FOREIGN KEY (sched_name, trigger_name, trigger_group) REFERENCES qrtz_triggers (sched_name,
|
||||
trigger_name,
|
||||
trigger_group);
|
||||
|
||||
-- ----------------------------
|
||||
-- FK: qrtz_cron_triggers
|
||||
-- ----------------------------
|
||||
ALTER TABLE qrtz_cron_triggers
|
||||
ADD CONSTRAINT qrtz_cron_triggers_ibfk_1 FOREIGN KEY (sched_name, trigger_name, trigger_group) REFERENCES qrtz_triggers (sched_name, trigger_name, trigger_group);
|
||||
|
||||
-- ----------------------------
|
||||
-- FK: qrtz_simple_triggers
|
||||
-- ----------------------------
|
||||
ALTER TABLE qrtz_simple_triggers
|
||||
ADD CONSTRAINT qrtz_simple_triggers_ibfk_1 FOREIGN KEY (sched_name, trigger_name, trigger_group) REFERENCES qrtz_triggers (sched_name,
|
||||
trigger_name,
|
||||
trigger_group);
|
||||
|
||||
-- ----------------------------
|
||||
-- FK: qrtz_simprop_triggers
|
||||
-- ----------------------------
|
||||
ALTER TABLE qrtz_simprop_triggers
|
||||
ADD CONSTRAINT qrtz_simprop_triggers_ibfk_1 FOREIGN KEY (sched_name, trigger_name, trigger_group) REFERENCES qrtz_triggers (sched_name, trigger_name, trigger_group);
|
||||
|
||||
-- ----------------------------
|
||||
-- FK: qrtz_triggers
|
||||
-- ----------------------------
|
||||
ALTER TABLE qrtz_triggers
|
||||
ADD CONSTRAINT qrtz_triggers_ibfk_1 FOREIGN KEY (sched_name, job_name, job_group) REFERENCES qrtz_job_details (sched_name, job_name, job_group);
|
|
@ -19,10 +19,14 @@ docker compose up -d mysql
|
|||
#### 1.2 Oracle
|
||||
|
||||
```Bash
|
||||
## x86 版本
|
||||
docker compose up -d oracle
|
||||
|
||||
## MacBook Apple Silicon
|
||||
docker compose up -d oracle_m1
|
||||
```
|
||||
|
||||
暂不支持 MacBook Apple Silicon,因为 Oracle 官方没有提供 Apple Silicon 版本的 Docker 镜像。
|
||||
> 注意:如果使用 MacBook Apple Silicon 版本,它的 ORACLE_SID 不是 XE,而是 FREE!!!
|
||||
|
||||
### 1.3 PostgreSQL
|
||||
|
||||
|
@ -38,16 +42,14 @@ docker compose up -d sqlserver
|
|||
docker compose exec sqlserver bash /tmp/create_schema.sh
|
||||
```
|
||||
|
||||
暂不支持 MacBook Apple Silicon,因为 SQL Server 官方没有提供 Apple Silicon 版本的 Docker 镜像。
|
||||
|
||||
### 1.5 DM 达梦
|
||||
|
||||
① 下载达梦 Docker 镜像:https://download.dameng.com/eco/dm8/dm8_20230808_rev197096_x86_rh6_64_single.tar
|
||||
① 下载达梦 Docker 镜像:<https://eco.dameng.com/download/> 地址,点击“Docker 镜像”选项,进行下载。
|
||||
|
||||
② 加载镜像文件,在镜像 tar 文件所在目录运行:
|
||||
|
||||
```Bash
|
||||
docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar
|
||||
docker load -i dm8_20240715_x86_rh6_rq_single.tar
|
||||
```
|
||||
|
||||
③ 在项目 `sql/tools` 目录下运行:
|
||||
|
@ -59,22 +61,17 @@ docker compose exec dm8 bash -c '/opt/dmdbms/bin/disql SYSDBA/SYSDBA001 \`/tmp/s
|
|||
exit
|
||||
```
|
||||
|
||||
**注意**: `sql/dm/ruoyi-vue-pro-dm8.sql` 文件编码必须为 `GBK` 或者 `GBK` 超集,否则会出现中文乱码。
|
||||
|
||||
暂不支持 MacBook Apple Silicon,因为 达梦 官方没有提供 Apple Silicon 版本的 Docker 镜像。
|
||||
|
||||
### 1.6 KingbaseES 人大金仓
|
||||
|
||||
① 下载人大金仓 Docker 镜像:
|
||||
|
||||
> x86_64 版本: https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/x86_64/kdb_x86_64_V009R001C001B0025.tar
|
||||
|
||||
> aarch64 版本:https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/aarch64/kdb_aarch64_V009R001C001B0025.tar
|
||||
* [x86_64 版本](https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/x86_64/kdb_x86_64_V009R001C001B0025.tar) 【Windows 选择这个】
|
||||
* [aarch64 版本](https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/aarch64/kdb_aarch64_V009R001C001B0025.tar) 【MacBook Apple Silicon 选择这个】
|
||||
|
||||
② 加载镜像文件,在镜像 tar 文件所在目录运行:
|
||||
|
||||
```Bash
|
||||
docker load -i x86_64/kdb_x86_64_V009R001C001B0025.tar
|
||||
docker load -i kdb_x86_64_V009R001C001B0025.tar
|
||||
```
|
||||
|
||||
③ 在项目 `sql/tools` 目录下运行:
|
||||
|
@ -106,9 +103,11 @@ docker volume rm ruoyi-vue-pro_postgres
|
|||
|
||||
## 2. MySQL 转换其它数据库
|
||||
|
||||
项目提供了 `sql/tools/convertor.py` 脚本,支持将 MySQL 转换为 Oracle、PostgreSQL、SQL Server、达梦、人大金仓、OpenGauss 等数据库的脚本。
|
||||
|
||||
### 2.1 实现原理
|
||||
|
||||
通过读取 MySQL 的 `sql/mysql/ruoyi-vue-pro.sql` 数据库文件,转换成 Oracle、PostgreSQL、SQL Server、达梦、人大金仓 等数据库的脚本。
|
||||
通过读取 MySQL 的 `sql/mysql/ruoyi-vue-pro.sql` 数据库文件,转换成对应的数据库脚本。
|
||||
|
||||
### 2.2 使用方法
|
||||
|
||||
|
@ -119,7 +118,7 @@ pip install simple-ddl-parser
|
|||
# pip3 install simple-ddl-parser
|
||||
```
|
||||
|
||||
② 执行如下命令打印生成 postgres 的脚本内容,其他可选参数有:`oracle`、`sqlserver`、`dm8`、`kingbase`:
|
||||
② 在 `sql/tools/` 目录下,执行如下命令打印生成 postgres 的脚本内容,其他可选参数有:`oracle`、`sqlserver`、`dm8`、`kingbase`、`opengauss`:
|
||||
|
||||
```Bash
|
||||
python3 convertor.py postgres
|
||||
|
|
|
@ -58,6 +58,20 @@ services:
|
|||
- ./oracle/1_create_user.sql:/docker-entrypoint-initdb.d/1_create_user.sql:ro
|
||||
- ./oracle/2_create_schema.sh:/docker-entrypoint-initdb.d/2_create_schema.sh:ro
|
||||
|
||||
oracle_m1:
|
||||
image: einslib/oracle-19c:19.3.0-ee-slim-faststart
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
## 登录信息 SID: FREE user: system password: oracle
|
||||
ORACLE_PASSWORD: oracle
|
||||
ports:
|
||||
- "1521:1521"
|
||||
volumes:
|
||||
- ../oracle/ruoyi-vue-pro.sql:/tmp/schema.sql:ro
|
||||
# 创建app用户: ROOT/123456@//localhost/XEPDB1
|
||||
- ./oracle/1_create_user.sql:/docker-entrypoint-initdb.d/1_create_user.sql:ro
|
||||
- ./oracle/2_create_schema.sh:/docker-entrypoint-initdb.d/2_create_schema.sh:ro
|
||||
|
||||
sqlserver:
|
||||
image: mcr.microsoft.com/mssql/server:2017-latest
|
||||
restart: unless-stopped
|
||||
|
@ -73,11 +87,9 @@ services:
|
|||
# docker compose exec sqlserver bash /tmp/create_schema.sh
|
||||
- ./sqlserver/create_schema.sh:/tmp/create_schema.sh:ro
|
||||
|
||||
|
||||
dm8:
|
||||
# wget https://download.dameng.com/eco/dm8/dm8_20230808_rev197096_x86_rh6_64_single.tar
|
||||
# docker load -i dm8_20230808_rev197096_x86_rh6_64_single.tar
|
||||
image: dm8_single:dm8_20230808_rev197096_x86_rh6_64
|
||||
# docker load -i dm8_20240715_x86_rh6_rq_single.tar
|
||||
image: dm8_single:dm8_20240715_rev232765_x86_rh6_64
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
PAGE_SIZE: 16
|
||||
|
@ -93,13 +105,10 @@ services:
|
|||
volumes:
|
||||
- dm8:/opt/dmdbms/data
|
||||
- ../dm/ruoyi-vue-pro-dm8.sql:/tmp/schema.sql:ro
|
||||
# docker compose exec dm8 bash -c '/opt/dmdbms/bin/disql SYSDBA/SYSDBA001 \`/tmp/schema.sql'
|
||||
|
||||
kingbase:
|
||||
# x86_64: https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/x86_64/kdb_x86_64_V009R001C001B0025.tar
|
||||
# aarch64: https://kingbase.oss-cn-beijing.aliyuncs.com/KESV8R3/V009R001C001B0025-安装包-docker/aarch64/kdb_aarch64_V009R001C001B0025.tar
|
||||
# docker load -i kdb_x86_64_V009R001C001B0025.tar
|
||||
image: kingbase_v009r001c001b0025_single_x86:v1
|
||||
# image: kingbase_v009r001c001b0025_single_arm:v1
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DB_USER: root
|
||||
|
@ -109,7 +118,6 @@ services:
|
|||
volumes:
|
||||
- kingbase:/home/kingbase/userdata
|
||||
- ../kingbase/ruoyi-vue-pro.sql:/tmp/schema.sql:ro
|
||||
# docker compose exec kingbase bash -c 'ksql -U $DB_USER -d test -f /tmp/schema.sql'
|
||||
|
||||
opengauss:
|
||||
image: opengauss/opengauss:5.0.0
|
||||
|
|
|
@ -290,7 +290,15 @@ public class CollectionUtils {
|
|||
return valueFunc.apply(t);
|
||||
}
|
||||
|
||||
public static <T, V extends Comparable<? super V>> V getSumValue(List<T> from, Function<T, V> valueFunc,
|
||||
public static <T, V extends Comparable<? super V>> T getMinObject(List<T> from, Function<T, V> valueFunc) {
|
||||
if (CollUtil.isEmpty(from)) {
|
||||
return null;
|
||||
}
|
||||
assert from.size() > 0; // 断言,避免告警
|
||||
return from.stream().min(Comparator.comparing(valueFunc)).get();
|
||||
}
|
||||
|
||||
public static <T, V extends Comparable<? super V>> V getSumValue(Collection<T> from, Function<T, V> valueFunc,
|
||||
BinaryOperator<V> accumulator) {
|
||||
return getSumValue(from, valueFunc, accumulator, null);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.framework.mybatis.config;
|
|||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
|
@ -42,9 +41,6 @@ public class IdTypeEnvironmentPostProcessor implements EnvironmentPostProcessor
|
|||
// TODO 芋艿:暂时没有找到特别合适的地方,先放在这里
|
||||
setJobStoreDriverIfPresent(environment, dbType);
|
||||
|
||||
// 初始化 SQL 静态变量
|
||||
SqlConstants.init(dbType);
|
||||
|
||||
// 如果非 NONE,则不进行处理
|
||||
IdType idType = getIdType(environment);
|
||||
if (idType != IdType.NONE) {
|
||||
|
@ -55,7 +51,7 @@ public class IdTypeEnvironmentPostProcessor implements EnvironmentPostProcessor
|
|||
setIdType(environment, IdType.INPUT);
|
||||
return;
|
||||
}
|
||||
// 情况二,自增 ID,适合 MySQL 等直接自增的数据库
|
||||
// 情况二,自增 ID,适合 MySQL、DM 达梦等直接自增的数据库
|
||||
setIdType(environment, IdType.AUTO);
|
||||
}
|
||||
|
||||
|
@ -86,6 +82,10 @@ public class IdTypeEnvironmentPostProcessor implements EnvironmentPostProcessor
|
|||
case SQL_SERVER2005:
|
||||
driverClass = "org.quartz.impl.jdbcjobstore.MSSQLDelegate";
|
||||
break;
|
||||
case DM:
|
||||
case KINGBASE_ES:
|
||||
driverClass = "org.quartz.impl.jdbcjobstore.StdJDBCDelegate";
|
||||
break;
|
||||
}
|
||||
// 设置 driverClass 变量
|
||||
if (StrUtil.isNotEmpty(driverClass)) {
|
||||
|
|
|
@ -18,10 +18,17 @@ import java.util.stream.Collectors;
|
|||
@AllArgsConstructor
|
||||
public enum DbTypeEnum {
|
||||
|
||||
/**
|
||||
* H2
|
||||
*
|
||||
* 注意:H2 不支持 find_in_set 函数
|
||||
*/
|
||||
H2(DbType.H2, "H2", ""),
|
||||
|
||||
/**
|
||||
* MySQL
|
||||
*/
|
||||
MY_SQL( DbType.MYSQL, "MySQL", "FIND_IN_SET('#{value}', #{column}) <> 0"),
|
||||
MY_SQL(DbType.MYSQL, "MySQL", "FIND_IN_SET('#{value}', #{column}) <> 0"),
|
||||
|
||||
/**
|
||||
* Oracle
|
||||
|
@ -39,6 +46,10 @@ public enum DbTypeEnum {
|
|||
* SQL Server
|
||||
*/
|
||||
SQL_SERVER(DbType.SQL_SERVER, "Microsoft SQL Server", "CHARINDEX(',' + #{value} + ',', ',' + #{column} + ',') <> 0"),
|
||||
/**
|
||||
* SQL Server 2005
|
||||
*/
|
||||
SQL_SERVER2005(DbType.SQL_SERVER2005, "Microsoft SQL Server 2005", "CHARINDEX(',' + #{value} + ',', ',' + #{column} + ',') <> 0"),
|
||||
|
||||
/**
|
||||
* 达梦
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package cn.iocoder.yudao.framework.mybatis.core.enums;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
|
||||
/**
|
||||
* SQL相关常量类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public class SqlConstants {
|
||||
|
||||
/**
|
||||
* 数据库的类型
|
||||
*/
|
||||
public static DbType DB_TYPE;
|
||||
|
||||
public static void init(DbType dbType) {
|
||||
DB_TYPE = dbType;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortingField;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
|
@ -22,7 +22,6 @@ import org.apache.ibatis.annotations.Param;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 在 MyBatis Plus 的 BaseMapper 的基础上拓展,提供更多的能力
|
||||
|
@ -135,11 +134,6 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
|||
return selectList(new LambdaQueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default List<T> selectList(SFunction<T, ?> leField, SFunction<T, ?> geField, Object value) {
|
||||
return selectList(new LambdaQueryWrapper<T>().le(leField, value).ge(geField, value));
|
||||
}
|
||||
|
||||
default List<T> selectList(SFunction<T, ?> field1, Object value1, SFunction<T, ?> field2, Object value2) {
|
||||
return selectList(new LambdaQueryWrapper<T>().eq(field1, value1).eq(field2, value2));
|
||||
}
|
||||
|
@ -151,7 +145,8 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
|||
*/
|
||||
default Boolean insertBatch(Collection<T> entities) {
|
||||
// 特殊:SQL Server 批量插入后,获取 id 会报错,因此通过循环处理
|
||||
if (Objects.equals(SqlConstants.DB_TYPE, DbType.SQL_SERVER)) {
|
||||
DbType dbType = JdbcUtils.getDbType();
|
||||
if (JdbcUtils.isSQLServer(dbType)) {
|
||||
entities.forEach(this::insert);
|
||||
return CollUtil.isNotEmpty(entities);
|
||||
}
|
||||
|
@ -166,7 +161,8 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
|||
*/
|
||||
default Boolean insertBatch(Collection<T> entities, int size) {
|
||||
// 特殊:SQL Server 批量插入后,获取 id 会报错,因此通过循环处理
|
||||
if (Objects.equals(SqlConstants.DB_TYPE, DbType.SQL_SERVER)) {
|
||||
DbType dbType = JdbcUtils.getDbType();
|
||||
if (JdbcUtils.isSQLServer(dbType)) {
|
||||
entities.forEach(this::insert);
|
||||
return CollUtil.isNotEmpty(entities);
|
||||
}
|
||||
|
@ -185,10 +181,6 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
|||
return Db.updateBatchById(entities, size);
|
||||
}
|
||||
|
||||
default Boolean insertOrUpdateBatch(Collection<T> collection) {
|
||||
return Db.saveOrUpdateBatch(collection);
|
||||
}
|
||||
|
||||
default int delete(String field, String value) {
|
||||
return delete(new QueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package cn.iocoder.yudao.framework.mybatis.core.query;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
|
@ -147,8 +147,8 @@ public class QueryWrapperX<T> extends QueryWrapper<T> {
|
|||
* @return this
|
||||
*/
|
||||
public QueryWrapperX<T> limitN(int n) {
|
||||
Assert.notNull(SqlConstants.DB_TYPE, "获取不到数据库的类型");
|
||||
switch (SqlConstants.DB_TYPE) {
|
||||
DbType dbType = JdbcUtils.getDbType();
|
||||
switch (dbType) {
|
||||
case ORACLE:
|
||||
case ORACLE_12C:
|
||||
super.le("ROWNUM", n);
|
||||
|
@ -157,7 +157,7 @@ public class QueryWrapperX<T> extends QueryWrapper<T> {
|
|||
case SQL_SERVER2005:
|
||||
super.select("TOP " + n + " *"); // 由于 SQL Server 是通过 SELECT TOP 1 实现限制一条,所以只好使用 * 查询剩余字段
|
||||
break;
|
||||
default:
|
||||
default: // MySQL、PostgreSQL、DM 达梦、KingbaseES 大金都是采用 LIMIT 实现
|
||||
super.last("LIMIT " + n);
|
||||
}
|
||||
return this;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package cn.iocoder.yudao.framework.mybatis.core.util;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.spring.SpringUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.enums.DbTypeEnum;
|
||||
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
|
@ -49,8 +51,13 @@ public class JdbcUtils {
|
|||
* @return DB 类型
|
||||
*/
|
||||
public static DbType getDbType() {
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringUtils.getBean(DynamicRoutingDataSource.class);
|
||||
DataSource dataSource = dynamicRoutingDataSource.determineDataSource();
|
||||
DataSource dataSource;
|
||||
try {
|
||||
DynamicRoutingDataSource dynamicRoutingDataSource = SpringUtils.getBean(DynamicRoutingDataSource.class);
|
||||
dataSource = dynamicRoutingDataSource.determineDataSource();
|
||||
} catch (NoSuchBeanDefinitionException e) {
|
||||
dataSource = SpringUtils.getBean(DataSource.class);
|
||||
}
|
||||
try (Connection conn = dataSource.getConnection()) {
|
||||
return DbTypeEnum.find(conn.getMetaData().getDatabaseProductName());
|
||||
} catch (SQLException e) {
|
||||
|
@ -58,4 +65,25 @@ public class JdbcUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 JDBC 连接是否为 SQLServer 数据库
|
||||
*
|
||||
* @param url JDBC 连接
|
||||
* @return 是否为 SQLServer 数据库
|
||||
*/
|
||||
public static boolean isSQLServer(String url) {
|
||||
DbType dbType = getDbType(url);
|
||||
return isSQLServer(dbType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 JDBC 连接是否为 SQLServer 数据库
|
||||
*
|
||||
* @param dbType DB 类型
|
||||
* @return 是否为 SQLServer 数据库
|
||||
*/
|
||||
public static boolean isSQLServer(DbType dbType) {
|
||||
return ObjectUtils.equalsAny(dbType, DbType.SQL_SERVER, DbType.SQL_SERVER2005);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ public class MyBatisUtils {
|
|||
* @return sql
|
||||
*/
|
||||
public static String findInSet(String column, Object value) {
|
||||
// 这里不用SqlConstants.DB_TYPE,因为它是使用 primary 数据源的 url 推断出来的类型
|
||||
DbType dbType = JdbcUtils.getDbType();
|
||||
return DbTypeEnum.getFindInSetTemplate(dbType)
|
||||
.replace("#{column}", column)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package cn.iocoder.yudao.framework.security.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.security.core.aop.PreAuthenticatedAspect;
|
||||
import cn.iocoder.yudao.framework.security.core.context.TransmittableThreadLocalSecurityContextHolderStrategy;
|
||||
import cn.iocoder.yudao.framework.security.core.filter.TokenAuthenticationFilter;
|
||||
import cn.iocoder.yudao.framework.security.core.handler.AccessDeniedHandlerImpl;
|
||||
|
@ -38,14 +37,6 @@ public class YudaoSecurityAutoConfiguration {
|
|||
@Resource
|
||||
private SecurityProperties securityProperties;
|
||||
|
||||
/**
|
||||
* 处理用户未登录拦截的切面的 Bean
|
||||
*/
|
||||
@Bean
|
||||
public PreAuthenticatedAspect preAuthenticatedAspect() {
|
||||
return new PreAuthenticatedAspect();
|
||||
}
|
||||
|
||||
/**
|
||||
* 认证失败处理类 Bean
|
||||
*/
|
||||
|
|
|
@ -129,17 +129,15 @@ public class YudaoWebSecurityConfigurerAdapter {
|
|||
.authorizeHttpRequests(c -> c
|
||||
// 1.1 静态资源,可匿名访问
|
||||
.requestMatchers(HttpMethod.GET, "/*.html", "/*.html", "/*.css", "/*.js").permitAll()
|
||||
// 1.1 设置 @PermitAll 无需认证
|
||||
// 1.2 设置 @PermitAll 无需认证
|
||||
.requestMatchers(HttpMethod.GET, permitAllUrls.get(HttpMethod.GET).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.POST, permitAllUrls.get(HttpMethod.POST).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.PUT, permitAllUrls.get(HttpMethod.PUT).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.DELETE, permitAllUrls.get(HttpMethod.DELETE).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.HEAD, permitAllUrls.get(HttpMethod.HEAD).toArray(new String[0])).permitAll()
|
||||
.requestMatchers(HttpMethod.PATCH, permitAllUrls.get(HttpMethod.PATCH).toArray(new String[0])).permitAll()
|
||||
// 1.2 基于 yudao.security.permit-all-urls 无需认证
|
||||
// 1.3 基于 yudao.security.permit-all-urls 无需认证
|
||||
.requestMatchers(securityProperties.getPermitAllUrls().toArray(new String[0])).permitAll()
|
||||
// 1.3 设置 App API 无需认证
|
||||
.requestMatchers(buildAppApi("/**")).permitAll()
|
||||
)
|
||||
// ②:每个项目的自定义规则
|
||||
.authorizeHttpRequests(c -> authorizeRequestsCustomizers.forEach(customizer -> customizer.customize(c)))
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package cn.iocoder.yudao.framework.security.core.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 声明用户需要登录
|
||||
*
|
||||
* 为什么不使用 {@link org.springframework.security.access.prepost.PreAuthorize} 注解,原因是不通过时,抛出的是认证不通过,而不是未登录
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@Documented
|
||||
public @interface PreAuthenticated {
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package cn.iocoder.yudao.framework.security.core.aop;
|
||||
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.UNAUTHORIZED;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
|
||||
@Aspect
|
||||
@Slf4j
|
||||
public class PreAuthenticatedAspect {
|
||||
|
||||
@Around("@annotation(preAuthenticated)")
|
||||
public Object around(ProceedingJoinPoint joinPoint, PreAuthenticated preAuthenticated) throws Throwable {
|
||||
if (SecurityFrameworkUtils.getLoginUser() == null) {
|
||||
throw exception(UNAUTHORIZED);
|
||||
}
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package cn.iocoder.yudao.framework.test.core.ut;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
|
@ -44,6 +45,9 @@ public class BaseDbAndRedisUnitTest {
|
|||
YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
|
||||
RedisAutoConfiguration.class, // Spring Redis 自动配置类
|
||||
RedissonAutoConfiguration.class, // Redisson 自动配置类
|
||||
|
||||
// 其它配置类
|
||||
SpringUtil.class
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.iocoder.yudao.framework.test.core.ut;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.test.config.SqlInitializationTestConfiguration;
|
||||
|
@ -36,6 +37,9 @@ public class BaseDbUnitTest {
|
|||
YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类
|
||||
MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类
|
||||
MybatisPlusJoinAutoConfiguration.class, // MyBatis 的Join配置类
|
||||
|
||||
// 其它配置类
|
||||
SpringUtil.class
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.iocoder.yudao.framework.test.core.ut;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.test.config.RedisTestConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
|
@ -25,6 +26,9 @@ public class BaseRedisUnitTest {
|
|||
RedisAutoConfiguration.class, // Spring Redis 自动配置类
|
||||
YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
|
||||
RedissonAutoConfiguration.class, // Redisson 自动配置类
|
||||
|
||||
// 其它配置类
|
||||
SpringUtil.class
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
|
|
@ -134,6 +134,11 @@ public class RandomUtils {
|
|||
@SafeVarargs
|
||||
public static <T> List<T> randomPojoList(Class<T> clazz, Consumer<T>... consumers) {
|
||||
int size = RandomUtil.randomInt(1, RANDOM_COLLECTION_LENGTH);
|
||||
return randomPojoList(clazz, size, consumers);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <T> List<T> randomPojoList(Class<T> clazz, int size, Consumer<T>... consumers) {
|
||||
return Stream.iterate(0, i -> i).limit(size).map(o -> randomPojo(clazz, consumers))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class YudaoWebSocketAutoConfiguration {
|
|||
// ==================== Sender 相关 ====================
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "local", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "local")
|
||||
public class LocalWebSocketMessageSenderConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -96,7 +96,7 @@ public class YudaoWebSocketAutoConfiguration {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "redis", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "redis")
|
||||
public class RedisWebSocketMessageSenderConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -114,7 +114,7 @@ public class YudaoWebSocketAutoConfiguration {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "rocketmq", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "rocketmq")
|
||||
public class RocketMQWebSocketMessageSenderConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -133,7 +133,7 @@ public class YudaoWebSocketAutoConfiguration {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "rabbitmq", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "rabbitmq")
|
||||
public class RabbitMQWebSocketMessageSenderConfiguration {
|
||||
|
||||
@Bean
|
||||
|
@ -162,7 +162,7 @@ public class YudaoWebSocketAutoConfiguration {
|
|||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "kafka", matchIfMissing = true)
|
||||
@ConditionalOnProperty(prefix = "yudao.websocket", name = "sender-type", havingValue = "kafka")
|
||||
public class KafkaWebSocketMessageSenderConfiguration {
|
||||
|
||||
@Bean
|
||||
|
|
Binary file not shown.
|
@ -18,8 +18,8 @@ public class BpmProcessInstancePageReqVO extends PageParam {
|
|||
@Schema(description = "流程名称", example = "芋道")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "流程定义的编号", example = "2048")
|
||||
private String processDefinitionId;
|
||||
@Schema(description = "流程定义的标识", example = "2048")
|
||||
private String processDefinitionKey; // 精准匹配
|
||||
|
||||
@Schema(description = "流程实例的状态", example = "1")
|
||||
@InEnum(BpmProcessInstanceStatusEnum.class)
|
||||
|
|
|
@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModel
|
|||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
|
@ -51,18 +52,18 @@ public interface BpmModelConvert {
|
|||
}
|
||||
|
||||
default BpmModelRespVO buildModel(Model model,
|
||||
byte[] bpmnBytes) {
|
||||
byte[] bpmnBytes) {
|
||||
BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model);
|
||||
BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null);
|
||||
if (ArrayUtil.isNotEmpty(bpmnBytes)) {
|
||||
modelVO.setBpmnXml(new String(bpmnBytes));
|
||||
modelVO.setBpmnXml(BpmnModelUtils.getBpmnXml(bpmnBytes));
|
||||
}
|
||||
return modelVO;
|
||||
}
|
||||
|
||||
default BpmModelRespVO buildModel0(Model model,
|
||||
BpmModelMetaInfoRespDTO metaInfo, BpmFormDO form, BpmCategoryDO category,
|
||||
Deployment deployment, ProcessDefinition processDefinition) {
|
||||
BpmModelMetaInfoRespDTO metaInfo, BpmFormDO form, BpmCategoryDO category,
|
||||
Deployment deployment, ProcessDefinition processDefinition) {
|
||||
BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName())
|
||||
.setKey(model.getKey()).setCategory(model.getCategory())
|
||||
.setCreateTime(DateUtils.of(model.getCreateTime()));
|
||||
|
|
|
@ -48,8 +48,13 @@ public class BpmParallelMultiInstanceBehavior extends ParallelMultiInstanceBehav
|
|||
super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId());
|
||||
|
||||
// 第二步,获取任务的所有处理人
|
||||
Set<Long> assigneeUserIds = taskCandidateInvoker.calculateUsers(execution);
|
||||
execution.setVariable(super.collectionVariable, assigneeUserIds);
|
||||
// 由于每次审批(会签、或签等情况)后都会执行一次,所以 variable 已经有结果,不重复计算
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Long> assigneeUserIds = (Set<Long>) execution.getVariable(super.collectionVariable, Set.class);
|
||||
if (assigneeUserIds == null) {
|
||||
assigneeUserIds = taskCandidateInvoker.calculateUsers(execution);
|
||||
execution.setVariable(super.collectionVariable, assigneeUserIds);
|
||||
}
|
||||
return assigneeUserIds.size();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.flowable.engine.delegate.DelegateExecution;
|
|||
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
|
||||
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -42,8 +41,13 @@ public class BpmSequentialMultiInstanceBehavior extends SequentialMultiInstanceB
|
|||
super.collectionElementVariable = FlowableUtils.formatExecutionCollectionElementVariable(execution.getCurrentActivityId());
|
||||
|
||||
// 第二步,获取任务的所有处理人
|
||||
Set<Long> assigneeUserIds = new LinkedHashSet<>(taskCandidateInvoker.calculateUsers(execution)); // 保证有序!!!
|
||||
execution.setVariable(super.collectionVariable, assigneeUserIds);
|
||||
// 由于每次审批(会签、或签等情况)后都会执行一次,所以 variable 已经有结果,不重复计算
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Long> assigneeUserIds = (Set<Long>) execution.getVariable(super.collectionVariable, Set.class);
|
||||
if (assigneeUserIds == null) {
|
||||
assigneeUserIds = taskCandidateInvoker.calculateUsers(execution);
|
||||
execution.setVariable(super.collectionVariable, assigneeUserIds);
|
||||
}
|
||||
return assigneeUserIds.size();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
|
||||
import org.flowable.bpmn.converter.BpmnXMLConverter;
|
||||
|
@ -9,10 +10,7 @@ import org.flowable.bpmn.model.Process;
|
|||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.common.engine.impl.util.io.BytesStreamSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 流程模型转操作工具类
|
||||
|
@ -111,7 +109,14 @@ public class BpmnModelUtils {
|
|||
return null;
|
||||
}
|
||||
BpmnXMLConverter converter = new BpmnXMLConverter();
|
||||
return new String(converter.convertToXML(model));
|
||||
return StrUtil.utf8Str(converter.convertToXML(model));
|
||||
}
|
||||
|
||||
public static String getBpmnXml(byte[] bpmnBytes) {
|
||||
if (ArrayUtil.isEmpty(bpmnBytes)) {
|
||||
return null;
|
||||
}
|
||||
return StrUtil.utf8Str(bpmnBytes);
|
||||
}
|
||||
|
||||
// ========== 遍历相关的方法 ==========
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,16 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE = new ErrorCode(1_001_000_003, "不能删除类型为系统内置的参数配置");
|
||||
ErrorCode CONFIG_GET_VALUE_ERROR_IF_VISIBLE = new ErrorCode(1_001_000_004, "获取参数配置失败,原因:不允许获取不可见配置");
|
||||
|
||||
// ========== 定时任务 1-001-001-000 ==========
|
||||
ErrorCode JOB_NOT_EXISTS = new ErrorCode(1_001_001_000, "定时任务不存在");
|
||||
ErrorCode JOB_HANDLER_EXISTS = new ErrorCode(1_001_001_001, "定时任务的处理器已经存在");
|
||||
ErrorCode JOB_CHANGE_STATUS_INVALID = new ErrorCode(1_001_001_002, "只允许修改为开启或者关闭状态");
|
||||
ErrorCode JOB_CHANGE_STATUS_EQUALS = new ErrorCode(1_001_001_003, "定时任务已经处于该状态,无需修改");
|
||||
ErrorCode JOB_UPDATE_ONLY_NORMAL_STATUS = new ErrorCode(1_001_001_004, "只有开启状态的任务,才可以修改");
|
||||
ErrorCode JOB_CRON_EXPRESSION_VALID = new ErrorCode(1_001_001_005, "CRON 表达式不正确");
|
||||
ErrorCode JOB_HANDLER_BEAN_NOT_EXISTS = new ErrorCode(1_001_001_006, "定时任务的处理器 Bean 不存在,注意 Bean 默认首字母小写");
|
||||
ErrorCode JOB_HANDLER_BEAN_TYPE_ERROR = new ErrorCode(1_001_001_007, "定时任务的处理器 Bean 类型不正确,未实现 JobHandler 接口");
|
||||
|
||||
// ========== API 错误日志 1-001-002-000 ==========
|
||||
ErrorCode API_ERROR_LOG_NOT_FOUND = new ErrorCode(1_001_002_000, "API 错误日志不存在");
|
||||
ErrorCode API_ERROR_LOG_PROCESSED = new ErrorCode(1_001_002_001, "API 错误日志已处理");
|
||||
|
|
|
@ -2,19 +2,20 @@ package cn.iocoder.yudao.module.infra.controller.app.file;
|
|||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateReqVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
|
||||
import cn.iocoder.yudao.module.infra.controller.app.file.vo.AppFileUploadReqVO;
|
||||
import cn.iocoder.yudao.module.infra.service.file.FileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 文件存储")
|
||||
|
@ -29,10 +30,25 @@ public class AppFileController {
|
|||
|
||||
@PostMapping("/upload")
|
||||
@Operation(summary = "上传文件")
|
||||
@PermitAll
|
||||
public CommonResult<String> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
@GetMapping("/presigned-url")
|
||||
@Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
|
||||
@PermitAll
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception {
|
||||
return success(fileService.getFilePresignedUrl(path));
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件")
|
||||
@PermitAll
|
||||
public CommonResult<Long> createFile(@Valid @RequestBody FileCreateReqVO createReqVO) {
|
||||
return success(fileService.createFile(createReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public interface CodegenColumnMapper extends BaseMapperX<CodegenColumnDO> {
|
|||
default List<CodegenColumnDO> selectListByTableId(Long tableId) {
|
||||
return selectList(new LambdaQueryWrapperX<CodegenColumnDO>()
|
||||
.eq(CodegenColumnDO::getTableId, tableId)
|
||||
.orderByAsc(CodegenColumnDO::getId));
|
||||
.orderByAsc(CodegenColumnDO::getOrdinalPosition));
|
||||
}
|
||||
|
||||
default void deleteListByTableId(Long tableId) {
|
||||
|
|
|
@ -22,13 +22,14 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
@ -179,11 +180,18 @@ public class CodegenServiceImpl implements CodegenService {
|
|||
&& tableField.getMetaInfo().isNullable() == codegenColumn.getNullable()
|
||||
&& tableField.isKeyFlag() == codegenColumn.getPrimaryKey()
|
||||
&& tableField.getComment().equals(codegenColumn.getColumnComment());
|
||||
Set<String> modifyFieldNames = tableFields.stream()
|
||||
.filter(tableField -> codegenColumnDOMap.get(tableField.getColumnName()) != null
|
||||
&& !primaryKeyPredicate.test(tableField, codegenColumnDOMap.get(tableField.getColumnName())))
|
||||
.map(TableField::getColumnName)
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> modifyFieldNames = IntStream.range(0, tableFields.size()).mapToObj(index -> {
|
||||
TableField tableField = tableFields.get(index);
|
||||
String columnName = tableField.getColumnName();
|
||||
CodegenColumnDO codegenColumn = codegenColumnDOMap.get(columnName);
|
||||
if (codegenColumn == null) {
|
||||
return null;
|
||||
}
|
||||
if (!primaryKeyPredicate.test(tableField, codegenColumn) || codegenColumn.getOrdinalPosition() != index) {
|
||||
return columnName;
|
||||
}
|
||||
return null;
|
||||
}).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
// 3.2 计算需要【删除】的字段
|
||||
Set<String> tableFieldNames = convertSet(tableFields, TableField::getName);
|
||||
Set<Long> deleteColumnIds = codegenColumns.stream()
|
||||
|
|
|
@ -5,7 +5,6 @@ import cn.hutool.core.lang.Assert;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.JdbcUtils;
|
||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||
|
@ -18,7 +17,6 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -49,12 +47,11 @@ public class DatabaseTableServiceImpl implements DatabaseTableService {
|
|||
// 获得数据源配置
|
||||
DataSourceConfigDO config = dataSourceConfigService.getDataSourceConfig(dataSourceConfigId);
|
||||
Assert.notNull(config, "数据源({}) 不存在!", dataSourceConfigId);
|
||||
DbType dbType = JdbcUtils.getDbType(config.getUrl());
|
||||
|
||||
// 使用 MyBatis Plus Generator 解析表结构
|
||||
DataSourceConfig.Builder dataSourceConfigBuilder = new DataSourceConfig.Builder(config.getUrl(), config.getUsername(),
|
||||
config.getPassword());
|
||||
if (Objects.equals(dbType, DbType.SQL_SERVER)) { // 特殊:SQLServer jdbc 非标准,参见 https://github.com/baomidou/mybatis-plus/issues/5419
|
||||
if (JdbcUtils.isSQLServer(config.getUrl())) { // 特殊:SQLServer jdbc 非标准,参见 https://github.com/baomidou/mybatis-plus/issues/5419
|
||||
dataSourceConfigBuilder.databaseQueryClass(SQLQuery.class);
|
||||
}
|
||||
StrategyConfig.Builder strategyConfig = new StrategyConfig.Builder().enableSkipView(); // 忽略视图,业务上一般用不到
|
||||
|
|
|
@ -24,12 +24,11 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
|||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableField;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -235,17 +234,16 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO @芋艿:这个单测会随机性失败,需要定位下;
|
||||
public void testSyncCodegenFromDB() {
|
||||
// mock 数据(CodegenTableDO)
|
||||
CodegenTableDO table = randomPojo(CodegenTableDO.class, o -> o.setTableName("t_yunai")
|
||||
.setDataSourceConfigId(1L).setScene(CodegenSceneEnum.ADMIN.getScene()));
|
||||
codegenTableMapper.insert(table);
|
||||
CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())
|
||||
.setColumnName("id"));
|
||||
.setColumnName("id").setPrimaryKey(true).setOrdinalPosition(0));
|
||||
codegenColumnMapper.insert(column01);
|
||||
CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())
|
||||
.setColumnName("name"));
|
||||
.setColumnName("name").setOrdinalPosition(1));
|
||||
codegenColumnMapper.insert(column02);
|
||||
// 准备参数
|
||||
Long tableId = table.getId();
|
||||
|
@ -264,7 +262,7 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||
when(databaseTableService.getTable(eq(1L), eq("t_yunai")))
|
||||
.thenReturn(tableInfo);
|
||||
// mock 方法(CodegenTableDO)
|
||||
List<CodegenColumnDO> newColumns = randomPojoList(CodegenColumnDO.class);
|
||||
List<CodegenColumnDO> newColumns = randomPojoList(CodegenColumnDO.class, 2);
|
||||
when(codegenBuilder.buildColumns(eq(table.getId()), argThat(tableFields -> {
|
||||
assertEquals(2, tableFields.size());
|
||||
assertSame(tableInfo.getFields(), tableFields);
|
||||
|
@ -458,9 +456,11 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||
.setTemplateType(CodegenTemplateTypeEnum.ONE.getType()));
|
||||
codegenTableMapper.insert(table);
|
||||
// mock 数据(CodegenColumnDO)
|
||||
CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()));
|
||||
CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())
|
||||
.setOrdinalPosition(1));
|
||||
codegenColumnMapper.insert(column01);
|
||||
CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()));
|
||||
CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())
|
||||
.setOrdinalPosition(2));
|
||||
codegenColumnMapper.insert(column02);
|
||||
// mock 执行生成
|
||||
Map<String, String> codes = MapUtil.of(randomString(), randomString());
|
||||
|
@ -487,9 +487,11 @@ public class CodegenServiceImplTest extends BaseDbUnitTest {
|
|||
.setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType()));
|
||||
codegenTableMapper.insert(table);
|
||||
// mock 数据(CodegenColumnDO)
|
||||
CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()));
|
||||
CodegenColumnDO column01 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())
|
||||
.setOrdinalPosition(1));
|
||||
codegenColumnMapper.insert(column01);
|
||||
CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId()));
|
||||
CodegenColumnDO column02 = randomPojo(CodegenColumnDO.class, o -> o.setTableId(table.getId())
|
||||
.setOrdinalPosition(2));
|
||||
codegenColumnMapper.insert(column02);
|
||||
// mock 数据(sub CodegenTableDO)
|
||||
CodegenTableDO subTable = randomPojo(CodegenTableDO.class,
|
||||
|
|
|
@ -12,6 +12,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 商品 SPU")
|
||||
|
@ -24,6 +27,16 @@ public interface ProductSpuApi {
|
|||
@Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5")
|
||||
CommonResult<List<ProductSpuRespDTO>> getSpuList(@RequestParam("ids") Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 批量查询 SPU MAP
|
||||
*
|
||||
* @param ids SPU 编号列表
|
||||
* @return SPU MAP
|
||||
*/
|
||||
default Map<Long, ProductSpuRespDTO> getSpusMap(Collection<Long> ids) {
|
||||
return convertMap(getSpuList(ids).getCheckedData(), ProductSpuRespDTO::getId);
|
||||
}
|
||||
|
||||
@GetMapping(PREFIX + "/valid")
|
||||
@Schema(description = "批量查询 SPU 数组,并且校验是否 SPU 是否有效")
|
||||
@Parameter(name = "ids", description = "SPU 编号列表", required = true, example = "1,3,5")
|
||||
|
|
|
@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -33,6 +34,7 @@ public class AppCategoryController {
|
|||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得商品分类列表")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppCategoryRespVO>> getProductCategoryList() {
|
||||
List<ProductCategoryDO> list = categoryService.getEnableCategoryList();
|
||||
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
||||
|
@ -42,6 +44,7 @@ public class AppCategoryController {
|
|||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得商品分类列表,指定编号")
|
||||
@Parameter(name = "ids", description = "商品分类编号数组", required = true)
|
||||
@PermitAll
|
||||
public CommonResult<List<AppCategoryRespVO>> getProductCategoryList(@RequestParam("ids") List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return success(Collections.emptyList());
|
||||
|
|
|
@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -30,6 +31,7 @@ public class AppProductCommentController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商品评价分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppProductCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) {
|
||||
// 查询评论分页
|
||||
PageResult<ProductCommentDO> pageResult = productCommentService.getCommentPage(pageVO, Boolean.TRUE);
|
||||
|
|
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.product.controller.app.favorite;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoritePageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.favorite.vo.AppFavoriteRespVO;
|
||||
|
@ -36,14 +35,12 @@ public class AppFavoriteController {
|
|||
|
||||
@PostMapping(value = "/create")
|
||||
@Operation(summary = "添加商品收藏")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> createFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
|
||||
return success(productFavoriteService.createFavorite(getLoginUserId(), reqVO.getSpuId()));
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete")
|
||||
@Operation(summary = "取消单个商品收藏")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> deleteFavorite(@RequestBody @Valid AppFavoriteReqVO reqVO) {
|
||||
productFavoriteService.deleteFavorite(getLoginUserId(), reqVO.getSpuId());
|
||||
return success(Boolean.TRUE);
|
||||
|
@ -51,7 +48,6 @@ public class AppFavoriteController {
|
|||
|
||||
@GetMapping(value = "/page")
|
||||
@Operation(summary = "获得商品收藏分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppFavoriteRespVO>> getFavoritePage(AppFavoritePageReqVO reqVO) {
|
||||
PageResult<ProductFavoriteDO> favoritePage = productFavoriteService.getFavoritePage(getLoginUserId(), reqVO);
|
||||
if (CollUtil.isEmpty(favoritePage.getList())) {
|
||||
|
@ -71,7 +67,6 @@ public class AppFavoriteController {
|
|||
|
||||
@GetMapping(value = "/exits")
|
||||
@Operation(summary = "检查是否收藏过商品")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> isFavoriteExists(AppFavoriteReqVO reqVO) {
|
||||
ProductFavoriteDO favorite = productFavoriteService.getFavorite(getLoginUserId(), reqVO.getSpuId());
|
||||
return success(favorite != null);
|
||||
|
@ -79,7 +74,6 @@ public class AppFavoriteController {
|
|||
|
||||
@GetMapping(value = "/get-count")
|
||||
@Operation(summary = "获得商品收藏数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> getFavoriteCount() {
|
||||
return success(productFavoriteService.getFavoriteCount(getLoginUserId()));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryDeleteReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.history.vo.AppProductBrowseHistoryPageReqVO;
|
||||
|
@ -40,7 +39,6 @@ public class AppProductBrowseHistoryController {
|
|||
|
||||
@DeleteMapping(value = "/delete")
|
||||
@Operation(summary = "删除商品浏览记录")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> deleteBrowseHistory(@RequestBody @Valid AppProductBrowseHistoryDeleteReqVO reqVO) {
|
||||
productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), reqVO.getSpuIds());
|
||||
return success(Boolean.TRUE);
|
||||
|
@ -48,7 +46,6 @@ public class AppProductBrowseHistoryController {
|
|||
|
||||
@DeleteMapping(value = "/clean")
|
||||
@Operation(summary = "清空商品浏览记录")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> deleteBrowseHistory() {
|
||||
productBrowseHistoryService.hideUserBrowseHistory(getLoginUserId(), null);
|
||||
return success(Boolean.TRUE);
|
||||
|
@ -56,7 +53,6 @@ public class AppProductBrowseHistoryController {
|
|||
|
||||
@GetMapping(value = "/page")
|
||||
@Operation(summary = "获得商品浏览记录分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppProductBrowseHistoryRespVO>> getBrowseHistoryPage(AppProductBrowseHistoryPageReqVO reqVO) {
|
||||
ProductBrowseHistoryPageReqVO pageReqVO = BeanUtils.toBean(reqVO, ProductBrowseHistoryPageReqVO.class)
|
||||
.setUserId(getLoginUserId())
|
||||
|
|
|
@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.member.api.level.MemberLevelApi;
|
||||
import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO;
|
||||
|
@ -21,6 +17,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -51,14 +48,10 @@ public class AppProductSpuController {
|
|||
@Resource
|
||||
private ProductBrowseHistoryService productBrowseHistoryService;
|
||||
|
||||
@Resource
|
||||
private MemberLevelApi memberLevelApi;
|
||||
@Resource
|
||||
private MemberUserApi memberUserApi;
|
||||
|
||||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得商品 SPU 列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true)
|
||||
@PermitAll
|
||||
public CommonResult<List<AppProductSpuRespVO>> getSpuList(@RequestParam("ids") Set<Long> ids) {
|
||||
List<ProductSpuDO> list = productSpuService.getSpuList(ids);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
|
@ -68,14 +61,12 @@ public class AppProductSpuController {
|
|||
// 拼接返回
|
||||
list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
|
||||
List<AppProductSpuRespVO> voList = BeanUtils.toBean(list, AppProductSpuRespVO.class);
|
||||
// 处理 vip 价格
|
||||
MemberLevelRespDTO memberLevel = getMemberLevel();
|
||||
voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
|
||||
return success(voList);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得商品 SPU 分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppProductSpuRespVO>> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
|
||||
PageResult<ProductSpuDO> pageResult = productSpuService.getSpuPage(pageVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
|
@ -85,15 +76,13 @@ public class AppProductSpuController {
|
|||
// 拼接返回
|
||||
pageResult.getList().forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount()));
|
||||
PageResult<AppProductSpuRespVO> voPageResult = BeanUtils.toBean(pageResult, AppProductSpuRespVO.class);
|
||||
// 处理 vip 价格
|
||||
MemberLevelRespDTO memberLevel = getMemberLevel();
|
||||
voPageResult.getList().forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel)));
|
||||
return success(voPageResult);
|
||||
}
|
||||
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得商品 SPU 明细")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PermitAll
|
||||
public CommonResult<AppProductSpuDetailRespVO> getSpuDetail(@RequestParam("id") Long id) {
|
||||
// 获得商品 SPU
|
||||
ProductSpuDO spu = productSpuService.getSpu(id);
|
||||
|
@ -115,37 +104,7 @@ public class AppProductSpuController {
|
|||
spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount());
|
||||
AppProductSpuDetailRespVO spuVO = BeanUtils.toBean(spu, AppProductSpuDetailRespVO.class)
|
||||
.setSkus(BeanUtils.toBean(skus, AppProductSpuDetailRespVO.Sku.class));
|
||||
// 处理 vip 价格
|
||||
MemberLevelRespDTO memberLevel = getMemberLevel();
|
||||
spuVO.setVipPrice(calculateVipPrice(spuVO.getPrice(), memberLevel));
|
||||
return success(spuVO);
|
||||
}
|
||||
|
||||
private MemberLevelRespDTO getMemberLevel() {
|
||||
Long userId = getLoginUserId();
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
MemberUserRespDTO user = memberUserApi.getUser(userId).getCheckedData();
|
||||
if (user.getLevelId() == null || user.getLevelId() <= 0) {
|
||||
return null;
|
||||
}
|
||||
return memberLevelApi.getMemberLevel(user.getLevelId()).getCheckedData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算会员 VIP 优惠价格
|
||||
*
|
||||
* @param price 原价
|
||||
* @param memberLevel 会员等级
|
||||
* @return 优惠价格
|
||||
*/
|
||||
public Integer calculateVipPrice(Integer price, MemberLevelRespDTO memberLevel) {
|
||||
if (memberLevel == null || memberLevel.getDiscountPercent() == null) {
|
||||
return 0;
|
||||
}
|
||||
Integer newPrice = price * memberLevel.getDiscountPercent() / 100;
|
||||
return price - newPrice;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,9 +46,6 @@ public class AppProductSpuDetailRespVO {
|
|||
@Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格
|
||||
private Integer vipPrice;
|
||||
|
||||
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
private Integer stock;
|
||||
|
||||
|
|
|
@ -38,9 +38,6 @@ public class AppProductSpuRespVO {
|
|||
@Schema(description = "市场价,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "VIP 价格,单位使用:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "968") // 通过会员等级,计算出折扣后价格
|
||||
private Integer vipPrice;
|
||||
|
||||
@Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
|
||||
private Integer stock;
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ public interface ProductCategoryService {
|
|||
* 校验商品分类是否有效。如下情况,视为无效:
|
||||
* 1. 商品分类编号不存在
|
||||
* 2. 商品分类被禁用
|
||||
* 3. 商品分类层级校验,必须使用第二级的商品分类及以下
|
||||
*
|
||||
* @param ids 商品分类编号数组
|
||||
*/
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
|
@ -112,13 +113,19 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
|||
Map<Long, ProductCategoryDO> categoryMap = CollectionUtils.convertMap(list, ProductCategoryDO::getId);
|
||||
// 校验
|
||||
ids.forEach(id -> {
|
||||
// 校验分类是否存在
|
||||
ProductCategoryDO category = categoryMap.get(id);
|
||||
if (category == null) {
|
||||
throw exception(CATEGORY_NOT_EXISTS);
|
||||
}
|
||||
// 校验分类是否启用
|
||||
if (!CommonStatusEnum.ENABLE.getStatus().equals(category.getStatus())) {
|
||||
throw exception(CATEGORY_DISABLED, category.getName());
|
||||
}
|
||||
// 商品分类层级校验,必须使用第二级的商品分类
|
||||
if (getCategoryLevel(id) < CATEGORY_LEVEL) {
|
||||
throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,6 @@ public interface DiscountActivityApi {
|
|||
@GetMapping(PREFIX + "/list-by-sku-id")
|
||||
@Operation(summary = "获得商品匹配的的限时折扣信息")
|
||||
@Parameter(name = "skuIds", description = "商品 SKU 编号数组", required = true, example = "[1, 2]")
|
||||
CommonResult<List<DiscountProductRespDTO>> getMatchDiscountProductList(@RequestParam("skuIds") Collection<Long> skuIds);
|
||||
CommonResult<List<DiscountProductRespDTO>> getMatchDiscountProductListBySkuIds(@RequestParam("skuIds") Collection<Long> skuIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.promotion.api.discount.dto;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 限时折扣活动商品 Response DTO
|
||||
*
|
||||
|
@ -44,5 +46,13 @@ public class DiscountProductRespDTO {
|
|||
* 活动标题
|
||||
*/
|
||||
private String activityName;
|
||||
/**
|
||||
* 活动开始时间点
|
||||
*/
|
||||
private LocalDateTime activityStartTime;
|
||||
/**
|
||||
* 活动结束时间点
|
||||
*/
|
||||
private LocalDateTime activityEndTime;
|
||||
|
||||
}
|
||||
}
|
|
@ -22,6 +22,6 @@ public interface RewardActivityApi {
|
|||
@GetMapping(PREFIX + "/list-by-spu-id")
|
||||
@Operation(summary = "获得商品匹配的的满减送活动信息")
|
||||
@Parameter(name = "spuIds", description = "商品 SPU 编号数组", required = true, example = "[1, 2]")
|
||||
CommonResult<List<RewardActivityMatchRespDTO>> getMatchRewardActivityList(@RequestParam("spuIds") Collection<Long> spuIds);
|
||||
CommonResult<List<RewardActivityMatchRespDTO>> getMatchRewardActivityListBySpuIds(@RequestParam("spuIds") Collection<Long> spuIds);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ import java.util.Map;
|
|||
@Data
|
||||
public class RewardActivityMatchRespDTO {
|
||||
|
||||
/**
|
||||
* 匹配的 SPU 数组
|
||||
*/
|
||||
private List<Long> spuIds;
|
||||
|
||||
/**
|
||||
* 活动编号,主键自增
|
||||
*/
|
||||
|
@ -100,6 +105,13 @@ public class RewardActivityMatchRespDTO {
|
|||
*/
|
||||
private Map<Long, Integer> giveCouponTemplateCounts;
|
||||
|
||||
/**
|
||||
* 规则描述
|
||||
*
|
||||
* 通过 {@link #limit}、{@link #discountPrice} 等字段进行拼接
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public interface ErrorCodeConstants {
|
|||
|
||||
// ========== 促销活动相关 1-013-001-000 ============
|
||||
ErrorCode DISCOUNT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_001_000, "限时折扣活动不存在");
|
||||
ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_001_001, "存在商品参加了其它限时折扣活动");
|
||||
ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_001_001, "存在商品参加了其它限时折扣活动【{}】");
|
||||
ErrorCode DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_002, "限时折扣活动已关闭,不能修改");
|
||||
ErrorCode DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_001_003, "限时折扣活动未关闭,不能删除");
|
||||
ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_001_004, "限时折扣活动已关闭,不能重复关闭");
|
||||
|
@ -38,14 +38,18 @@ public interface ErrorCodeConstants {
|
|||
|
||||
// ========== 满减送活动 1-013-006-000 ==========
|
||||
ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_006_000, "满减送活动不存在");
|
||||
ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_006_001, "存在商品参加了其它满减送活动");
|
||||
ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_006_001, "该时间段存在商品参加了其它满减送活动");
|
||||
ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_002, "满减送活动已关闭,不能修改");
|
||||
ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1_013_006_003, "满减送活动未关闭,不能删除");
|
||||
ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_006_004, "满减送活动已关闭,不能重复关闭");
|
||||
ErrorCode REWARD_ACTIVITY_SCOPE_ALL_EXISTS = new ErrorCode(1_013_006_005, "已存在商品范围为全场的满减送活动");
|
||||
ErrorCode REWARD_ACTIVITY_SCOPE_CATEGORY_EXISTS = new ErrorCode(1_013_006_006, "存在商品类型参加了其它满减送活动");
|
||||
ErrorCode REWARD_ACTIVITY_SCOPE_EXISTS = new ErrorCode(1_013_006_005, "与该时间段满减送活动【{}】商品范围冲突,原因:{}");
|
||||
|
||||
// ========== TODO 空着 1-013-007-000 ============
|
||||
// ========== 积分商城活动 1-013-007-000 ==========
|
||||
ErrorCode POINT_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_007_000, "积分商城活动不存在");
|
||||
ErrorCode POINT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1_013_007_001, "存在商品参加了其它积分商城活动");
|
||||
ErrorCode POINT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_007_002, "积分商城活动已关闭,不能修改");
|
||||
ErrorCode POINT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1_013_007_003, "积分商城活动未关闭或未结束,不能删除");
|
||||
ErrorCode POINT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1_013_007_004, "积分商城活动已关闭,不能重复关闭");
|
||||
|
||||
// ========== 秒杀活动 1-013-008-000 ==========
|
||||
ErrorCode SECKILL_ACTIVITY_NOT_EXISTS = new ErrorCode(1_013_008_000, "秒杀活动不存在");
|
||||
|
|
|
@ -5,6 +5,7 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 优惠劵领取方式
|
||||
|
@ -20,12 +21,12 @@ public enum CouponTakeTypeEnum implements IntArrayValuable {
|
|||
REGISTER(3, "新人券"), // 注册时自动领取
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getValue).toArray();
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTakeTypeEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private final Integer value;
|
||||
private final Integer type;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
|
@ -35,4 +36,9 @@ public enum CouponTakeTypeEnum implements IntArrayValuable {
|
|||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static boolean isUser(Integer type) {
|
||||
return Objects.equals(USER.getType(), type);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package cn.iocoder.yudao.module.promotion.api.discount;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -26,8 +27,9 @@ public class DiscountActivityApiImpl implements DiscountActivityApi {
|
|||
private DiscountActivityService discountActivityService;
|
||||
|
||||
@Override
|
||||
public CommonResult<List<DiscountProductRespDTO>> getMatchDiscountProductList(Collection<Long> skuIds) {
|
||||
return success(DiscountActivityConvert.INSTANCE.convertList02(discountActivityService.getMatchDiscountProductList(skuIds)));
|
||||
public CommonResult<List<DiscountProductRespDTO>> getMatchDiscountProductListBySkuIds(Collection<Long> skuIds) {
|
||||
List<DiscountProductDO> list = discountActivityService.getMatchDiscountProductListBySkuIds(skuIds);
|
||||
return success(BeanUtils.toBean(list, DiscountProductRespDTO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public class RewardActivityApiImpl implements RewardActivityApi {
|
|||
private RewardActivityService rewardActivityService;
|
||||
|
||||
@Override
|
||||
public CommonResult<List<RewardActivityMatchRespDTO>> getMatchRewardActivityList(Collection<Long> spuIds) {
|
||||
return success(rewardActivityService.getMatchRewardActivityList(spuIds));
|
||||
public CommonResult<List<RewardActivityMatchRespDTO>> getMatchRewardActivityListBySpuIds(Collection<Long> spuIds) {
|
||||
return success(rewardActivityService.getMatchRewardActivityListBySpuIds(spuIds));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ package cn.iocoder.yudao.module.promotion.controller.admin.discount;
|
|||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
||||
|
@ -33,9 +34,6 @@ public class DiscountActivityController {
|
|||
@Resource
|
||||
private DiscountActivityService discountActivityService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建限时折扣活动")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:discount-activity:create')")
|
||||
|
@ -73,7 +71,7 @@ public class DiscountActivityController {
|
|||
@Operation(summary = "获得限时折扣活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')")
|
||||
public CommonResult<DiscountActivityDetailRespVO> getDiscountActivity(@RequestParam("id") Long id) {
|
||||
public CommonResult<DiscountActivityRespVO> getDiscountActivity(@RequestParam("id") Long id) {
|
||||
DiscountActivityDO discountActivity = discountActivityService.getDiscountActivity(id);
|
||||
if (discountActivity == null) {
|
||||
return success(null);
|
||||
|
@ -88,18 +86,14 @@ public class DiscountActivityController {
|
|||
@PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')")
|
||||
public CommonResult<PageResult<DiscountActivityRespVO>> getDiscountActivityPage(@Valid DiscountActivityPageReqVO pageVO) {
|
||||
PageResult<DiscountActivityDO> pageResult = discountActivityService.getDiscountActivityPage(pageVO);
|
||||
|
||||
if (CollUtil.isEmpty(pageResult.getList())) { // TODO @zhangshuai:方法里的空行,目的是让代码分块,可以更清晰;所以上面这个空格可以不要,而下面判断之后的,空格,其实加下比较好;类似的还有 spuList、以及后面的 convert
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 拼接数据
|
||||
List<DiscountProductDO> products = discountActivityService.getDiscountProductsByActivityId(
|
||||
convertSet(pageResult.getList(), DiscountActivityDO::getId));
|
||||
|
||||
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(
|
||||
convertSet(products, DiscountProductDO::getSpuId)).getCheckedData();
|
||||
|
||||
return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult, products, spuList));
|
||||
return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult, products));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 限时折扣活动的详细 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DiscountActivityDetailRespVO extends DiscountActivityRespVO {
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
private List<Product> products;
|
||||
|
||||
}
|
|
@ -25,25 +25,7 @@ public class DiscountActivityRespVO extends DiscountActivityBaseVO {
|
|||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2048") // TODO @zhangshuai:属性和属性之间,最多空一行噢;
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "限时折扣商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<DiscountActivityBaseVO.Product> products;
|
||||
|
||||
// ========== 商品字段 ==========
|
||||
|
||||
// TODO @zhangshuai:一个优惠活动,会关联多个商品,所以它不用返回 spuName 哈;
|
||||
// TODO 最终界面展示字段就:编号、活动名称、参与商品数、活动状态、开始时间、结束时间、操作
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
private List<Product> products;
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO {
|
|||
*/
|
||||
@NotEmpty(message = "商品列表不能为空")
|
||||
@Valid
|
||||
private List<DiscountActivityCreateReqVO.Product> products;
|
||||
private List<Product> products;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.point;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivitySaveReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.point.PointActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||
|
||||
@Tag(name = "管理后台 - 积分商城活动")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/point-activity")
|
||||
@Validated
|
||||
public class PointActivityController {
|
||||
|
||||
@Resource
|
||||
private PointActivityService pointActivityService;
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建积分商城活动")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:create')")
|
||||
public CommonResult<Long> createPointActivity(@Valid @RequestBody PointActivitySaveReqVO createReqVO) {
|
||||
return success(pointActivityService.createPointActivity(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新积分商城活动")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:update')")
|
||||
public CommonResult<Boolean> updatePointActivity(@Valid @RequestBody PointActivitySaveReqVO updateReqVO) {
|
||||
pointActivityService.updatePointActivity(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/close")
|
||||
@Operation(summary = "关闭积分商城活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:close')")
|
||||
public CommonResult<Boolean> closeSeckillActivity(@RequestParam("id") Long id) {
|
||||
pointActivityService.closePointActivity(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除积分商城活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:delete')")
|
||||
public CommonResult<Boolean> deletePointActivity(@RequestParam("id") Long id) {
|
||||
pointActivityService.deletePointActivity(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得积分商城活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:query')")
|
||||
public CommonResult<PointActivityRespVO> getPointActivity(@RequestParam("id") Long id) {
|
||||
PointActivityDO pointActivity = pointActivityService.getPointActivity(id);
|
||||
if (pointActivity == null) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(Collections.singletonList(id));
|
||||
PointActivityRespVO respVO = BeanUtils.toBean(pointActivity, PointActivityRespVO.class);
|
||||
respVO.setProducts(BeanUtils.toBean(products, PointProductRespVO.class));
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得积分商城活动分页")
|
||||
@PreAuthorize("@ss.hasPermission('promotion:point-activity:query')")
|
||||
public CommonResult<PageResult<PointActivityRespVO>> getPointActivityPage(@Valid PointActivityPageReqVO pageReqVO) {
|
||||
PageResult<PointActivityDO> pageResult = pointActivityService.getPointActivityPage(pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 拼接数据
|
||||
List<PointActivityRespVO> resultList = buildPointActivityRespVOList(pageResult.getList());
|
||||
return success(new PageResult<>(resultList, pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得积分商城活动列表,基于活动编号数组")
|
||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||
public CommonResult<List<PointActivityRespVO>> getPointActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
// 1. 获得开启的活动列表
|
||||
List<PointActivityDO> activityList = pointActivityService.getPointActivityListByIds(ids);
|
||||
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
||||
if (CollUtil.isEmpty(activityList)) {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
// 2. 拼接返回
|
||||
List<PointActivityRespVO> result = buildPointActivityRespVOList(activityList);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
private List<PointActivityRespVO> buildPointActivityRespVOList(List<PointActivityDO> activityList) {
|
||||
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
|
||||
convertSet(activityList, PointActivityDO::getId));
|
||||
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
||||
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
|
||||
convertSet(activityList, PointActivityDO::getSpuId));
|
||||
List<PointActivityRespVO> result = BeanUtils.toBean(activityList, PointActivityRespVO.class);
|
||||
result.forEach(activity -> {
|
||||
// 设置 product 信息
|
||||
PointProductDO minProduct = getMinObject(productsMap.get(activity.getId()), PointProductDO::getPoint);
|
||||
assert minProduct != null;
|
||||
activity.setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice());
|
||||
findAndThen(spuMap, activity.getSpuId(),
|
||||
spu -> activity.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
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 PointActivityPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "积分商城活动商品", example = "19509")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductRespVO;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城活动 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PointActivityRespVO {
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373")
|
||||
@ExcelProperty("积分商城活动编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509")
|
||||
@ExcelProperty("积分商城活动商品")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("活动状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "积分商城活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("积分商城活动库存")
|
||||
private Integer stock; // 剩余库存积分兑换时扣减
|
||||
|
||||
@Schema(description = "积分商城活动总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("积分商城活动总库存")
|
||||
private Integer totalStock;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "积分商城商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<PointProductRespVO> products;
|
||||
|
||||
// ========== 商品字段 ==========
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
//======================= 显示所需兑换积分最少的 sku 信息 =======================
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
private Integer price;
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product.PointProductSaveReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城活动新增/修改 Request VO")
|
||||
@Data
|
||||
public class PointActivitySaveReqVO {
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509")
|
||||
@NotNull(message = "积分商城活动商品不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "积分商城商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<PointProductSaveReqVO> products;
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城商品 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PointProductRespVO {
|
||||
|
||||
@Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29388")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8112")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "积分商城商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "积分商城商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer activityStatus;
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.admin.point.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城商品新增/修改 Request VO")
|
||||
@Data
|
||||
public class PointProductSaveReqVO {
|
||||
|
||||
@Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29388")
|
||||
@NotNull(message = "积分商城活动 id不能为空")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8112")
|
||||
@NotNull(message = "商品 SPU 编号不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736")
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926")
|
||||
@NotNull(message = "可兑换数量不能为空")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "兑换积分不能为空")
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
@NotNull(message = "兑换金额,单位:分不能为空")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "积分商城商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@NotNull(message = "积分商城商品不能为空")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "积分商城商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "积分商城商品状态不能为空")
|
||||
private Integer activityStatus;
|
||||
|
||||
}
|
|
@ -102,7 +102,7 @@ public class SeckillActivityController {
|
|||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得秒杀活动列表,基于活动编号数组")
|
||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||
public CommonResult<List<SeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
public CommonResult<List<SeckillActivityRespVO>> getSeckillActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
// 1. 获得开启的活动列表
|
||||
List<SeckillActivityDO> activityList = seckillActivityService.getSeckillActivityListByIds(ids);
|
||||
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
||||
|
|
|
@ -54,7 +54,7 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO {
|
|||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
@Schema(description = "拼团金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
@Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer seckillPrice; // 从 products 获取最小 price 读取
|
||||
|
||||
}
|
||||
|
|
|
@ -1,41 +1,29 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.app.activity;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.activity.vo.AppActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum;
|
||||
import cn.iocoder.yudao.module.promotion.service.bargain.BargainActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
|
||||
import cn.iocoder.yudao.module.promotion.service.seckill.SeckillActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
|
||||
@Tag(name = "用户 APP - 营销活动") // 用于提供跨多个活动的 HTTP 接口
|
||||
@RestController
|
||||
|
@ -49,152 +37,32 @@ public class AppActivityController {
|
|||
private SeckillActivityService seckillActivityService;
|
||||
@Resource
|
||||
private BargainActivityService bargainActivityService;
|
||||
@Resource
|
||||
private DiscountActivityService discountActivityService;
|
||||
@Resource
|
||||
private RewardActivityService rewardActivityService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@GetMapping("/list-by-spu-id")
|
||||
@Operation(summary = "获得单个商品,近期参与的每个活动")
|
||||
@Operation(summary = "获得单个商品,进行中的拼团、秒杀、砍价活动信息", description = "每种活动,只返回一个")
|
||||
@Parameter(name = "spuId", description = "商品编号", required = true)
|
||||
@PermitAll
|
||||
public CommonResult<List<AppActivityRespVO>> getActivityListBySpuId(@RequestParam("spuId") Long spuId) {
|
||||
// 每种活动,只返回一个
|
||||
return success(getAppActivityList(Collections.singletonList(spuId)));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-spu-ids")
|
||||
@Operation(summary = "获得多个商品,近期参与的每个活动")
|
||||
@Parameter(name = "spuIds", description = "商品编号数组", required = true)
|
||||
public CommonResult<Map<Long, List<AppActivityRespVO>>> getActivityListBySpuIds(@RequestParam("spuIds") List<Long> spuIds) {
|
||||
if (CollUtil.isEmpty(spuIds)) {
|
||||
return success(MapUtil.empty());
|
||||
}
|
||||
// 每种活动,只返回一个;key 为 SPU 编号
|
||||
return success(convertMultiMap(getAppActivityList(spuIds), AppActivityRespVO::getSpuId));
|
||||
}
|
||||
|
||||
private List<AppActivityRespVO> getAppActivityList(Collection<Long> spuIds) {
|
||||
if (CollUtil.isEmpty(spuIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
// 获取开启的且开始的且没有结束的活动
|
||||
List<AppActivityRespVO> activityList = new ArrayList<>();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<AppActivityRespVO> activityVOList = new ArrayList<>();
|
||||
// 1. 拼团活动
|
||||
getCombinationActivities(spuIds, now, activityList);
|
||||
CombinationActivityDO combinationActivity = combinationActivityService.getMatchCombinationActivityBySpuId(spuId);
|
||||
if (combinationActivity != null) {
|
||||
activityVOList.add(new AppActivityRespVO(combinationActivity.getId(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(),
|
||||
combinationActivity.getName(), combinationActivity.getSpuId(), combinationActivity.getStartTime(), combinationActivity.getEndTime()));
|
||||
}
|
||||
// 2. 秒杀活动
|
||||
getSeckillActivities(spuIds, now, activityList);
|
||||
SeckillActivityDO seckillActivity = seckillActivityService.getMatchSeckillActivityBySpuId(spuId);
|
||||
if (seckillActivity != null) {
|
||||
activityVOList.add(new AppActivityRespVO(seckillActivity.getId(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(),
|
||||
seckillActivity.getName(), seckillActivity.getSpuId(), seckillActivity.getStartTime(), seckillActivity.getEndTime()));
|
||||
}
|
||||
// 3. 砍价活动
|
||||
getBargainActivities(spuIds, now, activityList);
|
||||
// 4. 限时折扣活动
|
||||
getDiscountActivities(spuIds, now, activityList);
|
||||
// 5. 满减送活动
|
||||
getRewardActivityList(spuIds, now, activityList);
|
||||
return activityList;
|
||||
}
|
||||
|
||||
private void getCombinationActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
List<CombinationActivityDO> combinationActivities = combinationActivityService.getCombinationActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isEmpty(combinationActivities)) {
|
||||
return;
|
||||
}
|
||||
|
||||
combinationActivities.forEach(item -> {
|
||||
activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.COMBINATION_ACTIVITY.getType(),
|
||||
item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime()));
|
||||
});
|
||||
}
|
||||
|
||||
private void getSeckillActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
List<SeckillActivityDO> seckillActivities = seckillActivityService.getSeckillActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isEmpty(seckillActivities)) {
|
||||
return;
|
||||
}
|
||||
|
||||
seckillActivities.forEach(item -> {
|
||||
activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.SECKILL_ACTIVITY.getType(),
|
||||
item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime()));
|
||||
});
|
||||
}
|
||||
|
||||
private void getBargainActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
List<BargainActivityDO> bargainActivities = bargainActivityService.getBargainActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isNotEmpty(bargainActivities)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bargainActivities.forEach(item -> {
|
||||
activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(),
|
||||
item.getName(), item.getSpuId(), item.getStartTime(), item.getEndTime()));
|
||||
});
|
||||
}
|
||||
|
||||
private void getDiscountActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
List<DiscountActivityDO> discountActivities = discountActivityService.getDiscountActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isEmpty(discountActivities)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<DiscountProductDO> products = discountActivityService.getDiscountProductsByActivityId(
|
||||
convertSet(discountActivities, DiscountActivityDO::getId));
|
||||
Map<Long, Long> productMap = convertMap(products, DiscountProductDO::getActivityId, DiscountProductDO::getSpuId);
|
||||
discountActivities.forEach(item -> activityList.add(new AppActivityRespVO(item.getId(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(),
|
||||
item.getName(), productMap.get(item.getId()), item.getStartTime(), item.getEndTime())));
|
||||
}
|
||||
|
||||
private void getRewardActivityList(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
// 1.1 获得所有的活动
|
||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityListByStatusAndDateTimeLt(
|
||||
CommonStatusEnum.ENABLE.getStatus(), now);
|
||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
||||
return;
|
||||
}
|
||||
// 1.2 获得所有的商品信息
|
||||
List<ProductSpuRespDTO> spuList = productSpuApi.getSpuList(spuIds).getCheckedData();
|
||||
if (CollUtil.isEmpty(spuList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 构建活动
|
||||
for (RewardActivityDO rewardActivity : rewardActivityList) {
|
||||
// 情况一:所有商品都能参加
|
||||
if (PromotionProductScopeEnum.isAll(rewardActivity.getProductScope())) {
|
||||
buildAppActivityRespVO(rewardActivity, spuIds, activityList);
|
||||
}
|
||||
// 情况二:指定商品参加
|
||||
if (PromotionProductScopeEnum.isSpu(rewardActivity.getProductScope())) {
|
||||
List<Long> fSpuIds = spuList.stream().map(ProductSpuRespDTO::getId).filter(id ->
|
||||
rewardActivity.getProductScopeValues().contains(id)).toList();
|
||||
buildAppActivityRespVO(rewardActivity, fSpuIds, activityList);
|
||||
}
|
||||
// 情况三:指定商品类型参加
|
||||
if (PromotionProductScopeEnum.isCategory(rewardActivity.getProductScope())) {
|
||||
List<Long> fSpuIds = spuList.stream().filter(spuItem -> rewardActivity.getProductScopeValues()
|
||||
.contains(spuItem.getCategoryId())).map(ProductSpuRespDTO::getId).toList();
|
||||
buildAppActivityRespVO(rewardActivity, fSpuIds, activityList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildAppActivityRespVO(RewardActivityDO rewardActivity, Collection<Long> spuIds,
|
||||
List<AppActivityRespVO> activityList) {
|
||||
for (Long spuId : spuIds) {
|
||||
// 校验商品是否已经加入过活动
|
||||
if (anyMatch(activityList, appActivity -> ObjUtil.equal(appActivity.getId(), rewardActivity.getId()) &&
|
||||
ObjUtil.equal(appActivity.getSpuId(), spuId))) {
|
||||
continue;
|
||||
}
|
||||
activityList.add(new AppActivityRespVO(rewardActivity.getId(),
|
||||
PromotionTypeEnum.REWARD_ACTIVITY.getType(), rewardActivity.getName(), spuId,
|
||||
rewardActivity.getStartTime(), rewardActivity.getEndTime()));
|
||||
BargainActivityDO bargainActivity = bargainActivityService.getMatchBargainActivityBySpuId(spuId);
|
||||
if (bargainActivity != null) {
|
||||
activityVOList.add(new AppActivityRespVO(bargainActivity.getId(), PromotionTypeEnum.BARGAIN_ACTIVITY.getType(),
|
||||
bargainActivity.getName(), bargainActivity.getSpuId(), bargainActivity.getStartTime(), bargainActivity.getEndTime()));
|
||||
}
|
||||
return success(activityVOList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,13 +12,14 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
@ -38,6 +39,7 @@ public class AppArticleController {
|
|||
@Parameter(name = "recommendHot", description = "是否热门", example = "false"), // 场景一:查看指定的文章
|
||||
@Parameter(name = "recommendBanner", description = "是否轮播图", example = "false") // 场景二:查看指定的文章
|
||||
})
|
||||
@PermitAll
|
||||
public CommonResult<List<AppArticleRespVO>> getArticleList(
|
||||
@RequestParam(value = "recommendHot", required = false) Boolean recommendHot,
|
||||
@RequestParam(value = "recommendBanner", required = false) Boolean recommendBanner) {
|
||||
|
@ -47,6 +49,7 @@ public class AppArticleController {
|
|||
|
||||
@RequestMapping("/page")
|
||||
@Operation(summary = "获得文章详情分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppArticleRespVO>> getArticlePage(AppArticlePageReqVO pageReqVO) {
|
||||
return success(ArticleConvert.INSTANCE.convertPage02(articleService.getArticlePage(pageReqVO)));
|
||||
}
|
||||
|
@ -57,6 +60,7 @@ public class AppArticleController {
|
|||
@Parameter(name = "id", description = "文章编号", example = "1024"),
|
||||
@Parameter(name = "title", description = "文章标题", example = "1024"),
|
||||
})
|
||||
@PermitAll
|
||||
public CommonResult<AppArticleRespVO> getArticle(@RequestParam(value = "id", required = false) Long id,
|
||||
@RequestParam(value = "title", required = false) String title) {
|
||||
ArticleDO article = id != null ? articleService.getArticle(id)
|
||||
|
@ -67,6 +71,7 @@ public class AppArticleController {
|
|||
@PutMapping("/add-browse-count")
|
||||
@Operation(summary = "增加文章浏览量")
|
||||
@Parameter(name = "id", description = "文章编号", example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
|
||||
articleService.addArticleBrowseCount(id);
|
||||
return success(true);
|
||||
|
|
|
@ -8,10 +8,11 @@ import cn.iocoder.yudao.module.promotion.service.banner.BannerService;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
@ -28,6 +29,7 @@ public class AppBannerController {
|
|||
@GetMapping("/list")
|
||||
@Operation(summary = "获得 banner 列表")
|
||||
@Parameter(name = "position", description = "Banner position", example = "1")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppBannerRespVO>> getBannerList(@RequestParam("position") Integer position) {
|
||||
List<BannerDO> bannerList = bannerService.getBannerListByPosition(position);
|
||||
return success(BannerConvert.INSTANCE.convertList01(bannerList));
|
||||
|
@ -36,6 +38,7 @@ public class AppBannerController {
|
|||
@PutMapping("/add-browse-count")
|
||||
@Operation(summary = "增加 Banner 点击量")
|
||||
@Parameter(name = "id", description = "Banner 编号", example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<Boolean> addBrowseCount(@RequestParam("id") Long id) {
|
||||
bannerService.addBannerBrowseCount(id);
|
||||
return success(true);
|
||||
|
|
|
@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -31,7 +32,6 @@ import java.util.List;
|
|||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
|
||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildCache;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@Tag(name = "用户 App - 砍价活动")
|
||||
|
@ -43,7 +43,7 @@ public class AppBargainActivityController {
|
|||
/**
|
||||
* {@link AppBargainActivityRespVO} 缓存,通过它异步刷新 {@link #getBargainActivityList0(Integer)} 所要的首页数据
|
||||
*/
|
||||
private final LoadingCache<Integer, List<AppBargainActivityRespVO>> bargainActivityListCache = buildCache(Duration.ofSeconds(10L),
|
||||
private final LoadingCache<Integer, List<AppBargainActivityRespVO>> bargainActivityListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
|
||||
new CacheLoader<Integer, List<AppBargainActivityRespVO>>() {
|
||||
|
||||
@Override
|
||||
|
@ -64,6 +64,7 @@ public class AppBargainActivityController {
|
|||
@GetMapping("/list")
|
||||
@Operation(summary = "获得砍价活动列表", description = "用于小程序首页")
|
||||
@Parameter(name = "count", description = "需要展示的数量", example = "6")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppBargainActivityRespVO>> getBargainActivityList(
|
||||
@RequestParam(name = "count", defaultValue = "6") Integer count) {
|
||||
return success(bargainActivityListCache.getUnchecked(count));
|
||||
|
@ -81,6 +82,7 @@ public class AppBargainActivityController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得砍价活动分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppBargainActivityRespVO>> getBargainActivityPage(PageParam pageReqVO) {
|
||||
PageResult<BargainActivityDO> result = bargainActivityService.getBargainActivityPage(pageReqVO);
|
||||
if (CollUtil.isEmpty(result.getList())) {
|
||||
|
@ -94,6 +96,7 @@ public class AppBargainActivityController {
|
|||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得砍价活动详情")
|
||||
@Parameter(name = "id", description = "活动编号", example = "1")
|
||||
@PermitAll
|
||||
public CommonResult<AppBargainActivityDetailRespVO> getBargainActivityDetail(@RequestParam("id") Long id) {
|
||||
BargainActivityDO activity = bargainActivityService.getBargainActivity(id);
|
||||
if (activity == null) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import cn.hutool.core.lang.Assert;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
|
@ -28,6 +27,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -61,6 +61,7 @@ public class AppBargainRecordController {
|
|||
|
||||
@GetMapping("/get-summary")
|
||||
@Operation(summary = "获得砍价记录的概要信息", description = "用于小程序首页")
|
||||
@PermitAll
|
||||
public CommonResult<AppBargainRecordSummaryRespVO> getBargainRecordSummary() {
|
||||
// 砍价成功的用户数量
|
||||
Integer successUserCount = bargainRecordService.getBargainRecordUserCount(
|
||||
|
@ -86,6 +87,7 @@ public class AppBargainRecordController {
|
|||
@Parameter(name = "id", description = "砍价记录编号", example = "111"), // 场景一:查看指定的砍价记录
|
||||
@Parameter(name = "activityId", description = "砍价活动编号", example = "222") // 场景二:查看指定的砍价活动
|
||||
})
|
||||
@PermitAll
|
||||
public CommonResult<AppBargainRecordDetailRespVO> getBargainRecordDetail(
|
||||
@RequestParam(value = "id", required = false) Long id,
|
||||
@RequestParam(value = "activityId", required = false) Long activityId) {
|
||||
|
@ -153,7 +155,6 @@ public class AppBargainRecordController {
|
|||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建砍价记录", description = "参与砍价活动")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> createBargainRecord(@RequestBody AppBargainRecordCreateReqVO reqVO) {
|
||||
Long recordId = bargainRecordService.createBargainRecord(getLoginUserId(), reqVO);
|
||||
return success(recordId);
|
||||
|
|
|
@ -18,6 +18,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -44,6 +45,7 @@ public class AppCombinationActivityController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得拼团活动分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppCombinationActivityRespVO>> getCombinationActivityPage(PageParam pageParam) {
|
||||
PageResult<CombinationActivityDO> pageResult = activityService.getCombinationActivityPage(pageParam);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
|
@ -59,6 +61,7 @@ public class AppCombinationActivityController {
|
|||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得拼团活动列表,基于活动编号数组")
|
||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
// 1. 获得开启的活动列表
|
||||
List<CombinationActivityDO> activityList = activityService.getCombinationActivityListByIds(ids);
|
||||
|
@ -76,6 +79,7 @@ public class AppCombinationActivityController {
|
|||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得拼团活动明细")
|
||||
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppCombinationActivityDetailRespVO> getCombinationActivityDetail(@RequestParam("id") Long id) {
|
||||
// 1. 获取活动
|
||||
CombinationActivityDO activity = activityService.getCombinationActivity(id);
|
||||
|
|
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.controller.app.combination;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordDetailRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.record.AppCombinationRecordRespVO;
|
||||
|
@ -16,6 +15,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -43,6 +43,7 @@ public class AppCombinationRecordController {
|
|||
|
||||
@GetMapping("/get-summary")
|
||||
@Operation(summary = "获得拼团记录的概要信息", description = "用于小程序首页")
|
||||
@PermitAll
|
||||
public CommonResult<AppCombinationRecordSummaryRespVO> getCombinationRecordSummary() {
|
||||
AppCombinationRecordSummaryRespVO summary = new AppCombinationRecordSummaryRespVO();
|
||||
// 1. 获得拼团参与用户数量
|
||||
|
@ -68,6 +69,7 @@ public class AppCombinationRecordController {
|
|||
@Parameter(name = "status", description = "拼团状态"), // 对应 CombinationRecordStatusEnum 枚举
|
||||
@Parameter(name = "count", description = "数量")
|
||||
})
|
||||
@PermitAll
|
||||
public CommonResult<List<AppCombinationRecordRespVO>> getHeadCombinationRecordList(
|
||||
@RequestParam(value = "activityId", required = false) Long activityId,
|
||||
@RequestParam("status") Integer status,
|
||||
|
@ -78,7 +80,6 @@ public class AppCombinationRecordController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得我的拼团记录分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppCombinationRecordRespVO>> getCombinationRecordPage(
|
||||
@Valid AppCombinationRecordPageReqVO pageReqVO) {
|
||||
PageResult<CombinationRecordDO> pageResult = combinationRecordService.getCombinationRecordPage(
|
||||
|
@ -89,6 +90,7 @@ public class AppCombinationRecordController {
|
|||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得拼团记录明细")
|
||||
@Parameter(name = "id", description = "拼团记录编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppCombinationRecordDetailRespVO> getCombinationRecordDetail(@RequestParam("id") Long id) {
|
||||
// 1. 查找这条拼团记录
|
||||
CombinationRecordDO record = combinationRecordService.getCombinationRecordById(id);
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.coupon.vo.coupon.AppCouponTakeReqVO;
|
||||
|
@ -41,7 +40,6 @@ public class AppCouponController {
|
|||
@PostMapping("/take")
|
||||
@Operation(summary = "领取优惠劵")
|
||||
@Parameter(name = "templateId", description = "优惠券模板编号", required = true, example = "1024")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> takeCoupon(@Valid @RequestBody AppCouponTakeReqVO reqVO) {
|
||||
// 1. 领取优惠劵
|
||||
Long userId = getLoginUserId();
|
||||
|
@ -59,7 +57,6 @@ public class AppCouponController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "我的优惠劵列表")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppCouponRespVO>> getCouponPage(AppCouponPageReqVO pageReqVO) {
|
||||
PageResult<CouponDO> pageResult = couponService.getCouponPage(
|
||||
CouponConvert.INSTANCE.convert(pageReqVO, Collections.singleton(getLoginUserId())));
|
||||
|
@ -69,7 +66,6 @@ public class AppCouponController {
|
|||
@GetMapping("/get")
|
||||
@Operation(summary = "获得优惠劵")
|
||||
@Parameter(name = "id", description = "优惠劵编号", required = true, example = "1024")
|
||||
@PreAuthenticated
|
||||
public CommonResult<AppCouponRespVO> getCoupon(@RequestParam("id") Long id) {
|
||||
CouponDO coupon = couponService.getCoupon(getLoginUserId(), id);
|
||||
return success(BeanUtils.toBean(coupon, AppCouponRespVO.class));
|
||||
|
@ -77,7 +73,6 @@ public class AppCouponController {
|
|||
|
||||
@GetMapping(value = "/get-unused-count")
|
||||
@Operation(summary = "获得未使用的优惠劵数量")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> getUnusedCouponCount() {
|
||||
return success(couponService.getUnusedCouponCount(getLoginUserId()));
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -51,6 +52,7 @@ public class AppCouponTemplateController {
|
|||
@GetMapping("/get")
|
||||
@Operation(summary = "获得优惠劵模版")
|
||||
@Parameter(name = "id", description = "优惠券模板编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppCouponTemplateRespVO> getCouponTemplate(Long id) {
|
||||
CouponTemplateDO template = couponTemplateService.getCouponTemplate(id);
|
||||
if (template == null) {
|
||||
|
@ -69,6 +71,7 @@ public class AppCouponTemplateController {
|
|||
@Parameter(name = "productScope", description = "使用类型"),
|
||||
@Parameter(name = "count", description = "数量", required = true)
|
||||
})
|
||||
@PermitAll
|
||||
public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(
|
||||
@RequestParam(value = "spuId", required = false) Long spuId,
|
||||
@RequestParam(value = "productScope", required = false) Integer productScope,
|
||||
|
@ -76,7 +79,7 @@ public class AppCouponTemplateController {
|
|||
// 1.1 处理查询条件:商品范围编号
|
||||
Long productScopeValue = getProductScopeValue(productScope, spuId);
|
||||
// 1.2 处理查询条件:领取方式 = 直接领取
|
||||
List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue());
|
||||
List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getType());
|
||||
|
||||
// 2. 查询
|
||||
List<CouponTemplateDO> list = couponTemplateService.getCouponTemplateList(canTakeTypes, productScope,
|
||||
|
@ -91,6 +94,7 @@ public class AppCouponTemplateController {
|
|||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得优惠劵模版列表")
|
||||
@Parameter(name = "ids", description = "优惠券模板编号列表")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppCouponTemplateRespVO>> getCouponTemplateList(
|
||||
@RequestParam(value = "ids", required = false) Set<Long> ids) {
|
||||
// 1. 查询
|
||||
|
@ -104,11 +108,12 @@ public class AppCouponTemplateController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得优惠劵模版分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppCouponTemplateRespVO>> getCouponTemplatePage(AppCouponTemplatePageReqVO pageReqVO) {
|
||||
// 1.1 处理查询条件:商品范围编号
|
||||
Long productScopeValue = getProductScopeValue(pageReqVO.getProductScope(), pageReqVO.getSpuId());
|
||||
// 1.2 处理查询条件:领取方式 = 直接领取
|
||||
List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getValue());
|
||||
List<Integer> canTakeTypes = singletonList(CouponTakeTypeEnum.USER.getType());
|
||||
|
||||
// 2. 分页查询
|
||||
PageResult<CouponTemplateDO> pageResult = couponTemplateService.getCouponTemplatePage(
|
||||
|
|
|
@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -29,6 +30,7 @@ public class AppDiyPageController {
|
|||
@GetMapping("/get")
|
||||
@Operation(summary = "获得装修页面")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppDiyPagePropertyRespVO> getDiyPage(@RequestParam("id") Long id) {
|
||||
DiyPageDO diyPage = diyPageService.getDiyPage(id);
|
||||
return success(BeanUtils.toBean(diyPage, AppDiyPagePropertyRespVO.class));
|
||||
|
|
|
@ -12,6 +12,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -37,6 +38,7 @@ public class AppDiyTemplateController {
|
|||
// TODO @疯狂:要不要把 used 和 get 接口合并哈;不传递 id,直接拿默认;
|
||||
@GetMapping("/used")
|
||||
@Operation(summary = "使用中的装修模板")
|
||||
@PermitAll
|
||||
public CommonResult<AppDiyTemplatePropertyRespVO> getUsedDiyTemplate() {
|
||||
DiyTemplateDO diyTemplate = diyTemplateService.getUsedDiyTemplate();
|
||||
return success(buildVo(diyTemplate));
|
||||
|
@ -45,6 +47,7 @@ public class AppDiyTemplateController {
|
|||
@GetMapping("/get")
|
||||
@Operation(summary = "获得装修模板")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppDiyTemplatePropertyRespVO> getDiyTemplate(@RequestParam("id") Long id) {
|
||||
DiyTemplateDO diyTemplate = diyTemplateService.getDiyTemplate(id);
|
||||
return success(buildVo(diyTemplate));
|
||||
|
|
|
@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
|||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessagePageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.kefu.vo.message.AppKeFuMessageSendReqVO;
|
||||
|
@ -32,7 +31,6 @@ public class AppKeFuMessageController {
|
|||
|
||||
@PostMapping("/send")
|
||||
@Operation(summary = "发送客服消息")
|
||||
@PreAuthenticated
|
||||
public CommonResult<Long> sendKefuMessage(@Valid @RequestBody AppKeFuMessageSendReqVO sendReqVO) {
|
||||
sendReqVO.setSenderId(getLoginUserId()).setSenderType(UserTypeEnum.MEMBER.getValue()); // 设置用户编号和类型
|
||||
return success(kefuMessageService.sendKefuMessage(sendReqVO));
|
||||
|
@ -41,7 +39,6 @@ public class AppKeFuMessageController {
|
|||
@PutMapping("/update-read-status")
|
||||
@Operation(summary = "更新客服消息已读状态")
|
||||
@Parameter(name = "conversationId", description = "会话编号", required = true)
|
||||
@PreAuthenticated
|
||||
public CommonResult<Boolean> updateKefuMessageReadStatus(@RequestParam("conversationId") Long conversationId) {
|
||||
kefuMessageService.updateKeFuMessageReadStatus(conversationId, getLoginUserId(), UserTypeEnum.MEMBER.getValue());
|
||||
return success(true);
|
||||
|
@ -49,7 +46,6 @@ public class AppKeFuMessageController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客服消息分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid AppKeFuMessagePageReqVO pageReqVO) {
|
||||
PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessagePage(pageReqVO, getLoginUserId());
|
||||
return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class));
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.app.point;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.point.vo.AppPointActivityDetailRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.point.vo.AppPointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.point.vo.AppPointActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.point.PointActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||
|
||||
@Tag(name = "用户 App - 积分商城活动")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/point-activity")
|
||||
@Validated
|
||||
public class AppPointActivityController {
|
||||
|
||||
@Resource
|
||||
private PointActivityService pointActivityService;
|
||||
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得积分商城活动分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppPointActivityRespVO>> getPointActivityPage(AppPointActivityPageReqVO pageReqVO) {
|
||||
// 1. 查询满足当前阶段的活动
|
||||
PageResult<PointActivityDO> pageResult = pointActivityService.getPointActivityPage(
|
||||
BeanUtils.toBean(pageReqVO, PointActivityPageReqVO.class));
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty(pageResult.getTotal()));
|
||||
}
|
||||
|
||||
// 2. 拼接数据
|
||||
List<AppPointActivityRespVO> resultList = buildAppPointActivityRespVOList(pageResult.getList());
|
||||
return success(new PageResult<>(resultList, pageResult.getTotal()));
|
||||
}
|
||||
|
||||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得积分商城活动明细")
|
||||
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppPointActivityDetailRespVO> getPointActivity(@RequestParam("id") Long id) {
|
||||
// 1. 获取活动
|
||||
PointActivityDO activity = pointActivityService.getPointActivity(id);
|
||||
if (activity == null
|
||||
|| ObjUtil.equal(activity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
|
||||
return success(null);
|
||||
}
|
||||
|
||||
// 2. 拼接数据
|
||||
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(Collections.singletonList(id));
|
||||
AppPointActivityDetailRespVO respVO = BeanUtils.toBean(activity, AppPointActivityDetailRespVO.class);
|
||||
respVO.setProducts(BeanUtils.toBean(products, AppPointActivityDetailRespVO.Product.class));
|
||||
return success(respVO);
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得积分商城活动列表,基于活动编号数组")
|
||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppPointActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
// 1. 获得开启的活动列表
|
||||
List<PointActivityDO> activityList = pointActivityService.getPointActivityListByIds(ids);
|
||||
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
||||
if (CollUtil.isEmpty(activityList)) {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
// 2. 拼接返回
|
||||
List<AppPointActivityRespVO> result = buildAppPointActivityRespVOList(activityList);
|
||||
return success(result);
|
||||
}
|
||||
|
||||
private List<AppPointActivityRespVO> buildAppPointActivityRespVOList(List<PointActivityDO> activityList) {
|
||||
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
|
||||
convertSet(activityList, PointActivityDO::getId));
|
||||
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
||||
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
|
||||
convertSet(activityList, PointActivityDO::getSpuId));
|
||||
List<AppPointActivityRespVO> result = BeanUtils.toBean(activityList, AppPointActivityRespVO.class);
|
||||
result.forEach(activity -> {
|
||||
// 设置 product 信息
|
||||
PointProductDO minProduct = getMinObject(productsMap.get(activity.getId()), PointProductDO::getPoint);
|
||||
assert minProduct != null;
|
||||
activity.setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice());
|
||||
findAndThen(spuMap, activity.getSpuId(),
|
||||
spu -> activity.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.app.point.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 积分商城活动的详细 Response VO")
|
||||
@Data
|
||||
public class AppPointActivityDetailRespVO {
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "积分商城活动库存(剩余库存积分兑换时扣减)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "积分商城活动总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer totalStock;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "商品信息数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<Product> products;
|
||||
|
||||
@Schema(description = "商品信息")
|
||||
@Data
|
||||
public static class Product {
|
||||
|
||||
@Schema(description = "积分商城商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31718")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2736")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "可兑换数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "3926")
|
||||
private Integer count;
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
private Integer price;
|
||||
|
||||
@Schema(description = "积分商城商品库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer stock;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.app.point.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "用户 App - 积分商城活动分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppPointActivityPageReqVO extends PageParam {
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package cn.iocoder.yudao.module.promotion.controller.app.point.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "用户 App - 积分商城活动 Response VO")
|
||||
@Data
|
||||
public class AppPointActivityRespVO {
|
||||
|
||||
@Schema(description = "积分商城活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11373")
|
||||
@ExcelProperty("积分商城活动编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "积分商城活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "19509")
|
||||
@ExcelProperty("积分商城活动商品")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("活动状态")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "积分商城活动库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("积分商城活动库存")
|
||||
private Integer stock; // 剩余库存积分兑换时扣减
|
||||
|
||||
@Schema(description = "积分商城活动总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("积分商城活动总库存")
|
||||
private Integer totalStock;
|
||||
|
||||
// TODO @puhui999:只返回必要的字段,例如说 remark、sort、createTime 应该是不需要的呢。也可以看看别的也不需要哈。
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// ========== 商品字段 ==========
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取
|
||||
example = "618大促")
|
||||
private String spuName;
|
||||
@Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取
|
||||
example = "https://www.iocoder.cn/xx.png")
|
||||
private String picUrl;
|
||||
@Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取
|
||||
example = "50")
|
||||
private Integer marketPrice;
|
||||
|
||||
//======================= 显示所需兑换积分最少的 sku 信息 =======================
|
||||
|
||||
@Schema(description = "兑换积分", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer point;
|
||||
|
||||
@Schema(description = "兑换金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "15860")
|
||||
private Integer price;
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -29,9 +30,20 @@ public class AppRewardActivityController {
|
|||
@GetMapping("/get")
|
||||
@Operation(summary = "获得满减送活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppRewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
|
||||
RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
|
||||
return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class));
|
||||
RewardActivityDO activity = rewardActivityService.getRewardActivity(id);
|
||||
if (activity == null) {
|
||||
return success(null);
|
||||
}
|
||||
// 拼接 Rule 描述
|
||||
AppRewardActivityRespVO activityVO = BeanUtils.toBean(activity, AppRewardActivityRespVO.class);
|
||||
for (int i = 0; i < activityVO.getRules().size(); i++) {
|
||||
AppRewardActivityRespVO.Rule ruleVO = activityVO.getRules().get(i);
|
||||
RewardActivityDO.Rule rule = activity.getRules().get(i);
|
||||
ruleVO.setDescription(rewardActivityService.getRewardActivityRuleDescription(activity.getConditionType(), rule));
|
||||
}
|
||||
return success(activityVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivi
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 满减送活动 Response VO")
|
||||
|
@ -19,6 +20,12 @@ public class AppRewardActivityRespVO {
|
|||
@Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer conditionType;
|
||||
|
||||
|
@ -26,9 +33,18 @@ public class AppRewardActivityRespVO {
|
|||
private Integer productScope;
|
||||
|
||||
@Schema(description = "商品 SPU 编号的数组", example = "1,2,3")
|
||||
private List<Long> productSpuIds;
|
||||
private List<Long> productScopeValues;
|
||||
|
||||
@Schema(description = "优惠规则的数组")
|
||||
private List<RewardActivityBaseVO.Rule> rules;
|
||||
private List<Rule> rules;
|
||||
|
||||
@Schema(description = "优惠规则")
|
||||
@Data
|
||||
public static class Rule extends RewardActivityBaseVO.Rule {
|
||||
|
||||
@Schema(description = "规则描述")
|
||||
private String description; // 通过 {@link #limit}、{@link #discountPrice} 等字段进行拼接
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -74,6 +75,7 @@ public class AppSeckillActivityController {
|
|||
|
||||
@GetMapping("/get-now")
|
||||
@Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用")
|
||||
@PermitAll
|
||||
public CommonResult<AppSeckillActivityNowRespVO> getNowSeckillActivity() {
|
||||
return success(nowSeckillActivityCache.getUnchecked("")); // 缓存
|
||||
}
|
||||
|
@ -96,6 +98,7 @@ public class AppSeckillActivityController {
|
|||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得秒杀活动分页")
|
||||
@PermitAll
|
||||
public CommonResult<PageResult<AppSeckillActivityRespVO>> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) {
|
||||
// 1. 查询满足当前阶段的活动
|
||||
PageResult<SeckillActivityDO> pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO);
|
||||
|
@ -113,6 +116,7 @@ public class AppSeckillActivityController {
|
|||
@GetMapping("/get-detail")
|
||||
@Operation(summary = "获得秒杀活动明细")
|
||||
@Parameter(name = "id", description = "活动编号", required = true, example = "1024")
|
||||
@PermitAll
|
||||
public CommonResult<AppSeckillActivityDetailRespVO> getSeckillActivity(@RequestParam("id") Long id) {
|
||||
// 1. 获取活动
|
||||
SeckillActivityDO activity = activityService.getSeckillActivity(id);
|
||||
|
@ -151,8 +155,9 @@ public class AppSeckillActivityController {
|
|||
}
|
||||
|
||||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得拼团活动列表,基于活动编号数组")
|
||||
@Operation(summary = "获得秒杀活动列表,基于活动编号数组")
|
||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppSeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
// 1. 获得开启的活动列表
|
||||
List<SeckillActivityDO> activityList = activityService.getSeckillActivityListByIds(ids);
|
||||
|
|
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.promotion.service.seckill.SeckillConfigService;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -28,6 +29,7 @@ public class AppSeckillConfigController {
|
|||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得秒杀时间段列表")
|
||||
@PermitAll
|
||||
public CommonResult<List<AppSeckillConfigRespVO>> getSeckillConfigList() {
|
||||
List<SeckillConfigDO> list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
return success(SeckillConfigConvert.INSTANCE.convertList2(list));
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
package cn.iocoder.yudao.module.promotion.convert.discount;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.api.discount.dto.DiscountProductRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.*;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 限时折扣活动 Convert
|
||||
|
@ -33,105 +30,22 @@ public interface DiscountActivityConvert {
|
|||
DiscountActivityRespVO convert(DiscountActivityDO bean);
|
||||
|
||||
List<DiscountActivityRespVO> convertList(List<DiscountActivityDO> list);
|
||||
List<DiscountActivityBaseVO.Product> convertList2(List<DiscountProductDO> list);
|
||||
|
||||
List<DiscountProductRespDTO> convertList02(List<DiscountProductDO> list);
|
||||
List<DiscountActivityBaseVO.Product> convertList2(List<DiscountProductDO> list);
|
||||
|
||||
PageResult<DiscountActivityRespVO> convertPage(PageResult<DiscountActivityDO> page);
|
||||
|
||||
default PageResult<DiscountActivityRespVO> convertPage(PageResult<DiscountActivityDO> page,
|
||||
List<DiscountProductDO> discountProductDOList,
|
||||
List<ProductSpuRespDTO> spuList) {
|
||||
List<DiscountProductDO> discountProductDOList) {
|
||||
PageResult<DiscountActivityRespVO> pageResult = convertPage(page);
|
||||
|
||||
// 拼接商品 TODO @zhangshuai:类似空行的问题,也可以看看
|
||||
Map<Long, DiscountProductDO> discountActivityMap = CollectionUtils.convertMap(discountProductDOList, DiscountProductDO::getActivityId);
|
||||
Map<Long, ProductSpuRespDTO> spuMap = CollectionUtils.convertMap(spuList, ProductSpuRespDTO::getId);
|
||||
pageResult.getList().forEach(item -> {
|
||||
item.setProducts(convertList2(discountProductDOList));
|
||||
item.setSpuId(discountActivityMap.get(item.getId())==null?null: discountActivityMap.get(item.getId()).getSpuId());
|
||||
if (item.getSpuId() != null) {
|
||||
MapUtils.findAndThen(spuMap, item.getSpuId(),
|
||||
spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||
}
|
||||
|
||||
});
|
||||
pageResult.getList().forEach(item -> item.setProducts(convertList2(discountProductDOList)));
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
DiscountProductDO convert(DiscountActivityBaseVO.Product bean);
|
||||
|
||||
default DiscountActivityDetailRespVO convert(DiscountActivityDO activity, List<DiscountProductDO> products){
|
||||
if ( activity == null && products == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DiscountActivityDetailRespVO discountActivityDetailRespVO = new DiscountActivityDetailRespVO();
|
||||
|
||||
if ( activity != null ) {
|
||||
discountActivityDetailRespVO.setName( activity.getName() );
|
||||
discountActivityDetailRespVO.setStartTime( activity.getStartTime() );
|
||||
discountActivityDetailRespVO.setEndTime( activity.getEndTime() );
|
||||
discountActivityDetailRespVO.setRemark( activity.getRemark() );
|
||||
discountActivityDetailRespVO.setId( activity.getId() );
|
||||
discountActivityDetailRespVO.setStatus( activity.getStatus() );
|
||||
discountActivityDetailRespVO.setCreateTime( activity.getCreateTime() );
|
||||
}
|
||||
if (!products.isEmpty()) {
|
||||
discountActivityDetailRespVO.setSpuId(products.get(0).getSpuId());
|
||||
}
|
||||
discountActivityDetailRespVO.setProducts( convertList2( products ) );
|
||||
|
||||
return discountActivityDetailRespVO;
|
||||
default DiscountActivityRespVO convert(DiscountActivityDO activity, List<DiscountProductDO> products) {
|
||||
return BeanUtils.toBean(activity, DiscountActivityRespVO.class).setProducts(convertList2(products));
|
||||
}
|
||||
|
||||
// =========== 比较是否相等 ==========
|
||||
/**
|
||||
* 比较两个限时折扣商品是否相等
|
||||
*
|
||||
* @param productDO 数据库中的商品
|
||||
* @param productVO 前端传入的商品
|
||||
* @return 是否匹配
|
||||
*/
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
default boolean isEquals(DiscountProductDO productDO, DiscountActivityBaseVO.Product productVO) {
|
||||
if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId())
|
||||
|| ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId())
|
||||
|| ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) {
|
||||
return false;
|
||||
}
|
||||
if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) {
|
||||
return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice());
|
||||
}
|
||||
if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) {
|
||||
return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两个限时折扣商品是否相等
|
||||
* 注意,比较时忽略 id 编号
|
||||
*
|
||||
* @param productDO 商品 1
|
||||
* @param productVO 商品 2
|
||||
* @return 是否匹配
|
||||
*/
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
default boolean isEquals(DiscountProductDO productDO, DiscountProductDO productVO) {
|
||||
if (ObjectUtil.notEqual(productDO.getSpuId(), productVO.getSpuId())
|
||||
|| ObjectUtil.notEqual(productDO.getSkuId(), productVO.getSkuId())
|
||||
|| ObjectUtil.notEqual(productDO.getDiscountType(), productVO.getDiscountType())) {
|
||||
return false;
|
||||
}
|
||||
if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PRICE.getType())) {
|
||||
return ObjectUtil.equal(productDO.getDiscountPrice(), productVO.getDiscountPrice());
|
||||
}
|
||||
if (productDO.getDiscountType().equals(PromotionDiscountTypeEnum.PERCENT.getType())) {
|
||||
return ObjectUtil.equal(productDO.getDiscountPercent(), productVO.getDiscountPercent());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -66,10 +66,16 @@ public class DiscountProductDO extends BaseDO {
|
|||
*/
|
||||
private Integer discountPrice;
|
||||
|
||||
/**
|
||||
* 活动标题
|
||||
*
|
||||
* 冗余 {@link DiscountActivityDO#getName()}
|
||||
*/
|
||||
private String activityName;
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
* 关联 {@link DiscountActivityDO#getStatus()}
|
||||
* 冗余 {@link DiscountActivityDO#getStatus()}
|
||||
*/
|
||||
private Integer activityStatus;
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.dataobject.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 积分商城活动 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName(value = "promotion_point_activity", autoResultMap = true)
|
||||
@KeySequence("promotion_point_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class PointActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 积分商城活动编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 积分商城活动商品
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 积分商城活动库存(剩余库存积分兑换时扣减)
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* 积分商城活动总库存
|
||||
*/
|
||||
private Integer totalStock;
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.dataobject.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 积分商城商品 DO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName("promotion_point_product")
|
||||
@KeySequence("promotion_point_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PointProductDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 积分商城商品编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 积分商城活动 id
|
||||
*
|
||||
* 关联 {@link PointActivityDO#getId()}
|
||||
*/
|
||||
private Long activityId;
|
||||
/**
|
||||
* 商品 SPU 编号
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
* 商品 SKU 编号
|
||||
*/
|
||||
private Long skuId;
|
||||
/**
|
||||
* 可兑换次数
|
||||
*/
|
||||
private Integer count;
|
||||
/**
|
||||
* 所需兑换积分
|
||||
*/
|
||||
private Integer point;
|
||||
/**
|
||||
* 所需兑换金额,单位:分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 积分商城商品库存
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* 积分商城商品状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum 对应的类}
|
||||
*/
|
||||
private Integer activityStatus;
|
||||
|
||||
}
|
|
@ -6,14 +6,11 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.BargainActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 砍价活动 Mapper
|
||||
|
@ -86,35 +83,13 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> {
|
|||
.last("LIMIT " + count));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 包含 spuId 和 activityId 的 map 对象列表
|
||||
*/
|
||||
default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
return selectMaps(new QueryWrapper<BargainActivityDO>()
|
||||
.select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id
|
||||
.in("spu_id", spuIds)
|
||||
.eq("status", status)
|
||||
.groupBy("spu_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定活动编号的活动列表且
|
||||
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
||||
*
|
||||
* @param ids 活动编号
|
||||
* @param dateTime 指定日期
|
||||
* @return 活动列表
|
||||
*/
|
||||
default List<BargainActivityDO> selectListByIdsAndDateTimeLt(Collection<Long> ids, LocalDateTime dateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<BargainActivityDO>()
|
||||
.in(BargainActivityDO::getId, ids)
|
||||
.lt(BargainActivityDO::getStartTime, dateTime)
|
||||
.gt(BargainActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||
.orderByDesc(BargainActivityDO::getCreateTime));
|
||||
default BargainActivityDO selectBySpuIdAndStatusAndNow(Long spuId, Integer status) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return selectOne(new LambdaQueryWrapperX<BargainActivityDO>()
|
||||
.eq(BargainActivityDO::getSpuId, spuId)
|
||||
.eq(BargainActivityDO::getStatus, status)
|
||||
.lt(BargainActivityDO::getStartTime, now)
|
||||
.gt(BargainActivityDO::getEndTime, now)); // 开始时间 < now < 结束时间,也就是说获取指定时间段的活动
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,14 +6,10 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 拼团活动 Mapper
|
||||
|
@ -39,40 +35,13 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi
|
|||
.eq(CombinationActivityDO::getStatus, status));
|
||||
}
|
||||
|
||||
default List<CombinationActivityDO> selectListByStatus(Integer status, Integer count) {
|
||||
return selectList(new LambdaQueryWrapperX<CombinationActivityDO>()
|
||||
default CombinationActivityDO selectBySpuIdAndStatusAndNow(Long spuId, Integer status) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return selectOne(new LambdaQueryWrapperX<CombinationActivityDO>()
|
||||
.eq(CombinationActivityDO::getSpuId, spuId)
|
||||
.eq(CombinationActivityDO::getStatus, status)
|
||||
.last("LIMIT " + count));
|
||||
.lt(CombinationActivityDO::getStartTime, now)
|
||||
.gt(CombinationActivityDO::getEndTime, now)); // 开始时间 < now < 结束时间,也就是说获取指定时间段的活动
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 包含 spuId 和 activityId 的 map 对象列表
|
||||
*/
|
||||
default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection<Long> spuIds, @Param("status") Integer status) {
|
||||
return selectMaps(new QueryWrapper<CombinationActivityDO>()
|
||||
.select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id
|
||||
.in("spu_id", spuIds)
|
||||
.eq("status", status)
|
||||
.groupBy("spu_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定活动编号的活动列表且
|
||||
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
||||
*
|
||||
* @param ids 活动编号
|
||||
* @param dateTime 指定日期
|
||||
* @return 活动列表
|
||||
*/
|
||||
default List<CombinationActivityDO> selectListByIdsAndDateTimeLt(Collection<Long> ids, LocalDateTime dateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<CombinationActivityDO>()
|
||||
.in(CombinationActivityDO::getId, ids)
|
||||
.lt(CombinationActivityDO::getStartTime, dateTime)
|
||||
.gt(CombinationActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||
.orderByDesc(CombinationActivityDO::getCreateTime));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ public interface CouponTemplateMapper extends BaseMapperX<CouponTemplateDO> {
|
|||
.in(CouponTemplateDO::getTakeType, canTakeTypes) // 2. 领取方式一致
|
||||
.and(ww -> ww.gt(CouponTemplateDO::getValidEndTime, LocalDateTime.now()) // 3.1 未过期
|
||||
.or().eq(CouponTemplateDO::getValidityType, CouponTemplateValidityTypeEnum.TERM.getType())) // 3.2 领取之后
|
||||
.apply(" (take_count < total_count OR total_count = -1 )"); // 4. 剩余数量大于 0,或者无限领取
|
||||
.apply(" (take_count < total_count OR total_count = -1)"); // 4. 剩余数量大于 0,或者无限领取
|
||||
}
|
||||
return canTakeConsumer;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.mysql.discount;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 限时折扣商城 Mapper
|
||||
|
@ -18,10 +18,6 @@ import java.util.Map;
|
|||
@Mapper
|
||||
public interface DiscountProductMapper extends BaseMapperX<DiscountProductDO> {
|
||||
|
||||
default List<DiscountProductDO> selectListBySkuId(Collection<Long> skuIds) {
|
||||
return selectList(DiscountProductDO::getSkuId, skuIds);
|
||||
}
|
||||
|
||||
default List<DiscountProductDO> selectListByActivityId(Long activityId) {
|
||||
return selectList(DiscountProductDO::getActivityId, activityId);
|
||||
}
|
||||
|
@ -30,22 +26,28 @@ public interface DiscountProductMapper extends BaseMapperX<DiscountProductDO> {
|
|||
return selectList(DiscountProductDO::getActivityId, activityIds);
|
||||
}
|
||||
|
||||
// TODO @zhangshuai:逻辑里,尽量避免写 join 语句哈,你可以看看这个查询,有什么办法优化?目前的一个思路,是分 2 次查询,性能也是 ok 的
|
||||
List<DiscountProductDO> getMatchDiscountProductList(@Param("skuIds") Collection<Long> skuIds);
|
||||
default List<DiscountProductDO> selectListBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<DiscountProductDO>()
|
||||
.in(DiscountProductDO::getSpuId, spuIds)
|
||||
.eq(DiscountProductDO::getActivityStatus, status));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 包含 spuId 和 activityId 的 map 对象列表
|
||||
*/
|
||||
default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
return selectMaps(new QueryWrapper<DiscountProductDO>()
|
||||
.select("spu_id AS spuId, MAX(DISTINCT(activity_id)) AS activityId")
|
||||
.in("spu_id", spuIds)
|
||||
.eq("activity_status", status)
|
||||
.groupBy("spu_id"));
|
||||
default void updateByActivityId(DiscountProductDO discountProductDO) {
|
||||
update(discountProductDO, new LambdaUpdateWrapper<DiscountProductDO>()
|
||||
.eq(DiscountProductDO::getActivityId, discountProductDO.getActivityId()));
|
||||
}
|
||||
|
||||
default void deleteByActivityId(Long activityId) {
|
||||
delete(DiscountProductDO::getActivityId, activityId);
|
||||
}
|
||||
|
||||
default List<DiscountProductDO> selectListBySkuIdsAndStatusAndNow(Collection<Long> skuIds, Integer status) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return selectList(new LambdaQueryWrapperX<DiscountProductDO>()
|
||||
.in(DiscountProductDO::getSkuId, skuIds)
|
||||
.eq(DiscountProductDO::getActivityStatus,status)
|
||||
.lt(DiscountProductDO::getActivityStartTime, now)
|
||||
.gt(DiscountProductDO::getActivityEndTime, now));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.mysql.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.point.vo.activity.PointActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointActivityDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 积分商城活动 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface PointActivityMapper extends BaseMapperX<PointActivityDO> {
|
||||
|
||||
default PageResult<PointActivityDO> selectPage(PointActivityPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<PointActivityDO>()
|
||||
.eqIfPresent(PointActivityDO::getSpuId, reqVO.getSpuId())
|
||||
.eqIfPresent(PointActivityDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(PointActivityDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(PointActivityDO::getSort, reqVO.getSort())
|
||||
.betweenIfPresent(PointActivityDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(PointActivityDO::getId));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package cn.iocoder.yudao.module.promotion.dal.mysql.point;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.point.PointProductDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分商城商品 Mapper
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Mapper
|
||||
public interface PointProductMapper extends BaseMapperX<PointProductDO> {
|
||||
|
||||
default List<PointProductDO> selectListByActivityId(Collection<Long> activityIds) {
|
||||
return selectList(PointProductDO::getActivityId, activityIds);
|
||||
}
|
||||
|
||||
default List<PointProductDO> selectListByActivityId(Long activityId) {
|
||||
return selectList(PointProductDO::getActivityId, activityId);
|
||||
}
|
||||
|
||||
default void updateByActivityId(PointProductDO pointProductDO) {
|
||||
update(pointProductDO, new LambdaUpdateWrapper<PointProductDO>()
|
||||
.eq(PointProductDO::getActivityId, pointProductDO.getActivityId()));
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
|||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -30,29 +30,23 @@ public interface RewardActivityMapper extends BaseMapperX<RewardActivityDO> {
|
|||
.orderByDesc(RewardActivityDO::getId));
|
||||
}
|
||||
|
||||
default List<RewardActivityDO> selectListBySpuIdsAndStatus(Collection<Long> spuIds, Integer status) {
|
||||
default List<RewardActivityDO> selectListBySpuIdAndStatusAndNow(Collection<Long> spuIds,
|
||||
Collection<Long> categoryIds,
|
||||
Integer status) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Function<Collection<Long>, String> productScopeValuesFindInSetFunc = ids -> ids.stream()
|
||||
.map(id -> StrUtil.format("FIND_IN_SET({}, product_scope_values) ", id))
|
||||
.collect(Collectors.joining(" OR "));
|
||||
return selectList(new QueryWrapper<RewardActivityDO>()
|
||||
.eq("status", status)
|
||||
.apply(productScopeValuesFindInSetFunc.apply(spuIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定活动编号的活动列表且
|
||||
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
||||
*
|
||||
* @param status 状态
|
||||
* @param dateTime 指定日期
|
||||
* @return 活动列表
|
||||
*/
|
||||
default List<RewardActivityDO> selectListByStatusAndDateTimeLt(Integer status, LocalDateTime dateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<RewardActivityDO>()
|
||||
.eq(RewardActivityDO::getStatus, status)
|
||||
.lt(RewardActivityDO::getStartTime, dateTime)
|
||||
.gt(RewardActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||
.orderByAsc(RewardActivityDO::getStartTime)
|
||||
.lt(RewardActivityDO::getStartTime, now)
|
||||
.gt(RewardActivityDO::getEndTime, now)
|
||||
.and(i -> i.eq(RewardActivityDO::getProductScope, PromotionProductScopeEnum.SPU.getScope())
|
||||
.and(i1 -> i1.apply(productScopeValuesFindInSetFunc.apply(spuIds)))
|
||||
.or(i1 -> i1.eq(RewardActivityDO::getProductScope, PromotionProductScopeEnum.ALL.getScope()))
|
||||
.or(i1 -> i1.eq(RewardActivityDO::getProductScope, PromotionProductScopeEnum.CATEGORY.getScope())
|
||||
.and(i2 -> i2.apply(productScopeValuesFindInSetFunc.apply(categoryIds)))))
|
||||
.orderByDesc(RewardActivityDO::getId)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,15 +8,11 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 秒杀活动 Mapper
|
||||
|
@ -35,9 +31,9 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
|
|||
.orderByDesc(SeckillActivityDO::getId));
|
||||
}
|
||||
|
||||
default List<SeckillActivityDO> selectListByStatus(Integer status) {
|
||||
return selectList(new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||
.eqIfPresent(SeckillActivityDO::getStatus, status));
|
||||
default List<SeckillActivityDO> selectListBySpuIdAndStatus(Long spuId, Integer status) {
|
||||
return selectList(SeckillActivityDO::getSpuId, spuId,
|
||||
SeckillActivityDO::getStatus, status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +47,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
|
|||
Assert.isTrue(count > 0);
|
||||
return update(null, new LambdaUpdateWrapper<SeckillActivityDO>()
|
||||
.eq(SeckillActivityDO::getId, id)
|
||||
.gt(SeckillActivityDO::getStock, count)
|
||||
.ge(SeckillActivityDO::getStock, count)
|
||||
.setSql("stock = stock - " + count));
|
||||
}
|
||||
|
||||
|
@ -69,41 +65,21 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
|
|||
.setSql("stock = stock + " + count));
|
||||
}
|
||||
|
||||
default PageResult<SeckillActivityDO> selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) {
|
||||
default PageResult<SeckillActivityDO> selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status, LocalDateTime dateTime) {
|
||||
return selectPage(pageReqVO, new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||
.eqIfPresent(SeckillActivityDO::getStatus, status)
|
||||
.lt(SeckillActivityDO::getStartTime, dateTime)
|
||||
.gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||
.apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询出指定 spuId 的 spu 参加的活动最接近现在的一条记录。多个的话,一个 spuId 对应一个最近的活动编号
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @return 包含 spuId 和 activityId 的 map 对象列表
|
||||
*/
|
||||
default List<Map<String, Object>> selectSpuIdAndActivityIdMapsBySpuIdsAndStatus(@Param("spuIds") Collection<Long> spuIds, @Param("status") Integer status) {
|
||||
return selectMaps(new QueryWrapper<SeckillActivityDO>()
|
||||
.select("spu_id AS spuId, MAX(DISTINCT(id)) AS activityId") // 时间越大 id 也越大 直接用 id
|
||||
.in("spu_id", spuIds)
|
||||
.eq("status", status)
|
||||
.groupBy("spu_id"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定活动编号的活动列表且
|
||||
* 开始时间和结束时间小于给定时间 dateTime 的活动列表
|
||||
*
|
||||
* @param ids 活动编号
|
||||
* @param dateTime 指定日期
|
||||
* @return 活动列表
|
||||
*/
|
||||
default List<SeckillActivityDO> selectListByIdsAndDateTimeLt(Collection<Long> ids, LocalDateTime dateTime) {
|
||||
return selectList(new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||
.in(SeckillActivityDO::getId, ids)
|
||||
.lt(SeckillActivityDO::getStartTime, dateTime)
|
||||
.gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||
.orderByDesc(SeckillActivityDO::getCreateTime));
|
||||
default SeckillActivityDO selectBySpuIdAndStatusAndNow(Long spuId, Integer status) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
return selectOne(new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||
.eq(SeckillActivityDO::getSpuId, spuId)
|
||||
.eq(SeckillActivityDO::getStatus, status)
|
||||
.lt(SeckillActivityDO::getStartTime, now)
|
||||
.gt(SeckillActivityDO::getEndTime, now)); // 开始时间 < now < 结束时间,也就是说获取指定时间段的活动
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.Ba
|
|||
import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -108,13 +106,11 @@ public interface BargainActivityService {
|
|||
List<BargainActivityDO> getBargainActivityListByCount(Integer count);
|
||||
|
||||
/**
|
||||
* 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录
|
||||
* 获得 SPU 进行中的砍价活动
|
||||
*
|
||||
* @param spuIds spu 编号
|
||||
* @param status 状态
|
||||
* @param dateTime 日期时间
|
||||
* @return 砍价活动列表
|
||||
* @param spuId SPU 编号数组
|
||||
* @return 砍价活动
|
||||
*/
|
||||
List<BargainActivityDO> getBargainActivityBySpuIdsAndStatusAndDateTimeLt(Collection<Long> spuIds, Integer status, LocalDateTime dateTime);
|
||||
BargainActivityDO getMatchBargainActivityBySpuId(Long spuId);
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue