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
60204813
Commit
60204813
authored
Jun 25, 2021
by
郭武斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*)删除冗余代码
parent
3b7d53fa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1048 additions
and
1052 deletions
+1048
-1052
BaseController.java
...ejoin/amos/boot/biz/common/controller/BaseController.java
+191
-195
ControllerAop.java
...m/yeejoin/amos/boot/module/jcs/biz/aop/ControllerAop.java
+128
-128
FeignAop.java
...va/com/yeejoin/amos/boot/module/jcs/biz/aop/FeignAop.java
+69
-69
UserController.java
...n/amos/boot/module/jcs/biz/controller/UserController.java
+346
-346
RemoteSecurityService.java
...ot/module/jcs/biz/service/impl/RemoteSecurityService.java
+314
-314
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/controller/BaseController.java
View file @
60204813
...
@@ -28,22 +28,22 @@ import java.util.HashMap;
...
@@ -28,22 +28,22 @@ import java.util.HashMap;
@RestController
@RestController
@RequestMapping
(
"/base"
)
@RequestMapping
(
"/base"
)
public
class
BaseController
{
public
class
BaseController
{
//
/**
//
/**
* 成功返回状态
//
* 成功返回状态
*/
//
*/
protected
static
final
String
SUCCESS
=
"SUCCESS"
;
//
protected static final String SUCCESS = "SUCCESS";
/**
//
/**
* 失败返回状态
//
* 失败返回状态
*/
//
*/
protected
static
final
String
FAILED
=
"FAILED"
;
//
protected static final String FAILED = "FAILED";
/**
//
/**
* 默认页大小
//
* 默认页大小
*/
//
*/
protected
static
final
int
DEFAULT_PAGE_SIZE
=
10
;
//
protected static final int DEFAULT_PAGE_SIZE = 10;
//
@Autowired
//
@Autowired
protected
HttpServletRequest
request
;
//
protected HttpServletRequest request;
@Autowired
@Autowired
private
RedisUtils
redisUtils
;
private
RedisUtils
redisUtils
;
...
@@ -52,92 +52,88 @@ public class BaseController {
...
@@ -52,92 +52,88 @@ public class BaseController {
* 获取token
* 获取token
**/
**/
protected
String
getToken
()
{
protected
String
getToken
()
{
String
authToken
=
request
.
getHeader
(
"token"
);
return
RequestContext
.
getToken
();
if
(
authToken
==
null
)
{
authToken
=
request
.
getHeader
(
"X-Access-Token"
);
}
return
authToken
;
}
}
/**
* 获取Product
**/
protected
String
getProduct
()
{
String
product
=
request
.
getHeader
(
"product"
);
if
(
product
==
null
)
{
product
=
request
.
getParameter
(
"product"
);
}
return
product
;
}
/**
* 获取AppKey
**/
protected
String
getAppKey
()
{
String
appKey
=
request
.
getHeader
(
"appKey"
);
if
(
appKey
==
null
)
{
appKey
=
request
.
getParameter
(
"appKey"
);
}
return
appKey
;
}
/**
* redi缓存选择的用户信息key
*
* @param userId
* @param token
* @return
*/
// private String buildKey(String userId, String token) {
//
//
// return "region_" + userId + "_" + token;
// /**
//
// * 获取Product
// **/
// protected String getProduct() {
// String product = request.getHeader("product");
// if (product == null) {
// product = request.getParameter("product");
// }
// return product;
// }
//
// /**
// * 获取AppKey
// **/
// protected String getAppKey() {
// String appKey = request.getHeader("appKey");
// if (appKey == null) {
// appKey = request.getParameter("appKey");
// }
// return appKey;
// }
// }
//
// /**
// * redi缓存选择的用户信息key
// *
// * @param userId
// * @param token
// * @return
// */
//// private String buildKey(String userId, String token) {
////
//// return "region_" + userId + "_" + token;
////
//// }
protected
String
buildKey
(
String
token
)
{
protected
String
buildKey
(
String
token
)
{
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
return
"region_"
+
token
;
return
"region_"
+
token
;
}
}
/**
//
/**
* 用户选择信息保存redis
//
* 用户选择信息保存redis
*/
//
*/
protected
void
saveSelectedOrgInfo
(
ReginParams
reginParams
)
{
//
protected void saveSelectedOrgInfo(ReginParams reginParams) {
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
redisUtils
.
set
(
buildKey
(
getToken
()),
JSONObject
.
toJSONString
(
reginParams
));
//
redisUtils.set(buildKey(getToken()), JSONObject.toJSONString(reginParams));
//
}
//
}
//
protected
void
saveUser
(
AgencyUserModel
agencyUserModel
)
{
//
protected void saveUser(AgencyUserModel agencyUserModel) {
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
redisUtils
.
set
(
getToken
(),
JSONObject
.
toJSONString
(
agencyUserModel
));
//
redisUtils.set(getToken(), JSONObject.toJSONString(agencyUserModel));
//
}
//
}
//
/**
//
/**
* 获取结构code
//
* 获取结构code
*
//
*
* @return
//
* @return
*/
//
*/
protected
String
getOrgCode
()
{
//
protected String getOrgCode() {
ReginParams
reginParams
=
getSelectedOrgInfo
();
//
ReginParams reginParams = getSelectedOrgInfo();
if
(
reginParams
==
null
)
{
//
if (reginParams == null) {
return
null
;
//
return null;
}
//
}
if
(
reginParams
.
getCompany
()
!=
null
)
{
//
if (reginParams.getCompany() != null) {
return
reginParams
.
getCompany
().
getOrgCode
();
//
return reginParams.getCompany().getOrgCode();
}
//
}
//
return
null
;
//
return null;
}
//
}
//
/**
/**
* 用户选择信心redis获取
* 用户选择信心redis获取
**/
**/
protected
ReginParams
getSelectedOrgInfo
()
{
protected
ReginParams
getSelectedOrgInfo
()
{
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
// return JSONObject.parseObject(redisUtils.get(buildKey(getUserId(), getToken())).toString(), ReginParams.class);
// return JSONObject.parseObject(redisUtils.get(buildKey(getUserId(), getToken())).toString(), ReginParams.class);
return
JSONObject
.
parseObject
(
redisUtils
.
get
(
buildKey
(
getToken
())).
toString
(),
ReginParams
.
class
);
return
JSONObject
.
parseObject
(
redisUtils
.
get
(
buildKey
(
RequestContext
.
getToken
())).
toString
(),
ReginParams
.
class
);
}
}
/**
/**
...
@@ -146,9 +142,9 @@ public class BaseController {
...
@@ -146,9 +142,9 @@ public class BaseController {
protected
AgencyUserModel
getUserInfo
()
{
protected
AgencyUserModel
getUserInfo
()
{
AgencyUserModel
userModel
=
null
;
AgencyUserModel
userModel
=
null
;
if
(
getToken
()
!=
null
)
{
if
(
getToken
()
!=
null
)
{
RequestContext
.
setToken
(
getToken
());
//
RequestContext.setToken(getToken());
RequestContext
.
setProduct
(
getProduct
());
//
RequestContext.setProduct(getProduct());
RequestContext
.
setAppKey
(
getAppKey
());
//
RequestContext.setAppKey(getAppKey());
FeignClientResult
<?>
feignClientResult
;
FeignClientResult
<?>
feignClientResult
;
try
{
try
{
feignClientResult
=
Privilege
.
agencyUserClient
.
getme
();
feignClientResult
=
Privilege
.
agencyUserClient
.
getme
();
...
@@ -162,109 +158,109 @@ public class BaseController {
...
@@ -162,109 +158,109 @@ public class BaseController {
return
userModel
;
return
userModel
;
}
}
//
/**
//
/**
* 获取当前登录用户id
//
* 获取当前登录用户id
**/
//
**/
protected
String
getUserId
()
{
//
protected String getUserId() {
String
userId
=
null
;
//
String userId = null;
if
(
getUserInfo
()
!=
null
)
{
//
if (getUserInfo() != null) {
userId
=
getUserInfo
().
getUserId
();
//
userId = getUserInfo().getUserId();
}
//
}
return
userId
;
//
return userId;
}
//
}
//
/**
//
/**
* 获取请求的cookies
//
* 获取请求的cookies
*
//
*
* @return
//
* @return
*/
//
*/
protected
HashMap
<
String
,
String
>
getCookInfoMap
()
{
//
protected HashMap<String, String> getCookInfoMap() {
HashMap
<
String
,
String
>
map
=
new
HashMap
<
String
,
String
>();
//
HashMap<String, String> map = new HashMap<String, String>();
Cookie
[]
cookies
=
request
.
getCookies
();
//
Cookie[] cookies = request.getCookies();
if
(
cookies
!=
null
)
{
//
if (cookies != null) {
for
(
Cookie
ck
:
cookies
)
{
//
for (Cookie ck : cookies) {
map
.
put
(
ck
.
getName
(),
ck
.
getValue
());
//
map.put(ck.getName(), ck.getValue());
}
//
}
}
//
}
return
map
;
//
return map;
}
//
}
//
/**
//
/**
* 获取登录用户getLoginOrgCode
//
* 获取登录用户getLoginOrgCode
**/
//
**/
protected
String
getLoginOrgCode
(
ReginParams
reginParams
)
{
//
protected String getLoginOrgCode(ReginParams reginParams) {
if
(
reginParams
==
null
)
{
//
if (reginParams == null) {
return
null
;
//
return null;
}
//
}
if
(
reginParams
.
getDepartment
()
!=
null
)
{
//
if (reginParams.getDepartment() != null) {
return
reginParams
.
getDepartment
().
getOrgCode
();
//
return reginParams.getDepartment().getOrgCode();
}
//
}
if
(
reginParams
.
getCompany
()
!=
null
)
{
//
if (reginParams.getCompany() != null) {
return
reginParams
.
getCompany
().
getOrgCode
();
//
return reginParams.getCompany().getOrgCode();
}
//
}
return
null
;
//
return null;
}
//
}
//
/**
//
/**
* 获取部门id
//
* 获取部门id
**/
//
**/
protected
Long
getDepartmentId
(
ReginParams
reginParams
)
{
//
protected Long getDepartmentId(ReginParams reginParams) {
if
(
reginParams
==
null
)
{
//
if (reginParams == null) {
return
null
;
//
return null;
}
//
}
if
(
reginParams
.
getDepartment
()
!=
null
)
{
//
if (reginParams.getDepartment() != null) {
return
reginParams
.
getDepartment
().
getSequenceNbr
();
//
return reginParams.getDepartment().getSequenceNbr();
}
//
}
return
null
;
//
return null;
}
//
}
//
/**
//
/**
* 获取公司id
//
* 获取公司id
**/
//
**/
protected
Long
getCompanyId
(
ReginParams
reginParams
)
{
//
protected Long getCompanyId(ReginParams reginParams) {
if
(
reginParams
==
null
)
{
//
if (reginParams == null) {
return
null
;
//
return null;
}
//
}
if
(
reginParams
.
getCompany
()
!=
null
)
{
//
if (reginParams.getCompany() != null) {
return
reginParams
.
getCompany
().
getSequenceNbr
();
//
return reginParams.getCompany().getSequenceNbr();
}
//
}
return
null
;
//
return null;
}
//
}
//
/**
//
/**
* <pre>
//
* <pre>
* 提取错误异常中的错误消息
//
* 提取错误异常中的错误消息
* </pre>
//
* </pre>
*
//
*
* <p>
//
* <p>
* 当实体类中对属相注解了以下类似的注解,需要用try.catch语句捕获异常,使用 #getErrorMessage(Exception)
//
* 当实体类中对属相注解了以下类似的注解,需要用try.catch语句捕获异常,使用 #getErrorMessage(Exception)
* 提取出异常信息NotNull(message = "属性不能为空!")
//
* 提取出异常信息NotNull(message = "属性不能为空!")
* </p>
//
* </p>
*
//
*
* @param e
//
* @param e
* @return
//
* @return
* @see {@code NotBlank} ... NotNull、NotEmpty...
//
* @see {@code NotBlank} ... NotNull、NotEmpty...
* @see {@code Valid}
//
* @see {@code Valid}
*/
//
*/
public
String
getErrorMessage
(
Exception
e
)
{
//
public String getErrorMessage(Exception e) {
StringBuilder
message
=
new
StringBuilder
();
//
StringBuilder message = new StringBuilder();
if
(
e
instanceof
TransactionSystemException
)
{
//
if (e instanceof TransactionSystemException) {
TransactionSystemException
exception
=
(
TransactionSystemException
)
e
;
//
TransactionSystemException exception = (TransactionSystemException) e;
if
(
exception
.
getRootCause
()
instanceof
ConstraintViolationException
)
{
//
if (exception.getRootCause() instanceof ConstraintViolationException) {
ConstraintViolationException
root
=
(
ConstraintViolationException
)
exception
.
getRootCause
();
//
ConstraintViolationException root = (ConstraintViolationException) exception.getRootCause();
root
.
getConstraintViolations
().
forEach
(
constraintViolation
->
{
//
root.getConstraintViolations().forEach(constraintViolation -> {
message
.
append
(
constraintViolation
.
getMessageTemplate
());
//
message.append(constraintViolation.getMessageTemplate());
});
//
});
}
else
{
//
} else {
message
.
append
(
e
.
getMessage
());
//
message.append(e.getMessage());
}
//
}
}
else
if
(
e
instanceof
ConstraintViolationException
)
{
//
} else if (e instanceof ConstraintViolationException) {
((
ConstraintViolationException
)
e
).
getConstraintViolations
()
//
((ConstraintViolationException) e).getConstraintViolations()
.
forEach
(
constraintViolation
->
message
.
append
(
constraintViolation
.
getMessageTemplate
()));
//
.forEach(constraintViolation -> message.append(constraintViolation.getMessageTemplate()));
}
else
{
//
} else {
message
.
append
(
"操作异常!"
);
//
message.append("操作异常!");
}
//
}
return
message
.
toString
();
//
return message.toString();
}
//
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/aop/ControllerAop.java
View file @
60204813
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
aop
;
//package com.yeejoin.amos.boot.module.jcs.biz.aop;
//
import
com.alibaba.fastjson.JSONObject
;
//import com.alibaba.fastjson.JSONObject;
import
com.yeejoin.amos.boot.biz.common.bo.CompanyBo
;
//import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import
com.yeejoin.amos.boot.biz.common.bo.DepartmentBo
;
//import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
//import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import
com.yeejoin.amos.boot.biz.common.bo.RoleBo
;
//import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
//import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService
;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
//import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
//import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
//import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
//import com.yeejoin.amos.feign.privilege.model.RoleModel;
import
org.aspectj.lang.JoinPoint
;
//import org.aspectj.lang.JoinPoint;
import
org.aspectj.lang.annotation.AfterReturning
;
//import org.aspectj.lang.annotation.AfterReturning;
import
org.aspectj.lang.annotation.Aspect
;
//import org.aspectj.lang.annotation.Aspect;
import
org.aspectj.lang.annotation.Before
;
//import org.aspectj.lang.annotation.Before;
import
org.aspectj.lang.annotation.Pointcut
;
//import org.aspectj.lang.annotation.Pointcut;
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.stereotype.Component
;
//import org.springframework.stereotype.Component;
import
org.springframework.web.context.request.RequestContextHolder
;
//import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
//import org.springframework.web.context.request.ServletRequestAttributes;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
//import org.typroject.tyboot.core.foundation.utils.Bean;
//
import
javax.servlet.http.HttpServletRequest
;
//import javax.servlet.http.HttpServletRequest;
import
java.util.Arrays
;
//import java.util.Arrays;
import
java.util.List
;
//import java.util.List;
import
java.util.Map
;
//import java.util.Map;
//
/**
///**
* controller层切面 用于用户数据缓存 供 sql自动填充使用
// * controller层切面 用于用户数据缓存 供 sql自动填充使用
*
// *
* @author Admin
// * @author Admin
*/
// */
@Aspect
//@Aspect
@Component
//@Component
public
class
ControllerAop
{
//public class ControllerAop {
/**
// /**
* saveUserRedis设置过期时间
// * saveUserRedis设置过期时间
*/
// */
@Value
(
"${redis_region_time_second}"
)
// @Value("${redis_region_time_second}")
private
Long
redisRegionTimeSecond
;
// private Long redisRegionTimeSecond;
@Autowired
// @Autowired
private
RemoteSecurityService
remoteSecurityService
;
// private RemoteSecurityService remoteSecurityService;
//
@Autowired
// @Autowired
private
RedisUtils
redisUtils
;
// private RedisUtils redisUtils;
//
@Pointcut
(
"execution(public * com.yeejoin.amos.boot.module.jcs.biz.controller..*(..))"
)
// @Pointcut("execution(public * com.yeejoin.amos.boot.module.jcs.biz.controller..*(..))")
public
void
userCache
()
{
// public void userCache() {
//
}
// }
//
@Before
(
"userCache()"
)
// @Before("userCache()")
public
void
doBefore
(
JoinPoint
joinPoint
)
throws
Throwable
{
// public void doBefore(JoinPoint joinPoint) throws Throwable {
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
attributes
.
getRequest
();
String
token
=
request
.
getHeader
(
"token"
);
if
(
token
!=
null
)
{
//验证token有效性,防止token失效
AgencyUserModel
userModel
;
try
{
userModel
=
remoteSecurityService
.
getAgencyUser
();
if
(
userModel
==
null
)
{
throw
new
Exception
(
"无法获取用户信息"
);
}
}
catch
(
Exception
e
)
{
//删除失效token缓存
redisUtils
.
del
(
buildKey
(
token
));
throw
new
RuntimeException
(
e
.
getMessage
());
}
// 不需要添加请求头的接口
String
[]
url
=
new
String
[]{
"/api/user/selectInfo"
,
"/api/user/save/curCompany"
};
// 获取请求路径
if
(
Arrays
.
asList
(
url
).
contains
(
request
.
getRequestURI
()))
{
// 暂无需要
}
else
{
if
(!
redisUtils
.
hasKey
(
buildKey
(
token
)))
{
saveUserRedis
(
userModel
,
token
);
}
}
}
System
.
out
.
println
(
redisUtils
.
get
(
buildKey
(
token
)));
}
public
void
saveUserRedis
(
AgencyUserModel
user
,
String
token
)
{
CompanyBo
company
=
new
CompanyBo
();
DepartmentBo
department
=
new
DepartmentBo
();
RoleBo
role
=
new
RoleBo
();
CompanyModel
companyM
=
user
.
getCompanys
().
get
(
0
);
Bean
.
copyExistPropertis
(
companyM
,
company
);
Map
<
Long
,
List
<
DepartmentModel
>>
mapDepartments
=
user
.
getCompanyDepartments
();
DepartmentModel
departmentM
=
mapDepartments
.
get
(
companyM
.
getSequenceNbr
()).
get
(
0
);
Bean
.
copyExistPropertis
(
departmentM
,
department
);
Map
<
Long
,
List
<
RoleModel
>>
roles
=
user
.
getOrgRoles
();
Long
sequenceNbr
;
if
(
departmentM
==
null
)
{
sequenceNbr
=
null
;
}
else
{
sequenceNbr
=
departmentM
.
getSequenceNbr
();
}
RoleModel
roleM
=
null
;
if
(
sequenceNbr
==
null
)
{
roleM
=
roles
.
get
(
companyM
.
getSequenceNbr
()).
get
(
0
);
}
else
{
roleM
=
roles
.
get
(
sequenceNbr
).
get
(
0
);
}
Bean
.
copyExistPropertis
(
roleM
,
role
);
ReginParams
reginParams
=
new
ReginParams
();
reginParams
.
setCompany
(
company
);
reginParams
.
setRole
(
role
);
reginParams
.
setDepartment
(
department
);
reginParams
.
setUserModel
(
user
);
redisUtils
.
set
(
buildKey
(
token
),
JSONObject
.
toJSONString
(
reginParams
),
redisRegionTimeSecond
);
}
public
String
buildKey
(
String
token
)
{
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//return "region_" + userId + "_" + token;
return
"region_"
+
token
;
}
@AfterReturning
(
returning
=
"ret"
,
pointcut
=
"userCache()"
)
public
void
doAfterReturning
(
Object
ret
)
throws
Throwable
{
//统一redis管理
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
// HttpServletRequest request = attributes.getRequest();
// String token = request.getHeader("token");
// String token = request.getHeader("token");
// if (token != null) {
// if (token != null) {
// GlobalCache.paramMap.remove(token);
// //验证token有效性,防止token失效
// AgencyUserModel userModel;
// try {
// userModel = remoteSecurityService.getAgencyUser();
// if (userModel == null) {
// throw new Exception("无法获取用户信息");
// }
// } catch (Exception e) {
// //删除失效token缓存
// redisUtils.del(buildKey(token));
// throw new RuntimeException(e.getMessage());
// }
// // 不需要添加请求头的接口
// String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany"};
// // 获取请求路径
// if (Arrays.asList(url).contains(request.getRequestURI())) {
// // 暂无需要
// } else {
// if (!redisUtils.hasKey(buildKey(token))) {
// saveUserRedis(userModel, token);
// }
// }
// }
// }
}
// System.out.println(redisUtils.get(buildKey(token)));
}
// }
//
// public void saveUserRedis(AgencyUserModel user, String token) {
// CompanyBo company = new CompanyBo();
// DepartmentBo department = new DepartmentBo();
// RoleBo role = new RoleBo();
// CompanyModel companyM = user.getCompanys().get(0);
// Bean.copyExistPropertis(companyM, company);
// Map<Long, List<DepartmentModel>> mapDepartments = user.getCompanyDepartments();
// DepartmentModel departmentM = mapDepartments.get(companyM.getSequenceNbr()).get(0);
// Bean.copyExistPropertis(departmentM, department);
// Map<Long, List<RoleModel>> roles = user.getOrgRoles();
// Long sequenceNbr;
// if (departmentM == null) {
// sequenceNbr = null;
// } else {
// sequenceNbr = departmentM.getSequenceNbr();
// }
// RoleModel roleM = null;
// if (sequenceNbr == null) {
// roleM = roles.get(companyM.getSequenceNbr()).get(0);
// } else {
// roleM = roles.get(sequenceNbr).get(0);
// }
// Bean.copyExistPropertis(roleM, role);
// ReginParams reginParams = new ReginParams();
// reginParams.setCompany(company);
// reginParams.setRole(role);
// reginParams.setDepartment(department);
// reginParams.setUserModel(user);
// redisUtils.set(buildKey(token), JSONObject.toJSONString(reginParams), redisRegionTimeSecond);
// }
// public String buildKey(String token) {
// //由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
// //return "region_" + userId + "_" + token;
// return "region_"+ token;
// }
//
// @AfterReturning(returning = "ret", pointcut = "userCache()")
// public void doAfterReturning(Object ret) throws Throwable {
// //统一redis管理
//// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//// HttpServletRequest request = attributes.getRequest();
//// String token = request.getHeader("token");
//// if (token != null) {
//// GlobalCache.paramMap.remove(token);
//// }
// }
//}
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/aop/FeignAop.java
View file @
60204813
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
aop
;
//
package com.yeejoin.amos.boot.module.jcs.biz.aop;
//
//
import
org.aspectj.lang.JoinPoint
;
//
import org.aspectj.lang.JoinPoint;
import
org.aspectj.lang.annotation.AfterReturning
;
//
import org.aspectj.lang.annotation.AfterReturning;
import
org.aspectj.lang.annotation.Aspect
;
//
import org.aspectj.lang.annotation.Aspect;
import
org.aspectj.lang.annotation.Before
;
//
import org.aspectj.lang.annotation.Before;
import
org.aspectj.lang.annotation.Pointcut
;
//
import org.aspectj.lang.annotation.Pointcut;
import
org.springframework.stereotype.Component
;
//
import org.springframework.stereotype.Component;
import
org.springframework.web.context.request.RequestContextHolder
;
//
import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
//
import org.springframework.web.context.request.ServletRequestAttributes;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
//
import org.typroject.tyboot.core.foundation.context.RequestContext;
//
import
javax.servlet.http.HttpServletRequest
;
//
import javax.servlet.http.HttpServletRequest;
import
java.util.Arrays
;
//
import java.util.Arrays;
//
//
/**
/
//
**
* feign请求header设置
//
* feign请求header设置
* @author DELL
//
* @author DELL
*
//
*
*/
//
*/
@Aspect
//
@Aspect
@Component
//
@Component
public
class
FeignAop
{
//
public class FeignAop {
//
//
//
@Pointcut
(
"execution(public * com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService.*(..))"
)
//
@Pointcut("execution(public * com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService.*(..))")
public
void
webLog
(){}
//
public void webLog(){}
//
/**
//
/**
* 前置通知:在连接点之前执行的通知
//
* 前置通知:在连接点之前执行的通知
* @param joinPoint
//
* @param joinPoint
* @throws Throwable
//
* @throws Throwable
*/
//
*/
@Before
(
"webLog()"
)
//
@Before("webLog()")
public
void
doBefore
(
JoinPoint
joinPoint
)
throws
Throwable
{
//
public void doBefore(JoinPoint joinPoint) throws Throwable {
// 接收到请求,记录请求内容
//
// 接收到请求,记录请求内容
ServletRequestAttributes
attributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
//
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest
request
=
attributes
.
getRequest
();
//
HttpServletRequest request = attributes.getRequest();
//不需要添加请求头的接口
//
//不需要添加请求头的接口
String
[]
url
=
new
String
[]{
"/api/user/mobile/login"
};
//
String[] url=new String[]{"/api/user/mobile/login"};
//获取请求路径
//
//获取请求路径
if
(
Arrays
.
asList
(
url
).
contains
(
request
.
getRequestURI
())){
//
if(Arrays.asList(url).contains(request.getRequestURI())){
//暂无需要
//
//暂无需要
}
else
{
//
}else{
//
String
token
=
request
.
getHeader
(
"token"
);
//
String token = request.getHeader("token");
String
product
=
request
.
getHeader
(
"product"
);
//
String product = request.getHeader("product");
String
appKey
=
request
.
getHeader
(
"appKey"
);
//
String appKey = request.getHeader("appKey");
if
(
token
==
null
||
product
==
null
||
appKey
==
null
||
""
.
equals
(
token
)||
""
.
equals
(
product
)||
""
.
equals
(
appKey
)){
//
if(token==null||product==null||appKey==null||"".equals(token)||"".equals(product)||"".equals(appKey)){
//没有请求头信息直接转异常到403
//
//没有请求头信息直接转异常到403
throw
new
RuntimeException
(
"非法异常请求!请重新登录!"
);
//
throw new RuntimeException("非法异常请求!请重新登录!");
}
//
}
RequestContext
.
setToken
(
token
);
//
RequestContext.setToken(token);
RequestContext
.
setProduct
(
product
);
//
RequestContext.setProduct(product);
RequestContext
.
setAppKey
(
appKey
);
//
RequestContext.setAppKey(appKey);
}
//
}
//
//
//
}
//
}
//
@AfterReturning
(
returning
=
"ret"
,
pointcut
=
"webLog()"
)
//
@AfterReturning(returning = "ret",pointcut = "webLog()")
public
void
doAfterReturning
(
Object
ret
)
throws
Throwable
{
//
public void doAfterReturning(Object ret) throws Throwable {
}
//
}
}
//
}
//
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/controller/UserController.java
View file @
60204813
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
controller
;
//package com.yeejoin.amos.boot.module.jcs.biz.controller;
//
import
java.io.IOException
;
//import java.io.IOException;
import
java.lang.reflect.Field
;
//import java.lang.reflect.Field;
import
java.util.ArrayList
;
//import java.util.ArrayList;
import
java.util.HashMap
;
//import java.util.HashMap;
import
java.util.Iterator
;
//import java.util.Iterator;
import
java.util.List
;
//import java.util.List;
import
java.util.Map
;
//import java.util.Map;
//
import
org.slf4j.Logger
;
//import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
//import org.slf4j.LoggerFactory;
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.core.io.ByteArrayResource
;
//import org.springframework.core.io.ByteArrayResource;
import
org.springframework.http.HttpEntity
;
//import org.springframework.http.HttpEntity;
import
org.springframework.http.HttpHeaders
;
//import org.springframework.http.HttpHeaders;
import
org.springframework.http.HttpMethod
;
//import org.springframework.http.HttpMethod;
import
org.springframework.http.HttpStatus
;
//import org.springframework.http.HttpStatus;
import
org.springframework.http.MediaType
;
//import org.springframework.http.MediaType;
import
org.springframework.http.ResponseEntity
;
//import org.springframework.http.ResponseEntity;
import
org.springframework.util.LinkedMultiValueMap
;
//import org.springframework.util.LinkedMultiValueMap;
import
org.springframework.util.MultiValueMap
;
//import org.springframework.util.MultiValueMap;
import
org.springframework.util.ObjectUtils
;
//import org.springframework.util.ObjectUtils;
import
org.springframework.web.bind.annotation.GetMapping
;
//import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.PathVariable
;
//import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.PostMapping
;
//import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
//import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
//import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
//import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
//import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
//import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.client.RestTemplate
;
//import org.springframework.web.client.RestTemplate;
import
org.springframework.web.multipart.MultipartFile
;
//import org.springframework.web.multipart.MultipartFile;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
//import org.typroject.tyboot.core.foundation.enumeration.UserType;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
//import org.typroject.tyboot.core.foundation.utils.Bean;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
//import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
//import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
//import org.typroject.tyboot.core.restful.utils.ResponseModel;
//
import
com.alibaba.fastjson.JSON
;
//import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
//import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
//import com.alibaba.fastjson.JSONObject;
import
com.google.common.collect.Maps
;
//import com.google.common.collect.Maps;
import
com.yeejoin.amos.boot.biz.common.bo.CompanyBo
;
//import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import
com.yeejoin.amos.boot.biz.common.bo.DepartmentBo
;
//import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
//import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import
com.yeejoin.amos.boot.biz.common.bo.RoleBo
;
//import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
//import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import
com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService
;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.RemoteSecurityService;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
//import com.yeejoin.amos.component.feign.model.FeignClientResult;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
//import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
//import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
//import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import
com.yeejoin.amos.feign.privilege.model.RoleModel
;
//import com.yeejoin.amos.feign.privilege.model.RoleModel;
import
com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel
;
//import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
//
import
io.swagger.annotations.Api
;
//import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
//import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.ApiParam
;
//import io.swagger.annotations.ApiParam;
//
/**
///**
* 获取用户信息
// * 获取用户信息
*
// *
* @author gaodongdong
// * @author gaodongdong
*/
// */
@RestController
//@RestController
@RequestMapping
(
value
=
"/user"
)
//@RequestMapping(value = "/user")
@Api
(
tags
=
"用户信息api"
)
//@Api(tags = "用户信息api")
public
class
UserController
extends
BaseController
{
//public class UserController extends BaseController {
//
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
UserController
.
class
);
// private final Logger logger = LoggerFactory.getLogger(UserController.class);
//
@Autowired
// @Autowired
private
RemoteSecurityService
remoteSecurityService
;
// private RemoteSecurityService remoteSecurityService;
@Autowired
// @Autowired
private
RestTemplate
restTemplate
;
// private RestTemplate restTemplate;
//
@Value
(
"${security.systemctl.name}"
)
// @Value("${security.systemctl.name}")
private
String
systemctl
;
// private String systemctl;
private
static
final
String
appType
=
"APP"
;
// private static final String appType = "APP";
//
/**
// /**
* 获取公司选择信息
// * 获取公司选择信息
*/
// */
@ApiOperation
(
value
=
"获取公司选择信息"
,
notes
=
"获取公司选择信息"
)
// @ApiOperation(value = "获取公司选择信息", notes = "获取公司选择信息")
@GetMapping
(
value
=
"/selectInfo"
)
// @GetMapping(value = "/selectInfo")
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
public
JSONObject
selectInfo
()
{
// public JSONObject selectInfo() {
try
{
// try {
JSONObject
result
=
new
JSONObject
();
// JSONObject result = new JSONObject();
AgencyUserModel
user
=
getUserInfo
();
// AgencyUserModel user = getUserInfo();
if
(
user
!=
null
)
{
// if (user != null) {
List
<
CompanyModel
>
list
=
user
.
getCompanys
();
// List<CompanyModel> list = user.getCompanys();
Map
<
Long
,
List
<
DepartmentModel
>>
mapDepartments
=
user
.
getCompanyDepartments
();
// Map<Long, List<DepartmentModel>> mapDepartments = user.getCompanyDepartments();
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
mapdate
=
new
HashMap
<
String
,
List
<
Map
<
String
,
Object
>>>();
// Map<String, List<Map<String, Object>>> mapdate = new HashMap<String, List<Map<String, Object>>>();
List
<
Map
>
listCompanyModel
=
new
ArrayList
();
// List<Map> listCompanyModel = new ArrayList();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
// if (list != null && list.size() > 0) {
for
(
CompanyModel
article
:
list
)
{
// for (CompanyModel article : list) {
Map
<
String
,
Object
>
map
=
objectToMap
(
article
);
// Map<String, Object> map = objectToMap(article);
map
.
put
(
"companySeq"
,
map
.
get
(
"sequenceNbr"
)
+
""
);
// map.put("companySeq", map.get("sequenceNbr") + "");
map
.
put
(
"parentId"
,
map
.
get
(
"parentId"
)
+
""
);
// map.put("parentId", map.get("parentId") + "");
listCompanyModel
.
add
(
map
);
// listCompanyModel.add(map);
long
key
=
Long
.
valueOf
(
map
.
get
(
"sequenceNbr"
).
toString
());
// long key = Long.valueOf(map.get("sequenceNbr").toString());
List
<
DepartmentModel
>
listdep
=
mapDepartments
.
get
(
key
);
// List<DepartmentModel> listdep = mapDepartments.get(key);
List
<
Map
<
String
,
Object
>>
dep
=
new
ArrayList
();
// List<Map<String, Object>> dep = new ArrayList();
for
(
DepartmentModel
departmentModel
:
listdep
)
{
// for (DepartmentModel departmentModel : listdep) {
if
(
departmentModel
!=
null
)
{
// if (departmentModel != null) {
Map
<
String
,
Object
>
mapo
=
objectToMap
(
departmentModel
);
// Map<String, Object> mapo = objectToMap(departmentModel);
mapo
.
put
(
"sequenceNbr"
,
mapo
.
get
(
"sequenceNbr"
).
toString
());
// mapo.put("sequenceNbr", mapo.get("sequenceNbr").toString());
dep
.
add
(
mapo
);
// dep.add(mapo);
}
// }
}
// }
mapdate
.
put
(
map
.
get
(
"sequenceNbr"
).
toString
(),
dep
);
// mapdate.put(map.get("sequenceNbr").toString(), dep);
}
// }
}
// }
Map
<
String
,
Object
>
mapRoles
=
objectToMap
(
user
.
getOrgRoles
());
// Map<String, Object> mapRoles = objectToMap(user.getOrgRoles());
//
result
.
put
(
"companys"
,
listCompanyModel
);
// result.put("companys", listCompanyModel);
result
.
put
(
"orgRoles"
,
user
.
getOrgRoles
());
// result.put("orgRoles", user.getOrgRoles());
result
.
put
(
"companyDepartments"
,
mapdate
);
// result.put("companyDepartments", mapdate);
return
result
;
// return result;
}
else
{
// } else {
throw
new
RuntimeException
(
"请重新登录"
);
// throw new RuntimeException("请重新登录");
}
// }
}
catch
(
Exception
e
)
{
// } catch (Exception e) {
e
.
printStackTrace
();
// e.printStackTrace();
logger
.
error
(
"获取公司选择信息异常"
,
e
);
// logger.error("获取公司选择信息异常", e);
throw
new
RuntimeException
(
e
.
getMessage
());
// throw new RuntimeException(e.getMessage());
}
// }
}
// }
//
//
// 对象转map
// // 对象转map
//
public
static
Map
<
String
,
Object
>
objectToMap
(
Object
obj
)
throws
IllegalAccessException
{
// public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException {
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
// Map<String, Object> map = new HashMap<String, Object>();
if
(
obj
!=
null
)
{
// if (obj != null) {
Class
<?>
clazz
=
obj
.
getClass
();
// Class<?> clazz = obj.getClass();
for
(
Field
field
:
clazz
.
getDeclaredFields
())
{
// for (Field field : clazz.getDeclaredFields()) {
field
.
setAccessible
(
true
);
// field.setAccessible(true);
String
fieldName
=
field
.
getName
();
// String fieldName = field.getName();
Object
value
=
nvl
(
field
.
get
(
obj
));
// Object value = nvl(field.get(obj));
//
if
(
fieldName
.
equals
(
"sequenceNbr"
))
{
// if (fieldName.equals("sequenceNbr")) {
map
.
put
(
fieldName
,
value
+
""
);
// map.put(fieldName, value + "");
}
else
if
(
fieldName
.
equals
(
"companySeq"
))
{
// } else if (fieldName.equals("companySeq")) {
map
.
put
(
fieldName
,
value
+
""
);
// map.put(fieldName, value + "");
}
else
if
(
fieldName
.
equals
(
"children"
))
{
// } else if (fieldName.equals("children")) {
map
.
put
(
fieldName
,
value
);
// map.put(fieldName, value);
}
else
{
// } else {
map
.
put
(
fieldName
,
value
);
// map.put(fieldName, value);
}
// }
//
}
// }
return
map
;
// return map;
}
// }
return
map
;
// return map;
}
// }
//
public
static
Object
nvl
(
Object
param
)
{
// public static Object nvl(Object param) {
return
param
!=
null
?
param
:
""
;
// return param != null ? param : "";
}
// }
//
/**
// /**
* 保存登陆用户选择公司信息
// * 保存登陆用户选择公司信息
*/
// */
@ApiOperation
(
value
=
"保存登陆用户选择公司信息"
,
notes
=
"保存登陆用户选择公司信息"
)
// @ApiOperation(value = "保存登陆用户选择公司信息", notes = "保存登陆用户选择公司信息")
@PostMapping
(
value
=
"/save/curCompany"
)
// @PostMapping(value = "/save/curCompany")
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
public
JSONObject
saveCurCompany
(
// public JSONObject saveCurCompany(
@ApiParam
(
value
=
"当前登陆用户所选单位机构编号"
,
required
=
true
)
@RequestBody
ReginParams
selectUserInfo
)
{
// @ApiParam(value = "当前登陆用户所选单位机构编号", required = true) @RequestBody ReginParams selectUserInfo) {
try
{
// try {
AgencyUserModel
user
=
getUserInfo
();
// AgencyUserModel user = getUserInfo();
CompanyBo
company
=
new
CompanyBo
();
// CompanyBo company = new CompanyBo();
DepartmentBo
department
=
new
DepartmentBo
();
// DepartmentBo department = new DepartmentBo();
RoleBo
role
=
new
RoleBo
();
// RoleBo role = new RoleBo();
if
(
ObjectUtils
.
isEmpty
(
selectUserInfo
.
getCompany
())){
// if(ObjectUtils.isEmpty(selectUserInfo.getCompany())){
CompanyModel
companyM
=
user
.
getCompanys
().
get
(
0
);
// CompanyModel companyM = user.getCompanys().get(0);
Bean
.
copyExistPropertis
(
companyM
,
company
);
// Bean.copyExistPropertis(companyM,company);
//
Map
<
Long
,
List
<
DepartmentModel
>>
mapDepartments
=
user
.
getCompanyDepartments
();
// Map<Long, List<DepartmentModel>> mapDepartments = user.getCompanyDepartments();
DepartmentModel
departmentM
=
mapDepartments
.
get
(
companyM
.
getSequenceNbr
()).
get
(
0
);
// DepartmentModel departmentM = mapDepartments.get(companyM.getSequenceNbr()).get(0);
Bean
.
copyExistPropertis
(
departmentM
,
department
);
// Bean.copyExistPropertis(departmentM,department);
Map
<
Long
,
List
<
RoleModel
>>
roles
=
user
.
getOrgRoles
();
// Map<Long, List<RoleModel>> roles = user.getOrgRoles();
RoleModel
roleM
=
roles
.
get
(
departmentM
.
getSequenceNbr
()).
get
(
0
);
// RoleModel roleM = roles.get(departmentM.getSequenceNbr()).get(0);
//
Bean
.
copyExistPropertis
(
roleM
,
role
);
// Bean.copyExistPropertis(roleM,role);
selectUserInfo
.
setCompany
(
company
);
// selectUserInfo.setCompany(company);
selectUserInfo
.
setDepartment
(
department
);
// selectUserInfo.setDepartment(department);
selectUserInfo
.
setRole
(
role
);
// selectUserInfo.setRole(role);
}
else
{
// }else{
company
=
selectUserInfo
.
getCompany
();
// company = selectUserInfo.getCompany();
role
=
selectUserInfo
.
getRole
();
// role = selectUserInfo.getRole();
department
=
selectUserInfo
.
getDepartment
();
// department = selectUserInfo.getDepartment();
}
// }
ReginParams
reginParams
=
new
ReginParams
();
// ReginParams reginParams = new ReginParams();
reginParams
.
setCompany
(
company
);
// reginParams.setCompany(company);
reginParams
.
setRole
(
role
);
// reginParams.setRole(role);
reginParams
.
setDepartment
(
department
);
// reginParams.setDepartment(department);
saveSelectedOrgInfo
(
reginParams
);
// saveSelectedOrgInfo(reginParams);
//保存用户信息
// //保存用户信息
saveUser
(
user
);
// saveUser(user);
//
return
buildCurCompany
(
selectUserInfo
,
user
);
// return buildCurCompany(selectUserInfo, user);
}
catch
(
Exception
e
)
{
// } catch (Exception e) {
e
.
printStackTrace
();
// e.printStackTrace();
logger
.
error
(
"保存登陆用户选择公司信息异常"
,
e
);
// logger.error("保存登陆用户选择公司信息异常", e);
throw
new
RuntimeException
(
"系统繁忙,请稍后再试"
);
// throw new RuntimeException("系统繁忙,请稍后再试");
}
// }
}
// }
private
JSONObject
buildCurCompany
(
ReginParams
selectUserInfo
,
AgencyUserModel
user
)
{
// private JSONObject buildCurCompany(ReginParams selectUserInfo, AgencyUserModel user) {
JSONObject
result
=
new
JSONObject
();
// JSONObject result = new JSONObject();
result
.
put
(
"userId"
,
user
.
getUserId
());
// result.put("userId", user.getUserId());
result
.
put
(
"realName"
,
user
.
getRealName
());
// result.put("realName", user.getRealName());
result
.
put
(
"userMobile"
,
user
.
getMobile
());
// result.put("userMobile", user.getMobile());
result
.
put
(
"userName"
,
user
.
getUserName
());
// result.put("userName", user.getUserName());
result
.
put
(
"email"
,
user
.
getEmail
());
// result.put("email", user.getEmail());
//
ResponseModel
secResponse
=
remoteSecurityService
// ResponseModel secResponse = remoteSecurityService
.
searchPermissionTree
(
selectUserInfo
.
getRole
().
getSequenceNbr
(),
appType
);
// .searchPermissionTree(selectUserInfo.getRole().getSequenceNbr(), appType);
List
<
JSONObject
>
listp
=
new
ArrayList
<>();
// List<JSONObject> listp = new ArrayList<>();
if
(
secResponse
.
getStatus
()==
HttpStatus
.
OK
.
value
()
&&
secResponse
.
getResult
()
!=
null
)
{
// if (secResponse.getStatus()==HttpStatus.OK.value() && secResponse.getResult() != null) {
JSONArray
arr
=
JSON
.
parseArray
(
JSONArray
.
toJSONString
(
secResponse
.
getResult
()));
// JSONArray arr = JSON.parseArray(JSONArray.toJSONString(secResponse.getResult()));
Map
<
String
,
JSONObject
>
map
=
Maps
.
newHashMap
();
// Map<String, JSONObject> map = Maps.newHashMap();
//
if
(
arr
!=
null
&&
arr
.
size
()
>
0
)
{
// if (arr != null && arr.size() > 0) {
JSONObject
obj
=
arr
.
getJSONObject
(
0
);
// JSONObject obj = arr.getJSONObject(0);
if
(
obj
!=
null
)
{
// if (obj != null) {
JSONArray
childrens
=
obj
.
getJSONArray
(
"children"
);
// JSONArray childrens = obj.getJSONArray("children");
if
(
childrens
!=
null
&&
childrens
.
size
()
>
0
)
{
// if (childrens != null && childrens.size() > 0) {
for
(
int
i
=
0
;
i
<
childrens
.
size
();
i
++)
{
// for (int i = 0; i < childrens.size(); i++) {
JSONObject
child
=
childrens
.
getJSONObject
(
i
);
// JSONObject child = childrens.getJSONObject(i);
// map.put(child.getString("path"), child);
// // map.put(child.getString("path"), child);
listp
.
add
(
child
);
// listp.add(child);
}
// }
}
// }
}
// }
//
// result.put("userPower", map.get("app"));
// // result.put("userPower", map.get("app"));
}
// }
}
// }
result
.
put
(
"userPower"
,
JSON
.
toJSON
(
listp
));
// result.put("userPower", JSON.toJSON(listp));
result
.
put
(
"companyModel"
,
selectUserInfo
.
getCompany
());
// result.put("companyModel", selectUserInfo.getCompany());
result
.
put
(
"departmentModel"
,
selectUserInfo
.
getDepartment
());
// result.put("departmentModel", selectUserInfo.getDepartment());
result
.
put
(
"roleModel"
,
selectUserInfo
.
getRole
());
// result.put("roleModel", selectUserInfo.getRole());
return
result
;
// return result;
}
// }
//
//
//
/**
// /**
*
// *
* 获取字典
// * 获取字典
*
// *
*/
// */
//
@ApiOperation
(
value
=
"查询指定的字典信息"
,
notes
=
"查询指定的字典信息"
)
// @ApiOperation(value = "查询指定的字典信息", notes = "查询指定的字典信息")
@GetMapping
(
value
=
"listDictionaryByDictCode/{dictCode}"
)
// @GetMapping(value = "listDictionaryByDictCode/{dictCode}")
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
public
List
<
DictionarieValueModel
>
listDictionaryByDictCode
(
@PathVariable
String
dictCode
)
{
// public List<DictionarieValueModel> listDictionaryByDictCode(@PathVariable String dictCode) {
try
{
// try {
List
<
DictionarieValueModel
>
list
=
remoteSecurityService
.
listDictionaryByDictCode
(
dictCode
);
// List<DictionarieValueModel> list = remoteSecurityService.listDictionaryByDictCode(dictCode);
//
return
list
;
// return list;
}
catch
(
Exception
e
)
{
// } catch (Exception e) {
//
throw
new
RuntimeException
();
// throw new RuntimeException();
}
// }
}
// }
//
/**
// /**
*
// *
*
// *
* 上传图片到平台
// * 上传图片到平台
*
// *
**/
// **/
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"文件上传(<font color='blue'>release</font>)"
,
notes
=
"文件上传"
)
// @ApiOperation(httpMethod = "POST", value = "文件上传(<font color='blue'>release</font>)", notes = "文件上传")
@RequestMapping
(
value
=
"/upload-file"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
// @RequestMapping(value = "/upload-file", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
public
ResponseModel
uploadFile
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
// public ResponseModel uploadFile(@RequestParam("file") MultipartFile file) {
//
FeignClientResult
<
Map
<
String
,
String
>>
date
=
remoteSecurityService
.
fileImage
(
file
);
// FeignClientResult<Map<String, String>> date = remoteSecurityService.fileImage(file);
Map
<
String
,
String
>
map1
=
new
HashMap
<>();
// Map<String, String> map1 = new HashMap<>();
if
(
date
!=
null
)
{
// if (date != null) {
Map
<
String
,
String
>
map
=
date
.
getResult
();
// Map<String, String> map = date.getResult();
Iterator
<
String
>
it
=
map
.
keySet
().
iterator
();
// Iterator<String> it = map.keySet().iterator();
//
while
(
it
.
hasNext
())
{
// while (it.hasNext()) {
map1
.
put
(
"url"
,
it
.
next
());
// map1.put("url", it.next());
}
// }
//
}
// }
return
ResponseHelper
.
buildResponse
(
map1
);
// return ResponseHelper.buildResponse(map1);
}
// }
//
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"文件上传(<font color='blue'>release</font>)"
,
notes
=
"文件上传"
)
// @ApiOperation(httpMethod = "POST", value = "文件上传(<font color='blue'>release</font>)", notes = "文件上传")
@RequestMapping
(
value
=
"/upload-files"
,
method
=
RequestMethod
.
POST
,
produces
=
"application/json;charset=UTF-8"
)
// @RequestMapping(value = "/upload-files", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
@TycloudOperation
(
needAuth
=
true
,
ApiLevel
=
UserType
.
AGENCY
)
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
public
ResponseModel
uploadFile
(
@RequestParam
(
"files"
)
MultipartFile
[]
files
)
throws
IOException
{
// public ResponseModel uploadFile(@RequestParam("files") MultipartFile[] files) throws IOException {
//
// 设置请求头
// // 设置请求头
HttpHeaders
headers
=
new
HttpHeaders
();
// HttpHeaders headers = new HttpHeaders();
MediaType
type
=
MediaType
.
parseMediaType
(
"multipart/form-data"
);
// MediaType type = MediaType.parseMediaType("multipart/form-data");
headers
.
setContentType
(
type
);
// headers.setContentType(type);
headers
.
set
(
"product"
,
getProduct
());
// headers.set("product", getProduct());
headers
.
set
(
"token"
,
getToken
());
// headers.set("token", getToken());
headers
.
set
(
"appKey"
,
getAppKey
());
// headers.set("appKey", getAppKey());
// 设置请求体,注意是LinkedMultiValueMap
// // 设置请求体,注意是LinkedMultiValueMap
MultiValueMap
<
String
,
Object
>
form
=
new
LinkedMultiValueMap
<>();
// MultiValueMap<String, Object> form = new LinkedMultiValueMap<>();
List
<
Object
>
fileList
=
new
ArrayList
<>();
// List<Object> fileList = new ArrayList<>();
for
(
MultipartFile
file
:
files
)
{
// for (MultipartFile file : files) {
ByteArrayResource
byteArrayResource
=
new
ByteArrayResource
(
file
.
getBytes
())
{
// ByteArrayResource byteArrayResource = new ByteArrayResource(file.getBytes()) {
@Override
// @Override
public
String
getFilename
()
throws
IllegalStateException
{
// public String getFilename() throws IllegalStateException {
return
file
.
getOriginalFilename
();
// return file.getOriginalFilename();
}
// }
};
// };
fileList
.
add
(
byteArrayResource
);
// fileList.add(byteArrayResource);
}
// }
//
form
.
put
(
"files"
,
fileList
);
// form.put("files", fileList);
//
// 用HttpEntity封装整个请求报文
// // 用HttpEntity封装整个请求报文
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
files1
=
new
HttpEntity
<>(
form
,
headers
);
// HttpEntity<MultiValueMap<String, Object>> files1 = new HttpEntity<>(form, headers);
//
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
// ResponseEntity<String> responseEntity = restTemplate.exchange(
"http://"
+
systemctl
+
"/systemctl/v1/filestorage/image"
,
HttpMethod
.
POST
,
files1
,
String
.
class
);
// "http://" + systemctl + "/systemctl/v1/filestorage/image", HttpMethod.POST, files1, String.class);
//
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseEntity
.
getBody
());
// JSONObject jsonObject = JSON.parseObject(responseEntity.getBody());
//
Map
<
String
,
String
>
map1
=
new
HashMap
<>();
// Map<String, String> map1 = new HashMap<>();
if
(
jsonObject
!=
null
)
{
// if (jsonObject != null) {
Map
<
String
,
String
>
map
=
JSON
.
parseObject
(
jsonObject
.
get
(
"result"
).
toString
(),
Map
.
class
);
// Map<String, String> map = JSON.parseObject(jsonObject.get("result").toString(), Map.class);
Iterator
<
String
>
it
=
map
.
keySet
().
iterator
();
// Iterator<String> it = map.keySet().iterator();
String
url
=
""
;
// String url = "";
while
(
it
.
hasNext
())
{
// while (it.hasNext()) {
url
=
url
+
it
.
next
()
+
","
;
// url = url + it.next() + ",";
}
// }
map1
.
put
(
"url"
,
url
);
// map1.put("url", url);
}
// }
return
ResponseHelper
.
buildResponse
(
map1
);
// return ResponseHelper.buildResponse(map1);
}
// }
//
}
//}
\ No newline at end of file
\ No newline at end of file
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/service/impl/RemoteSecurityService.java
View file @
60204813
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jcs
.
biz
.
service
.
impl
;
//
package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
//
import
java.util.ArrayList
;
//
import java.util.ArrayList;
import
java.util.Collection
;
//
import java.util.Collection;
import
java.util.List
;
//
import java.util.List;
import
java.util.Map
;
//
import java.util.Map;
import
java.util.Set
;
//
import java.util.Set;
//
import
javax.servlet.http.HttpServletRequest
;
//
import javax.servlet.http.HttpServletRequest;
//
import
org.springframework.beans.factory.annotation.Autowired
;
//
import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
//
import org.springframework.stereotype.Service;
import
org.springframework.util.StringUtils
;
//
import org.springframework.util.StringUtils;
import
org.springframework.web.multipart.MultipartFile
;
//
import org.springframework.web.multipart.MultipartFile;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
//
import org.typroject.tyboot.core.foundation.context.RequestContext;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
//
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
//
import org.typroject.tyboot.core.restful.utils.ResponseModel;
//
import
com.alibaba.fastjson.JSON
;
//
import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
//
import com.alibaba.fastjson.JSONArray;
import
com.yeejoin.amos.component.feign.config.InnerInvokException
;
//
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
//
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import
com.yeejoin.amos.component.feign.utils.FeignUtil
;
//
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import
com.yeejoin.amos.feign.privilege.Privilege
;
//
import com.yeejoin.amos.feign.privilege.Privilege;
import
com.yeejoin.amos.feign.privilege.client.AgencyUserClient
;
//
import com.yeejoin.amos.feign.privilege.client.AgencyUserClient;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
//
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import
com.yeejoin.amos.feign.privilege.model.CompanyModel
;
//
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import
com.yeejoin.amos.feign.privilege.model.DepartmentModel
;
//
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import
com.yeejoin.amos.feign.privilege.model.PermissionModel
;
//
import com.yeejoin.amos.feign.privilege.model.PermissionModel;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
//
import com.yeejoin.amos.feign.systemctl.Systemctl;
import
com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel
;
//
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
//
/***
/
//
***
*
//
*
* 平台安全接口实现类
//
* 平台安全接口实现类
*
//
*
* ***/
//
* ***/
@Service
(
"remoteSecurityService"
)
//
@Service("remoteSecurityService")
public
class
RemoteSecurityService
{
//
public class RemoteSecurityService {
//
//
@Autowired
//
@Autowired
private
HttpServletRequest
request
;
//
private HttpServletRequest request;
//
// * 根据公司id查询机构用户
//
// * 根据公司id查询机构用户
//
public
List
<
AgencyUserModel
>
listUserByCompanyId
(
String
companyId
)
{
////
public List<AgencyUserModel> listUserByCompanyId(String companyId) {
if
(
StringUtils
.
isEmpty
(
companyId
))
{
////
if (StringUtils.isEmpty(companyId)) {
return
null
;
////
return null;
}
////
}
List
<
AgencyUserModel
>
AgencyUserModel
=
null
;
////
List<AgencyUserModel> AgencyUserModel = null;
FeignClientResult
feignClientResult
;
////
FeignClientResult feignClientResult;
try
{
////
try {
feignClientResult
=
Privilege
.
agencyUserClient
.
queryByCompanyId
(
Long
.
valueOf
(
companyId
),
null
);
////
feignClientResult = Privilege.agencyUserClient.queryByCompanyId(Long.valueOf(companyId), null);
AgencyUserModel
=
(
List
<
AgencyUserModel
>)
feignClientResult
.
getResult
();
////
AgencyUserModel = (List<AgencyUserModel>) feignClientResult.getResult();
////
}
catch
(
InnerInvokException
e
)
{
////
} catch (InnerInvokException e) {
e
.
printStackTrace
();
////
e.printStackTrace();
throw
new
RuntimeException
();
////
throw new RuntimeException();
}
////
}
return
AgencyUserModel
;
////
return AgencyUserModel;
}
////
}
//
/**
//
/**
* 用户id批量获取用户信息
//
* 用户id批量获取用户信息
*
//
*
* @param userIds 用户ids
//
* @param userIds 用户ids
* @return List<AgencyUserModel>
//
* @return List<AgencyUserModel>
*/
//
*/
public
List
<
AgencyUserModel
>
listUserByUserIds
(
String
userIds
)
{
////
public List<AgencyUserModel> listUserByUserIds(String userIds) {
List
<
AgencyUserModel
>
agencyUserModel
=
null
;
////
List<AgencyUserModel> agencyUserModel = null;
FeignClientResult
feignClientResult
;
////
FeignClientResult feignClientResult;
try
{
////
try {
feignClientResult
=
Privilege
.
agencyUserClient
.
queryByIds
(
userIds
);
////
feignClientResult = Privilege.agencyUserClient.queryByIds(userIds);
agencyUserModel
=
(
List
<
AgencyUserModel
>)
feignClientResult
.
getResult
();
////
agencyUserModel = (List<AgencyUserModel>) feignClientResult.getResult();
////
}
catch
(
InnerInvokException
e
)
{
////
} catch (InnerInvokException e) {
e
.
printStackTrace
();
////
e.printStackTrace();
throw
new
RuntimeException
();
////
throw new RuntimeException();
}
////
}
return
agencyUserModel
;
////
return agencyUserModel;
}
////
}
//
/**
//
/**
* 用户id获取用户信息
//
* 用户id获取用户信息
*
//
*
* @param userId 用户编号
//
* @param userId 用户编号
* @return AgencyUserModel
//
* @return AgencyUserModel
*/
//
*/
public
AgencyUserModel
getUserById
(
String
userId
)
{
//
public AgencyUserModel getUserById(String userId) {
if
(
StringUtils
.
isEmpty
(
userId
))
{
//
if (StringUtils.isEmpty(userId)) {
return
null
;
//
return null;
}
//
}
AgencyUserModel
agencyUserModel
;
//
AgencyUserModel agencyUserModel;
try
{
//
try {
agencyUserModel
=
FeignUtil
.
remoteCall
(()
->
Privilege
.
agencyUserClient
.
queryByUserId
(
userId
));
//
agencyUserModel = FeignUtil.remoteCall(() -> Privilege.agencyUserClient.queryByUserId(userId));
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
e
.
printStackTrace
();
//
e.printStackTrace();
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
return
agencyUserModel
;
//
return agencyUserModel;
}
//
}
//
// 根据orgCode查询机构用户
//
// 根据orgCode查询机构用户
public
List
<
AgencyUserModel
>
listUserByOrgCode
(
String
orgCode
)
{
////
public List<AgencyUserModel> listUserByOrgCode(String orgCode) {
if
(
StringUtils
.
isEmpty
(
orgCode
))
{
////
if (StringUtils.isEmpty(orgCode)) {
return
null
;
////
return null;
}
////
}
Set
<
AgencyUserModel
>
agencyUserModel
;
////
Set<AgencyUserModel> agencyUserModel;
try
{
////
try {
agencyUserModel
=
FeignUtil
.
remoteCall
(()
->
Privilege
.
agencyUserClient
.
queryByOrgCode
(
orgCode
));
////
agencyUserModel = FeignUtil.remoteCall(() -> Privilege.agencyUserClient.queryByOrgCode(orgCode));
}
catch
(
Exception
e
)
{
////
} catch (Exception e) {
e
.
printStackTrace
();
////
e.printStackTrace();
throw
new
RuntimeException
();
////
throw new RuntimeException();
}
////
}
return
new
ArrayList
<>(
agencyUserModel
);
////
return new ArrayList<>(agencyUserModel);
}
////
}
//
// 根据部门id查询机构用户
//
// 根据部门id查询机构用户
public
List
<
AgencyUserModel
>
listUserByDepartmentId
(
Long
departmentId
)
{
////
public List<AgencyUserModel> listUserByDepartmentId(Long departmentId) {
if
(
departmentId
==
null
)
{
////
if (departmentId == null) {
return
null
;
////
return null;
}
////
}
List
<
AgencyUserModel
>
agencyUserModel
;
////
List<AgencyUserModel> agencyUserModel;
try
{
////
try {
agencyUserModel
=
FeignUtil
.
remoteCall
(
()
->
Privilege
.
agencyUserClient
.
queryByDepartmentId
(
departmentId
,
null
));
//// agencyUserModel = FeignUtil.remoteCall
() -> Privilege.agencyUserClient.queryByDepartmentId(departmentId, null));
}
catch
(
Exception
e
)
{
////
} catch (Exception e) {
e
.
printStackTrace
();
////
e.printStackTrace();
throw
new
RuntimeException
();
////
throw new RuntimeException();
}
////
}
return
agencyUserModel
;
////
return agencyUserModel;
}
////
}
//
// 根据orgCode查询机构
//
// 根据orgCode查询机构
public
Map
<
String
,
Object
>
listByOrgCode
(
String
orgCode
)
{
//
public Map<String, Object> listByOrgCode(String orgCode) {
if
(
StringUtils
.
isEmpty
(
orgCode
))
{
//
if (StringUtils.isEmpty(orgCode)) {
return
null
;
//
return null;
}
//
}
Map
<
String
,
Object
>
agencyUserModel
=
null
;
//
Map<String, Object> agencyUserModel = null;
FeignClientResult
feignClientResult
;
//
FeignClientResult feignClientResult;
try
{
//
try {
feignClientResult
=
Privilege
.
companyClient
.
queryByOrgcode
(
orgCode
);
//
feignClientResult = Privilege.companyClient.queryByOrgcode(orgCode);
agencyUserModel
=
(
Map
<
String
,
Object
>)
feignClientResult
.
getResult
();
//
agencyUserModel = (Map<String, Object>) feignClientResult.getResult();
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
return
agencyUserModel
;
//
return agencyUserModel;
}
//
}
//
// 查询指定公司的部门树
//
// 查询指定公司的部门树
public
List
<
DepartmentModel
>
getDepartmentTreeByCompanyId
(
Long
companyId
)
{
//
public List<DepartmentModel> getDepartmentTreeByCompanyId(Long companyId) {
if
(
companyId
==
null
)
{
//
if (companyId == null) {
return
null
;
//
return null;
}
//
}
List
<
DepartmentModel
>
departmentModel
=
null
;
//
List<DepartmentModel> departmentModel = null;
FeignClientResult
feignClientResult
;
//
FeignClientResult feignClientResult;
try
{
//
try {
feignClientResult
=
Privilege
.
departmentClient
.
queryDeptTree
(
null
,
companyId
);
//
feignClientResult = Privilege.departmentClient.queryDeptTree(null, companyId);
departmentModel
=
(
List
<
DepartmentModel
>)
feignClientResult
.
getResult
();
//
departmentModel = (List<DepartmentModel>) feignClientResult.getResult();
//
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
return
departmentModel
;
//
return departmentModel;
//
}
//
}
//
//
/**
//
/**
* 基础平台全部菜单权限树,用于平台登录前端初始化路由
//
* 基础平台全部菜单权限树,用于平台登录前端初始化路由
*/
//
*/
public
ResponseModel
<
Object
>
searchPermissionTree
(
long
id
,
String
appType
)
{
//
public ResponseModel<Object> searchPermissionTree(long id, String appType) {
List
<
PermissionModel
>
dictionarieModel
=
null
;
//
List<PermissionModel> dictionarieModel = null;
FeignClientResult
<
Collection
<
PermissionModel
>>
feignClientResult
;
//
FeignClientResult<Collection<PermissionModel>> feignClientResult;
try
{
//
try {
feignClientResult
=
Privilege
.
permissionClient
.
treeByRole
(
id
,
appType
,
null
,
null
);
//
feignClientResult = Privilege.permissionClient.treeByRole(id, appType, null, null);
dictionarieModel
=
(
List
<
PermissionModel
>)
feignClientResult
.
getResult
();
//
dictionarieModel = (List<PermissionModel>) feignClientResult.getResult();
//
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
ResponseModel
<
Object
>
commonResponse
=
ResponseHelper
.
buildResponse
(
dictionarieModel
);
//
ResponseModel<Object> commonResponse = ResponseHelper.buildResponse( dictionarieModel);
return
commonResponse
;
//
return commonResponse;
}
//
}
//
/**
//
/**
* 根据Code查询指定的字典信息
//
* 根据Code查询指定的字典信息
*
//
*
* @param dictCode 字典编号
//
* @param dictCode 字典编号
* @return List<DictionarieValueModel>
//
* @return List<DictionarieValueModel>
*/
//
*/
public
List
<
DictionarieValueModel
>
listDictionaryByDictCode
(
String
dictCode
)
{
//
public List<DictionarieValueModel> listDictionaryByDictCode(String dictCode) {
List
<
DictionarieValueModel
>
dictionarieModel
=
null
;
//
List<DictionarieValueModel> dictionarieModel = null;
FeignClientResult
<
List
<
DictionarieValueModel
>>
feignClientResult
;
//
FeignClientResult<List<DictionarieValueModel>> feignClientResult;
try
{
//
try {
feignClientResult
=
Systemctl
.
dictionarieClient
.
dictValues
(
dictCode
);
//
feignClientResult = Systemctl.dictionarieClient.dictValues(dictCode);
dictionarieModel
=
(
List
<
DictionarieValueModel
>)
feignClientResult
.
getResult
();
//
dictionarieModel = (List<DictionarieValueModel>) feignClientResult.getResult();
//
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
//
return
dictionarieModel
;
//
return dictionarieModel;
}
//
}
//
/**
//
/**
* 查询指定公司信息与其部门用户树
//
* 查询指定公司信息与其部门用户树
*/
//
*/
public
CompanyModel
listUserByCompanyId1
(
Long
companyId
)
{
//
public CompanyModel listUserByCompanyId1(Long companyId) {
if
(
companyId
==
null
)
{
//
if (companyId == null) {
return
null
;
//
return null;
}
//
}
CompanyModel
companyModel
=
null
;
//
CompanyModel companyModel = null;
FeignClientResult
feignClientResult
;
//
FeignClientResult feignClientResult;
try
{
//
try {
feignClientResult
=
Privilege
.
companyClient
.
withDeptAndUsers
(
companyId
);
//
feignClientResult = Privilege.companyClient.withDeptAndUsers(companyId);
companyModel
=
(
CompanyModel
)
feignClientResult
.
getResult
();
//
companyModel = (CompanyModel) feignClientResult.getResult();
//
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
return
companyModel
;
//
return companyModel;
//
}
//
}
//
//
//
//
//
public
JSONArray
listDepartmentUserTree
(
Long
companyId
)
{
//
public JSONArray listDepartmentUserTree(Long companyId) {
//
CompanyModel
companyModel
=
null
;
//
CompanyModel companyModel = null;
FeignClientResult
feignClientResult
;
//
FeignClientResult feignClientResult;
try
{
//
try {
feignClientResult
=
Privilege
.
companyClient
.
withDeptAndUsers
(
companyId
);
//
feignClientResult = Privilege.companyClient.withDeptAndUsers(companyId);
companyModel
=
(
CompanyModel
)
feignClientResult
.
getResult
();
//
companyModel = (CompanyModel) feignClientResult.getResult();
//
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
//
if
(
companyModel
!=
null
)
{
//
if (companyModel != null) {
String
jsonStr
=
null
;
//
String jsonStr = null;
//
jsonStr
=
JSON
.
toJSONString
(
companyModel
.
getChildren
());
//
jsonStr = JSON.toJSONString(companyModel.getChildren());
//
return
JSONArray
.
parseArray
(
jsonStr
);
//
return JSONArray.parseArray(jsonStr);
}
//
}
return
null
;
//
return null;
//
}
//
}
//
public
boolean
editPassword
(
String
userId
,
String
oldPassword
,
String
newPassword
)
throws
InnerInvokException
{
//
public boolean editPassword(String userId, String oldPassword, String newPassword) throws InnerInvokException {
boolean
flag
=
false
;
//
boolean flag = false;
AgencyUserModel
agencyUserModel
=
new
AgencyUserModel
();
//
AgencyUserModel agencyUserModel = new AgencyUserModel();
agencyUserModel
.
setPassword
(
newPassword
);
//
agencyUserModel.setPassword(newPassword);
agencyUserModel
.
setRePassword
(
newPassword
);
//
agencyUserModel.setRePassword(newPassword);
agencyUserModel
.
setOriginalPassword
(
oldPassword
);
//
agencyUserModel.setOriginalPassword(oldPassword);
AgencyUserModel
agencyUserModel2
=
null
;
//
AgencyUserModel agencyUserModel2 = null;
FeignClientResult
feignClientResult
;
//
FeignClientResult feignClientResult;
feignClientResult
=
Privilege
.
agencyUserClient
.
modifyPassword
(
userId
,
agencyUserModel
);
//
feignClientResult = Privilege.agencyUserClient.modifyPassword(userId, agencyUserModel);
agencyUserModel
=
(
AgencyUserModel
)
feignClientResult
.
getResult
();
//
agencyUserModel = (AgencyUserModel) feignClientResult.getResult();
if
(
agencyUserModel2
!=
null
)
{
//
if (agencyUserModel2 != null) {
flag
=
true
;
//
flag = true;
}
//
}
return
false
;
//
return false;
}
//
}
//
public
FeignClientResult
<
Map
<
String
,
String
>>
fileImage
(
MultipartFile
file
)
{
//
public FeignClientResult<Map<String, String>> fileImage(MultipartFile file) {
String
product
=
request
.
getHeader
(
"product"
);
//
String product = request.getHeader("product");
String
appKey
=
request
.
getHeader
(
"appKey"
);
//
String appKey = request.getHeader("appKey");
try
{
//
try {
RequestContext
.
setProduct
(
product
);
//
RequestContext.setProduct(product);
RequestContext
.
setAppKey
(
appKey
);
//
RequestContext.setAppKey(appKey);
FeignClientResult
<
Map
<
String
,
String
>>
date
=
Systemctl
.
fileStorageClient
.
updateCommonFile
(
file
);
//
FeignClientResult<Map<String, String>> date = Systemctl.fileStorageClient.updateCommonFile(file);
//
return
date
;
//
return date;
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
//
}
//
}
//
public
FeignClientResult
<
Map
<
String
,
String
>>
fileImage
(
MultipartFile
[]
files
)
{
//
public FeignClientResult<Map<String, String>> fileImage(MultipartFile[] files) {
//
try
{
//
try {
FeignClientResult
<
java
.
util
.
Map
<
String
,
String
>>
date
=
Systemctl
.
fileStorageClient
//
FeignClientResult<java.util.Map<String, String>> date = Systemctl.fileStorageClient
.
updateCommonFiles
(
files
);
//
.updateCommonFiles(files);
//
return
date
;
//
return date;
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
e
.
printStackTrace
();
//
e.printStackTrace();
throw
new
RuntimeException
();
//
throw new RuntimeException();
}
//
}
//
}
//
}
//
public
AgencyUserModel
getAgencyUser
()
{
//
public AgencyUserModel getAgencyUser() {
FeignClientResult
<
AgencyUserModel
>
agencyUser
=
null
;
//
FeignClientResult<AgencyUserModel> agencyUser = null;
AgencyUserModel
userModel
=
null
;
//
AgencyUserModel userModel = null;
try
{
//
try {
AgencyUserClient
agencyUserClient
=
Privilege
.
agencyUserClient
;
//
AgencyUserClient agencyUserClient = Privilege.agencyUserClient;
agencyUser
=
agencyUserClient
.
getme
();
//
agencyUser = agencyUserClient.getme();
userModel
=
agencyUser
.
getResult
();
//
userModel = agencyUser.getResult();
}
catch
(
InnerInvokException
e
)
{
//
} catch (InnerInvokException e) {
throw
new
RuntimeException
(
e
.
getMessage
());
//
throw new RuntimeException(e.getMessage());
}
//
}
return
userModel
;
//
return userModel;
}
//
}
}
//
}
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