Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
ce863973
Commit
ce863973
authored
Sep 24, 2021
by
kongfm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户登录逻辑修改tzs 微信
parent
593e2ee1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
53 deletions
+101
-53
ControllerAop.java
...a/com/yeejoin/amos/boot/biz/common/aop/ControllerAop.java
+1
-1
WechatAccessDto.java
...yeejoin/amos/boot/module/tzs/api/dto/WechatAccessDto.java
+9
-0
WechatRelationDto.java
...ejoin/amos/boot/module/tzs/api/dto/WechatRelationDto.java
+3
-0
WechatRelation.java
...ejoin/amos/boot/module/tzs/api/entity/WechatRelation.java
+7
-3
WechatController.java
...amos/boot/module/tzs/biz/controller/WechatController.java
+78
-9
WechatRelationController.java
...t/module/tzs/biz/controller/WechatRelationController.java
+3
-40
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/aop/ControllerAop.java
View file @
ce863973
...
...
@@ -64,7 +64,7 @@ public class ControllerAop {
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
// 不需要添加请求头的接口
String
[]
url
=
new
String
[]{
"/api/user/selectInfo"
,
"/api/user/save/curCompany"
,
"/jcs/command/lookHtmlText"
,
"/jcs/common/duty-person/findByDutyAreaId"
,
"/tzs/wechatBack"
,
"/tzs/
wechat-relation/save"
,
"/tzs/
alert-called/saveMobile"
,
"/tzs/elevator/getElevatorInfo"
};
String
[]
url
=
new
String
[]{
"/api/user/selectInfo"
,
"/api/user/save/curCompany"
,
"/jcs/command/lookHtmlText"
,
"/jcs/common/duty-person/findByDutyAreaId"
,
"/tzs/wechatBack"
,
"/tzs/alert-called/saveMobile"
,
"/tzs/elevator/getElevatorInfo"
};
// 获取请求路径
for
(
String
uri
:
url
)
{
if
(
request
.
getRequestURI
().
indexOf
(
uri
)
!=
-
1
)
{
...
...
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/dto/WechatAccessDto.java
View file @
ce863973
...
...
@@ -25,4 +25,13 @@ public class WechatAccessDto {
@ApiModelProperty
(
value
=
"用户性别"
)
private
String
sex
;
@ApiModelProperty
(
value
=
"token信息"
)
private
String
token
;
@ApiModelProperty
(
value
=
"product"
)
private
String
product
;
@ApiModelProperty
(
value
=
"appKey"
)
private
String
appKey
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/dto/WechatRelationDto.java
View file @
ce863973
...
...
@@ -29,4 +29,7 @@ public class WechatRelationDto {
@ApiModelProperty
(
value
=
"验证码"
)
private
String
code
;
@ApiModelProperty
(
value
=
"amos 用户id"
)
private
String
userId
;
}
amos-boot-module/amos-boot-module-api/amos-boot-module-tzs-api/src/main/java/com/yeejoin/amos/boot/module/tzs/api/entity/WechatRelation.java
View file @
ce863973
...
...
@@ -4,11 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.yeejoin.amos.boot.biz.common.entity.BaseEntity
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.util.Date
;
/**
* 微信公众号openid与电话号对应关系表
...
...
@@ -38,4 +35,11 @@ public class WechatRelation {
@TableField
(
"phone"
)
private
String
phone
;
/**
* amos 用户id
*/
@TableField
(
"user_id"
)
private
String
userId
;
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/WechatController.java
View file @
ce863973
...
...
@@ -9,6 +9,7 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.boot.module.tzs.api.dto.WechatAccessDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.WechatMyTaskDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.WechatMyTaskListDto
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.WechatRelationDto
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.AlertFormValue
;
import
com.yeejoin.amos.boot.module.tzs.api.entity.WechatRelation
;
import
com.yeejoin.amos.boot.module.tzs.api.service.IDispatchTaskService
;
...
...
@@ -17,6 +18,10 @@ import com.yeejoin.amos.boot.module.tzs.biz.service.impl.AlertFormValueServiceIm
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.WechatRelationServiceImpl
;
import
com.yeejoin.amos.boot.module.tzs.biz.utils.HttpUtils
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel
;
import
com.yeejoin.amos.feign.privilege.util.DesUtil
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.SmsRecordModel
;
import
io.swagger.annotations.Api
;
...
...
@@ -25,6 +30,7 @@ import io.swagger.annotations.ApiParam;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -216,20 +222,78 @@ public class WechatController extends BaseController {
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据手机号发送短信验证码"
,
notes
=
"根据手机号发送短信验证码"
)
public
ResponseModel
<
Boolean
>
sendSmsCode
(
@PathVariable
String
tel
)
{
Boolean
flag
=
false
;
String
code
=
getrandom
();
HashMap
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
"sms
Code"
,
"SMS_TZS_0001
"
);
params
.
put
(
"sms
Type"
,
"MOBILE_REGISTER
"
);
params
.
put
(
"mobile"
,
tel
);
params
.
put
(
"code"
,
code
);
FeignClientResult
<
SmsRecordModel
>
result
=
Systemctl
.
smsClient
.
sendCommonSms
(
params
);
if
(
result
.
getStatus
()
==
200
)
{
flag
=
true
;
// code 保存在redis中 设置10分钟过期时间
redisUtils
.
set
(
"tel_code_"
+
tel
,
code
,
time
);
}
FeignClientResult
<
SmsRecordModel
>
result
=
Systemctl
.
smsClient
.
sendVerifyCode
(
params
);
return
ResponseHelper
.
buildResponse
(
flag
);
}
/**
* 新增微信公众号openid与电话号对应关系表
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/addUser"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增微信公众号openid与电话号对应关系表"
,
notes
=
"新增微信公众号openid与电话号对应关系表"
)
@Transactional
public
ResponseModel
<
WechatAccessDto
>
addUser
(
@RequestBody
WechatRelationDto
model
)
{
if
(
ValidationUtil
.
isEmpty
(
model
.
getOpenId
())
||
ValidationUtil
.
isEmpty
(
model
.
getPhone
())
||
ValidationUtil
.
isEmpty
(
model
.
getCode
()))
throw
new
BadRequest
(
"参数校验失败."
);
AgencyUserModel
agencyUserModel
=
new
AgencyUserModel
();
String
passwd
=
DesUtil
.
encode
(
"a_"
+
model
.
getPhone
(),
"qaz"
);
agencyUserModel
.
setUserName
(
model
.
getPhone
());
agencyUserModel
.
setRealName
(
model
.
getPhone
());
agencyUserModel
.
setLockStatus
(
"UNLOCK"
);
agencyUserModel
.
setPassword
(
passwd
);
agencyUserModel
.
setRePassword
(
passwd
);
agencyUserModel
.
setAgencyCode
(
"tzs"
);
agencyUserModel
.
setMobile
(
model
.
getPhone
());
agencyUserModel
.
setVerifyCode
(
model
.
getCode
());
FeignClientResult
<
AgencyUserModel
>
result
=
Privilege
.
agencyUserClient
.
mobileRegister
(
agencyUserModel
);
agencyUserModel
=
result
.
getResult
();
if
(
agencyUserModel
!=
null
&&
StringUtils
.
isNotBlank
(
agencyUserModel
.
getUserId
()))
{
model
.
setUserId
(
agencyUserModel
.
getUserId
());
wechatRelationServiceImpl
.
createWithModel
(
model
);
}
else
{
throw
new
BadRequest
(
"注册失败"
);
}
WechatAccessDto
dto
=
new
WechatAccessDto
();
dto
.
setOpenId
(
model
.
getOpenId
());
dto
.
setTel
(
model
.
getPhone
());
IdPasswordAuthModel
loninData
=
new
IdPasswordAuthModel
();
loninData
.
setLoginId
(
model
.
getPhone
());
loninData
.
setPassword
(
passwd
);
FeignClientResult
loginResult
=
Privilege
.
authClient
.
idpassword
(
loninData
);
if
(
loginResult
.
getStatus
()
==
200
)
{
HashMap
resultMap
=
(
HashMap
)
loginResult
.
getResult
();
dto
.
setToken
(
resultMap
.
get
(
"token"
).
toString
());
redisUtils
.
set
(
model
.
getPhone
()
+
"_token"
,
resultMap
.
get
(
"token"
).
toString
(),
25920000
l
);
}
return
ResponseHelper
.
buildResponse
(
dto
);
}
public
String
login
(
String
tel
)
{
String
token
=
""
;
IdPasswordAuthModel
loninData
=
new
IdPasswordAuthModel
();
loninData
.
setLoginId
(
tel
);
String
passwd
=
DesUtil
.
encode
(
"a_"
+
tel
,
"qaz"
);
loninData
.
setPassword
(
passwd
);
FeignClientResult
loginResult
=
Privilege
.
authClient
.
idpassword
(
loninData
);
if
(
loginResult
.
getStatus
()
==
200
)
{
HashMap
resultMap
=
(
HashMap
)
loginResult
.
getResult
();
token
=
resultMap
.
get
(
"token"
).
toString
();
redisUtils
.
set
(
tel
+
"_token"
,
resultMap
.
get
(
"token"
).
toString
(),
25920000
l
);
}
return
token
;
}
/**
* 根据微信code获取openId和手机号接口
...
...
@@ -252,6 +316,11 @@ public class WechatController extends BaseController {
WechatRelation
temp
=
wechatRelationServiceImpl
.
getOne
(
new
LambdaQueryWrapper
<
WechatRelation
>().
eq
(
WechatRelation:
:
getOpenId
,
openId
));
if
(
temp
!=
null
)
{
wechatAccessDto
.
setTel
(
temp
.
getPhone
());
if
(
redisUtils
.
hasKey
(
temp
.
getPhone
()
+
"_token"
))
{
wechatAccessDto
.
setToken
(
redisUtils
.
get
(
temp
.
getPhone
()
+
"_token"
).
toString
());
}
else
{
wechatAccessDto
.
setToken
(
this
.
login
(
temp
.
getPhone
()));
}
}
}
return
ResponseHelper
.
buildResponse
(
wechatAccessDto
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-tzs-biz/src/main/java/com/yeejoin/amos/boot/module/tzs/biz/controller/WechatRelationController.java
View file @
ce863973
package
com
.
yeejoin
.
amos
.
boot
.
module
.
tzs
.
biz
.
controller
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.Api
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
java.util.List
;
import
com.yeejoin.amos.boot.module.tzs.biz.service.impl.WechatRelationServiceImpl
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
io.swagger.annotations.Api
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.*
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.tzs.api.dto.WechatRelationDto
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 微信公众号openid与电话号对应关系表
...
...
@@ -35,29 +22,5 @@ public class WechatRelationController extends BaseController {
WechatRelationServiceImpl
wechatRelationServiceImpl
;
@Autowired
RedisUtils
redisUtils
;
/**
* 新增微信公众号openid与电话号对应关系表
*
* @return
*/
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@PostMapping
(
value
=
"/save"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"新增微信公众号openid与电话号对应关系表"
,
notes
=
"新增微信公众号openid与电话号对应关系表"
)
public
ResponseModel
<
WechatRelationDto
>
save
(
@RequestBody
WechatRelationDto
model
)
{
if
(
ValidationUtil
.
isEmpty
(
model
.
getOpenId
())
||
ValidationUtil
.
isEmpty
(
model
.
getPhone
())
||
ValidationUtil
.
isEmpty
(
model
.
getCode
()))
throw
new
BadRequest
(
"参数校验失败."
);
if
(!
model
.
getCode
().
equals
(
redisUtils
.
get
(
"tel_code_"
+
model
.
getPhone
())))
{
throw
new
BadRequest
(
"验证码验证失败!"
);
}
model
=
wechatRelationServiceImpl
.
createWithModel
(
model
);
return
ResponseHelper
.
buildResponse
(
model
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment