Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
Overview
Overview
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
base_platform_enterprise
gic-platform-auth
Commits
c60fbf54
Commit
c60fbf54
authored
Nov 18, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
个人资料功能
parent
418b6625
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
9 deletions
+119
-9
UserApiService.java
...pi/src/main/java/com/gic/auth/service/UserApiService.java
+13
-0
UserApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
+15
-0
UserController.java
...main/java/com/gic/auth/web/controller/UserController.java
+91
-9
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/service/UserApiService.java
View file @
c60fbf54
...
...
@@ -143,4 +143,17 @@ public interface UserApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String> 返回日志操作对象
*/
ServiceResponse
<
String
>
removeAccountGroup
(
Integer
accountGroupId
,
Integer
userId
,
Integer
type
);
/**
* 编辑修改个人资料:手机号码/密码
* @Title: editPhoneOrPassword
* @Description:
* @author guojuxing
* @param userId
* @param nationCode
* @param phone
* @param password
* @return com.gic.api.base.commons.ServiceResponse<java.lang.String>
*/
ServiceResponse
<
String
>
editPhoneOrPassword
(
Integer
userId
,
String
nationCode
,
String
phone
,
String
password
);
}
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
View file @
c60fbf54
...
...
@@ -404,6 +404,21 @@ public class UserApiServiceImpl implements UserApiService {
return
ServiceResponse
.
success
(
tabUser
.
getUserName
());
}
@Override
public
ServiceResponse
<
String
>
editPhoneOrPassword
(
Integer
userId
,
String
nationCode
,
String
phone
,
String
password
)
{
TabSysUser
tabUser
=
userService
.
getUserById
(
userId
);
if
(
tabUser
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"用户ID输入有误,无此数据"
);
}
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setUserId
(
userId
);
userDTO
.
setPhoneNumber
(
phone
);
userDTO
.
setPhoneAreaCode
(
nationCode
);
userDTO
.
setPassword
(
password
);
userService
.
editUser
(
userDTO
);
return
ServiceResponse
.
success
(
tabUser
.
getUserName
());
}
/**
* 保存关联数据,角色关联、资源关联
* @Title: saveRole
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/UserController.java
View file @
c60fbf54
...
...
@@ -5,7 +5,9 @@ import com.gic.auth.dto.AuthCodeDTO;
import
com.gic.auth.service.AuthCodeApiService
;
import
com.gic.auth.web.vo.LoginUserVO
;
import
com.gic.commons.util.EntityUtil
;
import
com.gic.commons.util.Md5Util
;
import
com.gic.enterprise.utils.CreateRandomUtils
;
import
com.gic.enterprise.utils.UserDetail
;
import
com.gic.marketing.process.api.service.sms.SmsSendApiService
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.log4j.LogManager
;
...
...
@@ -43,7 +45,7 @@ public class UserController {
private
AuthCodeApiService
authCodeApiService
;
@RequestMapping
(
"/save-or-update-user"
)
public
RestResponse
editUser
(
@Validated
({
UserDTO
.
UserQoValid
.
class
})
UserDTO
userDTO
)
{
public
RestResponse
editUser
(
@Validated
({
UserDTO
.
UserQoValid
.
class
})
UserDTO
userDTO
)
{
if
(
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getSuperAdmin
().
intValue
()
==
0
)
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"子管理员不能编辑"
);
}
...
...
@@ -65,7 +67,8 @@ public class UserController {
if
(
StringUtils
.
isBlank
(
userDTO
.
getPhoneAreaCode
()))
{
userDTO
.
setPhoneAreaCode
(
"86"
);
}
smsArr
=
new
String
[]{
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseName
(),
userDTO
.
getPhoneNumber
(),
password
};
smsArr
=
new
String
[]
{
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseName
(),
userDTO
.
getPhoneNumber
(),
password
};
}
}
ServiceResponse
userResult
;
...
...
@@ -79,7 +82,8 @@ public class UserController {
if
(
userResult
.
isSuccess
())
{
if
(
isNeedSendSms
)
{
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
"GICpassword001"
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseId
(),
userDTO
.
getPhoneAreaCode
(),
userDTO
.
getPhoneNumber
(),
smsArr
);
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseId
(),
userDTO
.
getPhoneAreaCode
(),
userDTO
.
getPhoneNumber
(),
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
logger
.
warn
(
smsSendResult
.
getMessage
());
}
...
...
@@ -137,18 +141,23 @@ public class UserController {
return
RestResponse
.
success
(
vo
);
}
@RequestMapping
(
"send-auth-code"
)
@RequestMapping
(
"send-auth-code
-to-modify-phone
"
)
public
RestResponse
sendAuthCode
(
String
phone
,
String
nationCode
)
{
if
(
StringUtils
.
isBlank
(
nationCode
))
{
nationCode
=
"86"
;
}
AuthCodeDTO
authCodeDTO
=
new
AuthCodeDTO
();
authCodeDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
//生成4位数字验证码
authCodeDTO
.
setAuthCode
(
CreateRandomUtils
.
getStringRandom
(
4
));
String
authCode
=
CreateRandomUtils
.
getStringRandom
(
4
);
authCodeDTO
.
setAuthCode
(
authCode
);
ServiceResponse
<
Integer
>
result
=
authCodeApiService
.
saveAuth
(
authCodeDTO
);
if
(
result
.
isSuccess
())
{
Integer
authCodeId
=
result
.
getResult
();
//发送手机验证码
String
[]
smsArr
=
new
String
[]{};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
"GICpassword001"
,
String
[]
smsArr
=
new
String
[]
{
authCode
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseName
()
};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
"GICphone"
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseId
(),
nationCode
,
phone
,
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
return
EnterpriseRestResponse
.
failure
(
smsSendResult
);
...
...
@@ -159,6 +168,80 @@ public class UserController {
return
EnterpriseRestResponse
.
failure
(
result
);
}
@RequestMapping
(
"modify-phone"
)
public
RestResponse
modifyPhone
(
String
phone
,
String
nationCode
,
String
authCode
,
Integer
authCodeId
)
{
ServiceResponse
authCodeResult
=
authCodeApiService
.
validateAuthCode
(
authCodeId
,
authCode
);
if
(
authCodeResult
.
isSuccess
())
{
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
// password 自身作为盐值
String
password
=
userDetail
.
getUserInfo
().
getPassword
();
ServiceResponse
<
UserDTO
>
login
=
this
.
userApiService
.
login
(
userDetail
.
getUserInfo
().
getPhoneNumber
(),
userDetail
.
getEnterpriseId
(),
password
);
ServiceResponse
<
String
>
result
=
userApiService
.
editPhoneOrPassword
(
login
.
getResult
().
getUserId
(),
nationCode
,
phone
,
null
);
if
(
result
.
isSuccess
())
{
//过期验证码
authCodeApiService
.
expireAuthCode
(
authCodeId
);
}
return
OperationResultUtils
.
operationResult
(
result
,
"修改手机号"
,
OperationResultUtils
.
getOperationObject
(
result
));
}
return
EnterpriseRestResponse
.
failure
(
authCodeResult
);
}
@RequestMapping
(
"send-auth-code-to-modify-password"
)
public
RestResponse
sendAuthCode
()
{
AuthCodeDTO
authCodeDTO
=
new
AuthCodeDTO
();
authCodeDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
//生成4位数字验证码
String
authCode
=
CreateRandomUtils
.
getStringRandom
(
4
);
authCodeDTO
.
setAuthCode
(
authCode
);
ServiceResponse
<
Integer
>
result
=
authCodeApiService
.
saveAuth
(
authCodeDTO
);
if
(
result
.
isSuccess
())
{
Integer
authCodeId
=
result
.
getResult
();
//发送手机验证码
String
[]
smsArr
=
new
String
[]
{
authCode
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseName
()
};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
"GICpassword"
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseId
(),
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getPhoneAreaCode
(),
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getPhoneNumber
(),
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
return
EnterpriseRestResponse
.
failure
(
smsSendResult
);
}
else
{
return
RestResponse
.
success
(
authCodeId
);
}
}
return
EnterpriseRestResponse
.
failure
(
result
);
}
@RequestMapping
(
"modify-password"
)
public
RestResponse
modifyPassword
(
String
oldPassword
,
String
newPhone
,
String
authCode
,
Integer
authCodeId
)
{
ServiceResponse
authCodeResult
=
authCodeApiService
.
validateAuthCode
(
authCodeId
,
authCode
);
if
(
authCodeResult
.
isSuccess
())
{
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
Md5Util
md5
=
new
Md5Util
();
// password 自身作为盐值
if
(
oldPassword
.
length
()
!=
32
)
{
oldPassword
=
md5
.
encrypt
(
oldPassword
+
oldPassword
);
}
ServiceResponse
<
UserDTO
>
login
=
this
.
userApiService
.
login
(
userDetail
.
getUserInfo
().
getPhoneNumber
(),
userDetail
.
getEnterpriseId
(),
oldPassword
);
if
(!
login
.
isSuccess
())
{
return
EnterpriseRestResponse
.
failure
(
login
);
}
ServiceResponse
<
String
>
result
=
userApiService
.
editPhoneOrPassword
(
login
.
getResult
().
getUserId
(),
null
,
null
,
md5
.
encrypt
(
newPhone
+
newPhone
));
if
(
result
.
isSuccess
())
{
//过期验证码
authCodeApiService
.
expireAuthCode
(
authCodeId
);
}
return
OperationResultUtils
.
operationResult
(
result
,
"修改密码"
,
OperationResultUtils
.
getOperationObject
(
result
));
}
return
EnterpriseRestResponse
.
failure
(
authCodeResult
);
}
@RequestMapping
(
"/list-user-nopage"
)
public
RestResponse
listUserNoPage
(
UserListQO
params
)
{
params
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
...
...
@@ -179,8 +262,7 @@ public class UserController {
@RequestMapping
(
"/remove-user-account-group"
)
public
RestResponse
removeUserAccountGroup
(
Integer
type
,
Integer
accountGroupId
,
Integer
userId
)
{
ServiceResponse
<
String
>
result
=
userApiService
.
removeAccountGroup
(
accountGroupId
,
userId
,
type
);
return
OperationResultUtils
.
operationResult
(
result
,
"移除账号分组"
,
OperationResultUtils
.
getOperationObject
(
result
));
return
OperationResultUtils
.
operationResult
(
result
,
"移除账号分组"
,
OperationResultUtils
.
getOperationObject
(
result
));
}
}
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