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
83f735df
Commit
83f735df
authored
Aug 23, 2023
by
tianbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
weapp修改
parent
248b0fab
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
29 deletions
+84
-29
TzsAppController.java
...amos/boot/module/app/biz/controller/TzsAppController.java
+10
-4
TzsWeChatController.java
...s/boot/module/app/biz/controller/TzsWeChatController.java
+35
-0
StartPlatformTokenService.java
...odule/app/biz/service/impl/StartPlatformTokenService.java
+2
-12
TzBaseEnterpriseInfoServiceImpl.java
...app/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
+2
-0
TzsAuthServiceImpl.java
.../boot/module/app/biz/service/impl/TzsAuthServiceImpl.java
+35
-13
No files found.
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/controller/TzsAppController.java
View file @
83f735df
...
@@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.yeejoin.amos.boot.biz.common.utils.Menu
;
import
com.yeejoin.amos.boot.biz.common.utils.Menu
;
import
com.yeejoin.amos.boot.biz.common.utils.TreeParser
;
import
com.yeejoin.amos.boot.biz.common.utils.TreeParser
;
import
com.yeejoin.amos.boot.module.app.api.common.MobileLoginParam
;
import
com.yeejoin.amos.boot.module.app.api.common.MobileLoginParam
;
import
com.yeejoin.amos.boot.module.app.api.dto.EquipExportDto
;
import
com.yeejoin.amos.boot.module.app.api.dto.TzBaseEnterpriseInfoDto
;
import
com.yeejoin.amos.boot.module.app.api.dto.TzBaseEnterpriseInfoDto
;
import
com.yeejoin.amos.boot.module.app.api.entity.EquipmentCategory
;
import
com.yeejoin.amos.boot.module.app.api.entity.EquipmentCategory
;
import
com.yeejoin.amos.boot.module.app.api.entity.PageParam
;
import
com.yeejoin.amos.boot.module.app.api.entity.PageParam
;
...
@@ -30,7 +29,14 @@ import io.swagger.annotations.ApiOperation;
...
@@ -30,7 +29,14 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
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.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
...
@@ -256,8 +262,8 @@ public class TzsAppController {
...
@@ -256,8 +262,8 @@ public class TzsAppController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
value
=
"获取机器人登录token"
,
notes
=
"获取机器人登录token"
)
@ApiOperation
(
value
=
"获取机器人登录token"
,
notes
=
"获取机器人登录token"
)
@GetMapping
(
value
=
"/acquireToken"
)
@GetMapping
(
value
=
"/acquireToken"
)
synchronized
public
String
getRobotLoginToken
()
{
synchronized
public
ResponseModel
<
String
>
getRobotLoginToken
()
{
return
amosRequestContext
.
getToken
(
);
return
ResponseHelper
.
buildResponse
(
amosRequestContext
.
getToken
()
);
}
}
/**
/**
...
...
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/controller/TzsWeChatController.java
0 → 100644
View file @
83f735df
package
com
.
yeejoin
.
amos
.
boot
.
module
.
app
.
biz
.
controller
;
import
com.yeejoin.amos.boot.module.app.biz.service.impl.TzsAuthServiceImpl
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
@RestController
@Slf4j
@Api
(
tags
=
"wechat小程序接口"
)
@RequestMapping
(
value
=
"/wechat"
)
public
class
TzsWeChatController
{
@Autowired
AmosRequestContext
amosRequestContext
;
@Autowired
TzsAuthServiceImpl
authServiceImpl
;
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@ApiOperation
(
value
=
"获取机器人登录token"
,
notes
=
"获取机器人登录token"
)
@GetMapping
(
value
=
"/api/acquireToken"
)
synchronized
public
ResponseModel
<
String
>
getRobotLoginToken
()
{
return
ResponseHelper
.
buildResponse
(
authServiceImpl
.
getUserToken
());
}
}
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/service/impl/StartPlatformTokenService.java
View file @
83f735df
...
@@ -11,28 +11,18 @@ import com.yeejoin.amos.component.robot.AmosRequestContext;
...
@@ -11,28 +11,18 @@ import com.yeejoin.amos.component.robot.AmosRequestContext;
@Service
@Service
public
class
StartPlatformTokenService
{
public
class
StartPlatformTokenService
{
@Value
(
"${a
dmin
.product}"
)
@Value
(
"${a
mos.system.user
.product}"
)
String
product
;
String
product
;
@Value
(
"${a
dmin.app
key}"
)
@Value
(
"${a
mos.system.user.app-
key}"
)
String
appkey
;
String
appkey
;
@Value
(
"${admin.user}"
)
String
user
;
@Value
(
"${admin.password}"
)
String
password
;
@Value
(
"${amos.secret.key}"
)
String
secretKey
;
@Autowired
@Autowired
RedisUtil
redisUtil
;
RedisUtil
redisUtil
;
@Autowired
@Autowired
AmosRequestContext
amosRequestContext
;
AmosRequestContext
amosRequestContext
;
public
void
getToken
()
{
public
void
getToken
()
{
RequestContext
.
setProduct
(
product
);
RequestContext
.
setProduct
(
product
);
RequestContext
.
setAppKey
(
appkey
);
RequestContext
.
setAppKey
(
appkey
);
...
...
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/service/impl/TzBaseEnterpriseInfoServiceImpl.java
View file @
83f735df
...
@@ -39,6 +39,7 @@ import com.yeejoin.amos.feign.privilege.util.DesUtil;
...
@@ -39,6 +39,7 @@ import com.yeejoin.amos.feign.privilege.util.DesUtil;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
...
@@ -82,6 +83,7 @@ public class TzBaseEnterpriseInfoServiceImpl
...
@@ -82,6 +83,7 @@ public class TzBaseEnterpriseInfoServiceImpl
RegUnitIcServiceImpl
regUnitIcService
;
RegUnitIcServiceImpl
regUnitIcService
;
@Autowired
@Autowired
@Lazy
RegUnitInfoServiceImpl
regUnitInfoService
;
RegUnitInfoServiceImpl
regUnitInfoService
;
@Autowired
@Autowired
...
...
amos-boot-system-tzs/amos-boot-module-app/amos-boot-module-app-biz/src/main/java/com/yeejoin/amos/boot/module/app/biz/service/impl/TzsAuthServiceImpl.java
View file @
83f735df
...
@@ -48,6 +48,11 @@ public class TzsAuthServiceImpl implements TzsAuthService {
...
@@ -48,6 +48,11 @@ public class TzsAuthServiceImpl implements TzsAuthService {
@Value
(
"${cti.user.pwd}"
)
@Value
(
"${cti.user.pwd}"
)
private
String
ctiUserPwd
;
private
String
ctiUserPwd
;
@Value
(
"${amos.wechat.robot.user}"
)
private
String
weRobotUser
;
@Value
(
"${amos.wechat.robot.password}"
)
private
String
weRobotPassword
;
/**
/**
* saveUserRedis设置过期时间
* saveUserRedis设置过期时间
...
@@ -58,6 +63,7 @@ public class TzsAuthServiceImpl implements TzsAuthService {
...
@@ -58,6 +63,7 @@ public class TzsAuthServiceImpl implements TzsAuthService {
@Autowired
@Autowired
private
StartPlatformTokenService
startPlatformTokenService
;
private
StartPlatformTokenService
startPlatformTokenService
;
String
weChatToken
=
"WECHAT_TOKEN"
;
@Override
@Override
public
List
<
String
>
getUserRegionCode
()
{
public
List
<
String
>
getUserRegionCode
()
{
...
@@ -149,20 +155,18 @@ public class TzsAuthServiceImpl implements TzsAuthService {
...
@@ -149,20 +155,18 @@ public class TzsAuthServiceImpl implements TzsAuthService {
}
}
private
void
loginUser
(
String
userName
,
String
password
,
String
token
)
{
private
void
loginCtiUser
()
{
String
pwd
=
DesUtil
.
encode
(
password
,
"qaz"
);
String
passwd
=
DesUtil
.
encode
(
ctiUserPwd
,
"qaz"
);
IdPasswordAuthModel
loginData
=
new
IdPasswordAuthModel
();
IdPasswordAuthModel
loninData
=
new
IdPasswordAuthModel
();
loginData
.
setLoginId
(
userName
);
loninData
.
setLoginId
(
ctiUserName
);
loginData
.
setPassword
(
pwd
);
loninData
.
setPassword
(
passwd
);
FeignClientResult
loginResult
=
Privilege
.
authClient
.
idpassword
(
loginData
);
FeignClientResult
loginResult
=
Privilege
.
authClient
.
idpassword
(
loninData
);
if
(
loginResult
.
getStatus
()
==
200
)
{
if
(
loginResult
.
getStatus
()
==
200
)
{
HashMap
resultMap
=
(
HashMap
)
loginResult
.
getResult
();
HashMap
resultMap
=
(
HashMap
)
loginResult
.
getResult
();
redisUtils
.
set
(
RedisKey
.
CTI_USER_TOKEN
,
resultMap
.
get
(
"token"
).
toString
(),
redisRegionTimeSecond
);
redisUtils
.
set
(
token
,
resultMap
.
get
(
"token"
).
toString
(),
redisRegionTimeSecond
);
}
}
}
}
public
void
setRequestContext
()
{
public
void
setRequestContext
()
{
// 需要登录后台账号
// 需要登录后台账号
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
...
@@ -173,10 +177,10 @@ public class TzsAuthServiceImpl implements TzsAuthService {
...
@@ -173,10 +177,10 @@ public class TzsAuthServiceImpl implements TzsAuthService {
boolean
validToken
=
TokenOperation
.
refresh
(
redisUtils
.
get
(
RedisKey
.
CTI_USER_TOKEN
).
toString
());
boolean
validToken
=
TokenOperation
.
refresh
(
redisUtils
.
get
(
RedisKey
.
CTI_USER_TOKEN
).
toString
());
// 登陆
// 登陆
if
(!
validToken
)
{
if
(!
validToken
)
{
this
.
login
CtiUser
(
);
this
.
login
User
(
ctiUserName
,
ctiUserPwd
,
RedisKey
.
CTI_USER_TOKEN
);
}
}
}
else
{
// 登陆
}
else
{
// 登陆
this
.
login
CtiUser
(
);
this
.
login
User
(
ctiUserName
,
ctiUserPwd
,
RedisKey
.
CTI_USER_TOKEN
);
}
}
}
}
String
ctiToken
=
redisUtils
.
get
(
RedisKey
.
CTI_USER_TOKEN
).
toString
();
String
ctiToken
=
redisUtils
.
get
(
RedisKey
.
CTI_USER_TOKEN
).
toString
();
...
@@ -193,7 +197,6 @@ public class TzsAuthServiceImpl implements TzsAuthService {
...
@@ -193,7 +197,6 @@ public class TzsAuthServiceImpl implements TzsAuthService {
}
}
private
void
saveUserRedis
(
AgencyUserModel
user
,
String
token
)
{
private
void
saveUserRedis
(
AgencyUserModel
user
,
String
token
)
{
String
authToken
=
RedisKey
.
buildReginKey
(
user
.
getUserId
(),
token
);
String
authToken
=
RedisKey
.
buildReginKey
(
user
.
getUserId
(),
token
);
if
(
redisUtils
.
hasKey
(
authToken
))
{
if
(
redisUtils
.
hasKey
(
authToken
))
{
...
@@ -229,5 +232,23 @@ public class TzsAuthServiceImpl implements TzsAuthService {
...
@@ -229,5 +232,23 @@ public class TzsAuthServiceImpl implements TzsAuthService {
redisUtils
.
set
(
authToken
,
JSONObject
.
toJSONString
(
reginParams
),
redisRegionTimeSecond
);
redisUtils
.
set
(
authToken
,
JSONObject
.
toJSONString
(
reginParams
),
redisRegionTimeSecond
);
}
}
public
String
getUserToken
()
{
// 需要登录后台账号
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setProduct
(
"AMOS_STUDIO_WEB"
);
synchronized
(
TzsAuthServiceImpl
.
class
)
{
if
(
redisUtils
.
hasKey
(
weChatToken
))
{
// 验证token
boolean
validToken
=
TokenOperation
.
refresh
(
redisUtils
.
get
(
weChatToken
).
toString
());
// 登陆
if
(!
validToken
)
{
this
.
loginUser
(
weRobotUser
,
weRobotPassword
,
weChatToken
);
}
}
else
{
// 登陆
this
.
loginUser
(
weRobotUser
,
weRobotPassword
,
weChatToken
);
}
}
String
weToken
=
redisUtils
.
get
(
weChatToken
).
toString
();
return
weToken
;
}
}
}
\ No newline at end of file
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