Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
maintain_service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
刘帅
maintain_service
Commits
adf968e4
Commit
adf968e4
authored
Jun 14, 2025
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.用户与组织架构数据接口对接
parent
532bf160
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
577 additions
and
19 deletions
+577
-19
SysDeptController.java
...com/maintain/web/controller/system/SysDeptController.java
+13
-6
SysUserController.java
...com/maintain/web/controller/system/SysUserController.java
+8
-4
ExternalDept.java
.../com/maintain/common/core/domain/entity/ExternalDept.java
+72
-0
ExternalUser.java
.../com/maintain/common/core/domain/entity/ExternalUser.java
+115
-0
SysDept.java
.../java/com/maintain/common/core/domain/entity/SysDept.java
+5
-0
ISysDeptService.java
...ain/java/com/maintain/system/service/ISysDeptService.java
+5
-0
ISysUserService.java
...ain/java/com/maintain/system/service/ISysUserService.java
+6
-1
SysDeptServiceImpl.java
.../com/maintain/system/service/impl/SysDeptServiceImpl.java
+50
-0
SysUserServiceImpl.java
.../com/maintain/system/service/impl/SysUserServiceImpl.java
+33
-3
HttpTmEncryptUtil.java
...main/java/com/maintain/system/util/HttpTmEncryptUtil.java
+190
-0
package.json
maintain-ui/package.json
+1
-1
dept.js
maintain-ui/src/api/system/dept.js
+8
-0
user.js
maintain-ui/src/api/system/user.js
+8
-0
index.js
maintain-ui/src/router/index.js
+1
-1
request.js
maintain-ui/src/utils/request.js
+1
-1
index.vue
maintain-ui/src/views/system/dept/index.vue
+26
-1
index.vue
maintain-ui/src/views/system/user/index.vue
+35
-1
No files found.
maintain-admin/src/main/java/com/maintain/web/controller/system/SysDeptController.java
View file @
adf968e4
package
com
.
maintain
.
web
.
controller
.
system
;
package
com
.
maintain
.
web
.
controller
.
system
;
import
cn.dev33.satoken.annotation.SaCheckLogin
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
cn.dev33.satoken.annotation.SaIgnore
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.Convert
;
...
@@ -136,10 +135,18 @@ public class SysDeptController extends BaseController {
...
@@ -136,10 +135,18 @@ public class SysDeptController extends BaseController {
}
}
@SaIgnore
@PostMapping
(
"/deptExtracted"
)
public
R
<
Void
>
deptExtracted
()
{
/**
deptService
.
deptExtracted
();
* 同步外部数据
return
R
.
ok
(
"操作成功"
);
* @return
*/
// @SaIgnore
@SaCheckPermission
(
"system:dept:sync"
)
@Log
(
title
=
"同步部门外部数据"
,
businessType
=
BusinessType
.
OTHER
)
@PostMapping
(
"/deptSync"
)
public
R
<
Void
>
deptSync
()
{
deptService
.
deptSync
();
return
R
.
ok
(
"数据同步成功"
);
}
}
}
}
maintain-admin/src/main/java/com/maintain/web/controller/system/SysUserController.java
View file @
adf968e4
...
@@ -255,10 +255,14 @@ public class SysUserController extends BaseController {
...
@@ -255,10 +255,14 @@ public class SysUserController extends BaseController {
}
}
@SaIgnore
/**
@PostMapping
(
"/userExtracted"
)
* 同步外部用户数据
public
R
<
Void
>
userExtracted
()
{
*/
userService
.
userExtracted
();
// @SaIgnore
@SaCheckPermission
(
"system:user:sync"
)
@PostMapping
(
"/userSync"
)
public
R
<
Void
>
userSync
()
{
userService
.
userSync
();
return
R
.
ok
(
"操作成功"
);
return
R
.
ok
(
"操作成功"
);
}
}
}
}
maintain-common/src/main/java/com/maintain/common/core/domain/entity/ExternalDept.java
0 → 100644
View file @
adf968e4
package
com
.
maintain
.
common
.
core
.
domain
.
entity
;
import
lombok.Data
;
/**
* 外部部门
*/
public
class
ExternalDept
{
private
String
deptName
;
private
String
upperDeptName
;
private
String
upperDeptCode
;
private
String
deptType
;
private
String
deptCode
;
private
String
deptFullName
;
private
String
status
;
public
String
getDeptName
()
{
return
deptName
;
}
public
void
setDeptName
(
String
deptName
)
{
this
.
deptName
=
deptName
;
}
public
String
getUpperDeptName
()
{
return
upperDeptName
;
}
public
void
setUpperDeptName
(
String
upperDeptName
)
{
this
.
upperDeptName
=
upperDeptName
;
}
public
String
getUpperDeptCode
()
{
return
upperDeptCode
;
}
public
void
setUpperDeptCode
(
String
upperDeptCode
)
{
this
.
upperDeptCode
=
upperDeptCode
;
}
public
String
getDeptType
()
{
return
deptType
;
}
public
void
setDeptType
(
String
deptType
)
{
this
.
deptType
=
deptType
;
}
public
String
getDeptCode
()
{
return
deptCode
;
}
public
void
setDeptCode
(
String
deptCode
)
{
this
.
deptCode
=
deptCode
;
}
public
String
getDeptFullName
()
{
return
deptFullName
;
}
public
void
setDeptFullName
(
String
deptFullName
)
{
this
.
deptFullName
=
deptFullName
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
}
maintain-common/src/main/java/com/maintain/common/core/domain/entity/ExternalUser.java
0 → 100644
View file @
adf968e4
package
com
.
maintain
.
common
.
core
.
domain
.
entity
;
/**
* 外部部门
*/
public
class
ExternalUser
{
private
String
filaNo
;
private
String
groupName
;
private
String
lineNo
;
private
String
empName
;
private
String
statusName
;
private
String
lineName
;
private
String
empNo
;
private
String
groupNo
;
private
String
subStatusName
;
private
String
filaName
;
private
String
subStatus
;
private
String
status
;
public
String
getFilaNo
()
{
return
filaNo
;
}
public
void
setFilaNo
(
String
filaNo
)
{
this
.
filaNo
=
filaNo
;
}
public
String
getGroupName
()
{
return
groupName
;
}
public
void
setGroupName
(
String
groupName
)
{
this
.
groupName
=
groupName
;
}
public
String
getLineNo
()
{
return
lineNo
;
}
public
void
setLineNo
(
String
lineNo
)
{
this
.
lineNo
=
lineNo
;
}
public
String
getEmpName
()
{
return
empName
;
}
public
void
setEmpName
(
String
empName
)
{
this
.
empName
=
empName
;
}
public
String
getStatusName
()
{
return
statusName
;
}
public
void
setStatusName
(
String
statusName
)
{
this
.
statusName
=
statusName
;
}
public
String
getLineName
()
{
return
lineName
;
}
public
void
setLineName
(
String
lineName
)
{
this
.
lineName
=
lineName
;
}
public
String
getEmpNo
()
{
return
empNo
;
}
public
void
setEmpNo
(
String
empNo
)
{
this
.
empNo
=
empNo
;
}
public
String
getGroupNo
()
{
return
groupNo
;
}
public
void
setGroupNo
(
String
groupNo
)
{
this
.
groupNo
=
groupNo
;
}
public
String
getSubStatusName
()
{
return
subStatusName
;
}
public
void
setSubStatusName
(
String
subStatusName
)
{
this
.
subStatusName
=
subStatusName
;
}
public
String
getFilaName
()
{
return
filaName
;
}
public
void
setFilaName
(
String
filaName
)
{
this
.
filaName
=
filaName
;
}
public
String
getSubStatus
()
{
return
subStatus
;
}
public
void
setSubStatus
(
String
subStatus
)
{
this
.
subStatus
=
subStatus
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
}
maintain-common/src/main/java/com/maintain/common/core/domain/entity/SysDept.java
View file @
adf968e4
...
@@ -72,6 +72,11 @@ public class SysDept extends TreeEntity<SysDept> {
...
@@ -72,6 +72,11 @@ public class SysDept extends TreeEntity<SysDept> {
@TableLogic
@TableLogic
private
String
delFlag
;
private
String
delFlag
;
/**
* 外部code
*/
private
String
externalDeptCode
;
/**
/**
* 祖级列表
* 祖级列表
*/
*/
...
...
maintain-system/src/main/java/com/maintain/system/service/ISysDeptService.java
View file @
adf968e4
...
@@ -125,4 +125,9 @@ public interface ISysDeptService {
...
@@ -125,4 +125,9 @@ public interface ISysDeptService {
* 外部数据创建
* 外部数据创建
*/
*/
void
deptExtracted
();
void
deptExtracted
();
/**
* 根据外部接口同步部门数据
*/
void
deptSync
();
}
}
maintain-system/src/main/java/com/maintain/system/service/ISysUserService.java
View file @
adf968e4
...
@@ -209,8 +209,13 @@ public interface ISysUserService {
...
@@ -209,8 +209,13 @@ public interface ISysUserService {
int
deleteUserByIds
(
Long
[]
userIds
);
int
deleteUserByIds
(
Long
[]
userIds
);
/**
/**
*
外部数据创建
*
根据文件同步外部数据
*/
*/
void
userExtracted
();
void
userExtracted
();
/**
* 根据接口同步外部数据
*/
void
userSync
();
}
}
maintain-system/src/main/java/com/maintain/system/service/impl/SysDeptServiceImpl.java
View file @
adf968e4
package
com
.
maintain
.
system
.
service
.
impl
;
package
com
.
maintain
.
system
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.convert.Convert
;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.lang.tree.Tree
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.maintain.common.constant.CacheNames
;
import
com.maintain.common.constant.CacheNames
;
import
com.maintain.common.constant.UserConstants
;
import
com.maintain.common.constant.UserConstants
;
import
com.maintain.common.core.domain.entity.ExternalDept
;
import
com.maintain.common.core.domain.entity.SysDept
;
import
com.maintain.common.core.domain.entity.SysDept
;
import
com.maintain.common.core.domain.entity.SysRole
;
import
com.maintain.common.core.domain.entity.SysRole
;
import
com.maintain.common.core.domain.entity.SysUser
;
import
com.maintain.common.core.domain.entity.SysUser
;
import
com.maintain.common.core.service.DeptService
;
import
com.maintain.common.core.service.DeptService
;
import
com.maintain.common.enums.IsEnableStatus
;
import
com.maintain.common.exception.ServiceException
;
import
com.maintain.common.exception.ServiceException
;
import
com.maintain.common.helper.DataBaseHelper
;
import
com.maintain.common.helper.DataBaseHelper
;
import
com.maintain.common.helper.LoginHelper
;
import
com.maintain.common.helper.LoginHelper
;
...
@@ -32,6 +37,7 @@ import org.springframework.stereotype.Service;
...
@@ -32,6 +37,7 @@ import org.springframework.stereotype.Service;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 部门管理 服务实现
* 部门管理 服务实现
...
@@ -323,4 +329,48 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
...
@@ -323,4 +329,48 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
baseMapper
.
insertBatch
(
sysDeptList
);
baseMapper
.
insertBatch
(
sysDeptList
);
}
}
/**
* 根据外部接口同步部门数据
*/
@Override
public
void
deptSync
()
{
String
res
=
com
.
zxw
.
util
.
tm
.
HttpTmEncryptUtil
.
sendPostRequest
(
"http://10.100.102.67:22220/api/basis/deptInfoExtRepair"
,
null
,
null
);
Map
map
=
JSONUtil
.
toBean
(
res
,
Map
.
class
);
List
<
ExternalDept
>
departmentList
=
JSONUtil
.
toList
(
JSONUtil
.
toJsonStr
(
map
.
get
(
"data"
)),
ExternalDept
.
class
);
departmentList
.
forEach
(
department
->
{
SysDept
selectOne
=
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
SysDept
>().
eq
(
SysDept:
:
getExternalDeptCode
,
department
.
getDeptCode
()));
// 查询是否已存在系统
if
(
null
==
selectOne
)
{
SysDept
dept
=
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
SysDept
>().
eq
(
SysDept:
:
getExternalDeptCode
,
department
.
getUpperDeptCode
()));
if
(
dept
!=
null
)
{
SysDept
sysDept
=
new
SysDept
();
sysDept
.
setAncestors
(
dept
.
getAncestors
()
+
StringUtils
.
SEPARATOR
+
dept
.
getDeptId
());
sysDept
.
setParentId
(
dept
.
getDeptId
());
sysDept
.
setDeptName
(
department
.
getDeptName
());
sysDept
.
setExternalDeptCode
(
department
.
getDeptCode
());
// 状态转换
sysDept
.
setStatus
(
department
.
getStatus
().
equals
(
"已启用"
)
?
String
.
valueOf
(
IsEnableStatus
.
YES
.
getCode
())
// 已启用对应YES
:
String
.
valueOf
(
IsEnableStatus
.
NO
.
getCode
())
);
baseMapper
.
insert
(
sysDept
);
}
else
if
(
department
.
getUpperDeptCode
().
equals
(
"-1"
))
{
SysDept
sysDept
=
new
SysDept
();
sysDept
.
setAncestors
(
"0,1"
);
sysDept
.
setParentId
(
1L
);
sysDept
.
setDeptName
(
department
.
getDeptName
());
sysDept
.
setExternalDeptCode
(
department
.
getDeptCode
());
// 状态转换
sysDept
.
setStatus
(
department
.
getStatus
().
equals
(
"已启用"
)
?
String
.
valueOf
(
IsEnableStatus
.
YES
.
getCode
())
// 已启用对应YES
:
String
.
valueOf
(
IsEnableStatus
.
NO
.
getCode
())
);
baseMapper
.
insert
(
sysDept
);
}
}
});
}
}
}
maintain-system/src/main/java/com/maintain/system/service/impl/SysUserServiceImpl.java
View file @
adf968e4
package
com
.
maintain
.
system
.
service
.
impl
;
package
com
.
maintain
.
system
.
service
.
impl
;
import
cn.dev33.satoken.secure.BCrypt
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
@@ -12,11 +14,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -12,11 +14,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.maintain.common.constant.CacheNames
;
import
com.maintain.common.constant.CacheNames
;
import
com.maintain.common.constant.UserConstants
;
import
com.maintain.common.constant.UserConstants
;
import
com.maintain.common.core.domain.PageQuery
;
import
com.maintain.common.core.domain.PageQuery
;
import
com.maintain.common.core.domain.entity.SysDept
;
import
com.maintain.common.core.domain.entity.*
;
import
com.maintain.common.core.domain.entity.SysRole
;
import
com.maintain.common.core.domain.entity.SysUser
;
import
com.maintain.common.core.page.TableDataInfo
;
import
com.maintain.common.core.page.TableDataInfo
;
import
com.maintain.common.core.service.UserService
;
import
com.maintain.common.core.service.UserService
;
import
com.maintain.common.enums.UserStatus
;
import
com.maintain.common.exception.ServiceException
;
import
com.maintain.common.exception.ServiceException
;
import
com.maintain.common.helper.DataBaseHelper
;
import
com.maintain.common.helper.DataBaseHelper
;
import
com.maintain.common.helper.LoginHelper
;
import
com.maintain.common.helper.LoginHelper
;
...
@@ -34,6 +35,7 @@ import org.springframework.cache.annotation.Cacheable;
...
@@ -34,6 +35,7 @@ import org.springframework.cache.annotation.Cacheable;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -490,4 +492,32 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
...
@@ -490,4 +492,32 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
baseMapper
.
insertBatch
(
userList
);
baseMapper
.
insertBatch
(
userList
);
}
}
/**
* 根据接口同步外部数据
*/
@Override
public
void
userSync
()
{
String
res
=
com
.
zxw
.
util
.
tm
.
HttpTmEncryptUtil
.
sendPostRequest
(
"http://10.100.102.67:22220/api/basis/empInfoExtRepair"
,
null
,
null
);
Map
map
=
JSONUtil
.
toBean
(
res
,
Map
.
class
);
List
<
ExternalUser
>
externalUserList
=
JSONUtil
.
toList
(
JSONUtil
.
toJsonStr
(
map
.
get
(
"data"
)),
ExternalUser
.
class
);
List
<
SysUser
>
users
=
new
ArrayList
<>();
List
<
SysUser
>
sysUserList
=
baseMapper
.
selectList
();
List
<
SysDept
>
sysDeptList
=
deptMapper
.
selectList
();
externalUserList
.
forEach
(
externalUser
->
{
if
(
sysUserList
.
stream
().
noneMatch
(
item
->
externalUser
.
getEmpNo
().
equals
(
item
.
getUserName
())))
{
SysUser
sysUser
=
new
SysUser
();
SysDept
dept
=
sysDeptList
.
stream
().
filter
(
item
->
item
.
getExternalDeptCode
().
equals
(
externalUser
.
getGroupNo
()))
.
findFirst
()
.
orElseThrow
(()
->
new
RuntimeException
(
"未找到部门="
+
externalUser
.
getGroupNo
()));
sysUser
.
setDeptId
(
dept
!=
null
?
dept
.
getDeptId
()
:
null
);
sysUser
.
setUserName
(
externalUser
.
getEmpNo
());
sysUser
.
setNickName
(
externalUser
.
getEmpName
());
sysUser
.
setStatus
(
externalUser
.
getStatusName
().
equals
(
"在职"
)
?
UserStatus
.
OK
.
getCode
()
:
UserStatus
.
DISABLE
.
getCode
());
sysUser
.
setPassword
(
BCrypt
.
hashpw
(
externalUser
.
getEmpNo
()));
users
.
add
(
sysUser
);
}
});
baseMapper
.
insertBatch
(
users
);
}
}
}
maintain-system/src/main/java/com/maintain/system/util/HttpTmEncryptUtil.java
0 → 100644
View file @
adf968e4
package
com
.
zxw
.
util
.
tm
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.json.JSONObject
;
import
org.apache.commons.codec.digest.HmacUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.lang.Nullable
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
sun.misc.BASE64Decoder
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.net.*
;
import
java.nio.charset.StandardCharsets
;
import
java.security.Key
;
import
java.util.*
;
/**
* 天迈数据http请求
*/
public
class
HttpTmEncryptUtil
{
/**
* 客户端appid
*/
private
static
String
appId
=
"1924051882771222530"
;
/**
* 客户端鉴权密钥
*/
private
static
String
secret
=
"869v5NED"
;
/**
* 数据加密密钥
*/
private
static
String
secretKey
=
"..."
;
/**
* 天迈数据请求地址
*/
private
static
final
String
TM_PERSON_DATA_URL
=
"http://10.100.102.67:22220/api/basis/deptInfoExtRepair"
;
// 示例调用
public
static
void
main
(
String
[]
args
)
{
// 构造请求参数
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>();
// params.add("dataDate", "20250301");
// params.add("curPage", "1");
// params.add("pageSize", "10");
JSONObject
boby
=
new
JSONObject
();
boby
.
append
(
"curPage"
,
"1"
);
boby
.
append
(
"pageSize"
,
"1"
);
// 构造请求体(JSON)
// String body = "{\"dataDate\":\"20250301\"}";
// 发送请求
String
response
=
sendPostRequest
(
TM_PERSON_DATA_URL
,
params
,
boby
.
toString
());
System
.
out
.
println
(
"响应结果: "
+
response
);
}
/**
* 构建带有鉴权头的POST请求
*/
public
static
String
sendPostRequest
(
String
url
,
MultiValueMap
<
String
,
String
>
params
,
String
body
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
try
{
// 1. 生成鉴权头
HttpHeaders
headers
=
getHeaders
(
params
,
body
);
// 2. 构建请求实体(包含头和体)
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
body
,
headers
);
// 3. 发送POST请求
ResponseEntity
<
String
>
response
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
return
response
.
getBody
();
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
"编码错误"
,
e
);
}
}
/**
* 拼装请求数据
*
* @param appid appid
* @param timestamp 时间戳
* @param params 参数
* @param body 请求体
*/
public
static
String
baseString
(
String
appid
,
long
timestamp
,
MultiValueMap
<
String
,
String
>
params
,
@Nullable
String
body
)
throws
UnsupportedEncodingException
{
StringBuilder
baseString
=
new
StringBuilder
();
if
(
MapUtils
.
isNotEmpty
(
params
))
{
params
.
keySet
().
stream
().
sorted
().
forEach
(
key
->
{
List
<
String
>
values
=
params
.
get
(
key
);
if
(
CollectionUtils
.
isNotEmpty
(
values
))
{
baseString
.
append
(
key
).
append
(
"="
);
baseString
.
append
(
values
.
size
()
==
1
?
values
.
get
(
0
)
:
Arrays
.
toString
(
values
.
toArray
()));
baseString
.
append
(
"&"
);
}
});
}
baseString
.
append
(
"appid="
).
append
(
appid
).
append
(
"&"
);
baseString
.
append
(
"timestamp="
).
append
(
timestamp
);
if
(
StringUtils
.
isNotBlank
(
body
))
{
body
=
body
.
replaceAll
(
"\\s*"
,
StringUtils
.
EMPTY
);
baseString
.
append
(
"&body="
).
append
(
body
);
}
return
URLDecoder
.
decode
(
baseString
.
toString
(),
StandardCharsets
.
UTF_8
.
name
());
}
/**
* 生成摘要digest
*
* @param secret secret
* @param salt 拼接好的请求参数字符串
*/
public
static
String
encode
(
String
secret
,
String
salt
)
{
final
byte
[]
key
=
secret
.
getBytes
(
StandardCharsets
.
UTF_8
);
final
byte
[]
digest
=
salt
.
getBytes
(
StandardCharsets
.
UTF_8
);
byte
[]
bytes
=
HmacUtils
.
hmacSha1
(
key
,
digest
);
return
Base64
.
encode
(
bytes
);
}
/**
* 获取鉴权Authorization
*
* @param timestamp 当前请求时间戳
* @param params 请求url参数
* @param body 请求体
* @return 鉴权Authorization
*/
private
static
String
getAuthorization
(
long
timestamp
,
MultiValueMap
<
String
,
String
>
params
,
String
body
)
throws
UnsupportedEncodingException
{
String
salt
=
baseString
(
appId
,
timestamp
,
params
,
body
);
return
"HmacSHA "
+
appId
+
":"
+
timestamp
+
":"
+
encode
(
secret
,
salt
);
}
/**
* 获取设置鉴权的HttpHeaders
*
* @param params 请求url参数
* @param body 请求体
* @return HttpHeaders
*/
private
static
HttpHeaders
getHeaders
(
MultiValueMap
<
String
,
String
>
params
,
String
body
)
throws
UnsupportedEncodingException
{
// 当前请求时间戳
long
timestamp
=
System
.
currentTimeMillis
();
String
authorization
=
getAuthorization
(
timestamp
,
params
,
body
);
HttpHeaders
httpHeaders
=
new
HttpHeaders
();
httpHeaders
.
set
(
"Content-Type"
,
"application/json"
);
httpHeaders
.
set
(
"Authorization"
,
authorization
);
System
.
out
.
println
(
authorization
);
return
httpHeaders
;
}
/**
* 解密
* @param result 返回数据(AES加密后的)
* @return 解密数据
*/
protected
String
decrypt
(
String
result
)
throws
Exception
{
// 将接口返回的加密数据使用BASE64算法解码
byte
[]
datas
=
new
BASE64Decoder
().
decodeBuffer
(
result
);
// 使用AES/ECB/PKCS5Padding解密算法
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/ECB/PKCS5Padding"
);
// 使用服务端发放的128位解密密钥secretKey
Key
key
=
new
SecretKeySpec
(
secretKey
.
getBytes
(),
"AES"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
key
);
//解密
byte
[]
bytes
=
cipher
.
doFinal
(
datas
);
// 将解密的字节数组转出字符串使用
return
new
String
(
bytes
,
StandardCharsets
.
UTF_8
);
}
}
maintain-ui/package.json
View file @
adf968e4
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"name"
:
"ruoyi-vue-plus"
,
"name"
:
"ruoyi-vue-plus"
,
"version"
:
"4.8.2"
,
"version"
:
"4.8.2"
,
"description"
:
"维修管理系统"
,
"description"
:
"维修管理系统"
,
"author"
:
"Li
onL
i"
,
"author"
:
"Li
uShua
i"
,
"license"
:
"MIT"
,
"license"
:
"MIT"
,
"scripts"
:
{
"scripts"
:
{
"dev"
:
"vue-cli-service serve"
,
"dev"
:
"vue-cli-service serve"
,
...
...
maintain-ui/src/api/system/dept.js
View file @
adf968e4
...
@@ -50,3 +50,11 @@ export function delDept(deptId) {
...
@@ -50,3 +50,11 @@ export function delDept(deptId) {
method
:
'
delete
'
method
:
'
delete
'
})
})
}
}
// 删除部门
export
function
deptSync
()
{
return
request
({
url
:
'
/system/dept/deptSync
'
,
method
:
'
post
'
})
}
maintain-ui/src/api/system/user.js
View file @
adf968e4
...
@@ -133,3 +133,11 @@ export function deptTreeSelect() {
...
@@ -133,3 +133,11 @@ export function deptTreeSelect() {
method
:
'
get
'
method
:
'
get
'
})
})
}
}
// 同步用户数据
export
function
userSync
()
{
return
request
({
url
:
'
/system/user/userSync
'
,
method
:
'
post
'
})
}
maintain-ui/src/router/index.js
View file @
adf968e4
...
@@ -68,7 +68,7 @@ export const constantRoutes = [
...
@@ -68,7 +68,7 @@ export const constantRoutes = [
children
:
[
children
:
[
{
{
path
:
'
index
'
,
path
:
'
index
'
,
component
:
()
=>
import
(
'
@/views/index
'
),
component
:
()
=>
import
(
'
@/views/
business/repairForm/
index
'
),
name
:
'
Index
'
,
name
:
'
Index
'
,
meta
:
{
title
:
'
首页
'
,
icon
:
'
dashboard
'
,
affix
:
true
}
meta
:
{
title
:
'
首页
'
,
icon
:
'
dashboard
'
,
affix
:
true
}
}
}
...
...
maintain-ui/src/utils/request.js
View file @
adf968e4
...
@@ -19,7 +19,7 @@ const service = axios.create({
...
@@ -19,7 +19,7 @@ const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
// axios中请求配置有baseURL选项,表示请求URL公共部分
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
baseURL
:
process
.
env
.
VUE_APP_BASE_API
,
// 超时
// 超时
timeout
:
1
0000
timeout
:
5
0000
})
})
// request拦截器
// request拦截器
...
...
maintain-ui/src/views/system/dept/index.vue
View file @
adf968e4
...
@@ -45,6 +45,17 @@
...
@@ -45,6 +45,17 @@
@
click=
"toggleExpandAll"
@
click=
"toggleExpandAll"
>
展开/折叠
</el-button>
>
展开/折叠
</el-button>
</el-col>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"success"
plain
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"clickSync"
:loading=
"syncLoading"
v-hasPermi=
"['system:dept:sync']"
>
同步数据
</el-button>
</el-col>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
></right-toolbar>
</el-row>
</el-row>
...
@@ -158,7 +169,7 @@
...
@@ -158,7 +169,7 @@
</template>
</template>
<
script
>
<
script
>
import
{
listDept
,
getDept
,
delDept
,
addDept
,
updateDept
,
listDeptExcludeChild
}
from
"
@/api/system/dept
"
;
import
{
listDept
,
getDept
,
delDept
,
addDept
,
updateDept
,
listDeptExcludeChild
,
sync
,
deptSync
}
from
"
@/api/system/dept
"
;
import
Treeselect
from
"
@riophae/vue-treeselect
"
;
import
Treeselect
from
"
@riophae/vue-treeselect
"
;
import
"
@riophae/vue-treeselect/dist/vue-treeselect.css
"
;
import
"
@riophae/vue-treeselect/dist/vue-treeselect.css
"
;
...
@@ -170,6 +181,7 @@ export default {
...
@@ -170,6 +181,7 @@ export default {
return
{
return
{
// 遮罩层
// 遮罩层
loading
:
true
,
loading
:
true
,
syncLoading
:
false
,
// 显示搜索条件
// 显示搜索条件
showSearch
:
true
,
showSearch
:
true
,
// 表格树数据
// 表格树数据
...
@@ -306,6 +318,19 @@ export default {
...
@@ -306,6 +318,19 @@ export default {
});
});
});
});
},
},
clickSync
()
{
const
loading
=
this
.
$loading
({
lock
:
true
,
text
:
'
数据同步中,预计需要5-30秒
'
,
spinner
:
'
el-icon-loading
'
,
background
:
'
rgba(0, 0, 0, 0.7)
'
});
deptSync
().
then
(
response
=>
{
this
.
$modal
.
msgSuccess
(
"
数据同步成功
"
);
loading
.
close
()
this
.
getList
();
});
},
/** 提交按钮 */
/** 提交按钮 */
submitForm
:
function
()
{
submitForm
:
function
()
{
this
.
$refs
[
"
form
"
].
validate
(
valid
=>
{
this
.
$refs
[
"
form
"
].
validate
(
valid
=>
{
...
...
maintain-ui/src/views/system/user/index.vue
View file @
adf968e4
...
@@ -134,6 +134,16 @@
...
@@ -134,6 +134,16 @@
v-hasPermi=
"['system:user:export']"
v-hasPermi=
"['system:user:export']"
>
导出
</el-button>
>
导出
</el-button>
</el-col>
</el-col>
<el-col
:span=
"1.5"
>
<el-button
type=
"success"
plain
icon=
"el-icon-refresh"
size=
"mini"
@
click=
"clickSync"
v-hasPermi=
"['system:user:sync']"
>
同步数据
</el-button>
</el-col>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
:columns=
"columns"
></right-toolbar>
<right-toolbar
:showSearch.sync=
"showSearch"
@
queryTable=
"getList"
:columns=
"columns"
></right-toolbar>
</el-row>
</el-row>
...
@@ -342,10 +352,21 @@
...
@@ -342,10 +352,21 @@
</template>
</template>
<
script
>
<
script
>
import
{
listUser
,
getUser
,
delUser
,
addUser
,
updateUser
,
resetUserPwd
,
changeUserStatus
,
deptTreeSelect
}
from
"
@/api/system/user
"
;
import
{
listUser
,
getUser
,
delUser
,
addUser
,
updateUser
,
resetUserPwd
,
changeUserStatus
,
deptTreeSelect
,
userSync
}
from
"
@/api/system/user
"
;
import
{
getToken
}
from
"
@/utils/auth
"
;
import
{
getToken
}
from
"
@/utils/auth
"
;
import
Treeselect
from
"
@riophae/vue-treeselect
"
;
import
Treeselect
from
"
@riophae/vue-treeselect
"
;
import
"
@riophae/vue-treeselect/dist/vue-treeselect.css
"
;
import
"
@riophae/vue-treeselect/dist/vue-treeselect.css
"
;
import
{
sync
}
from
"
@/api/system/dept
"
;
export
default
{
export
default
{
name
:
"
User
"
,
name
:
"
User
"
,
...
@@ -634,6 +655,19 @@ export default {
...
@@ -634,6 +655,19 @@ export default {
this
.
$modal
.
msgSuccess
(
"
删除成功
"
);
this
.
$modal
.
msgSuccess
(
"
删除成功
"
);
}).
catch
(()
=>
{});
}).
catch
(()
=>
{});
},
},
clickSync
()
{
const
loading
=
this
.
$loading
({
lock
:
true
,
text
:
'
数据同步中,预计需要5-30秒
'
,
spinner
:
'
el-icon-loading
'
,
background
:
'
rgba(0, 0, 0, 0.7)
'
});
userSync
().
then
(
response
=>
{
this
.
$modal
.
msgSuccess
(
"
数据同步成功
"
);
loading
.
close
()
this
.
getList
();
});
},
/** 导出按钮操作 */
/** 导出按钮操作 */
handleExport
()
{
handleExport
()
{
this
.
download
(
'
system/user/export
'
,
{
this
.
download
(
'
system/user/export
'
,
{
...
...
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