Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
legobackend
/
lego-manage
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
a558fb88
authored
2025-05-05 20:33:35 +0800
by
chentao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
新增用户注册和登录
1 parent
7204fa59
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
lego-admin/src/main/java/com/lego/web/controller/core/RegisterUserController.java
lego-admin/src/main/java/com/lego/web/controller/core/RegisterUserController.java
0 → 100644
View file @
a558fb8
package
com
.
lego
.
web
.
controller
.
core
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
com.lego.common.constant.Constants
;
import
com.lego.common.core.controller.BaseController
;
import
com.lego.common.core.domain.R
;
import
com.lego.common.core.domain.model.LoginBody
;
import
com.lego.common.core.domain.model.RegisterBody
;
import
com.lego.common.enums.UserType
;
import
com.lego.system.service.SysLoginService
;
import
com.lego.system.service.SysRegisterService
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 用户信息
*
* @author chentao
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping
(
"/core/user"
)
public
class
RegisterUserController
extends
BaseController
{
private
final
SysRegisterService
registerService
;
private
final
SysLoginService
loginService
;
/**
* 用户注册
*/
@SaIgnore
@PostMapping
(
"/register"
)
public
R
<
Void
>
register
(
@Validated
@RequestBody
RegisterBody
user
)
{
user
.
setUserType
(
UserType
.
APP_USER
.
name
());
registerService
.
register
(
user
);
return
R
.
ok
();
}
@SaIgnore
@PostMapping
(
"/login"
)
public
R
<
Map
<
String
,
Object
>>
login
(
@Validated
@RequestBody
LoginBody
loginBody
)
{
Map
<
String
,
Object
>
ajax
=
new
HashMap
<>();
// 生成令牌
String
token
=
loginService
.
login
(
loginBody
.
getUsername
(),
loginBody
.
getPassword
(),
loginBody
.
getCode
(),
loginBody
.
getUuid
());
ajax
.
put
(
Constants
.
TOKEN
,
token
);
return
R
.
ok
(
ajax
);
}
}
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment