Compare commits

...

227 Commits

Author SHA1 Message Date
9ab82b718c 修改了docker相关1 2025-08-14 15:02:17 +08:00
32c3be920e 修改了docker相关 2025-08-14 14:52:43 +08:00
eaaeb8c28b 评论状态 2025-08-14 08:41:41 +08:00
3eb7107361 4444 2025-08-13 17:59:06 +08:00
1f72007754 修改了首页推荐,新增了医院 2025-08-13 16:30:14 +08:00
24e597966c 55555 2025-08-12 16:39:29 +08:00
6bd9ab31b6 23444 2025-08-12 13:44:55 +08:00
fd9ae57649 1123344 2025-08-12 11:40:31 +08:00
d8f1eb8d16 评论接口更改返回状态44 2025-08-05 11:27:17 +08:00
5ba59aecf9 评论接口更改返回状态3 2025-08-05 11:22:45 +08:00
aa76f5e07f 评论接口更改返回状态2 2025-08-05 11:14:28 +08:00
e997998b40 评论接口更改返回状态1 2025-08-05 11:11:09 +08:00
66920c976c 评论接口更改返回状态 2025-08-05 11:01:35 +08:00
c0f182de55 4444 2025-08-05 10:16:22 +08:00
5f7e7a0c5f 111 2025-08-05 10:00:21 +08:00
2098589016 修改打上积分4 2025-08-04 17:28:00 +08:00
01ef215163 修改打上积分2 2025-08-04 17:27:02 +08:00
f88c3521fd 修改打上积分 2025-08-04 17:26:35 +08:00
e1f49cf813 修改登录2 2025-08-04 17:18:52 +08:00
e667e312ab 修改登录1 2025-08-04 16:55:13 +08:00
c41d50c54f 修改登录 2025-08-04 16:47:24 +08:00
54c250a7a6 修改了病例交流的统计数据和登陆状态1 2025-08-04 16:09:40 +08:00
20ff8778b8 修改了病例交流的统计数据和登陆状态 2025-08-04 15:58:02 +08:00
36a796853b 修改了评论没有域名 2025-08-04 11:01:56 +08:00
85ee55c9f7 修改了资源路径-作者4 2025-08-01 14:58:40 +08:00
ac19f19c47 修改了资源路径-作者2 2025-08-01 14:35:37 +08:00
14856318d8 修改了资源路径-作者1 2025-08-01 14:15:46 +08:00
b9c47f8aca 修改了资源路径-作者 2025-08-01 13:56:59 +08:00
131d417834 修改了资源路径9 2025-08-01 13:32:21 +08:00
6f1715e857 修改了资源路径8 2025-08-01 13:17:17 +08:00
8962369be6 修改了资源路径7 2025-08-01 11:37:58 +08:00
492eef5bc0 修改了资源路径6 2025-08-01 11:32:54 +08:00
7a060c442e 修改了资源路径5 2025-08-01 11:25:44 +08:00
68e4c8d592 修改了资源路径4 2025-08-01 11:13:07 +08:00
edb21d1a99 修改了资源路径3 2025-08-01 11:10:17 +08:00
fcf5a0e4eb 修改了资源路径2 2025-08-01 11:07:07 +08:00
a8c9f2126c 修改了资源路径1 2025-08-01 11:02:30 +08:00
5c6718b905 修改了资源路径 2025-08-01 10:57:50 +08:00
b19c16e540 修改了医生的验证逻辑3344 2025-08-01 10:49:36 +08:00
eacc43c2d8 修改了医生的验证逻辑 2025-08-01 10:34:24 +08:00
462318b5ec 修改了图片 2025-08-01 09:32:47 +08:00
329d7c91ff 修改文章查询证书问题 2025-08-01 08:54:00 +08:00
4930e7245f 修改了同步视频2 2025-08-01 08:42:18 +08:00
f2ede0d149 修改了同步视频1 2025-07-31 18:41:32 +08:00
0a2457f3b2 修改了同步视频 2025-07-31 18:28:16 +08:00
f2581d421c 修改发放积分 2025-07-31 17:42:25 +08:00
8b96dd8325 44444 2025-07-31 17:20:52 +08:00
f47161fcc8 11111 2025-07-31 16:51:37 +08:00
c2502c487d 修改列表查询12 2025-07-31 16:26:42 +08:00
ce9ef01888 修改列表查询1 2025-07-31 16:19:50 +08:00
b39a5c8e6e 修改列表查询 2025-07-31 16:18:20 +08:00
206e7db697 修改评论的时区 2025-07-31 08:56:11 +08:00
fedd8a0465 修改浏览记录134 2025-07-31 08:51:41 +08:00
1db0b3605b 修改浏览记录13 2025-07-31 08:49:57 +08:00
6b380411c6 修改浏览记录1 2025-07-31 08:47:16 +08:00
bc44e11fd9 修改浏览记录 2025-07-31 08:44:42 +08:00
2f0d44ae76 修改发放积分1 2025-07-30 19:20:31 +08:00
8bd0cc1d28 修改发放积分 2025-07-30 19:19:15 +08:00
d30982b4d5 8797898989 2025-07-30 19:12:15 +08:00
89dfc5575b 8888 2025-07-30 19:04:24 +08:00
a16995d845 56666 2025-07-30 18:48:21 +08:00
a344ece9fd 4555 2025-07-30 18:29:09 +08:00
a515bb3085 3333 2025-07-30 18:25:33 +08:00
827f8ddc92 1111 2025-07-30 18:23:42 +08:00
9964dccf68 删除评论 2025-07-30 18:22:11 +08:00
0b8413ef79 44444 2025-07-30 17:35:42 +08:00
23fd06cf99 222 2025-07-30 17:25:21 +08:00
34aab6a66c 1 2025-07-30 17:23:34 +08:00
7754370892 评论修改1111 2025-07-30 17:07:05 +08:00
2e5a06f825 评论修改 2025-07-30 17:00:28 +08:00
511ae5c374 5555 2025-07-30 16:53:02 +08:00
b165524210 4444 2025-07-30 16:50:16 +08:00
a14c951cac 1111 2025-07-30 16:48:44 +08:00
046d7d9c74 登陆增加二次匹配 2025-07-30 16:26:46 +08:00
0c18896fa2 4445 2025-07-30 15:58:06 +08:00
c46a83500a 111 2025-07-30 15:46:14 +08:00
4a48ba3757 头像 2025-07-30 15:44:01 +08:00
e1f51949ed 445555 2025-07-30 15:29:25 +08:00
2cdb0daf3d 456661233 2025-07-30 15:24:13 +08:00
cd5a008a36 45666 2025-07-30 15:22:46 +08:00
c1bfcc3840 67777 2025-07-30 15:12:54 +08:00
2bf75f99a5 6666 2025-07-30 14:40:04 +08:00
f365725ddc 5555 2025-07-30 14:33:51 +08:00
d37e46e2a7 修改评论积分2 2025-07-30 14:30:45 +08:00
4db0e612ab 修改评论积分1 2025-07-30 14:29:52 +08:00
dd04813211 修改评论积分 2025-07-30 14:23:46 +08:00
9187b467ce 修正头像11445557777 2025-07-30 14:16:34 +08:00
dfab1ec324 修正头像1144555 2025-07-30 14:08:05 +08:00
7997d0abe9 修正头像11111 2025-07-30 13:54:45 +08:00
290e457977 修正头像1111 2025-07-30 13:52:49 +08:00
5ef855aa2d 修正头像 2025-07-30 13:49:38 +08:00
7f6dcd5061 修正头像 2025-07-30 13:00:25 +08:00
667ffdb9ea 55556666 2025-07-30 11:53:00 +08:00
2f92f54cb6 5555 2025-07-30 11:11:49 +08:00
39e57c6fcc nihao1 2025-07-30 11:06:31 +08:00
b9be135a56 nihao 2025-07-30 10:58:37 +08:00
dd4db760f0 66664666678888 2025-07-30 10:55:17 +08:00
00338d96e5 6666466667 2025-07-30 10:50:59 +08:00
983ec56b9c 666646666 2025-07-30 10:48:11 +08:00
1401671c28 66664 2025-07-30 10:34:42 +08:00
6e076f2a37 6666 2025-07-30 10:30:44 +08:00
3e4642d937 5555 2025-07-30 10:16:39 +08:00
1bc315902f 新增了积分发放 2025-07-30 09:54:42 +08:00
cc7c07aa4a 修改了首页临床病例库的推荐 2025-07-29 15:58:07 +08:00
7a752c3cc5 6666 2025-07-29 15:36:32 +08:00
3fe8e3f807 5555 2025-07-29 15:34:31 +08:00
07088b6919 3333 2025-07-29 15:31:34 +08:00
ca409dcac6 1111 2025-07-29 15:28:33 +08:00
dfce0a6b31 修改排序 2025-07-29 11:29:58 +08:00
45682cac23 445555 2025-07-28 17:09:11 +08:00
3f94685c77 334444 2025-07-28 16:56:40 +08:00
72cc412f50 44444 2025-07-28 15:33:42 +08:00
98449feef3 111 2025-07-28 15:24:12 +08:00
2a68315cc8 修改限制数量1 2025-07-28 14:55:57 +08:00
897b1c3cbe 修改限制数量 2025-07-28 14:46:51 +08:00
ec78f1167d 1234 2025-07-28 14:33:31 +08:00
8d659750f7 修改时间排序 2025-07-28 14:17:04 +08:00
98e7715481 111 2025-07-28 11:04:05 +08:00
cb10052615 1111 2025-07-28 11:01:20 +08:00
209e52ff4c 新增了同步app视频,1 2025-07-28 09:22:33 +08:00
6372a75c1c 新增了同步app视频, 2025-07-28 09:13:34 +08:00
7b09f59b51 1111 2025-07-25 17:16:30 +08:00
59de0d8ea1 数量为0的判断 2025-07-25 16:54:42 +08:00
cbe48f9780 详情页增加了删除状态的判断1 2025-07-25 16:11:47 +08:00
a88cdbe43f 详情页增加了删除状态的判断 2025-07-25 16:10:53 +08:00
7d206deaac 病例交流修改的问题 2025-07-25 16:00:46 +08:00
d829af6ba0 病例交流列表去掉删除状态 2025-07-25 15:45:59 +08:00
d2cb421fa7 app接口。新增了两个接口1 2025-07-25 15:18:19 +08:00
262e576192 app接口。新增了两个接口 2025-07-25 14:34:57 +08:00
cb6717e3fa 1 2025-07-24 10:13:54 +08:00
862df3035c 病例交流列表 新增了评论排序 2025-07-22 15:55:45 +08:00
c5bc0920d3 病例交流列表2 2025-07-22 15:30:33 +08:00
79ff5e6d10 病例交流列表1 2025-07-22 15:12:51 +08:00
901af4db84 病例交流列表 2025-07-22 15:10:13 +08:00
55f9b8f634 77777 2025-07-18 17:59:53 +08:00
88ee5ad694 22222 2025-07-18 17:32:09 +08:00
579c81e553 1111 2025-07-18 13:28:55 +08:00
f53e5b5d65 445555 2025-07-18 10:57:30 +08:00
476dfb53e8 4444 2025-07-17 16:44:53 +08:00
05b3f93703 1113333 2025-07-17 16:42:00 +08:00
9f50e3eb5c 111 2025-07-17 16:04:00 +08:00
d99ecce3a4 时间排序 2025-07-17 15:25:53 +08:00
69071077bd 登陆职称修改 2025-07-17 11:26:45 +08:00
2753484bbb 修改了病例交流 2025-07-17 11:03:31 +08:00
20571f6e9e 修改了疾病标签的搜索444 2025-07-16 17:21:48 +08:00
e3d7345221 修改了疾病标签的搜索3 2025-07-16 17:15:10 +08:00
d134ffd200 修改了疾病标签的搜索2 2025-07-16 17:09:00 +08:00
ac161b5bd4 修改了疾病标签的搜索1 2025-07-16 16:39:03 +08:00
0675a7ea21 修改了疾病标签的搜索 2025-07-16 16:28:52 +08:00
b1fda37e38 增加了外联地址1 2025-07-16 16:08:31 +08:00
a4cd9317f0 增加了外联地址 2025-07-16 16:05:55 +08:00
1064bc0b84 修改了评论1 2025-07-16 15:08:11 +08:00
872598cffe 修改了评论 2025-07-16 13:37:36 +08:00
6553531416 封装了统计字段 2025-06-18 11:54:39 +08:00
61cef2f2a4 修正了登录 2025-06-18 10:56:40 +08:00
d4c2385179 修正数据库和互动病例保持一致 2025-06-17 17:17:45 +08:00
b449de8732 334444444 2025-06-17 16:12:28 +08:00
3b8fd1e956 33444 2025-06-17 13:05:10 +08:00
3243e23601 333 2025-06-17 11:58:37 +08:00
5517e2c2f8 1 2025-06-17 11:56:27 +08:00
bedb39fc58 修改aliyunsdk版本 2025-06-17 11:49:14 +08:00
588e896aff 白名单 2025-06-17 11:35:26 +08:00
d86125909a 处理了微信登录1 2025-06-17 11:27:34 +08:00
6eab966eab 处理了微信登录 2025-06-17 11:26:54 +08:00
b516ddf5df 修改redis配置 2025-06-16 16:34:42 +08:00
db2e0d810a 11111 2025-06-16 16:11:20 +08:00
f618d8e733 oss签名修改 2025-06-16 16:05:36 +08:00
f70a495bb7 测试跨域 2025-06-16 10:12:29 +08:00
75d13febeb 新增了hcp登录2 2025-06-16 09:42:48 +08:00
72ebcefef7 新增了hcp登录1 2025-06-16 09:30:05 +08:00
92d2483425 新增了hcp登录 2025-06-16 09:20:59 +08:00
916a9868c5 新增了阅读记录 2025-06-16 08:53:38 +08:00
12ddc57bca 333dfsfdfgfddfg 2025-06-13 18:48:55 +08:00
bbc53de701 333 2025-06-13 18:47:08 +08:00
47198f2033 4444 2025-06-13 17:00:15 +08:00
8509343e3c 1111 2025-06-13 16:58:10 +08:00
5e50b35ef4 新增了用户投票 2025-06-13 15:46:11 +08:00
be5a9a2085 333 2025-06-13 14:22:45 +08:00
5aeef97712 111 2025-06-13 14:11:17 +08:00
d226b4e4f0 新增了标签统计数据 2025-06-13 13:56:23 +08:00
4ebdb2c862 新增了标签搜索 2025-06-13 13:16:54 +08:00
637dea8d2f 修改了dockerfile和java版本名 2025-06-12 19:10:42 +08:00
70dd08b359 新增了证书图片,新增了搜索数量 2025-06-12 18:32:37 +08:00
3a8c82c459 病例交流投票数据 2025-06-12 17:49:07 +08:00
0e5d8effa8 新增了打赏积分和获取用户积分 2025-06-12 16:53:08 +08:00
73e7eb620a 新增了标签1 2025-06-11 17:58:56 +08:00
872e6dc49c 新增了标签 2025-06-11 17:52:28 +08:00
b05be13e5c 病例交流增加了列表中的图片和视频预览 2025-06-11 16:17:55 +08:00
0e6d48284c 新增了草稿操作 2025-06-10 16:58:44 +08:00
8eb64d1c41 新增了草稿搜索 2025-06-10 14:19:54 +08:00
a899914fea 修正了出离职 2025-06-10 10:49:57 +08:00
7d388adbde 444 2025-06-10 10:23:35 +08:00
6c4d7a90f8 111 2025-06-10 09:59:11 +08:00
f09faeef6b 新增了病例交流列表 2025-06-10 09:01:01 +08:00
56b1b3b7ad 评论新增了标题1111444 2025-06-09 15:25:40 +08:00
8c8b779ab3 评论新增了标题111111 2025-06-09 15:24:54 +08:00
468b99c27e 评论新增了标题1111111344 2025-06-09 14:55:42 +08:00
a9120604c6 评论新增了标题1111 2025-06-09 14:44:05 +08:00
566be0b3fe 评论新增了标题 2025-06-09 11:58:05 +08:00
e3b3cca738 新增了oss签名接口 2025-06-09 10:39:21 +08:00
bd5a9f819a 修改了首页,增加了标签字段 2025-06-09 08:55:11 +08:00
a0b70e5029 修正了dec inc的字段小于0的问题 2025-06-06 09:37:35 +08:00
6380b06140 新增我的阅读记录 2025-06-05 16:18:58 +08:00
25d03491be 新增我的收藏 2025-06-04 15:10:50 +08:00
003c4eea74 新增我参与的评论 2025-06-03 17:47:35 +08:00
8fc7084b31 2 2025-06-03 15:29:35 +08:00
654eb2ee5c 1 2025-06-03 15:25:01 +08:00
6aaff9f345 获取用户信息增加了医生id 2025-06-03 13:58:09 +08:00
9e1c30a81c 新增了病例交流2 2025-06-03 09:02:32 +08:00
82c2055756 新增了病例交流1 2025-05-30 16:32:38 +08:00
257b08d28e 新增了病例交流 2025-05-29 14:43:39 +08:00
d3c30c0eee 新增了我的页面 2025-05-26 10:47:42 +08:00
fcf9ca6744 新增了评论1 2025-05-23 14:14:26 +08:00
f719a1d347 新增了评论 2025-05-23 13:18:54 +08:00
c106bce7e2 修改了搜索,增加了部分评论模块接口 2025-05-21 16:06:00 +08:00
bbc66da590 去除了打印log 2025-05-20 13:08:03 +08:00
1a8c64757d 修改了搜索、修改了dockerfile 2025-05-20 10:15:49 +08:00
0acfe1a06e 修改了接口白名单 2025-05-19 19:06:29 +08:00
4d95f22d0f 修改了搜索 2025-05-19 18:41:36 +08:00
f186b98dbe 新增api路由 2025-05-19 16:50:06 +08:00
a20af2a32a 去除api路由 2025-05-19 16:09:07 +08:00
beb057f621 去除了api 2025-05-19 13:33:07 +08:00
a215b740c9 增加了api 2025-05-19 13:21:42 +08:00
89745907b0 去除api层级 2025-05-15 17:02:36 +08:00
fa8278939e 1 2025-05-13 14:32:26 +08:00
8841975427 新增了文章收藏 2025-05-12 17:43:41 +08:00
ebffb14ba5 增加了dockerfile 2025-05-12 16:57:22 +08:00
213 changed files with 16241 additions and 528 deletions

View File

@ -1,15 +0,0 @@
# 基础镜像
FROM openjdk:17-jdk-alpine
LABEL authors="wucongxing"
# 工作目录
WORKDIR /app
# 复制jar包
COPY target/caseData.jar /app/app.jar
# 暴露端口
EXPOSE 8080
# 启动命令
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

41
Dockerfile-env Normal file
View File

@ -0,0 +1,41 @@
# 第一阶段:构建 JAR 包
FROM maven:3.9.2-eclipse-temurin-17-alpine AS builder
WORKDIR /app
# 添加国内 Maven 镜像源
RUN mkdir -p /root/.m2 && \
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 \
https://maven.apache.org/xsd/settings-1.0.0.xsd"> \
<mirrors> \
<mirror> \
<id>aliyun</id> \
<mirrorOf>*</mirrorOf> \
<name>aliyun maven</name> \
<url>https://maven.aliyun.com/repository/public</url> \
</mirror> \
</mirrors> \
</settings>' > /root/.m2/settings.xml
# 将 pom.xml 和 src 目录复制到容器
COPY pom.xml .
COPY src ./src
# 执行 Maven 打包
RUN mvn clean package -DskipTests
# 第二阶段:运行镜像
FROM eclipse-temurin:17-jdk-alpine
WORKDIR /app
# 将构建好的 JAR 包从构建阶段复制到运行阶段
COPY --from=builder /app/target/caseData-1.0.0.jar app.jar
# 暴露端口
EXPOSE 5477
# 启动应用
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=dev"]

41
Dockerfile-prod Normal file
View File

@ -0,0 +1,41 @@
# 第一阶段:构建 JAR 包
FROM maven:3.9.2-eclipse-temurin-17-alpine AS builder
WORKDIR /app
# 添加国内 Maven 镜像源
RUN mkdir -p /root/.m2 && \
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" \
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 \
https://maven.apache.org/xsd/settings-1.0.0.xsd"> \
<mirrors> \
<mirror> \
<id>aliyun</id> \
<mirrorOf>*</mirrorOf> \
<name>aliyun maven</name> \
<url>https://maven.aliyun.com/repository/public</url> \
</mirror> \
</mirrors> \
</settings>' > /root/.m2/settings.xml
# 将 pom.xml 和 src 目录复制到容器
COPY pom.xml .
COPY src ./src
# 执行 Maven 打包
RUN mvn clean package -DskipTests
# 第二阶段:运行镜像
FROM eclipse-temurin:17-jdk-alpine
WORKDIR /app
# 将构建好的 JAR 包从构建阶段复制到运行阶段
COPY --from=builder /app/target/caseData-1.0.0.jar app.jar
# 暴露端口
EXPOSE 5477
# 启动应用
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.profiles.active=prod"]

BIN
cert.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

33
pom.xml
View File

@ -10,8 +10,8 @@
</parent>
<groupId>com.example</groupId>
<artifactId>caseData</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>caseData</name>
<description>病例库</description>
<url/>
@ -28,7 +28,7 @@
<url/>
</scm>
<properties>
<java.version>23</java.version>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
@ -98,6 +98,27 @@
<version>3.17.4</version>
</dependency>
<!-- 阿里云短信服务 SDK -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>2.0.23</version>
</dependency>
<!-- 阿里云 OpenAPI 基础依赖 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-openapi</artifactId>
<version>0.2.6</version>
</dependency>
<!-- 阿里云 Tea 工具库 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-util</artifactId>
<version>0.2.13</version>
</dependency>
<!-- JWT 解析库 -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
@ -158,6 +179,12 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -1,15 +1,20 @@
package com.example.caseData;
import jakarta.annotation.PostConstruct;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import java.util.TimeZone;
@SpringBootApplication
@MapperScan("com.example.caseData.dao")
public class CaseDataApplication {
public static void main(String[] args) {
// 设置 JVM 全局默认时区建议与数据库一致比如 "Asia/Shanghai"
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
SpringApplication.run(CaseDataApplication.class, args);
}
}

View File

@ -1,12 +1,9 @@
package com.example.caseData.common;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
/**
* 返回方法

View File

@ -18,4 +18,10 @@ public class AppConfig {
@Value("${app.platform}")
private String platform;
@Value("${app.platformPointAccount}")
private String platformPointAccount;
@Value("${app.access-token}")
private String accessToken;
}

View File

@ -0,0 +1,16 @@
package com.example.caseData.config;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
@Getter
public class DySmsConfig {
@Value("${dysms.access-key}")
private String accessKey;
@Value("${dysms.access-secret}")
private String accessSecret;
}

View File

@ -0,0 +1,33 @@
package com.example.caseData.config;
import lombok.Getter;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Value;
@Component
@Getter
public class RedisConfig {
@Value("${spring.redis.dev.host}")
private String devHost;
@Value("${spring.redis.dev.port}")
private int devPort;
@Value("${spring.redis.dev.password}")
private String devPassword;
@Value("${spring.redis.dev.database}")
private String devDatabase;
@Value("${spring.redis.prod.host}")
private String prodHost;
@Value("${spring.redis.prod.port}")
private int prodPort;
@Value("${spring.redis.prod.password}")
private String prodPassword;
@Value("${spring.redis.prod.database}")
private String prodDatabase;
}

View File

@ -5,21 +5,29 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.common.Response;
import com.example.caseData.dao.*;
import com.example.caseData.dto.basicHospital.BasicHospitalDto;
import com.example.caseData.dto.T;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.statsCaseClinicalHospital.StatsCaseClinicalHospitalDto;
import com.example.caseData.model.BasicHospitalModel;
import com.example.caseData.model.CaseClinicalArticleAuthorModel;
import com.example.caseData.model.CaseClinicalArticleModel;
import com.example.caseData.model.CaseClinicalDoctorModel;
import com.example.caseData.request.clinicalRequest.getClinicalHospitalSearchPage;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
import com.example.caseData.dto.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.model.*;
import com.example.caseData.request.CaseClinicalArticleRequest.addClinicalArticleComment;
import com.example.caseData.request.CaseClinicalArticleRequest.getClinicalArticleCommentPage;
import com.example.caseData.request.CaseClinicalArticleRequest.getUserClinicalArticleCommentPage;
import com.example.caseData.request.caseExchangeRequest.getUserCaseExchangeCommentPage;
import com.example.caseData.request.clinicalRequest.getClinicalArticleSearchPage;
import com.example.caseData.service.CaseClinicalArticleService;
import com.example.caseData.utils.IntToString;
import com.example.caseData.utils.Replace;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
@RequestMapping("/api")
@ -39,11 +47,29 @@ public class CaseClinicalArticleController {
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private UserCommentClinicalArticleDao userCommentClinicalArticleDao;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseClinicalArticleService caseClinicalArticleService;
@Resource
private UserDao userDao;
@Resource
private StatsCaseClinicalDao statsCaseClinicalDao;
@Resource
private StatsCaseClinicalHospitalDao statsCaseClinicalHospitalDao;
/**
* 临床病例库-文章-详情
*/
@GetMapping("/clinical/article/{article_id}")
public Response<CaseClinicalArticleDto> getClinicalHospitalSearchPage(
public Response<CaseClinicalArticleDto> getClinicalArticle(
@PathVariable("article_id") String articleId
) {
@ -53,6 +79,12 @@ public class CaseClinicalArticleController {
return Response.error("非法文章");
}
// 检测作品状态
boolean result = caseClinicalArticleService.checkClinicalArticleStatus(article);
if (!result){
return Response.error(201,null,"该作品已被删除");
}
// 查找作者
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, article.getArticleId());
@ -67,10 +99,345 @@ public class CaseClinicalArticleController {
author.setCaseClinicalDoctor(caseClinicalDoctor);
}
article.setAuthor(caseClinicalArticleAuthors);
// 处理返回值
CaseClinicalArticleDto g = CaseClinicalArticleDto.GetDto(article);
// 是否已收藏
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId != null) {
// 检测用户是否已收藏过
UserCollectClinicalArticleModel userCollectClinicalArticle = caseClinicalArticleService.getUserCollectClinicalArticleStatus(articleId,userId);
if (userCollectClinicalArticle != null) {
g.setCollect(true);
}
}
return Response.success(g);
}
/**
* 临床病例库-文章-收藏
*/
@PostMapping("/clinical/article/collect/{article_id}")
public Response<T> AddClinicalArticleCollect(
@PathVariable("article_id") String articleId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseClinicalArticleService.AddClinicalArticleCollect(articleId,userId);
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
/**
* 临床病例库-文章-取消收藏
*/
@DeleteMapping("/clinical/article/collect/{article_id}")
public Response<T> DeleteClinicalArticleCollect(
@PathVariable("article_id") String articleId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseClinicalArticleService.DeleteClinicalArticleCollect(articleId,userId);
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
/**
* 临床病例库-文章-新增评论
*/
@PostMapping("/clinical/article/comment/{article_id}")
public Response<Map<String, Object>> AddClinicalArticleComment(
@PathVariable("article_id") String articleId,
@Validated()
@RequestBody addClinicalArticleComment request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
Map<String, Object> resultData = new HashMap<>();
resultData.put("status", 1);
resultData.put("message", "成功");
try {
resultData = caseClinicalArticleService.AddClinicalArticleComment(articleId,userId,request);
return Response.success(200,resultData,"");
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
}
/**
* 临床病例库-文章-评论-删除
*/
@DeleteMapping("/clinical/article/comment/{comment_id}")
public Response<T> DeleteClinicalArticleComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败1");
}
try {
boolean res = caseClinicalArticleService.DeleteClinicalArticleComment(commentId,userId);
if (!res){
return Response.error("操作失败2");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 临床病例库-文章-评论-置顶
*/
@PutMapping("/clinical/article/comment/top/{comment_id}")
public Response<T> AddTopClinicalArticleComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseClinicalArticleService.AddTopClinicalArticleComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 临床病例库-文章-评论-取消置顶
*/
@DeleteMapping("/clinical/article/comment/top/{comment_id}")
public Response<T> deleteTopClinicalArticleComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseClinicalArticleService.deleteTopClinicalArticleComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 临床病例库-文章-评论-列表
*/
@PostMapping("/clinical/article/comment/page")
public Response<Map<String, Object>> getClinicalArticleCommentPage(
@Validated()
@RequestBody getClinicalArticleCommentPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<UserCommentClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章评论数据
IPage<UserCommentClinicalArticleDto> resultPage = userCommentClinicalArticleDao.getClinicalArticleCommentPage(
page,
request.getArticleId(),
request.getRootId()
);
// 获取文章数据
CaseClinicalArticleModel article = caseClinicalArticleDao.selectById(request.getArticleId());
if (article == null) {
return Response.error();
}
if (article.getArticleStatus() != 1){
return Response.error();
}
// 是否作者
int isAuthor = 0;
// 获取文章作者数据
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, request.getArticleId());
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
if (caseClinicalDoctor == null) {
return Response.error();
}
// 处理是否本人评论
if (Objects.equals(user.getUserIden(), caseClinicalDoctor.getDoctorIden())){
isAuthor = 1;
}
}
// 处理返回值
for (UserCommentClinicalArticleDto dto : resultPage.getRecords()) {
// 查询医生
LambdaQueryWrapper<CaseClinicalDoctorModel> doctorQueryWrapper = new LambdaQueryWrapper<>();
doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, dto.getUserIden());
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
if (caseClinicalDoctor != null) {
dto.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
// 去除用户唯一标识
dto.setUserIden(null);
dto.setAvatar(Replace.addOssDomain(dto.getAvatar()));
// 图片
dto.setCommentImage(Replace.addOssDomain(dto.getCommentImage()));
// 获取次级评论
if (request.getIsHaveSubComment() == 1){
if (dto.getRootId() == null){
List<UserCommentClinicalArticleDto> subComments = userCommentClinicalArticleDao.getClinicalArticleCommentList(
dto.getArticleId(),
dto.getCommentId(),
5
);
for (UserCommentClinicalArticleDto subComment : subComments) {
// 查询医生
doctorQueryWrapper = new LambdaQueryWrapper<>();
doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, subComment.getUserIden());
caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
if (caseClinicalDoctor != null) {
subComment.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
subComment.setAvatar(Replace.addOssDomain(subComment.getAvatar()));
subComment.setCommentImage(Replace.addOssDomain(subComment.getCommentImage()));
}
dto.setSubComment(subComments);
}
}
}
// 获取全部评论数
LambdaQueryWrapper<UserCommentClinicalArticleModel> aQueryWrapper = new LambdaQueryWrapper<>();
aQueryWrapper.eq(UserCommentClinicalArticleModel::getArticleId, request.getArticleId());
Long total = userCommentClinicalArticleDao.selectCount(aQueryWrapper);
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", total);
resultMap.put("data", resultPage.getRecords());
resultMap.put("is_author", isAuthor);
return Response.success(resultMap);
}
/**
* 临床病例库-文章-评论-分页-用户
*/
@PostMapping("/clinical/article/user/comment/page")
public Response<Map<String, Object>> getUserClinicalArticleCommentPage(
@Validated()
@RequestBody getUserClinicalArticleCommentPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<UserCommentClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章评论数据
IPage<GetUserClinicalArticleCommentPageDto> resultPage = userCommentClinicalArticleDao.getUserClinicalArticleCommentPage(
page,
userId
);
for (GetUserClinicalArticleCommentPageDto dto : resultPage.getRecords()){
dto.setAuthor(new ArrayList<>());
// 获取文章作者数据
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, dto.getArticleId());
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
GetUserClinicalArticleCommentPageDto.CaseClinicalArticleAuthorDto authorDto = new GetUserClinicalArticleCommentPageDto.CaseClinicalArticleAuthorDto();
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
if (caseClinicalDoctor == null) {
return Response.error();
}
authorDto.setDoctorName(caseClinicalDoctor.getDoctorName());
dto.getAuthor().add(authorDto);
}
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
}

View File

@ -1,20 +1,31 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.common.Response;
import com.example.caseData.dao.*;
import com.example.caseData.dto.T;
import com.example.caseData.dto.caseClinicalVideo.CaseClinicalVideoDto;
import com.example.caseData.model.BasicHospitalModel;
import com.example.caseData.model.CaseClinicalVideoAuthorModel;
import com.example.caseData.model.CaseClinicalVideoModel;
import com.example.caseData.model.CaseClinicalDoctorModel;
import com.example.caseData.dto.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.example.caseData.dto.userCommentClinicalVideo.GetUserClinicalVideoCommentPageDto;
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.model.*;
import com.example.caseData.request.CaseClinicalArticleRequest.getUserClinicalArticleCommentPage;
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoApp;
import com.example.caseData.request.CaseClinicalVideoRequest.addClinicalVideoComment;
import com.example.caseData.request.CaseClinicalVideoRequest.getClinicalVideoCommentPage;
import com.example.caseData.service.CaseClinicalVideoService;
import com.example.caseData.service.CaseClinicalVideoService;
import com.example.caseData.utils.Replace;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.*;
@RestController
@RequestMapping("/api")
@ -34,6 +45,18 @@ public class CaseClinicalVideoController {
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseClinicalVideoService caseClinicalVideoService;
@Resource
private UserDao userDao;
@Resource
private UserCommentClinicalVideoDao userCommentClinicalVideoDao;
/**
* 临床病例库-视频-详情
*/
@ -42,14 +65,20 @@ public class CaseClinicalVideoController {
@PathVariable("video_id") String videoId
) {
// 获取视频数据
CaseClinicalVideoModel article = caseClinicalVideoDao.selectById(videoId);
if (article == null) {
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(videoId);
if (video == null) {
return Response.error("非法视频");
}
// 检测作品状态
boolean result = caseClinicalVideoService.checkClinicalVideoStatus(video);
if (!result){
return Response.error(201,null,"该作品已被删除");
}
// 查找作者
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, article.getVideoId());
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, video.getVideoId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
// 查询医生
@ -62,9 +91,359 @@ public class CaseClinicalVideoController {
author.setCaseClinicalDoctor(caseClinicalDoctor);
}
article.setAuthor(caseClinicalVideoAuthors);
video.setAuthor(caseClinicalVideoAuthors);
CaseClinicalVideoDto g = CaseClinicalVideoDto.GetDto(video);
// 是否已收藏
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId != null) {
// 检测用户是否已收藏过
UserCollectClinicalVideoModel userCollectClinicalVideo = caseClinicalVideoService.getUserCollectClinicalVideoStatus(videoId,userId);
if (userCollectClinicalVideo != null) {
g.setCollect(true);
}
}
CaseClinicalVideoDto g = CaseClinicalVideoDto.GetDto(article);
return Response.success(g);
}
/**
* 临床病例库-视频-收藏
*/
@PostMapping("/clinical/video/collect/{video_id}")
public Response<T> AddClinicalVideoCollect(
@PathVariable("video_id") String videoId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseClinicalVideoService.AddClinicalVideoCollect(videoId,userId);
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
/**
* 临床病例库-视频-取消收藏
*/
@DeleteMapping("/clinical/video/collect/{video_id}")
public Response<T> DeleteClinicalVideoCollect(
@PathVariable("video_id") String videoId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseClinicalVideoService.DeleteClinicalVideoCollect(videoId,userId);
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
/**
* 临床病例库-视频-新增评论
*/
@PostMapping("/clinical/video/comment/{video_id}")
public Response<Map<String, Object>> AddClinicalVideoComment(
@PathVariable("video_id") String videoId,
@Validated()
@RequestBody addClinicalVideoComment request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
Map<String, Object> resultData = new HashMap<>();
resultData.put("status", 1);
resultData.put("message", "成功");
try {
resultData = caseClinicalVideoService.AddClinicalVideoComment(videoId,userId,request);
return Response.success(200,resultData,"");
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
}
/**
* 临床病例库-视频-评论-删除
*/
@DeleteMapping("/clinical/video/comment/{comment_id}")
public Response<T> DeleteClinicalVideoComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseClinicalVideoService.DeleteClinicalVideoComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 临床病例库-视频-评论-置顶
*/
@PutMapping("/clinical/video/comment/top/{comment_id}")
public Response<T> AddTopClinicalVideoComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseClinicalVideoService.AddTopClinicalVideoComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 临床病例库-视频-评论-取消置顶
*/
@DeleteMapping("/clinical/video/comment/top/{comment_id}")
public Response<T> deleteTopClinicalVideoComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseClinicalVideoService.deleteTopClinicalVideoComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 临床病例库-视频-评论-列表
*/
@PostMapping("/clinical/video/comment/page")
public Response<Map<String, Object>> getClinicalVideoCommentPage(
@Validated()
@RequestBody getClinicalVideoCommentPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<UserCommentClinicalVideoDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取视频评论数据
IPage<UserCommentClinicalVideoDto> resultPage = userCommentClinicalVideoDao.getClinicalVideoCommentPage(
page,
request.getVideoId(),
request.getRootId()
);
// 获取视频数据
CaseClinicalVideoModel video = caseClinicalVideoDao.selectById(request.getVideoId());
if (video == null) {
return Response.error();
}
if (video.getVideoStatus() != 1){
return Response.error();
}
// 获取视频作者数据
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, request.getVideoId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
if (caseClinicalDoctor == null) {
return Response.error();
}
// 处理是否本人评论
for (UserCommentClinicalVideoDto dto : resultPage.getRecords()) {
if (Objects.equals(dto.getUserIden(), caseClinicalDoctor.getDoctorIden())){
dto.setIsAuthor(1);
}
}
}
// 处理返回值
for (UserCommentClinicalVideoDto dto : resultPage.getRecords()) {
// 查询医生
LambdaQueryWrapper<CaseClinicalDoctorModel> doctorQueryWrapper = new LambdaQueryWrapper<>();
doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, dto.getUserIden());
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
if (caseClinicalDoctor != null) {
dto.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
// 去除用户唯一标识
dto.setUserIden(null);
dto.setAvatar(Replace.addOssDomain(dto.getAvatar()));
// 图片
dto.setCommentImage(Replace.addOssDomain(dto.getCommentImage()));
// 获取次级评论
if (request.getIsHaveSubComment() == 1){
if (dto.getRootId() == null){
List<UserCommentClinicalVideoDto> subComments = userCommentClinicalVideoDao.getClinicalVideoCommentList(
dto.getVideoId(),
dto.getCommentId(),
5
);
for (UserCommentClinicalVideoDto subComment : subComments) {
// 查询医生
doctorQueryWrapper = new LambdaQueryWrapper<>();
doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, subComment.getUserIden());
caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
if (caseClinicalDoctor != null) {
subComment.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
subComment.setAvatar(Replace.addOssDomain(subComment.getAvatar()));
subComment.setCommentImage(Replace.addOssDomain(subComment.getCommentImage()));
}
dto.setSubComment(subComments);
}
}
}
// 获取全部评论数
LambdaQueryWrapper<UserCommentClinicalVideoModel> aQueryWrapper = new LambdaQueryWrapper<>();
aQueryWrapper.eq(UserCommentClinicalVideoModel::getVideoId, request.getVideoId());
Long total = userCommentClinicalVideoDao.selectCount(aQueryWrapper);
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", total);
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 临床病例库-视频-评论-分页-用户
*/
@PostMapping("/clinical/video/user/comment/page")
public Response<Map<String, Object>> getUserClinicalVideoCommentPage(
@Validated()
@RequestBody getUserClinicalArticleCommentPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<UserCommentClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章评论数据
IPage<GetUserClinicalVideoCommentPageDto> resultPage = userCommentClinicalVideoDao.getUserClinicalVideoCommentPage(
page,
userId
);
for (GetUserClinicalVideoCommentPageDto dto : resultPage.getRecords()){
dto.setAuthor(new ArrayList<>());
// 获取文章作者数据
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, dto.getVideoId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
GetUserClinicalVideoCommentPageDto.CaseClinicalVideoAuthorDto authorDto = new GetUserClinicalVideoCommentPageDto.CaseClinicalVideoAuthorDto();
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
if (caseClinicalDoctor == null) {
return Response.error();
}
authorDto.setDoctorName(caseClinicalDoctor.getDoctorName());
dto.getAuthor().add(authorDto);
}
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 临床病例库-视频-同步app视频
*/
@PostMapping("/app/clinical/video")
public Response<T> AddClinicalVideoApp(
HttpServletRequest request
) {
try {
boolean res = caseClinicalVideoService.AddClinicalVideoApp(request);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
}

View File

@ -0,0 +1,743 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.common.Response;
import com.example.caseData.dao.*;
import com.example.caseData.dto.T;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.caseExchangeLabel.CaseExchangeLabelDto;
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.model.*;
import com.example.caseData.request.caseExchangeRequest.*;
import com.example.caseData.service.CaseExchangeService;
import com.example.caseData.utils.IntToString;
import com.example.caseData.utils.Replace;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@RestController
@RequestMapping("/api")
public class CaseExchangeController {
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseExchangeDao caseExchangeDao;
@Resource
private UserDao userDao;
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private CaseExchangeService caseExchangeService;
@Resource
private CaseExchangeVoteDao caseExchangeVoteDao;
@Resource
private CaseExchangeLabelDao caseExchangeLabelDao;
@Resource
private CaseExchangeVoteOptionDao caseExchangeVoteOptionDao;
@Resource
private UserVoteExchangeDao userVoteExchangeDao;
@Resource
private UserCommentExchangeDao userCommentExchangeDao;
@Resource
private CaseClinicalDoctorDao caseClinicalDoctorDao;
/**
* 临床病例库-病例交流-搜索
*/
@PostMapping("/exchange/search")
public Response<Map<String, Object>> getCaseExchangeSearchPage(
@Validated()
@RequestBody getCaseExchangeSearchPage request
) {
UserModel user = new UserModel();
BasicHospitalModel basicHospital = new BasicHospitalModel();
// 此步骤是为了在我的病例交流列表页面少查询
String userId = (String) httpServletRequest.getAttribute("userId");
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<CaseExchangeDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取数据
IPage<CaseExchangeDto> resultPage = caseExchangeDao.getCaseExchangeSearchPage(
page,
request.getKeyword(),
request.getUserId(),
request.getIsSelected(),
request.getLabelIden(),
request.handleOrder()
);
for (CaseExchangeDto dto : resultPage.getRecords()) {
// 处理预览视频
dto.setExchangeContentVideoString(dto.getExchangeContentVideoString());
// 处理预览图片
if (dto.getExchangeContentVideo() == null){
dto.setExchangeContentImageString(dto.getExchangeContentImageString());
}
dto.setExchangeContentImageString("");
dto.setExchangeContentVideoString("");
user = userDao.selectById(dto.getUserId());
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
dto.setAvatar(Replace.addOssDomain(user.getAvatar()));
dto.setUserName(user.getUserName());
dto.setHospitalName(basicHospital.getHospitalName());
// 获取用户收藏状态
UserCollectExchangeModel userCollectExchangeModel = caseExchangeService.getUserCollectExchangeStatus(dto.getExchangeId(),userId);
if (userCollectExchangeModel != null) {
dto.setCollect(true);
}
// 查找标签
LambdaQueryWrapper<CaseExchangeLabelModel> labelQueryWrapper = new LambdaQueryWrapper<>();
labelQueryWrapper.eq(CaseExchangeLabelModel::getExchangeId, dto.getExchangeId());
List<CaseExchangeLabelModel> caseExchangeLabels = caseExchangeLabelDao.selectList(labelQueryWrapper);
if (caseExchangeLabels != null && !caseExchangeLabels.isEmpty()) {
List<CaseExchangeLabelDto> caseExchangeLabelDto = CaseExchangeLabelDto.GetListDto(caseExchangeLabels);
dto.setLabel(caseExchangeLabelDto);
}
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 病例交流-详情
*/
@GetMapping("/exchange/{exchange_id}")
public Response<CaseExchangeDto> getExchange(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取数据
CaseExchangeModel caseExchange = caseExchangeDao.selectById(exchangeId);
if (caseExchange == null) {
return Response.error();
}
// 检测作品状态
boolean result = caseExchangeService.checkCaseExchangeStatus(caseExchange);
if (!result){
return Response.error(201,null,"该作品已被删除");
}
// 查找用户
UserModel user = userDao.selectById(caseExchange.getUserId());
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
BasicHospitalModel basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
// 获取投票数据
LambdaQueryWrapper<CaseExchangeVoteModel> caseExchangeVoteQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteQueryWrapper.eq(CaseExchangeVoteModel::getExchangeId, caseExchange.getExchangeId());
CaseExchangeVoteModel caseExchangeVote = caseExchangeVoteDao.selectOne(caseExchangeVoteQueryWrapper);
if (caseExchangeVote != null) {
// 检测是否过期
if (caseExchangeVote.getEndTime() == null) {
return Response.error();
}
// 获取选项
LambdaQueryWrapper<CaseExchangeVoteOptionModel> caseExchangeVoteOptionQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteOptionQueryWrapper.eq(CaseExchangeVoteOptionModel::getVoteId, caseExchangeVote.getVoteId());
List<CaseExchangeVoteOptionModel> caseExchangeVoteOptions = caseExchangeVoteOptionDao.selectList(caseExchangeVoteOptionQueryWrapper);
if (caseExchangeVoteOptions.isEmpty()) {
return Response.error();
}
caseExchangeVote.setCaseExchangeVoteOption(caseExchangeVoteOptions);
caseExchange.setCaseExchangeVote(caseExchangeVote);
}
// 获取标签数据
LambdaQueryWrapper<CaseExchangeLabelModel> caseExchangeLabelQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeLabelQueryWrapper.eq(CaseExchangeLabelModel::getExchangeId, caseExchange.getExchangeId());
List<CaseExchangeLabelModel> caseExchangeLabels = caseExchangeLabelDao.selectList(caseExchangeLabelQueryWrapper);
if (caseExchangeLabels != null && !caseExchangeLabels.isEmpty()) {
caseExchange.setCaseExchangeLabel(caseExchangeLabels);
}
// 处理返回值
CaseExchangeDto g = CaseExchangeDto.GetDto(caseExchange);
g.setAvatar(Replace.addOssDomain(user.getAvatar()));
g.setUserName(user.getUserName());
g.setHospitalName(basicHospital.getHospitalName());
// 获取用户收藏状态
if (userId != null) {
// 检测用户是否已收藏过
UserCollectExchangeModel userCollectExchangeModel = caseExchangeService.getUserCollectExchangeStatus(String.valueOf(caseExchange.getExchangeId()),userId);
if (userCollectExchangeModel != null) {
g.setCollect(true);
}
}
// 处理投票数据
if (g.getCaseExchangeVote() != null){
if (g.getCaseExchangeVote().getEndTime().isAfter(LocalDateTime.now())) {
g.getCaseExchangeVote().setIsEnabled(1);
}else{
g.getCaseExchangeVote().setIsEnabled(0);
}
// 用户投票状态
if (userId != null) {
LambdaQueryWrapper<UserVoteExchangeModel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(UserVoteExchangeModel::getUserId, userId);
queryWrapper.eq(UserVoteExchangeModel::getExchangeId, exchangeId);
queryWrapper.eq(UserVoteExchangeModel::getVoteId, g.getCaseExchangeVote().getVoteId());
UserVoteExchangeModel userVoteExchange = userVoteExchangeDao.selectOne(queryWrapper);
if (userVoteExchange != null) {
// 已投过票
g.getCaseExchangeVote().setIsHaveVoted(1);
}
}
// 处理投票数据
Integer voteNum = 0;
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVote().getCaseExchangeVoteOption()){
voteNum += dto.getVoteNum();
}
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVote().getCaseExchangeVoteOption()){
Integer proportion = (int) (Math.round((double) dto.getVoteNum() / voteNum * 10000) / 100.0);
dto.setProportion(proportion);
}
}
return Response.success(g);
}
/**
* 临床病例库-病例交流-列表
*/
@PostMapping("/exchange/list")
public Response<List<CaseExchangeDto>> getCaseExchangeSearchList(
@Validated()
@RequestBody getCaseExchangeSearchList request
) {
request.validateForLimit();
// 获取数据
List<CaseExchangeDto> caseExchanges = caseExchangeDao.getCaseExchangeSearchLimitList(
request.getLimit(),
request.getKeyword(),
null,
request.getIsSelected(),
request.handleOrder()
);
return Response.success(caseExchanges);
}
/**
* 病例交流-详情-投票数据
*/
@GetMapping("/exchange/vote/{exchange_id}")
public Response<CaseExchangeVoteDto> getExchangeVote(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取投票数据
LambdaQueryWrapper<CaseExchangeVoteModel> caseExchangeVoteQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteQueryWrapper.eq(CaseExchangeVoteModel::getExchangeId, exchangeId);
CaseExchangeVoteModel caseExchangeVote = caseExchangeVoteDao.selectOne(caseExchangeVoteQueryWrapper);
if (caseExchangeVote == null) {
return Response.success();
}
// 检测是否过期
if (caseExchangeVote.getEndTime() == null) {
return Response.error();
}
// 获取选项
LambdaQueryWrapper<CaseExchangeVoteOptionModel> caseExchangeVoteOptionQueryWrapper = new LambdaQueryWrapper<>();
caseExchangeVoteOptionQueryWrapper.eq(CaseExchangeVoteOptionModel::getVoteId, caseExchangeVote.getVoteId());
List<CaseExchangeVoteOptionModel> caseExchangeVoteOptions = caseExchangeVoteOptionDao.selectList(caseExchangeVoteOptionQueryWrapper);
if (caseExchangeVoteOptions.isEmpty()) {
return Response.error();
}
caseExchangeVote.setCaseExchangeVoteOption(caseExchangeVoteOptions);
// 处理返回值
CaseExchangeVoteDto g = CaseExchangeVoteDto.GetDto(caseExchangeVote);
// 过期状态
if (g.getEndTime().isAfter(LocalDateTime.now())) {
g.setIsEnabled(1);
}else{
g.setIsEnabled(0);
}
// 用户投票状态
if (userId != null) {
LambdaQueryWrapper<UserVoteExchangeModel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(UserVoteExchangeModel::getUserId, userId);
queryWrapper.eq(UserVoteExchangeModel::getExchangeId, exchangeId);
queryWrapper.eq(UserVoteExchangeModel::getVoteId, g.getVoteId());
UserVoteExchangeModel userVoteExchange = userVoteExchangeDao.selectOne(queryWrapper);
if (userVoteExchange != null) {
// 已投过票
g.setIsHaveVoted(1);
}
}
// 处理投票数据
Integer voteNum = 0;
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVoteOption()){
voteNum += dto.getVoteNum();
}
for (CaseExchangeVoteOptionDto dto : g.getCaseExchangeVoteOption()){
Integer proportion = (int) (Math.round((double) dto.getVoteNum() / voteNum * 10000) / 100.0);
dto.setProportion(proportion);
}
return Response.success(g);
}
/**
* 病例交流-新增
*/
@PostMapping("/exchange")
public Response<T> AddCaseExchange(
@Validated()
@RequestBody addCaseExchange request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeService.AddCaseExchange(userId,request);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-修改
*/
@PutMapping("/exchange/{exchange_id}")
public Response<T> UpdateCaseExchange(
@Validated()
@RequestBody updateCaseExchange request,
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeService.UpdateCaseExchange(userId,exchangeId,request);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-删除
*/
@DeleteMapping("/exchange/{exchange_id}")
public Response<T> DeleteCaseExchange(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeService.DeleteCaseExchange(exchangeId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-收藏
*/
@PostMapping("/exchange/collect/{exchange_id}")
public Response<T> AddCaseExchangeCollect(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseExchangeService.AddCaseExchangeCollect(exchangeId,userId);
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
/**
* 病例交流-取消收藏
*/
@DeleteMapping("/exchange/collect/{exchange_id}")
public Response<T> DeleteCaseExchangeCollect(
@PathVariable("exchange_id") String exchangeId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseExchangeService.DeleteCaseExchangeCollect(exchangeId,userId);
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
/**
* 病例交流-新增评论
*/
@PostMapping("/exchange/comment/{exchange_id}")
public Response<Map<String, Object>> AddCaseExchangeComment(
@PathVariable("exchange_id") String exchangeId,
@Validated()
@RequestBody addCaseExchangeComment request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
Map<String, Object> resultData = new HashMap<>();
resultData.put("status", 1);
resultData.put("message", "成功");
try {
resultData = caseExchangeService.AddCaseExchangeComment(exchangeId,userId,request);
return Response.success(200,resultData,"");
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
}
/**
* 病例交流-评论-删除
*/
@DeleteMapping("/exchange/comment/{comment_id}")
public Response<T> DeleteCaseExchangeComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeService.DeleteCaseExchangeComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-评论-置顶
*/
@PutMapping("/exchange/comment/top/{comment_id}")
public Response<T> AddTopCaseExchangeComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeService.AddTopCaseExchangeComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-评论-取消置顶
*/
@DeleteMapping("/exchange/comment/top/{comment_id}")
public Response<T> deleteTopCaseExchangeComment(
@PathVariable("comment_id") String commentId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeService.deleteTopCaseExchangeComment(commentId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-评论-分页
*/
@PostMapping("/exchange/comment/page")
public Response<Map<String, Object>> getCaseExchangeCommentPage(
@Validated()
@RequestBody getCaseExchangeCommentPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<UserCommentCaseExchangeDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取评论数据
IPage<UserCommentCaseExchangeDto> resultPage = userCommentExchangeDao.getCaseExchangeCommentPage(
page,
request.getExchangeId(),
request.getRootId()
);
// 处理是否本人评论
for (UserCommentCaseExchangeDto dto : resultPage.getRecords()) {
if (Objects.equals(dto.getUserId(), userId)){
dto.setIsAuthor(1);
}
}
// 处理返回值
for (UserCommentCaseExchangeDto dto : resultPage.getRecords()) {
// 查询医生
LambdaQueryWrapper<CaseClinicalDoctorModel> doctorQueryWrapper = new LambdaQueryWrapper<>();
doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, dto.getUserIden());
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
if (caseClinicalDoctor != null) {
dto.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
dto.setAvatar(Replace.addOssDomain(dto.getAvatar()));
// 去除用户唯一标识
dto.setUserIden(null);
// 图片
dto.setCommentImage(Replace.addOssDomain(dto.getCommentImage()));
// 获取次级评论
if (request.getIsHaveSubComment() == 1){
if (dto.getRootId() == null){
List<UserCommentCaseExchangeDto> subComments = userCommentExchangeDao.getCaseExchangeCommentList(
dto.getExchangeId(),
dto.getCommentId(),
5
);
for (UserCommentCaseExchangeDto subComment : subComments) {
// 查询医生
doctorQueryWrapper = new LambdaQueryWrapper<>();
doctorQueryWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, subComment.getUserIden());
caseClinicalDoctor = caseClinicalDoctorDao.selectOne(doctorQueryWrapper);
if (caseClinicalDoctor != null) {
subComment.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
subComment.setAvatar(Replace.addOssDomain(subComment.getAvatar()));
subComment.setCommentImage(Replace.addOssDomain(subComment.getCommentImage()));
}
dto.setSubComment(subComments);
}
}
}
// 获取全部评论数
LambdaQueryWrapper<UserCommentExchangeModel> aQueryWrapper = new LambdaQueryWrapper<>();
aQueryWrapper.eq(UserCommentExchangeModel::getExchangeId, request.getExchangeId());
Long total = userCommentExchangeDao.selectCount(aQueryWrapper);
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", total);
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 病例交流-评论-分页-用户
*/
@PostMapping("/exchange/user/comment/page")
public Response<Map<String, Object>> getUserCaseExchangeCommentPage(
@Validated()
@RequestBody getUserCaseExchangeCommentPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<UserCommentCaseExchangeDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取评论数据
IPage<GetUserCaseExchangeCommentPageDto> resultPage = userCommentExchangeDao.getUserCaseExchangeCommentPage(
page,
userId
);
// 处理返回值
for (GetUserCaseExchangeCommentPageDto dto : resultPage.getRecords()) {
if (dto.getAuthorTitleInt() != null) {
dto.setAuthorTitle(IntToString.DoctorTitleToString(dto.getAuthorTitleInt()));
}
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 病例交流-投票
*/
@PostMapping("/exchange/vote/{exchange_id}")
public Response<T> AddCaseExchangeVote(
@Validated()
@PathVariable("exchange_id") String exchangeId,
@RequestBody addCaseExchangeVote r
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
boolean res = caseExchangeService.AddCaseExchangeVote(exchangeId,userId,r.getOptionId());
if (!res){
return Response.error("操作失败");
}
return Response.success();
}
}

View File

@ -0,0 +1,189 @@
package com.example.caseData.controller;
import cn.hutool.core.lang.Dict;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.common.Response;
import com.example.caseData.dao.*;
import com.example.caseData.dto.T;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.caseExchangeDraft.CaseExchangeDraftDto;
import com.example.caseData.dto.caseExchangeLabel.CaseExchangeLabelDto;
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.model.*;
import com.example.caseData.request.caseExchangeDraftRequest.addCaseExchangeDraft;
import com.example.caseData.request.caseExchangeDraftRequest.getCaseExchangeDraftSearchPage;
import com.example.caseData.request.caseExchangeRequest.*;
import com.example.caseData.service.CaseExchangeDraftService;
import com.example.caseData.service.CaseExchangeService;
import com.example.caseData.utils.IntToString;
import com.example.caseData.utils.Replace;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.*;
@RestController
@RequestMapping("/api")
public class CaseExchangeDraftController {
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseExchangeDao caseExchangeDao;
@Resource
private UserDao userDao;
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private CaseExchangeService caseExchangeService;
@Resource
private CaseExchangeDraftService caseExchangeDraftService;
@Resource
private CaseExchangeDraftDao caseExchangeDraftDao;
@Resource
private CaseExchangeVoteDao caseExchangeVoteDao;
@Resource
private CaseExchangeLabelDao caseExchangeLabelDao;
@Resource
private CaseExchangeVoteOptionDao caseExchangeVoteOptionDao;
@Resource
private UserVoteExchangeDao userVoteExchangeDao;
@Resource
private UserCommentExchangeDao userCommentExchangeDao;
/**
* 临床病例库-病例交流-草稿-搜索
*/
@PostMapping("/exchange/draft/search")
public Response<Map<String, Object>> getCaseExchangeDraftSearchPage(
@Validated()
@RequestBody getCaseExchangeDraftSearchPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<CaseExchangeDraftDto> page = new Page<>(request.getPage(), request.getPageSize());
IPage<CaseExchangeDraftDto> resultPage = caseExchangeDraftDao.getCaseExchangeDraftSearchPage(
page,
userId,
request.handleOrder()
);
for (CaseExchangeDraftDto dto : resultPage.getRecords()) {
// 处理标签
if (dto.getExchangeLabelJson() != null && !dto.getExchangeLabelJson().isEmpty()){
try {
JSONArray array = JSONUtil.parseArray(dto.getExchangeLabelJson());
List<CaseExchangeDraftDto.CaseExchangeLabelDto> caseExchangeLabelDto = JSONUtil.toList(array, CaseExchangeDraftDto.CaseExchangeLabelDto.class);
dto.setExchangeLabel(caseExchangeLabelDto);
dto.setExchangeLabelJson("");
} catch (Exception e) {
return Response.error(e.getMessage());
}
}
// 处理投票
if (dto.getExchangeVoteJson() != null && !dto.getExchangeVoteJson().isEmpty()){
try {
CaseExchangeDraftDto.ExchangeVoteDto caseExchangeVoteDto = JSONUtil.toBean(dto.getExchangeVoteJson(), CaseExchangeDraftDto.ExchangeVoteDto.class);
dto.setExchangeVote(caseExchangeVoteDto);
dto.setExchangeVoteJson("");
} catch (Exception e) {
return Response.error(e.getMessage());
}
}
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 临床病例库-病例交流-草稿-新增
*/
@PostMapping("/exchange/draft")
public Response<T> AddCaseExchangeDraft(
@Validated()
@RequestBody addCaseExchangeDraft request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeDraftService.AddCaseExchangeDraft(request,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
/**
* 病例交流-草稿-删除
*/
@DeleteMapping("/exchange/draft/{draft_id}")
public Response<T> DeleteCaseExchangeComment(
@PathVariable("draft_id") String draftId
) {
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error("操作失败");
}
try {
boolean res = caseExchangeDraftService.DeleteCaseExchangeDraft(draftId,userId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
}

View File

@ -0,0 +1,50 @@
package com.example.caseData.controller;
import com.example.caseData.common.Response;
import com.example.caseData.dto.caseLabel.GetCaseLabelDto;
import com.example.caseData.dto.user.UserDto;
import com.example.caseData.extend.app.Hospital.GetHospitalByUuidResponse;
import com.example.caseData.extend.app.Hospital.Hospital;
import com.example.caseData.extend.app.label.GetLabelsResponse;
import com.example.caseData.extend.app.label.Label;
import com.example.caseData.request.UserRequest.UserRequest;
import com.example.caseData.request.caseLabelRequest.getCaseLabel;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/api")
public class CaseLabelController {
@Resource
private Label label;
/**
* 获取疾病标签数据
*/
@GetMapping("/case/label")
public Response<List<GetCaseLabelDto>> getCaseLabel(@Validated() @ModelAttribute getCaseLabel request) {
GetLabelsResponse result = label.getLabels(request.getPId());
List<GetLabelsResponse.GetLabelsData> datas = result.getData();
List<GetCaseLabelDto> labelDtoList = new ArrayList<>();
for (GetLabelsResponse.GetLabelsData d : datas) {
GetCaseLabelDto dto = new GetCaseLabelDto();
dto.setAppIden(d.getId());
dto.setLabelName(d.getName());
if (d.getChildrenSize() > 0){
dto.setIsSub(1);
}
labelDtoList.add(dto);
}
return Response.success(labelDtoList);
}
}

View File

@ -13,23 +13,21 @@ import com.example.caseData.dto.caseClinicalVideo.CaseClinicalVideoDto;
import com.example.caseData.dto.caseClinicalVideoAuthor.CaseClinicalVideoAuthorDto;
import com.example.caseData.dto.statsCaseClinicalDoctor.StatsCaseClinicalDoctorDto;
import com.example.caseData.dto.statsCaseClinicalHospital.StatsCaseClinicalHospitalDto;
import com.example.caseData.model.BasicHospitalModel;
import com.example.caseData.model.CaseClinicalArticleAuthorModel;
import com.example.caseData.model.CaseClinicalDoctorModel;
import com.example.caseData.model.CaseClinicalVideoAuthorModel;
import com.example.caseData.request.clinicalRequest.getClinicalDoctorSearchPage;
import com.example.caseData.request.clinicalRequest.getClinicalHospitalSearchPage;
import com.example.caseData.request.clinicalRequest.getClinicalSearchPage;
import com.example.caseData.dto.statsCaseClinicalLabel.StatsCaseClinicalLabelDto;
import com.example.caseData.model.*;
import com.example.caseData.request.clinicalRequest.*;
import com.example.caseData.service.CaseClinicalArticleService;
import com.example.caseData.service.CaseClinicalVideoService;
import com.example.caseData.utils.Replace;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@RestController
@RequestMapping("/api")
@ -61,84 +59,199 @@ public class ClinicalController extends BaseController {
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseClinicalArticleService caseClinicalArticleService;
@Resource
private CaseClinicalVideoService caseClinicalVideoService;
@Resource
private StatsCaseClinicalLabelDao statsCaseClinicalLabelDao;
@Resource
private UserDao userDao;
@Resource
private CaseClinicalDoctorCertDao caseClinicalDoctorCertDao;
/**
* 临床病例库-搜索
* 临床病例库-搜索-文章
*/
@PostMapping("/clinical/search")
public Response<Map<String, Object>> getClinicalSearchPage(
@Validated({getClinicalSearchPage.class})
@RequestBody getClinicalSearchPage request
@PostMapping("/clinical/article/search")
public Response<Map<String, Object>> getClinicalArticleSearchPage(
@Validated()
@RequestBody getClinicalArticleSearchPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取用户数据
UserModel user = userDao.selectById(userId);
if (user == null) {
return Response.error("错误");
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
if (request.getType() == 1){
Page<CaseClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
Page<CaseClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<CaseClinicalArticleDto> resultPage = caseClinicalArticleDao.getCaseClinicalArticleSearchPage(
page,
request.getTitle(),
request.getDoctorName(),
request.getLabelName(),
// 获取文章数据
IPage<CaseClinicalArticleDto> resultPage = caseClinicalArticleDao.getCaseClinicalArticleSearchPage(
page,
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
request.getLabelIden(),
request.handleOrder()
);
for (CaseClinicalArticleDto dto : resultPage.getRecords()) {
// 查找作者
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, dto.getArticleId());
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
author.setCaseClinicalDoctor(caseClinicalDoctor);
if (Objects.equals(user.getUserIden(), caseClinicalDoctor.getDoctorIden())){
// 获取医生证书
LambdaQueryWrapper<CaseClinicalDoctorCertModel> certWrapper = new LambdaQueryWrapper<>();
certWrapper.eq(CaseClinicalDoctorCertModel::getDoctorId, caseClinicalDoctor.getDoctorId());
certWrapper.eq(CaseClinicalDoctorCertModel::getId, dto.getArticleId());
certWrapper.eq(CaseClinicalDoctorCertModel::getType, 1);
CaseClinicalDoctorCertModel caseClinicalDoctorCert = caseClinicalDoctorCertDao.selectOne(certWrapper);
if (caseClinicalDoctorCert != null){
dto.setCertImage(Replace.addOssDomain(caseClinicalDoctorCert.getCertImage()));
}
}
}
List<CaseClinicalArticleAuthorDto> caseClinicalArticleAuthorListDto = CaseClinicalArticleAuthorDto.GetListDto(caseClinicalArticleAuthors);
dto.setAuthor(caseClinicalArticleAuthorListDto);
// 获取用户收藏状态
if (userId != null) {
// 检测用户是否已收藏过
UserCollectClinicalArticleModel userCollectClinicalArticle = caseClinicalArticleService.getUserCollectClinicalArticleStatus(dto.getArticleId(),userId);
if (userCollectClinicalArticle != null) {
dto.setCollect(true);
}
}
}
if (request.getIsNeedNum() == 1){
// 获取视频数量
Long searchVideoNum = caseClinicalVideoDao.getCaseClinicalVideoSearchCount(
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
request.handleOrder()
request.getLabelIden()
);
for (CaseClinicalArticleDto dto : resultPage.getRecords()) {
// 查找作者
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, dto.getArticleId());
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
author.setCaseClinicalDoctor(caseClinicalDoctor);
}
List<CaseClinicalArticleAuthorDto> caseClinicalArticleAuthorListDto = CaseClinicalArticleAuthorDto.GetListDto(caseClinicalArticleAuthors);
dto.setAuthor(caseClinicalArticleAuthorListDto);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
} else if (request.getType() == 2) {
Page<CaseClinicalVideoDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取视频数据
IPage<CaseClinicalVideoDto> resultPage = caseClinicalVideoDao.getCaseClinicalVideoSearchPage(
page,
request.getTitle(),
request.getDoctorName(),
request.getLabelName(),
request.handleOrder()
);
for (CaseClinicalVideoDto dto : resultPage.getRecords()) {
// 查找作者
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, dto.getVideoId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
author.setCaseClinicalDoctor(caseClinicalDoctor);
}
List<CaseClinicalVideoAuthorDto> caseClinicalVideoAuthorListDto = CaseClinicalVideoAuthorDto.GetListDto(caseClinicalVideoAuthors);
dto.setAuthor(caseClinicalVideoAuthorListDto);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
resultMap.put("search_article_num", resultPage.getTotal());
resultMap.put("search_video_num", searchVideoNum);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 临床病例库-搜索-视频
*/
@PostMapping("/clinical/video/search")
public Response<Map<String, Object>> getClinicalVideoSearchPage(
@Validated()
@RequestBody getClinicalVideoSearchPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取用户数据
UserModel user = userDao.selectById(userId);
if (user == null) {
return Response.error("错误");
}
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
Page<CaseClinicalVideoDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取视频数据
IPage<CaseClinicalVideoDto> resultPage = caseClinicalVideoDao.getCaseClinicalVideoSearchPage(
page,
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
request.getLabelIden(),
request.handleOrder()
);
for (CaseClinicalVideoDto dto : resultPage.getRecords()) {
// 查找作者
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, dto.getVideoId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
author.setCaseClinicalDoctor(caseClinicalDoctor);
if (Objects.equals(user.getUserIden(), caseClinicalDoctor.getDoctorIden())){
// 获取医生证书
LambdaQueryWrapper<CaseClinicalDoctorCertModel> certWrapper = new LambdaQueryWrapper<>();
certWrapper.eq(CaseClinicalDoctorCertModel::getDoctorId, caseClinicalDoctor.getDoctorId());
certWrapper.eq(CaseClinicalDoctorCertModel::getId, dto.getVideoId());
certWrapper.eq(CaseClinicalDoctorCertModel::getType, 2);
CaseClinicalDoctorCertModel caseClinicalDoctorCert = caseClinicalDoctorCertDao.selectOne(certWrapper);
if (caseClinicalDoctorCert != null){
dto.setCertImage(Replace.addOssDomain(caseClinicalDoctorCert.getCertImage()));
}
}
}
List<CaseClinicalVideoAuthorDto> caseClinicalVideoAuthorListDto = CaseClinicalVideoAuthorDto.GetListDto(caseClinicalVideoAuthors);
dto.setAuthor(caseClinicalVideoAuthorListDto);
// 获取用户收藏状态
if (userId != null) {
// 检测用户是否已收藏过
UserCollectClinicalVideoModel userCollectClinicalVideo = caseClinicalVideoService.getUserCollectClinicalVideoStatus(dto.getVideoId(),userId);
if (userCollectClinicalVideo != null) {
dto.setCollect(true);
}
}
}
if (request.getIsNeedNum() == 1){
// 获取文章数量
Long searchArticleNum = caseClinicalArticleDao.getCaseClinicalArticleSearchCount(
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
request.getLabelIden()
);
resultMap.put("search_article_num", searchArticleNum);
resultMap.put("search_video_num", resultPage.getTotal());
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
@ -215,4 +328,30 @@ public class ClinicalController extends BaseController {
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
/**
* 临床病例库-疾病标签-搜索
*/
@PostMapping("/clinical/label/search")
public Response<Map<String, Object>> getClinicalLabelSearchPage(
@Validated()
@RequestBody getClinicalLabelSearchPage request
) {
request.validateForPage();
Page<StatsCaseClinicalHospitalDto> page = new Page<>(request.getPage(), request.getPageSize());
IPage<StatsCaseClinicalLabelDto> resultPage = statsCaseClinicalLabelDao.getStatsCaseClinicalLabelSearchPage(
page,
request.getLabelName(),
request.handleOrder()
);
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
return Response.success(resultMap);
}
}

View File

@ -2,6 +2,7 @@ package com.example.caseData.controller;
import com.example.caseData.common.Response;
import com.example.caseData.dto.index.GetIndexClinicalDto;
import com.example.caseData.dto.index.GetIndexExchangeDto;
import com.example.caseData.service.IndexService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
@ -19,5 +20,4 @@ public class IndexController extends BaseController {
public Response<GetIndexClinicalDto> getIndexClinical() {
return Response.success(indexService.GetIndexClinical());
}
}

View File

@ -1,39 +1,268 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.example.caseData.common.Response;
import com.example.caseData.dao.UserDao;
import com.example.caseData.dto.PublicDto;
import com.example.caseData.model.BasicHospitalModel;
import com.example.caseData.model.UserModel;
import com.example.caseData.request.PublicRequest;
import com.example.caseData.request.UserRequest;
import com.example.caseData.config.EnvConfig;
import com.example.caseData.dto.T;
import com.example.caseData.dto.publicDto.GetOssSignDto;
import com.example.caseData.dto.publicDto.LoginDto;
import com.example.caseData.dto.user.UserDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.aliyun.DySms;
import com.example.caseData.extend.aliyun.Oss;
import com.example.caseData.extend.weChat.WxMaServiceUtils;
import com.example.caseData.request.publicRequest.*;
import com.example.caseData.request.UserRequest.UserRequest;
import com.example.caseData.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.Duration;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
@RequiredArgsConstructor
@RestController
@RequestMapping("/api")
@Slf4j
public class PublicController {
@Resource
private UserService userService;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private EnvConfig envConfig;
private final WxMaServiceUtils wxMaServiceUtils;
@Resource
private RedisTemplate<String, String> redisTemplate;
@Resource
private DySms dySms;
// 登陆
@PostMapping("/login/wechat/mobile")
public Response<PublicDto> login(@Validated({PublicRequest.Login.class}) @ModelAttribute PublicRequest request) {
public Response<LoginDto> loginWechatMobile(@Validated({LoginRequest.Login.class}) @ModelAttribute LoginRequest request) {
// 微信手机号授权登录
try {
// 获取手机号
WxMaPhoneNumberInfo phoneInfo = wxMaServiceUtils.getPhoneNumber(request.getPhone_code());
if (phoneInfo == null) {
return Response.error("微信授权失败");
}
if (phoneInfo.getPurePhoneNumber() == null) {
return Response.error("微信授权失败");
}
// 获取用户openid
WxMaJscode2SessionResult wxInfoData = wxMaServiceUtils.getSessionInfo(request.getWx_code());
if (wxInfoData == null) {
return Response.error("微信授权失败");
}
// 临时测试使用
String phone = "18221234167";
if (wxInfoData.getOpenid() == null) {
return Response.error("微信授权失败");
}
// 用户登陆
PublicDto g = userService.UserLogin(phone);
if (wxInfoData.getSessionKey() == null) {
return Response.error("微信授权失败");
}
Map resultMap = userService.getAppUser(phoneInfo.getPurePhoneNumber());
log.info(resultMap.toString());
// 取出code
Integer code = (Integer) resultMap.get("code");
if (code != 200){
String msg = (String) resultMap.get("msg");
if (msg != null && !msg.isEmpty()){
return Response.error(code,null,msg);
}
return Response.error(code,null,"登陆失败");
}
// 用户登陆
LoginDto g = userService.UserLoginWithMobile(phoneInfo.getPurePhoneNumber());
return Response.success(g);
} catch (Exception e) {
if (Objects.equals(e.getMessage(), "请耐心等待审核")){
return Response.error(10005,null,e.getMessage());
}
if (Objects.equals(e.getMessage(), "待补充资料")){
return Response.error(10007,null,e.getMessage());
}
return Response.error(e.getMessage());
}
}
// 登陆
@PostMapping("/login/hcp")
public Response<LoginDto> loginHcp(@Validated() @ModelAttribute LoginHcpRequest request) {
try {
// 用户登陆
LoginDto g = userService.UserLoginWithApp(request.getToken());
return Response.success(g);
} catch (Exception e) {
if (Objects.equals(e.getMessage(), "请耐心等待审核")){
return Response.error(10005,null,e.getMessage());
}
if (Objects.equals(e.getMessage(), "待补充资料")){
return Response.error(10007,null,e.getMessage());
}
// if (Objects.equals(e.getMessage(), "没有HCP权限")){
// return Response.error(405,null,e.getMessage());
// }
return Response.error(e.getMessage());
}
}
// 获取签名
@GetMapping("/sign/oss")
public Response<GetOssSignDto> GetOssSign(
@Validated()
@ModelAttribute GetOssSignRequest request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
String ossPath = "dev/";
if (Objects.equals(envConfig.getActive(), "prod")){
ossPath = "prod/";
}
if (request.getScene() == 1){
ossPath = ossPath + "static/images/exchange/";
}else if (request.getScene() == 2){
ossPath = ossPath + "static/video/exchange/";
}else{
return Response.error();
}
// 生成签名
GetOssSignDto g = Oss.getOssSign(ossPath);
return Response.success(g);
}
// 获取验证码
@PostMapping("/code/phone")
public Response<T> GetPhoneCode(@Validated() @ModelAttribute GetPhoneCodeRequest request) {
String templateCode = "";
String scene = "注册验证码";
// 手机号登录
if (request.getScene() == 1){
templateCode = "SMS_215344868";
scene = "注册验证码";
}
// 限流 key
String limitKey = "sms:limit:" + request.getPhone();
// 验证码缓存 key
String codeKey = "sms:code:" + request.getPhone();
// 获取当前请求次数
String countStr = redisTemplate.opsForValue().get(limitKey);
int count = countStr != null ? Integer.parseInt(countStr) : 0;
if (count > 3) {
return Response.error("验证码请求过于频繁,请稍后再试");
}
// 生成 4 位数字验证码
String code = String.format("%04d", new Random().nextInt(10000));
try {
dySms.sendSms(
request.getPhone(),
templateCode,
scene,
Map.of("code", code)
);
} catch (Exception e) {
return Response.error(e.getMessage());
}
// 缓存验证码有效期 5 分钟
redisTemplate.opsForValue().set(codeKey, code, Duration.ofMinutes(5));
// 缓存请求次数
if (count == 0) {
// 初次请求设置有效期为 5 分钟
redisTemplate.opsForValue().set(limitKey, "1", Duration.ofMinutes(5));
} else {
redisTemplate.opsForValue().increment(limitKey);
}
return Response.success();
}
// 登陆
@PostMapping("/login/mobile")
public Response<LoginDto> loginPhone(@Validated() @ModelAttribute LoginPhoneRequest request) {
// 验证码缓存 key
if (!Objects.equals(envConfig.getActive(), "dev")){
String codeKey = "sms:code:" + request.getPhone();
String code = redisTemplate.opsForValue().get(codeKey);
if (!Objects.equals(request.getCode(), code)){
return Response.error("验证码错误");
}
}
try {
// 获取用户openid
WxMaJscode2SessionResult wxInfoData = wxMaServiceUtils.getSessionInfo(request.getWx_code());
if (wxInfoData == null) {
return Response.error("微信授权失败");
}
if (wxInfoData.getOpenid() == null) {
return Response.error("微信授权失败");
}
if (wxInfoData.getSessionKey() == null) {
return Response.error("微信授权失败");
}
Map resultMap = userService.getAppUser(request.getPhone());
// 取出code
Integer code = (Integer) resultMap.get("code");
if (code != 200){
String msg = (String) resultMap.get("msg");
if (msg != null && !msg.isEmpty()){
return Response.error(code,null,msg);
}
return Response.error(code,null,"登陆失败");
}
// 用户登陆
LoginDto g = userService.UserLoginWithMobile(request.getPhone());
return Response.success(g);
} catch (Exception e) {
if (Objects.equals(e.getMessage(), "请耐心等待审核")){
return Response.error(10005,null,e.getMessage());
}
if (Objects.equals(e.getMessage(), "待补充资料")){
return Response.error(10007,null,e.getMessage());
}
return Response.error(e.getMessage());
}
}
}

View File

@ -0,0 +1,50 @@
package com.example.caseData.controller;
import com.example.caseData.common.Response;
import com.example.caseData.dto.T;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.request.RewardPointRequest.rewardPoint;
import com.example.caseData.service.RewardPointService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/api")
public class RewardPointController {
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private RewardPointService rewardService;
/**
* 临床病例库-打赏
*/
@PostMapping("/reward")
public Response<T> RewardPoint(@Validated() @ModelAttribute rewardPoint r) {
// 判断参数
if (r.getType() != 1 && r.getType() != 2 && r.getType() != 3){
return Response.error("操作失败");
}
String userId = (String) httpServletRequest.getAttribute("userId");
try {
boolean res = rewardService.RewardPoint(userId,r);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
}

View File

@ -2,16 +2,23 @@ package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.caseData.common.Response;
import com.example.caseData.dao.StatsCaseClinicalDao;
import com.example.caseData.dao.StatsCaseClinicalDoctorDao;
import com.example.caseData.dao.StatsCaseClinicalHospitalDao;
import com.example.caseData.dao.*;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.caseClinicalVideo.CaseClinicalVideoDto;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.statsCaseClinical.StatsCaseClinicalDto;
import com.example.caseData.dto.statsCaseClinicalDoctor.StatsCaseClinicalDoctorDto;
import com.example.caseData.dto.statsCaseClinicalHospital.StatsCaseClinicalHospitalDto;
import com.example.caseData.dto.statsCaseClinicalLabel.StatsCaseClinicalLabelDto;
import com.example.caseData.model.*;
import com.example.caseData.request.StatsCaseClinicalRequest.getClinicalStatsLabel;
import com.example.caseData.request.caseLabelRequest.getCaseLabel;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api")
public class StatsCaseClinicalController extends BaseController {
@ -24,6 +31,15 @@ public class StatsCaseClinicalController extends BaseController {
@Resource
private StatsCaseClinicalDoctorDao statsCaseClinicalDoctorDao;
@Resource
private StatsCaseClinicalLabelDao statsCaseClinicalLabelDao;
@Resource
private CaseClinicalArticleDao caseClinicalArticleDao;
@Resource
private CaseClinicalVideoDao caseClinicalVideoDao;
/**
* 临床病例库-统计
*/
@ -35,6 +51,15 @@ public class StatsCaseClinicalController extends BaseController {
StatsCaseClinicalDto g = StatsCaseClinicalDto.GetDto(statsCaseClinical);
if (g == null){
return Response.success(new StatsCaseClinicalDto());
}
Long articleReadNum = caseClinicalArticleDao.getTotalReadNum();
Long videoReadNum = caseClinicalVideoDao.getTotalReadNum();
g.setArticleReadNum(Math.toIntExact(articleReadNum));
g.setVideoReadNum(Math.toIntExact(videoReadNum));
return Response.success(g);
}
@ -46,12 +71,40 @@ public class StatsCaseClinicalController extends BaseController {
@PathVariable("hospital_id") String hospitalId
){
// 统计表-病例库-临床
LambdaQueryWrapper<StatsCaseClinicalHospitalModel> statsCaseClinicalHospitalQueryWrapper = new LambdaQueryWrapper<>();
statsCaseClinicalHospitalQueryWrapper.eq(StatsCaseClinicalHospitalModel::getHospitalId, hospitalId);
StatsCaseClinicalHospitalModel statsCaseClinicalHospital = statsCaseClinicalHospitalDao.selectOne(statsCaseClinicalHospitalQueryWrapper);
Integer articleReadNum = 0;
Integer videoReadNum = 0;
StatsCaseClinicalHospitalDto g = StatsCaseClinicalHospitalDto.GetDto(statsCaseClinicalHospital);
// 获取该标签下文章数据
List<CaseClinicalArticleDto> caseClinicalArticles = caseClinicalArticleDao.getCaseClinicalArticleSearchList(
"",
hospitalId,
"",
"",
null
);
for (CaseClinicalArticleDto article : caseClinicalArticles){
articleReadNum += article.getReadNum();
}
// 获取该标签下视频数据
List<CaseClinicalVideoDto> caseClinicalVideos = caseClinicalVideoDao.getCaseClinicalVideoSearchList(
"",
hospitalId,
"",
"",
null
);
for (CaseClinicalVideoDto video : caseClinicalVideos){
videoReadNum += video.getReadNum();
}
StatsCaseClinicalHospitalDto g = new StatsCaseClinicalHospitalDto();
g.setStatsId("1");
g.setArticleNum(caseClinicalArticles.size());
g.setArticleReadNum(articleReadNum);
g.setVideoNum(caseClinicalVideos.size());
g.setVideoReadNum(videoReadNum);
return Response.success(g);
}
@ -63,12 +116,85 @@ public class StatsCaseClinicalController extends BaseController {
public Response<StatsCaseClinicalDoctorDto> getClinicalStatsDoctor(
@PathVariable("doctor_id") String doctorId
){
// 统计表-病例库-临床
LambdaQueryWrapper<StatsCaseClinicalDoctorModel> statsCaseClinicalDoctorQueryWrapper = new LambdaQueryWrapper<>();
statsCaseClinicalDoctorQueryWrapper.eq(StatsCaseClinicalDoctorModel::getDoctorId, doctorId);
StatsCaseClinicalDoctorModel statsCaseClinicalDoctor = statsCaseClinicalDoctorDao.selectOne(statsCaseClinicalDoctorQueryWrapper);
Integer articleReadNum = 0;
Integer videoReadNum = 0;
StatsCaseClinicalDoctorDto g = StatsCaseClinicalDoctorDto.GetDto(statsCaseClinicalDoctor);
// 获取该标签下文章数据
List<CaseClinicalArticleDto> caseClinicalArticles = caseClinicalArticleDao.getCaseClinicalArticleSearchList(
"",
"",
doctorId,
"",
null
);
for (CaseClinicalArticleDto article : caseClinicalArticles){
articleReadNum += article.getReadNum();
}
// 获取该标签下视频数据
List<CaseClinicalVideoDto> caseClinicalVideos = caseClinicalVideoDao.getCaseClinicalVideoSearchList(
"",
"",
doctorId,
"",
null
);
for (CaseClinicalVideoDto video : caseClinicalVideos){
videoReadNum += video.getReadNum();
}
StatsCaseClinicalDoctorDto g = new StatsCaseClinicalDoctorDto();
g.setStatsId("1");
g.setArticleNum(caseClinicalArticles.size());
g.setArticleReadNum(articleReadNum);
g.setVideoNum(caseClinicalVideos.size());
g.setVideoReadNum(videoReadNum);
return Response.success(g);
}
/**
* 临床病例库-统计-疾病标签
*/
@GetMapping("/clinical/stats/label")
public Response<StatsCaseClinicalLabelDto> getClinicalStatsLabel(
@Validated() @ModelAttribute getClinicalStatsLabel request
){
Integer articleReadNum = 0;
Integer videoReadNum = 0;
// 获取该标签下文章数据
List<CaseClinicalArticleDto> caseClinicalArticles = caseClinicalArticleDao.getCaseClinicalArticleSearchList(
"",
"",
"",
request.getLabel_iden(),
null
);
for (CaseClinicalArticleDto article : caseClinicalArticles){
articleReadNum += article.getReadNum();
}
// 获取该标签下视频数据
List<CaseClinicalVideoDto> caseClinicalVideos = caseClinicalVideoDao.getCaseClinicalVideoSearchList(
"",
"",
"",
request.getLabel_iden(),
null
);
for (CaseClinicalVideoDto video : caseClinicalVideos){
videoReadNum += video.getReadNum();
}
StatsCaseClinicalLabelDto g = new StatsCaseClinicalLabelDto();
g.setStatsId("1");
g.setArticleNum(caseClinicalArticles.size());
g.setArticleReadNum(articleReadNum);
g.setVideoNum(caseClinicalVideos.size());
g.setVideoReadNum(videoReadNum);
return Response.success(g);
}

View File

@ -0,0 +1,97 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.caseData.common.Response;
import com.example.caseData.dao.CaseExchangeDao;
import com.example.caseData.dao.StatsCaseExchangeDao;
import com.example.caseData.dao.StatsCaseExchangeUserDao;
import com.example.caseData.dao.StatsCaseExchangeUserDao;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.statsCaseClinical.StatsCaseClinicalDto;
import com.example.caseData.dto.statsCaseExchange.StatsCaseExchangeDto;
import com.example.caseData.dto.statsCaseExchange.StatsCaseExchangeDto;
import com.example.caseData.dto.statsCaseExchangeUser.StatsCaseExchangeUserDto;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import com.example.caseData.model.StatsCaseExchangeModel;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api")
public class StatsCaseExchangeController extends BaseController {
@Resource
private StatsCaseExchangeDao statsCaseExchangeDao;
@Resource
private CaseExchangeDao caseExchangeDao;
@Resource
private StatsCaseExchangeUserDao statsCaseExchangeUserDao;
@Resource
private HttpServletRequest httpServletRequest;
/**
* 病例交流-统计
*/
@GetMapping("/exchange/stats")
public Response<StatsCaseExchangeDto> getClinicalStats(){
LambdaQueryWrapper<StatsCaseExchangeModel> statsCaseExchangeQueryWrapper = new LambdaQueryWrapper<>();
StatsCaseExchangeModel statsCaseExchange = statsCaseExchangeDao.selectOne(statsCaseExchangeQueryWrapper);
StatsCaseExchangeDto g = StatsCaseExchangeDto.GetDto(statsCaseExchange);
if (g == null){
return Response.success(new StatsCaseExchangeDto());
}
Long totalCommentNum = caseExchangeDao.getTotalCommentNum();
g.setExchangeCommentNum(Math.toIntExact(totalCommentNum));
return Response.success(g);
}
/**
* 病例交流-用户
*/
@GetMapping("/exchange/stats/user")
public Response<StatsCaseExchangeUserDto> getClinicalStatsUser(){
String userId = (String) httpServletRequest.getAttribute("userId");
if (userId == null) {
return Response.error();
}
LambdaQueryWrapper<StatsCaseExchangeUserModel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StatsCaseExchangeUserModel::getUserId, userId);
StatsCaseExchangeUserModel statsCaseExchangeUser = statsCaseExchangeUserDao.selectOne(queryWrapper);
StatsCaseExchangeUserDto g = StatsCaseExchangeUserDto.GetDto(statsCaseExchangeUser);
if (g == null){
return Response.success(new StatsCaseExchangeUserDto());
}
Integer readNum = 0;
// 获取该标签下文章数据
List<CaseExchangeDto> caseExchanges = caseExchangeDao.getCaseExchangeSearchList(
"",
userId,
null,
null
);
for (CaseExchangeDto caseExchange : caseExchanges){
readNum += caseExchange.getReadNum();
}
g.setExchangeReadNum(readNum);
return Response.success(g);
}
}

View File

@ -0,0 +1,223 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.common.Response;
import com.example.caseData.dao.*;
import com.example.caseData.dto.T;
import com.example.caseData.dto.userCaseRead.UserCaseReadDto;
import com.example.caseData.dto.userCollectClinicalVideo.UserCollectClinicalVideoDto;
import com.example.caseData.dto.userCollectExchange.UserCollectExchangeDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.model.*;
import com.example.caseData.request.caseExchangeRequest.addCaseExchangeComment;
import com.example.caseData.request.caseExchangeRequest.getCaseExchangeCommentPage;
import com.example.caseData.request.userCaseReadRequest.addUserCaseRead;
import com.example.caseData.request.userCaseReadRequest.getUserCaseReadSearchPage;
import com.example.caseData.service.UserCaseReadService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api")
public class UserCaseReadController extends BaseController {
@Resource
private UserDao userDao;
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseClinicalDoctorDao caseClinicalDoctorDao;
@Resource
private UserCollectClinicalArticleDao userCollectClinicalArticleDao;
@Resource
private CaseClinicalArticleAuthorDao caseClinicalArticleAuthorDao;
@Resource
private UserCollectClinicalVideoDao userCollectClinicalVideoDao;
@Resource
private CaseClinicalVideoAuthorDao caseClinicalVideoAuthorDao;
@Resource
private UserCollectExchangeDao userCollectExchangeDao;
@Resource
private UserCaseReadDao userCaseReadDao;
@Resource
private UserCaseReadService userCaseReadService;
/**
* 浏览记录-搜索-分页
*/
@PostMapping("/user/case/read/search")
public Response<Map<String, Object>> getUserCaseReadSearchPage(
@Validated()
@RequestBody getUserCaseReadSearchPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
if (request.getType() == 1){
// 文章
Page<UserCaseReadDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<UserCaseReadDto> resultPage = userCaseReadDao.getUserCaseReadArticleSearchPage(
page,
request.getKeyword(),
userId
);
for (UserCaseReadDto dto : resultPage.getRecords()) {
UserCaseReadDto.DataDto data = dto.getData();
List<UserCaseReadDto.DataAuthorDto> dataAuthors = new ArrayList<>();
// 查找作者
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, dto.getId());
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
UserCaseReadDto.DataAuthorDto dataAuthor = new UserCaseReadDto.DataAuthorDto();
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
dataAuthor.setDoctorName(caseClinicalDoctor.getDoctorName());
dataAuthors.add(dataAuthor);
}
data.setAuthor(dataAuthors);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
}else if (request.getType() == 2){
// 视频
Page<UserCaseReadDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<UserCaseReadDto> resultPage = userCaseReadDao.getUserCaseReadVideoSearchPage(
page,
request.getKeyword(),
userId
);
for (UserCaseReadDto dto : resultPage.getRecords()) {
UserCaseReadDto.DataDto data = dto.getData();
List<UserCaseReadDto.DataAuthorDto> dataAuthors = new ArrayList<>();
// 查找作者
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, dto.getId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
UserCaseReadDto.DataAuthorDto dataAuthor = new UserCaseReadDto.DataAuthorDto();
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
dataAuthor.setDoctorName(caseClinicalDoctor.getDoctorName());
dataAuthors.add(dataAuthor);
}
data.setAuthor(dataAuthors);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
} else if (request.getType() == 3) {
// 病例交流
Page<UserCaseReadDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<UserCaseReadDto> resultPage = userCaseReadDao.getUserCaseReadExchangeSearchPage(
page,
request.getKeyword(),
userId
);
for (UserCaseReadDto dto : resultPage.getRecords()) {
UserCaseReadDto.DataDto data = dto.getData();
List<UserCaseReadDto.DataAuthorDto> dataAuthors = new ArrayList<>();
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
BasicHospitalModel basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
UserCaseReadDto.DataAuthorDto dataAuthor = new UserCaseReadDto.DataAuthorDto();
dataAuthor.setDoctorName(user.getUserName());
dataAuthor.setHospitalName(basicHospital.getHospitalName());
dataAuthors.add(dataAuthor);
data.setAuthor(dataAuthors);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
}else{
return Response.error();
}
return Response.success(resultMap);
}
/**
* 浏览记录-新增
*/
@PostMapping("/user/case/read")
public Response<T> AddUserCaseRead(
@Validated()
@RequestBody addUserCaseRead request
) {
String loginUserId = (String) httpServletRequest.getAttribute("userId");
if (loginUserId == null) {
return Response.error("操作失败");
}
try {
boolean res = userCaseReadService.AddUserCaseRead(request,loginUserId);
if (!res){
return Response.error("操作失败");
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success();
}
}

View File

@ -0,0 +1,192 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.common.Response;
import com.example.caseData.dao.*;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.example.caseData.dto.userCollectClinicalVideo.UserCollectClinicalVideoDto;
import com.example.caseData.dto.userCollectExchange.UserCollectExchangeDto;
import com.example.caseData.model.*;
import com.example.caseData.request.userCollectRequest.getUserCollectSearchPage;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api")
public class UserCollectController extends BaseController {
@Resource
private UserDao userDao;
@Resource
private BasicHospitalDao basicHospitalDao;
@Resource
private HttpServletRequest httpServletRequest;
@Resource
private CaseClinicalDoctorDao caseClinicalDoctorDao;
@Resource
private UserCollectClinicalArticleDao userCollectClinicalArticleDao;
@Resource
private CaseClinicalArticleAuthorDao caseClinicalArticleAuthorDao;
@Resource
private UserCollectClinicalVideoDao userCollectClinicalVideoDao;
@Resource
private CaseClinicalVideoAuthorDao caseClinicalVideoAuthorDao;
@Resource
private UserCollectExchangeDao userCollectExchangeDao;
/**
* 收藏记录-搜索-分页
*/
@PostMapping("/user/collect/search")
public Response<Map<String, Object>> getUserCollectSearchPage(
@Validated()
@RequestBody getUserCollectSearchPage request
) {
String userId = (String) httpServletRequest.getAttribute("userId");
request.validateForPage();
Map<String, Object> resultMap = new HashMap<>();
if (request.getType() == 1){
// 文章
Page<UserCollectClinicalArticleDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<UserCollectClinicalArticleDto> resultPage = userCollectClinicalArticleDao.getUserCollectClinicalArticleSearchPage(
page,
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
userId
);
for (UserCollectClinicalArticleDto dto : resultPage.getRecords()) {
UserCollectClinicalArticleDto.DataDto data = dto.getData();
List<UserCollectClinicalArticleDto.DataAuthorDto> dataAuthors = new ArrayList<>();
// 查找作者
LambdaQueryWrapper<CaseClinicalArticleAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalArticleAuthorModel::getArticleId, dto.getId());
List<CaseClinicalArticleAuthorModel> caseClinicalArticleAuthors = caseClinicalArticleAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalArticleAuthorModel author : caseClinicalArticleAuthors) {
UserCollectClinicalArticleDto.DataAuthorDto dataAuthor = new UserCollectClinicalArticleDto.DataAuthorDto();
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
dataAuthor.setDoctorName(caseClinicalDoctor.getDoctorName());
dataAuthors.add(dataAuthor);
}
data.setAuthor(dataAuthors);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
}else if (request.getType() == 2){
// 视频
Page<UserCollectClinicalVideoDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<UserCollectClinicalVideoDto> resultPage = userCollectClinicalVideoDao.getUserCollectClinicalVideoSearchPage(
page,
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
userId
);
for (UserCollectClinicalVideoDto dto : resultPage.getRecords()) {
UserCollectClinicalVideoDto.DataDto data = dto.getData();
List<UserCollectClinicalVideoDto.DataAuthorDto> dataAuthors = new ArrayList<>();
// 查找作者
LambdaQueryWrapper<CaseClinicalVideoAuthorModel> authorQueryWrapper = new LambdaQueryWrapper<>();
authorQueryWrapper.eq(CaseClinicalVideoAuthorModel::getVideoId, dto.getId());
List<CaseClinicalVideoAuthorModel> caseClinicalVideoAuthors = caseClinicalVideoAuthorDao.selectList(authorQueryWrapper);
for (CaseClinicalVideoAuthorModel author : caseClinicalVideoAuthors) {
UserCollectClinicalVideoDto.DataAuthorDto dataAuthor = new UserCollectClinicalVideoDto.DataAuthorDto();
// 查询医生
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectById(author.getDoctorId());
dataAuthor.setDoctorName(caseClinicalDoctor.getDoctorName());
dataAuthors.add(dataAuthor);
}
data.setAuthor(dataAuthors);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
} else if (request.getType() == 3) {
// 病例交流
Page<UserCollectExchangeDto> page = new Page<>(request.getPage(), request.getPageSize());
// 获取文章数据
IPage<UserCollectExchangeDto> resultPage = userCollectExchangeDao.getUserCollectExchangeSearchPage(
page,
request.getKeyword(),
request.getHospitalId(),
request.getDoctorId(),
userId
);
for (UserCollectExchangeDto dto : resultPage.getRecords()) {
UserCollectExchangeDto.DataDto data = dto.getData();
List<UserCollectExchangeDto.DataAuthorDto> dataAuthors = new ArrayList<>();
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
// 获取当前用户所属医院
BasicHospitalModel basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
UserCollectExchangeDto.DataAuthorDto dataAuthor = new UserCollectExchangeDto.DataAuthorDto();
dataAuthor.setDoctorName(user.getUserName());
dataAuthor.setHospitalName(basicHospital.getHospitalName());
dataAuthors.add(dataAuthor);
data.setAuthor(dataAuthors);
}
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", resultPage.getRecords());
}else{
return Response.error();
}
return Response.success(resultMap);
}
}

View File

@ -1,22 +1,26 @@
package com.example.caseData.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.caseData.common.Response;
import com.example.caseData.dao.UserDao;
import com.example.caseData.dto.UserDto;
import com.example.caseData.model.UserModel;
import com.example.caseData.request.UserRequest;
import com.example.caseData.dao.*;
import com.example.caseData.dto.T;
import com.example.caseData.dto.user.UserDto;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.app.UserPoint.UserPoint;
import com.example.caseData.extend.app.UserPoint.UserPointResponse;
import com.example.caseData.model.*;
import com.example.caseData.request.CaseClinicalArticleRequest.addClinicalArticleComment;
import com.example.caseData.request.UserRequest.ReportUserScoreRequest;
import com.example.caseData.request.UserRequest.UserRequest;
import com.example.caseData.service.CertService;
import com.example.caseData.service.RewardPointService;
import com.example.caseData.service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.Year;
@RestController
@RequestMapping("/api")
@ -24,29 +28,159 @@ public class UserController extends BaseController {
@Resource
private UserDao userDao;
// 查询所有用户
@GetMapping("/users")
public Response<Map<String, Object>> getUserPage(@Validated({UserRequest.Page.class}) @ModelAttribute UserRequest request) {
request.validateForPage(); // 确保分页参数有默认值
@Resource
private BasicHospitalDao basicHospitalDao;
Page<UserModel> page = new Page<>(request.getPage(), request.getPageSize()); // 创建分页对象
@Resource
private HttpServletRequest httpServletRequest;
QueryWrapper<UserModel> queryWrapper = new QueryWrapper<>();
queryWrapper.like("user_id", "");
@Resource
private CaseClinicalDoctorDao caseClinicalDoctorDao;
// 执行分页查询
Page<UserModel> resultPage = userDao.selectPage(page, queryWrapper);
@Resource
private UserCollectClinicalArticleDao userCollectClinicalArticleDao;
// 返回
List<UserDto> userDtoList = UserDto.getUserListDto(resultPage.getRecords());
@Resource
private CaseClinicalArticleAuthorDao caseClinicalArticleAuthorDao;
// 组装分页结果
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("page", resultPage.getCurrent());
resultMap.put("pageSize", resultPage.getSize());
resultMap.put("total", resultPage.getTotal());
resultMap.put("data", userDtoList);
@Resource
private UserCollectClinicalVideoDao userCollectClinicalVideoDao;
return Response.success(resultMap);
@Resource
private CaseClinicalVideoAuthorDao caseClinicalVideoAuthorDao;
@Resource
private UserCollectExchangeDao userCollectExchangeDao;
@Resource
private UserCaseReadDao userCaseReadDao;
@Resource
private RewardPointService rewardService;
@Resource
private UserPoint userPoint;
@Resource
private UserService userService;
@Resource
private CertService certService;
// // 查询所有用户
// @GetMapping("/users")
// public Response<Map<String, Object>> getUserPage(@Validated({UserRequest.Page.class}) @ModelAttribute UserRequest request) {
// request.validateForPage(); // 确保分页参数有默认值
//
// Page<UserModel> page = new Page<>(request.getPage(), request.getPageSize()); // 创建分页对象
//
// QueryWrapper<UserModel> queryWrapper = new QueryWrapper<>();
// queryWrapper.like("user_id", "");
//
// // 执行分页查询
// Page<UserModel> resultPage = userDao.selectPage(page, queryWrapper);
//
// // 返回
// List<UserDto> userDtoList = UserDto.getUserListDto(resultPage.getRecords());
//
// // 组装分页结果
// Map<String, Object> resultMap = new HashMap<>();
// resultMap.put("page", resultPage.getCurrent());
// resultMap.put("pageSize", resultPage.getSize());
// resultMap.put("total", resultPage.getTotal());
// resultMap.put("data", userDtoList);
//
// return Response.success(resultMap);
// }
// 获取用户信息
@GetMapping("/user")
public Response<UserDto> getUser(@Validated({UserRequest.Page.class}) @ModelAttribute UserRequest request) {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
// 获取用户医院数据
BasicHospitalModel basicHospital = basicHospitalDao.selectById(user.getHospitalId());
if (basicHospital == null) {
return Response.error();
}
user.setBasicHospital(basicHospital);
// 获取对应医生数据
LambdaQueryWrapper<CaseClinicalDoctorModel> caseClinicalDoctorWrapper = new LambdaQueryWrapper<>();
caseClinicalDoctorWrapper.eq(CaseClinicalDoctorModel::getDoctorIden, user.getUserIden());
CaseClinicalDoctorModel caseClinicalDoctor = caseClinicalDoctorDao.selectOne(caseClinicalDoctorWrapper);
// 处理返回值
UserDto g = UserDto.GetDto(user);
g.setUserIden("");
g.setOpenId("");
g.setUnionId("");
g.setUserMobile("");
g.setMobileEncryption("");
if (caseClinicalDoctor != null) {
g.setDoctorId(String.valueOf(caseClinicalDoctor.getDoctorId()));
}
return Response.success(g);
}
/**
* 获取用户积分
*/
@GetMapping("/user/point")
public Response<Integer> getUserPoint() {
String userId = (String) httpServletRequest.getAttribute("userId");
// 获取当前登录用户数据
UserModel user = userDao.selectById(Long.valueOf(userId));
if (user == null) {
return Response.error();
}
Integer point = 0;
try {
UserPointResponse result = userPoint.GetUserPoint(user.getUserIden());
point = result.getData();
if (point == null) {
point = 0;
}
} catch (BusinessException e) {
return Response.error(e.getMessage());
}
return Response.success(point);
}
@GetMapping("/user/test")
public Response<T> getUser() {
try {
byte[] qrCodeByte = new byte[0];
// 生成证书
String avt = "src/main/resources/static/cert/avt.png";
String sealPath = "src/main/resources/static/cert/seal.png";
String certificateNo = "GDXZALK" + String.valueOf(Year.now().getValue()) + "123456";
String name = "吴从兴";
String content = "您的案例《儿童肾上腺危象一例》经评议,被肝胆相照临床病例库收录,特发此";
certService.createCertTest(sealPath,certificateNo,name,content);
// 生成用户分享二维码-文章/视频
// userService.CreateUserCaseClinicalContentUnlimitedQrcode(String.valueOf(1),1);
} catch (Exception e) {
return Response.error(e.getMessage());
}
return Response.success();
}
}

View File

@ -3,26 +3,44 @@ package com.example.caseData.core;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.NonNull;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.Arrays;
@Configuration
public class CorsConfig {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(@NonNull CorsRegistry registry) {
registry.addMapping("/**") // 允许所有路径
.allowedOriginPatterns("*") // 允许所有来源Spring 2.4+ `allowedOriginPatterns`
.allowedMethods("POST", "GET", "OPTIONS", "PUT", "DELETE", "UPDATE") // 允许的 HTTP 方法
.allowedHeaders("Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization") // 允许的请求头
.exposedHeaders("Content-Length", "Access-Control-Allow-Origin",
"Access-Control-Allow-Headers", "Cache-Control",
"Content-Language", "Content-Type") // 允许前端访问的响应头
.allowCredentials(false); // 是否允许携带 Cookie
}
};
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
// 允许所有来源 Gin 中的动态 Origin 等价
config.addAllowedOriginPattern("*");
// 允许的请求方法
config.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS", "UPDATE"));
// 允许的请求头
config.setAllowedHeaders(Arrays.asList(
"Origin", "X-Requested-With", "Content-Type", "Accept", "Authorization"
));
// 暴露哪些响应头给前端
config.setExposedHeaders(Arrays.asList(
"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers",
"Cache-Control", "Content-Language", "Content-Type"
));
// 是否允许携带 Cookie 等认证信息Gin 里是 false
config.setAllowCredentials(false);
// 注册跨域配置
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}

View File

@ -5,14 +5,17 @@ import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.ZoneId;
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
private static final ZoneId BEIJING_ZONE = ZoneId.of("Asia/Shanghai");
@Override
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "createdAt", LocalDateTime.class, LocalDateTime.now());
this.strictInsertFill(metaObject, "updatedAt", LocalDateTime.class, LocalDateTime.now());
this.strictInsertFill(metaObject, "createdAt", LocalDateTime.class, LocalDateTime.now(BEIJING_ZONE));
this.strictInsertFill(metaObject, "updatedAt", LocalDateTime.class, LocalDateTime.now(BEIJING_ZONE));
}
@Override

View File

@ -1,26 +0,0 @@
package com.example.caseData.core;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
// 使用String序列化方式
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(stringRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(stringRedisSerializer);
return template;
}
}

View File

@ -0,0 +1,63 @@
package com.example.caseData.core;
import com.example.caseData.config.RedisConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisPassword;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@RequiredArgsConstructor
public class RedisConfiguration {
private final RedisConfig redisConfig; // 自动注入你的配置类
@Bean
@Qualifier("redisTemplate")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
// 使用String序列化方式
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(stringRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(stringRedisSerializer);
return template;
}
@Bean
@Qualifier("prodRedisTemplate")
public RedisTemplate<String, Object> prodRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
configuration.setHostName(redisConfig.getProdHost());
configuration.setPort(redisConfig.getProdPort());
configuration.setDatabase(Integer.parseInt(redisConfig.getProdDatabase()));
if (redisConfig.getProdPassword() != null && !redisConfig.getProdPassword().isEmpty()) {
configuration.setPassword(RedisPassword.of(redisConfig.getProdPassword()));
}
LettuceConnectionFactory factory = new LettuceConnectionFactory(configuration);
factory.afterPropertiesSet();
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
// 使用String序列化方式
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
template.setKeySerializer(stringRedisSerializer);
template.setValueSerializer(stringRedisSerializer);
template.setHashKeySerializer(stringRedisSerializer);
template.setHashValueSerializer(stringRedisSerializer);
return template;
}
}

View File

@ -1,12 +1,16 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.model.CaseClinicalArticleModel;
import org.apache.ibatis.annotations.*;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Mapper
@ -14,18 +18,92 @@ public interface CaseClinicalArticleDao extends BaseMapper<CaseClinicalArticleMo
/**
* 临床病例库-搜索
* @param page 分页数据
* @param title 标题
* @param doctorName 医生名称
* @param labelName 标签名称
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
IPage<CaseClinicalArticleDto> getCaseClinicalArticleSearchPage(
Page<?> page,
@Param("title") String title,
@Param("doctorName") String doctorName,
@Param("labelName") String labelName,
@Param("hospital_id") String hospitalId,
@Param("doctor_id") String doctorId,
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("labelIden") String labelIden,
@Param("order") Map<String, String> order
);
/**
* 临床病例库-搜索
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
List<CaseClinicalArticleDto> getCaseClinicalArticleSearchList(
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("labelIden") String labelIden,
@Param("order") Map<String, String> order
);
/**
* 临床病例库-搜索-数量
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
Long getCaseClinicalArticleSearchCount(
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("labelIden") String labelIden
);
/**
* 查询所有未删除文章的阅读量总和
*
* @return 阅读量总和
*/
@Select("SELECT SUM(read_num) FROM case_clinical_article WHERE delete_status = 0 and article_status = 1")
Long getTotalReadNum();
/**
* Inc 自增
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE case_clinical_article SET ${field} = ${field} + #{numeral} WHERE article_id = #{articleId}")
int inc(@Param("articleId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE case_clinical_article " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE article_id = #{articleId}")
int dec(@Param("articleId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* 根据医院ID查询该医院最后一篇文章的发表时间
* @param hospitalId 医院ID
* @return 最新发表时间无数据时返回 null
*/
LocalDateTime selectLastArticlePushDateByHospitalId(@Param("hospitalId") Long hospitalId);
/**
* 根据医生ID查询该医生最后一篇文章的发表时间
* @param doctorId 医院ID
* @return 最新发表时间无数据时返回 null
*/
LocalDateTime selectLastArticlePushDateByDoctorId(@Param("doctorId") Long doctorId);
/**
* 根据医院ID查询该医院最后一篇文章的发表时间
* @param labelIden 标签唯一标识
* @return 最新发表时间无数据时返回 null
*/
LocalDateTime selectLastArticlePushDateByLabelId(@Param("labelIden") String labelIden);
}

View File

@ -0,0 +1,9 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseClinicalDoctorCertModel;
import com.example.caseData.model.CaseClinicalDoctorModel;
public interface CaseClinicalDoctorCertDao extends BaseMapper<CaseClinicalDoctorCertModel> {
}

View File

@ -0,0 +1,11 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseClinicalRecordScoreModel;
import com.example.caseData.model.StatsCaseClinicalModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface CaseClinicalRecordScoreDao extends BaseMapper<CaseClinicalRecordScoreModel> {
}

View File

@ -8,7 +8,11 @@ import com.example.caseData.dto.caseClinicalVideo.CaseClinicalVideoDto;
import com.example.caseData.model.CaseClinicalVideoModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Mapper
@ -16,16 +20,92 @@ public interface CaseClinicalVideoDao extends BaseMapper<CaseClinicalVideoModel>
/**
* 临床病例库-搜索
* @param page 分页数据
* @param title 标题
* @param doctorName 医生名称
* @param labelName 标签名称
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
IPage<CaseClinicalVideoDto> getCaseClinicalVideoSearchPage(
Page<?> page,
@Param("title") String title,
@Param("doctorName") String doctorName,
@Param("labelName") String labelName,
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("labelIden") String labelIden,
@Param("order") Map<String, String> order
);
/**
* 临床病例库-搜索
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
List<CaseClinicalVideoDto> getCaseClinicalVideoSearchList(
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("labelIden") String labelIden,
@Param("order") Map<String, String> order
);
/**
* 临床病例库-搜索-数量
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
Long getCaseClinicalVideoSearchCount(
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("labelIden") String labelIden
);
/**
* Inc 自增
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE case_clinical_video SET ${field} = ${field} + #{numeral} WHERE video_id = #{videoId}")
int inc(@Param("videoId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE case_clinical_video " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE video_id = #{videoId}")
int dec(@Param("videoId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* 根据医院ID查询该医院最后一篇文章的发表时间
* @param hospitalId 医院ID
* @return 最新发表时间无数据时返回 null
*/
LocalDateTime selectLastVideoPushDateByHospitalId(@Param("hospitalId") Long hospitalId);
/**
* 根据医生ID查询该医生最后一篇文章的发表时间
* @param doctorId 医院ID
* @return 最新发表时间无数据时返回 null
*/
LocalDateTime selectLastVideoPushDateByDoctorId(@Param("doctorId") Long doctorId);
/**
* 根据医院ID查询该医院最后一篇文章的发表时间
* @param labelIden 标签唯一标识
* @return 最新发表时间无数据时返回 null
*/
LocalDateTime selectLastVideoPushDateByLabelId(@Param("labelIden") String labelIden);
/**
* 查询所有未删除文章的阅读量总和
*
* @return 阅读量总和
*/
@Select("SELECT SUM(read_num) FROM case_clinical_video WHERE delete_status = 0 and video_status = 1")
Long getTotalReadNum();
}

View File

@ -0,0 +1,97 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseClinicalArticleModel;
import com.example.caseData.model.CaseExchangeModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
import java.util.Map;
@Mapper
public interface CaseExchangeDao extends BaseMapper<CaseExchangeModel> {
/**
* 临床病例库-搜索
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
IPage<CaseExchangeDto> getCaseExchangeSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("userId") String userId,
@Param("isSelected") Integer isSelected,
@Param("labelIden") String labelIden,
@Param("order") Map<String, String> order
);
/**
* 临床病例库-搜索
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
List<CaseExchangeDto> getCaseExchangeSearchLimitList(
@Param("limit") Integer limit,
@Param("keyword") String keyword,
@Param("userId") String userId,
@Param("isSelected") Integer isSelected,
@Param("order") Map<String, String> order
);
/**
* 临床病例库-搜索
* @param keyword 搜索关键词-标题/医生名称/标签名称
* @param order 排序
*/
List<CaseExchangeDto> getCaseExchangeSearchList(
@Param("keyword") String keyword,
@Param("userId") String userId,
@Param("isSelected") Integer isSelected,
@Param("order") Map<String, String> order
);
/**
* Inc 自增
* @param exchangeId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE case_exchange SET ${field} = ${field} + #{numeral} WHERE exchange_id = #{exchangeId}")
int inc(@Param("exchangeId") Long exchangeId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param exchangeId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE case_exchange SET ${field} = ${field} - #{numeral} WHERE exchange_id = #{exchangeId}")
int dec(@Param("exchangeId") Long exchangeId, @Param("field") String field, @Param("numeral") int numeral);
/**
* 查询所有未删除文章的阅读量总和
*
* @return 阅读量总和
*/
@Select("SELECT SUM(comment_num) FROM case_exchange WHERE delete_status = 0 and exchange_status = 1")
Long getTotalCommentNum();
/**
* 查询所有未删除文章的阅读量总和
*
* @return 阅读量总和
*/
@Select("SELECT SUM(comment_num) FROM case_exchange WHERE delete_status = 0 and exchange_status = 1")
Long getTotalRedNum();
}

View File

@ -0,0 +1,30 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.caseExchangeDraft.CaseExchangeDraftDto;
import com.example.caseData.model.CaseExchangeDraftModel;
import com.example.caseData.model.CaseExchangeModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.List;
import java.util.Map;
@Mapper
public interface CaseExchangeDraftDao extends BaseMapper<CaseExchangeDraftModel> {
/**
* 临床病例库-草稿箱-搜索
* @param page 分页数据
* @param order 排序
*/
IPage<CaseExchangeDraftDto> getCaseExchangeDraftSearchPage(
Page<?> page,
@Param("userId") String userId,
@Param("order") Map<String, String> order
);
}

View File

@ -0,0 +1,10 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseExchangeLabelModel;
import com.example.caseData.model.CaseExchangeModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CaseExchangeLabelDao extends BaseMapper<CaseExchangeLabelModel> {
}

View File

@ -0,0 +1,16 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.CaseExchangeVoteModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface CaseExchangeVoteDao extends BaseMapper<CaseExchangeVoteModel> {
}

View File

@ -0,0 +1,34 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.CaseExchangeVoteModel;
import com.example.caseData.model.CaseExchangeVoteOptionModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
@Mapper
public interface CaseExchangeVoteOptionDao extends BaseMapper<CaseExchangeVoteOptionModel> {
/**
* Inc 自增
* @param optionId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE case_exchange_vote_option SET ${field} = ${field} + #{numeral} WHERE option_id = #{optionId}")
int inc(@Param("optionId") Long optionId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param optionId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE case_exchange_vote_option " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE option_id = #{optionId}")
int dec(@Param("optionId") Long optionId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -0,0 +1,18 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseClinicalVideo.CaseClinicalVideoDto;
import com.example.caseData.model.CaseClinicalVideoModel;
import com.example.caseData.model.RecordRewardPointModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.Map;
@Mapper
public interface RecordRewardPointDao extends BaseMapper<RecordRewardPointModel> {
}

View File

@ -2,6 +2,30 @@ package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.StatsCaseClinicalModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface StatsCaseClinicalDao extends BaseMapper<StatsCaseClinicalModel> {
/**
* Inc 自增
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical SET ${field} = ${field} + #{numeral} WHERE stats_id = #{statsId}")
int inc(@Param("statsId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE stats_id = #{statsId}")
int dec(@Param("statsId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -7,6 +7,7 @@ import com.example.caseData.dto.statsCaseClinicalDoctor.StatsCaseClinicalDoctorD
import com.example.caseData.dto.statsCaseClinicalHospital.StatsCaseClinicalHospitalDto;
import com.example.caseData.model.StatsCaseClinicalDoctorModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.Map;
@ -19,7 +20,30 @@ public interface StatsCaseClinicalDoctorDao extends BaseMapper<StatsCaseClinical
*/
IPage<StatsCaseClinicalDoctorDto> getStatsCaseClinicalDoctorSearchPage(
Page<?> page,
@Param("doctor_name") String doctorName,
@Param("doctorName") String doctorName,
@Param("order") Map<String, String> order
);
/**
* Inc 自增
* @param doctorId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical_doctor SET ${field} = ${field} + #{numeral} WHERE doctor_id = #{doctorId}")
int inc(@Param("doctorId") Long doctorId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param doctorId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical_doctor " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE doctor_id = #{doctorId}")
int dec(@Param("doctorId") Long doctorId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.statsCaseClinicalHospital.StatsCaseClinicalHospitalDto;
import com.example.caseData.model.StatsCaseClinicalHospitalModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.checkerframework.checker.units.qual.N;
import java.util.Map;
@ -22,4 +23,27 @@ public interface StatsCaseClinicalHospitalDao extends BaseMapper<StatsCaseClinic
@Param("hospital_name") String hospitalName,
@Param("order") Map<String, String> order
);
/**
* Inc 自增
* @param articleId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical_hospital SET ${field} = ${field} + #{numeral} WHERE hospital_id = #{hospitalId}")
int inc(@Param("hospitalId") Long articleId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param hospitalId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical_hospital " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE hospital_id = #{hospitalId}")
int dec(@Param("hospitalId") Long hospitalId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -0,0 +1,51 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.statsCaseClinicalHospital.StatsCaseClinicalHospitalDto;
import com.example.caseData.dto.statsCaseClinicalLabel.StatsCaseClinicalLabelDto;
import com.example.caseData.model.StatsCaseClinicalLabelModel;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.Map;
@Mapper
public interface StatsCaseClinicalLabelDao extends BaseMapper<StatsCaseClinicalLabelModel> {
/**
* 医院病例库推荐-搜索
* @param page 分页数据
* @param labelName 疾病标签名称
* @param order 排序
*/
IPage<StatsCaseClinicalLabelDto> getStatsCaseClinicalLabelSearchPage(
Page<?> page,
@Param("labelName") String labelName,
@Param("order") Map<String, String> order
);
/**
* Inc 自增
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical_label SET ${field} = ${field} + #{numeral} WHERE label_iden = #{labelIden}")
int inc(@Param("labelIden") String labelIden, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_clinical_label " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE label_iden = #{labelIden}")
int dec(@Param("labelIden") String labelIden, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -0,0 +1,32 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.StatsCaseClinicalModel;
import com.example.caseData.model.StatsCaseExchangeModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface StatsCaseExchangeDao extends BaseMapper<StatsCaseExchangeModel> {
/**
* Inc 自增
* @param statsId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_exchange SET ${field} = ${field} + #{numeral} WHERE stats_id = #{statsId}")
int inc(@Param("statsId") Long statsId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param statsId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_exchange " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE stats_id = #{statsId}")
int dec(@Param("statsId") Long statsId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -0,0 +1,39 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.Map;
@Mapper
public interface StatsCaseExchangeUserDao extends BaseMapper<StatsCaseExchangeUserModel> {
/**
* Inc 自增
* @param userId 文章 ID
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_exchange_user SET ${field} = ${field} + #{numeral} WHERE user_id = #{userId}")
int inc(@Param("userId") Long userId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param userId 文章 ID
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE stats_case_exchange_user " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE user_id = #{userId}")
int dec(@Param("userId") Long userId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -0,0 +1,66 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.userCaseRead.UserCaseReadDto;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.example.caseData.model.UserCaseReadModel;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
public interface UserCaseReadDao extends BaseMapper<UserCaseReadModel> {
/**
* 用户阅读记录-搜索-文章
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
IPage<UserCaseReadDto> getUserCaseReadArticleSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("userId") String userId
);
/**
* 用户阅读记录-搜索-视频
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
IPage<UserCaseReadDto> getUserCaseReadVideoSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("userId") String userId
);
/**
* 用户阅读记录-搜索-病例交流
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
IPage<UserCaseReadDto> getUserCaseReadExchangeSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("userId") String userId
);
/**
* Inc 自增
* @param field 字段名称
* @param numeral 增加的数值
* @return 更新的行数
*/
@Update("UPDATE user_case_read SET ${field} = ${field} + #{numeral} WHERE read_id = #{readId}")
int inc(@Param("readId") Long readId, @Param("field") String field, @Param("numeral") int numeral);
/**
* Dec 自减
*
* @param field 字段名称
* @param numeral 减少的数值
* @return 更新的行数
*/
@Update("UPDATE user_case_read " +
"SET ${field} = CASE WHEN ${field} >= #{numeral} THEN ${field} - #{numeral} ELSE 0 END " +
"WHERE read_id = #{statsId}")
int dec(@Param("readId") Long readId, @Param("field") String field, @Param("numeral") int numeral);
}

View File

@ -1,7 +1,27 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.example.caseData.model.UserCollectClinicalArticleModel;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
public interface UserCollectClinicalArticleDao extends BaseMapper<UserCollectClinicalArticleModel> {
/**
* 临床病例库-搜索
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
IPage<UserCollectClinicalArticleDto> getUserCollectClinicalArticleSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("userId") String userId
);
}

View File

@ -1,7 +1,24 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.example.caseData.dto.userCollectClinicalVideo.UserCollectClinicalVideoDto;
import com.example.caseData.model.UserCollectClinicalVideoModel;
import org.apache.ibatis.annotations.Param;
public interface UserCollectClinicalVideoDao extends BaseMapper<UserCollectClinicalVideoModel> {
/**
* 临床病例库-搜索
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
IPage<UserCollectClinicalVideoDto> getUserCollectClinicalVideoSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("userId") String userId
);
}

View File

@ -0,0 +1,27 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.example.caseData.dto.userCollectExchange.UserCollectExchangeDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.UserCollectExchangeModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserCollectExchangeDao extends BaseMapper<UserCollectExchangeModel> {
/**
* 临床病例库-搜索
* @param page 分页数据
* @param keyword 搜索关键词-标题/医生名称/标签名称
*/
IPage<UserCollectExchangeDto> getUserCollectExchangeSearchPage(
Page<?> page,
@Param("keyword") String keyword,
@Param("hospitalId") String hospitalId,
@Param("doctorId") String doctorId,
@Param("userId") String userId
);
}

View File

@ -1,7 +1,43 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.example.caseData.model.UserCommentClinicalArticleModel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface UserCommentClinicalArticleDao extends BaseMapper<UserCommentClinicalArticleModel> {
/**
* 临床病例库--评论-分页
* @param page 分页数据
*/
IPage<UserCommentClinicalArticleDto> getClinicalArticleCommentPage(
Page<?> page,
@Param("articleId") String articleId,
@Param("rootId") String rootId
);
/**
* 临床病例库--评论-列表
*/
List<UserCommentClinicalArticleDto> getClinicalArticleCommentList(
@Param("articleId") String articleId,
@Param("rootId") String rootId,
@Param("limit") int limit
);
/**
* 临床病例库--评论-分页
* @param page 分页数据
*/
IPage<GetUserClinicalArticleCommentPageDto> getUserClinicalArticleCommentPage(
Page<?> page,
@Param("userId") String userId
);
}

View File

@ -1,7 +1,43 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.userCommentClinicalArticle.GetUserClinicalArticleCommentPageDto;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.example.caseData.dto.userCommentClinicalVideo.GetUserClinicalVideoCommentPageDto;
import com.example.caseData.dto.userCommentClinicalVideo.UserCommentClinicalVideoDto;
import com.example.caseData.model.UserCommentClinicalVideoModel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface UserCommentClinicalVideoDao extends BaseMapper<UserCommentClinicalVideoModel> {
/**
* 临床病例库--评论-分页
* @param page 分页数据
*/
IPage<UserCommentClinicalVideoDto> getClinicalVideoCommentPage(
Page<?> page,
@Param("videoId") String videoId,
@Param("rootId") String rootId
);
/**
* 临床病例库--评论-分页
*/
List<UserCommentClinicalVideoDto> getClinicalVideoCommentList(
@Param("videoId") String videoId,
@Param("rootId") String rootId,
@Param("limit") int limit
);
/**
* 临床病例库--评论-分页
* @param page 分页数据
*/
IPage<GetUserClinicalVideoCommentPageDto> getUserClinicalVideoCommentPage(
Page<?> page,
@Param("userId") String userId
);
}

View File

@ -0,0 +1,48 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.userCommentCaseExchange.GetUserCaseExchangeCommentPageDto;
import com.example.caseData.dto.userCommentCaseExchange.UserCommentCaseExchangeDto;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.UserCommentExchangeModel;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface UserCommentExchangeDao extends BaseMapper<UserCommentExchangeModel> {
/**
* 临床病例库--评论-分页
* @param page 分页数据
*/
IPage<UserCommentCaseExchangeDto> getCaseExchangeCommentPage(
Page<?> page,
@Param("exchangeId") String exchangeId,
@Param("rootId") String rootId
);
/**
* 临床病例库--评论-列表
*/
List<UserCommentCaseExchangeDto> getCaseExchangeCommentList(
@Param("exchangeId") String exchangeId,
@Param("rootId") String rootId,
@Param("limit") int limit
);
/**
* 临床病例库--评论-分页
* @param page 分页数据
*/
IPage<GetUserCaseExchangeCommentPageDto> getUserCaseExchangeCommentPage(
Page<?> page,
@Param("userId") String userId
);
}

View File

@ -0,0 +1,11 @@
package com.example.caseData.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.caseData.model.UserCommentExchangeModel;
import com.example.caseData.model.UserVoteExchangeModel;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface UserVoteExchangeDao extends BaseMapper<UserVoteExchangeModel> {
}

View File

@ -1,75 +0,0 @@
package com.example.caseData.dto;
import com.example.caseData.model.UserModel;
import com.example.caseData.utils.Replace;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserDto {
private String userId; // 主键id
private String userIden; // 第三方平台唯一标识
private String userName; // 用户名称
private String userMobile; // 手机号
private Integer status; // 状态0:禁用 1:正常 2:删除
private Integer registerSource;// 注册来源1:未知 2:app用户 3:佳动例
private String openId; // 用户微信标识
private String unionId; // 微信开放平台标识
private Integer sex; // 性别0:未知 1: 2:
private String avatar; // 头像
private Integer title; // 医生职称
private String departmentName; // 科室名称
private String hospitalId; // 所属医院id
private LocalDateTime createdAt; // 创建时间
private LocalDateTime updatedAt; // 修改时间
public static UserDto getUserDto(UserModel userModel) {
if (userModel == null) {
return null;
}
UserDto dto = new UserDto();
dto.setUserId(userModel.getUserId().toString());
dto.setUserIden(userModel.getUserIden());
dto.setUserName(userModel.getUserName());
dto.setUserMobile(userModel.getUserMobile());
dto.setStatus(userModel.getStatus());
dto.setRegisterSource(userModel.getRegisterSource());
dto.setOpenId(userModel.getOpenId());
dto.setUnionId(userModel.getUnionId());
dto.setSex(userModel.getSex());
dto.setAvatar(userModel.getAvatar());
dto.setTitle(userModel.getTitle());
dto.setDepartmentName(userModel.getDepartmentName());
dto.setHospitalId(userModel.getHospitalId().toString());
dto.setCreatedAt(userModel.getCreatedAt());
dto.setUpdatedAt(userModel.getUpdatedAt());
return dto;
}
public static List<UserDto> getUserListDto(List<UserModel> userModels) {
List<UserDto> userDtoList = new ArrayList<>();
for (UserModel userModel : userModels) {
UserDto dto = getUserDto(userModel);
// 在这里对字段做一些操作暂时不做任何处理
// 例如: dto.setUserName(dto.getUserName().toUpperCase());
userDtoList.add(dto);
}
return userDtoList;
}
}

View File

@ -1,7 +1,10 @@
package com.example.caseData.dto.caseClinicalArticle;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.dto.caseClinicalArticleLabel.CaseClinicalArticleLabelDto;
import com.example.caseData.model.CaseClinicalArticleLabelModel;
import com.example.caseData.model.CaseClinicalArticleModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@ -31,6 +34,12 @@ public class CaseClinicalArticleDto {
@JsonProperty("article_status")
private Integer articleStatus;
/**
* 删除状态0: 1:
*/
@JsonProperty("delete_status")
private Integer deleteStatus;
/**
* 阅读量
*/
@ -43,13 +52,36 @@ public class CaseClinicalArticleDto {
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 评论量
*/
@JsonProperty("comment_num")
private Integer commentNum;
/**
* 发表时间
*/
@JsonProperty("push_date")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime pushDate;
/**
* 证书图片
*/
@JsonProperty("cert_image")
private String certImage;
/**
* 是否外部链接0: 1:
*/
@JsonProperty("is_link")
private Integer isLink;
/**
* 外部链接地址
*/
@JsonProperty("is_link_url")
private String isLinkUrl;
/**
* 内容
*/
@ -74,6 +106,18 @@ public class CaseClinicalArticleDto {
@JsonProperty("author")
private List<CaseClinicalArticleAuthorDto> author;
/**
* 标签
*/
@JsonProperty("label")
private List<CaseClinicalArticleLabelDto> label;
/**
* 收藏状态
*/
@JsonProperty("is_collect")
private boolean isCollect;
/**
* 列表
*/
@ -97,6 +141,12 @@ public class CaseClinicalArticleDto {
dto.setAuthor(caseClinicalArticleAuthorListDto);
}
// 标签
if (model.getLabel() != null && !model.getLabel().isEmpty()) {
List<CaseClinicalArticleLabelDto> caseClinicalArticleLabelListDto = CaseClinicalArticleLabelDto.GetListDto(model.getLabel());
dto.setLabel(caseClinicalArticleLabelListDto);
}
dto.setArticleContent("");
return dto;
})
@ -124,6 +174,12 @@ public class CaseClinicalArticleDto {
dto.setAuthor(caseClinicalArticleAuthorListDto);
}
// 标签
if (model.getLabel() != null && !model.getLabel().isEmpty()) {
List<CaseClinicalArticleLabelDto> caseClinicalArticleLabelListDto = CaseClinicalArticleLabelDto.GetListDto(model.getLabel());
dto.setLabel(caseClinicalArticleLabelListDto);
}
return dto;
}
}

View File

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.dto.caseClinicalDoctor.CaseClinicalDoctorDto;
import com.example.caseData.model.CaseClinicalArticleAuthorModel;
import com.example.caseData.utils.Replace;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@ -34,11 +35,17 @@ public class CaseClinicalArticleAuthorDto {
private String doctorId;
/**
* 名称
* 名称
*/
@JsonProperty("doctor_name")
private String doctorName;
/**
* 医生头像
*/
@JsonProperty("avatar")
private String avatar;
/**
* 医院名称
*/
@ -80,6 +87,7 @@ public class CaseClinicalArticleAuthorDto {
CaseClinicalDoctorDto caseClinicalDoctorDto = CaseClinicalDoctorDto.GetDto(model.getCaseClinicalDoctor());
dto.setDoctorName(caseClinicalDoctorDto.getDoctorName());
dto.setHospitalName(caseClinicalDoctorDto.getHospitalName());
dto.setAvatar(Replace.addOssDomain(caseClinicalDoctorDto.getAvatar()));
}
return dto;

View File

@ -1,8 +1,14 @@
package com.example.caseData.dto.caseClinicalArticleLabel;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalDoctor.CaseClinicalDoctorDto;
import com.example.caseData.model.CaseClinicalArticleLabelModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseClinicalArticleLabelDto {
@ -10,13 +16,13 @@ public class CaseClinicalArticleLabelDto {
* 主键id
*/
@JsonProperty("article_label_id")
private Long articleLabelId;
private String articleLabelId;
/**
* 临床文章id
*/
@JsonProperty("article_id")
private Long articleId;
private String articleId;
/**
* app唯一标识
@ -41,4 +47,26 @@ public class CaseClinicalArticleLabelDto {
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<CaseClinicalArticleLabelDto> GetListDto(List<CaseClinicalArticleLabelModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseClinicalArticleLabelDto dto = BeanUtil.copyProperties(model, CaseClinicalArticleLabelDto.class);
// 示例手动处理字段类型不一致
if (model.getArticleLabelId() != null) {
dto.setArticleLabelId(String.valueOf(model.getArticleLabelId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
}

View File

@ -34,6 +34,12 @@ public class CaseClinicalVideoDto {
@JsonProperty("video_status")
private Integer videoStatus;
/**
* 删除状态0: 1:
*/
@JsonProperty("delete_status")
private Integer deleteStatus;
/**
* 阅读量
*/
@ -58,6 +64,24 @@ public class CaseClinicalVideoDto {
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 证书图片
*/
@JsonProperty("cert_image")
private String certImage;
/**
* 是否外部链接0: 1:
*/
@JsonProperty("is_link")
private Integer isLink;
/**
* 外部链接地址
*/
@JsonProperty("is_link_url")
private String isLinkUrl;
/**
* 创建时间
*/
@ -78,6 +102,12 @@ public class CaseClinicalVideoDto {
@JsonProperty("author")
private List<CaseClinicalVideoAuthorDto> author;
/**
* 收藏状态
*/
@JsonProperty("is_collect")
private boolean isCollect;
/**
* 列表
*/

View File

@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalVideoAuthor.CaseClinicalVideoAuthorDto;
import com.example.caseData.dto.caseClinicalDoctor.CaseClinicalDoctorDto;
import com.example.caseData.model.CaseClinicalVideoAuthorModel;
import com.example.caseData.utils.Replace;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
@ -43,6 +44,12 @@ public class CaseClinicalVideoAuthorDto {
@JsonProperty("hospital_name")
private String hospitalName;
/**
* 医生头像
*/
@JsonProperty("avatar")
private String avatar;
/**
* 创建时间
*/
@ -75,6 +82,8 @@ public class CaseClinicalVideoAuthorDto {
if (model.getCaseClinicalDoctor() != null) {
CaseClinicalDoctorDto caseClinicalDoctorDto = CaseClinicalDoctorDto.GetDto(model.getCaseClinicalDoctor());
dto.setDoctorName(caseClinicalDoctorDto.getDoctorName());
dto.setHospitalName(caseClinicalDoctorDto.getHospitalName());
dto.setAvatar(Replace.addOssDomain(caseClinicalDoctorDto.getAvatar()));
}
return dto;

View File

@ -0,0 +1,243 @@
package com.example.caseData.dto.caseExchange;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.dto.caseExchangeLabel.CaseExchangeLabelDto;
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.utils.Replace;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeDto {
/**
* 主键id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 标题
*/
@JsonProperty("exchange_title")
private String exchangeTitle;
/**
* 状态1:正常 2:禁用
*/
@JsonProperty("exchange_status")
private Integer exchangeStatus;
/**
* 删除状态0: 1:
*/
@JsonProperty("delete_status")
private Integer deleteStatus;
/**
* 阅读量
*/
@JsonProperty("read_num")
private Integer readNum;
/**
* 收藏量
*/
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 评论量
*/
@JsonProperty("comment_num")
private Integer commentNum;
/**
* 发表时间
*/
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 内容
*/
@JsonProperty("exchange_content")
private String exchangeContent;
/**
* 总结
*/
@JsonProperty("exchange_summary")
private String exchangeSummary;
/**
* 预览图片
*/
@JsonProperty("exchange_content_image_string")
private String exchangeContentImageString;
/**
* 预览图片
*/
@JsonProperty("exchange_content_image")
private List<String> exchangeContentImage = new ArrayList<>();
/**
* 预览图片
*/
@JsonProperty("exchange_content_video_string")
private String exchangeContentVideoString;
/**
* 预览图片
*/
@JsonProperty("exchange_content_video")
private List<String> exchangeContentVideo = new ArrayList<>();
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 用户名称
*/
@JsonProperty("user_name")
private String userName; // 用户名称
/**
* 头像
*/
@JsonProperty("avatar")
private String avatar; // 头像
/**
* 所属医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName; // 所属医院名称
/**
* 收藏状态
*/
@JsonProperty("is_collect")
private boolean isCollect;
/**
* 投票数据
*/
@JsonProperty("exchange_vote")
private CaseExchangeVoteDto caseExchangeVote;
/**
* 标签数据
*/
@JsonProperty("exchange_label")
private List<CaseExchangeLabelDto> label;
/**
* 列表
*/
public static List<CaseExchangeDto> GetListDto(List<CaseExchangeModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeDto dto = BeanUtil.copyProperties(model, CaseExchangeDto.class);
// 示例手动处理字段类型不一致
if (model.getExchangeId() != null) {
dto.setExchangeId(String.valueOf(model.getExchangeId())); // Long -> String
}
dto.setExchangeContent("");
dto.setExchangeSummary("");
// 投票
if (model.getCaseExchangeVote() != null) {
CaseExchangeVoteDto listDto = CaseExchangeVoteDto.GetDto(model.getCaseExchangeVote());
dto.setCaseExchangeVote(listDto);
}
if (model.getCaseExchangeLabel() != null) {
List<CaseExchangeLabelDto> listDto = CaseExchangeLabelDto.GetListDto(model.getCaseExchangeLabel());
dto.setLabel(listDto);
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeDto GetDto(CaseExchangeModel model) {
if (model == null) {
return null;
}
CaseExchangeDto dto = BeanUtil.copyProperties(model, CaseExchangeDto.class);
// 类型转换示例
if (model.getExchangeId() != null) {
dto.setExchangeId(String.valueOf(model.getExchangeId())); // Long -> String
}
// 投票
if (model.getCaseExchangeVote() != null) {
CaseExchangeVoteDto listDto = CaseExchangeVoteDto.GetDto(model.getCaseExchangeVote());
dto.setCaseExchangeVote(listDto);
}
// 标签
if (model.getCaseExchangeLabel() != null) {
List<CaseExchangeLabelDto> listDto = CaseExchangeLabelDto.GetListDto(model.getCaseExchangeLabel());
dto.setLabel(listDto);
}
return dto;
}
public void setExchangeContentImageString(String str) {
this.exchangeContentImageString = str;
if (str != null && !str.isEmpty()) {
this.exchangeContentImage = Arrays.stream(str.split(","))
.map(Replace::addOssDomain)
.collect(Collectors.toList());
}
}
public void setExchangeContentVideoString(String str) {
this.exchangeContentVideoString = str;
if (str != null && !str.isEmpty()) {
this.exchangeContentVideo = Arrays.stream(str.split(","))
.map(Replace::addOssDomain)
.collect(Collectors.toList());
}
}
}

View File

@ -0,0 +1,133 @@
package com.example.caseData.dto.caseExchangeDraft;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.request.caseExchangeRequest.addCaseExchange;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Data
public class CaseExchangeDraftDto {
/**
* 主键id
*/
@JsonProperty("draft_id")
private String draftId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 标题
*/
@JsonProperty("exchange_title")
private String exchangeTitle;
/**
* 内容
*/
@JsonProperty("exchange_content")
private String exchangeContent;
/**
* 总结
*/
@JsonProperty("exchange_summary")
private String exchangeSummary;
/**
* 标签id逗号分隔
*/
@JsonProperty("exchange_label_json")
private String exchangeLabelJson;
/**
* 标签
*/
@JsonProperty("exchange_label")
private List<CaseExchangeLabelDto> exchangeLabel;
/**
* 投票(json)
*/
@JsonProperty("exchange_vote_json")
private String exchangeVoteJson;
/**
* 投票
*/
@JsonProperty("exchange_vote")
private ExchangeVoteDto exchangeVote;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 标签
*/
@Data
public static class CaseExchangeLabelDto {
/**
* app唯一标识
*/
@JsonProperty("app_iden")
private String appIden;
/**
* 标签名称
*/
@JsonProperty("label_name")
private String labelName;
}
/**
* 标签
*/
@Data
public static class ExchangeVoteDto {
/**
* 选项标题
*/
@JsonProperty("vote_title")
private String voteTitle;
@JsonProperty("valid_day")
private Integer validDay; // 投票有效期天数
/**
* 选项
*/
@JsonProperty("option")
private List<OptionDto> option;
}
/**
* 标签
*/
@Data
public static class OptionDto {
/**
* 选项
*/
@JsonProperty("option_value")
private String optionValue;
}
}

View File

@ -0,0 +1,98 @@
package com.example.caseData.dto.caseExchangeLabel;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.model.CaseExchangeLabelModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeLabelDto {
/**
* 主键id
*/
@JsonProperty("exchange_label_id")
private String exchangeLabelId;
/**
* 临床文章id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* app唯一标识
*/
@JsonProperty("app_iden")
private String appIden;
/**
* 标签名称
*/
@JsonProperty("label_name")
private String labelName;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<CaseExchangeLabelDto> GetListDto(List<CaseExchangeLabelModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeLabelDto dto = BeanUtil.copyProperties(model, CaseExchangeLabelDto.class);
// 示例手动处理字段类型不一致
if (model.getExchangeLabelId() != null) {
dto.setExchangeLabelId(String.valueOf(model.getExchangeLabelId())); // Long -> String
}
if (model.getExchangeId() != null) {
dto.setExchangeId(String.valueOf(model.getExchangeId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeLabelDto GetDto(CaseExchangeLabelModel model) {
if (model == null) {
return null;
}
CaseExchangeLabelDto dto = BeanUtil.copyProperties(model, CaseExchangeLabelDto.class);
// 类型转换示例
if (model.getExchangeLabelId() != null) {
dto.setExchangeLabelId(String.valueOf(model.getExchangeLabelId())); // Long -> String
}
if (model.getExchangeId() != null) {
dto.setExchangeId(String.valueOf(model.getExchangeId())); // Long -> String
}
return dto;
}
}

View File

@ -0,0 +1,124 @@
package com.example.caseData.dto.caseExchangeVote;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.dto.caseExchange.CaseExchangeDto;
import com.example.caseData.dto.caseExchangeVoteOption.CaseExchangeVoteOptionDto;
import com.example.caseData.model.CaseExchangeModel;
import com.example.caseData.model.CaseExchangeVoteModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeVoteDto {
/**
* 主键id
*/
@JsonProperty("vote_id")
private String voteId;
/**
* 病例交流id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* 选项标题
*/
@JsonProperty("vote_title")
private String voteTitle;
/**
* 结束投票时间
*/
@JsonProperty("end_time")
private LocalDateTime endTime;
/**
* 是否开启中0: 1:过期状态
*/
@JsonProperty("is_enabled")
private Integer isEnabled;
/**
* 是否已投票0: 1:
*/
@JsonProperty("is_have_voted")
private Integer isHaveVoted = 0;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 选项
*/
@JsonProperty("case_exchange_vote_option")
private List<CaseExchangeVoteOptionDto> caseExchangeVoteOption;
/**
* 列表
*/
public static List<CaseExchangeVoteDto> GetListDto(List<CaseExchangeVoteModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeVoteDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteDto.class);
// 示例手动处理字段类型不一致
if (model.getVoteId() != null) {
dto.setVoteId(String.valueOf(model.getVoteId())); // Long -> String
}
// 选项
if (model.getCaseExchangeVoteOption() != null && !model.getCaseExchangeVoteOption().isEmpty()) {
List<CaseExchangeVoteOptionDto> caseExchangeVoteOptionListDto = CaseExchangeVoteOptionDto.GetListDto(model.getCaseExchangeVoteOption());
dto.setCaseExchangeVoteOption(caseExchangeVoteOptionListDto);
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeVoteDto GetDto(CaseExchangeVoteModel model) {
if (model == null) {
return null;
}
CaseExchangeVoteDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteDto.class);
// 类型转换示例
if (model.getVoteId() != null) {
dto.setVoteId(String.valueOf(model.getVoteId())); // Long -> String
}
// 选项
if (model.getCaseExchangeVoteOption() != null && !model.getCaseExchangeVoteOption().isEmpty()) {
List<CaseExchangeVoteOptionDto> caseExchangeVoteOptionListDto = CaseExchangeVoteOptionDto.GetListDto(model.getCaseExchangeVoteOption());
dto.setCaseExchangeVoteOption(caseExchangeVoteOptionListDto);
}
return dto;
}
}

View File

@ -0,0 +1,98 @@
package com.example.caseData.dto.caseExchangeVoteOption;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseExchangeVote.CaseExchangeVoteDto;
import com.example.caseData.model.CaseExchangeVoteModel;
import com.example.caseData.model.CaseExchangeVoteOptionModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class CaseExchangeVoteOptionDto {
/**
* 主键id
*/
@JsonProperty("option_id")
private String optionId;
/**
* 投票id
*/
@JsonProperty("vote_id")
private String voteId;
/**
* 选项
*/
@JsonProperty("option_value")
private String optionValue;
/**
* 票数
*/
@JsonProperty("vote_num")
private Integer voteNum;
/**
* 被选择占比
*/
@JsonProperty("proportion")
private Integer proportion;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<CaseExchangeVoteOptionDto> GetListDto(List<CaseExchangeVoteOptionModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
CaseExchangeVoteOptionDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteOptionDto.class);
// 示例手动处理字段类型不一致
if (model.getOptionId() != null) {
dto.setOptionId(String.valueOf(model.getOptionId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static CaseExchangeVoteOptionDto GetDto(CaseExchangeVoteOptionModel model) {
if (model == null) {
return null;
}
CaseExchangeVoteOptionDto dto = BeanUtil.copyProperties(model, CaseExchangeVoteOptionDto.class);
// 类型转换示例
if (model.getOptionId() != null) {
dto.setOptionId(String.valueOf(model.getOptionId())); // Long -> String
}
return dto;
}
}

View File

@ -0,0 +1,25 @@
package com.example.caseData.dto.caseLabel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class GetCaseLabelDto {
/**
* app唯一标识
*/
@JsonProperty("app_iden")
private String appIden;
/**
* 标签名称
*/
@JsonProperty("label_name")
private String labelName;
/**
* 是否存在子标签0 1:
*/
@JsonProperty("is_sub")
private Integer isSub = 0;
}

View File

@ -0,0 +1,26 @@
package com.example.caseData.dto.index;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GetIndexExchangeDto {
@JsonProperty("new_articles")
private List<CaseClinicalArticleDto> newArticles; // 最新上线
@JsonProperty("most_read_articles")
private List<CaseClinicalArticleDto> mostReadArticles; // 最多阅读
@JsonProperty("recommend_hospital")
private List<RecommendHospitalDto> recommendHospital; // 医院病例库推荐
@JsonProperty("recommend_doctor")
private List<RecommendDoctorDto> recommendDoctor; // 医生病例库推荐
}

View File

@ -0,0 +1,49 @@
package com.example.caseData.dto.publicDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class GetOssSignDto {
/**
* 临时访问密钥 ID
*/
@JsonProperty("access_id")
private String accessId;
/**
* 上传目标地址 Host
*/
@JsonProperty("host")
private String host;
/**
* 策略 Policy
*/
@JsonProperty("policy")
private String policy;
/**
* 签名结果
*/
@JsonProperty("signature")
private String signature;
/**
* 签名过期时间秒级时间戳
*/
@JsonProperty("expire")
private Long expire;
/**
* 回调配置
*/
@JsonProperty("callback")
private String callback;
/**
* 上传目录路径
*/
@JsonProperty("dir")
private String dir;
}

View File

@ -1,4 +1,4 @@
package com.example.caseData.dto;
package com.example.caseData.dto.publicDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
@ -8,10 +8,13 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PublicDto {
public class LoginDto {
@JsonProperty("user_id")
private String userId; // 主键id
@JsonProperty("doctor_id")
private String doctorId; // 医生id
@JsonProperty("user_name")
private String userName; // 用户名称

View File

@ -1,6 +1,7 @@
package com.example.caseData.dto.statsCaseClinical;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.model.StatsCaseClinicalModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@ -17,29 +18,41 @@ public class StatsCaseClinicalDto {
@JsonProperty("stats_id")
private String statsId;
/**
* 数量-文章
*/
@JsonProperty("article_num")
private Integer articleNum = 0;
/**
* 总阅读量-文章
*/
@JsonProperty("article_read_num")
private Integer articleReadNum;
private Integer articleReadNum = 0;
/**
* 总收藏量-文章
*/
@JsonProperty("article_collect_num")
private Integer articleCollectNum;
private Integer articleCollectNum = 0;
/**
* 数量-视频
*/
@JsonProperty("video_num")
private Integer videoNum = 0;
/**
* 总阅读量-视频
*/
@JsonProperty("video_read_num")
private Integer videoReadNum;
private Integer videoReadNum = 0;
/**
* 总收藏量-视频
*/
@JsonProperty("video_collect_num")
private Integer videoCollectNum;
private Integer videoCollectNum = 0;
/**
* 创建时间

View File

@ -30,19 +30,19 @@ public class StatsCaseClinicalDoctorDto {
* 数量-文章
*/
@JsonProperty("article_num")
private Integer articleNum;
private Integer articleNum = 0;
/**
* 总阅读量-文章
*/
@JsonProperty("article_read_num")
private Integer articleReadNum;
private Integer articleReadNum = 0;
/**
* 总收藏量-文章
*/
@JsonProperty("article_collect_num")
private Integer articleCollectNum;
private Integer articleCollectNum = 0;
/**
* 最后一篇文章发表时间
@ -54,19 +54,19 @@ public class StatsCaseClinicalDoctorDto {
* 数量-视频
*/
@JsonProperty("video_num")
private Integer videoNum;
private Integer videoNum = 0;
/**
* 总阅读量-视频
*/
@JsonProperty("video_read_num")
private Integer videoReadNum;
private Integer videoReadNum = 0;
/**
* 总收藏量-视频
*/
@JsonProperty("video_collect_num")
private Integer videoCollectNum;
private Integer videoCollectNum = 0;
/**
* 创建时间

View File

@ -31,19 +31,19 @@ public class StatsCaseClinicalHospitalDto {
* 数量-文章
*/
@JsonProperty("article_num")
private Integer articleNum;
private Integer articleNum = 0;
/**
* 总阅读量-文章
*/
@JsonProperty("article_read_num")
private Integer articleReadNum;
private Integer articleReadNum = 0;
/**
* 总收藏量-文章
*/
@JsonProperty("article_collect_num")
private Integer articleCollectNum;
private Integer articleCollectNum = 0;
/**
* 最后一篇文章发表时间
@ -55,19 +55,19 @@ public class StatsCaseClinicalHospitalDto {
* 数量-视频
*/
@JsonProperty("video_num")
private Integer videoNum;
private Integer videoNum = 0;
/**
* 总阅读量-视频
*/
@JsonProperty("video_read_num")
private Integer videoReadNum;
private Integer videoReadNum = 0;
/**
* 总收藏量-视频
*/
@JsonProperty("video_collect_num")
private Integer videoCollectNum;
private Integer videoCollectNum = 0;
/**
* 创建时间

View File

@ -0,0 +1,128 @@
package com.example.caseData.dto.statsCaseClinicalLabel;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.caseClinicalDoctor.CaseClinicalDoctorDto;
import com.example.caseData.model.StatsCaseClinicalDoctorModel;
import com.example.caseData.model.StatsCaseClinicalLabelModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class StatsCaseClinicalLabelDto {
/**
* 主键id
*/
@JsonProperty("stats_id")
private String statsId;
@JsonProperty("label_iden")
private String labelIden;
@JsonProperty("label_name")
private String labelName;
/**
* 数量-文章
*/
@JsonProperty("article_num")
private Integer articleNum = 0;
/**
* 总阅读量-文章
*/
@JsonProperty("article_read_num")
private Integer articleReadNum = 0;
/**
* 总收藏量-文章
*/
@JsonProperty("article_collect_num")
private Integer articleCollectNum = 0;
/**
* 最后一篇文章发表时间
*/
@JsonProperty("last_push_date")
private LocalDateTime lastPushDate;
/**
* 数量-视频
*/
@JsonProperty("video_num")
private Integer videoNum = 0;
/**
* 总阅读量-视频
*/
@JsonProperty("video_read_num")
private Integer videoReadNum = 0;
/**
* 总收藏量-视频
*/
@JsonProperty("video_collect_num")
private Integer videoCollectNum = 0;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 基础数据-医生
*/
@JsonProperty("case_clinical_doctor")
private CaseClinicalDoctorDto caseClinicalDoctor;
/**
* 列表
*/
public static List<StatsCaseClinicalLabelDto> GetListDto(List<StatsCaseClinicalLabelModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
StatsCaseClinicalLabelDto dto = BeanUtil.copyProperties(model, StatsCaseClinicalLabelDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static StatsCaseClinicalLabelDto GetDto(StatsCaseClinicalLabelModel model) {
if (model == null) {
return null;
}
StatsCaseClinicalLabelDto dto = BeanUtil.copyProperties(model, StatsCaseClinicalLabelDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
}
}

View File

@ -0,0 +1,97 @@
package com.example.caseData.dto.statsCaseExchange;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.model.StatsCaseExchangeModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class StatsCaseExchangeDto {
/**
* 主键id
*/
@JsonProperty("stats_id")
private String statsId;
/**
* 数量-病例交流
*/
@JsonProperty("exchange_num")
private Integer exchangeNum = 0;
/**
* 总阅读量-病例交流
*/
@JsonProperty("exchange_read_num")
private Integer exchangeReadNum = 0;
/**
* 总收藏量-病例交流
*/
@JsonProperty("exchange_collect_num")
private Integer exchangeCollectNum = 0;
/**
* 总评论量-病例交流
*/
@JsonProperty("exchange_comment_num")
private Integer exchangeCommentNum = 0;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<StatsCaseExchangeDto> GetListDto(List<StatsCaseExchangeModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
StatsCaseExchangeDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static StatsCaseExchangeDto GetDto(StatsCaseExchangeModel model) {
if (model == null) {
return null;
}
StatsCaseExchangeDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
}
}

View File

@ -0,0 +1,96 @@
package com.example.caseData.dto.statsCaseExchangeUser;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.model.StatsCaseExchangeUserModel;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class StatsCaseExchangeUserDto {
/**
* 主键id
*/
@JsonProperty("stats_id")
private String statsId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 数量-病例交流
*/
@JsonProperty("exchange_num")
private Integer exchangeNum = 0;
/**
* 总阅读量-病例交流
*/
@JsonProperty("exchange_read_num")
private Integer exchangeReadNum = 0;
/**
* 总收藏量-病例交流
*/
@JsonProperty("exchange_collect_num")
private Integer exchangeCollectNum = 0;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 列表
*/
public static List<StatsCaseExchangeUserDto> GetListDto(List<StatsCaseExchangeUserModel> models) {
if (models == null || models.isEmpty()) {
return Collections.emptyList();
}
return models.stream()
.map(model -> {
StatsCaseExchangeUserDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeUserDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
})
.collect(Collectors.toList());
}
/**
* 详情
*/
public static StatsCaseExchangeUserDto GetDto(StatsCaseExchangeUserModel model) {
if (model == null) {
return null;
}
StatsCaseExchangeUserDto dto = BeanUtil.copyProperties(model, StatsCaseExchangeUserDto.class);
// 示例手动处理字段类型不一致
if (model.getStatsId() != null) {
dto.setStatsId(String.valueOf(model.getStatsId())); // Long -> String
}
return dto;
}
}

View File

@ -0,0 +1,162 @@
package com.example.caseData.dto.user;
import cn.hutool.core.bean.BeanUtil;
import com.example.caseData.dto.basicHospital.BasicHospitalDto;
import com.example.caseData.dto.basicSensitiveWord.BasicSensitiveWordDto;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.model.BasicHospitalModel;
import com.example.caseData.model.CaseClinicalArticleModel;
import com.example.caseData.model.UserModel;
import com.example.caseData.utils.IntToString;
import com.example.caseData.utils.Replace;
import com.example.caseData.utils.StringToInt;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserDto {
/**
* 主键id
*/
@JsonProperty("user_id")
private String userId; // 主键id
/**
* 第三方平台唯一标识
*/
@JsonProperty("user_iden")
private String userIden; // 第三方平台唯一标识
/**
* 用户名称
*/
@JsonProperty("user_name")
private String userName; // 用户名称
/**
* 手机号
*/
@JsonProperty("user_mobile")
private String userMobile; // 手机号
/**
* 手机号加密
*/
@JsonProperty("mobile_encryption")
private String mobileEncryption; // 手机号加密
/**
* 状态0:禁用 1:正常 2:删除
*/
@JsonProperty("status")
private Integer status; // 状态0:禁用 1:正常 2:删除
/**
* 注册来源
*/
@JsonProperty("register_source")
private Integer registerSource;// 注册来源1:未知 2:app用户 3:佳动例
/**
* 用户微信标识
*/
@JsonProperty("open_id")
private String openId; // 用户微信标识
/**
* 微信开放平台标识
*/
@JsonProperty("union_id")
private String unionId; // 微信开放平台标识
/**
* 性别
*/
@JsonProperty("sex")
private Integer sex; // 性别0:未知 1: 2:
/**
* 头像
*/
@JsonProperty("avatar")
private String avatar; // 头像
/**
* 医生职称
*/
@JsonProperty("title")
private String title; // 医生职称
/**
* 科室名称
*/
@JsonProperty("department_name")
private String departmentName; // 科室名称
/**
* 所属医院id
*/
@JsonProperty("hospital_id")
private String hospitalId; // 所属医院id
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt; // 创建时间
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt; // 修改时间
/**
* 所属医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName; // 所属医院名称
/**
* 医生id
*/
@JsonProperty("doctor_id")
private String doctorId; // 医生id
/**
* 详情
*/
public static UserDto GetDto(UserModel model) {
if (model == null) {
return null;
}
UserDto dto = BeanUtil.copyProperties(model, UserDto.class);
// 类型转换示例
if (model.getUserId() != null) {
dto.setUserId(String.valueOf(model.getUserId())); // Long -> String
}
// 头像
if (model.getAvatar() != null) {
dto.setAvatar(Replace.addOssDomain(model.getAvatar()));
}
// 职称
if (model.getTitle() != null) {
dto.setTitle(IntToString.DoctorTitleToString(model.getTitle()));
}
// 医院
if (model.getBasicHospital() != null) {
dto.setHospitalName(model.getBasicHospital().getHospitalName());
}
return dto;
}
}

View File

@ -0,0 +1,102 @@
package com.example.caseData.dto.userCaseRead;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCaseReadDto {
/**
* 主键id
*/
@JsonProperty("read_id")
private String readId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 对应的id
*/
@JsonProperty("id")
private String id;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 数据
*/
@JsonProperty("data")
private UserCaseReadDto.DataDto data;
@Data
public static class DataDto {
@JsonProperty("id")
private String id;
/**
* 标题
*/
@JsonProperty("title")
private String title;
/**
* 发布时间
*/
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 阅读量
*/
@JsonProperty("read_num")
private Integer readNum;
/**
* 收藏量
*/
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 作者
*/
@JsonProperty("author")
private List<UserCaseReadDto.DataAuthorDto> author;
}
/**
* 作者
*/
@Data
public static class DataAuthorDto {
/**
* 医生名称
*/
@JsonProperty("doctor_name")
private String doctorName;
/**
* 医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName;
}
}

View File

@ -1,8 +1,14 @@
package com.example.caseData.dto.userCollectClinicalArticle;
import com.example.caseData.dto.caseClinicalArticle.CaseClinicalArticleDto;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.example.caseData.request.caseExchangeRequest.addCaseExchange;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCollectClinicalArticleDto {
@ -10,19 +16,19 @@ public class UserCollectClinicalArticleDto {
* 主键id
*/
@JsonProperty("collect_id")
private Long collectId;
private String collectId;
/**
* 用户id
*/
@JsonProperty("user_id")
private Long userId;
private String userId;
/**
* 临床文章id
* 对应的id
*/
@JsonProperty("article_id")
private Long articleId;
@JsonProperty("id")
private String id;
/**
* 创建时间
@ -35,4 +41,64 @@ public class UserCollectClinicalArticleDto {
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
}
/**
* 数据
*/
@JsonProperty("data")
private DataDto data;
@Data
public static class DataDto {
@JsonProperty("id")
private String id;
/**
* 标题
*/
@JsonProperty("title")
private String title;
/**
* 发布时间
*/
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 阅读量
*/
@JsonProperty("read_num")
private Integer readNum;
/**
* 收藏量
*/
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 作者
*/
@JsonProperty("author")
private List<DataAuthorDto> author;
}
/**
* 作者
*/
@Data
public static class DataAuthorDto {
/**
* 医生名称
*/
@JsonProperty("doctor_name")
private String doctorName;
/**
* 医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName;
}
}

View File

@ -1,8 +1,10 @@
package com.example.caseData.dto.userCollectClinicalVideo;
import com.example.caseData.dto.userCollectClinicalArticle.UserCollectClinicalArticleDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCollectClinicalVideoDto {
@ -10,19 +12,19 @@ public class UserCollectClinicalVideoDto {
* 主键id
*/
@JsonProperty("collect_id")
private Long collectId;
private String collectId;
/**
* 用户id
*/
@JsonProperty("user_id")
private Long userId;
private String userId;
/**
* 临床视频id
* 对应的id
*/
@JsonProperty("video_id")
private Long videoId;
@JsonProperty("id")
private String id;
/**
* 创建时间
@ -35,4 +37,64 @@ public class UserCollectClinicalVideoDto {
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 数据
*/
@JsonProperty("data")
private UserCollectClinicalVideoDto.DataDto data;
@Data
public static class DataDto {
@JsonProperty("id")
private String id;
/**
* 标题
*/
@JsonProperty("title")
private String title;
/**
* 发布时间
*/
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 阅读量
*/
@JsonProperty("read_num")
private Integer readNum;
/**
* 收藏量
*/
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 作者
*/
@JsonProperty("author")
private List<UserCollectClinicalVideoDto.DataAuthorDto> author;
}
/**
* 作者
*/
@Data
public static class DataAuthorDto {
/**
* 医生名称
*/
@JsonProperty("doctor_name")
private String doctorName;
/**
* 医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName;
}
}

View File

@ -0,0 +1,100 @@
package com.example.caseData.dto.userCollectExchange;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCollectExchangeDto {
/**
* 主键id
*/
@JsonProperty("collect_id")
private String collectId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 对应的id
*/
@JsonProperty("id")
private String id;
/**
* 创建时间
*/
@JsonProperty("created_at")
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
private LocalDateTime updatedAt;
/**
* 数据
*/
@JsonProperty("data")
private DataDto data;
@Data
public static class DataDto {
@JsonProperty("id")
private String id;
/**
* 标题
*/
@JsonProperty("title")
private String title;
/**
* 发布时间
*/
@JsonProperty("push_date")
private LocalDateTime pushDate;
/**
* 阅读量
*/
@JsonProperty("read_num")
private Integer readNum;
/**
* 收藏量
*/
@JsonProperty("collect_num")
private Integer collectNum;
/**
* 作者
*/
@JsonProperty("author")
private List<DataAuthorDto> author;
}
/**
* 作者
*/
@Data
public static class DataAuthorDto {
/**
* 医生名称
*/
@JsonProperty("doctor_name")
private String doctorName;
/**
* 医院名称
*/
@JsonProperty("hospital_name")
private String hospitalName;
}
}

View File

@ -0,0 +1,98 @@
package com.example.caseData.dto.userCommentCaseExchange;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class GetUserCaseExchangeCommentPageDto {
/**
* 主键id
*/
@JsonProperty("comment_id")
private String commentId;
/**
* 病例交流id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* 点赞数量
*/
@JsonProperty("like_num")
private Integer likeNum;
/**
* 评论内容
*/
@JsonProperty("content")
private String content;
/**
* 评论内容(原版)
*/
@JsonProperty("content_word")
private String contentWord;
/**
* 评论图片
*/
@JsonProperty("comment_image")
private String commentImage;
/**
* 创建时间
*/
@JsonProperty("created_at")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 标题
*/
@JsonProperty("exchange_title")
private String exchangeTitle;
/**
* 作者名称
*/
@JsonProperty("author_name")
private String authorName;
/**
* 作者医院id
*/
@JsonProperty("author_hospital_id")
private String authorHospitalId;
/**
* 作者医院
*/
@JsonProperty("author_hospital_name")
private String authorHospitalName;
/**
* 作者职称
*/
@JsonProperty("author_title_int")
private Integer authorTitleInt;
/**
* 作者职称
*/
@JsonProperty("author_title")
private String authorTitle;
}

View File

@ -0,0 +1,135 @@
package com.example.caseData.dto.userCommentCaseExchange;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCommentCaseExchangeDto {
/**
* 主键id
*/
@JsonProperty("comment_id")
private String commentId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 病例交流id
*/
@JsonProperty("exchange_id")
private String exchangeId;
/**
* 医生id
*/
@JsonProperty("doctor_id")
private String doctorId;
/**
* 父级id一级评论为null
*/
@JsonProperty("parent_id")
private String parentId;
/**
* 根评论id一级评论时为null其余为一级评论id
*/
@JsonProperty("root_id")
private String rootId;
/**
* 评论状态0:禁用 1:正常
*/
@JsonProperty("status")
private Integer status;
/**
* 是否存在敏感词0: 1:
*/
@JsonProperty("is_sensitive")
private Integer isSensitive;
/**
* 是否置顶0: 1:
*/
@JsonProperty("is_top")
private Integer isTop;
/**
* 点赞数量
*/
@JsonProperty("like_num")
private Integer likeNum;
/**
* 评论内容
*/
@JsonProperty("content")
private String content;
/**
* 评论内容(原版)
*/
@JsonProperty("content_word")
private String contentWord;
/**
* 评论图片
*/
@JsonProperty("comment_image")
private String commentImage;
/**
* 创建时间
*/
@JsonProperty("created_at")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 用户名称
*/
@JsonProperty("user_name")
private String userName;
/**
* 用户头像
*/
@JsonProperty("avatar")
private String avatar;
/**
* 用户唯一标识
*/
@JsonProperty("user_iden")
private String userIden;
/**
* 是否作者0: 1:
*/
@JsonProperty("is_author")
private Integer isAuthor;
/**
* 次级评论
*/
@JsonProperty("sub_comment")
private List<UserCommentCaseExchangeDto> subComment;
}

View File

@ -0,0 +1,84 @@
package com.example.caseData.dto.userCommentClinicalArticle;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.dto.caseClinicalArticleAuthor.CaseClinicalArticleAuthorDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class GetUserClinicalArticleCommentPageDto {
/**
* 主键id
*/
@JsonProperty("comment_id")
private String commentId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 文章id
*/
@JsonProperty("article_id")
private String articleId;
/**
* 标题
*/
@JsonProperty("article_title")
private String articleTitle;
/**
* 点赞数量
*/
@JsonProperty("like_num")
private Integer likeNum;
/**
* 评论内容
*/
@JsonProperty("content")
private String content;
/**
* 评论内容(原版)
*/
@JsonProperty("content_word")
private String contentWord;
/**
* 创建时间
*/
@JsonProperty("created_at")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 作者
*/
@JsonProperty("author")
private List<CaseClinicalArticleAuthorDto> author;
@Data
public static class CaseClinicalArticleAuthorDto {
/**
* 医生名称
*/
@JsonProperty("doctor_name")
private String doctorName;
}
}

View File

@ -1,8 +1,11 @@
package com.example.caseData.dto.userCommentClinicalArticle;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCommentClinicalArticleDto {
@ -10,31 +13,37 @@ public class UserCommentClinicalArticleDto {
* 主键id
*/
@JsonProperty("comment_id")
private Long commentId;
private String commentId;
/**
* 用户id
*/
@JsonProperty("user_id")
private Long userId;
private String userId;
/**
* 医生id
*/
@JsonProperty("doctor_id")
private String doctorId;
/**
* 临床文章id
*/
@JsonProperty("article_id")
private Long articleId;
private String articleId;
/**
* 父级id一级评论为null
*/
@JsonProperty("parent_id")
private Long parentId;
private String parentId;
/**
* 根评论id一级评论时为null其余为一级评论id
*/
@JsonProperty("root_id")
private Long rootId;
private String rootId;
/**
* 评论状态0:禁用 1:正常
@ -49,10 +58,10 @@ public class UserCommentClinicalArticleDto {
private Integer isSensitive;
/**
* 是否优质留言0: 1:
* 是否置顶0: 1:
*/
@JsonProperty("is_high_quality")
private Integer isHighQuality;
@JsonProperty("is_top")
private Integer isTop;
/**
* 点赞数量
@ -72,15 +81,53 @@ public class UserCommentClinicalArticleDto {
@JsonProperty("content_word")
private String contentWord;
/**
* 评论图片
*/
@JsonProperty("comment_image")
private String commentImage;
/**
* 创建时间
*/
@JsonProperty("created_at")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 用户名称
*/
@JsonProperty("user_name")
private String userName;
/**
* 用户唯一标识
*/
@JsonProperty("user_iden")
private String userIden;
/**
* 用户头像
*/
@JsonProperty("avatar")
private String avatar;
/**
* 是否作者0: 1:
*/
@JsonProperty("is_author")
private Integer isAuthor;
/**
* 次级评论
*/
@JsonProperty("sub_comment")
private List<UserCommentClinicalArticleDto> subComment;
}

View File

@ -0,0 +1,84 @@
package com.example.caseData.dto.userCommentClinicalVideo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.dto.caseClinicalVideoAuthor.CaseClinicalVideoAuthorDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class GetUserClinicalVideoCommentPageDto {
/**
* 主键id
*/
@JsonProperty("comment_id")
private String commentId;
/**
* 用户id
*/
@JsonProperty("user_id")
private String userId;
/**
* 视频id
*/
@JsonProperty("video_id")
private String videoId;
/**
* 标题
*/
@JsonProperty("video_title")
private String videoTitle;
/**
* 点赞数量
*/
@JsonProperty("like_num")
private Integer likeNum;
/**
* 评论内容
*/
@JsonProperty("content")
private String content;
/**
* 评论内容(原版)
*/
@JsonProperty("content_word")
private String contentWord;
/**
* 创建时间
*/
@JsonProperty("created_at")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 作者
*/
@JsonProperty("author")
private List<CaseClinicalVideoAuthorDto> author;
@Data
public static class CaseClinicalVideoAuthorDto {
/**
* 医生名称
*/
@JsonProperty("doctor_name")
private String doctorName;
}
}

View File

@ -1,8 +1,12 @@
package com.example.caseData.dto.userCommentClinicalVideo;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.example.caseData.dto.userCommentClinicalArticle.UserCommentClinicalArticleDto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class UserCommentClinicalVideoDto {
@ -10,31 +14,37 @@ public class UserCommentClinicalVideoDto {
* 主键id
*/
@JsonProperty("comment_id")
private Long commentId;
private String commentId;
/**
* 用户id
*/
@JsonProperty("user_id")
private Long userId;
private String userId;
/**
* 医生id
*/
@JsonProperty("doctor_id")
private String doctorId;
/**
* 临床视频id
*/
@JsonProperty("video_id")
private Long videoId;
private String videoId;
/**
* 父级id一级评论为null
*/
@JsonProperty("parent_id")
private Long parentId;
private String parentId;
/**
* 根评论id一级评论时为null其余为一级评论id
*/
@JsonProperty("root_id")
private Long rootId;
private String rootId;
/**
* 评论状态0:禁用 1:正常
@ -72,15 +82,53 @@ public class UserCommentClinicalVideoDto {
@JsonProperty("content_word")
private String contentWord;
/**
* 评论图片
*/
@JsonProperty("comment_image")
private String commentImage;
/**
* 创建时间
*/
@JsonProperty("created_at")
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createdAt;
/**
* 修改时间
*/
@JsonProperty("updated_at")
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updatedAt;
/**
* 用户名称
*/
@JsonProperty("user_name")
private String userName;
/**
* 用户头像
*/
@JsonProperty("avatar")
private String avatar;
/**
* 用户唯一标识
*/
@JsonProperty("user_iden")
private String userIden;
/**
* 是否作者0: 1:
*/
@JsonProperty("is_author")
private Integer isAuthor;
/**
* 次级评论
*/
@JsonProperty("sub_comment")
private List<UserCommentClinicalVideoDto> subComment;
}

View File

@ -26,24 +26,6 @@ import java.util.Map;
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
// 处理所有未捕获的异常
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, Object>> handleGlobalException(Exception ex) {
System.out.print(ExceptionUtils.getStackTrace(ex));
Map<String, Object> errorResponse = new HashMap<>();
String message = ExceptionUtils.getStackTrace(ex);
if (EnvUtil.isProd()) {
log.error("error:{}", message);
message = "内部错误";
}
errorResponse.put("message", "异常");
errorResponse.put("data", null);
errorResponse.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}
// 处理 404 请求接口不存在
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
@ -92,4 +74,22 @@ public class GlobalExceptionHandler {
errorResponse.put("code", ex.getCode());
return ResponseEntity.ok(errorResponse);
}
// 处理所有未捕获的异常
@ExceptionHandler(Exception.class)
public ResponseEntity<Map<String, Object>> handleGlobalException(Exception ex) {
System.out.print(ExceptionUtils.getStackTrace(ex));
Map<String, Object> errorResponse = new HashMap<>();
String message = ExceptionUtils.getStackTrace(ex);
if (EnvUtil.isProd()) {
log.error("error:{}", message);
message = "内部错误";
}
errorResponse.put("message", "异常");
errorResponse.put("data", null);
errorResponse.put("code", HttpStatus.INTERNAL_SERVER_ERROR.value());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorResponse);
}
}

View File

@ -0,0 +1,77 @@
package com.example.caseData.extend.aliyun;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
import com.example.caseData.config.DySmsConfig;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
@Slf4j
@Component
public class DySms {
@Resource
private DySmsConfig dySmsConfig;
private static final String endpoint = "dysmsapi.aliyuncs.com";
private static final String signName = "肝胆相照";
/**
* 创建短信客户端
*/
private Client createClient() throws Exception {
Config config = new Config()
.setAccessKeyId(dySmsConfig.getAccessKey())
.setAccessKeySecret(dySmsConfig.getAccessSecret())
.setEndpoint(endpoint);
return new Client(config);
}
/**
* 发送短信
*
* @param phoneNumber 手机号
* @param templateCode 模板CODE
* @param sceneDesc 场景说明用于日志或调试
* @param templateParam 模板参数
*/
public void sendSms(String phoneNumber, String templateCode, String sceneDesc, Map<String, Object> templateParam) {
try {
Client client = createClient();
ObjectMapper objectMapper = new ObjectMapper();
String paramJson = objectMapper.writeValueAsString(templateParam);
SendSmsRequest request = new SendSmsRequest()
.setPhoneNumbers(phoneNumber)
.setSignName(signName)
.setTemplateCode(templateCode)
.setTemplateParam(paramJson);
// 只用标准的RuntimeOptions不加任何自定义字段
RuntimeOptions runtime = new RuntimeOptions();
SendSmsResponse response = client.sendSmsWithOptions(request, runtime);
if (response.getBody() == null || !"OK".equals(response.getBody().getCode())) {
log.error("短信发送失败,手机号:{},场景:{},返回信息:{}", phoneNumber, sceneDesc, response.getBody() != null ? response.getBody().getMessage() : "无返回体");
throw new RuntimeException("短信发送失败: " + (response.getBody() != null ? response.getBody().getMessage() : "无返回体"));
} else {
log.info("短信发送成功,手机号:{},场景:{},返回信息:{}", phoneNumber, sceneDesc, response.getBody().getMessage());
}
} catch (TeaException e) {
log.error("阿里云短信发送异常,手机号:{},场景:{},错误信息:{}", phoneNumber, sceneDesc, e.getMessage(), e);
throw new RuntimeException("阿里云短信发送异常", e);
} catch (Exception e) {
log.error("短信发送异常,手机号:{},场景:{},错误信息:{}", phoneNumber, sceneDesc, e.getMessage(), e);
throw new RuntimeException("短信发送异常", e);
}
}
}

View File

@ -0,0 +1,187 @@
package com.example.caseData.extend.aliyun;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.*;
import com.example.caseData.config.JwtConfig;
import com.example.caseData.config.OssConfig;
import com.example.caseData.dto.publicDto.GetOssSignDto;
import com.example.caseData.middlewares.LogRequestInterceptor;
import com.example.caseData.utils.JwtUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;
@Slf4j
@Component
public class Oss {
private static OssConfig ossConfig;
private static final Logger logger = LoggerFactory.getLogger(LogRequestInterceptor.class);
public Oss(OssConfig ossConfig ){
Oss.ossConfig = ossConfig;
}
public static OSS createClient() {
return new OSSClientBuilder().build(ossConfig.getEndpoint(), ossConfig.getAccessKey(), ossConfig.getAccessKeySecret());
}
public static boolean putObject(String fileName, byte[] content) {
if (content == null || content.length == 0) {
logger.warn("Failed to upload object to OSS: content is null or empty, fileName={}", fileName);
return false;
}
if (fileName == null || fileName.trim().isEmpty()) {
logger.warn("Failed to upload object to OSS: fileName is null or empty");
return false;
}
OSS client = createClient();
ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
try {
// 推断 Content-Type
String contentType = determineContentType(fileName);
// 创建对象元数据
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(content.length);
metadata.setContentType(contentType);
// 执行上传
PutObjectRequest request = new PutObjectRequest(ossConfig.getBucket(), fileName, inputStream, metadata);
client.putObject(request);
logger.info("Successfully uploaded object to OSS: bucket={}, fileName={}, size={} bytes",
ossConfig.getBucket(), fileName, content.length);
return true;
} catch (Exception e) {
logger.error("Failed to upload object to OSS. fileName={}, error={}", fileName, e.getMessage(), e);
return false;
} finally {
try {
inputStream.close(); // 可以不关ByteArrayInputStream 空操作但建议写上
} catch (IOException ignored) { }
client.shutdown();
}
}
private static String determineContentType(String fileName) {
if (fileName == null) return "application/octet-stream";
int lastDotIndex = fileName.lastIndexOf('.');
if (lastDotIndex < 0) {
return "application/octet-stream";
}
String ext = fileName.substring(lastDotIndex + 1).toLowerCase();
return switch (ext) {
case "jpg", "jpeg" -> "image/jpeg";
case "png" -> "image/png";
case "gif" -> "image/gif";
case "bmp" -> "image/bmp";
case "webp" -> "image/webp";
case "pdf" -> "application/pdf";
case "txt" -> "text/plain";
case "html", "htm" -> "text/html";
case "xml" -> "application/xml";
case "json" -> "application/json";
case "mp4" -> "video/mp4";
case "avi" -> "video/x-msvideo";
case "mp3" -> "audio/mpeg";
default -> "application/octet-stream";
};
}
public static String getObjectToString(String fileName) {
OSS client = createClient();
try {
OSSObject ossObject = client.getObject(ossConfig.getBucket(), fileName);
InputStream content = ossObject.getObjectContent();
return new String(content.readAllBytes());
} catch (Exception e) {
logger.info(e.getMessage());
return null;
} finally {
client.shutdown();
}
}
public static boolean downloadObjectToFile(String fileName, String localPath) {
OSS client = createClient();
try {
client.getObject(new GetObjectRequest(ossConfig.getBucket(), fileName), new java.io.File(localPath));
return true;
} catch (Exception e) {
logger.info(e.getMessage());
return false;
} finally {
client.shutdown();
}
}
// 获取oss签名
public static GetOssSignDto getOssSign(String dir) {
long expireTime = 30;
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
Date expiration = new Date(expireEndTime);
PolicyConditions conditions = new PolicyConditions();
conditions.addConditionItem(PolicyConditions.COND_CONTENT_LENGTH_RANGE, 0, 1048576000);
conditions.addConditionItem(MatchMode.StartWith, PolicyConditions.COND_KEY, dir);
OSS client = createClient();
try {
String postPolicy = client.generatePostPolicy(expiration, conditions);
byte[] binaryData = postPolicy.getBytes(StandardCharsets.UTF_8);
String encodedPolicy = Base64.getEncoder().encodeToString(binaryData);
String signature = client.calculatePostSignature(postPolicy);
GetOssSignDto g = new GetOssSignDto();
g.setAccessId(ossConfig.getAccessKey());
g.setPolicy(encodedPolicy);
g.setSignature(signature);
g.setDir(dir);
g.setHost(ossConfig.getCustomDomainName());
g.setExpire( expireEndTime / 1000);
g.setCallback("");
return g;
} catch (Exception e) {
logger.info(e.getMessage());
return null;
} finally {
client.shutdown();
}
}
// 下载文件为 byte[]
public static byte[] getObjectToByte(String fileName) {
OSS client = createClient();
try (OSSObject ossObject = client.getObject(ossConfig.getBucket(), fileName);
InputStream content = ossObject.getObjectContent()) {
return content.readAllBytes();
} catch (Exception e) {
log.error("OSS 下载失败: fileName={}, error={}", fileName, e.getMessage(), e);
return null;
} finally {
client.shutdown();
}
}
}

View File

@ -2,15 +2,22 @@ package com.example.caseData.extend.app;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.example.caseData.exception.BusinessException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
public class Base {
@ -119,4 +126,42 @@ public class Base {
return response.body();
}
}
/**
* 校验签名使用已反序列化的 dto 对象
* @param request HttpServletRequest用于获取 appId sign
* @param secretKey 签名用的密钥
* @param dto 请求对象 addClinicalVideoApp
* @param mapper ObjectMapper 实例用于序列化 dto
*/
public void checkSign(HttpServletRequest request, String secretKey, Object dto, ObjectMapper mapper) {
try {
String appId = request.getHeader("appId");
String sign = request.getHeader("sign");
if (appId == null || appId.isEmpty()) {
throw new BusinessException("-1", "请求未授权(缺少 appId");
}
if (sign == null || sign.isEmpty()) {
throw new BusinessException("-1", "缺少签名");
}
// 转换 dto Map<String, Object> 用于签名生成
@SuppressWarnings("unchecked")
Map<String, Object> params = mapper.convertValue(dto, Map.class);
// 生成签名
String serverSign = genSignature(params, secretKey);
System.out.println("客户端签名: " + sign);
System.out.println("服务端签名: " + serverSign);
if (!sign.equals(serverSign)) {
throw new BusinessException("-1", "签名错误");
}
} catch (BusinessException e) {
throw e;
} catch (Exception e) {
throw new BusinessException("-1", "签名校验失败:" + e.getMessage());
}
}
}

View File

@ -1,6 +1,5 @@
package com.example.caseData.extend.app.Hospital;
import com.example.caseData.extend.app.UserInfo.GetUserInfoByMobileResponse;
import lombok.Data;
@Data
@ -23,7 +22,7 @@ public class GetHospitalByUuidResponse
/**
* 根据手机号获取医生信息 - 详细数据
* - 详细数据
*/
@Data
public static class GetHospitalByUuidData {
@ -40,6 +39,12 @@ public class GetHospitalByUuidResponse
/** 省份 */
private String prov_name;
/** 城市 */
private String city_name;
/** 区县 */
private String county_name;
/** 医生数量 */
private Integer expert_num;
}

View File

@ -0,0 +1,67 @@
package com.example.caseData.extend.app.Reward;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.example.caseData.config.AppConfig;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.app.Base;
import com.example.caseData.extend.app.label.GetLabelsResponse;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
public class Reward extends Base {
@Resource
private AppConfig appConfig;
// 打赏积分
public RewardResponse RewardPoint(String userUuid,Integer point,String authorUuid) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("user_uuid", userUuid);
requestData.put("bonusPoints", point);
requestData.put("recipients", authorUuid);
requestData.put("platform", appConfig.getPlatform());
requestData.put("timestamp", timestamp);
// 生成签名
String sign = genSignature(requestData,appConfig.getSecretKey());
String url = appConfig.getApiUrl() + "/expert-api/admireBonusPoints";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
try(HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("sign", sign)
.body(jsonBody)
.execute()){
if (response.getStatus() != 200) {
throw new BusinessException("失败");
}
// 反序列化 JSON
RewardResponse result = JSONUtil.toBean(response.body(), RewardResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){
throw new BusinessException(result.getMsg());
}else{
throw new BusinessException("失败");
}
}
return result;
}
}
}

View File

@ -0,0 +1,23 @@
package com.example.caseData.extend.app.Reward;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class RewardResponse
{
/** 接口调用状态。200正常其它值调用出错 */
private int code;
/** 结果说明。如果接口调用出错,那么返回错误描述。成功则返回 ok */
private String msg;
/** 接口是否调用成功 */
private boolean success;
/** 错误信息或提示信息 */
private String message;
}

View File

@ -0,0 +1,22 @@
package com.example.caseData.extend.app.Score;
import lombok.Data;
@Data
public class ReportUserScoreResponse
{
/** 接口调用状态。200正常其它值调用出错 */
private int code;
/** 结果说明。如果接口调用出错,那么返回错误描述。成功则返回 ok */
private String msg;
/** 接口是否调用成功 */
private boolean success;
/** 错误信息或提示信息 */
private String message;
/** 接口返回的数据 */
private Integer data;
}

View File

@ -0,0 +1,67 @@
package com.example.caseData.extend.app.Score;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.example.caseData.config.AppConfig;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.app.Base;
import com.example.caseData.extend.app.UserPoint.UserPointResponse;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
public class Score extends Base {
@Resource
private AppConfig appConfig;
// 上报用户积分
public ReportUserScoreResponse ReportUserScore(String uuid,Integer bonuspoints,String bonuspointsNote) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("bonuspoints_note", bonuspointsNote);
requestData.put("bonuspoints", bonuspoints);
requestData.put("user_uuid", uuid);
requestData.put("platform", appConfig.getPlatform());
requestData.put("timestamp", timestamp);
// 生成签名
String sign = genSignature(requestData,appConfig.getSecretKey());
String url = appConfig.getApiUrl() + "/expert-api/addBonusPoints";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
try(HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("sign", sign)
.body(jsonBody)
.execute()){
if (response.getStatus() != 200) {
throw new BusinessException("失败");
}
// 反序列化 JSON
ReportUserScoreResponse result = JSONUtil.toBean(response.body(), ReportUserScoreResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){
throw new BusinessException(result.getMsg());
}else{
throw new BusinessException("失败");
}
}
return result;
}
}
}

View File

@ -3,7 +3,7 @@ package com.example.caseData.extend.app.UserInfo;
import lombok.Data;
@Data
public class GetUserInfoByMobileResponse {
public class GetUserInfoResponse {
/** 接口调用状态。200正常其它值调用出错 */
private int code;
@ -11,7 +11,7 @@ public class GetUserInfoByMobileResponse {
private String msg;
/** 接口返回的用户信息数据 */
private GetUserInfoByMobileData data;
private ResponsData data;
/** 接口是否调用成功 */
private boolean success;
@ -20,11 +20,8 @@ public class GetUserInfoByMobileResponse {
private String message;
/**
* 根据手机号获取医生信息 - 详细数据
*/
@Data
public static class GetUserInfoByMobileData {
public static class ResponsData {
/** app唯一标识 */
private String uuid;
@ -41,6 +38,9 @@ public class GetUserInfoByMobileResponse {
/** 手机号 */
private String mobile;
/** 头像地址 */
private String img_host;
/** 头像地址 */
private String photo;

View File

@ -21,7 +21,7 @@ public class UserInfo extends Base {
private AppConfig appConfig;
// 根据手机号获取信息V3
public GetUserInfoByMobileResponse getUserInfoByMobile(String mobile) throws BusinessException {
public GetUserInfoResponse getUserInfoByMobile(String mobile) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
@ -48,7 +48,99 @@ public class UserInfo extends Base {
}
// 反序列化 JSON
GetUserInfoByMobileResponse result = JSONUtil.toBean(response.body(), GetUserInfoByMobileResponse.class);
GetUserInfoResponse result = JSONUtil.toBean(response.body(), GetUserInfoResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){
throw new BusinessException(result.getMsg());
}else{
throw new BusinessException("失败");
}
}
if (result.getData() == null){
throw new BusinessException("失败");
}
return result;
}
}
// 根据token获取信息V3
public GetUserInfoResponse getUserInfoByToken(String appToken) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("token", appToken);
requestData.put("platform", appConfig.getPlatform());
requestData.put("timestamp", timestamp);
// 生成签名
String sign = genSignature(requestData,appConfig.getSecretKey());
String url = appConfig.getApiUrl() + "/expert-api/getInfoByToken";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
try(HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("sign", sign)
.body(jsonBody)
.execute()){
if (response.getStatus() != 200) {
throw new BusinessException("失败");
}
// 反序列化 JSON
GetUserInfoResponse result = JSONUtil.toBean(response.body(), GetUserInfoResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){
throw new BusinessException(result.getMsg());
}else{
throw new BusinessException("失败");
}
}
if (result.getData() == null){
throw new BusinessException("失败");
}
return result;
}
}
// 根据唯一标识获取信息V3
public GetUserInfoResponse getUserInfoByUuid(String uuid) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("user_uuid", uuid);
requestData.put("platform", appConfig.getPlatform());
requestData.put("timestamp", timestamp);
// 生成签名
String sign = genSignature(requestData,appConfig.getSecretKey());
String url = appConfig.getApiUrl() + "/expert-api/getInfoByUuid";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
try(HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("sign", sign)
.body(jsonBody)
.execute()){
if (response.getStatus() != 200) {
throw new BusinessException("失败");
}
// 反序列化 JSON
GetUserInfoResponse result = JSONUtil.toBean(response.body(), GetUserInfoResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){

View File

@ -0,0 +1,64 @@
package com.example.caseData.extend.app.UserPoint;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.example.caseData.config.AppConfig;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.app.Base;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
public class UserPoint extends Base {
@Resource
private AppConfig appConfig;
// 获取用户积分
public UserPointResponse GetUserPoint(String uuid) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("user_uuid", uuid);
requestData.put("platform", appConfig.getPlatform());
requestData.put("timestamp", timestamp);
// 生成签名
String sign = genSignature(requestData,appConfig.getSecretKey());
String url = appConfig.getApiUrl() + "/expert-api/getBonusPoints";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
try(HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("sign", sign)
.body(jsonBody)
.execute()){
if (response.getStatus() != 200) {
throw new BusinessException("失败");
}
// 反序列化 JSON
UserPointResponse result = JSONUtil.toBean(response.body(), UserPointResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){
throw new BusinessException(result.getMsg());
}else{
throw new BusinessException("失败");
}
}
return result;
}
}
}

View File

@ -0,0 +1,26 @@
package com.example.caseData.extend.app.UserPoint;
import com.example.caseData.extend.app.label.GetLabelsResponse;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class UserPointResponse
{
/** 接口调用状态。200正常其它值调用出错 */
private int code;
/** 结果说明。如果接口调用出错,那么返回错误描述。成功则返回 ok */
private String msg;
/** 接口是否调用成功 */
private boolean success;
/** 错误信息或提示信息 */
private String message;
/** 接口返回的数据 */
private Integer data;
}

View File

@ -0,0 +1,19 @@
package com.example.caseData.extend.app.Video;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.app.Base;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@Slf4j
@Component
public class Video extends Base {
}

View File

@ -0,0 +1,55 @@
package com.example.caseData.extend.app.label;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class GetLabelsResponse
{
/** 接口调用状态。200正常其它值调用出错 */
private int code;
/** 结果说明。如果接口调用出错,那么返回错误描述。成功则返回 ok */
private String msg;
/** 接口返回的用户信息数据 */
private List<GetLabelsData> data;
/** 接口是否调用成功 */
private boolean success;
/** 错误信息或提示信息 */
private String message;
/**
* 根据统一标签列表 - 详细数据
*/
@Data
public static class GetLabelsData {
/**
* 标签名称
*/
private String name;
/**
* id
*/
private String id;
/**
* 子标签数量
*/
@JsonProperty("children_size")
private Integer childrenSize;
/**
* p_id
*/
@JsonProperty("p_id")
private String pId;
}
}

View File

@ -0,0 +1,69 @@
package com.example.caseData.extend.app.label;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.example.caseData.config.AppConfig;
import com.example.caseData.exception.BusinessException;
import com.example.caseData.extend.app.Base;
import com.example.caseData.extend.app.Hospital.GetHospitalByUuidResponse;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Slf4j
@Component
public class Label extends Base {
@Resource
private AppConfig appConfig;
// 根据医院唯一标识获取医院数据
public GetLabelsResponse getLabels(String p_id) throws BusinessException {
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
// 处理参数
Map<String, Object> requestData = new HashMap<>();
requestData.put("p_id", p_id);
requestData.put("platform", appConfig.getPlatform());
requestData.put("timestamp", timestamp);
// 生成签名
String sign = genSignature(requestData,appConfig.getSecretKey());
String url = appConfig.getApiUrl() + "/expert-api/getLabels";
String jsonBody = JSONUtil.toJsonStr(requestData);
log.info("获取app数据参数:{}",jsonBody);
try(HttpResponse response = HttpRequest.post(url)
.header("Content-Type", "application/json")
.header("sign", sign)
.body(jsonBody)
.execute()){
if (response.getStatus() != 200) {
throw new BusinessException("失败");
}
// 反序列化 JSON
GetLabelsResponse result = JSONUtil.toBean(response.body(), GetLabelsResponse.class);
log.info("获取app数据返回:{}",result);
if (result.getCode() != 200){
if (!Objects.equals(result.getMsg(), "")){
throw new BusinessException(result.getMsg());
}else{
throw new BusinessException("失败");
}
}
if (result.getData() == null){
throw new BusinessException("失败");
}
return result;
}
}
}

Some files were not shown because too many files have changed in this diff Show More