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
提交
1870db71
提交
1870db71
编写于
8月 29, 2019
作者:
rushui.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
20190829 忘记密码与修改密码功能
上级
3a50f4e0
流水线
#13795
已失败 于阶段
in 1 second
变更
18
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
475 行增加
和
52 行删除
+475
-52
AccountBaseController.java
...ount/account/server/controller/AccountBaseController.java
+51
-7
ModifyMobileController.java
...unt/account/server/controller/ModifyMobileController.java
+44
-1
PasswordController.java
...account/account/server/controller/PasswordController.java
+77
-0
AccountUser.java
...pica/cloud/account/account/server/entity/AccountUser.java
+41
-0
ExceptionType.java
...ica/cloud/account/account/server/enums/ExceptionType.java
+4
-1
AccountInfoDetailMapper.java
...ccount/account/server/mapper/AccountInfoDetailMapper.java
+23
-8
AccountUserInfoMapper.java
.../account/account/server/mapper/AccountUserInfoMapper.java
+13
-0
BaseRequest.java
...om/pica/cloud/account/account/server/req/BaseRequest.java
+19
-1
ModifyMobileService.java
...d/account/account/server/service/ModifyMobileService.java
+7
-0
PasswordService.java
...cloud/account/account/server/service/PasswordService.java
+10
-0
LoginServiceImpl.java
...account/account/server/service/impl/LoginServiceImpl.java
+33
-23
ModifyMobileServiceImpl.java
.../account/server/service/impl/ModifyMobileServiceImpl.java
+27
-0
PasswordServiceImpl.java
...ount/account/server/service/impl/PasswordServiceImpl.java
+78
-0
RegisterServiceImpl.java
...ount/account/server/service/impl/RegisterServiceImpl.java
+16
-10
DateEntityUtils.java
...ca/cloud/account/account/server/util/DateEntityUtils.java
+10
-0
TokenUtils.java
...om/pica/cloud/account/account/server/util/TokenUtils.java
+0
-1
AccountInfoEntityMapper.xml
...er/src/main/resources/mybatis/AccountInfoEntityMapper.xml
+12
-0
AccountUserInfoEntityMapper.xml
...rc/main/resources/mybatis/AccountUserInfoEntityMapper.xml
+10
-0
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountBaseController.java
浏览文件 @
1870db71
...
...
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.pica.cloud.account.account.server.configuration.PropertiesConfiguration
;
import
com.pica.cloud.account.account.server.constants.Constants
;
import
com.pica.cloud.account.account.server.entity.AccountUser
;
import
com.pica.cloud.account.account.server.enums.ExceptionType
;
import
com.pica.cloud.account.account.server.util.PICAPSendMsgModel
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
...
...
@@ -19,6 +20,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.*
;
/**
...
...
@@ -129,20 +131,62 @@ public abstract class AccountBaseController extends BaseController {
}
}
public
int
getProductType
()
{
return
0
;
/**
* 账户信息
*
* @return
*/
public
AccountUser
getAccountUser
()
{
//无论是否登录,当前对象都应该存在
//把所有请求头信息都封装到当前模型中
String
token
=
this
.
getToken
();
AccountUser
accountUser
=
super
.
getRedisClient
().
getToken
(
token
,
AccountUser
.
class
);
accountUser
.
setLoginFrom
(
this
.
getSourceType
());
accountUser
.
setLoginPlatform
(
this
.
getProductType
());
accountUser
.
setLoginIp
(
super
.
getIpAddr
());
return
accountUser
;
}
/**
* 获取账户id
*
* @return
*/
public
Integer
getAcctId
()
{
try
{
AccountUser
accountUser
=
getAccountUser
();
return
accountUser
.
getAcctId
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
PicaException
(
ExceptionType
.
PICA_LOGIN_AGAIN
.
getCode
(),
ExceptionType
.
PICA_LOGIN_AGAIN
.
getMessage
());
}
}
public
int
getSourceType
()
{
return
0
;
/**
* 产品线类型:productType: 1.云鹊医(默认值) 2云鹊健康
*
* @return
*/
public
Integer
getProductType
()
{
HttpServletRequest
request
=
super
.
getRequest
();
String
str
=
request
.
getHeader
(
"productType"
);
if
(
StringUtils
.
isNotEmpty
(
str
))
{
return
Integer
.
parseInt
(
str
);
}
return
null
;
}
/**
*
账户信息
*
终端来源 sourceType:1.android 2.ios 3.web 4.wechat(例如微信小程序) 5.h5
*
* @return
*/
protected
AccountUser
getAccountUser
()
{
return
new
AccountUser
();
public
Integer
getSourceType
()
{
HttpServletRequest
request
=
super
.
getRequest
();
String
str
=
request
.
getHeader
(
"sourceType"
);
if
(
StringUtils
.
isNotEmpty
(
str
))
{
return
Integer
.
parseInt
(
str
);
}
return
null
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/ModifyMobileController.java
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.pica.cloud.account.account.server.entity.AccountUser
;
import
com.pica.cloud.account.account.server.entity.EncryptEntity
;
import
com.pica.cloud.account.account.server.enums.EnumsType
;
import
com.pica.cloud.account.account.server.enums.ExceptionType
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.service.ModifyMobileService
;
import
com.pica.cloud.account.account.server.util.AccountUtils
;
import
com.pica.cloud.account.account.server.util.CryptoUtil
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.sun.javafx.scene.control.skin.TableHeaderRow
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
@Api
(
"修改手机号资源"
)
@RestController
public
class
ModifyMobileController
{
public
class
ModifyMobileController
extends
AccountBaseController
{
@Autowired
private
AccountUtils
accountUtils
;
@Autowired
private
ModifyMobileService
modifyMobileService
;
@ApiOperation
(
"修改手机号"
)
@PostMapping
(
"/mobile/modify"
)
public
PicaResponse
modifyMobile
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
Integer
acctId
=
null
;
try
{
AccountUser
accountUser
=
super
.
getAccountUser
();
acctId
=
accountUser
.
getAcctId
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
PicaException
(
ExceptionType
.
PICA_LOGIN_AGAIN
.
getCode
(),
ExceptionType
.
PICA_LOGIN_AGAIN
.
getMessage
());
}
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
String
mobile
=
request
.
getMobile
();
accountUtils
.
checkMobilePhone
(
mobile
);
accountUtils
.
checkAuthCode
(
mobile
,
EnumsType
.
SYSCODE_TYPE_MODIFY_MOBILE
.
getCode
()
+
""
,
request
.
getSysCode
());
modifyMobileService
.
modify
(
acctId
,
mobile
);
return
PicaResponse
.
toResponse
(
"修改成功"
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/PasswordController.java
0 → 100644
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.pica.cloud.account.account.server.entity.AccountUser
;
import
com.pica.cloud.account.account.server.entity.EncryptEntity
;
import
com.pica.cloud.account.account.server.enums.EnumsType
;
import
com.pica.cloud.account.account.server.enums.ExceptionType
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
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.CryptoUtil
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@Api
(
"密码资源"
)
@RestController
@RequestMapping
(
"/password"
)
public
class
PasswordController
extends
AccountBaseController
{
@Autowired
private
PasswordService
passwordService
;
@Autowired
private
AccountUtils
accountUtils
;
/**
* 修改密码
*
* @return
*/
@ApiOperation
(
"修改密码接口"
)
@PostMapping
(
value
=
"/modify"
)
public
PicaResponse
modifyPassword
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
Integer
acctId
=
super
.
getAcctId
();
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
String
oldPwd
=
request
.
getOldPwd
();
String
password
=
request
.
getPassword
();
if
(!
StringUtils
.
isEmpty
(
password
)
&&
!
StringUtils
.
isEmpty
(
oldPwd
))
{
if
(!
password
.
equals
(
oldPwd
))
{
passwordService
.
modifyPassword
(
acctId
,
oldPwd
,
password
);
return
PicaResponse
.
toResponse
();
}
else
{
throw
new
PicaException
(
ExceptionType
.
PICA_PASSWORD_EQUAL
.
getCode
(),
ExceptionType
.
PICA_PASSWORD_EQUAL
.
getMessage
());
}
}
else
{
throw
new
PicaException
(
ExceptionType
.
PICA_PASSWORD_NULL
.
getCode
(),
ExceptionType
.
PICA_PASSWORD_NULL
.
getMessage
());
}
}
/**
* 忘记密码
*
* @return
*/
@ApiOperation
(
"忘记密码接口"
)
@PostMapping
(
value
=
"/reset"
)
public
PicaResponse
forgetPassword
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
Integer
acctId
=
super
.
getAcctId
();
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
accountUtils
.
checkMobilePhone
(
request
.
getMobile
());
accountUtils
.
checkAuthCode
(
request
.
getMobile
(),
EnumsType
.
SYSCODE_TYPE_RESET_PASSWORD
.
getCode
()
+
""
,
request
.
getSysCode
());
if
(
StringUtils
.
isEmpty
(
request
.
getPassword
()))
{
throw
new
PicaException
(
ExceptionType
.
PICA_PASSWORD_ERROR
.
getCode
(),
ExceptionType
.
PICA_PASSWORD_ERROR
.
getMessage
());
}
request
.
setAccId
(
acctId
);
passwordService
.
forgetPassword
(
request
);
return
PicaResponse
.
toResponse
();
}
}
server/src/main/java/com/pica/cloud/account/account/server/entity/AccountUser.java
浏览文件 @
1870db71
...
...
@@ -4,7 +4,16 @@ import com.pica.cloud.foundation.utils.entity.PicaUser;
public
class
AccountUser
extends
PicaUser
{
//账户id
private
Integer
acctId
;
//渠道来源
private
Integer
loginFrom
;
//平台来源
private
Integer
loginPlatform
;
//账户名
private
String
acctName
;
//登录ip
private
String
loginIp
;
public
Integer
getAcctId
()
{
return
acctId
;
...
...
@@ -13,6 +22,38 @@ public class AccountUser extends PicaUser {
public
void
setAcctId
(
Integer
acctId
)
{
this
.
acctId
=
acctId
;
}
public
Integer
getLoginFrom
()
{
return
loginFrom
;
}
public
void
setLoginFrom
(
Integer
loginFrom
)
{
this
.
loginFrom
=
loginFrom
;
}
public
Integer
getLoginPlatform
()
{
return
loginPlatform
;
}
public
void
setLoginPlatform
(
Integer
loginPlatform
)
{
this
.
loginPlatform
=
loginPlatform
;
}
public
String
getAcctName
()
{
return
acctName
;
}
public
void
setAcctName
(
String
acctName
)
{
this
.
acctName
=
acctName
;
}
public
String
getLoginIp
()
{
return
loginIp
;
}
public
void
setLoginIp
(
String
loginIp
)
{
this
.
loginIp
=
loginIp
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/enums/ExceptionType.java
浏览文件 @
1870db71
...
...
@@ -12,7 +12,10 @@ public enum ExceptionType {
PICA_NOT_REGISTER
(
"216508"
,
"未注册,请先注册"
),
PICA_PASSWORD_ERROR
(
"216509"
,
"请输入正确的密码"
),
PICA_IMAGE_PASSWORD_ERROR
(
"216511"
,
"图形验证码错误"
),
PICA_LOGIN_AGAIN
(
"216512"
,
"请重新登录"
);
PICA_LOGIN_AGAIN
(
"216512"
,
"请重新登录"
),
PICA_PASSWORD_NULL
(
"216513"
,
"密码不能为空"
),
PICA_PASSWORD_EQUAL
(
"216514"
,
"旧密码与新密码不能相同"
);
private
String
code
;
private
String
message
;
...
...
server/src/main/java/com/pica/cloud/account/account/server/mapper/AccountInfoDetailMapper.java
浏览文件 @
1870db71
...
...
@@ -4,12 +4,6 @@ package com.pica.cloud.account.account.server.mapper;
import
com.pica.cloud.account.account.server.entity.AccountInfoEntity
;
public
interface
AccountInfoDetailMapper
{
int
deleteByPrimaryKey
(
Integer
id
);
int
insert
(
AccountInfoEntity
record
);
int
insertSelective
(
AccountInfoEntity
record
);
/**
* 通过电话号码查询账号信息
*
...
...
@@ -27,11 +21,32 @@ public interface AccountInfoDetailMapper {
void
updateCreateInfo
(
int
acctId
);
/**
* 修改手机号
*
* @param record
* @return
*/
void
updateMobileByPrimaryKey
(
AccountInfoEntity
record
);
AccountInfoEntity
selectByPrimaryKey
(
Integer
id
);
/**
* 修改用户密码
*
* @param record
* @return
*/
void
updatePasswordByPrimaryKey
(
AccountInfoEntity
record
);
AccountInfoEntity
selectByPrimaryKey
(
Integer
id
);
int
updateByPrimaryKeySelective
(
AccountInfoEntity
record
);
int
updateByPrimaryKey
(
AccountInfoEntity
record
);
}
\ No newline at end of file
int
deleteByPrimaryKey
(
Integer
id
);
int
insert
(
AccountInfoEntity
record
);
int
insertSelective
(
AccountInfoEntity
record
);
}
server/src/main/java/com/pica/cloud/account/account/server/mapper/AccountUserInfoMapper.java
浏览文件 @
1870db71
...
...
@@ -10,8 +10,21 @@ public interface AccountUserInfoMapper {
int
insertSelective
(
AccountUserInfoEntity
record
);
/**
* 通过用户id查询用户信息
* @param id
* @return
*/
AccountUserInfoEntity
selectByPrimaryKey
(
Integer
id
);
/**
* 通过账户id查询用户信息
*
* @param acctId
* @return
*/
AccountUserInfoEntity
selectByAcctId
(
Integer
acctId
);
int
updateByPrimaryKeySelective
(
AccountUserInfoEntity
record
);
int
updateByPrimaryKey
(
AccountUserInfoEntity
record
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/req/BaseRequest.java
浏览文件 @
1870db71
...
...
@@ -5,9 +5,12 @@ import io.swagger.annotations.ApiModelProperty;
@ApiModel
public
class
BaseRequest
{
@ApiModelProperty
(
"账户id"
)
private
Integer
accId
;
private
String
mobile
;
private
String
password
;
@ApiModelProperty
(
"旧密码"
)
private
String
oldPwd
;
private
String
sysCode
;
private
int
flag
;
@ApiModelProperty
(
"产品线类型"
)
...
...
@@ -17,6 +20,13 @@ public class BaseRequest {
@ApiModelProperty
(
"登录ip"
)
private
String
loginIp
;
public
Integer
getAccId
()
{
return
accId
;
}
public
void
setAccId
(
Integer
accId
)
{
this
.
accId
=
accId
;
}
public
String
getMobile
()
{
return
mobile
;
...
...
@@ -34,6 +44,14 @@ public class BaseRequest {
this
.
password
=
password
;
}
public
String
getOldPwd
()
{
return
oldPwd
;
}
public
void
setOldPwd
(
String
oldPwd
)
{
this
.
oldPwd
=
oldPwd
;
}
public
String
getSysCode
()
{
return
sysCode
;
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/ModifyMobileService.java
0 → 100644
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
public
interface
ModifyMobileService
{
void
modify
(
Integer
acctId
,
String
mobile
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/PasswordService.java
0 → 100644
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
public
interface
PasswordService
{
void
modifyPassword
(
Integer
acctId
,
String
oldPwd
,
String
pwd
);
void
forgetPassword
(
BaseRequest
request
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/LoginServiceImpl.java
浏览文件 @
1870db71
...
...
@@ -3,11 +3,13 @@ package com.pica.cloud.account.account.server.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.pica.cloud.account.account.server.entity.Account
;
import
com.pica.cloud.account.account.server.entity.AccountInfoEntity
;
import
com.pica.cloud.account.account.server.entity.AccountUserInfoEntity
;
import
com.pica.cloud.account.account.server.entity.LogLoginEntity
;
import
com.pica.cloud.account.account.server.enums.EnumsType
;
import
com.pica.cloud.account.account.server.enums.ExceptionType
;
import
com.pica.cloud.account.account.server.log.PicaLogUtils
;
import
com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper
;
import
com.pica.cloud.account.account.server.mapper.AccountUserInfoMapper
;
import
com.pica.cloud.account.account.server.req.AccountReq
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.service.LoginService
;
...
...
@@ -34,6 +36,10 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private
AccountInfoDetailMapper
accountInfoDetailMapper
;
@Autowired
private
AccountUserInfoMapper
accountUserInfoMapper
;
@Autowired
private
PicaLogUtils
picaLogUtils
;
...
...
@@ -56,28 +62,30 @@ public class LoginServiceImpl implements LoginService {
String
password
=
request
.
getPassword
();
if
(
password
.
equals
(
EncryptCreateUtil
.
dencrypt
(
oldPwd
)))
{
//登陆成功,返回新的token
Integer
id
=
accountInfoEntity
.
getId
();
//通过账户id查询用户id
Date
currentTime
=
new
Date
();
Integer
acctId
=
accountInfoEntity
.
getId
();
AccountUserInfoEntity
accountUserInfoEntity
=
accountUserInfoMapper
.
selectByAcctId
(
acctId
);
int
productType
=
request
.
getProductType
();
int
sourceType
=
request
.
getSourceType
();
Account
account
=
new
Account
();
//account.setId(userId
.longValue());
account
.
setAcctId
(
i
d
);
account
.
setCreatTime
(
new
Date
()
);
account
.
setId
(
accountUserInfoEntity
.
getId
()
.
longValue
());
account
.
setAcctId
(
acctI
d
);
account
.
setCreatTime
(
currentTime
);
account
.
setMobilePhone
(
mobile
);
account
.
setRegisterSource
(
sourceType
);
String
newToken
=
tokenUtils
.
generateToken
(
account
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"token"
,
newToken
);
//todo:登陆成功是否要返回用户id
jsonObject
.
put
(
"userId"
,
newToken
);
jsonObject
.
put
(
"userId"
,
accountUserInfoEntity
.
getId
().
longValue
());
LogLoginEntity
entity
=
new
LogLoginEntity
();
entity
.
setAcctId
(
i
d
);
entity
.
setCreateId
(
i
d
);
entity
.
setCreateTime
(
new
Date
()
);
entity
.
setModifyId
(
i
d
);
entity
.
setModifyTime
(
new
Date
()
);
entity
.
setAcctId
(
acctI
d
);
entity
.
setCreateId
(
acctI
d
);
entity
.
setCreateTime
(
currentTime
);
entity
.
setModifyId
(
acctI
d
);
entity
.
setModifyTime
(
currentTime
);
entity
.
setDeleteFlag
(
1
);
entity
.
setLoginTime
(
new
Date
()
);
entity
.
setLoginTime
(
currentTime
);
entity
.
setProductType
(
productType
);
entity
.
setSourceType
(
request
.
getSourceType
());
entity
.
setLoginType
(
EnumsType
.
LOGIN_REGISTER
.
getCode
());
...
...
@@ -105,7 +113,9 @@ public class LoginServiceImpl implements LoginService {
if
(
accountInfoEntity
==
null
)
{
return
registerService
.
register
(
baseRequest
);
}
else
{
Integer
id
=
accountInfoEntity
.
getId
();
Date
currentTime
=
new
Date
();
Integer
acctId
=
accountInfoEntity
.
getId
();
AccountUserInfoEntity
accountUserInfoEntity
=
accountUserInfoMapper
.
selectByAcctId
(
acctId
);
//验证码登陆:只要相同即可成功
AccountReq
accountReq
=
new
AccountReq
();
accountReq
.
setAuthCode
(
baseRequest
.
getSysCode
());
...
...
@@ -113,23 +123,23 @@ public class LoginServiceImpl implements LoginService {
accountReq
.
setFlag
(
"0"
);
checkAuthCode
(
accountReq
);
Account
account
=
new
Account
();
//account.setId(userId
.longValue());
account
.
setAcctId
(
i
d
);
account
.
setCreatTime
(
new
Date
()
);
account
.
setId
(
accountUserInfoEntity
.
getId
()
.
longValue
());
account
.
setAcctId
(
acctI
d
);
account
.
setCreatTime
(
currentTime
);
account
.
setMobilePhone
(
mobile
);
account
.
setRegisterSource
(
sourceType
);
String
newToken
=
tokenUtils
.
generateToken
(
account
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"token"
,
newToken
);
//todo:登陆成功是否要返回用户id
jsonObject
.
put
(
"userId"
,
accountUserInfoEntity
.
getId
().
longValue
());
LogLoginEntity
entity
=
new
LogLoginEntity
();
entity
.
setAcctId
(
i
d
);
entity
.
setCreateId
(
i
d
);
entity
.
setCreateTime
(
new
Date
()
);
entity
.
setModifyId
(
i
d
);
entity
.
setModifyTime
(
new
Date
()
);
entity
.
setAcctId
(
acctI
d
);
entity
.
setCreateId
(
acctI
d
);
entity
.
setCreateTime
(
currentTime
);
entity
.
setModifyId
(
acctI
d
);
entity
.
setModifyTime
(
currentTime
);
entity
.
setDeleteFlag
(
1
);
entity
.
setLoginTime
(
new
Date
()
);
entity
.
setLoginTime
(
currentTime
);
entity
.
setProductType
(
productType
);
entity
.
setSourceType
(
baseRequest
.
getSourceType
());
entity
.
setLoginType
(
EnumsType
.
LOGIN_REGISTER
.
getCode
());
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/impl/ModifyMobileServiceImpl.java
0 → 100644
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
.
impl
;
import
com.pica.cloud.account.account.server.entity.AccountInfoEntity
;
import
com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper
;
import
com.pica.cloud.account.account.server.service.ModifyMobileService
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
@Service
public
class
ModifyMobileServiceImpl
implements
ModifyMobileService
{
@Autowired
private
AccountInfoDetailMapper
accountInfoDetailMapper
;
@Override
public
void
modify
(
Integer
acctId
,
String
mobile
)
{
AccountInfoEntity
accountInfoEntity
=
new
AccountInfoEntity
();
accountInfoEntity
.
setId
(
acctId
);
accountInfoEntity
.
setModifiedId
(
acctId
);
accountInfoEntity
.
setModifiedTime
(
new
Date
());
accountInfoEntity
.
setMobilePhone
(
EncryptCreateUtil
.
encrypt
(
mobile
));
accountInfoDetailMapper
.
updateMobileByPrimaryKey
(
accountInfoEntity
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/PasswordServiceImpl.java
0 → 100644
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
.
impl
;
import
com.pica.cloud.account.account.server.entity.AccountInfoEntity
;
import
com.pica.cloud.account.account.server.entity.LogPWDModifyEntity
;
import
com.pica.cloud.account.account.server.enums.EnumsType
;
import
com.pica.cloud.account.account.server.enums.ExceptionType
;
import
com.pica.cloud.account.account.server.log.PicaLogUtils
;
import
com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.service.PasswordService
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
@Service
public
class
PasswordServiceImpl
implements
PasswordService
{
@Autowired
private
AccountInfoDetailMapper
accountInfoDetailMapper
;
@Autowired
private
PicaLogUtils
picaLogUtils
;
@Override
public
void
modifyPassword
(
Integer
acctId
,
String
oldPwd
,
String
pwd
)
{
AccountInfoEntity
entity
=
accountInfoDetailMapper
.
selectByPrimaryKey
(
acctId
);
if
(
entity
.
getPassword
().
equals
(
EncryptCreateUtil
.
encrypt
(
oldPwd
)))
{
AccountInfoEntity
accountInfoEntity
=
new
AccountInfoEntity
();
accountInfoEntity
.
setId
(
acctId
);
accountInfoEntity
.
setModifiedId
(
acctId
);
accountInfoEntity
.
setModifiedTime
(
new
Date
());
accountInfoEntity
.
setPassword
(
EncryptCreateUtil
.
encrypt
(
pwd
));
accountInfoDetailMapper
.
updatePasswordByPrimaryKey
(
accountInfoEntity
);
//密码修改日志
Date
currentTime
=
new
Date
();
LogPWDModifyEntity
logPWDModifyEntity
=
new
LogPWDModifyEntity
();
logPWDModifyEntity
.
setCreatedId
(
acctId
);
logPWDModifyEntity
.
setCreatedTime
(
currentTime
);
logPWDModifyEntity
.
setDeleteFlag
(
1
);
logPWDModifyEntity
.
setMobilePhone
(
entity
.
getMobilePhone
());
logPWDModifyEntity
.
setModifiedId
(
acctId
);
logPWDModifyEntity
.
setModifiedTime
(
currentTime
);
logPWDModifyEntity
.
setOldPwd
(
EncryptCreateUtil
.
encrypt
(
oldPwd
));
logPWDModifyEntity
.
setNewPwd
(
EncryptCreateUtil
.
encrypt
(
pwd
));
logPWDModifyEntity
.
setLogType
(
EnumsType
.
LOG_TYPE_PASSWORD
.
getCode
());
picaLogUtils
.
info
(
logPWDModifyEntity
);
}
else
{
throw
new
PicaException
(
ExceptionType
.
PICA_PASSWORD_ERROR
.
getCode
(),
ExceptionType
.
PICA_PASSWORD_ERROR
.
getMessage
());
}
}
@Override
public
void
forgetPassword
(
BaseRequest
request
)
{
Integer
accId
=
request
.
getAccId
();
AccountInfoEntity
accountInfoEntity
=
new
AccountInfoEntity
();
accountInfoEntity
.
setId
(
accId
);
accountInfoEntity
.
setModifiedId
(
accId
);
accountInfoEntity
.
setModifiedTime
(
new
Date
());
accountInfoEntity
.
setPassword
(
EncryptCreateUtil
.
encrypt
(
request
.
getPassword
()));
accountInfoDetailMapper
.
updatePasswordByPrimaryKey
(
accountInfoEntity
);
//密码修改日志
Date
currentTime
=
new
Date
();
LogPWDModifyEntity
logPWDModifyEntity
=
new
LogPWDModifyEntity
();
logPWDModifyEntity
.
setCreatedId
(
accId
);
logPWDModifyEntity
.
setCreatedTime
(
currentTime
);
logPWDModifyEntity
.
setDeleteFlag
(
1
);
logPWDModifyEntity
.
setMobilePhone
(
request
.
getMobile
());
logPWDModifyEntity
.
setModifiedId
(
accId
);
logPWDModifyEntity
.
setModifiedTime
(
currentTime
);
logPWDModifyEntity
.
setOldPwd
(
""
);
logPWDModifyEntity
.
setNewPwd
(
EncryptCreateUtil
.
encrypt
(
request
.
getPassword
()));
logPWDModifyEntity
.
setLogType
(
EnumsType
.
LOG_TYPE_PASSWORD
.
getCode
());
picaLogUtils
.
info
(
logPWDModifyEntity
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/RegisterServiceImpl.java
浏览文件 @
1870db71
...
...
@@ -17,6 +17,7 @@ import com.pica.cloud.foundation.entity.PicaException;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -50,16 +51,21 @@ public class RegisterServiceImpl implements RegisterService {
//校验用户是否已经注册
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
mobile
);
if
(
accountInfoEntity
==
null
)
{
Date
currentTime
=
new
Date
();
int
productType
=
baseRequest
.
getProductType
();
int
sourceType
=
baseRequest
.
getSourceType
();
AccountInfoEntity
accountInfo
=
new
AccountInfoEntity
();
accountInfo
.
setMobilePhone
(
EncryptCreateUtil
.
encrypt
(
baseRequest
.
getMobile
()));
accountInfo
.
setPassword
(
EncryptCreateUtil
.
encrypt
(
baseRequest
.
getPassword
()));
accountInfo
.
setCreatedTime
(
new
Date
());
if
(!
StringUtils
.
isNotEmpty
(
baseRequest
.
getPassword
()))
{
accountInfo
.
setPassword
(
EncryptCreateUtil
.
encrypt
(
baseRequest
.
getPassword
()));
}
else
{
accountInfo
.
setPassword
(
""
);
}
accountInfo
.
setCreatedTime
(
currentTime
);
accountInfo
.
setCreatedId
(
0
);
accountInfo
.
setModifiedId
(
0
);
accountInfo
.
setModifiedTime
(
new
Date
()
);
accountInfo
.
setRegTime
(
new
Date
()
);
accountInfo
.
setModifiedTime
(
currentTime
);
accountInfo
.
setRegTime
(
currentTime
);
accountInfo
.
setDeleteFlag
(
1
);
accountInfo
.
setSex
(
0
);
accountInfo
.
setRegisterProduct
(
productType
);
...
...
@@ -72,14 +78,14 @@ public class RegisterServiceImpl implements RegisterService {
accountUserInfoEntity
.
setDeleteFlag
(
1
);
accountUserInfoEntity
.
setCreateId
(
acctId
);
accountUserInfoEntity
.
setModifyId
(
acctId
);
accountUserInfoEntity
.
setCreateTime
(
new
Date
()
);
accountUserInfoEntity
.
setModifyTime
(
new
Date
()
);
accountUserInfoEntity
.
setCreateTime
(
currentTime
);
accountUserInfoEntity
.
setModifyTime
(
currentTime
);
accountUserInfoMapper
.
insertSelective
(
accountUserInfoEntity
);
Integer
userId
=
accountUserInfoEntity
.
getId
();
Account
account
=
new
Account
();
account
.
setId
(
userId
.
longValue
());
account
.
setAcctId
(
acctId
);
account
.
setCreatTime
(
new
Date
()
);
account
.
setCreatTime
(
currentTime
);
account
.
setMobilePhone
(
mobile
);
account
.
setRegisterSource
(
sourceType
);
String
newToken
=
this
.
generateToken
(
account
);
...
...
@@ -89,11 +95,11 @@ public class RegisterServiceImpl implements RegisterService {
LogLoginEntity
entity
=
new
LogLoginEntity
();
entity
.
setAcctId
(
acctId
);
entity
.
setCreateId
(
acctId
);
entity
.
setCreateTime
(
new
Date
()
);
entity
.
setCreateTime
(
currentTime
);
entity
.
setModifyId
(
acctId
);
entity
.
setModifyTime
(
new
Date
()
);
entity
.
setModifyTime
(
currentTime
);
entity
.
setDeleteFlag
(
1
);
entity
.
setLoginTime
(
new
Date
()
);
entity
.
setLoginTime
(
currentTime
);
entity
.
setProductType
(
productType
);
entity
.
setSourceType
(
baseRequest
.
getSourceType
());
entity
.
setLoginType
(
EnumsType
.
LOGIN_REGISTER
.
getCode
());
...
...
server/src/main/java/com/pica/cloud/account/account/server/util/DateEntityUtils.java
0 → 100644
浏览文件 @
1870db71
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
util
;
public
class
DateEntityUtils
{
// TODO: 2019/8/29 封装通用性data
// public static <T> T processTime(T t) {
//
//
// }
}
server/src/main/java/com/pica/cloud/account/account/server/util/TokenUtils.java
浏览文件 @
1870db71
...
...
@@ -33,7 +33,6 @@ public class TokenUtils {
public
boolean
checkTokenStatus
(
String
token
)
{
String
str
=
cacheClient
.
get
(
"token-"
+
token
);
return
StringUtils
.
isBlank
(
str
);
}
...
...
server/src/main/resources/mybatis/AccountInfoEntityMapper.xml
浏览文件 @
1870db71
...
...
@@ -43,6 +43,18 @@
update account_info set created_id=#{acctId}, modified_id=#{acctId} where id=#{acctId}
</update>
<!--更新用户的手机号-->
<update
id=
"updateMobileByPrimaryKey"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountInfoEntity"
>
update account_info set modified_id=#{id}, modified_time=#{modifiedTime},mobile_phone=#{mobilePhone} where id=#{id}
</update>
<!--修改用户的密码-->
<update
id=
"updatePasswordByPrimaryKey"
parameterType=
"com.pica.cloud.account.account.server.entity.AccountInfoEntity"
>
update account_info set modified_id=#{id}, modified_time=now(),password=#{password} where id=#{id}
</update>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from account_info
where id = #{id,jdbcType=INTEGER}
...
...
server/src/main/resources/mybatis/AccountUserInfoEntityMapper.xml
浏览文件 @
1870db71
...
...
@@ -44,6 +44,16 @@
from account_user_info
where id = #{id,jdbcType=INTEGER}
</select>
<!--通过账户id查询信息-->
<select
id=
"selectByAcctId"
resultMap=
"BaseResultMap"
parameterType=
"java.lang.Integer"
>
select
<include
refid=
"Base_Column_List"
/>
from account_user_info
where acct_id = #{acctId,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
delete from account_user_info
where id = #{id,jdbcType=INTEGER}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录