Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dsk-operate-sys-cscec
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
fulixin
dsk-operate-sys-cscec
Commits
d0944724
Commit
d0944724
authored
Nov 23, 2023
by
lcl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
u
parent
fb3a2254
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
29 deletions
+81
-29
SysConfigController.java
...va/com/dsk/web/controller/system/SysConfigController.java
+15
-0
ISysConfigService.java
...c/main/java/com/dsk/system/service/ISysConfigService.java
+7
-0
SysConfigServiceImpl.java
...ava/com/dsk/system/service/impl/SysConfigServiceImpl.java
+59
-29
No files found.
dsk-admin/src/main/java/com/dsk/web/controller/system/SysConfigController.java
View file @
d0944724
...
...
@@ -9,6 +9,7 @@ import com.dsk.common.core.domain.R;
import
com.dsk.common.core.domain.model.DskAccessTokenVO
;
import
com.dsk.common.core.page.TableDataInfo
;
import
com.dsk.common.enums.BusinessType
;
import
com.dsk.common.tenant.helper.TenantHelper
;
import
com.dsk.common.utils.poi.ExcelUtil
;
import
com.dsk.system.domain.SysConfig
;
import
com.dsk.system.service.ISysConfigService
;
...
...
@@ -87,6 +88,20 @@ public class SysConfigController extends BaseController {
return
R
.
ok
();
}
/**
* 新增租户参数配置
*/
@SaCheckPermission
(
"system:config:tenant:add"
)
@Log
(
title
=
"参数管理"
,
businessType
=
BusinessType
.
INSERT
)
@PostMapping
(
"/tenant/add"
)
public
R
<
Void
>
tenantAdd
(
@Validated
@RequestBody
SysConfig
config
)
{
if
(!
configService
.
checkConfigKeyUnique
(
config
))
{
return
R
.
fail
(
"新增参数'"
+
config
.
getConfigName
()
+
"'失败,参数键名已存在"
);
}
TenantHelper
.
ignore
(()->
configService
.
insertTenantConfig
(
config
));
return
R
.
ok
();
}
/**
* 修改参数配置
*/
...
...
dsk-system/src/main/java/com/dsk/system/service/ISysConfigService.java
View file @
d0944724
...
...
@@ -55,6 +55,13 @@ public interface ISysConfigService {
* @return 结果
*/
String
insertConfig
(
SysConfig
config
);
/**
* 新增租户参数配置
*
* @param config 参数配置信息
* @return 结果
*/
String
insertTenantConfig
(
SysConfig
config
);
/**
* 修改参数配置
...
...
dsk-system/src/main/java/com/dsk/system/service/impl/SysConfigServiceImpl.java
View file @
d0944724
...
...
@@ -10,9 +10,11 @@ import cn.hutool.core.util.StrUtil;
import
cn.hutool.http.HttpUtil
;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.CollectionUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.dsk.common.constant.CacheNames
;
import
com.dsk.common.constant.TenantConstants
;
import
com.dsk.common.constant.UserConstants
;
import
com.dsk.common.core.domain.PageQuery
;
import
com.dsk.common.core.domain.model.DskAccessTokenVO
;
...
...
@@ -24,7 +26,9 @@ import com.dsk.common.utils.StringUtils;
import
com.dsk.common.utils.redis.CacheUtils
;
import
com.dsk.common.utils.spring.SpringUtils
;
import
com.dsk.system.domain.SysConfig
;
import
com.dsk.system.domain.SysTenant
;
import
com.dsk.system.mapper.SysConfigMapper
;
import
com.dsk.system.mapper.SysTenantMapper
;
import
com.dsk.system.service.ISysConfigService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -32,10 +36,7 @@ import org.springframework.cache.annotation.CachePut;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
* 参数配置 服务层实现
...
...
@@ -49,15 +50,17 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
private
final
SysConfigMapper
baseMapper
;
private
final
SysTenantMapper
tenantMapper
;
@Override
public
TableDataInfo
<
SysConfig
>
selectPageConfigList
(
SysConfig
config
,
PageQuery
pageQuery
)
{
Map
<
String
,
Object
>
params
=
config
.
getParams
();
LambdaQueryWrapper
<
SysConfig
>
lqw
=
new
LambdaQueryWrapper
<
SysConfig
>()
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigName
()),
SysConfig:
:
getConfigName
,
config
.
getConfigName
())
.
eq
(
StringUtils
.
isNotBlank
(
config
.
getConfigType
()),
SysConfig:
:
getConfigType
,
config
.
getConfigType
())
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigKey
()),
SysConfig:
:
getConfigKey
,
config
.
getConfigKey
())
.
between
(
params
.
get
(
"beginTime"
)
!=
null
&&
params
.
get
(
"endTime"
)
!=
null
,
SysConfig:
:
getCreateTime
,
params
.
get
(
"beginTime"
),
params
.
get
(
"endTime"
));
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigName
()),
SysConfig:
:
getConfigName
,
config
.
getConfigName
())
.
eq
(
StringUtils
.
isNotBlank
(
config
.
getConfigType
()),
SysConfig:
:
getConfigType
,
config
.
getConfigType
())
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigKey
()),
SysConfig:
:
getConfigKey
,
config
.
getConfigKey
())
.
between
(
params
.
get
(
"beginTime"
)
!=
null
&&
params
.
get
(
"endTime"
)
!=
null
,
SysConfig:
:
getCreateTime
,
params
.
get
(
"beginTime"
),
params
.
get
(
"endTime"
));
Page
<
SysConfig
>
page
=
baseMapper
.
selectPage
(
pageQuery
.
build
(),
lqw
);
return
TableDataInfo
.
build
(
page
);
}
...
...
@@ -84,7 +87,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
@Override
public
String
selectConfigByKey
(
String
configKey
)
{
SysConfig
retConfig
=
baseMapper
.
selectOne
(
new
LambdaQueryWrapper
<
SysConfig
>()
.
eq
(
SysConfig:
:
getConfigKey
,
configKey
));
.
eq
(
SysConfig:
:
getConfigKey
,
configKey
));
if
(
ObjectUtil
.
isNotNull
(
retConfig
))
{
return
retConfig
.
getConfigValue
();
}
...
...
@@ -115,11 +118,11 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
public
List
<
SysConfig
>
selectConfigList
(
SysConfig
config
)
{
Map
<
String
,
Object
>
params
=
config
.
getParams
();
LambdaQueryWrapper
<
SysConfig
>
lqw
=
new
LambdaQueryWrapper
<
SysConfig
>()
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigName
()),
SysConfig:
:
getConfigName
,
config
.
getConfigName
())
.
eq
(
StringUtils
.
isNotBlank
(
config
.
getConfigType
()),
SysConfig:
:
getConfigType
,
config
.
getConfigType
())
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigKey
()),
SysConfig:
:
getConfigKey
,
config
.
getConfigKey
())
.
between
(
params
.
get
(
"beginTime"
)
!=
null
&&
params
.
get
(
"endTime"
)
!=
null
,
SysConfig:
:
getCreateTime
,
params
.
get
(
"beginTime"
),
params
.
get
(
"endTime"
));
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigName
()),
SysConfig:
:
getConfigName
,
config
.
getConfigName
())
.
eq
(
StringUtils
.
isNotBlank
(
config
.
getConfigType
()),
SysConfig:
:
getConfigType
,
config
.
getConfigType
())
.
like
(
StringUtils
.
isNotBlank
(
config
.
getConfigKey
()),
SysConfig:
:
getConfigKey
,
config
.
getConfigKey
())
.
between
(
params
.
get
(
"beginTime"
)
!=
null
&&
params
.
get
(
"endTime"
)
!=
null
,
SysConfig:
:
getCreateTime
,
params
.
get
(
"beginTime"
),
params
.
get
(
"endTime"
));
return
baseMapper
.
selectList
(
lqw
);
}
...
...
@@ -139,6 +142,33 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
throw
new
ServiceException
(
"操作失败"
);
}
/**
* 新增参数配置
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public
String
insertTenantConfig
(
SysConfig
config
)
{
List
<
SysConfig
>
list
=
new
ArrayList
<>();
SysConfig
bean
=
new
SysConfig
();
BeanUtil
.
copyProperties
(
config
,
bean
);
bean
.
setTenantId
(
TenantConstants
.
DEFAULT_TENANT_ID
);
List
<
SysTenant
>
sysTenants
=
tenantMapper
.
selectList
();
if
(
CollectionUtils
.
isEmpty
(
sysTenants
))
{
}
int
row
=
baseMapper
.
insert
(
config
);
if
(
row
>
0
)
{
return
config
.
getConfigValue
();
}
throw
new
ServiceException
(
"操作失败"
);
}
/**
* 修改参数配置
*
...
...
@@ -157,7 +187,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
row
=
baseMapper
.
updateById
(
config
);
}
else
{
row
=
baseMapper
.
update
(
config
,
new
LambdaQueryWrapper
<
SysConfig
>()
.
eq
(
SysConfig:
:
getConfigKey
,
config
.
getConfigKey
()));
.
eq
(
SysConfig:
:
getConfigKey
,
config
.
getConfigKey
()));
}
if
(
row
>
0
)
{
return
config
.
getConfigValue
();
...
...
@@ -189,7 +219,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
public
void
loadingConfigCache
()
{
List
<
SysConfig
>
configsList
=
selectConfigList
(
new
SysConfig
());
configsList
.
forEach
(
config
->
CacheUtils
.
put
(
CacheNames
.
SYS_CONFIG
,
config
.
getConfigKey
(),
config
.
getConfigValue
()));
CacheUtils
.
put
(
CacheNames
.
SYS_CONFIG
,
config
.
getConfigKey
(),
config
.
getConfigValue
()));
}
/**
...
...
@@ -228,10 +258,10 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
@Override
public
DskAccessTokenVO
getDskAccessToken
()
{
List
<
SysConfig
>
dskName
=
queryListByKey
(
"dsk"
);
Assert
.
notEmpty
(
dskName
,
"大司空数据APPkey配置异常"
);
Map
<
String
,
Object
>
dskConfig
=
new
HashMap
<>();
Assert
.
notEmpty
(
dskName
,
"大司空数据APPkey配置异常"
);
Map
<
String
,
Object
>
dskConfig
=
new
HashMap
<>();
for
(
SysConfig
sysConfig
:
dskName
)
{
dskConfig
.
put
(
sysConfig
.
getConfigKey
(),
sysConfig
.
getConfigValue
());
dskConfig
.
put
(
sysConfig
.
getConfigKey
(),
sysConfig
.
getConfigValue
());
}
String
domain
=
(
String
)
dskConfig
.
get
(
"dsk-Domain"
);
...
...
@@ -240,19 +270,19 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
String
appSecret
=
(
String
)
dskConfig
.
get
(
"dsk-AppSecret"
);
Map
<
String
,
Object
>
dskAccessTokenDto
=
new
HashMap
<>();
dskAccessTokenDto
.
put
(
"appKey"
,
appkey
);
dskAccessTokenDto
.
put
(
"appSecret"
,
appSecret
);
Map
<
String
,
Object
>
dskAccessTokenDto
=
new
HashMap
<>();
dskAccessTokenDto
.
put
(
"appKey"
,
appkey
);
dskAccessTokenDto
.
put
(
"appSecret"
,
appSecret
);
String
post
=
HttpUtil
.
post
(
domain
+
accessTokenAPI
,
JsonUtils
.
toJsonString
(
dskAccessTokenDto
));
Assert
.
notEmpty
(
post
,
"大司空数据accessTokenAPI响应异常"
);
log
.
info
(
"大司空数据accessToken API响应:"
+
post
);
Assert
.
notEmpty
(
post
,
"大司空数据accessTokenAPI响应异常"
);
log
.
info
(
"大司空数据accessToken API响应:"
+
post
);
Dict
dict
=
JsonUtils
.
parseMap
(
post
);
Object
dataObj
=
dict
.
getObj
(
"data"
);
if
(
dict
.
getInt
(
"code"
)
!=
200
||
ObjectUtil
.
isEmpty
(
dataObj
))
{
throw
new
ServiceException
(
"API数据accessTokenAPI响应异常"
,
500
);
if
(
dict
.
getInt
(
"code"
)
!=
200
||
ObjectUtil
.
isEmpty
(
dataObj
))
{
throw
new
ServiceException
(
"API数据accessTokenAPI响应异常"
,
500
);
}
return
BeanUtil
.
toBean
(
dataObj
,
DskAccessTokenVO
.
class
);
return
BeanUtil
.
toBean
(
dataObj
,
DskAccessTokenVO
.
class
);
}
/**
...
...
@@ -267,7 +297,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
}
public
List
<
SysConfig
>
queryListByKey
(
String
keyName
){
public
List
<
SysConfig
>
queryListByKey
(
String
keyName
)
{
LambdaQueryWrapper
<
SysConfig
>
dsk
=
new
LambdaQueryWrapper
<
SysConfig
>().
likeRight
(
SysConfig:
:
getConfigKey
,
keyName
);
return
baseMapper
.
selectList
(
dsk
);
}
...
...
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