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
提交
7f61b368
提交
7f61b368
编写于
5月 22, 2019
作者:
dong.an
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
账号微服务
上级
e56e38ee
流水线
#9154
已失败 于阶段
in 0 second
变更
13
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
1156 行增加
和
3 行删除
+1156
-3
pom.xml
server/pom.xml
+28
-0
PropertiesConfiguration.java
...account/server/configuration/PropertiesConfiguration.java
+23
-0
Constants.java
...ica/cloud/account/account/server/constants/Constants.java
+14
-0
AccountBaseController.java
...ount/account/server/controller/AccountBaseController.java
+111
-0
AccountController.java
.../account/account/server/controller/AccountController.java
+208
-0
DemoController.java
...oud/account/account/server/controller/DemoController.java
+11
-3
Account.java
...com/pica/cloud/account/account/server/entity/Account.java
+271
-0
AccountMapper.java
...ca/cloud/account/account/server/mapper/AccountMapper.java
+26
-0
AccountReq.java
...com/pica/cloud/account/account/server/req/AccountReq.java
+67
-0
AccountService.java
.../cloud/account/account/server/service/AccountService.java
+20
-0
AccountServiceImpl.java
...count/account/server/service/impl/AccountServiceImpl.java
+50
-0
MobileSmsEntityContent.java
...d/account/account/server/util/MobileSmsEntityContent.java
+32
-0
AccountMapper.xml
server/src/main/resources/mybatis/AccountMapper.xml
+295
-0
未找到文件。
server/pom.xml
浏览文件 @
7f61b368
...
...
@@ -59,6 +59,10 @@
<artifactId>
pica-cloud-service-starter
</artifactId>
<version>
1.2.5-SNAPSHOT
</version>
<exclusions>
<exclusion>
<groupId>
com.pica.cloud.foundation
</groupId>
<artifactId>
pica-cloud-redis
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job-core
</artifactId>
...
...
@@ -70,6 +74,30 @@
</exclusions>
</dependency>
<dependency>
<groupId>
com.pica.cloud.foundation
</groupId>
<artifactId>
pica-cloud-utils
</artifactId>
<version>
2.0.1-SNAPSHOT
</version>
<exclusions>
<exclusion>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.dianping.cat
</groupId>
<artifactId>
cat-client
</artifactId>
</exclusion>
<exclusion>
<groupId>
com.pica.cloud.foundation
</groupId>
<artifactId>
pica-cloud-entity
</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--zipkin dependencies begin-->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
server/src/main/java/com/pica/cloud/account/account/server/configuration/PropertiesConfiguration.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
configuration
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
@RefreshScope
public
class
PropertiesConfiguration
{
@Value
(
"${pica.cloud.message.url}"
)
private
String
messageUrl
;
public
String
getMessageUrl
()
{
return
messageUrl
;
}
public
void
setMessageUrl
(
String
messageUrl
)
{
this
.
messageUrl
=
messageUrl
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/constants/Constants.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
constants
;
/**
* @author andong
* @create 2018/12/11
*/
public
class
Constants
{
private
Constants
()
{}
/** 批量短信url */
public
static
final
String
BATCH_SEND_MESSAGE
=
"/sms/send_batch_dif"
;
}
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountBaseController.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.alibaba.fastjson.JSON
;
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.util.MobileSmsEntityContent
;
import
com.pica.cloud.foundation.utils.controller.BaseController
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.foundation.utils.utils.CommonUtil
;
import
com.pica.cloud.foundation.utils.utils.HttpClientUtil
;
import
com.pica.cloud.foundation.utils.utils.json.Object2Map
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* controller基类
* @author andong
* @create 2019/5/21
*/
public
abstract
class
AccountBaseController
extends
BaseController
{
private
static
final
String
KEY_PREFIX
=
"token-doctor-"
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountBaseController
.
class
);
@Autowired
private
PropertiesConfiguration
configuration
;
//获取deviceInfo信息
public
String
getDeviceInfo
(
String
key
)
{
String
deviceInfo
=
super
.
getDeviceInfo
();
if
(
StringUtils
.
isBlank
(
key
)
||
StringUtils
.
isBlank
(
deviceInfo
))
{
return
StringUtils
.
EMPTY
;
}
try
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
deviceInfo
);
return
jsonObject
.
getString
(
key
);
}
catch
(
Exception
ex
)
{
return
StringUtils
.
EMPTY
;
}
}
//保存token,并返回token值(web或app,不包含h5)
public
String
saveToken
(
String
token
,
PicaUser
picaUser
)
{
if
(
StringUtils
.
isNotEmpty
(
token
))
{
picaUser
.
setToken
(
token
);
}
String
sysCode
=
super
.
getSysCode
();
if
(
"9"
.
equals
(
sysCode
))
{
sysCode
=
"saas"
;
}
else
if
(
"10"
.
equals
(
sysCode
))
{
sysCode
=
"app"
;
}
String
tokenValue
=
super
.
getRedisClient
().
get
(
KEY_PREFIX
+
picaUser
.
getId
().
toString
()
+
"-"
+
sysCode
);
if
(
StringUtils
.
isNotBlank
(
tokenValue
))
{
return
tokenValue
.
replace
(
"token-"
,
""
);
//token已经存在则直接返回
}
try
{
Map
<
String
,
String
>
data
=
Object2Map
.
objectToMapString
(
"yyyy-MM-dd HH:mm:ss"
,
picaUser
,
new
String
[
0
]);
data
.
put
(
"sysCode"
,
sysCode
);
return
super
.
getRedisClient
().
saveToken
(
data
,
365
*
24
*
3600
);
//token有效期365天
}
catch
(
Exception
ex
)
{
logger
.
error
(
"保存token失败,doctorId: {}"
,
picaUser
.
getId
());
return
StringUtils
.
EMPTY
;
}
}
//发送手机短信
public
void
sendMobileMessage
(
String
mobile
,
String
content
,
long
senderId
)
{
String
sysCodeStr
=
super
.
getSysCode
();
int
sysCode
=
10
;
//默认移动端
if
(
StringUtils
.
isNotBlank
(
sysCodeStr
))
{
try
{
sysCode
=
Integer
.
parseInt
(
sysCodeStr
);
}
catch
(
Exception
ex
)
{
logger
.
error
(
ex
.
getMessage
(),
ex
);
}
}
String
batchNo
=
CommonUtil
.
getBatchNo
(
sysCode
);
//短信批次号
Map
<
String
,
Object
>
batchMap
=
new
HashMap
();
//批量map
String
sign
=
StringUtils
.
EMPTY
;
//获取消息发送的签名
MobileSmsEntityContent
smsEntity
=
new
MobileSmsEntityContent
();
smsEntity
.
setMobile
(
mobile
);
smsEntity
.
setSms_entity_id
(
0
);
smsEntity
.
setContent
(
content
);
List
<
MobileSmsEntityContent
>
list
=
Arrays
.
asList
(
smsEntity
);
batchMap
.
put
(
"mobileSmsEntityContentList"
,
list
);
batchMap
.
put
(
"sign"
,
sign
);
batchMap
.
put
(
"userId"
,
senderId
);
batchMap
.
put
(
"batchNo"
,
batchNo
);
String
postData
=
JSON
.
toJSONString
(
batchMap
);
String
messageUrl
=
configuration
.
getMessageUrl
()
+
Constants
.
BATCH_SEND_MESSAGE
;
String
jsonObj
=
HttpClientUtil
.
httpExecute
(
messageUrl
,
postData
);
if
(
StringUtils
.
isNotBlank
(
jsonObj
))
{
logger
.
info
(
"发送短信成功,返回结果:{}"
,
jsonObj
);
}
else
{
logger
.
error
(
"发送短信失败"
);
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountController.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.pica.cloud.account.account.server.entity.Account
;
import
com.pica.cloud.account.account.server.req.AccountReq
;
import
com.pica.cloud.account.account.server.service.AccountService
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.utils.constants.CommonConstants
;
import
com.pica.cloud.foundation.utils.utils.CommonUtil
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
com.pica.cloud.foundation.utils.utils.ValidateUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.UUID
;
/**
* 账号相关controller
* @author andong
* @create 2019/5/20
*/
@Api
(
description
=
"账号管理"
)
@RestController
@RequestMapping
(
"/account"
)
public
class
AccountController
extends
AccountBaseController
{
private
final
String
AUTH_CODE_PREFIX
=
"authCode-"
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountController
.
class
);
@Autowired
private
AccountService
accountService
;
@Autowired
@Qualifier
(
"cacheMigrateClient"
)
private
ICacheClient
redisClient
;
@ApiOperation
(
"获取登录验证码"
)
@GetMapping
(
"/authCode"
)
public
PicaResponse
<
String
>
getAuthCode
(
@ApiParam
(
value
=
"手机号"
,
required
=
true
)
@RequestParam
(
"mobilePhone"
)
String
mobilePhone
,
@ApiParam
(
value
=
"验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码"
)
@RequestParam
(
value
=
"flag"
,
defaultValue
=
"0"
)
String
flag
)
{
this
.
checkMobilePhone
(
mobilePhone
);
String
authCode
=
CommonUtil
.
createValidateCode
();
//随机生成验证码
String
message
=
"您的验证码是"
+
authCode
+
",在10分钟内有效。如非本人操作,请忽略本短信!"
;
//判断账号是否已经存在
Account
account
=
accountService
.
getByMobilePhone
(
mobilePhone
);
long
senderId
=
account
==
null
?
0L
:
account
.
getId
();
//发送短信
super
.
sendMobileMessage
(
mobilePhone
,
message
,
senderId
);
//验证码保存到redis,失效时间10分钟
redisClient
.
set
(
this
.
getAuthCodeKey
(
mobilePhone
,
flag
),
authCode
,
600
);
return
PicaResponse
.
toResponse
(
authCode
);
}
@ApiOperation
(
"登录"
)
@PostMapping
(
"/login"
)
public
PicaResponse
<
String
>
login
(
@RequestBody
AccountReq
req
)
{
this
.
checkMobilePhone
(
req
.
getMobilePhone
());
Account
account
=
accountService
.
getByMobilePhone
(
req
.
getMobilePhone
());
//获取账号信息
if
(
account
==
null
)
{
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"该手机号尚未注册"
);
}
if
(
StringUtils
.
isBlank
(
req
.
getPassword
()))
{
//验证码登录
req
.
setFlag
(
"0"
);
this
.
checkAuthCode
(
req
);
//校验验证码
}
else
{
//密码登录
if
(
StringUtils
.
equals
(
req
.
getPassword
(),
account
.
getPassword
()))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的密码"
);
}
}
//更新最后登录时间
Account
update
=
new
Account
();
update
.
setId
(
account
.
getId
());
update
.
setLastLoginTime
(
new
Date
());
accountService
.
updateAccountById
(
update
);
//登录成功,清除旧token,生成新token
String
deviceType
=
super
.
getDeviceInfo
(
"device_type"
);
//1:pc 2:android 3:ios
String
newToken
;
switch
(
deviceType
)
{
//注册来源
case
"1"
:
//pc
//TODO
newToken
=
StringUtils
.
EMPTY
;
break
;
case
"2"
:
//android
case
"3"
:
//ios
//TODO 更新设备信息
newToken
=
StringUtils
.
EMPTY
;
break
;
default
:
//H5
newToken
=
this
.
generateH5Token
(
account
.
getId
());
}
return
PicaResponse
.
toResponse
(
newToken
);
}
@ApiOperation
(
"注册"
)
@PostMapping
(
"/register"
)
public
PicaResponse
<
String
>
register
(
@RequestBody
AccountReq
req
)
{
this
.
checkMobilePhone
(
req
.
getMobilePhone
());
this
.
checkAuthCode
(
req
);
String
deviceType
=
super
.
getDeviceInfo
(
"device_type"
);
//1:pc 2:android 3:ios
Account
account
=
new
Account
();
account
.
setMobilePhone
(
req
.
getMobilePhone
());
switch
(
deviceType
)
{
//注册来源
case
"1"
:
account
.
setRegisterSource
(
CommonConstants
.
SYSTEM_TYPE_P024_NO_3
);
//saas
break
;
case
"2"
:
account
.
setRegisterSource
(
CommonConstants
.
SYSTEM_TYPE_P024_NO_1
);
//android
break
;
case
"3"
:
account
.
setRegisterSource
(
CommonConstants
.
SYSTEM_TYPE_P024_NO_2
);
//ios
break
;
default
:
account
.
setRegisterSource
(
7
);
//H5注册
}
accountService
.
createAccount
(
account
);
//创建账号
//生成token并返回
try
{
if
(
account
.
getRegisterSource
().
intValue
()
==
7
)
{
//H5注册生成token
return
PicaResponse
.
toResponse
(
this
.
generateH5Token
(
account
.
getId
()));
}
else
{
//pc,android,ios注册生成token
//TODO 生成token; app注册更新设备信息
//super.saveToken(null, null);
return
PicaResponse
.
toResponse
(
StringUtils
.
EMPTY
);
}
}
catch
(
Exception
ex
)
{
logger
.
error
(
"生成token异常:{}"
,
ex
.
getMessage
());
return
PicaResponse
.
toResponse
(
StringUtils
.
EMPTY
);
}
}
@ApiOperation
(
"登录或注册"
)
@PostMapping
(
"/login-register"
)
public
PicaResponse
<
String
>
loginRegister
(
@RequestBody
AccountReq
req
)
{
this
.
checkMobilePhone
(
req
.
getMobilePhone
());
req
.
setPassword
(
null
);
//登录或注册,只能使用验证码
//判断账号是否已经存在
Account
account
=
accountService
.
getByMobilePhone
(
req
.
getMobilePhone
());
if
(
account
!=
null
)
{
return
this
.
login
(
req
);
//登录
}
else
{
return
this
.
register
(
req
);
//注册
}
}
//手机格式校验
private
void
checkMobilePhone
(
String
mobilePhone
)
{
if
(
StringUtils
.
isBlank
(
mobilePhone
)
||
!
ValidateUtils
.
isMobile
(
mobilePhone
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
}
}
//获取验证码redis key
private
String
getAuthCodeKey
(
String
mobilePhone
,
String
flag
)
{
return
AUTH_CODE_PREFIX
+
flag
+
"-"
+
EncryptCreateUtil
.
encrypt
(
mobilePhone
);
}
//校验验证码
private
void
checkAuthCode
(
AccountReq
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
=
this
.
getAuthCodeKey
(
req
.
getMobilePhone
(),
flag
);
String
cacheCode
=
redisClient
.
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
(),
"请输入正确的验证码"
);
}
redisClient
.
del
(
authCodeKey
);
//清除验证码
}
//生成H5 token
private
String
generateH5Token
(
Long
doctorId
)
{
//先清除旧token
String
tokenValue
=
"token-doctor-"
+
doctorId
.
toString
();
String
oldToken
=
redisClient
.
get
(
tokenValue
+
"-h5"
);
if
(
StringUtils
.
isNotBlank
(
oldToken
))
{
redisClient
.
del
(
oldToken
);
}
//生成新token
int
expiredSeconds
=
30
*
24
*
60
*
60
;
//H5 token有效期30天
String
newToken
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toUpperCase
();
String
tokenKey
=
"token-"
+
newToken
;
redisClient
.
set
(
tokenKey
,
tokenValue
,
expiredSeconds
);
redisClient
.
set
(
tokenValue
+
"-h5"
,
tokenKey
,
expiredSeconds
);
return
newToken
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/DemoController.java
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/demo"
)
@Api
(
value
=
"冒烟测试"
,
description
=
"测试 db,redis,config, zipkin, job
"
)
@Api
(
description
=
"测试
"
)
public
class
DemoController
{
@Autowired
@Qualifier
(
"cacheMigrateClient"
)
private
ICacheClient
redisClient
;
@GetMapping
(
"/test"
)
public
String
trace
()
{
return
"test"
;
public
String
trace
()
throws
Exception
{
String
token
=
redisClient
.
get
(
"token-doctor-100627531-saas"
);
redisClient
.
saveToken
(
null
,
1000
);
return
token
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/entity/Account.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
entity
;
import
java.util.Date
;
/**
* 账号
* @author andong
* @create 2019/5/20
*/
public
class
Account
{
private
Long
id
;
private
Integer
sex
;
private
String
name
;
private
String
mobilePhone
;
private
String
avatarImageUrl
;
private
String
email
;
private
String
qrcode
;
private
String
nickname
;
private
String
personalSign
;
private
Integer
deleteFlag
;
private
Long
creatId
;
private
Date
creatTime
;
private
Long
modifyId
;
private
Date
modifyTime
;
private
String
password
;
private
String
info
;
private
Integer
entireFlag
;
private
Date
regTime
;
private
Date
lastLoginTime
;
private
String
unionid
;
private
Integer
registerSource
;
private
String
comment
;
private
Integer
registerType
;
private
Date
firstLoginTime
;
private
String
card
;
private
Date
birthday
;
public
Long
getId
()
{
return
id
;
}
public
void
setId
(
Long
id
)
{
this
.
id
=
id
;
}
public
Integer
getSex
()
{
return
sex
;
}
public
void
setSex
(
Integer
sex
)
{
this
.
sex
=
sex
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getMobilePhone
()
{
return
mobilePhone
;
}
public
void
setMobilePhone
(
String
mobilePhone
)
{
this
.
mobilePhone
=
mobilePhone
;
}
public
String
getAvatarImageUrl
()
{
return
avatarImageUrl
;
}
public
void
setAvatarImageUrl
(
String
avatarImageUrl
)
{
this
.
avatarImageUrl
=
avatarImageUrl
;
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
String
getQrcode
()
{
return
qrcode
;
}
public
void
setQrcode
(
String
qrcode
)
{
this
.
qrcode
=
qrcode
;
}
public
String
getNickname
()
{
return
nickname
;
}
public
void
setNickname
(
String
nickname
)
{
this
.
nickname
=
nickname
;
}
public
String
getPersonalSign
()
{
return
personalSign
;
}
public
void
setPersonalSign
(
String
personalSign
)
{
this
.
personalSign
=
personalSign
;
}
public
Integer
getDeleteFlag
()
{
return
deleteFlag
;
}
public
void
setDeleteFlag
(
Integer
deleteFlag
)
{
this
.
deleteFlag
=
deleteFlag
;
}
public
Long
getCreatId
()
{
return
creatId
;
}
public
void
setCreatId
(
Long
creatId
)
{
this
.
creatId
=
creatId
;
}
public
Date
getCreatTime
()
{
return
creatTime
;
}
public
void
setCreatTime
(
Date
creatTime
)
{
this
.
creatTime
=
creatTime
;
}
public
Long
getModifyId
()
{
return
modifyId
;
}
public
void
setModifyId
(
Long
modifyId
)
{
this
.
modifyId
=
modifyId
;
}
public
Date
getModifyTime
()
{
return
modifyTime
;
}
public
void
setModifyTime
(
Date
modifyTime
)
{
this
.
modifyTime
=
modifyTime
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getInfo
()
{
return
info
;
}
public
void
setInfo
(
String
info
)
{
this
.
info
=
info
;
}
public
Integer
getEntireFlag
()
{
return
entireFlag
;
}
public
void
setEntireFlag
(
Integer
entireFlag
)
{
this
.
entireFlag
=
entireFlag
;
}
public
Date
getRegTime
()
{
return
regTime
;
}
public
void
setRegTime
(
Date
regTime
)
{
this
.
regTime
=
regTime
;
}
public
Date
getLastLoginTime
()
{
return
lastLoginTime
;
}
public
void
setLastLoginTime
(
Date
lastLoginTime
)
{
this
.
lastLoginTime
=
lastLoginTime
;
}
public
String
getUnionid
()
{
return
unionid
;
}
public
void
setUnionid
(
String
unionid
)
{
this
.
unionid
=
unionid
;
}
public
Integer
getRegisterSource
()
{
return
registerSource
;
}
public
void
setRegisterSource
(
Integer
registerSource
)
{
this
.
registerSource
=
registerSource
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
public
Integer
getRegisterType
()
{
return
registerType
;
}
public
void
setRegisterType
(
Integer
registerType
)
{
this
.
registerType
=
registerType
;
}
public
Date
getFirstLoginTime
()
{
return
firstLoginTime
;
}
public
void
setFirstLoginTime
(
Date
firstLoginTime
)
{
this
.
firstLoginTime
=
firstLoginTime
;
}
public
String
getCard
()
{
return
card
;
}
public
void
setCard
(
String
card
)
{
this
.
card
=
card
;
}
public
Date
getBirthday
()
{
return
birthday
;
}
public
void
setBirthday
(
Date
birthday
)
{
this
.
birthday
=
birthday
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/mapper/AccountMapper.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
mapper
;
import
com.pica.cloud.account.account.server.entity.Account
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
/**
* 账号Mapper
* @author andong
* @create 2019/5/20
*/
@Mapper
public
interface
AccountMapper
{
//根据id获取账号
Account
selectById
(
long
id
);
//新增账号
void
insertSelective
(
Account
account
);
//更新账号
int
updateByIdSelective
(
Account
account
);
//根据手机号获取账号
Account
getByMobilePhone
(
@Param
(
"mobilePhone"
)
String
mobilePhone
);
}
server/src/main/java/com/pica/cloud/account/account/server/req/AccountReq.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
req
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* @author andong
* @create 2019/5/21
*/
@ApiModel
public
class
AccountReq
{
@ApiModelProperty
(
"手机号"
)
private
String
mobilePhone
;
@ApiModelProperty
(
"密码"
)
private
String
password
;
@ApiModelProperty
(
"验证码"
)
private
String
authCode
;
@ApiModelProperty
(
"微信unionid"
)
private
String
unionid
;
@ApiModelProperty
(
"验证码类型"
)
private
String
flag
;
public
String
getMobilePhone
()
{
return
mobilePhone
;
}
public
void
setMobilePhone
(
String
mobilePhone
)
{
this
.
mobilePhone
=
mobilePhone
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getAuthCode
()
{
return
authCode
;
}
public
void
setAuthCode
(
String
authCode
)
{
this
.
authCode
=
authCode
;
}
public
String
getUnionid
()
{
return
unionid
;
}
public
void
setUnionid
(
String
unionid
)
{
this
.
unionid
=
unionid
;
}
public
String
getFlag
()
{
return
flag
;
}
public
void
setFlag
(
String
flag
)
{
this
.
flag
=
flag
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/service/AccountService.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
import
com.pica.cloud.account.account.server.entity.Account
;
/**
* @author andong
* @create 2019/5/20
*/
public
interface
AccountService
{
//根据手机号获取账号
Account
getByMobilePhone
(
String
mobilePhone
);
//创建账号
void
createAccount
(
Account
account
);
//更新账号信息
void
updateAccountById
(
Account
account
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/AccountServiceImpl.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
.
impl
;
import
com.pica.cloud.account.account.server.entity.Account
;
import
com.pica.cloud.account.account.server.mapper.AccountMapper
;
import
com.pica.cloud.account.account.server.service.AccountService
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
/**
* @author andong
* @create 2019/5/20
*/
@Service
public
class
AccountServiceImpl
implements
AccountService
{
@Autowired
private
AccountMapper
accountMapper
;
//根据手机号获取账号
@Override
public
Account
getByMobilePhone
(
String
mobilePhone
)
{
String
encryptMobilePhone
=
EncryptCreateUtil
.
encrypt
(
mobilePhone
);
return
accountMapper
.
getByMobilePhone
(
encryptMobilePhone
);
}
//创建账号
@Override
@Transactional
public
void
createAccount
(
Account
account
)
{
Date
currentTime
=
new
Date
();
account
.
setMobilePhone
(
EncryptCreateUtil
.
encrypt
(
account
.
getMobilePhone
()));
//手机号加密
account
.
setCreatId
(
0L
);
account
.
setModifyId
(
0L
);
account
.
setCreatTime
(
currentTime
);
account
.
setModifyTime
(
currentTime
);
account
.
setFirstLoginTime
(
currentTime
);
account
.
setLastLoginTime
(
currentTime
);
accountMapper
.
insertSelective
(
account
);
}
//更新账号信息
@Override
@Transactional
public
void
updateAccountById
(
Account
account
)
{
accountMapper
.
updateByIdSelective
(
account
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/util/MobileSmsEntityContent.java
0 → 100644
浏览文件 @
7f61b368
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
util
;
public
class
MobileSmsEntityContent
{
private
String
mobile
;
private
Integer
sms_entity_id
;
//业务相关 id 例如患教通知 list
private
String
content
;
public
String
getMobile
()
{
return
mobile
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
Integer
getSms_entity_id
()
{
return
sms_entity_id
;
}
public
void
setSms_entity_id
(
Integer
sms_entity_id
)
{
this
.
sms_entity_id
=
sms_entity_id
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
}
server/src/main/resources/mybatis/AccountMapper.xml
0 → 100644
浏览文件 @
7f61b368
<?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">
<mapper
namespace=
"com.pica.cloud.account.account.server.mapper.AccountMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.pica.cloud.account.account.server.entity.Account"
>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"sex"
jdbcType=
"INTEGER"
property=
"sex"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"mobile_phone"
jdbcType=
"VARCHAR"
property=
"mobilePhone"
/>
<result
column=
"avatar_image_url"
jdbcType=
"VARCHAR"
property=
"avatarImageUrl"
/>
<result
column=
"email"
jdbcType=
"VARCHAR"
property=
"email"
/>
<result
column=
"qrcode"
jdbcType=
"VARCHAR"
property=
"qrcode"
/>
<result
column=
"nickname"
jdbcType=
"VARCHAR"
property=
"nickname"
/>
<result
column=
"personal_sign"
jdbcType=
"VARCHAR"
property=
"personalSign"
/>
<result
column=
"delete_flag"
jdbcType=
"INTEGER"
property=
"deleteFlag"
/>
<result
column=
"creat_id"
jdbcType=
"INTEGER"
property=
"creatId"
/>
<result
column=
"creat_time"
jdbcType=
"TIMESTAMP"
property=
"creatTime"
/>
<result
column=
"modify_id"
jdbcType=
"INTEGER"
property=
"modifyId"
/>
<result
column=
"modify_time"
jdbcType=
"TIMESTAMP"
property=
"modifyTime"
/>
<result
column=
"password"
jdbcType=
"VARCHAR"
property=
"password"
/>
<result
column=
"info"
jdbcType=
"VARCHAR"
property=
"info"
/>
<result
column=
"entire_flag"
jdbcType=
"INTEGER"
property=
"entireFlag"
/>
<result
column=
"reg_time"
jdbcType=
"DATE"
property=
"regTime"
/>
<result
column=
"last_login_time"
jdbcType=
"TIMESTAMP"
property=
"lastLoginTime"
/>
<result
column=
"unionid"
jdbcType=
"VARCHAR"
property=
"unionid"
/>
<result
column=
"register_source"
jdbcType=
"INTEGER"
property=
"registerSource"
/>
<result
column=
"comment"
jdbcType=
"VARCHAR"
property=
"comment"
/>
<result
column=
"register_type"
jdbcType=
"INTEGER"
property=
"registerType"
/>
<result
column=
"first_login_time"
jdbcType=
"TIMESTAMP"
property=
"firstLoginTime"
/>
<result
column=
"card"
jdbcType=
"VARCHAR"
property=
"card"
/>
<result
column=
"birthday"
jdbcType=
"DATE"
property=
"birthday"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, sex, name, mobile_phone, avatar_image_url, email, qrcode, nickname, personal_sign, delete_flag,
creat_id, creat_time, modify_id, modify_time, password, info, entire_flag, reg_time, last_login_time,
unionid, register_source, comment, register_type, first_login_time, card, birthday
</sql>
<select
id=
"selectById"
parameterType=
"java.lang.Long"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from p_doctor
where id = #{id,jdbcType=INTEGER}
</select>
<insert
id=
"insertSelective"
parameterType=
"com.pica.cloud.account.account.server.entity.Account"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
insert into p_doctor
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"sex != null"
>
sex,
</if>
<if
test=
"name != null"
>
name,
</if>
<if
test=
"mobilePhone != null"
>
mobile_phone,
</if>
<if
test=
"avatarImageUrl != null"
>
avatar_image_url,
</if>
<if
test=
"email != null"
>
email,
</if>
<if
test=
"qrcode != null"
>
qrcode,
</if>
<if
test=
"nickname != null"
>
nickname,
</if>
<if
test=
"personalSign != null"
>
personal_sign,
</if>
<if
test=
"deleteFlag != null"
>
delete_flag,
</if>
<if
test=
"creatId != null"
>
creat_id,
</if>
<if
test=
"creatTime != null"
>
creat_time,
</if>
<if
test=
"modifyId != null"
>
modify_id,
</if>
<if
test=
"modifyTime != null"
>
modify_time,
</if>
<if
test=
"password != null"
>
password,
</if>
<if
test=
"info != null"
>
info,
</if>
<if
test=
"entireFlag != null"
>
entire_flag,
</if>
<if
test=
"regTime != null"
>
reg_time,
</if>
<if
test=
"lastLoginTime != null"
>
last_login_time,
</if>
<if
test=
"unionid != null"
>
unionid,
</if>
<if
test=
"registerSource != null"
>
register_source,
</if>
<if
test=
"comment != null"
>
comment,
</if>
<if
test=
"registerType != null"
>
register_type,
</if>
<if
test=
"firstLoginTime != null"
>
first_login_time,
</if>
<if
test=
"card != null"
>
card,
</if>
<if
test=
"birthday != null"
>
birthday,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"sex != null"
>
#{sex,jdbcType=INTEGER},
</if>
<if
test=
"name != null"
>
#{name,jdbcType=VARCHAR},
</if>
<if
test=
"mobilePhone != null"
>
#{mobilePhone,jdbcType=VARCHAR},
</if>
<if
test=
"avatarImageUrl != null"
>
#{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if
test=
"email != null"
>
#{email,jdbcType=VARCHAR},
</if>
<if
test=
"qrcode != null"
>
#{qrcode,jdbcType=VARCHAR},
</if>
<if
test=
"nickname != null"
>
#{nickname,jdbcType=VARCHAR},
</if>
<if
test=
"personalSign != null"
>
#{personalSign,jdbcType=VARCHAR},
</if>
<if
test=
"deleteFlag != null"
>
#{deleteFlag,jdbcType=INTEGER},
</if>
<if
test=
"creatId != null"
>
#{creatId,jdbcType=INTEGER},
</if>
<if
test=
"creatTime != null"
>
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"modifyId != null"
>
#{modifyId,jdbcType=INTEGER},
</if>
<if
test=
"modifyTime != null"
>
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"password != null"
>
#{password,jdbcType=VARCHAR},
</if>
<if
test=
"info != null"
>
#{info,jdbcType=VARCHAR},
</if>
<if
test=
"entireFlag != null"
>
#{entireFlag,jdbcType=INTEGER},
</if>
<if
test=
"regTime != null"
>
#{regTime,jdbcType=DATE},
</if>
<if
test=
"lastLoginTime != null"
>
#{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"unionid != null"
>
#{unionid,jdbcType=VARCHAR},
</if>
<if
test=
"registerSource != null"
>
#{registerSource,jdbcType=INTEGER},
</if>
<if
test=
"comment != null"
>
#{comment,jdbcType=VARCHAR},
</if>
<if
test=
"registerType != null"
>
#{registerType,jdbcType=INTEGER},
</if>
<if
test=
"firstLoginTime != null"
>
#{firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"card != null"
>
#{card,jdbcType=VARCHAR},
</if>
<if
test=
"birthday != null"
>
#{birthday,jdbcType=DATE},
</if>
</trim>
</insert>
<update
id=
"updateByIdSelective"
parameterType=
"com.pica.cloud.account.account.server.entity.Account"
>
update p_doctor
<set>
<if
test=
"sex != null"
>
sex = #{sex,jdbcType=INTEGER},
</if>
<if
test=
"name != null"
>
name = #{name,jdbcType=VARCHAR},
</if>
<if
test=
"mobilePhone != null"
>
mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
</if>
<if
test=
"avatarImageUrl != null"
>
avatar_image_url = #{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if
test=
"email != null"
>
email = #{email,jdbcType=VARCHAR},
</if>
<if
test=
"qrcode != null"
>
qrcode = #{qrcode,jdbcType=VARCHAR},
</if>
<if
test=
"nickname != null"
>
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if
test=
"personalSign != null"
>
personal_sign = #{personalSign,jdbcType=VARCHAR},
</if>
<if
test=
"deleteFlag != null"
>
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if
test=
"creatId != null"
>
creat_id = #{creatId,jdbcType=INTEGER},
</if>
<if
test=
"creatTime != null"
>
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"modifyId != null"
>
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if
test=
"modifyTime != null"
>
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"password != null"
>
password = #{password,jdbcType=VARCHAR},
</if>
<if
test=
"info != null"
>
info = #{info,jdbcType=VARCHAR},
</if>
<if
test=
"entireFlag != null"
>
entire_flag = #{entireFlag,jdbcType=INTEGER},
</if>
<if
test=
"regTime != null"
>
reg_time = #{regTime,jdbcType=DATE},
</if>
<if
test=
"lastLoginTime != null"
>
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"unionid != null"
>
unionid = #{unionid,jdbcType=VARCHAR},
</if>
<if
test=
"registerSource != null"
>
register_source = #{registerSource,jdbcType=INTEGER},
</if>
<if
test=
"comment != null"
>
comment = #{comment,jdbcType=VARCHAR},
</if>
<if
test=
"registerType != null"
>
register_type = #{registerType,jdbcType=INTEGER},
</if>
<if
test=
"firstLoginTime != null"
>
first_login_time = #{firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"card != null"
>
card = #{card,jdbcType=VARCHAR},
</if>
<if
test=
"birthday != null"
>
birthday = #{birthday,jdbcType=DATE},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select
id=
"getByMobilePhone"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from p_doctor
where mobile_phone = #{mobilePhone} and delete_flag = 1
limit 1
</select>
</mapper>
\ No newline at end of file
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录