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
1d0b3535
Commit
1d0b3535
authored
Jan 18, 2021
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
忘记密码重置密码&权限菜单部分代码优化
parent
0212d867
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
324 additions
and
57 deletions
+324
-57
MenuProjectConstants.java
...main/java/com/gic/auth/constant/MenuProjectConstants.java
+15
-0
MenuApiService.java
...pi/src/main/java/com/gic/auth/service/MenuApiService.java
+2
-2
UserApiService.java
...pi/src/main/java/com/gic/auth/service/UserApiService.java
+10
-1
MenuAuthDepartServiceImpl.java
.../com/gic/auth/service/impl/MenuAuthDepartServiceImpl.java
+2
-0
MenuApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
+7
-42
UserApiServiceImpl.java
...a/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
+19
-1
AbstractMenuOperation.java
...n/java/com/gic/auth/utils/menu/AbstractMenuOperation.java
+96
-0
GicMenuSave.java
...ce/src/main/java/com/gic/auth/utils/menu/GicMenuSave.java
+47
-0
MenuOperationUtils.java
...main/java/com/gic/auth/utils/menu/MenuOperationUtils.java
+61
-0
UserController.java
...main/java/com/gic/auth/web/controller/UserController.java
+65
-11
No files found.
gic-platform-auth-api/src/main/java/com/gic/auth/constant/MenuProjectConstants.java
View file @
1d0b3535
package
com
.
gic
.
auth
.
constant
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 菜单项目
* @ClassName: MenuProjectConstants
...
...
@@ -46,4 +50,15 @@ public class MenuProjectConstants {
* 好办小程序应用
*/
public
final
static
String
HAO_BAN_WECHAT_APP_PROJECT
=
"haobanWechatApp"
;
public
final
static
Map
<
Integer
,
String
>
HAO_PROJECT_MAP
=
new
HashMap
<>(
8
);
static
{
HAO_PROJECT_MAP
.
put
(
1
,
HAO_BAN_PROJECT
);
HAO_PROJECT_MAP
.
put
(
2
,
HAO_BAN_WECHAT_PROJECT
);
HAO_PROJECT_MAP
.
put
(
3
,
HAO_BAN_PC_PROJECT
);
HAO_PROJECT_MAP
.
put
(
4
,
HAO_BAN_WECHAT_APP_PROJECT
);
}
}
gic-platform-auth-api/src/main/java/com/gic/auth/service/MenuApiService.java
View file @
1d0b3535
...
...
@@ -271,7 +271,7 @@ public interface MenuApiService {
ServiceResponse
<
List
<
MenuDTO
>>
listMenuItemByParentId
(
Integer
parentId
);
/**
* 新增页面
* 新增
gic第一层级的
页面
* @Title: saveGICPage
* @Description:
* @author guojuxing
...
...
@@ -281,7 +281,7 @@ public interface MenuApiService {
ServiceResponse
<
Void
>
saveGICPage
(
MenuDTO
menuDTO
);
/**
* 新增页面(好办)
* 新增
第一层级的
页面(好办)
* @Title: savePageForHaoban
* @Description:
* @author guojuxing
...
...
gic-platform-auth-api/src/main/java/com/gic/auth/service/UserApiService.java
View file @
1d0b3535
...
...
@@ -177,7 +177,16 @@ public interface UserApiService {
* @return com.gic.api.base.commons.ServiceResponse<com.gic.auth.dto.UserDTO>
*/
ServiceResponse
<
UserDTO
>
getUserByPhoneNumber
(
String
nationCode
,
String
phoneNumber
,
Integer
enterpriseId
);
/**
* 获取gic用户账号
* @param nationCode
* @param phoneNumber
* @param enterpriseId
* @return
*/
ServiceResponse
<
UserDTO
>
getGicUserByPhoneNumber
(
String
nationCode
,
String
phoneNumber
,
Integer
enterpriseId
);
/**
* login
* @Title: login
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/impl/MenuAuthDepartServiceImpl.java
View file @
1d0b3535
...
...
@@ -7,6 +7,7 @@ import com.gic.auth.service.MenuAuthDepartService;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
...
...
@@ -22,6 +23,7 @@ public class MenuAuthDepartServiceImpl implements MenuAuthDepartService{
private
TabSysMenuAuthDepartMapper
tabSysMenuAuthDepartMapper
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveFetch
(
List
<
MenuAuthDepartDTO
>
list
,
String
menuCode
)
{
tabSysMenuAuthDepartMapper
.
deleteByMenuCode
(
menuCode
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/MenuApiServiceImpl.java
View file @
1d0b3535
...
...
@@ -12,6 +12,7 @@ import com.gic.auth.qo.MenuListQO;
import
com.gic.auth.qo.MenuOperationItemListQO
;
import
com.gic.auth.qo.UserMenuQO
;
import
com.gic.auth.service.*
;
import
com.gic.auth.utils.menu.MenuOperationUtils
;
import
com.gic.authcenter.api.dto.GicDepartmentDTO
;
import
com.gic.authcenter.api.dto.GicPositionDTO
;
import
com.gic.authcenter.api.dto.GicUserDTO
;
...
...
@@ -317,37 +318,19 @@ public class MenuApiServiceImpl implements MenuApiService {
@Override
public
ServiceResponse
<
Void
>
saveGICPage
(
MenuDTO
menuDTO
)
{
menuDTO
.
setProject
(
MenuProjectConstants
.
DEFAULT_PROJECT
);
return
savePage
(
menuDTO
,
MenuDTO
.
SavePageValid
.
class
);
return
MenuOperationUtils
.
operateApi
(
menuDTO
,
MenuOperationUtils
.
SAVE_FIRST_PAGE
);
}
@Override
public
ServiceResponse
<
Void
>
savePageForHaoban
(
MenuDTO
menuDTO
)
{
Integer
platformType
=
menuDTO
.
getPlatformType
();
boolean
isRight
=
platformType
!=
null
&&
(
platformType
.
intValue
()
==
1
||
platformType
.
intValue
()
==
2
||
platformType
.
intValue
()
==
3
||
platformType
.
intValue
()
==
4
);
if
(!
isRight
)
{
Map
<
Integer
,
String
>
map
=
MenuProjectConstants
.
HAO_PROJECT_MAP
;
boolean
isRightPlatformType
=
map
.
get
(
platformType
)
!=
null
;
if
(!
isRightPlatformType
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"菜单平台类型值非法"
);
}
switch
(
platformType
)
{
case
1
:
menuDTO
.
setProject
(
MenuProjectConstants
.
HAO_BAN_PROJECT
);
break
;
case
2
:
menuDTO
.
setProject
(
MenuProjectConstants
.
HAO_BAN_WECHAT_PROJECT
);
break
;
case
3
:
menuDTO
.
setProject
(
MenuProjectConstants
.
HAO_BAN_PC_PROJECT
);
break
;
case
4
:
menuDTO
.
setProject
(
MenuProjectConstants
.
HAO_BAN_WECHAT_APP_PROJECT
);
break
;
default
:
menuDTO
.
setProject
(
MenuProjectConstants
.
HAO_BAN_PROJECT
);
}
return
savePage
(
menuDTO
,
MenuDTO
.
SavePageValid
.
class
);
menuDTO
.
setProject
(
map
.
get
(
platformType
));
return
MenuOperationUtils
.
operateApi
(
menuDTO
,
MenuOperationUtils
.
SAVE_FIRST_PAGE
);
}
@Override
...
...
@@ -893,24 +876,6 @@ public class MenuApiServiceImpl implements MenuApiService {
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityListNew
(
MenuDTO
.
class
,
list
));
}
private
ServiceResponse
<
Void
>
savePage
(
MenuDTO
menuDTO
,
Class
clazz
)
{
ServiceResponse
paramsValid
=
ValidParamsUtils
.
allCheckValidate
(
menuDTO
,
clazz
);
if
(!
paramsValid
.
isSuccess
())
{
return
paramsValid
;
}
//验证code是否重复
if
(
menuService
.
isRepeatMenuCode
(
menuDTO
.
getMenuCode
(),
null
))
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"code:"
+
menuDTO
.
getMenuCode
()
+
"重复"
);
}
setMenuVersion
(
menuDTO
);
setNormalFieldValue
(
menuDTO
);
setMenuAuthType
(
menuDTO
);
menuService
.
savePage
(
menuDTO
);
menuAuthDepartService
.
saveFetch
(
menuDTO
.
getMenuAuthDepartList
(),
menuDTO
.
getMenuCode
());
return
ServiceResponse
.
success
();
}
/**
* 奢姿权限适用字段数据
* @param menuDTO
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/service/outer/impl/UserApiServiceImpl.java
View file @
1d0b3535
...
...
@@ -450,7 +450,25 @@ public class UserApiServiceImpl implements UserApiService {
}
}
}
return
ServiceResponse
.
success
();
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"查不到用户数据"
);
}
@Override
public
ServiceResponse
<
UserDTO
>
getGicUserByPhoneNumber
(
String
nationCode
,
String
phoneNumber
,
Integer
enterpriseId
)
{
if
(
enterpriseId
==
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"商户数据为空"
);
}
List
<
TabSysUser
>
list
=
this
.
userService
.
listUserByPhoneNumberAndEnterprise
(
phoneNumber
,
nationCode
,
enterpriseId
);
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
for
(
TabSysUser
tabSysUser
:
list
)
{
//gic用户
if
(
tabSysUser
.
getLoginType
()
==
0
)
{
return
ServiceResponse
.
success
(
EntityUtil
.
changeEntityNew
(
UserDTO
.
class
,
tabSysUser
));
}
}
}
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"查不到用户数据"
);
}
@Override
...
...
gic-platform-auth-service/src/main/java/com/gic/auth/utils/menu/AbstractMenuOperation.java
0 → 100644
View file @
1d0b3535
package
com
.
gic
.
auth
.
utils
.
menu
;
import
com.gic.auth.constant.DeleteFlagConstants
;
import
com.gic.auth.constant.MenuProjectConstants
;
import
com.gic.auth.constant.SignConstants
;
import
com.gic.auth.dto.MenuAuthDepartDTO
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.auth.service.MenuApiService
;
import
com.gic.auth.service.MenuAuthDepartService
;
import
com.gic.auth.service.MenuService
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 权限菜单操作
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/1/16 10:31 AM
*/
@Component
public
abstract
class
AbstractMenuOperation
{
@Autowired
protected
MenuApiService
menuApiService
;
@Autowired
protected
MenuAuthDepartService
menuAuthDepartService
;
@Autowired
protected
MenuService
menuService
;
/**
* 权限操作
* @param menuDTO
* @return 如果有数据,表示错误信息
*/
public
abstract
String
operate
(
MenuDTO
menuDTO
);
/**
* gic基础版本/应用版本 数据处理
* @param menuDTO
*/
protected
void
setMenuVersion
(
MenuDTO
menuDTO
)
{
if
(
MenuProjectConstants
.
DEFAULT_PROJECT
.
equals
(
menuDTO
.
getProject
()))
{
menuDTO
.
setMenuVersion
(
SignConstants
.
UNDERLINE
+
menuDTO
.
getMenuVersion
().
replaceAll
(
SignConstants
.
COMMA
,
SignConstants
.
UNDERLINE
)
+
SignConstants
.
UNDERLINE
);
String
[]
menuVersionArr
=
menuDTO
.
getMenuVersion
().
split
(
SignConstants
.
UNDERLINE
);
StringBuilder
result
=
new
StringBuilder
();
Map
<
String
,
String
>
gicDefaultVersion
=
menuApiService
.
getGicDefaultVersion
().
getResult
();
for
(
String
str
:
menuVersionArr
)
{
if
(
StringUtils
.
isBlank
(
str
))
{
continue
;
}
result
.
append
(
gicDefaultVersion
.
get
(
str
)).
append
(
SignConstants
.
SLASH
);
}
String
menuVersionStr
=
result
.
toString
();
menuDTO
.
setMenuVersionName
(
menuVersionStr
.
substring
(
0
,
menuVersionStr
.
length
()
-
1
));
}
else
{
menuDTO
.
setMenuVersion
(
SignConstants
.
UNDERLINE
+
menuDTO
.
getMenuVersion
().
replaceAll
(
SignConstants
.
COMMA
,
SignConstants
.
UNDERLINE
)
+
SignConstants
.
UNDERLINE
);
menuDTO
.
setMenuVersionName
(
menuDTO
.
getMenuVersionName
().
replaceAll
(
SignConstants
.
COMMA
,
SignConstants
.
SLASH
));
}
}
/**
* 设置 权限适用 数据 管理员/超管/达摩人员
* @param menuDTO
*/
protected
void
setMenuAuthType
(
MenuDTO
menuDTO
)
{
Integer
authType
=
menuDTO
.
getAuthType
();
if
(
authType
==
null
)
{
authType
=
1
;
}
menuDTO
.
setAuthType
(
authType
);
if
(
authType
!=
1
)
{
List
<
MenuAuthDepartDTO
>
list
=
menuDTO
.
getMenuAuthDepartList
();
if
(
CollectionUtils
.
isNotEmpty
(
list
))
{
Date
now
=
new
Date
();
menuDTO
.
setMenuAuthDepartList
(
list
.
stream
().
map
(
e
->
e
.
setMenuCode
(
menuDTO
.
getMenuCode
())
.
setDeleteFlag
(
DeleteFlagConstants
.
NORMAL_STATUS
)
.
setCreateTime
(
now
)
.
setUpdateTime
(
now
)).
collect
(
Collectors
.
toList
()));
}
}
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/utils/menu/GicMenuSave.java
0 → 100644
View file @
1d0b3535
package
com
.
gic
.
auth
.
utils
.
menu
;
import
org.springframework.stereotype.Component
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.constant.MenuLevelConstants
;
import
com.gic.auth.constant.MenuProjectConstants
;
import
com.gic.auth.constant.MenuTypeEnum
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.enterprise.utils.valid.ValidParamsUtils
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* gic菜单新增
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/1/16 10:36 AM
*/
@Component
public
class
GicMenuSave
extends
AbstractMenuOperation
{
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
operate
(
MenuDTO
menuDTO
)
{
ServiceResponse
paramsValid
=
ValidParamsUtils
.
allCheckValidate
(
menuDTO
,
MenuDTO
.
SavePageValid
.
class
);
if
(!
paramsValid
.
isSuccess
())
{
return
paramsValid
.
getMessage
();
}
//验证code是否重复
if
(
menuService
.
isRepeatMenuCode
(
menuDTO
.
getMenuCode
(),
null
))
{
return
"code:"
+
menuDTO
.
getMenuCode
()
+
"重复"
;
}
//组装数据
setMenuVersion
(
menuDTO
);
String
project
=
MenuProjectConstants
.
DEFAULT_PROJECT
.
equals
(
menuDTO
.
getProject
())
?
menuDTO
.
getProject
()
:
null
;
int
maxSort
=
menuService
.
getMaxSortByParentId
(
MenuLevelConstants
.
FIRST_LEVEL_PARENT_ID
,
project
);
menuDTO
.
setSort
(
maxSort
+
1
);
menuDTO
.
setLevel
(
1
);
menuDTO
.
setParentId
(
MenuLevelConstants
.
FIRST_LEVEL_PARENT_ID
);
menuDTO
.
setMenuType
(
MenuTypeEnum
.
PAGE
.
getCode
());
setMenuAuthType
(
menuDTO
);
menuService
.
savePage
(
menuDTO
);
menuAuthDepartService
.
saveFetch
(
menuDTO
.
getMenuAuthDepartList
(),
menuDTO
.
getMenuCode
());
return
null
;
}
}
gic-platform-auth-service/src/main/java/com/gic/auth/utils/menu/MenuOperationUtils.java
0 → 100644
View file @
1d0b3535
package
com
.
gic
.
auth
.
utils
.
menu
;
import
com.gic.api.base.commons.ServiceResponse
;
import
com.gic.auth.dto.MenuDTO
;
import
com.gic.auth.utils.ApplicationContextUtils
;
import
com.gic.enterprise.error.ErrorCode
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 权限数据操作工具
* @ClassName:
* @Description:
* @author guojuxing
* @date 2021/1/16 11:01 AM
*/
public
class
MenuOperationUtils
{
private
static
Map
<
Integer
,
AbstractMenuOperation
>
map
=
new
HashMap
<>(
16
);
/**
* 新增第一层级的菜单数据
*/
public
static
final
Integer
SAVE_FIRST_PAGE
=
1
;
static
{
map
.
put
(
SAVE_FIRST_PAGE
,
ApplicationContextUtils
.
getBean
(
GicMenuSave
.
class
));
}
public
static
String
test
()
{
MenuDTO
test
=
new
MenuDTO
();
test
.
setProject
(
"gic"
);
test
.
setMenuVersion
(
"basic,advanced"
);
test
.
setMenuName
(
"guojx_test1"
);
test
.
setMenuCode
(
"guojx_test1"
);
test
.
setIsShow
(
1
);
test
.
setTarget
(
1
);
String
result
=
map
.
get
(
SAVE_FIRST_PAGE
).
operate
(
test
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
test
.
toString
());
return
result
;
}
public
static
String
operate
(
MenuDTO
menuDTO
,
Integer
operateType
)
{
return
map
.
get
(
operateType
).
operate
(
menuDTO
);
}
/**
* 操作
* @param menuDTO
* @param operateType 操作类型
* @return
*/
public
static
ServiceResponse
<
Void
>
operateApi
(
MenuDTO
menuDTO
,
Integer
operateType
)
{
String
result
=
operate
(
menuDTO
,
operateType
);
if
(
result
!=
null
)
{
return
ServiceResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
result
);
}
return
ServiceResponse
.
success
();
}
}
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/UserController.java
View file @
1d0b3535
...
...
@@ -2,8 +2,11 @@ package com.gic.auth.web.controller;
import
com.gic.auth.web.vo.SuperUserVO
;
import
com.gic.auth.web.vo.UserOfGicVO
;
import
com.gic.enterprise.ano.IgnoreLogin
;
import
com.gic.enterprise.base.EnterpriseInfo
;
import
com.gic.enterprise.constants.Constants
;
import
com.gic.enterprise.dto.EnterpriseDTO
;
import
com.gic.enterprise.service.EnterpriseApiService
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
...
...
@@ -56,6 +59,8 @@ public class UserController {
private
SmsSendApiService
smsSendApiService
;
@Autowired
private
AuthCodeApiService
authCodeApiService
;
@Autowired
private
EnterpriseApiService
enterpriseApiService
;
@RequestMapping
(
"/save-or-update-user"
)
public
RestResponse
editUser
(
@Validated
({
UserDTO
.
UserQoValid
.
class
})
UserDTO
userDTO
)
{
...
...
@@ -180,10 +185,7 @@ public class UserController {
//生成4位数字验证码
String
authCode
=
CreateRandomUtils
.
getStringRandom
(
4
);
authCodeDTO
.
setAuthCode
(
authCode
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
calendar
.
add
(
Calendar
.
MINUTE
,
5
);
authCodeDTO
.
setExpirationTime
(
calendar
.
getTime
());
authCodeDTO
.
setExpirationTime
(
setAuthCodeExpireTime
(
5
));
ServiceResponse
<
Integer
>
result
=
authCodeApiService
.
saveAuth
(
authCodeDTO
);
if
(
result
.
isSuccess
())
{
Integer
authCodeId
=
result
.
getResult
();
...
...
@@ -222,22 +224,30 @@ public class UserController {
}
@RequestMapping
(
"send-auth-code-to-modify-password"
)
public
RestResponse
sendAuthCode
()
{
@IgnoreLogin
public
RestResponse
sendAuthCode
(
String
nationCode
,
String
phoneNumber
,
Integer
enterpriseId
)
{
ServiceResponse
<
UserDTO
>
response
=
userApiService
.
getGicUserByPhoneNumber
(
nationCode
,
phoneNumber
,
enterpriseId
);
if
(!
response
.
isSuccess
())
{
return
RestResponse
.
failure
(
response
.
getCode
(),
response
.
getMessage
());
}
ServiceResponse
<
EnterpriseDTO
>
enterpriseResponse
=
enterpriseApiService
.
getEnterpriseById
(
enterpriseId
);
//生成数字验证码
AuthCodeDTO
authCodeDTO
=
new
AuthCodeDTO
();
authCodeDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
//生成4位数字验证码
authCodeDTO
.
setEnterpriseId
(
enterpriseId
);
String
authCode
=
CreateRandomUtils
.
getStringRandom
(
4
);
authCodeDTO
.
setAuthCode
(
authCode
);
authCodeDTO
.
setExpirationTime
(
setAuthCodeExpireTime
(
1
));
ServiceResponse
<
Integer
>
result
=
authCodeApiService
.
saveAuth
(
authCodeDTO
);
if
(
result
.
isSuccess
())
{
Integer
authCodeId
=
result
.
getResult
();
//发送手机验证码
String
[]
smsArr
=
new
String
[]
{
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseName
(),
authCode
};
enterpriseResponse
.
getResult
().
getEnterpriseName
(),
authCode
};
ServiceResponse
<
Void
>
smsSendResult
=
smsSendApiService
.
sendPlatformSms
(
"GICSHHT004"
,
UserDetailUtils
.
getUserDetail
().
getEnterpriseInfo
().
getEnterpriseId
()
,
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getPhoneAreaCode
()
,
UserDetailUtils
.
getUserDetail
().
getUserInfo
().
getPhoneNumber
()
,
smsArr
);
enterpriseId
,
nationCode
,
phoneNumber
,
smsArr
);
if
(!
smsSendResult
.
isSuccess
())
{
return
EnterpriseRestResponse
.
failure
(
smsSendResult
);
}
else
{
...
...
@@ -247,6 +257,43 @@ public class UserController {
return
EnterpriseRestResponse
.
failure
(
result
);
}
/**
* 忘记密码,重置密码根据验证码
* @param authCode 验证码
* @param authCodeId 验证码ID
* @param password
* @param confirmPassword
* @param nationCode 手机号区号
* @param phoneNumber 手机号码
* @param enterpriseId 商户ID
* @return
*/
@RequestMapping
(
"reset-password-by-auth-code"
)
public
RestResponse
resetPasswordByAuthCode
(
String
authCode
,
Integer
authCodeId
,
String
password
,
String
confirmPassword
,
String
nationCode
,
String
phoneNumber
,
Integer
enterpriseId
)
{
//获取用户ID
ServiceResponse
<
UserDTO
>
response
=
userApiService
.
getGicUserByPhoneNumber
(
nationCode
,
phoneNumber
,
enterpriseId
);
if
(!
response
.
isSuccess
())
{
return
RestResponse
.
failure
(
response
.
getCode
(),
response
.
getMessage
());
}
ServiceResponse
authCodeResult
=
authCodeApiService
.
validateAuthCode
(
authCodeId
,
authCode
);
if
(
authCodeResult
.
isSuccess
())
{
if
(
StringUtils
.
isBlank
(
password
))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"密码不能为空"
);
}
if
(!
password
.
equals
(
confirmPassword
))
{
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"密码和确认密码不一致"
);
}
//密码加密
Md5Util
md5
=
new
Md5Util
();
password
=
md5
.
encrypt
(
password
+
password
);
userApiService
.
editPhoneOrPassword
(
response
.
getResult
().
getUserId
(),
null
,
null
,
password
);
}
return
RestResponse
.
failure
(
authCodeResult
.
getCode
(),
authCodeResult
.
getMessage
());
}
@RequestMapping
(
"modify-password"
)
public
RestResponse
modifyPassword
(
String
oldPassword
,
String
newPassword
)
{
UserDetail
userDetail
=
UserDetailUtils
.
getUserDetail
();
...
...
@@ -320,4 +367,11 @@ public class UserController {
SuperUserVO
.
class
);
}
private
Date
setAuthCodeExpireTime
(
Integer
minute
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
new
Date
());
calendar
.
add
(
Calendar
.
MINUTE
,
minute
);
return
calendar
.
getTime
();
}
}
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