Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
查尔斯-BUG万象集
Continew Admin
提交
dcc87cb6
Continew Admin
项目概览
查尔斯-BUG万象集
/
Continew Admin
8 个月 前同步成功
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
分析
仓库
DevOps
项目成员
Pages
Continew Admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
dcc87cb6
编写于
9月 22, 2023
作者:
B
Bull-BCLS
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 新增网站配置修改功能
上级
b30f6c2e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
217 addition
and
24 deletion
+217
-24
continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/interceptor/LogInterceptor.java
...charles7c/cnadmin/monitor/interceptor/LogInterceptor.java
+23
-7
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/OptionRequest.java
...charles7c/cnadmin/system/model/request/OptionRequest.java
+55
-0
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/ResetOptionValueRequest.java
...cnadmin/system/model/request/ResetOptionValueRequest.java
+46
-0
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/OptionService.java
...a/top/charles7c/cnadmin/system/service/OptionService.java
+18
-0
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/OptionServiceImpl.java
...rles7c/cnadmin/system/service/impl/OptionServiceImpl.java
+13
-0
continew-admin-ui/src/api/system/config.ts
continew-admin-ui/src/api/system/config.ts
+5
-1
continew-admin-ui/src/views/system/config/components/basic-setting.vue
...n-ui/src/views/system/config/components/basic-setting.vue
+36
-12
continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/OptionController.java
...7c/cnadmin/webapi/controller/system/OptionController.java
+21
-4
未找到文件。
continew-admin-monitor/src/main/java/top/charles7c/cnadmin/monitor/interceptor/LogInterceptor.java
浏览文件 @
dcc87cb6
...
...
@@ -17,6 +17,8 @@
package
top.charles7c.cnadmin.monitor.interceptor
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -44,6 +46,8 @@ import cn.hutool.core.util.StrUtil;
import
cn.hutool.extra.servlet.ServletUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
cn.hutool.http.HttpStatus
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
top.charles7c.cnadmin.auth.model.request.LoginRequest
;
...
...
@@ -214,19 +218,31 @@ public class LogInterceptor implements HandlerInterceptor {
logDO
.
setRequestMethod
(
request
.
getMethod
());
logDO
.
setRequestHeaders
(
this
.
desensitize
(
ServletUtil
.
getHeaderMap
(
request
)));
String
requestBody
=
this
.
getRequestBody
(
request
);
if
(
StrUtil
.
isNotBlank
(
requestBody
))
{
logDO
.
setRequestBody
(
this
.
desensitize
(
JSONUtil
.
isTypeJSON
(
requestBody
)
?
JSONUtil
.
parseObj
(
requestBody
)
:
ServletUtil
.
getParamMap
(
request
)));
}
logDO
.
setClientIp
(
ServletUtil
.
getClientIP
(
request
));
logDO
.
setLocation
(
IpUtils
.
getCityInfo
(
logDO
.
getClientIp
()));
logDO
.
setBrowser
(
ServletUtils
.
getBrowser
(
request
));
logDO
.
setCreateUser
(
ObjectUtil
.
defaultIfNull
(
logDO
.
getCreateUser
(),
LoginHelper
.
getUserId
()));
if
(
null
==
logDO
.
getCreateUser
()
&&
SysConsts
.
LOGIN_URI
.
equals
(
request
.
getRequestURI
()))
{
LoginRequest
loginRequest
=
JSONUtil
.
toBean
(
requestBody
,
LoginRequest
.
class
);
logDO
.
setCreateUser
(
ExceptionUtils
.
exToNull
(()
->
userService
.
getByUsername
(
loginRequest
.
getUsername
()).
getId
()));
}
if
(
StrUtil
.
isNotBlank
(
requestBody
))
{
if
(
JSONUtil
.
isTypeJSONObject
(
requestBody
))
{
requestBody
=
this
.
desensitize
(
JSONUtil
.
parseObj
(
requestBody
));
}
else
if
(
JSONUtil
.
isTypeJSONArray
(
requestBody
))
{
JSONArray
requestBodyJsonArr
=
JSONUtil
.
parseArray
(
requestBody
);
List
<
JSONObject
>
requestBodyJsonObjList
=
new
ArrayList
<>(
requestBodyJsonArr
.
size
());
for
(
Object
requestBodyJsonObj
:
requestBodyJsonArr
)
{
requestBodyJsonObjList
.
add
(
JSONUtil
.
parseObj
(
this
.
desensitize
(
JSONUtil
.
parseObj
(
requestBodyJsonObj
))));
}
requestBody
=
JSONUtil
.
toJsonStr
(
requestBodyJsonObjList
);
}
else
{
requestBody
=
this
.
desensitize
(
ServletUtil
.
getParamMap
(
request
));
}
logDO
.
setRequestBody
(
requestBody
);
}
logDO
.
setClientIp
(
ServletUtil
.
getClientIP
(
request
));
logDO
.
setLocation
(
IpUtils
.
getCityInfo
(
logDO
.
getClientIp
()));
logDO
.
setBrowser
(
ServletUtils
.
getBrowser
(
request
));
}
/**
...
...
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/OptionRequest.java
0 → 100644
浏览文件 @
dcc87cb6
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
top.charles7c.cnadmin.system.model.request
;
import
javax.validation.constraints.NotBlank
;
import
lombok.Data
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
org.hibernate.validator.constraints.Length
;
import
top.charles7c.cnadmin.common.base.BaseRequest
;
/**
* 修改系统参数信息
*
* @author Bull-BCLS
* @since 2023/8/26 19:38
*/
@Data
@Schema
(
description
=
"修改系统参数信息"
)
public
class
OptionRequest
extends
BaseRequest
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 参数键
*/
@Schema
(
description
=
"参数键"
,
example
=
"site_title"
)
@NotBlank
(
message
=
"参数键不能为空"
)
@Length
(
max
=
100
,
message
=
"参数键长度不能超过 {max} 个字符"
)
private
String
code
;
/**
* 参数值
*/
@Schema
(
description
=
"参数值"
,
example
=
"ContiNew Admin"
)
@NotBlank
(
message
=
"参数值不能为空"
)
private
String
value
;
}
\ No newline at end of file
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/request/ResetOptionValueRequest.java
0 → 100644
浏览文件 @
dcc87cb6
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
top.charles7c.cnadmin.system.model.request
;
import
java.io.Serializable
;
import
java.util.List
;
import
javax.validation.constraints.NotEmpty
;
import
lombok.Data
;
import
io.swagger.v3.oas.annotations.media.Schema
;
/**
* 重置系统参数信息
*
* @author Bull-BCLS
* @since 2023/9/21 23:10
*/
@Data
@Schema
(
description
=
"重置系统参数信息"
)
public
class
ResetOptionValueRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 参数键列表
*/
@Schema
(
description
=
"参数键列表"
,
example
=
"site_title,site_copyright"
)
@NotEmpty
(
message
=
"参数键不能为空"
)
private
List
<
String
>
code
;
}
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/OptionService.java
浏览文件 @
dcc87cb6
...
...
@@ -19,6 +19,8 @@ package top.charles7c.cnadmin.system.service;
import
java.util.List
;
import
top.charles7c.cnadmin.system.model.query.OptionQuery
;
import
top.charles7c.cnadmin.system.model.request.OptionRequest
;
import
top.charles7c.cnadmin.system.model.request.ResetOptionValueRequest
;
import
top.charles7c.cnadmin.system.model.vo.OptionVO
;
/**
...
...
@@ -37,4 +39,20 @@ public interface OptionService {
* @return 列表信息
*/
List
<
OptionVO
>
list
(
OptionQuery
query
);
/**
* 修改系统参数
*
* @param request
* 参数信息
*/
void
update
(
List
<
OptionRequest
>
request
);
/**
* 重置系统参数
*
* @param request
* 重置参数信息
*/
void
resetValue
(
ResetOptionValueRequest
request
);
}
\ No newline at end of file
continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/OptionServiceImpl.java
浏览文件 @
dcc87cb6
...
...
@@ -26,7 +26,10 @@ import cn.hutool.core.bean.BeanUtil;
import
top.charles7c.cnadmin.common.util.helper.QueryHelper
;
import
top.charles7c.cnadmin.system.mapper.OptionMapper
;
import
top.charles7c.cnadmin.system.model.entity.OptionDO
;
import
top.charles7c.cnadmin.system.model.query.OptionQuery
;
import
top.charles7c.cnadmin.system.model.request.OptionRequest
;
import
top.charles7c.cnadmin.system.model.request.ResetOptionValueRequest
;
import
top.charles7c.cnadmin.system.model.vo.OptionVO
;
import
top.charles7c.cnadmin.system.service.OptionService
;
...
...
@@ -46,4 +49,14 @@ public class OptionServiceImpl implements OptionService {
public
List
<
OptionVO
>
list
(
OptionQuery
query
)
{
return
BeanUtil
.
copyToList
(
baseMapper
.
selectList
(
QueryHelper
.
build
(
query
)),
OptionVO
.
class
);
}
@Override
public
void
update
(
List
<
OptionRequest
>
request
)
{
baseMapper
.
updateBatchById
(
BeanUtil
.
copyToList
(
request
,
OptionDO
.
class
));
}
@Override
public
void
resetValue
(
ResetOptionValueRequest
request
)
{
baseMapper
.
lambdaUpdate
().
set
(
OptionDO:
:
getValue
,
null
).
in
(
OptionDO:
:
getCode
,
request
.
getCode
()).
update
();
}
}
\ No newline at end of file
continew-admin-ui/src/api/system/config.ts
浏览文件 @
dcc87cb6
...
...
@@ -11,7 +11,7 @@ export interface BasicConfigRecord {
}
export
interface
DataRecord
{
name
:
string
;
name
?
:
string
;
code
:
string
;
value
:
string
;
description
?:
string
;
...
...
@@ -30,6 +30,10 @@ export function list(params: ListParam) {
});
}
export
function
save
(
req
:
DataRecord
[])
{
return
axios
.
patch
(
`
${
BASE_URL
}
`
,
req
);
}
export
function
resetValue
(
params
:
ListParam
)
{
return
axios
.
patch
(
`
${
BASE_URL
}
/value`
,
params
);
}
continew-admin-ui/src/views/system/config/components/basic-setting.vue
浏览文件 @
dcc87cb6
...
...
@@ -164,6 +164,7 @@
DataRecord
,
ListParam
,
list
,
save
,
resetValue
,
}
from
'
@/api/system/config
'
;
...
...
@@ -207,20 +208,51 @@
siteFavicon
.
value
=
dataList
.
value
.
find
(
(
option
)
=>
option
.
code
===
'
site_favicon
'
);
form
.
value
.
site_title
=
siteTitle
.
value
?.
value
;
form
.
value
.
site_copyright
=
siteCopyright
.
value
?.
value
;
form
.
value
=
{
site_title
:
siteTitle
.
value
?.
value
,
site_copyright
:
siteCopyright
.
value
?.
value
,
site_logo
:
{
url
:
siteLogo
.
value
?.
value
,
},
site_favicon
:
{
url
:
siteFavicon
.
value
?.
value
,
},
};
logoFile
.
value
.
url
=
siteLogo
.
value
?.
value
;
faviconFile
.
value
.
url
=
siteFavicon
.
value
?.
value
;
};
getConfig
();
/**
*
保存
*
取消
*/
const
handle
Save
=
async
()
=>
{
const
handle
Cancel
=
()
=>
{
isEdit
.
value
=
false
;
};
/**
* 保存
*/
const
handleSave
=
()
=>
{
proxy
.
$refs
.
formRef
.
validate
((
valid
:
any
)
=>
{
if
(
!
valid
)
{
const
optionList
:
DataRecord
[]
=
Object
.
entries
(
form
.
value
).
map
(
(
item
)
=>
{
return
{
code
:
item
[
0
],
value
:
item
[
1
]?.
url
||
item
[
1
],
};
}
);
save
(
optionList
).
then
((
res
)
=>
{
// siteConfigStore().save(data.form);
handleCancel
();
proxy
.
$message
.
success
(
res
.
msg
);
});
}
});
};
/**
* 上传 Logo
*
...
...
@@ -315,14 +347,6 @@
const
reset
=
()
=>
{
proxy
.
$refs
.
formRef
?.
resetFields
();
};
/**
* 取消
*/
const
handleCancel
=
()
=>
{
isEdit
.
value
=
false
;
reset
();
};
</
script
>
<
style
scoped
lang=
"less"
>
...
...
continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/OptionController.java
浏览文件 @
dcc87cb6
...
...
@@ -18,19 +18,20 @@ package top.charles7c.cnadmin.webapi.controller.system;
import
java.util.List
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
lombok.RequiredArgsConstructor
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.
GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.
*
;
import
cn.dev33.satoken.annotation.SaCheckPermission
;
import
top.charles7c.cnadmin.common.model.vo.R
;
import
top.charles7c.cnadmin.system.model.query.OptionQuery
;
import
top.charles7c.cnadmin.system.model.request.OptionRequest
;
import
top.charles7c.cnadmin.system.model.request.ResetOptionValueRequest
;
import
top.charles7c.cnadmin.system.model.vo.OptionVO
;
import
top.charles7c.cnadmin.system.service.OptionService
;
...
...
@@ -54,4 +55,20 @@ public class OptionController {
public
R
<
List
<
OptionVO
>>
list
(
@Validated
OptionQuery
query
)
{
return
R
.
ok
(
optionService
.
list
(
query
));
}
@Operation
(
summary
=
"修改系统参数"
,
description
=
"修改系统参数"
)
@SaCheckPermission
(
"system:config:update"
)
@PatchMapping
public
R
update
(
@Validated
@RequestBody
List
<
OptionRequest
>
request
)
{
optionService
.
update
(
request
);
return
R
.
ok
();
}
@Operation
(
summary
=
"重置系统参数"
,
description
=
"重置系统参数"
)
@SaCheckPermission
(
"system:config:reset"
)
@PatchMapping
(
"/value"
)
public
R
resetValue
(
@Validated
@RequestBody
ResetOptionValueRequest
request
)
{
optionService
.
resetValue
(
request
);
return
R
.
ok
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录