Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-account
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.account
pica-cloud-account
提交
af92ebe1
提交
af92ebe1
编写于
8月 20, 2019
作者:
rushui.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
20190820 修改密码与忘记密码
上级
15804707
流水线
#13513
已失败 于阶段
变更
15
流水线
1
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
384 行增加
和
116 行删除
+384
-116
AccountUserInfoController.java
.../account/server/controller/AccountUserInfoController.java
+0
-1
ModifyMobileController.java
...unt/account/server/controller/ModifyMobileController.java
+0
-1
PasswordController.java
...account/account/server/controller/PasswordController.java
+83
-2
LogPasswordModify.java
...loud/account/account/server/entity/LogPasswordModify.java
+9
-1
AccountContactMapper.java
...d/account/account/server/mapper/AccountContactMapper.java
+17
-0
AccountDetailsMapper.java
...d/account/account/server/mapper/AccountDetailsMapper.java
+1
-0
ForgetPasswordReq.java
...a/cloud/account/account/server/req/ForgetPasswordReq.java
+59
-0
ModifyMobileReq.java
...ica/cloud/account/account/server/req/ModifyMobileReq.java
+0
-1
PasswordReq.java
...om/pica/cloud/account/account/server/req/PasswordReq.java
+1
-1
AccountContactServer.java
.../account/account/server/service/AccountContactServer.java
+9
-0
PasswordService.java
...cloud/account/account/server/service/PasswordService.java
+6
-2
AccountContactServerImpl.java
...account/server/service/impl/AccountContactServerImpl.java
+19
-0
PasswordServiceImpl.java
...ount/account/server/service/impl/PasswordServiceImpl.java
+39
-4
AccountUtils.java
.../pica/cloud/account/account/server/util/AccountUtils.java
+28
-0
AcctountContactMapper.xml
server/src/main/resources/mybatis/AcctountContactMapper.xml
+113
-103
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountUserInfoController.java
浏览文件 @
af92ebe1
...
@@ -26,7 +26,6 @@ public class AccountUserInfoController extends AccountBaseController {
...
@@ -26,7 +26,6 @@ public class AccountUserInfoController extends AccountBaseController {
@Autowired
@Autowired
private
AccountUserInfoService
accountUserInfoService
;
private
AccountUserInfoService
accountUserInfoService
;
/**
/**
* 修改用户信息接口
* 修改用户信息接口
*
*
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/ModifyMobileController.java
浏览文件 @
af92ebe1
...
@@ -35,7 +35,6 @@ public class ModifyMobileController extends AccountBaseController {
...
@@ -35,7 +35,6 @@ public class ModifyMobileController extends AccountBaseController {
@Autowired
@Autowired
private
ModifyMobileService
modifyMobileService
;
private
ModifyMobileService
modifyMobileService
;
/**
/**
* 修改手机号
* 修改手机号
*
*
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/PasswordController.java
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pica.cloud.account.account.server.entity.AccountContact
;
import
com.pica.cloud.account.account.server.entity.AccountUser
;
import
com.pica.cloud.account.account.server.entity.AccountUser
;
import
com.pica.cloud.account.account.server.req.ModifyPasswordReq
;
import
com.pica.cloud.account.account.server.mapper.AccountContactMapper
;
import
com.pica.cloud.account.account.server.req.ForgetPasswordReq
;
import
com.pica.cloud.account.account.server.req.PasswordReq
;
import
com.pica.cloud.account.account.server.service.AccountContactServer
;
import
com.pica.cloud.account.account.server.service.PasswordService
;
import
com.pica.cloud.account.account.server.service.PasswordService
;
import
com.pica.cloud.account.account.server.util.AccountUtils
;
import
com.pica.cloud.account.account.server.util.RSAUtils
;
import
com.pica.cloud.account.account.server.util.RSAUtils
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.redis.CacheClient
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -21,9 +29,23 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -21,9 +29,23 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/password"
)
@RequestMapping
(
"/password"
)
public
class
PasswordController
extends
AccountBaseController
{
public
class
PasswordController
extends
AccountBaseController
{
@Autowired
@Autowired
private
PasswordService
passwordService
;
private
PasswordService
passwordService
;
@Autowired
private
AccountContactServer
accountContactServer
;
@Autowired
private
CacheClient
cacheClient
;
/**
* 修改密码
*
* @param params params
* @return PicaResponse
* @throws Exception
*/
@ApiOperation
(
value
=
"修改密码"
)
@ApiOperation
(
value
=
"修改密码"
)
@PostMapping
(
value
=
"/modify"
)
@PostMapping
(
value
=
"/modify"
)
public
PicaResponse
modifyPassword
(
@RequestBody
String
params
)
throws
Exception
{
public
PicaResponse
modifyPassword
(
@RequestBody
String
params
)
throws
Exception
{
...
@@ -31,7 +53,7 @@ public class PasswordController extends AccountBaseController {
...
@@ -31,7 +53,7 @@ public class PasswordController extends AccountBaseController {
String
token
=
accountUser
.
getToken
();
String
token
=
accountUser
.
getToken
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
if
(
StringUtils
.
isNotEmpty
(
token
))
{
String
json
=
RSAUtils
.
decrypt
(
params
,
RSAUtils
.
getPrivateKey
());
String
json
=
RSAUtils
.
decrypt
(
params
,
RSAUtils
.
getPrivateKey
());
ModifyPasswordReq
modifyPasswordReq
=
JSONObject
.
parseObject
(
json
,
Modify
PasswordReq
.
class
);
PasswordReq
modifyPasswordReq
=
JSONObject
.
parseObject
(
json
,
PasswordReq
.
class
);
modifyPasswordReq
.
setId
(
accountUser
.
getAcctId
());
modifyPasswordReq
.
setId
(
accountUser
.
getAcctId
());
passwordService
.
modifyPassword
(
modifyPasswordReq
);
passwordService
.
modifyPassword
(
modifyPasswordReq
);
return
PicaResponse
.
toResponse
(
"密码修改成功"
);
return
PicaResponse
.
toResponse
(
"密码修改成功"
);
...
@@ -39,4 +61,63 @@ public class PasswordController extends AccountBaseController {
...
@@ -39,4 +61,63 @@ public class PasswordController extends AccountBaseController {
throw
new
PicaException
(
"请登陆"
);
throw
new
PicaException
(
"请登陆"
);
}
}
}
}
/**
* 忘记密码
*
* @param params params
* @return PicaResponse
* @throws Exception
*/
@ApiOperation
(
value
=
"忘记密码操作"
)
@PostMapping
(
value
=
"/reset"
)
public
PicaResponse
forwardPassword
(
@RequestBody
String
params
)
throws
Exception
{
//TODO: 2019/8/20 当前手机号是否注册过,如果没有注册,请先注册
String
json
=
RSAUtils
.
decrypt
(
params
,
RSAUtils
.
getPrivateKey
());
ForgetPasswordReq
forwardPasswordReq
=
JSONObject
.
parseObject
(
json
,
ForgetPasswordReq
.
class
);
forwardPasswordReq
.
setFlag
(
"4"
);
//是否注册校验
checkRegisterMobile
(
forwardPasswordReq
.
getMobile
());
//手机号校验
AccountUtils
.
checkMobilePhone
(
forwardPasswordReq
.
getMobile
());
//验证码校验
this
.
checkAuthCode
(
forwardPasswordReq
);
passwordService
.
forgetPassword
(
forwardPasswordReq
);
return
PicaResponse
.
toResponse
(
"密码修改成功"
);
}
/**
* 校验手机号是否注册过
*
* @param mobile
*/
private
void
checkRegisterMobile
(
String
mobile
)
{
String
encrypt
=
EncryptCreateUtil
.
encrypt
(
mobile
);
AccountContact
accountContact
=
accountContactServer
.
selectByMobile
(
encrypt
);
if
(
accountContact
==
null
)
{
throw
new
PicaException
(
"请先注册"
);
}
}
/**
* 校验验证码
*
* @param req
*/
private
void
checkAuthCode
(
ForgetPasswordReq
req
)
{
String
flag
=
StringUtils
.
isBlank
(
req
.
getFlag
())
?
"0"
:
req
.
getFlag
();
if
(
StringUtils
.
isBlank
(
req
.
getAuthCode
()))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
String
authCodeKey
=
AccountUtils
.
getAuthCodeKey
(
req
.
getMobile
(),
flag
);
String
cacheCode
=
cacheClient
.
get
(
authCodeKey
);
//从redis获取验证码
if
(
StringUtils
.
isBlank
(
cacheCode
))
{
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"短信验证码已过期,请重新获取"
);
}
if
(!
StringUtils
.
equals
(
req
.
getAuthCode
(),
cacheCode
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
cacheClient
.
del
(
authCodeKey
);
//清除验证码
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/entity/LogPasswordModify.java
浏览文件 @
af92ebe1
...
@@ -3,6 +3,8 @@ package com.pica.cloud.account.account.server.entity;
...
@@ -3,6 +3,8 @@ package com.pica.cloud.account.account.server.entity;
import
java.util.Date
;
import
java.util.Date
;
public
class
LogPasswordModify
{
public
class
LogPasswordModify
{
private
Long
id
;
private
Long
id
;
private
String
mobilePhone
;
private
String
mobilePhone
;
...
@@ -21,6 +23,12 @@ public class LogPasswordModify {
...
@@ -21,6 +23,12 @@ public class LogPasswordModify {
private
Date
createdTime
;
private
Date
createdTime
;
public
LogPasswordModify
()
{
this
.
modifiedTime
=
new
Date
();
this
.
deleteFlag
=
1
;
this
.
createdTime
=
new
Date
();
}
public
Long
getId
()
{
public
Long
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -33,7 +41,7 @@ public class LogPasswordModify {
...
@@ -33,7 +41,7 @@ public class LogPasswordModify {
return
mobilePhone
;
return
mobilePhone
;
}
}
public
void
setMobilePhone
(
String
mobilePhone
)
{
public
void
setMobilePhone
(
String
mobilePhone
)
{
this
.
mobilePhone
=
mobilePhone
==
null
?
null
:
mobilePhone
.
trim
();
this
.
mobilePhone
=
mobilePhone
==
null
?
null
:
mobilePhone
.
trim
();
}
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/mapper/AccountContactMapper.java
浏览文件 @
af92ebe1
...
@@ -13,5 +13,22 @@ public interface AccountContactMapper {
...
@@ -13,5 +13,22 @@ public interface AccountContactMapper {
*/
*/
int
updateByPrimaryKeySelective
(
AccountContact
record
);
int
updateByPrimaryKeySelective
(
AccountContact
record
);
/**
* 获取账户信息
*
* @param id
* @return
*/
AccountContact
selectByPrimaryKey
(
Long
id
);
/**
* 通过手机号获取账户信息
*
* @param mobile
* @return
*/
AccountContact
selectByMobile
(
String
mobile
);
}
}
\ No newline at end of file
server/src/main/java/com/pica/cloud/account/account/server/mapper/AccountDetailsMapper.java
浏览文件 @
af92ebe1
...
@@ -23,4 +23,5 @@ public interface AccountDetailsMapper {
...
@@ -23,4 +23,5 @@ public interface AccountDetailsMapper {
* @return
* @return
*/
*/
int
updatePasswordById
(
AccountInfo
record
);
int
updatePasswordById
(
AccountInfo
record
);
}
}
\ No newline at end of file
server/src/main/java/com/pica/cloud/account/account/server/req/ForgetPasswordReq.java
0 → 100644
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
req
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
@ApiModel
(
value
=
"忘记密码"
)
public
class
ForgetPasswordReq
{
@ApiModelProperty
(
value
=
"账户id"
)
private
Integer
acctId
;
@ApiModelProperty
(
value
=
"手机号"
)
private
String
mobile
;
@ApiModelProperty
(
value
=
"验证码"
)
private
String
authCode
;
@ApiModelProperty
(
value
=
"新密码"
)
private
String
newPsw
;
@ApiModelProperty
(
"验证码类型"
)
private
String
flag
;
public
Integer
getAcctId
()
{
return
acctId
;
}
public
void
setAcctId
(
Integer
acctId
)
{
this
.
acctId
=
acctId
;
}
public
String
getMobile
()
{
return
mobile
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
String
getAuthCode
()
{
return
authCode
;
}
public
void
setAuthCode
(
String
authCode
)
{
this
.
authCode
=
authCode
;
}
public
String
getNewPsw
()
{
return
newPsw
;
}
public
void
setNewPsw
(
String
newPsw
)
{
this
.
newPsw
=
newPsw
;
}
public
String
getFlag
()
{
return
flag
;
}
public
void
setFlag
(
String
flag
)
{
this
.
flag
=
flag
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/req/ModifyMobileReq.java
浏览文件 @
af92ebe1
...
@@ -13,7 +13,6 @@ public class ModifyMobileReq {
...
@@ -13,7 +13,6 @@ public class ModifyMobileReq {
@ApiModelProperty
(
value
=
"验证码类型"
)
@ApiModelProperty
(
value
=
"验证码类型"
)
private
String
flag
;
private
String
flag
;
public
String
getMobile
()
{
public
String
getMobile
()
{
return
mobile
;
return
mobile
;
}
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/req/
Modify
PasswordReq.java
→
server/src/main/java/com/pica/cloud/account/account/server/req/PasswordReq.java
浏览文件 @
af92ebe1
...
@@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModel;
...
@@ -4,7 +4,7 @@ import io.swagger.annotations.ApiModel;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
@ApiModel
(
description
=
"修改密码"
)
@ApiModel
(
description
=
"修改密码"
)
public
class
Modify
PasswordReq
{
public
class
PasswordReq
{
@ApiModelProperty
(
"账户id"
)
@ApiModelProperty
(
"账户id"
)
private
int
id
;
private
int
id
;
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/AccountContactServer.java
0 → 100644
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
import
com.pica.cloud.account.account.server.entity.AccountContact
;
public
interface
AccountContactServer
{
AccountContact
selectByMobile
(
String
mobile
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/PasswordService.java
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
import
com.pica.cloud.account.account.server.req.ModifyPasswordReq
;
import
com.pica.cloud.account.account.server.req.ForgetPasswordReq
;
import
com.pica.cloud.account.account.server.req.PasswordReq
;
public
interface
PasswordService
{
public
interface
PasswordService
{
...
@@ -11,5 +12,8 @@ public interface PasswordService {
...
@@ -11,5 +12,8 @@ public interface PasswordService {
* @param modifyPasswordReq
* @param modifyPasswordReq
* @return
* @return
*/
*/
void
modifyPassword
(
ModifyPasswordReq
modifyPasswordReq
);
void
modifyPassword
(
PasswordReq
modifyPasswordReq
);
void
forgetPassword
(
ForgetPasswordReq
forgetPasswordReq
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/AccountContactServerImpl.java
0 → 100644
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
.
impl
;
import
com.pica.cloud.account.account.server.entity.AccountContact
;
import
com.pica.cloud.account.account.server.mapper.AccountContactMapper
;
import
com.pica.cloud.account.account.server.service.AccountContactServer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
@Service
public
class
AccountContactServerImpl
implements
AccountContactServer
{
@Autowired
private
AccountContactMapper
accountContactMapper
;
@Override
public
AccountContact
selectByMobile
(
String
mobile
)
{
return
accountContactMapper
.
selectByMobile
(
mobile
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/PasswordServiceImpl.java
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
.
impl
;
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
.
impl
;
import
com.pica.cloud.account.account.server.entity.AccountContact
;
import
com.pica.cloud.account.account.server.entity.AccountInfo
;
import
com.pica.cloud.account.account.server.entity.AccountInfo
;
import
com.pica.cloud.account.account.server.entity.LogPasswordModify
;
import
com.pica.cloud.account.account.server.mapper.AccountContactMapper
;
import
com.pica.cloud.account.account.server.mapper.AccountDetailsMapper
;
import
com.pica.cloud.account.account.server.mapper.AccountDetailsMapper
;
import
com.pica.cloud.account.account.server.req.ModifyPasswordReq
;
import
com.pica.cloud.account.account.server.mapper.LogPasswordModifyMapper
;
import
com.pica.cloud.account.account.server.req.ForgetPasswordReq
;
import
com.pica.cloud.account.account.server.req.PasswordReq
;
import
com.pica.cloud.account.account.server.service.PasswordService
;
import
com.pica.cloud.account.account.server.service.PasswordService
;
import
com.sun.xml.internal.bind.v2.TODO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -15,16 +19,47 @@ public class PasswordServiceImpl implements PasswordService {
...
@@ -15,16 +19,47 @@ public class PasswordServiceImpl implements PasswordService {
@Autowired
@Autowired
private
AccountDetailsMapper
accountDetailsMapper
;
private
AccountDetailsMapper
accountDetailsMapper
;
@Autowired
private
LogPasswordModifyMapper
logPasswordModifyMapper
;
@Autowired
private
AccountContactMapper
accountContactMapper
;
@Override
@Override
public
void
modifyPassword
(
Modify
PasswordReq
modifyPasswordReq
)
{
public
void
modifyPassword
(
PasswordReq
modifyPasswordReq
)
{
Integer
id
=
modifyPasswordReq
.
getId
();
Integer
id
=
modifyPasswordReq
.
getId
();
AccountInfo
AccountInfoEntity
=
accountDetailsMapper
.
selectByPrimaryKey
(
id
.
longValue
());
//更新密码
AccountInfo
accountInfo
=
new
AccountInfo
();
AccountInfo
accountInfo
=
new
AccountInfo
();
accountInfo
.
setId
(
id
.
longValue
());
accountInfo
.
setId
(
id
.
longValue
());
accountInfo
.
setPassword
(
modifyPasswordReq
.
getOldPsw
());
accountInfo
.
setPassword
(
modifyPasswordReq
.
getOldPsw
());
accountDetailsMapper
.
updatePasswordById
(
accountInfo
);
accountDetailsMapper
.
updatePasswordById
(
accountInfo
);
//记录密码更新日志
//记录密码更新日志
// TODO: 2019/8/20
LogPasswordModify
logPasswordModify
=
new
LogPasswordModify
();
logPasswordModify
.
setCreatedId
(
id
.
longValue
());
logPasswordModify
.
setModifiedId
(
id
);
logPasswordModify
.
setNewPwd
(
modifyPasswordReq
.
getNewPsw
());
logPasswordModify
.
setOldPwd
(
AccountInfoEntity
.
getPassword
());
AccountContact
accountContact
=
accountContactMapper
.
selectByPrimaryKey
(
id
.
longValue
());
logPasswordModify
.
setMobilePhone
(
accountContact
.
getMobilePhone
());
logPasswordModifyMapper
.
insertSelective
(
logPasswordModify
);
}
@Override
public
void
forgetPassword
(
ForgetPasswordReq
forgetPasswordReq
)
{
AccountContact
accountContact
=
accountContactMapper
.
selectByMobile
(
forgetPasswordReq
.
getMobile
());
AccountInfo
accountInfo
=
new
AccountInfo
();
accountInfo
.
setId
(
accountContact
.
getAcctId
().
longValue
());
accountInfo
.
setPassword
(
forgetPasswordReq
.
getNewPsw
());
accountDetailsMapper
.
updatePasswordById
(
accountInfo
);
//记录更新日志
LogPasswordModify
logPasswordModify
=
new
LogPasswordModify
();
logPasswordModify
.
setCreatedId
(
accountContact
.
getAcctId
().
longValue
());
logPasswordModify
.
setModifiedId
(
accountContact
.
getAcctId
());
logPasswordModify
.
setNewPwd
(
forgetPasswordReq
.
getNewPsw
());
logPasswordModify
.
setOldPwd
(
""
);
logPasswordModify
.
setMobilePhone
(
forgetPasswordReq
.
getMobile
());
logPasswordModifyMapper
.
insertSelective
(
logPasswordModify
);
}
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/util/AccountUtils.java
0 → 100644
浏览文件 @
af92ebe1
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
util
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
com.pica.cloud.foundation.utils.utils.ValidateUtils
;
import
org.apache.commons.lang3.StringUtils
;
/**
* 账户工具类
*/
public
class
AccountUtils
{
private
static
final
String
AUTH_CODE_PREFIX
=
"authCode-"
;
//手机格式校验
public
static
void
checkMobilePhone
(
String
mobilePhone
)
{
if
(
StringUtils
.
isBlank
(
mobilePhone
)
||
!
ValidateUtils
.
isMobile
(
mobilePhone
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
}
}
//获取验证码redis key
public
static
String
getAuthCodeKey
(
String
mobilePhone
,
String
flag
)
{
return
AUTH_CODE_PREFIX
+
flag
+
"-"
+
EncryptCreateUtil
.
encrypt
(
mobilePhone
);
}
}
server/src/main/resources/mybatis/AcctountContactMapper.xml
浏览文件 @
af92ebe1
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.pica.cloud.account.account.server.mapper.AccountContactMapper"
>
<mapper
namespace=
"com.pica.cloud.account.account.server.mapper.AccountContactMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"acct_id"
property=
"acctId"
jdbcType=
"INTEGER"
/>
<result
column=
"acct_id"
property=
"acctId"
jdbcType=
"INTEGER"
/>
<result
column=
"mobile_phone"
property=
"mobilePhone"
jdbcType=
"VARCHAR"
/>
<result
column=
"mobile_phone"
property=
"mobilePhone"
jdbcType=
"VARCHAR"
/>
<result
column=
"delete_flag"
property=
"deleteFlag"
jdbcType=
"INTEGER"
/>
<result
column=
"delete_flag"
property=
"deleteFlag"
jdbcType=
"INTEGER"
/>
<result
column=
"created_id"
property=
"createdId"
jdbcType=
"BIGINT"
/>
<result
column=
"created_id"
property=
"createdId"
jdbcType=
"BIGINT"
/>
<result
column=
"created_time"
property=
"createdTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"created_time"
property=
"createdTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"modified_id"
property=
"modifiedId"
jdbcType=
"BIGINT"
/>
<result
column=
"modified_id"
property=
"modifiedId"
jdbcType=
"BIGINT"
/>
<result
column=
"modified_time"
property=
"modifiedTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"modified_time"
property=
"modifiedTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, acct_id, mobile_phone, delete_flag, created_id, created_time, modified_id, modified_time
id, acct_id, mobile_phone, delete_flag, created_id, created_time, modified_id, modified_time
</sql>
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Long"
>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Long"
>
select
select
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from acct_contact
from acct_contact
where id = #{id,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</select>
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Long"
>
delete from acct_contact
<!--通过手机号获取账户信息-->
where id = #{id,jdbcType=BIGINT}
<select
id=
"selectByMobile"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.String"
>
</delete>
select
<insert
id=
"insert"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
<include
refid=
"Base_Column_List"
/>
from acct_contact
where mobile = #{mobile_phone}
</select>
<!--修改手机号-->
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
update acct_contact
<set>
<if
test=
"mobilePhone != null"
>
mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
</if>
<if
test=
"deleteFlag != null"
>
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if
test=
"createdId != null"
>
created_id = #{createdId,jdbcType=BIGINT},
</if>
<if
test=
"createdTime != null"
>
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"modifiedId != null"
>
modified_id = #{modifiedId,jdbcType=BIGINT},
</if>
<if
test=
"modifiedTime != null"
>
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where acct_id = #{acctId,jdbcType=BIGINT}
</update>
<insert
id=
"insert"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
insert into acct_contact (id, acct_id, mobile_phone,
insert into acct_contact (id, acct_id, mobile_phone,
delete_flag, created_id, created_time,
delete_flag, created_id, created_time,
modified_id, modified_time)
modified_id, modified_time)
...
@@ -32,86 +67,61 @@
...
@@ -32,86 +67,61 @@
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT}, #{createdTime,jdbcType=TIMESTAMP},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT}, #{createdTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP})
#{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP})
</insert>
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
<insert
id=
"insertSelective"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
insert into acct_contact
insert into acct_contact
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
<if
test=
"id != null"
>
id,
id,
</if>
</if>
<if
test=
"acctId != null"
>
<if
test=
"acctId != null"
>
acct_id,
acct_id,
</if>
</if>
<if
test=
"mobilePhone != null"
>
<if
test=
"mobilePhone != null"
>
mobile_phone,
mobile_phone,
</if>
</if>
<if
test=
"deleteFlag != null"
>
<if
test=
"deleteFlag != null"
>
delete_flag,
delete_flag,
</if>
</if>
<if
test=
"createdId != null"
>
<if
test=
"createdId != null"
>
created_id,
created_id,
</if>
</if>
<if
test=
"createdTime != null"
>
<if
test=
"createdTime != null"
>
created_time,
created_time,
</if>
</if>
<if
test=
"modifiedId != null"
>
<if
test=
"modifiedId != null"
>
modified_id,
modified_id,
</if>
</if>
<if
test=
"modifiedTime != null"
>
<if
test=
"modifiedTime != null"
>
modified_time,
modified_time,
</if>
</if>
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
<if
test=
"id != null"
>
#{id,jdbcType=BIGINT},
#{id,jdbcType=BIGINT},
</if>
</if>
<if
test=
"acctId != null"
>
<if
test=
"acctId != null"
>
#{acctId,jdbcType=INTEGER},
#{acctId,jdbcType=INTEGER},
</if>
</if>
<if
test=
"mobilePhone != null"
>
<if
test=
"mobilePhone != null"
>
#{mobilePhone,jdbcType=VARCHAR},
#{mobilePhone,jdbcType=VARCHAR},
</if>
</if>
<if
test=
"deleteFlag != null"
>
<if
test=
"deleteFlag != null"
>
#{deleteFlag,jdbcType=INTEGER},
#{deleteFlag,jdbcType=INTEGER},
</if>
</if>
<if
test=
"createdId != null"
>
<if
test=
"createdId != null"
>
#{createdId,jdbcType=BIGINT},
#{createdId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"createdTime != null"
>
<if
test=
"createdTime != null"
>
#{createdTime,jdbcType=TIMESTAMP},
#{createdTime,jdbcType=TIMESTAMP},
</if>
</if>
<if
test=
"modifiedId != null"
>
<if
test=
"modifiedId != null"
>
#{modifiedId,jdbcType=BIGINT},
#{modifiedId,jdbcType=BIGINT},
</if>
</if>
<if
test=
"modifiedTime != null"
>
<if
test=
"modifiedTime != null"
>
#{modifiedTime,jdbcType=TIMESTAMP},
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</if>
</trim>
</trim>
</insert>
</insert>
<!--修改手机号-->
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountContact"
>
update acct_contact
<set
>
<if
test=
"mobilePhone != null"
>
mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
</if>
<if
test=
"deleteFlag != null"
>
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if
test=
"createdId != null"
>
created_id = #{createdId,jdbcType=BIGINT},
</if>
<if
test=
"createdTime != null"
>
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"modifiedId != null"
>
modified_id = #{modifiedId,jdbcType=BIGINT},
</if>
<if
test=
"modifiedTime != null"
>
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where acct_id = #{acctId,jdbcType=BIGINT}
</update>
</mapper>
</mapper>
\ No newline at end of file
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录