Compare commits

..

11 Commits

  1. 372
      API-Document.md
  2. 77
      dscape-cache/pom.xml
  3. 80
      dscape-cache/src/main/java/net/lensfrex/dscape/cache/UserBasicCache.java
  4. 23
      dscape-cache/src/main/java/net/lensfrex/dscape/configure/GlobalConstant.java
  5. 37
      dscape-cache/src/main/java/net/lensfrex/dscape/configure/RedisConfigure.java
  6. 46
      dscape-compute/pom.xml
  7. 13
      dscape-compute/src/main/java/net/lensfrex/dscape/ComputeMain.java
  8. 67
      dscape-dao/pom.xml
  9. 63
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/configure/MybatisPlusConfigure.java
  10. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/BlackListMapper.java
  11. 24
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/ComputeHistoryMapper.java
  12. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/PatientDataMapper.java
  13. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/RegisterAppliesMapper.java
  14. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/RolePermissionMapper.java
  15. 22
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/UserBasicMapper.java
  16. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/mapper/UserRoleMapper.java
  17. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/BlackListService.java
  18. 34
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/ComputeHistoryService.java
  19. 30
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/PatientDataService.java
  20. 23
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/RegisterAppliesService.java
  21. 30
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/RolePermissionService.java
  22. 34
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/UserBasicService.java
  23. 28
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/UserRoleService.java
  24. 24
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/BlackListServiceImpl.java
  25. 80
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/ComputeHistoryServiceImpl.java
  26. 50
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/PatientDataServiceImpl.java
  27. 22
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/RegisterAppliesServiceImpl.java
  28. 59
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/RolePermissionServiceImpl.java
  29. 61
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/UserBasicServiceImpl.java
  30. 43
      dscape-dao/src/main/java/net/lensfrex/dscape/dao/service/impl/UserRoleServiceImpl.java
  31. 54
      dscape-entities/pom.xml
  32. 68
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/BlackList.java
  33. 63
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/ComputeHistory.java
  34. 84
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/PatientData.java
  35. 68
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/RegisterApplies.java
  36. 63
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/RolePermission.java
  37. 83
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/UserBasic.java
  38. 63
      dscape-entities/src/main/java/net/lensfrex/dscape/dao/entity/UserRole.java
  39. 20
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/request/UserLoginRequestBody.java
  40. 10
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/request/compute/ComputeRequestBody.java
  41. 21
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/request/user/PasswordModifyRequestBody.java
  42. 23
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/request/user/RegisterRequestBody.java
  43. 22
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/request/user/UserAddRequest.java
  44. 38
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/response/data/compute/ComputeHistoryResponseData.java
  45. 10
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/response/data/compute/ComputeResponseData.java
  46. 20
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/response/data/user/RegisterResponseBody.java
  47. 58
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/response/general/Response.java
  48. 51
      dscape-entities/src/main/java/net/lensfrex/dscape/dto/response/general/ResponseCode.java
  49. 41
      dscape-entities/src/main/java/net/lensfrex/dscape/enums/blacklist/BlackListTypeEnum.java
  50. 24
      dscape-entities/src/main/java/net/lensfrex/dscape/enums/compute/ComputeStatusEnum.java
  51. 46
      dscape-entities/src/main/java/net/lensfrex/dscape/enums/user/UserRoleEnum.java
  52. 37
      dscape-entities/src/main/java/net/lensfrex/dscape/enums/user/UserStatusEnum.java
  53. 37
      dscape-entities/src/main/java/net/lensfrex/dscape/exception/GlobalException.java
  54. 55
      dscape-utils/pom.xml
  55. 46
      dscape-utils/src/main/java/net/lensfrex/dscape/utils/ObjectJsonSerializer.java
  56. 55
      dscape-utils/src/main/java/net/lensfrex/dscape/utils/ObjectSerializer.java
  57. 67
      dscape-utils/src/main/java/net/lensfrex/dscape/utils/validate/TextCheckUtil.java
  58. 132
      dscape-web/pom.xml
  59. 29
      dscape-web/src/main/java/net/lensfrex/dscape/ServerMain.java
  60. 45
      dscape-web/src/main/java/net/lensfrex/dscape/annotation/NotInvalidChar.java
  61. 108
      dscape-web/src/main/java/net/lensfrex/dscape/auth/StpInterfaceImpl.java
  62. 48
      dscape-web/src/main/java/net/lensfrex/dscape/configure/RabbitConfigure.java
  63. 187
      dscape-web/src/main/java/net/lensfrex/dscape/exception/handler/GlobalExceptionHandler.java
  64. 24
      dscape-web/src/main/java/net/lensfrex/dscape/mq/MessageQueueProducer.java
  65. 23
      dscape-web/src/main/java/net/lensfrex/dscape/utils/NetworkUtil.java
  66. 50
      dscape-web/src/main/java/net/lensfrex/dscape/web/controllers/compute/ComputeController.java
  67. 87
      dscape-web/src/main/java/net/lensfrex/dscape/web/controllers/history/HistoryController.java
  68. 87
      dscape-web/src/main/java/net/lensfrex/dscape/web/controllers/user/UserController.java
  69. 93
      dscape-web/src/main/java/net/lensfrex/dscape/web/controllers/user/admin/AdminController.java
  70. 64
      dscape-web/src/main/java/net/lensfrex/dscape/web/service/compute/ComputeService.java
  71. 62
      dscape-web/src/main/java/net/lensfrex/dscape/web/service/data/HistoryService.java
  72. 118
      dscape-web/src/main/java/net/lensfrex/dscape/web/service/user/AdminService.java
  73. 211
      dscape-web/src/main/java/net/lensfrex/dscape/web/service/user/UserService.java
  74. 92
      dscape-web/src/main/java/net/lensfrex/dscape/web/service/user/admin/InviteCode.java
  75. 73
      dscape-web/src/main/resources/application.yml
  76. 52
      dscape-web/src/main/resources/database.sql
  77. 115
      pom.xml
  78. 15
      src/main/java/net/lensfrex/dscape/ServerMain.java
  79. 12
      src/main/java/net/lensfrex/dscape/dao/PatientDataDao.java
  80. 5
      src/main/java/net/lensfrex/dscape/dao/UserBasicDao.java
  81. 12
      src/main/java/net/lensfrex/dscape/dao/mappers/PatientDataMapper.java
  82. 10
      src/main/java/net/lensfrex/dscape/dao/mappers/UserBasicMapper.java
  83. 142
      src/main/java/net/lensfrex/dscape/domain/PatientData.java
  84. 48
      src/main/java/net/lensfrex/dscape/domain/response/Response.java
  85. 36
      src/main/java/net/lensfrex/dscape/domain/response/data/admin/CreateUserResponse.java
  86. 62
      src/main/java/net/lensfrex/dscape/domain/response/data/admin/UserRegisterApplicationResponseData.java
  87. 87
      src/main/java/net/lensfrex/dscape/domain/response/data/compute/ComputeHistoryReponseData.java
  88. 36
      src/main/java/net/lensfrex/dscape/domain/response/data/compute/ComputeStatusQueryResponse.java
  89. 26
      src/main/java/net/lensfrex/dscape/domain/response/data/compute/ComputeTaskResponseData.java
  90. 66
      src/main/java/net/lensfrex/dscape/domain/response/data/user/LoginResponseData.java
  91. 26
      src/main/java/net/lensfrex/dscape/domain/response/data/user/RegisterResponseData.java
  92. 62
      src/main/java/net/lensfrex/dscape/domain/user/UserBasic.java
  93. 17
      src/main/java/net/lensfrex/dscape/domain/user/UserRole.java
  94. 15
      src/main/java/net/lensfrex/dscape/domain/user/UserStatus.java
  95. 19
      src/main/java/net/lensfrex/dscape/web/controllers/Error.java
  96. 18
      src/main/java/net/lensfrex/dscape/web/controllers/Index.java
  97. 24
      src/main/java/net/lensfrex/dscape/web/controllers/compute/Compute.java
  98. 26
      src/main/java/net/lensfrex/dscape/web/controllers/history/History.java
  99. 34
      src/main/java/net/lensfrex/dscape/web/controllers/user/User.java
  100. 37
      src/main/java/net/lensfrex/dscape/web/controllers/user/admin/Admin.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,4 +1,4 @@
# Dscape Restful API文档
# DscapeAPI文档
这里是Dscape服务端的API文档。这里定义了该服务的接口以及调用方式。
@ -14,20 +14,44 @@
---
## 0. 通用信息(非http状态码)
# 目录
- [DscapeAPI文档](#dscapeapi文档)
- [目录](#目录)
- [通用状态码](#通用状态码)
- [登录认证](#登录认证)
- [用户登录](#用户登录)
- [用户注册(公共)](#用户注册公共)
- [计算相关](#计算相关)
- [请求计算](#请求计算)
- [计算记录查询](#计算记录查询)
- [计算记录删除](#计算记录删除)
- [计算状态查询](#计算状态查询)
- [用户管理相关](#用户管理相关)
- [添加用户](#添加用户)
- [修改密码](#修改密码)
- [封禁、删除用户](#封禁删除用户)
- [管理员发放注册码](#管理员发放注册码)
| code | 信息 |
| --- | --- |
| 20000 | 成功 |
| 30000 | 参数错误 |
| 30001 | token过期 |
| 40300 | 权限不足 |
| 40000 | 非法请求 |
---
## 通用状态码
这里的状态码是所有接口都有可能会返回的状态码
| code | 信息 |
| ----- | -------------- |
| 20000 | 成功 |
| 30000 | 非法请求 |
| 30001 | 参数错误 |
| 40000 | 权限不足 |
| 40001 | token过期 |
| 40002 | token无效 |
| 50000 | 服务器内部错误 |
| 0 | 接口未实现 |
---
## 1. 登录认证
## 登录认证
### 用户登录
@ -36,28 +60,28 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| userName | string | false |用户登录名,非空 |
| password | string | false |用户登录密码,非空,其值为明文密码两次sha256加密 |
| 参数 | 值类型 | 可空 | 说明 |
| --------- | ------ | ----- | ------------------------------------------------ |
| user_name | string | false | 用户登录名,非空 |
| password | string | false | 用户登录密码,非空,其值为明文密码两次sha256加密 |
例如:
``` json
{
"userName": "admin",
"user_name": "admin",
"password": "e723fb2ff93afb010960ac20c05439f1cdd1ecbb533947e7de9f43656a612052"
}
```
- 返回数据
| 参数 | 值类型 | 说明 |
| --- | --- | --- |
| uid | string | 用户对应的uid |
| role | int | 用户权限类型,0:普通用户,1:管理员 |
| access_token | string | 本次登录得到的token,过期后应当用refresh_token重新获取 |
| refresh_token | string | 刷新用的token,过期后应当重新登录 |
| expired | long | access_token过期时间 |
| 参数 | 值类型 | 说明 |
| ------------- | ------ | ------------------------------------------------------ |
| uid | string | 用户对应的uid |
| role | int | 用户权限类型,0:普通用户,1:管理员 |
| access_token | string | 本次登录得到的token,过期后应当用refresh_token重新获取 |
| refresh_token | string | 刷新用的token,过期后应当重新登录 |
| expired | long | access_token过期时间 |
例如:(token为精简过的jwt)
``` json
@ -75,45 +99,43 @@
```
- 错误信息
| code | 错误 |
| --- | --- |
| 40301 | 用户名或密码错误 |
| 40302 | 用户已被封禁 |
| 40305 | 上级管理员未认证该用户 |
| code | 错误 |
| ----- | ---------------------- |
| 60101 | 用户名或密码错误 |
| 60102 | 用户已被封禁 |
| 60103 | 上级管理员未认证该用户 |
---
### 用户注册(公共)
> 用户注册可由管理员手动创建,也可以由用户自行注册,但是需要提供管理员名称,并且由管理员确认信息后才能使用
>
> 在系统中首次注册的用户即为管理员,管理员注册后普通用户必须要提供上级管理员才能注册
> 在系统中首次注册的用户即为管理员,管理员注册后普通用户必须要提供上级管理员提供的注册码才能注册
- URL路径:`/user/register`
- 方法:`POST`
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| userName | string | false | 用户登录名,非空 |
| password | string | false | 用户登录密码,非空,其值为明文密码两次sha256加密 |
| superior | string | true | 上级管理员用户名 |
| 参数 | 值类型 | 可空 | 说明 |
| ----------- | ------ | ----- | ------------------------------------------------ |
| user_name | string | false | 用户登录名,非空 |
| password | string | false | 用户登录密码,非空,其值为明文密码两次sha256加密 |
| invite_code | string | true | 上级管理员发放的注册码 |
例如:
``` json
{
"userName": "admin",
"user_name": "lensfrex",
"password": "e723fb2ff93afb010960ac20c05439f1cdd1ecbb533947e7de9f43656a612052",
"superior": "lensfrex"
"invite_code": "asdf"
}
```
- 返回数据
| 参数 | 值类型 | 说明 |
| --- | --- | --- |
| uid | string | 用户对应的uid |
| 参数 | 值类型 | 说明 |
| ---- | ------ | ------------- |
| uid | string | 用户对应的uid |
例如:
``` json
@ -128,16 +150,17 @@
- 错误信息
| code | 错误 |
| --- | --- |
| 40300 | 权限不足 |
| 20001 | 用户已存在 |
| code | 错误 |
| ----- | ---------- |
| 40300 | 权限不足 |
| 60201 | 用户已存在 |
| 60202 | 注册码不正确 |
> 管理员添加用户,详见[添加用户](#添加用户)
---
## 2. 计算相关
## 计算相关
### 请求计算
@ -146,12 +169,12 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| pid | string | false | 患者数据id |
| ctdna | int | false | 患者ctDNA长度 |
| cpg | int | false | 患者甲基化位点数 |
| token | string(header) | false |请求token,必须提供 |
| 参数 | 值类型 | 可空 | 说明 |
| ----- | -------------- | ----- | ------------------- |
| pid | string | false | 患者数据id |
| ctdna | int | false | 患者ctDNA长度 |
| cpg | int | false | 患者甲基化位点数 |
| token | string(header) | false | 请求token,必须提供 |
例如:
``` json
@ -164,9 +187,9 @@
- 返回数据
| 参数 | 值类型 | 说明 |
| --- | --- | --- |
| id | string | 本次计算请求的任务id |
| 参数 | 值类型 | 说明 |
| ---- | ------ | -------------------- |
| id | string | 本次计算请求的任务id |
例如:
``` json
@ -183,10 +206,10 @@
- 错误信息
| code | 错误 |
| --- | --- |
| 40300 | 权限不足 |
| 40303 | 计算请求的ip已被封禁 |
| code | 错误 |
| ----- | ---------------------- |
| 40300 | 权限不足 |
| 40303 | 计算请求的ip已被封禁 |
| 40304 | 计算请求的用户已被封禁 |
| 40305 | 用户的计算配额到达上限 |
@ -199,13 +222,13 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| uid | string(url) | false | 需要获取记录的用户uid |
| offset | int(url) | false | 分页数据偏移量 |
| limit | int(url) | false | 每页数据数量 |
| page | int(url) | false | 分页页码 |
| token | string(header) | false | 请求token,必须提供 |
| 参数 | 值类型 | 可空 | 说明 |
| ------ | -------------- | ----- | --------------------- |
| uid | string(url) | false | 需要获取记录的用户uid |
| offset | int(url) | false | 分页数据偏移量 |
| limit | int(url) | false | 每页数据数量 |
| page | int(url) | false | 分页页码 |
| token | string(header) | false | 请求token,必须提供 |
例如,需要获取用户uid为`9a6d777c-997d-a7e5-35f4-8471b7582ac0`记录的第三页数据,每页10条数据:
```
@ -216,15 +239,15 @@
> data部分以数组的形式返回
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| id | int | 数据id |
| pid | int | 患者id |
| ctdna | int | 患者ctDNA长度 |
| cpg | int | 患者甲基化位点数 |
| hcc | boolean | 患者是否为HCC |
| hcc_infer | boolean | 推算得出的HCC状态 |
| time | datetime(string) | 时间 |
| 参数 | 值类型 | 可空 | 说明 |
| --------- | ---------------- | ----------------- | ---- |
| id | int | 数据id |
| pid | int | 患者id |
| ctdna | int | 患者ctDNA长度 |
| cpg | int | 患者甲基化位点数 |
| hcc | boolean | 患者是否为HCC |
| hcc_infer | boolean | 推算得出的HCC状态 |
| time | datetime(string) | 时间 |
例如:
``` json
@ -258,8 +281,8 @@
- 错误信息
| code | 错误 |
| --- | --- |
| code | 错误 |
| ----- | -------- |
| 40300 | 权限不足 |
---
@ -271,10 +294,10 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| rid | int(url) | false | 欲删除的计算历史记录 |
| token | string(header) | false |当前登录用户的token |
| 参数 | 值类型 | 可空 | 说明 |
| ----- | -------------- | ----- | -------------------- |
| rid | int(url) | false | 欲删除的计算历史记录 |
| token | string(header) | false | 当前登录用户的token |
例如,需要获取id为`1145`的记录:
```
@ -296,8 +319,8 @@
- 错误信息
| code | 错误 |
| --- | --- |
| code | 错误 |
| ----- | -------- |
| 40300 | 权限不足 |
---
@ -309,9 +332,9 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| tid | string | false | 计算任务的id |
| 参数 | 值类型 | 可空 | 说明 |
| ----- | -------------- | ----- | ------------------- |
| tid | string | false | 计算任务的id |
| token | string(header) | false | 当前登录用户的token |
例如:
@ -321,10 +344,10 @@
- 返回数据
| 参数 | 值类型 | 说明 |
| --- | --- | --- |
| id | string | 本次计算请求的任务id |
| status | int | 计算状态,0:完成,1:计算中,3:排队中,4:已被终止或未被运行 |
| 参数 | 值类型 | 说明 |
| ------ | ------ | -------------------------------------------------------------- |
| id | string | 本次计算请求的任务id |
| status | int | 计算状态,0:完成,1:计算中,3:排队中,4:已被终止或未被运行 |
例如:
``` json
@ -340,13 +363,13 @@
- 错误信息
| code | 错误 |
| --- | --- |
| code | 错误 |
| ----- | -------- |
| 40300 | 权限不足 |
---
## 3. 用户管理相关
## 用户管理相关
> 这部分的的大部分接口只能由管理员调用使用
@ -357,17 +380,17 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| userName | string | false | 用户登录名,非空 |
| password | string | false | 用户登录密码,非空,其值为明文密码两次sha256加密 |
| role | int | true | 用户角色 |
| token | string(header) | 管理员的access_token |
| 参数 | 值类型 | 可空 | 说明 |
| --------- | -------------- | -------------------- | ------------------------------------------------ |
| user_name | string | false | 用户登录名,非空 |
| password | string | false | 用户登录密码,非空,其值为明文密码两次sha256加密 |
| role | int | true | 用户角色 |
| token | string(header) | 管理员的access_token |
例如:
``` json
{
"userName": "admin",
"user_name": "admin",
"password": "e723fb2ff93afb010960ac20c05439f1cdd1ecbb533947e7de9f43656a612052",
"role": 0
}
@ -375,10 +398,10 @@
- 返回数据
| 字段 | 值类型 | 说明 |
| --- | --- | --- |
| uid | string | 用户对应的uid |
| role | int | 用户权限类型,0:普通用户,1:管理员 |
| 字段 | 值类型 | 说明 |
| ---- | ------ | ------------------------------------ |
| uid | string | 用户对应的uid |
| role | int | 用户权限类型,0:普通用户,1:管理员 |
例如:
@ -395,9 +418,9 @@
- 错误信息
| code | 错误 |
| --- | --- |
| 40300 | 权限不足 |
| code | 错误 |
| ----- | ---------- |
| 40300 | 权限不足 |
| 20001 | 用户已存在 |
---
@ -411,12 +434,12 @@
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| uid | string(url) | false |欲修改密码的用户uid |
| old_password | string | true |原始密码,其值为明文密码两次sha256加密,若不提供,则token拥有者应当为管理员 |
| new_password | string | false | 新密码,其值为明文密码两次sha256加密 |
| token | string(header) | false | 当前对应用户的uid |
| 参数 | 值类型 | 可空 | 说明 |
| ------------ | -------------- | ----- | --------------------------------------------------------------------------- |
| uid | string(url) | false | 欲修改密码的用户uid |
| old_password | string | true | 原始密码,其值为明文密码两次sha256加密,若不提供,则token拥有者应当为管理员 |
| new_password | string | false | 新密码,其值为明文密码两次sha256加密 |
| token | string(header) | false | 当前对应用户的uid |
例如:
``` json
@ -441,32 +464,24 @@
- 错误信息
| code | 错误 |
| --- | --- |
| code | 错误 |
| ----- | -------- |
| 40300 | 权限不足 |
---
### 封禁、删除用户
- URL路径:`/user/admin/modifyStatus/{uid}`
- URL路径:`/user/admin/modifyStatus/{uid}?status={status}`
- 方法:`POST`
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| uid | string(url) | false | 欲修改状态的用户uid |
| status | int | false |修改状态,0:正常;1:彻底封禁(无法登录);2:注销(销号);3:计算封禁 |
| token | string(header) | 当前对应用户的uid |
例如:
``` json
{
"uid": "9a6d777c-997d-a7e5-35f4-8471b7582ac0",
"new_password": 1
}
```
| 参数 | 值类型 | 可空 | 说明 |
| ------ | -------------- | ----------------- | ------------------------------------------------------------------------ |
| uid | string(url) | false | 欲修改状态的用户uid |
| status | int(url) | false | 修改状态,0:正常;1:彻底封禁(无法登录);2:注销(销号);3:计算封禁 |
| token | string(header) | 当前对应用户的uid |
- 返回数据
@ -483,115 +498,50 @@
- 错误信息
| code | 错误 |
| --- | --- |
| code | 错误 |
| ----- | -------- |
| 40300 | 权限不足 |
---
### 管理员获取待审批注册用户
### 管理员发放注册码
- URL路径:`/user/admin/application/list?offset={offset}&limit={limit}&page={page}`
- URL路径:`/user/admin/inviteCode?expired={expired}&count={count}`
- 方法:`GET`
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| offset | int(url) | false | 分页数据偏移量 |
| limit | int(url) | false | 每页数据数量 |
| page | int(url) | false | 分页页码 |
| token | string(header) | false | 请求token,必须提供 |
例如,需要第三页数据,每页10条数据:
```
https://dscape.lensfrex.net/api/v1/user/admin/apply?offset=20&limit=10&page=3
```
| 参数 | 值类型 | 可空 | 说明 |
| ------ | -------------- | ----- | ------------------- |
| expired | long(url) | false | 过期时间,留空或设为0表示不过期,以时间戳为格式 |
| count | int(url) | false | 获取数量,留空只获取一条,每位管理员最大可申请1024条(有效的) |
- 返回数据
> data部分以数组的形式返回
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| id | int | 审批记录id |
| uid | string | 待审批用户uid |
| name | string | 待审批用户名 |
| ip | string | 用户发送审批时的ip |
| time | datetime(string) | 申请时间 |
| 参数 | 值类型 | 可空 | 说明 |
| ---- | ---------------- | ------------------ | ---- |
例如:
``` json
{
"code": 20000,
"msg": "success",
"data" : [
{
"id": 64888,
"uid": "9a6d777c-997d-a7e5-35f4-8471b7582ac0",
"name": "lensfrex2",
"ip": "127.0.0.1",
"time": "2022-07-10 08:00:00"
},
{
"id": 64889,
"uid": "9a6d777c-997d-a7e5-35f4-8471b7582ac1",
"name": "lensfrex2",
"ip": "127.0.0.1",
"time": "2022-07-10 08:00:00"
},
"asdf",
"zxcv",
"qwer"
// ...
]
}
```
- 错误信息
| code | 错误 |
| --- | --- |
| 40300 | 权限不足 |
---
### 审核用户注册
- URL路径:`/user/admin/application/deal/{uid}`
- 方法:`POST`
- 请求参数:
| 参数 | 值类型 | 可空 | 说明 |
| --- | --- | --- | --- |
| uid | string(url) | false | 处理的用户uid |
| idea | boolean | false | 处理意见,true:通过;false:拒绝 |
| token | string(header) | 当前对应用户的uid |
例如:
``` json
{
"uid": "9a6d777c-997d-a7e5-35f4-8471b7582ac0",
"idea": true
}
```
- 返回数据
> data部分无返回数据
例如:
``` json
{
"code": 20000,
"msg": "success",
"data" : null
}
```
- 错误信息
| code | 错误 |
| --- | --- |
| code | 错误 |
| ----- | -------- |
| 40300 | 权限不足 |
| 60401 | 申请数量超过上限 |
---
---

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Class created by lensfrex.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dscape-server</artifactId>
<groupId>net.lensfrex</groupId>
<version>0.0.1-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dscape-cache</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-entities</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-utils</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,80 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.cache;
import net.lensfrex.dscape.configure.GlobalConstant;
import net.lensfrex.dscape.dao.entity.UserBasic;
import net.lensfrex.dscape.utils.ObjectJsonSerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class UserBasicCache {
private static final String USER_INFO_CACHE_KEY = GlobalConstant.USER_INFO_CACHE_KEY;
private static final String USERNAME_UID_CACHE_KEY = GlobalConstant.USERNAME_UID_CACHE_KEY;
private final RedisTemplate<String, String> redis;
public UserBasicCache(RedisTemplate<String, String> redis) {
this.redis = redis;
}
public UserBasic getUserByUid(String uid) {
try {
String cacheData = (String) redis.opsForHash().get(USER_INFO_CACHE_KEY, uid);
if (cacheData != null) {
return ObjectJsonSerializer.deserialize(cacheData, UserBasic.class);
} else {
log.debug("缓存中没有用户信息");
return null;
}
} catch (Exception e) {
log.warn("获取缓存时出现问题");
log.debug("追踪:", e);
return null;
}
}
public UserBasic getUserByUserName(String username) {
try {
String uid = (String) redis.opsForHash().get(USERNAME_UID_CACHE_KEY, username);
if (uid != null) {
return this.getUserByUid(uid);
} else {
log.debug("缓存中没有用户名和uid的对应信息");
return null;
}
} catch (Exception e) {
log.warn("获取缓存时出现问题");
log.debug("追踪:", e);
return null;
}
}
public void save(UserBasic userBasic) {
redis.opsForHash().put(USER_INFO_CACHE_KEY, userBasic.getUid(), ObjectJsonSerializer.serialize(userBasic));
redis.opsForHash().put(USERNAME_UID_CACHE_KEY, userBasic.getUserName(), userBasic.getUid());
}
public void clear(String uid) {
redis.opsForHash().delete(USER_INFO_CACHE_KEY, uid);
}
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.configure;
public class GlobalConstant {
public static final String USER_INFO_CACHE_KEY = "dscape:user:basic";
public static final String USERNAME_UID_CACHE_KEY = "dscape:user:uid";
public static final String REGISTER_INVITE_CODE_KEY = "dscape:user:inviteCodes";
public static final String ADMIN_INVITE_CODE_COUNTER_KEY = "dscape:admin:inviteCodeCounter:%s";
}

@ -0,0 +1,37 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.configure;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@EnableCaching
public class RedisConfigure extends CachingConfigurerSupport {
@Bean
public RedisTemplate<String, Object> redisTemplate(LettuceConnectionFactory redisConnectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory);
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.afterPropertiesSet();
return redisTemplate;
}
}

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dscape-server</artifactId>
<groupId>net.lensfrex</groupId>
<version>0.0.1-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dscape-compute</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-dao</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.yannrichet/Rsession -->
<dependency>
<groupId>com.github.yannrichet</groupId>
<artifactId>Rsession</artifactId>
<version>3.1.6</version>
<exclusions>
<exclusion>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

@ -0,0 +1,13 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@MapperScan("net.lensfrex.dscape.dao.mapper")
public class ComputeMain {
}

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Class created by lensfrex.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dscape-server</artifactId>
<groupId>net.lensfrex</groupId>
<version>0.0.1-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dscape-dao</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-entities</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,63 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.configure;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.annotation.Resource;
/**
* 分页功能的配置类
*/
@Slf4j
@Configuration
@EnableTransactionManagement
public class MybatisPlusConfigure {
@Resource
DataSourceProperties dataSourceProperties;
@Bean
public PaginationInnerInterceptor paginationInnerInterceptor() {
return new PaginationInnerInterceptor();
}
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
String databaseDriverName = dataSourceProperties.getDriverClassName();
PaginationInnerInterceptor paginationInnerInterceptor;
if (databaseDriverName.contains("mariadb")) {
log.info("使用Mariadb作为数据库");
paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MARIADB);
} else if (databaseDriverName.contains("mysql")) {
log.info("使用Mysql作为数据库");
paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
} else {
paginationInnerInterceptor = new PaginationInnerInterceptor();
log.warn("使用了可能不受支持的数据库:" + databaseDriverName);
}
paginationInnerInterceptor.setOptimizeJoin(true);
interceptor.addInnerInterceptor(paginationInnerInterceptor);
return interceptor;
}
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.BlackList;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description black_listMapper
* @date 2022-08-19
*/
@Mapper
public interface BlackListMapper extends BaseMapper<BlackList> {
}

@ -0,0 +1,24 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.ComputeHistory;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description compute_historyMapper
* @date 2022-08-22
*/
@Mapper
public interface ComputeHistoryMapper extends BaseMapper<ComputeHistory> {
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.PatientData;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description patient_dataMapper
* @date 2022-08-22
*/
@Mapper
public interface PatientDataMapper extends BaseMapper<PatientData> {
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.RegisterApplies;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description register_appliesMapper
* @date 2022-08-18
*/
@Mapper
public interface RegisterAppliesMapper extends BaseMapper<RegisterApplies> {
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.RolePermission;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description role_permissionMapper
* @date 2022-08-17
*/
@Mapper
public interface RolePermissionMapper extends BaseMapper<RolePermission> {
}

@ -0,0 +1,22 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.UserBasic;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description user_basicMapper
* @date 2022-08-18
*/
@Mapper
public interface UserBasicMapper extends BaseMapper<UserBasic> {
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.dao.entity.UserRole;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lensfrex
* @description user_roleMapper
* @date 2022-08-17
*/
@Mapper
public interface UserRoleMapper extends BaseMapper<UserRole> {
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.BlackList;
import org.springframework.stereotype.Service;
/**
* @author lensfrex
* @description black_list服务层
* @date 2022-08-19
*/
@Service
public interface BlackListService extends IService<BlackList> {
}

@ -0,0 +1,34 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.ComputeHistory;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author lensfrex
* @description compute_history服务层
* @date 2022-08-22
*/
@Service
public interface ComputeHistoryService extends IService<ComputeHistory> {
long count(SFunction<ComputeHistory, ?> indexColum, Object index);
List<ComputeHistory> getHistory(String uid, int page, int limit);
List<Long> getHistoryDataIds(String uid, int page, int limit);
boolean remove(Long id);
String getHistoryUser(Long rid);
}

@ -0,0 +1,30 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.PatientData;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
/**
* @author lensfrex
* @description patient_data服务层
* @date 2022-08-22
*/
@Service
public interface PatientDataService extends IService<PatientData> {
List<PatientData> getData(Collection<Long> ids);
PatientData getData(Long id);
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.RegisterApplies;
import org.springframework.stereotype.Service;
/**
* @author lensfrex
* @description register_applies服务层
* @date 2022-08-18
*/
@Service
public interface RegisterAppliesService extends IService<RegisterApplies> {
}

@ -0,0 +1,30 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.RolePermission;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author lensfrex
* @description role_permission服务层
* @date 2022-08-17
*/
@Service
public interface RolePermissionService extends IService<RolePermission> {
@Select("select permission from role_permission where role = #{role} and is_deleted = 0")
List<String> getPermissions(String role);
@Select("select permission from role_permission where role = #{role} and is_deleted = 0")
List<String> getPermissions(List<String> roles);
}

@ -0,0 +1,34 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.UserBasic;
import org.springframework.stereotype.Service;
/**
* @author lensfrex
* @description user_basic服务层
* @date 2022-08-18
*/
@Service
public interface UserBasicService extends IService<UserBasic> {
UserBasic getUser(SFunction<UserBasic, ?> function, String index);
UserBasic getUser(QueryWrapper<UserBasic> wrapper);
boolean userNameExists(String username);
void modify(SFunction<UserBasic, ?> colm, Object index, SFunction<UserBasic, ?> modifyColm, Object newValue);
void modify(UpdateWrapper<UserBasic> wrapper);
}

@ -0,0 +1,28 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service;
import com.baomidou.mybatisplus.extension.service.IService;
import net.lensfrex.dscape.dao.entity.UserRole;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author lensfrex
* @description user_role服务层
* @date 2022-08-17
*/
@Service
public interface UserRoleService extends IService<UserRole> {
@Select("select role from user_role where uid = '#{uid}' and is_deleted != 1")
List<String> getRoles(String uid);
}

@ -0,0 +1,24 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.entity.BlackList;
import net.lensfrex.dscape.dao.mapper.BlackListMapper;
import net.lensfrex.dscape.dao.service.BlackListService;
import org.springframework.stereotype.Service;
@Service
public class BlackListServiceImpl extends ServiceImpl<BlackListMapper, BlackList> implements BlackListService {
}

@ -0,0 +1,80 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.entity.ComputeHistory;
import net.lensfrex.dscape.dao.mapper.ComputeHistoryMapper;
import net.lensfrex.dscape.dao.service.ComputeHistoryService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class ComputeHistoryServiceImpl extends ServiceImpl<ComputeHistoryMapper, ComputeHistory> implements ComputeHistoryService {
@Override
public long count(SFunction<ComputeHistory, ?> indexColum, Object index) {
QueryWrapper<ComputeHistory> wrapper = new QueryWrapper<>();
wrapper.lambda()
.eq(indexColum, index);
return this.count(wrapper);
}
@Override
public List<ComputeHistory> getHistory(String uid, int page, int limit) {
QueryWrapper<ComputeHistory> wrapper = new QueryWrapper<>();
wrapper.lambda()
.eq(ComputeHistory::getUid, uid);
return this.page(new Page<>(page, limit), wrapper).getRecords();
}
@Override
public List<Long> getHistoryDataIds(String uid, int page, int limit) {
QueryWrapper<ComputeHistory> wrapper = new QueryWrapper<>();
wrapper.lambda()
.select(ComputeHistory::getRid)
.eq(ComputeHistory::getUid, uid);
List<ComputeHistory> results = this.page(new Page<>(page, limit), wrapper).getRecords();
List<Long> ids = new ArrayList<>(results.size());
results.forEach(result -> ids.add(result.getRid()));
return ids;
}
@Override
public boolean remove(Long rid) {
QueryWrapper<ComputeHistory> wrapper = new QueryWrapper<>();
wrapper.lambda()
.eq(ComputeHistory::getRid, rid);
return this.remove(wrapper);
}
@Override
public String getHistoryUser(Long rid) {
QueryWrapper<ComputeHistory> wrapper = new QueryWrapper<>();
wrapper.lambda()
.select(ComputeHistory::getUid)
.eq(ComputeHistory::getRid, rid);
return this.getOne(wrapper).getUid();
}
}

@ -0,0 +1,50 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.entity.PatientData;
import net.lensfrex.dscape.dao.service.PatientDataService;
import net.lensfrex.dscape.dao.mapper.PatientDataMapper;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@Service
public class PatientDataServiceImpl extends ServiceImpl<PatientDataMapper, PatientData> implements PatientDataService {
@Override
public List<PatientData> getData(Collection<Long> ids) {
if (ids == null || ids.isEmpty()) {
return new ArrayList<>();
}
QueryWrapper<PatientData> wrapper = new QueryWrapper<>();
wrapper.lambda()
.in(PatientData::getId, ids)
.orderByDesc(PatientData::getId);
return this.list(wrapper);
}
@Override
public PatientData getData(Long rid) {
QueryWrapper<PatientData> wrapper = new QueryWrapper<>();
wrapper.lambda()
.eq(PatientData::getId, rid);
return this.getOne(wrapper);
}
}

@ -0,0 +1,22 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.mapper.RegisterAppliesMapper;
import net.lensfrex.dscape.dao.service.RegisterAppliesService;
import net.lensfrex.dscape.dao.entity.RegisterApplies;
public class RegisterAppliesServiceImpl extends ServiceImpl<RegisterAppliesMapper, RegisterApplies> implements RegisterAppliesService {
}

@ -0,0 +1,59 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.entity.RolePermission;
import net.lensfrex.dscape.dao.mapper.RolePermissionMapper;
import net.lensfrex.dscape.dao.service.RolePermissionService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {
@Override
public List<String> getPermissions(String role) {
QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
wrapper.lambda()
.select(RolePermission::getPermission)
.eq(RolePermission::getRole, role)
.eq(RolePermission::getIsDeleted, 0);
return this.getPermissions(wrapper);
}
@Override
public List<String> getPermissions(List<String> roles) {
QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
wrapper.lambda()
.select(RolePermission::getPermission)
.in(RolePermission::getRole, roles)
.eq(RolePermission::getIsDeleted, 0);
return this.getPermissions(wrapper);
}
private List<String> getPermissions(QueryWrapper<RolePermission> wrapper) {
List<RolePermission> rolePermissionList = this.list(wrapper);
List<String> permissions = new ArrayList<>();
rolePermissionList.forEach(rolePermission -> permissions.add(rolePermission.getPermission().toString()));
return permissions;
}
}

@ -0,0 +1,61 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.entity.UserBasic;
import net.lensfrex.dscape.dao.service.UserBasicService;
import net.lensfrex.dscape.dao.mapper.UserBasicMapper;
import org.springframework.stereotype.Service;
@Service
public class UserBasicServiceImpl extends ServiceImpl<UserBasicMapper, UserBasic> implements UserBasicService {
@Override
public UserBasic getUser(SFunction<UserBasic, ?> indexColm, String index) {
QueryWrapper<UserBasic> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(indexColm, index);
return this.getOne(wrapper);
}
@Override
public UserBasic getUser(QueryWrapper<UserBasic> wrapper) {
return this.getOne(wrapper);
}
@Override
public boolean userNameExists(String username) {
QueryWrapper<UserBasic> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(UserBasic::getUserName, username);
return this.count(wrapper) != 0;
}
@Override
public void modify(SFunction<UserBasic, ?> indexColm, Object index, SFunction<UserBasic, ?> modifyColm, Object newValue) {
UpdateWrapper<UserBasic> wrapper = new UpdateWrapper<>();
wrapper.lambda()
.eq(indexColm, index)
.set(modifyColm, newValue);
this.update(wrapper);
}
@Override
public void modify(UpdateWrapper<UserBasic> wrapper) {
this.update(wrapper);
}
}

@ -0,0 +1,43 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.lensfrex.dscape.dao.entity.UserRole;
import net.lensfrex.dscape.dao.mapper.UserRoleMapper;
import net.lensfrex.dscape.dao.service.UserRoleService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
@Override
public List<String> getRoles(String uid) {
QueryWrapper<UserRole> wrapper = new QueryWrapper<>();
wrapper.lambda()
.select(UserRole::getRole)
.eq(UserRole::getUid, uid)
.eq(UserRole::getIsDeleted, 0);
List<UserRole> userRoleList = this.list(wrapper);
List<String> roles = new ArrayList<>();
userRoleList.forEach(userRole -> roles.add(userRole.getRole().toString()));
return roles;
}
}

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Class created by lensfrex.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dscape-server</artifactId>
<groupId>net.lensfrex</groupId>
<version>0.0.1-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dscape-entities</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>3.5.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,68 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author lensfrex
* @description black_list
* @date 2022-08-19
*/
@Data
public class BlackList implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
/**
* id
*/
private Integer id;
/**
* 黑名单数据类型0ip1uid
*/
private int type;
/**
* 黑名单条目名称可空
*/
private String name;
/**
* 黑名单数据
*/
private String data;
/**
* create_time
*/
private Date createTime;
/**
* edit_time
*/
private Date editTime;
/**
* is_deleted
*/
@TableLogic
private int isDeleted;
public BlackList() {
}
}

@ -0,0 +1,63 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lensfrex
* @description compute_history
* @date 2022-08-23
*/
@Data
public class ComputeHistory implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
/**
* id
*/
private Long id;
/**
* 计算数据记录对应的用户uid
*/
private String uid;
/**
* 计算数据记录对应的患者数据id
*/
private Long rid;
/**
* 状态0完成1计算中
*/
private int status;
/**
* create_time
*/
private LocalDateTime createTime;
/**
* edit_time
*/
private LocalDateTime editTime;
/**
* is_deleted
*/
private int isDeleted;
public ComputeHistory() {
}
}

@ -0,0 +1,84 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lensfrex
* @description patient_data
* @date 2022-08-17
*/
@Data
public class PatientData implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 数据id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 病人id
*/
private Integer pid;
/**
* ctdna长度
*/
private Integer ctdnaLength;
/**
* 甲基化位点数
*/
private Integer cpg;
/**
* 是否为hcc0: 1:
*/
private int isHcc;
/**
* 通过推断得出的hcc状态
*/
private int isInferHcc;
/**
* create_time
*/
private LocalDateTime createTime;
/**
* edit_time
*/
private LocalDateTime editTime;
/**
* is_deleted
*/
@TableLogic
private int isDeleted;
public PatientData() {
}
}

@ -0,0 +1,68 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lensfrex
* @description register_applies
* @date 2022-08-18
*/
@Data
public class RegisterApplies implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 管理员uid
*/
private String admin;
/**
* 申请认证的用户
*/
private String applyUser;
/**
* 申请状态
*/
private int status;
/**
* create_time
*/
private LocalDateTime createTime;
/**
* edit_time
*/
private LocalDateTime editTime;
/**
* is_deleted
*/
@TableLogic
private int isDeleted;
public RegisterApplies() {
}
}

@ -0,0 +1,63 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lensfrex
* @description role_permission
* @date 2022-08-17
*/
@Data
public class RolePermission implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
/**
* id
*/
private Long id;
/**
* 角色id
*/
private Integer role;
/**
* 权限id
*/
private Integer permission;
/**
* create_time
*/
private LocalDateTime createTime;
/**
* edit_time
*/
private LocalDateTime editTime;
/**
* is_deleted
*/
@TableLogic
private int isDeleted;
public RolePermission() {
}
}

@ -0,0 +1,83 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lensfrex
* @description user_basic
* @date 2022-08-18
*/
@Data
public class UserBasic implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private Integer id;
/**
* 用户唯一uuid
*/
@TableId(type = IdType.AUTO)
private String uid;
/**
* 用户用户名
*/
private String userName;
/**
* 用户密码
*/
private String password;
/**
* 账号对应的上级管理员若无上级管理员请设为null字符串
*/
private String superior;
/**
* 用户注册ip
*/
private String createIp;
/**
* 用户状态0正常1封禁2注销销号;3未激活
*/
private int status;
/**
* create_time
*/
private LocalDateTime createTime;
/**
* edit_time
*/
private LocalDateTime editTime;
/**
* is_deleted
*/
@TableLogic
private int isDeleted;
public UserBasic() {
}
}

@ -0,0 +1,63 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author lensfrex
* @description user_role
* @date 2022-08-17
*/
@Data
public class UserRole implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 角色id
*/
private Integer role;
/**
* 用户uid
*/
private String uid;
/**
* create_time
*/
private LocalDateTime createTime;
/**
* edit_time
*/
private LocalDateTime editTime;
/**
* is_deleted
*/
@TableLogic
private int isDeleted;
public UserRole() {
}
}

@ -0,0 +1,20 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.request;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class UserLoginRequestBody {
@JsonProperty("user_name")
private String userName;
private String password;
}

@ -0,0 +1,10 @@
package net.lensfrex.dscape.dto.request.compute;
import lombok.Data;
@Data
public class ComputeRequestBody{
private int pid;
private int cpg;
private int ctdna;
}

@ -0,0 +1,21 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.request.user;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class PasswordModifyRequestBody {
@JsonProperty("old_password")
String oldPassword;
@JsonProperty("new_password")
String newPassword;
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.request.user;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class RegisterRequestBody {
@JsonProperty("user_name")
private String userName;
private String password;
@JsonProperty("invite_code")
private String inviteCode;
}

@ -0,0 +1,22 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.request.user;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class UserAddRequest {
@JsonProperty("user_name")
private String userName;
private String password;
private int role;
}

@ -0,0 +1,38 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.response.data.compute;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class ComputeHistoryResponseData {
private long id;
private long cpg;
private long ctdna;
private Boolean hcc;
@JsonProperty("hcc_infer")
private Boolean hccInfer;
private long pid;
private String time;
}

@ -0,0 +1,10 @@
package net.lensfrex.dscape.dto.response.data.compute;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class ComputeResponseData{
private Long id;
}

@ -0,0 +1,20 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.response.data.user;
import lombok.Data;
@Data
public class RegisterResponseBody {
private String uid;
}

@ -0,0 +1,58 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.response.general;
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response<T> {
private final int code;
private final String message;
private final T data;
public Response(int code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public static <T> Response<T> success(T data) {
return new Response<>(ResponseCode.SUCCESS.getCode(), "success", data);
}
public static <T> Response<T> success() {
return success(null);
}
public static <T> Response<T> error(int code, String message) {
return new Response<>(code, message, null);
}
public static <T> Response<T> error(ResponseCode code, String message) {
return error(code.getCode(), message);
}
public static <T> Response<T> error(ResponseCode code) {
return error(code, code.getMessage());
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
public T getData() {
return data;
}
}

@ -0,0 +1,51 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dto.response.general;
public enum ResponseCode {
SUCCESS(20000, "成功"),
INVALID_REQUEST(30000, "非法请求"),
PARAM_WRONG(30001, "参数错误"),
PERMISSION_DENIED(40000, "权限不足"),
NEED_LOGIN(40001, "需要登录"),
TOKEN_EXPIRED(40001, "token过期"),
TOKEN_INVALID(40002, "token无效"),
SERVER_INTERNAL_ERROR(50000, "服务器内部错误"),
API_NOT_IMPLEMENT(0, "接口未实现"),
USERNAME_OR_PASSWORD_WRONG(60101, "用户名或密码不正确"),
USER_WAS_BANNED(60102, "用户已被封禁"),
USER_WAS_NOT_IDENTIFIED(60103, "上级管理员未认证该用户"),
USER_NAME_EXISTS(60204, "用户名已经被使用"),
INVITE_CODE_WRONG(60202, "注册码不正确"),
INVITE_CODE_REACHED_LIMIT(60401, "注册码已达上限");
private final int code;
private final String message;
ResponseCode(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
}

@ -0,0 +1,41 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.enums.blacklist;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
@Getter
public enum BlackListTypeEnum {
IP_ADDRESS(0, "IP地址"),
UID(1, "用户UID"),
;
@EnumValue
private final int code;
private final String name;
BlackListTypeEnum(int code, String name) {
this.code = code;
this.name = name;
}
}

@ -0,0 +1,24 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.enums.compute;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Data;
import lombok.Getter;
@Getter
public enum ComputeStatusEnum {
FINISHED(0, "完成"),
PROCESSING(1, "处理中");
@EnumValue
private final int code;
private final String name;
ComputeStatusEnum(int code, String name) {
this.code = code;
this.name = name;
}
}

@ -0,0 +1,46 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.enums.user;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
@Getter
public enum UserRoleEnum {
NORMAL_USER(0, "normal"),
ADMIN(1, "admin");
private final static UserRoleEnum[] allEnums = values();
@EnumValue
private final int code;
private final String name;
UserRoleEnum(int code, String name) {
this.code = code;
this.name = name;
}
public static UserRoleEnum getTypeEnumByCode(int code) {
for (UserRoleEnum result : allEnums) {
if (result.code == code) {
return result;
}
}
throw new IllegalArgumentException(String.format("角色id\"%s\"不存在", code));
}
}

@ -0,0 +1,37 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.enums.user;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
@Getter
public enum UserStatusEnum {
NORMAL(0, "正常"),
BANNED(1, "封禁中"),
NOT_IDENTIFIED(2, "管理员未认证");
@EnumValue
private final int code;
private final String name;
UserStatusEnum(int code, String name) {
this.code = code;
this.name = name;
}
}

@ -0,0 +1,37 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.exception;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
public class GlobalException extends RuntimeException {
private final ResponseCode responseCode;
public GlobalException(ResponseCode responseCode) {
super(responseCode.toString());
this.responseCode = responseCode;
}
public GlobalException(ResponseCode responseCode, String message) {
super(message);
this.responseCode = responseCode;
}
public ResponseCode getResponseCode() {
return responseCode;
}
}

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Class created by lensfrex.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dscape-server</artifactId>
<groupId>net.lensfrex</groupId>
<version>0.0.1-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dscape-utils</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,46 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
public class ObjectJsonSerializer {
/**
* 序列化对象到json字符串
*
* @param obj 待序列化的对象
* @return 序列化后的数据
*/
public static String serialize(Object obj) {
try {
return new ObjectMapper().registerModule(new JavaTimeModule()).writeValueAsString(obj);
} catch (Exception e) {
return null;
}
}
/**
* 反序列化对象
*
* @param data 源数据
* @return 反序列化后的对象
*/
public static <T> T deserialize(String data, Class<T> valueType) {
try {
return new ObjectMapper().registerModule(new JavaTimeModule()).readValue(data, valueType);
} catch (Exception e) {
return null;
}
}
}

@ -0,0 +1,55 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.utils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
@Slf4j
public class ObjectSerializer {
/**
* 序列化对象到二进制
*
* @param obj 待序列化的对象
* @return 序列化后的数据
*/
public static byte[] serialize(Object obj) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
new ObjectOutputStream(byteArrayOutputStream).writeObject(obj);
return byteArrayOutputStream.toByteArray();
} catch (Exception e) {
return null;
}
}
/**
* 反序列化对象
*
* @param data 源数据
* @return 反序列化后的对象
*/
public static Object deserialize(byte[] data) {
try {
return new ObjectInputStream(new ByteArrayInputStream(data)).readObject();
} catch (Exception e) {
return null;
}
}
}

@ -0,0 +1,67 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.utils.validate;
public class TextCheckUtil {
private static final String ABC_AND_CHINESE_REGEX = "[^a-zA-Z0-9\\_\\u4e00-\\u9fa5]";
private static final String ABC_REGEX = "[^a-zA-Z0-9\\_]";
// [^a-zA-Z0-9\_\[\];',./{}:"<>?/*\-\\!@#$%^&()\+\u4e00-\u9fa5]
private static final String ALL_CHARACTER_REGEX = "[^a-zA-Z0-9\\_\\[\\];',./{}:\"<>?/*\\-\\\\!@#$%^&()+=~`\\u4e00-\\u9fa5]";
/**
* 检测非字母和中文符号下划线"_"除外
*
* @param source 待检测字符串
* @return 是否含有非字母字符
*/
public static boolean checkNoneAbcAndChinese(String source) {
return !source.matches(ABC_AND_CHINESE_REGEX);
}
/**
* 批量检测非字母和中文符号下划线"_"除外
*
* @param source 待检测字符串
* @return 是否含有非字母字符
*/
public static boolean checkNoneAbcAndChinese(String... source) {
for (String text : source) {
if (text.matches(ABC_AND_CHINESE_REGEX)) {
return true;
}
}
return false;
}
public static boolean checkNoneCharacter(String source) {
return !source.matches(ALL_CHARACTER_REGEX);
}
public static boolean checkNoneCharacter(String... source) {
for (String text : source) {
if (text.matches(ALL_CHARACTER_REGEX)) {
return true;
}
}
return false;
}
}

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dscape-server</artifactId>
<groupId>net.lensfrex</groupId>
<version>0.0.1-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dscape-web</artifactId>
<description>dscape后端主服务</description>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-dao</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-cache</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-entities</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>net.lensfrex</groupId>
<artifactId>dscape-utils</artifactId>
<version>0.0.1-dev</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>2.7.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-spring-boot-starter</artifactId>
<version>1.30.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- 雪花id算法生成库(改进过的) -->
<dependency>
<groupId>com.github.yitter</groupId>
<artifactId>yitter-idgenerator</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>2.7.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,29 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape;
import com.github.yitter.contract.IdGeneratorOptions;
import com.github.yitter.idgen.YitIdHelper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import java.util.TimeZone;
@SpringBootApplication
@MapperScan("net.lensfrex.dscape.dao.mapper")
public class ServerMain extends SpringBootServletInitializer {
public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
IdGeneratorOptions options = new IdGeneratorOptions((short) 12);
options.WorkerIdBitLength = 4;
YitIdHelper.setIdGenerator(options);
SpringApplication.run(ServerMain.class, args);
}
}

@ -0,0 +1,45 @@
///*
// * Class created by lensfrex.
// */
//
//package net.lensfrex.dscape.annotation;
//
//import net.lensfrex.dscape.utils.validate.TextCheckUtil;
//
//import java.lang.annotation.Documented;
//import java.lang.annotation.Repeatable;
//import java.lang.annotation.Retention;
//import java.lang.annotation.Target;
//
//import static java.lang.annotation.ElementType.*;
//import static java.lang.annotation.RetentionPolicy.RUNTIME;
//
//@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
//@Retention(RUNTIME)
//@Repeatable(NotInvalidChar.List.class)
//@Documented
//@Constraint(validatedBy = TextCheckUtil.class)//标明由哪个类执行校验逻辑
//public @interface NotInvalidChar {
// String message() default "value not in enum values.";
//
// Class<?>[] groups() default {};
//
//// Class<? extends Payload>[] payload() default {};
//
// /**
// * @return date must in this value array
// */
// String[] value();
//
// /**
// * Defines several {@link NotInvalidChar} annotations on the same element.
// *
// * @see NotInvalidChar
// */
// @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE})
// @Retention(RUNTIME)
// @Documented
// @interface List {
// NotInvalidChar[] value();
// }
//}

@ -0,0 +1,108 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.auth;
import cn.dev33.satoken.stp.StpInterface;
import lombok.extern.slf4j.Slf4j;
import net.lensfrex.dscape.dao.service.RolePermissionService;
import net.lensfrex.dscape.dao.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Component
public class StpInterfaceImpl implements StpInterface {
private final UserRoleService userRoleService;
private final RolePermissionService rolePermissionService;
private final RedisTemplate<String, String> redis;
@Autowired
public StpInterfaceImpl(RedisTemplate<String, String> redis,
UserRoleService userRoleService,
RolePermissionService rolePermissionService) {
this.userRoleService = userRoleService;
this.rolePermissionService = rolePermissionService;
this.redis = redis;
}
@Override
public List<String> getPermissionList(Object loginId, String loginType) {
String uid = (String) loginId;
List<String> userRoles = this.getRoleList(loginId, loginType);
List<String> rolePermissions = new ArrayList<>();
for (String role : userRoles) {
String redisRolePermissionKey = "dscape:auth:role:permission:" + role;
if (Boolean.FALSE.equals(redis.hasKey(redisRolePermissionKey))) {
log.debug("角色 " + uid + " 的权限信息缓存不存在,从数据库中查找并放入缓存");
rolePermissions.addAll(rolePermissionService.getPermissions(role));
if (rolePermissions.isEmpty()) {
return rolePermissions;
}
redis.opsForList().leftPushAll(redisRolePermissionKey, rolePermissions);
} else {
List<String> cachedUserRole = redis.opsForList().range(redisRolePermissionKey, 0, -1);
if (cachedUserRole == null) {
return rolePermissions;
}
rolePermissions.addAll(cachedUserRole);
}
}
return rolePermissions;
}
@Override
public List<String> getRoleList(Object loginId, String loginType) {
String uid = (String) loginId;
String redisUserRoleKey = "dscape:auth:user:role:" + uid;
List<String> userRoleList = new ArrayList<>(2);
if (Boolean.FALSE.equals(redis.hasKey(redisUserRoleKey))) {
log.debug("用户 " + uid + " 的角色信息缓存不存在,从数据库中查找并放入缓存");
userRoleList.addAll(userRoleService.getRoles(uid));
if (userRoleList.isEmpty()) {
return userRoleList;
}
redis.opsForList().leftPushAll(redisUserRoleKey, userRoleList);
} else {
List<String> cachedUserRole = redis.opsForList().range(redisUserRoleKey, 0, -1);
if (cachedUserRole == null) {
return userRoleList;
}
userRoleList.addAll(cachedUserRole);
}
return userRoleList;
}
}

@ -0,0 +1,48 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.configure;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class RabbitConfigure {
public static final String QUEUE_NAME = "net.lensfrex.dscape.mq.queue";
public static final String EXCHANGE_NAME = "net.lensfrex.dscape.mq.exchange";
public static final String ROUTING_KEY = "net.lensfrex.dscape.mq.routing";
@Bean
public Queue queue() {
return new Queue(QUEUE_NAME, true, false, false);
}
@Bean
public DirectExchange directExchange() {
return new DirectExchange(EXCHANGE_NAME, true, false);
}
@Bean
public Binding binding() {
return BindingBuilder
.bind(this.queue())
.to(this.directExchange())
.with(ROUTING_KEY);
}
}

@ -0,0 +1,187 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.exception.handler;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.NotRoleException;
import com.fasterxml.jackson.databind.JsonMappingException;
import net.lensfrex.dscape.dto.response.general.Response;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.exception.GlobalException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MultipartException;
/**
* 全局异常处理负责后端抛出Exception时响应相应的信息
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
* 负责处理各种自定义业务异常权限不足学号不存在等
*
* @param e 抛出的异常
* @return 统一响应
*/
@ExceptionHandler(GlobalException.class)
public Response<Object> handler(GlobalException e) {
log.debug("请求错误: " + e.getResponseCode().getMessage());
return Response.error(e.getResponseCode());
}
/**
* 负责处理和响应其他部分都没有接收的异常说白了就是剩下的都返回50000
* 这部分日志要特别关注所以以error打出来
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(Exception.class)
public Response<Object> handler(Exception e) {
log.error("请求错误: " + e.getMessage());
log.error("异常类: " + e.getClass());
log.error("追踪:", e);
return Response.error(ResponseCode.SERVER_INTERNAL_ERROR);
}
/**
* 处理参数不完整的请求异常
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(MissingServletRequestParameterException.class)
public Response<Object> handler(MissingServletRequestParameterException e) {
log.debug("请求的参数不完整: " + e.getMessage());
return Response.error(ResponseCode.PARAM_WRONG);
}
/**
* 处理参数类型错误的请求异常请求参数类型错误
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public Response<Object> handler(MethodArgumentTypeMismatchException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.PARAM_WRONG);
}
/**
* 处理参数类型错误的请求异常请求参数类型错误
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(IllegalArgumentException.class)
public Response<Object> handler(IllegalArgumentException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.PARAM_WRONG);
}
/**
* 处理参数类型错误的请求异常2Json解析错误
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(JsonMappingException.class)
public Response<Object> handler(JsonMappingException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.PARAM_WRONG);
}
/**
* 处理参数类型错误的请求异常3字段映射错误
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(HttpMessageNotReadableException.class)
public Response<Object> handler(HttpMessageNotReadableException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.PARAM_WRONG);
}
/**
* 处理请求头中Content-Type字段不正确的异常
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public Response<Object> handler(HttpMediaTypeNotSupportedException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.PARAM_WRONG, "请求头\"Contene-Type\"字段有误");
}
/**
* 处理请求方法错误的情况
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Response<Object> handler(HttpRequestMethodNotSupportedException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.INVALID_REQUEST);
}
/**
* 处理上传文件时不是Multipart方式
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(MultipartException.class)
public Response<Object> handler(MultipartException e) {
log.debug(String.format("请求错误(%s): %s", e.getClass().getName(), e.getMessage()));
return Response.error(ResponseCode.INVALID_REQUEST);
}
/**
* 权限不足
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(NotRoleException.class)
public Response<Object> handler(NotRoleException e) {
return Response.error(ResponseCode.PERMISSION_DENIED);
}
/**
* 没登陆
*
* @param e 异常
* @return 统一响应
*/
@ExceptionHandler(NotLoginException.class)
public Response<Object> handler(NotLoginException e) {
return Response.error(ResponseCode.NEED_LOGIN);
}
}

@ -0,0 +1,24 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.mq;
import lombok.extern.slf4j.Slf4j;
import net.lensfrex.dscape.configure.RabbitConfigure;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class MessageQueueProducer {
private final RabbitTemplate rabbit;
public MessageQueueProducer(RabbitTemplate rabbit) {
this.rabbit = rabbit;
}
public void sendObject(Object data) {
rabbit.convertAndSend(RabbitConfigure.EXCHANGE_NAME, RabbitConfigure.ROUTING_KEY, data);
}
}

@ -0,0 +1,23 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.utils;
import javax.servlet.http.HttpServletRequest;
public class NetworkUtil {
public static String getRealIP(HttpServletRequest request) {
String forward = request.getHeader("X-Forwarded-For");
if (forward != null) {
return forward.split(",")[0];
} else {
return request.getRemoteAddr();
}
}
}

@ -0,0 +1,50 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.compute;
import cn.dev33.satoken.annotation.SaCheckLogin;
import net.lensfrex.dscape.dto.request.compute.ComputeRequestBody;
import net.lensfrex.dscape.dto.response.data.compute.ComputeResponseData;
import net.lensfrex.dscape.dto.response.general.Response;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.web.service.compute.ComputeService;
import org.springframework.web.bind.annotation.*;
@SaCheckLogin
@RestController
@RequestMapping("/compute")
public class ComputeController {
private final ComputeService computeService;
public ComputeController(ComputeService computeService) {
this.computeService = computeService;
}
@GetMapping(value = "/status/{tid}", produces = "application/json")
public Response status(@PathVariable String tid,
@RequestHeader String token) {
return Response.error(ResponseCode.API_NOT_IMPLEMENT);
}
@PostMapping(value = "/add", produces = "application/json")
public Response<ComputeResponseData> addComputeTask(@RequestBody ComputeRequestBody request) {
long rid = computeService.addTask(request);
return Response.success(new ComputeResponseData(rid));
}
}

@ -0,0 +1,87 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.history;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import net.lensfrex.dscape.dao.entity.PatientData;
import net.lensfrex.dscape.dto.response.data.compute.ComputeHistoryResponseData;
import net.lensfrex.dscape.dto.response.general.Response;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.exception.GlobalException;
import net.lensfrex.dscape.web.service.data.HistoryService;
import org.springframework.web.bind.annotation.*;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
@SaCheckLogin
@RestController
@RequestMapping("/history")
public class HistoryController {
private final HistoryService historyService;
public HistoryController(HistoryService historyService) {
this.historyService = historyService;
}
@GetMapping(value = "/list", produces = "application/json")
public Response<List<ComputeHistoryResponseData>> list(@RequestParam(required = false, defaultValue = "1") int page,
@RequestParam(required = false, defaultValue = "10") int limit) {
String uid = StpUtil.getLoginIdAsString();
List<PatientData> results = historyService.getUserHistoryData(uid, page, limit);
List<ComputeHistoryResponseData> responseDataList = new ArrayList<>(results.size());
results.forEach(result -> {
ComputeHistoryResponseData response = new ComputeHistoryResponseData();
response.setId(result.getId());
response.setPid(result.getPid());
response.setCpg(result.getCpg());
response.setHcc(result.getIsHcc() == 1);
response.setHccInfer(result.getIsInferHcc() == 1);
response.setCtdna(result.getCtdnaLength());
response.setTime(result.getCreateTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
responseDataList.add(response);
});
return Response.success(responseDataList);
}
@RequestMapping(value = "/delete/{rid}", method = {RequestMethod.DELETE, RequestMethod.GET}, produces = "application/json")
public Response<Object> delete(@PathVariable long rid) {
String historyUser = historyService.getHistoryUser(rid);
if (!StpUtil.getLoginIdAsString().equals(historyUser)) {
throw new GlobalException(ResponseCode.PERMISSION_DENIED);
}
historyService.deleteHistoryData(rid);
return Response.success();
}
@RequestMapping(value = "/count", method = {RequestMethod.DELETE, RequestMethod.GET}, produces = "application/json")
public Response<Long> count() {
long result = historyService.getTotalCount(StpUtil.getLoginIdAsString());
return Response.success(result);
}
}

@ -0,0 +1,87 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.user;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import net.lensfrex.dscape.dto.request.UserLoginRequestBody;
import net.lensfrex.dscape.dto.response.general.Response;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.exception.GlobalException;
import net.lensfrex.dscape.web.service.user.UserService;
import net.lensfrex.dscape.dto.request.user.PasswordModifyRequestBody;
import net.lensfrex.dscape.dto.request.user.RegisterRequestBody;
import net.lensfrex.dscape.dto.response.data.user.RegisterResponseBody;
import net.lensfrex.dscape.utils.NetworkUtil;
import net.lensfrex.dscape.utils.validate.TextCheckUtil;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@JsonSerialize(using = ToStringSerializer.class)
@RestController
@RequestMapping("/user")
public class UserController {
private final UserService userService;
public UserController(UserService userService) {
this.userService = userService;
}
@PostMapping(value = "/login", produces = "application/json")
public Response<SaTokenInfo> login(@RequestBody UserLoginRequestBody requestBody) {
if (requestBody == null
|| requestBody.getUserName() == null
|| requestBody.getPassword() == null) {
throw new GlobalException(ResponseCode.PARAM_WRONG);
}
return Response.success(userService.login(requestBody));
}
@GetMapping(value = "/checkLogin", produces = "application/json")
public Response<SaTokenInfo> testLogin() {
return Response.success(userService.checkLogin());
}
@PostMapping(value = "/register", produces = "application/json")
public Response<RegisterResponseBody> register(@RequestBody RegisterRequestBody request, HttpServletRequest httpServletRequest) {
if (request.getUserName() == null || request.getPassword() == null) {
throw new GlobalException(ResponseCode.PARAM_WRONG);
}
// 这里的密码也用checkNoneAbcAndChinese是因为正常从前端发来的话是sha256,实际上是可以任意符号的
if (TextCheckUtil.checkNoneAbcAndChinese(request.getUserName(), request.getPassword())) {
throw new GlobalException(ResponseCode.INVALID_REQUEST);
}
return Response.success(userService.register(request, NetworkUtil.getRealIP(httpServletRequest)));
}
@PostMapping(value = "/modifyPassword/{uid}", produces = "application/json")
public Response<Object> modifyPassword(@RequestBody PasswordModifyRequestBody body, @PathVariable String uid) {
StpUtil.checkLogin();
userService.modifyPassword(uid, body.getOldPassword(), body.getNewPassword());
return Response.success();
}
}

@ -0,0 +1,93 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.user.admin;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import net.lensfrex.dscape.dto.response.general.Response;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.enums.user.UserRoleEnum;
import net.lensfrex.dscape.exception.GlobalException;
import lombok.extern.slf4j.Slf4j;
import net.lensfrex.dscape.dto.request.user.UserAddRequest;
import net.lensfrex.dscape.dto.response.data.user.RegisterResponseBody;
import net.lensfrex.dscape.utils.NetworkUtil;
import net.lensfrex.dscape.web.service.user.AdminService;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Slf4j
@SaCheckLogin
@RestController
@RequestMapping("/user/admin")
public class AdminController {
private final AdminService adminService;
public AdminController(AdminService adminService) {
this.adminService = adminService;
}
@PostMapping(value = "/add", produces = "application/json")
public Response<RegisterResponseBody> addUser(@RequestBody UserAddRequest request, HttpServletRequest httpServletRequest) {
StpUtil.checkRole(String.valueOf(UserRoleEnum.ADMIN.getCode()));
return Response.success(adminService.adminAddUser(request, NetworkUtil.getRealIP(httpServletRequest)));
}
@PostMapping(value = "/modifyStatus", produces = "application/json")
public Response<Object> modifyStatus(@RequestParam String uid, @RequestParam int status) {
StpUtil.checkRole(String.valueOf(UserRoleEnum.ADMIN.getCode()));
if (StpUtil.getLoginIdAsString().equals(uid)) {
throw new GlobalException(ResponseCode.PERMISSION_DENIED);
}
switch (status) {
case 0:
case 1:
adminService.modifyUserStatus(uid, status);
break;
case 2:
adminService.deleteUser(uid);
break;
case 3:
adminService.addUserToBlackList(uid);
break;
default:
throw new GlobalException(ResponseCode.PARAM_WRONG);
}
return Response.success();
}
@GetMapping(value = "/inviteCode", produces = "application/json")
public Response<List<String>> generateInviteCodes(@RequestParam(required = false, defaultValue = "-1") long expired,
@RequestParam(required = false, defaultValue = "1") int count) {
StpUtil.checkRole(String.valueOf(UserRoleEnum.ADMIN.getCode()));
if (count > 1024) {
throw new GlobalException(ResponseCode.INVALID_REQUEST);
}
List<String> result = adminService.generateInviteCode(expired, count);
return Response.success(result);
}
}

@ -0,0 +1,64 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.service.compute;
import cn.dev33.satoken.stp.StpUtil;
import com.github.yitter.idgen.YitIdHelper;
import net.lensfrex.dscape.configure.RabbitConfigure;
import net.lensfrex.dscape.dao.entity.ComputeHistory;
import net.lensfrex.dscape.dao.entity.PatientData;
import net.lensfrex.dscape.dao.service.ComputeHistoryService;
import net.lensfrex.dscape.dao.service.PatientDataService;
import net.lensfrex.dscape.dto.request.compute.ComputeRequestBody;
import net.lensfrex.dscape.enums.compute.ComputeStatusEnum;
import net.lensfrex.dscape.mq.MessageQueueProducer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class ComputeService {
private final PatientDataService patientDataService;
private final ComputeHistoryService computeHistoryService;
private final MessageQueueProducer messageQueueProducer;
public ComputeService(PatientDataService patientDataService,
ComputeHistoryService computeHistoryService,
MessageQueueProducer messageQueueProducer) {
this.patientDataService = patientDataService;
this.computeHistoryService = computeHistoryService;
this.messageQueueProducer = messageQueueProducer;
}
@Transactional
public long addTask(ComputeRequestBody request) {
long rid = YitIdHelper.nextId();
String uid = StpUtil.getLoginIdAsString();
ComputeHistory computeHistory = new ComputeHistory();
computeHistory.setUid(uid);
computeHistory.setRid(rid);
computeHistory.setStatus(ComputeStatusEnum.PROCESSING.getCode());
PatientData patientData = new PatientData();
patientData.setId(rid);
patientData.setCpg(request.getCpg());
patientData.setPid(request.getPid());
patientData.setCtdnaLength(request.getCtdna());
computeHistoryService.save(computeHistory);
patientDataService.save(patientData);
this.addMessageQueue(patientData);
return rid;
}
private void addMessageQueue(PatientData patientData) {
messageQueueProducer.sendObject(patientData);
}
}

@ -0,0 +1,62 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.service.data;
import net.lensfrex.dscape.dao.entity.ComputeHistory;
import net.lensfrex.dscape.dao.entity.PatientData;
import net.lensfrex.dscape.dao.service.PatientDataService;
import lombok.extern.slf4j.Slf4j;
import net.lensfrex.dscape.dao.service.ComputeHistoryService;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class HistoryService {
private final ComputeHistoryService computeHistoryService;
private final PatientDataService patientDataService;
public HistoryService(ComputeHistoryService computeHistoryService,
PatientDataService patientDataService) {
this.computeHistoryService = computeHistoryService;
this.patientDataService = patientDataService;
}
public long getTotalCount(String uid) {
return computeHistoryService.count(ComputeHistory::getUid, uid);
}
public List<Long> getUserHistoryId(String uid, int page, int limit) {
return computeHistoryService.getHistoryDataIds(uid, page, limit);
}
public List<PatientData> getUserHistoryData(String uid, int page, int limit) {
return patientDataService.getData(getUserHistoryId(uid, page, limit));
}
public String getHistoryUser(Long rid) {
return computeHistoryService.getHistoryUser(rid);
}
public void deleteHistoryData(Long rid) {
computeHistoryService.remove(rid);
}
}

@ -0,0 +1,118 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.service.user;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import net.lensfrex.dscape.web.service.user.admin.InviteCode;
import net.lensfrex.dscape.cache.UserBasicCache;
import net.lensfrex.dscape.dao.entity.BlackList;
import net.lensfrex.dscape.dao.entity.UserBasic;
import net.lensfrex.dscape.dao.service.BlackListService;
import net.lensfrex.dscape.dao.service.UserBasicService;
import net.lensfrex.dscape.dto.request.user.UserAddRequest;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.enums.blacklist.BlackListTypeEnum;
import net.lensfrex.dscape.enums.user.UserRoleEnum;
import net.lensfrex.dscape.exception.GlobalException;
import net.lensfrex.dscape.dto.response.data.user.RegisterResponseBody;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class AdminService {
private final RedisTemplate<String, String> redis;
private final UserBasicService userBasicService;
private final UserService userService;
private final BlackListService blackListService;
private final InviteCode inviteCode;
private final UserBasicCache userBasicCache;
public AdminService(RedisTemplate<String, String> redis,
UserBasicService userBasicService,
UserService userService,
BlackListService blackListService,
InviteCode inviteCode,
UserBasicCache userBasicCache) {
this.redis = redis;
this.userBasicService = userBasicService;
this.userService = userService;
this.blackListService = blackListService;
this.inviteCode = inviteCode;
this.userBasicCache = userBasicCache;
}
public List<String> generateInviteCode(long expired, int count) {
return inviteCode.generateInviteCode(expired, count, StpUtil.getLoginIdAsString());
}
public void modifyUserStatus(String uid, int status) {
UpdateWrapper<UserBasic> wrapper = new UpdateWrapper<>();
wrapper.lambda()
.eq(UserBasic::getUid, uid)
.eq(UserBasic::getSuperior, StpUtil.getLoginIdAsString())
.set(UserBasic::getStatus, status);
this.clearUserBasicCache(uid);
userBasicService.update(wrapper);
}
public void addUserToBlackList(String uid) {
BlackList blackList = new BlackList();
blackList.setData(uid);
blackList.setType(BlackListTypeEnum.UID.getCode());
blackListService.save(blackList);
}
public void deleteUser(String uid) {
this.clearUserBasicCache(uid);
userBasicService.removeById(uid);
}
private void clearUserBasicCache(String uid) {
userBasicCache.clear(uid);
}
public RegisterResponseBody adminAddUser(UserAddRequest requestBody, String registerIp) {
if (userService.userNameExists(requestBody.getUserName())) {
throw new GlobalException(ResponseCode.USER_NAME_EXISTS);
}
String uid = userService.addUserToDatabase(requestBody.getUserName(), requestBody.getPassword(),
StpUtil.getLoginIdAsString(), UserRoleEnum.getTypeEnumByCode(requestBody.getRole()), registerIp);
RegisterResponseBody registerResponseBody = new RegisterResponseBody();
registerResponseBody.setUid(uid);
return registerResponseBody;
}
}

@ -0,0 +1,211 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.service.user;
import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import net.lensfrex.dscape.dao.entity.UserBasic;
import net.lensfrex.dscape.dao.service.UserBasicService;
import net.lensfrex.dscape.dto.request.UserLoginRequestBody;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.enums.user.UserRoleEnum;
import net.lensfrex.dscape.enums.user.UserStatusEnum;
import net.lensfrex.dscape.exception.GlobalException;
import lombok.extern.slf4j.Slf4j;
import net.lensfrex.dscape.web.service.user.admin.InviteCode;
import net.lensfrex.dscape.cache.UserBasicCache;
import net.lensfrex.dscape.dao.entity.UserRole;
import net.lensfrex.dscape.dao.service.UserRoleService;
import net.lensfrex.dscape.dto.request.user.RegisterRequestBody;
import net.lensfrex.dscape.dto.response.data.user.RegisterResponseBody;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.UUID;
@Slf4j
@Service
public class UserService {
private final UserBasicCache userBasicCache;
private final UserBasicService userBasicService;
private final UserRoleService userRoleService;
private final InviteCode inviteCode;
@Autowired
public UserService(UserBasicCache userBasicCache,
UserBasicService userBasicService,
UserRoleService userRoleService,
InviteCode inviteCode) {
this.userBasicCache = userBasicCache;
this.userBasicService = userBasicService;
this.userRoleService = userRoleService;
this.inviteCode = inviteCode;
}
public SaTokenInfo checkLogin() {
return StpUtil.getTokenInfo();
}
public SaTokenInfo login(UserLoginRequestBody requestBody) {
String username = requestBody.getUserName();
String password = requestBody.getPassword();
// 找缓存
UserBasic userBasic = userBasicCache.getUserByUserName(username);
if (userBasic == null) {
userBasic = this.getUserAndCache(username);
}
// 验证密码
if (userBasic != null && BCrypt.checkpw(password, userBasic.getPassword())) {
// 检查用户状态
if (userBasic.getStatus() == UserStatusEnum.BANNED.getCode()) {
throw new GlobalException(ResponseCode.USER_WAS_BANNED);
} else if (userBasic.getStatus() == UserStatusEnum.NOT_IDENTIFIED.getCode()) {
throw new GlobalException(ResponseCode.USER_WAS_NOT_IDENTIFIED);
}
StpUtil.login(userBasic.getUid());
} else {
throw new GlobalException(ResponseCode.USERNAME_OR_PASSWORD_WRONG);
}
return StpUtil.getTokenInfo();
}
private UserBasic getUserAndCache(String username) {
UserBasic userBasic = userBasicService.getUser(UserBasic::getUserName, username);
this.cacheUser(userBasic);
return userBasic;
}
private UserBasic getUserAndCacheByUid(String uid) {
UserBasic userBasic = userBasicService.getUser(UserBasic::getUid, uid);
this.cacheUser(userBasic);
return userBasic;
}
private boolean cacheUser(UserBasic userBasic) {
try {
if (userBasic != null) {
userBasicCache.save(userBasic);
}
} catch (Exception e) {
log.info("将用户数据存入redis缓存时发生错误");
log.debug("追踪:", e);
return false;
}
return true;
}
@Transactional
public RegisterResponseBody register(RegisterRequestBody requestBody, String registerIp) {
if (userNameExists(requestBody.getUserName())) {
throw new GlobalException(ResponseCode.USER_NAME_EXISTS);
}
RegisterResponseBody registerResponseBody = new RegisterResponseBody();
// 注册码验证
String inviteCode = requestBody.getInviteCode();
if (inviteCode == null) {
// 验证是否注册为初始管理员
if (userBasicService.count() != 0) {
throw new GlobalException(ResponseCode.PERMISSION_DENIED);
}
String uid = addUserToDatabase(requestBody.getUserName(), requestBody.getPassword(), "null", UserRoleEnum.ADMIN, registerIp);
registerResponseBody.setUid(uid);
} else {
String superior = this.inviteCode.useInviteCode(inviteCode);
String uid = addUserToDatabase(requestBody.getUserName(), requestBody.getPassword(), superior, UserRoleEnum.NORMAL_USER, registerIp);
registerResponseBody.setUid(uid);
}
return registerResponseBody;
}
/**
* 添加一个用户到数据库
*
* @param userName 用户名
* @param password 密码未用bcrypt加密的
* @param superior 上级管理员本身是管理员时可为空
* @param userRoleEnum 用户角色
* @return 用户uid
*/
protected String addUserToDatabase(String userName, String password, String superior, UserRoleEnum userRoleEnum, String userIp) {
UserBasic userBasic = new UserBasic();
String uid = UUID.randomUUID().toString();
userBasic.setUid(uid);
userBasic.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
userBasic.setUserName(userName);
userBasic.setStatus(UserStatusEnum.NORMAL.getCode());
userBasic.setSuperior(superior);
userBasic.setCreateIp(userIp);
userBasicService.save(userBasic);
UserRole userRole = new UserRole();
userRole.setRole(userRoleEnum.getCode());
userRole.setUid(uid);
userRoleService.save(userRole);
return uid;
}
protected boolean userNameExists(String username) {
return userBasicService.userNameExists(username);
}
public void modifyPassword(String uid, String oldPassword, String newPassword) {
String loginUser = StpUtil.getLoginIdAsString();
UserBasic userBasic = this.getUserAndCacheByUid(uid);
if (userBasic == null) {
return;
}
if (!loginUser.equals(uid)) {
if (!loginUser.equals(userBasic.getSuperior())) {
throw new GlobalException(ResponseCode.PERMISSION_DENIED);
}
}
if (BCrypt.checkpw(userBasic.getPassword(), oldPassword)) {
throw new GlobalException(ResponseCode.PERMISSION_DENIED);
}
String newHashedPassword = BCrypt.hashpw(newPassword, BCrypt.gensalt());
userBasicService.modify(UserBasic::getUid, uid,
UserBasic::getPassword, newHashedPassword);
userBasicCache.clear(uid);
}
}

@ -0,0 +1,92 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.service.user.admin;
import net.lensfrex.dscape.configure.GlobalConstant;
import net.lensfrex.dscape.dto.response.general.ResponseCode;
import net.lensfrex.dscape.exception.GlobalException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Slf4j
@Service
public class InviteCode {
private static final int INVITE_CODE_LENGTH = 6;
private static final String REGISTER_INVITE_CODE_KEY = GlobalConstant.REGISTER_INVITE_CODE_KEY;
private static final String ADMIN_INVITE_CODE_COUNTER_KEY = GlobalConstant.ADMIN_INVITE_CODE_COUNTER_KEY;
private final RedisTemplate<String, String> redis;
public InviteCode(RedisTemplate<String, String> redis) {
this.redis = redis;
}
public List<String> generateInviteCode(long expired, int count, String adminUid) {
String adminInviteCodeCounterKey = String.format(ADMIN_INVITE_CODE_COUNTER_KEY, adminUid);
String countResult = redis.opsForValue().get(adminInviteCodeCounterKey);
if (countResult != null && Integer.parseInt(countResult) > 1024) {
throw new GlobalException(ResponseCode.INVITE_CODE_REACHED_LIMIT);
}
List<String> inviteCodes = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
inviteCodes.add(RandomStringUtils.randomAlphanumeric(INVITE_CODE_LENGTH));
}
HashMap<String, String> codeAdmin = new HashMap<>(count);
inviteCodes.forEach(inviteCode -> codeAdmin.put(inviteCode, adminUid));
redis.opsForHash().putAll(REGISTER_INVITE_CODE_KEY, codeAdmin);
redis.opsForValue().increment(adminInviteCodeCounterKey, count);
return inviteCodes;
}
public boolean checkInviteCode(String code) {
try {
return redis.opsForHash().get(REGISTER_INVITE_CODE_KEY, code) == null;
} catch (Exception e) {
return false;
}
}
public String useInviteCode(String code) {
try {
String superior = (String) redis.opsForHash().get(REGISTER_INVITE_CODE_KEY, code);
if (superior == null) {
throw new GlobalException(ResponseCode.INVITE_CODE_WRONG);
}
redis.opsForHash().delete(REGISTER_INVITE_CODE_KEY, code);
redis.opsForValue().decrement(String.format(ADMIN_INVITE_CODE_COUNTER_KEY, superior));
return superior;
} catch (Exception e) {
throw new GlobalException(ResponseCode.INVITE_CODE_WRONG);
}
}
}

@ -0,0 +1,73 @@
spring:
profiles:
active: dev
---
server:
address: 127.0.0.1
port: 6480
http2:
enabled: false
ssl:
enabled: false
trust-certificate:
trust-certificate-private-key:
logging:
level:
net.lensfrex.dscape: debug
spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mariadb://localhost:3306/dscape?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: "dscape_user"
password: asdfasdf
rabbitmq:
host: 127.0.0.1
port: 5672
username: dscape-test
password: asdfasdf
redis:
client-name: dscape
host: 127.0.0.1
port: 49153
username: default
password: bd2fbffa5
timeout: 2000ms
lettuce:
pool:
max-active: 8
max-wait: -1
max-idle: 8
min-idle: 0
config:
activate:
on-profile: dev
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler
global-config:
db-config:
logic-delete-field: id_deleted
logic-not-delete-value: 0
logic-delete-value: 1
sa-token:
token-name: dscape-token
timeout: 259200
activity-timeout: -1
is-concurrent: true
is-share: false
token-style: random-64
is-log: true
# 性能检测用的,记得在生产环境中不要enable
ko-time:
enable: true
pointcut: execution(public * net.lensfrex.dscape..*.*(..))
threshold: 250.0
exception-enable: true
auth-enable: false
log-enable: true

@ -1,16 +1,11 @@
/*
MariaDB Backup
Database: dscape
Backup Time: 2022-07-10 22:20:06
*/
/*
MariaDB Backup
Database: dscape
Backup Time: 2022-07-10 22:20:06
*/
SET FOREIGN_KEY_CHECKS=0;
DROP TABLE IF EXISTS `dscape`.`black_list`;
DROP TABLE IF EXISTS `dscape`.`compute_history`;
DROP TABLE IF EXISTS `dscape`.`patient_data`;
DROP TABLE IF EXISTS `dscape`.`role_permission`;
DROP TABLE IF EXISTS `dscape`.`user_basic`;
CREATE TABLE `black_list` (
CREATE TABLE dscape.`black_list` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL COMMENT '黑名单数据类型;\r\n0:ip;\r\n1:uid',
`name` varchar(255) NOT NULL COMMENT '黑名单条目名称,可空',
@ -22,7 +17,7 @@ CREATE TABLE `black_list` (
UNIQUE KEY `index_id` (`id`) USING BTREE,
KEY `index_data` (`data`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `compute_history` (
CREATE TABLE dscape.`compute_history` (
`id` int(11) NOT NULL,
`uid` char(36) NOT NULL COMMENT '计算数据记录对应的用户uid',
`rid` int(11) NOT NULL COMMENT '计算数据记录对应的患者数据id',
@ -31,7 +26,7 @@ CREATE TABLE `compute_history` (
KEY `index_uid` (`uid`) USING BTREE,
KEY `index_pid` (`rid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `patient_data` (
CREATE TABLE dscape.`patient_data` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '数据id',
`pid` int(15) NOT NULL COMMENT '病人id',
`ctDNA_length` int(4) NOT NULL COMMENT 'ctDNA长度',
@ -45,7 +40,7 @@ CREATE TABLE `patient_data` (
UNIQUE KEY `id` (`id`) USING BTREE,
KEY `pid` (`pid`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `role_permission` (
CREATE TABLE dscape.`role_permission` (
`id` int(4) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL COMMENT '权限名称',
`permit` varchar(255) NOT NULL COMMENT '许可的用户角色,角色之间用";"(分号)隔开',
@ -56,7 +51,7 @@ CREATE TABLE `role_permission` (
UNIQUE KEY `index_id` (`id`) USING BTREE,
UNIQUE KEY `index_name` (`name`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `user_basic` (
CREATE TABLE dscape.`user_basic` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`uid` char(36) NOT NULL COMMENT '用户唯一uuid',
`user_name` varchar(32) NOT NULL COMMENT '用户用户名',
@ -70,28 +65,3 @@ CREATE TABLE `user_basic` (
UNIQUE KEY `uid` (`uid`) USING BTREE,
UNIQUE KEY `user_name` (`user_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
BEGIN;
LOCK TABLES `dscape`.`black_list` WRITE;
DELETE FROM `dscape`.`black_list`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `dscape`.`compute_history` WRITE;
DELETE FROM `dscape`.`compute_history`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `dscape`.`patient_data` WRITE;
DELETE FROM `dscape`.`patient_data`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `dscape`.`role_permission` WRITE;
DELETE FROM `dscape`.`role_permission`;
UNLOCK TABLES;
COMMIT;
BEGIN;
LOCK TABLES `dscape`.`user_basic` WRITE;
DELETE FROM `dscape`.`user_basic`;
UNLOCK TABLES;
COMMIT;

@ -2,6 +2,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>dscape-compute</module>
<module>dscape-web</module>
<module>dscape-dao</module>
<module>dscape-cache</module>
<module>dscape-entities</module>
<module>dscape-utils</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
@ -12,108 +21,32 @@
<artifactId>dscape-server</artifactId>
<version>0.0.1-dev</version>
<name>dscape-server</name>
<description>dscape-server</description>
<description>dscape后端</description>
<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.0</version>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- 性能分析用的 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<groupId>cn.langpy</groupId>
<artifactId>ko-time</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-gson</artifactId>
<version>0.11.5</version>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
<artifactId>spring-boot-starter-aop</artifactId>
<version>2.7.3</version>
</dependency>
</dependencies>
@ -123,8 +56,10 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>net.lensfrex.dscape.ServerMain</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -1,15 +0,0 @@
package net.lensfrex.dscape;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
@MapperScan("net.lensfrex.dscape.dao.mappers")
public class ServerMain extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(ServerMain.class, args);
}
}

@ -1,12 +0,0 @@
/*
* Class created by lensfrex.
*/
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao;
public class PatientDataDao {
}

@ -1,5 +0,0 @@
package net.lensfrex.dscape.dao;
public class UserBasicDao {
}

@ -1,12 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.dao.mappers;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.domain.PatientData;
public interface PatientDataMapper extends BaseMapper<PatientData> {
}

@ -1,10 +0,0 @@
package net.lensfrex.dscape.dao.mappers;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.lensfrex.dscape.domain.user.UserBasic;
import org.springframework.stereotype.Repository;
@Repository
public interface UserBasicMapper extends BaseMapper<UserBasic> {
}

@ -1,142 +0,0 @@
package net.lensfrex.dscape.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("patient_data")
public class PatientData {
/**
* 患者数据id
*/
private int id;
/**
* 病人id
*/
private int pid;
/**
* ctDNA长度
*/
private int ctDNALength;
/**
* 甲基化位点数
*/
private int cpg;
/**
* 是否为hcc
*/
private boolean hccStatus;
/**
* 通过推断得出的hcc状态
*/
private boolean hccInferStatus;
/**
* create_time
*/
private Date createTime;
/**
* edit_time
*/
private Date editTime;
/**
* delete
*/
private boolean delete;
public PatientData() {}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public int getCtDNALength() {
return ctDNALength;
}
public void setCtDNALength(int ctDNALength) {
this.ctDNALength = ctDNALength;
}
public boolean isHccStatus() {
return hccStatus;
}
public void setHccStatus(boolean hccStatus) {
this.hccStatus = hccStatus;
}
public boolean isHccInferStatus() {
return hccInferStatus;
}
public void setHccInferStatus(boolean hccInferStatus) {
this.hccInferStatus = hccInferStatus;
}
public boolean isDelete() {
return delete;
}
public void setDelete(boolean delete) {
this.delete = delete;
}
public int getCpg() {
return cpg;
}
public void setCpg(int cpg) {
this.cpg = cpg;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getEditTime() {
return editTime;
}
public void setEditTime(Date editTime) {
this.editTime = editTime;
}
@Override
public String toString() {
return "PatientData{" + "id=" + id +
", pid=" + pid +
", ctDNALength=" + ctDNALength +
", cpg=" + cpg +
", hccStatus=" + hccStatus +
", hccInferStatus=" + hccInferStatus +
", createTime=" + createTime +
", editTime=" + editTime +
", delete=" + delete +
'}';
}
}

@ -1,48 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response;
//@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response<T> {
private final int code;
private final String message;
private final T data;
public Response(int code, String message, T data) {
this.code = code;
this.message = message;
this.data = data;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
public T getData() {
return data;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("Response{");
sb.append("code=").append(code);
sb.append(", message='").append(message).append('\'');
sb.append(", data=").append(data);
sb.append('}');
return sb.toString();
}
public static<T> Response<T> success(T data) {
return new Response<>(20000, "success", data);
}
public static Response<Object> error(int code, String message) {
return new Response<>(code, message, null);
}
}

@ -1,36 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response.data.admin;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class CreateUserResponse {
@Expose
private long role;
@Expose
private String uid;
public long getRole() {
return role;
}
public void setRole(long role) {
this.role = role;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
}

@ -1,62 +0,0 @@
package net.lensfrex.dscape.domain.response.data.admin;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class UserRegisterApplicationResponseData {
@Expose
private long id;
@Expose
private String ip;
@Expose
private String name;
@Expose
private String time;
@Expose
private String uid;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
}

@ -1,87 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response.data.compute;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class ComputeHistoryReponseData {
@Expose
private long cpg;
@Expose
private long ctdna;
@Expose
private Boolean hcc;
@SerializedName("hcc_infer")
private Boolean hccInfer;
@Expose
private long id;
@Expose
private long pid;
@Expose
private String time;
public long getCpg() {
return cpg;
}
public void setCpg(long cpg) {
this.cpg = cpg;
}
public long getCtdna() {
return ctdna;
}
public void setCtdna(long ctdna) {
this.ctdna = ctdna;
}
public Boolean getHcc() {
return hcc;
}
public void setHcc(Boolean hcc) {
this.hcc = hcc;
}
public Boolean getHccInfer() {
return hccInfer;
}
public void setHccInfer(Boolean hccInfer) {
this.hccInfer = hccInfer;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getPid() {
return pid;
}
public void setPid(long pid) {
this.pid = pid;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
}

@ -1,36 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response.data.compute;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class ComputeStatusQueryResponse {
@Expose
private String id;
@Expose
private int status;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

@ -1,26 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response.data.compute;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class ComputeTaskResponseData {
@Expose
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

@ -1,66 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response.data.user;
import javax.annotation.Generated;
import com.google.gson.annotations.SerializedName;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class LoginResponseData {
@SerializedName("access_token")
private String mAccessToken;
@SerializedName("expired")
private long mExpired;
@SerializedName("refresh_token")
private String mRefreshToken;
@SerializedName("role")
private long mRole;
@SerializedName("uid")
private String mUid;
public String getAccessToken() {
return mAccessToken;
}
public void setAccessToken(String accessToken) {
mAccessToken = accessToken;
}
public long getExpired() {
return mExpired;
}
public void setExpired(long expired) {
mExpired = expired;
}
public String getRefreshToken() {
return mRefreshToken;
}
public void setRefreshToken(String refreshToken) {
mRefreshToken = refreshToken;
}
public long getRole() {
return mRole;
}
public void setRole(long role) {
mRole = role;
}
public String getUid() {
return mUid;
}
public void setUid(String uid) {
mUid = uid;
}
}

@ -1,26 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.domain.response.data.user;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class RegisterResponseData {
@Expose
private String uid;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
}

@ -1,62 +0,0 @@
package net.lensfrex.dscape.domain.user;
public class UserBasic {
private String uid;
private String userName;
private String password;
private UserStatus status;
private UserRole role;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public UserRole getRole() {
return role;
}
public void setRole(UserRole role) {
this.role = role;
}
public UserStatus getStatus() {
return status;
}
public void setStatus(UserStatus status) {
this.status = status;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("UserBasic{");
sb.append("uid='").append(uid).append('\'');
sb.append(", userName='").append(userName).append('\'');
sb.append(", password='").append(password).append('\'');
sb.append(", status=").append(status);
sb.append(", role=").append(role);
sb.append('}');
return sb.toString();
}
}

@ -1,17 +0,0 @@
package net.lensfrex.dscape.domain.user;
import com.baomidou.mybatisplus.annotation.EnumValue;
public enum UserRole {
ADMIN(1, "admin"), NORMAL_USER(0, "normal");
@EnumValue
private final int role;
private final String desc;
UserRole(int role, String desc) {
this.role = role;
this.desc = desc;
}
}

@ -1,15 +0,0 @@
package net.lensfrex.dscape.domain.user;
import com.baomidou.mybatisplus.annotation.EnumValue;
public enum UserStatus {
NORMAL(0), BANNED(1), DELETED(2);
@EnumValue
private final int status;
UserStatus(int status) {
this.status = status;
}
}

@ -1,19 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers;
import net.lensfrex.dscape.domain.response.Response;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
public class Error extends AbstractMethodError {
@ExceptionHandler({ RuntimeException.class })
public Response error() {
return Response.error(50000, "服务器内部错误....");
}
}

@ -1,18 +0,0 @@
package net.lensfrex.dscape.web.controllers;
import net.lensfrex.dscape.dao.mappers.UserBasicMapper;
import net.lensfrex.dscape.domain.user.UserBasic;
import net.lensfrex.dscape.domain.user.UserRole;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
public class Index {
@RequestMapping("/")
public String index() {
return "Wow~~~~~~~~~~~~~~~~~~~~~~";
}
}

@ -1,24 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.compute;
import net.lensfrex.dscape.domain.response.Response;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/compute")
public class Compute {
@GetMapping(value = "/status/{tid}", produces = "application/json")
public Response status(@PathVariable String tid,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
@PostMapping(value = "/add", produces = "application/json")
public Response addComputeTask(@RequestBody String body,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
}

@ -1,26 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.history;
import net.lensfrex.dscape.domain.response.Response;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/history")
public class History {
@GetMapping(value = "/list/{uid}", produces = "application/json")
public Response list(@PathVariable String uid,
@RequestParam int offset, @RequestParam int limit, @RequestParam int page,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
@RequestMapping(value = "/delete/{rid}", method = {RequestMethod.DELETE, RequestMethod.GET}, produces = "application/json")
public Response delete(@PathVariable int rid,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
}

@ -1,34 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.user;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import net.lensfrex.dscape.domain.response.Response;
import net.lensfrex.dscape.domain.response.data.user.LoginResponseData;
import net.lensfrex.dscape.domain.response.data.user.RegisterResponseData;
import org.springframework.web.bind.annotation.*;
@JsonSerialize(using = ToStringSerializer.class)
@RestController
@RequestMapping("/user")
public class User {
@PostMapping(value = "/login" , produces = "application/json")
public Response login(@RequestBody String body) {
return Response.error(0, "Not implement");
}
@PostMapping(value = "/register", produces = "application/json")
public Response register(@RequestBody String body) {
return Response.error(0, "Not implement");
}
@PostMapping(value = "/modifyPassword/{uid}", produces = "application/json")
public Response modifyPassword(@RequestBody String body, @PathVariable String uid,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
}

@ -1,37 +0,0 @@
/*
* Class created by lensfrex.
*/
package net.lensfrex.dscape.web.controllers.user.admin;
import net.lensfrex.dscape.domain.response.Response;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/user/admin")
public class Admin {
@PostMapping(value = "/add", produces = "application/json")
public Response addUser(@RequestBody String body,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
@PostMapping(value = "/modifyStatus/{uid}", produces = "application/json")
public Response modifyStatus(@RequestBody String body, @PathVariable String uid,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
@GetMapping(value = "/application/list", produces = "application/json")
public Response listApplication(
@RequestParam String offset, @RequestParam String limit, @RequestParam String page,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
@PostMapping(value = "/application/deal/{uid}", produces = "application/json")
public Response dealApplication(@RequestBody String body, @PathVariable String uid,
@RequestHeader String token) {
return Response.error(0, "Not implement");
}
}

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

Loading…
Cancel
Save