Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
V
volunteer_service
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
volunteer_service
Commits
fb9d6ca1
Commit
fb9d6ca1
authored
Jan 15, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户登录推出接口实现
parent
08de3d98
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
21 deletions
+133
-21
LoginRecordMapper.java
.../src/main/java/cn/wisenergy/mapper/LoginRecordMapper.java
+1
-1
OperationTypeEnum.java
...main/java/cn/wisenergy/model/enums/OperationTypeEnum.java
+13
-0
UserLoginVo.java
...odel/src/main/java/cn/wisenergy/model/vo/UserLoginVo.java
+36
-0
UserLoginService.java
.../main/java/cn/wisenergy/service/app/UserLoginService.java
+7
-9
UserLoginServiceImpl.java
...a/cn/wisenergy/service/app/impl/UserLoginServiceImpl.java
+50
-11
UserLongController.java
...isenergy/web/admin/controller/app/UserLongController.java
+26
-0
No files found.
wisenergy-mapper/src/main/java/cn/wisenergy/mapper/LoginRecordMapper.java
View file @
fb9d6ca1
...
...
@@ -11,7 +11,7 @@ public interface LoginRecordMapper extends BaseMapper<LoginRecord> {
* @param loginRecord 登录信息
* @return 登录信息
*/
LoginRecord
add
(
LoginRecord
loginRecord
);
int
add
(
LoginRecord
loginRecord
);
/**
* 编辑
...
...
wisenergy-model/src/main/java/cn/wisenergy/model/enums/OperationTypeEnum.java
View file @
fb9d6ca1
...
...
@@ -37,4 +37,17 @@ public enum OperationTypeEnum {
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
public
static
String
getByCode
(
Integer
code
)
{
if
(
null
==
code
)
{
return
null
;
}
for
(
OperationTypeEnum
operation
:
OperationTypeEnum
.
values
())
{
if
(
operation
.
getCode
().
intValue
()
==
code
.
intValue
())
{
return
operation
.
getDesc
();
}
}
return
null
;
}
}
wisenergy-model/src/main/java/cn/wisenergy/model/vo/UserLoginVo.java
0 → 100644
View file @
fb9d6ca1
package
cn
.
wisenergy
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
*@ Description: 用户登录Vo
*@ Author : 86187
*@ Date : 2021/1/15 14:27
*/
@Data
@ApiModel
(
value
=
"UserLoginVo"
)
public
class
UserLoginVo
implements
Serializable
{
private
static
final
long
serialVersionUID
=
2206962675782086034L
;
/**
* 手机号码
*/
@ApiModelProperty
(
value
=
"手机号码"
,
name
=
"phone"
)
private
String
phone
;
/**
* 密码
*/
@ApiModelProperty
(
value
=
"密码"
,
name
=
"password"
)
private
String
password
;
/**
* 验证码
*/
@ApiModelProperty
(
value
=
"验证码"
,
name
=
"smCode"
)
private
String
smCode
;
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/UserLoginService.java
View file @
fb9d6ca1
...
...
@@ -2,6 +2,7 @@ package cn.wisenergy.service.app;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.model.vo.UserInfoVo
;
import
cn.wisenergy.model.vo.UserLoginVo
;
import
cn.wisenergy.model.vo.UserRegisterVo
;
/**
...
...
@@ -21,20 +22,18 @@ public interface UserLoginService {
/**
* 手机验证码登录
*
* @param code 验证码
* @param phone 手机号
* @param userLoginVo 登录信息
* @return true 成功 false 失败
*/
R
<
Boolean
>
loginCode
(
String
code
,
String
phone
);
R
<
Boolean
>
loginCode
(
UserLoginVo
userLoginVo
);
/**
* 手机-密码登录
*
* @param phone 手机号
* @param password 密码
* @param userLoginVo 登录信息
* @return true 成功 false 失败
*/
R
<
UserInfoVo
>
login
(
String
phone
,
String
password
);
R
<
UserInfoVo
>
login
(
UserLoginVo
userLoginVo
);
/**
* 退出登录
...
...
@@ -65,9 +64,8 @@ public interface UserLoginService {
/**
* 短信重置密码
*
* @param code 用户id
* @param phone 手机号
* @param userLoginVo 登录信息
* @return true 成功 false 失败
*/
R
<
Boolean
>
notePassword
(
Integer
code
,
String
phone
);
R
<
Boolean
>
notePassword
(
UserLoginVo
userLoginVo
);
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserLoginServiceImpl.java
View file @
fb9d6ca1
...
...
@@ -2,10 +2,13 @@ package cn.wisenergy.service.app.impl;
import
cn.wisenergy.common.utils.Md5Util
;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.mapper.LoginRecordMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.LoginRecord
;
import
cn.wisenergy.model.app.UserInfo
;
import
cn.wisenergy.model.enums.OperationTypeEnum
;
import
cn.wisenergy.model.vo.UserInfoVo
;
import
cn.wisenergy.model.vo.UserLoginVo
;
import
cn.wisenergy.model.vo.UserRegisterVo
;
import
cn.wisenergy.service.app.UserLoginService
;
import
cn.wisenergy.service.common.Common
;
...
...
@@ -18,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
/**
* @author 86187
* @ Description: 用户登录相关接口实现
* @ Author : 86187
* @ Date : 2021/1/7 14:22
...
...
@@ -28,6 +32,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
@Autowired
private
UsersMapper
usersMapper
;
@Autowired
private
LoginRecordMapper
loginRecordMapper
;
@Override
public
R
<
Boolean
>
register
(
UserRegisterVo
userVo
)
{
log
.
info
(
"volunteer-service[]UserLoginServiceImpl[]register[]input.param.userVo:"
+
userVo
);
...
...
@@ -60,27 +67,34 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
}
//4、保存操作记录
LoginRecord
loginRecord
=
new
LoginRecord
();
loginRecord
.
setType
(
1
);
LoginRecord
loginRecord
=
new
LoginRecord
();
loginRecord
.
setType
(
OperationTypeEnum
.
USER_REGISTER
.
getCode
());
loginRecord
.
setUserId
(
user
.
getId
());
String
name
=
OperationTypeEnum
.
getByCode
(
OperationTypeEnum
.
USER_REGISTER
.
getCode
());
loginRecord
.
setOperationName
(
name
);
int
sum
=
loginRecordMapper
.
add
(
loginRecord
);
if
(
sum
==
0
)
{
return
R
.
ok
(
1
,
false
);
}
return
R
.
ok
(
0
,
true
);
}
@Override
public
R
<
Boolean
>
loginCode
(
String
code
,
String
phone
)
{
public
R
<
Boolean
>
loginCode
(
UserLoginVo
userLoginVo
)
{
return
null
;
}
@Override
public
R
<
UserInfoVo
>
login
(
String
phone
,
String
password
)
{
log
.
info
(
"volunteer-service[]UserLoginServiceImpl[]login[]input.param.
phone,password:"
+
phone
,
password
);
if
(
StringUtils
.
isBlank
(
phone
)
||
StringUtils
.
isBlank
(
password
))
{
public
R
<
UserInfoVo
>
login
(
UserLoginVo
userVo
)
{
log
.
info
(
"volunteer-service[]UserLoginServiceImpl[]login[]input.param.
userVo:"
+
userVo
);
if
(
null
==
userVo
||
StringUtils
.
isBlank
(
userVo
.
getPhone
())
||
StringUtils
.
isBlank
(
userVo
.
getPassword
()
))
{
return
R
.
error
(
"入参为空!"
);
}
//1、根据手机号,获取用户信息
QueryWrapper
<
UserInfo
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
eq
(
"phone"
,
phone
);
queryWrapper
.
eq
(
"phone"
,
userVo
.
getPhone
()
);
queryWrapper
.
eq
(
"is_delete"
,
0
);
UserInfo
userInfo
=
usersMapper
.
selectOne
(
queryWrapper
);
if
(
null
==
userInfo
)
{
...
...
@@ -89,7 +103,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
//2、判断密码是否正确
//MD5加密
String
secret
=
Md5Util
.
digestMD5
(
phone
+
password
);
String
secret
=
Md5Util
.
digestMD5
(
userVo
.
getPhone
()
+
userVo
.
getPassword
()
);
if
(!
userInfo
.
getPassword
().
equals
(
secret
))
{
return
R
.
error
(
"密码错误,请您输入正确密码!"
);
...
...
@@ -100,12 +114,38 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
userInfoVo
.
setUserId
(
userInfo
.
getId
());
userInfoVo
.
setUserName
(
userInfo
.
getUserName
());
userInfoVo
.
setPhone
(
userInfo
.
getPhone
());
//3、保存操作记录
LoginRecord
loginRecord
=
new
LoginRecord
();
loginRecord
.
setType
(
OperationTypeEnum
.
USER_LOGIN
.
getCode
());
loginRecord
.
setUserId
(
userInfo
.
getId
());
String
name
=
OperationTypeEnum
.
getByCode
(
OperationTypeEnum
.
USER_LOGIN
.
getCode
());
loginRecord
.
setOperationName
(
name
);
int
sum
=
loginRecordMapper
.
add
(
loginRecord
);
if
(
sum
==
0
)
{
return
R
.
error
(
"保存操作记录失败!"
);
}
return
R
.
ok
(
userInfoVo
);
}
@Override
public
R
<
Boolean
>
loginOut
(
Integer
userId
)
{
return
null
;
log
.
info
(
"volunteer-service[]UserLoginServiceImpl[]loginOut[]input.param.userId:"
+
userId
);
if
(
null
==
userId
)
{
return
R
.
error
(
"入参为空!"
);
}
//保存用户退出操作
LoginRecord
loginRecord
=
new
LoginRecord
();
loginRecord
.
setType
(
OperationTypeEnum
.
USER_OUT
.
getCode
());
loginRecord
.
setUserId
(
userId
);
String
name
=
OperationTypeEnum
.
getByCode
(
OperationTypeEnum
.
USER_OUT
.
getCode
());
loginRecord
.
setOperationName
(
name
);
int
sum
=
loginRecordMapper
.
add
(
loginRecord
);
if
(
sum
==
0
)
{
return
R
.
ok
(
1
,
false
);
}
return
R
.
ok
(
0
,
true
);
}
@Override
...
...
@@ -135,7 +175,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
}
@Override
public
R
<
Boolean
>
notePassword
(
Integer
code
,
String
phone
)
{
public
R
<
Boolean
>
notePassword
(
UserLoginVo
userVo
)
{
return
null
;
}
...
...
@@ -166,5 +206,4 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, UserInfo> imp
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/UserLongController.java
View file @
fb9d6ca1
...
...
@@ -2,6 +2,8 @@ package cn.wisenergy.web.admin.controller.app;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.model.vo.UserInfoVo
;
import
cn.wisenergy.model.vo.UserLoginVo
;
import
cn.wisenergy.model.vo.UserRegisterVo
;
import
cn.wisenergy.service.app.UserLoginService
;
import
io.swagger.annotations.Api
;
...
...
@@ -41,6 +43,30 @@ public class UserLongController {
return
userLoginService
.
register
(
userVo
);
}
@ApiOperation
(
value
=
"用户账号密码登录"
,
notes
=
"用户账号密码登录"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
(
name
=
"userVo"
,
value
=
"登录用户信息"
,
dataType
=
"UserLoginVo"
)
@PostMapping
(
"/login"
)
public
R
<
UserInfoVo
>
login
(
@RequestBody
UserLoginVo
userVo
)
{
log
.
info
(
"volunteer-service[]UserLongController[]login[]input.param.userVo:"
+
userVo
);
if
(
null
==
userVo
||
StringUtils
.
isBlank
(
userVo
.
getPhone
())
||
StringUtils
.
isBlank
(
userVo
.
getPassword
()))
{
return
R
.
error
(
"入参不能为空!"
);
}
return
userLoginService
.
login
(
userVo
);
}
@ApiOperation
(
value
=
"退出登录"
,
notes
=
"退出登录"
,
httpMethod
=
"POST"
)
@PostMapping
(
"/loginOut"
)
public
R
<
Boolean
>
loginOut
(
Integer
userId
)
{
log
.
info
(
"volunteer-service[]UserLongController[]loginOut[]input.param.userId:"
+
userId
);
if
(
null
==
userId
)
{
return
R
.
error
(
"入参不能为空!"
);
}
return
userLoginService
.
loginOut
(
userId
);
}
@ApiOperation
(
value
=
"重置密码"
,
notes
=
"重置密码"
,
httpMethod
=
"POST"
)
@PostMapping
(
"/resetPassword"
)
public
R
<
Boolean
>
resetPassword
(
Integer
userId
)
{
...
...
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