加入不允许注册模块
This commit is contained in:
parent
b6db17290b
commit
0106db1e3b
8
info_upload.sql
Normal file
8
info_upload.sql
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
USE dormstar;
|
||||||
|
|
||||||
|
TRUNCATE ds_info;
|
||||||
|
|
||||||
|
INSERT INTO ds_info (value, data, commit) VALUES
|
||||||
|
('title', '201京海市保护伞', '网站标题'),
|
||||||
|
('sub_title', '我们的宿舍', '网站副标题'),
|
||||||
|
('register', true, '是否允许注册');
|
|
@ -6,6 +6,7 @@ import com.frontleaves.general.utils.ResultUtil
|
||||||
import com.xlf.dromstarkotlin.entity.voData.SignInVO
|
import com.xlf.dromstarkotlin.entity.voData.SignInVO
|
||||||
import com.xlf.dromstarkotlin.entity.voData.SignUpVO
|
import com.xlf.dromstarkotlin.entity.voData.SignUpVO
|
||||||
import com.xlf.dromstarkotlin.exception.BusinessException
|
import com.xlf.dromstarkotlin.exception.BusinessException
|
||||||
|
import com.xlf.dromstarkotlin.mapper.InfoMapper
|
||||||
import com.xlf.dromstarkotlin.services.TokenService
|
import com.xlf.dromstarkotlin.services.TokenService
|
||||||
import com.xlf.dromstarkotlin.services.UserService
|
import com.xlf.dromstarkotlin.services.UserService
|
||||||
import jakarta.servlet.http.HttpServletRequest
|
import jakarta.servlet.http.HttpServletRequest
|
||||||
|
@ -30,7 +31,8 @@ import java.util.Date
|
||||||
@RequestMapping("/api/user")
|
@RequestMapping("/api/user")
|
||||||
class UserController(
|
class UserController(
|
||||||
private val tokenService: TokenService,
|
private val tokenService: TokenService,
|
||||||
private val userService: UserService
|
private val userService: UserService,
|
||||||
|
private val infoMapper: InfoMapper,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* 用户登录组件
|
* 用户登录组件
|
||||||
|
@ -73,6 +75,10 @@ class UserController(
|
||||||
@RequestBody signUpVO: SignUpVO?, @CookieValue("session") token: String?, httpServletResponse: HttpServletResponse,
|
@RequestBody signUpVO: SignUpVO?, @CookieValue("session") token: String?, httpServletResponse: HttpServletResponse,
|
||||||
httpServletRequest: HttpServletRequest
|
httpServletRequest: HttpServletRequest
|
||||||
): ResponseEntity<BaseResponse> {
|
): ResponseEntity<BaseResponse> {
|
||||||
|
// 检查是否允许注册
|
||||||
|
if (!infoMapper.getRegister()) {
|
||||||
|
return ResultUtil.error(ErrorCode.REGISTRATION_NOT_ALLOWED, httpServletRequest)
|
||||||
|
}
|
||||||
// 判断请求体是否为空
|
// 判断请求体是否为空
|
||||||
if (signUpVO == null) {
|
if (signUpVO == null) {
|
||||||
return ResultUtil.error(ErrorCode.MISSING_REQUEST_BODY, httpServletRequest)
|
return ResultUtil.error(ErrorCode.MISSING_REQUEST_BODY, httpServletRequest)
|
||||||
|
|
11
src/main/kotlin/com/xlf/dromstarkotlin/mapper/InfoMapper.kt
Normal file
11
src/main/kotlin/com/xlf/dromstarkotlin/mapper/InfoMapper.kt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package com.xlf.dromstarkotlin.mapper
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper
|
||||||
|
import org.apache.ibatis.annotations.Select
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
interface InfoMapper {
|
||||||
|
|
||||||
|
@Select("SELECT * FROM dormstar.ds_info WHERE value = 'register'")
|
||||||
|
fun getRegister(): Boolean
|
||||||
|
}
|
|
@ -72,6 +72,12 @@ enum class ErrorCode(val output: String, val code: Int, val message: String, val
|
||||||
"您已经登录",
|
"您已经登录",
|
||||||
HttpStatus.BAD_REQUEST
|
HttpStatus.BAD_REQUEST
|
||||||
),
|
),
|
||||||
|
REGISTRATION_NOT_ALLOWED(
|
||||||
|
"RegistrationNotAllowed",
|
||||||
|
40027,
|
||||||
|
"不允许注册",
|
||||||
|
HttpStatus.BAD_REQUEST
|
||||||
|
),
|
||||||
YOU_ARE_NOT_LOGIN(
|
YOU_ARE_NOT_LOGIN(
|
||||||
"YouAreNotLogin",
|
"YouAreNotLogin",
|
||||||
40110,
|
40110,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user