Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
data-server
Commits
ce3a6af7
Commit
ce3a6af7
authored
Mar 17, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户注册 接口提交 4
parent
ce1d60b1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
23 deletions
+60
-23
UserLoginVo.java
...odel/src/main/java/cn/wisenergy/model/vo/UserLoginVo.java
+23
-0
LoginService.java
.../src/main/java/cn/wisenergy/service/app/LoginService.java
+2
-0
LoginServiceImpl.java
.../java/cn/wisenergy/service/app/impl/LoginServiceImpl.java
+5
-0
LoginController.java
...n/wisenergy/web/admin/controller/app/LoginController.java
+30
-23
No files found.
wisenergy-model/src/main/java/cn/wisenergy/model/vo/UserLoginVo.java
0 → 100644
View file @
ce3a6af7
package
cn
.
wisenergy
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
/**
* @author 86187
* @ Description: 用户登录请求Vo
* @ Author : 86187
* @ Date : 2021/3/17 14:31
*/
@Data
@ApiModel
(
value
=
"UserLoginVo"
)
public
class
UserLoginVo
{
/**
* 用户手机号码
*/
@ApiModelProperty
(
value
=
""
,
name
=
""
)
private
String
userId
;
private
String
sms
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/LoginService.java
View file @
ce3a6af7
...
...
@@ -14,4 +14,6 @@ public interface LoginService {
* @return true or false
*/
R
<
Boolean
>
userRegister
(
UserRegisterVo
userRegisterVo
);
R
<
String
>
login
();
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/LoginServiceImpl.java
View file @
ce3a6af7
...
...
@@ -97,6 +97,11 @@ public class LoginServiceImpl implements LoginService {
return
R
.
ok
(
0
,
true
);
}
@Override
public
R
<
String
>
login
()
{
return
null
;
}
/**
* 检查用户手机号是否已注册
*
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/LoginController.java
View file @
ce3a6af7
...
...
@@ -6,6 +6,8 @@ import cn.wisenergy.common.enums.ResultEnum;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.model.app.UsersDto
;
import
cn.wisenergy.model.vo.UserRegisterVo
;
import
cn.wisenergy.service.app.LoginService
;
import
cn.wisenergy.service.app.UserService
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.Api
;
...
...
@@ -13,6 +15,7 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.ClassPathResource
;
...
...
@@ -34,6 +37,7 @@ import java.util.Map;
/**
* Created by m1991 on 2021/3/2 13:35
*
* @author 86187
*/
@Api
(
tags
=
"登录/注册"
)
...
...
@@ -49,11 +53,14 @@ public class LoginController {
@Autowired
private
UserService
usersService
;
@Autowired
private
LoginService
loginService
;
/**
* 手机登录接口
*
* @param userId 用户id
* @param sms 短信验证码
* @param sms
短信验证码
* @return 返回结果
* @throws Exception 异常
*/
...
...
@@ -102,7 +109,6 @@ public class LoginController {
}
public
String
createToken
(
User
users
)
throws
Exception
{
String
token
=
StringUtil
.
createToken
();
//保存token
...
...
@@ -193,6 +199,7 @@ public class LoginController {
/**
* 退出登录
*
* @param
* @return
*/
...
...
@@ -201,30 +208,30 @@ public class LoginController {
@PostMapping
(
"/logout"
)
public
Result
logout
(
HttpServletRequest
request
)
{
log
.
info
(
"退出登录"
);
Result
result
=
ResultUtils
.
returnFail
();
String
token
=
request
.
getHeader
(
"token"
);
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
Constants
.
Redis
.
PREFIX_TOKEN
,
token
);
if
(
redisUtils
.
getValue
(
key
)
==
null
){
log
.
info
(
"要退出登录的用户未登录"
);
return
ResultUtils
.
returnResult
(
ResultEnum
.
FILE_NOT_LOGIN
);
}
int
succ
=
usersService
.
logout
(
token
);
if
(
succ
>
0
)
{
result
=
ResultUtils
.
returnSuccess
();
}
return
result
;
log
.
info
(
"退出登录"
);
Result
result
=
ResultUtils
.
returnFail
();
String
token
=
request
.
getHeader
(
"token"
);
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
Constants
.
Redis
.
PREFIX_TOKEN
,
token
);
if
(
redisUtils
.
getValue
(
key
)
==
null
)
{
log
.
info
(
"要退出登录的用户未登录"
);
return
ResultUtils
.
returnResult
(
ResultEnum
.
FILE_NOT_LOGIN
);
}
int
succ
=
usersService
.
logout
(
token
);
if
(
succ
>
0
)
{
result
=
ResultUtils
.
returnSuccess
();
}
return
result
;
}
@ApiOperation
(
value
=
"用户注册"
,
notes
=
"用户注册"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
s
({
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户手机号"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"beInvitedCode"
,
value
=
"推荐人邀请码"
,
required
=
false
,
dataType
=
"String"
),
@ApiImplicitParam
(
name
=
"sms"
,
value
=
"验证码"
,
required
=
true
,
dataType
=
"String"
)
})
@RequestMapping
(
"/userRegister"
)
public
R
<
Boolean
>
userRegister
(){
return
R
.
ok
(
);
@ApiImplicitParam
(
name
=
"userVo"
,
value
=
"用户信息"
,
dataType
=
"UserRegisterVo"
)
@PostMapping
(
"/userRegister"
)
public
R
<
Boolean
>
userRegister
(
@RequestBody
UserRegisterVo
userVo
)
{
log
.
info
(
"shop-mall[]LoginController[]userRegister[]input.param.userVo:"
+
userVo
);
if
(
null
==
userVo
||
StringUtils
.
isBlank
(
userVo
.
getUserId
())
||
StringUtils
.
isBlank
(
userVo
.
getSms
()))
{
return
R
.
error
(
"入参不能为空!"
);
}
return
loginService
.
userRegister
(
userVo
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment