Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43139784b2 | |||
| 18224b9a97 |
+5
@@ -1,6 +1,11 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<Languages>
|
||||||
|
<language minSize="49" name="Kotlin" />
|
||||||
|
</Languages>
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
<inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
<option name="ignoredNames">
|
<option name="ignoredNames">
|
||||||
<list>
|
<list>
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
|
|
||||||
#### 认证方式
|
#### 认证方式
|
||||||
|
|
||||||
所有 API 均使用 **JWT 认证**(除了需要特殊处理的端点):
|
所有 API 均使用 **JWT 认证**(除了需要特殊处理的端点)
|
||||||
|
|
||||||
```
|
```
|
||||||
Authorization: Bearer <token>
|
Authorization: Bearer <token>
|
||||||
@@ -152,7 +152,7 @@ Authorization: Bearer <token>
|
|||||||
|
|
||||||
## 数据库结构
|
## 数据库结构
|
||||||
|
|
||||||
[schema.sql](./schema.sql)。
|
[schema.sql](./schema.sql)
|
||||||
|
|
||||||
- users (系统用户/认证信息)
|
- users (系统用户/认证信息)
|
||||||
- departments (组织/部门)
|
- departments (组织/部门)
|
||||||
|
|||||||
+4
-11
@@ -5,6 +5,7 @@ import club.itstudio.itmanager.entity.enums.EmailType
|
|||||||
import club.itstudio.itmanager.entity.vo.request.EmailRegisterVO
|
import club.itstudio.itmanager.entity.vo.request.EmailRegisterVO
|
||||||
import club.itstudio.itmanager.entity.vo.request.PasswordResetVO
|
import club.itstudio.itmanager.entity.vo.request.PasswordResetVO
|
||||||
import club.itstudio.itmanager.service.v1.AuthorizationService
|
import club.itstudio.itmanager.service.v1.AuthorizationService
|
||||||
|
import club.itstudio.itmanager.utils.Const
|
||||||
import jakarta.validation.Valid
|
import jakarta.validation.Valid
|
||||||
import jakarta.validation.constraints.Email
|
import jakarta.validation.constraints.Email
|
||||||
import jakarta.validation.constraints.NotBlank
|
import jakarta.validation.constraints.NotBlank
|
||||||
@@ -31,21 +32,21 @@ class AuthorizeController(
|
|||||||
logger.info("Trying to ask code")
|
logger.info("Trying to ask code")
|
||||||
val ip = exchange.request.remoteAddress?.address?.hostAddress ?: "unknown"
|
val ip = exchange.request.remoteAddress?.address?.hostAddress ?: "unknown"
|
||||||
return service.askEmailVerifyCode(type, email, ip)
|
return service.askEmailVerifyCode(type, email, ip)
|
||||||
.map(::messageHandler)
|
.map(Const::messageHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
fun emailRegister(@RequestBody @Valid vo: EmailRegisterVO): Mono<ApiResponse<Any?>> {
|
fun emailRegister(@RequestBody @Valid vo: EmailRegisterVO): Mono<ApiResponse<Any?>> {
|
||||||
logger.info("Trying to register")
|
logger.info("Trying to register")
|
||||||
return service.registerEmailAccount(vo)
|
return service.registerEmailAccount(vo)
|
||||||
.map(::messageHandler)
|
.map(Const::messageHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/reset")
|
@PostMapping("/reset")
|
||||||
fun emailResetPassword(@RequestBody @Valid vo: PasswordResetVO): Mono<ApiResponse<Any?>> {
|
fun emailResetPassword(@RequestBody @Valid vo: PasswordResetVO): Mono<ApiResponse<Any?>> {
|
||||||
logger.info("Trying to reset password")
|
logger.info("Trying to reset password")
|
||||||
return service.resetEmailAccountPassword(vo)
|
return service.resetEmailAccountPassword(vo)
|
||||||
.map(::messageHandler)
|
.map(Const::messageHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/logout")
|
@GetMapping("/logout")
|
||||||
@@ -68,12 +69,4 @@ class AuthorizeController(
|
|||||||
?.map { ApiResponse.success(it) }
|
?.map { ApiResponse.success(it) }
|
||||||
?: Mono.just(ApiResponse.failure(401, null, "Please login with password."))
|
?: Mono.just(ApiResponse.failure(401, null, "Please login with password."))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun messageHandler(wrongMessage: String): ApiResponse<Any?> {
|
|
||||||
return if (wrongMessage.isBlank()) {
|
|
||||||
ApiResponse.success()
|
|
||||||
} else {
|
|
||||||
ApiResponse.failure(400, null, wrongMessage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package club.itstudio.itmanager.service.v1
|
||||||
|
|
||||||
|
import club.itstudio.itmanager.entity.dto.Attachment
|
||||||
|
import club.itstudio.itmanager.entity.dto.Category
|
||||||
|
import club.itstudio.itmanager.entity.dto.Item
|
||||||
|
import club.itstudio.itmanager.entity.dto.ItemTransaction
|
||||||
|
import club.itstudio.itmanager.service.AttachmentService
|
||||||
|
import club.itstudio.itmanager.service.CategoryService
|
||||||
|
import club.itstudio.itmanager.service.ItemService
|
||||||
|
import club.itstudio.itmanager.service.ItemTransactionService
|
||||||
|
import club.itstudio.itmanager.utils.Const
|
||||||
|
import club.itstudio.itmanager.utils.DateUtils.getCurrentDateTime
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import org.springframework.beans.factory.annotation.Value
|
||||||
|
import org.springframework.http.codec.multipart.FilePart
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
import reactor.core.publisher.Mono
|
||||||
|
import reactor.core.scheduler.Schedulers
|
||||||
|
import java.io.IOException
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
@Service
|
||||||
|
class ItemsApiService
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package club.itstudio.itmanager.utils
|
package club.itstudio.itmanager.utils
|
||||||
|
|
||||||
|
import club.itstudio.itmanager.entity.ApiResponse
|
||||||
import reactor.core.publisher.Mono
|
import reactor.core.publisher.Mono
|
||||||
|
|
||||||
object Const {
|
object Const {
|
||||||
@@ -14,4 +15,13 @@ object Const {
|
|||||||
|
|
||||||
const val INTERNAL_ERROR_STR = "something went wrong. Please contact the administrator."
|
const val INTERNAL_ERROR_STR = "something went wrong. Please contact the administrator."
|
||||||
val INTERNAL_ERROR_MONO = Mono.just(INTERNAL_ERROR_STR)
|
val INTERNAL_ERROR_MONO = Mono.just(INTERNAL_ERROR_STR)
|
||||||
|
|
||||||
|
// for Controllers
|
||||||
|
fun messageHandler(wrongMessage: String): ApiResponse<Any?> {
|
||||||
|
return if (wrongMessage.isBlank()) {
|
||||||
|
ApiResponse.success()
|
||||||
|
} else {
|
||||||
|
ApiResponse.failure(400, null, wrongMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -42,3 +42,5 @@ app:
|
|||||||
count: 1000
|
count: 1000
|
||||||
limit-time: 3
|
limit-time: 3
|
||||||
ban-time: 60
|
ban-time: 60
|
||||||
|
file:
|
||||||
|
upload-path: ./data/upload/
|
||||||
Reference in New Issue
Block a user