From 42996a7317fc5b4730723367d933dd728ae65b6f Mon Sep 17 00:00:00 2001 From: Bull-BCLS <1019113057@qq.com> Date: Thu, 21 Sep 2023 22:38:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cnadmin/system/mapper/OptionMapper.java | 28 +++++++ .../cnadmin/system/model/entity/OptionDO.java | 74 +++++++++++++++++++ .../system/model/query/OptionQuery.java | 50 +++++++++++++ .../cnadmin/system/model/vo/OptionVO.java | 74 +++++++++++++++++++ .../cnadmin/system/service/OptionService.java | 40 ++++++++++ .../service/impl/OptionServiceImpl.java | 49 ++++++++++++ continew-admin-ui/src/api/system/config.ts | 2 +- .../controller/system/OptionController.java | 55 ++++++++++++++ 8 files changed, 371 insertions(+), 1 deletion(-) create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/OptionMapper.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/OptionDO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/OptionQuery.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/OptionVO.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/OptionService.java create mode 100644 continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/OptionServiceImpl.java create mode 100644 continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/OptionController.java diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/OptionMapper.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/OptionMapper.java new file mode 100644 index 00000000..e751d89e --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/mapper/OptionMapper.java @@ -0,0 +1,28 @@ +/* + * 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.mapper; + +import top.charles7c.cnadmin.common.base.BaseMapper; +import top.charles7c.cnadmin.system.model.entity.OptionDO; + +/** + * 系统参数 Mapper + * + * @author Bull-BCLS + * @since 2023/8/26 19:38 + */ +public interface OptionMapper extends BaseMapper {} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/OptionDO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/OptionDO.java new file mode 100644 index 00000000..d91b79c0 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/entity/OptionDO.java @@ -0,0 +1,74 @@ +/* + * 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.entity; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import lombok.Data; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +/** + * 系统参数表 + * + * @author Bull-BCLS + * @since 2023/8/26 19:20 + */ +@Data +@TableName("sys_option") +public class OptionDO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 参数名称 + */ + private String name; + + /** + * 参数键 + */ + @TableId + private String code; + + /** + * 参数值 + */ + private String value; + + /** + * 参数默认值 + */ + private String defaultValue; + + /** + * 描述 + */ + private String description; + + /** + * 修改人 + */ + private Long updateUser; + + /** + * 修改时间 + */ + private LocalDateTime updateTime; +} diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/OptionQuery.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/OptionQuery.java new file mode 100644 index 00000000..3147dcc4 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/query/OptionQuery.java @@ -0,0 +1,50 @@ +/* + * 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.query; + +import java.io.Serializable; +import java.util.List; + +import javax.validation.constraints.NotEmpty; + +import lombok.Data; + +import io.swagger.v3.oas.annotations.media.Schema; + +import top.charles7c.cnadmin.common.annotation.Query; +import top.charles7c.cnadmin.common.enums.QueryTypeEnum; + +/** + * 系统参数查询条件 + * + * @author Bull-BCLS + * @since 2023/8/26 19:38 + */ +@Data +@Schema(description = "系统参数查询条件") +public class OptionQuery implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 参数键列表 + */ + @Schema(description = "参数键列表", example = "site_title,site_copyright") + @NotEmpty(message = "参数键不能为空") + @Query(type = QueryTypeEnum.IN) + private List code; +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/OptionVO.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/OptionVO.java new file mode 100644 index 00000000..17fd4ca7 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/model/vo/OptionVO.java @@ -0,0 +1,74 @@ +/* + * 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.vo; + +import java.io.Serializable; + +import lombok.Data; + +import io.swagger.v3.oas.annotations.media.Schema; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +import cn.hutool.core.util.StrUtil; + +/** + * 系统参数信息 + * + * @author Bull-BCLS + * @since 2023/8/26 19:38 + */ +@Data +@Schema(description = "系统参数信息") +public class OptionVO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 参数名称 + */ + @Schema(description = "参数名称", example = "系统标题") + private String name; + + /** + * 参数键 + */ + @Schema(description = "参数键", example = "site_title") + private String code; + + /** + * 参数值 + */ + @Schema(description = "参数值", example = "ContiNew Admin") + private String value; + + /** + * 参数默认值 + */ + @JsonIgnore + private String defaultValue; + + /** + * 描述 + */ + @Schema(description = "描述", example = "用于显示登录页面的系统标题。") + private String description; + + public String getValue() { + return StrUtil.nullToDefault(value, defaultValue); + } +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/OptionService.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/OptionService.java new file mode 100644 index 00000000..e9cd1b07 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/OptionService.java @@ -0,0 +1,40 @@ +/* + * 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.service; + +import java.util.List; + +import top.charles7c.cnadmin.system.model.query.OptionQuery; +import top.charles7c.cnadmin.system.model.vo.OptionVO; + +/** + * 系统参数业务接口 + * + * @author Bull-BCLS + * @since 2023/8/26 19:38 + */ +public interface OptionService { + + /** + * 查询列表 + * + * @param query + * 查询条件 + * @return 列表信息 + */ + List list(OptionQuery query); +} \ No newline at end of file diff --git a/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/OptionServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/OptionServiceImpl.java new file mode 100644 index 00000000..22cafb82 --- /dev/null +++ b/continew-admin-system/src/main/java/top/charles7c/cnadmin/system/service/impl/OptionServiceImpl.java @@ -0,0 +1,49 @@ +/* + * 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.service.impl; + +import java.util.List; + +import lombok.RequiredArgsConstructor; + +import org.springframework.stereotype.Service; + +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.query.OptionQuery; +import top.charles7c.cnadmin.system.model.vo.OptionVO; +import top.charles7c.cnadmin.system.service.OptionService; + +/** + * 系统参数业务实现 + * + * @author Bull-BCLS + * @since 2023/8/26 19:38 + */ +@Service +@RequiredArgsConstructor +public class OptionServiceImpl implements OptionService { + + private final OptionMapper baseMapper; + + @Override + public List list(OptionQuery query) { + return BeanUtil.copyToList(baseMapper.selectList(QueryHelper.build(query)), OptionVO.class); + } +} \ No newline at end of file diff --git a/continew-admin-ui/src/api/system/config.ts b/continew-admin-ui/src/api/system/config.ts index d2014c29..99e44c15 100644 --- a/continew-admin-ui/src/api/system/config.ts +++ b/continew-admin-ui/src/api/system/config.ts @@ -1,7 +1,7 @@ import axios from 'axios'; import qs from 'query-string'; -const BASE_URL = '/api/system/option'; +const BASE_URL = '/system/option'; export interface BasicConfigRecord { site_title?: string; diff --git a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/OptionController.java b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/OptionController.java new file mode 100644 index 00000000..7a26a8be --- /dev/null +++ b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/system/OptionController.java @@ -0,0 +1,55 @@ +/* + * 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.webapi.controller.system; + +import java.util.List; + +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 top.charles7c.cnadmin.common.model.vo.R; +import top.charles7c.cnadmin.system.model.query.OptionQuery; +import top.charles7c.cnadmin.system.model.vo.OptionVO; +import top.charles7c.cnadmin.system.service.OptionService; + +/** + * 系统参数管理 API + * + * @author Bull-BCLS + * @since 2023/8/26 19:38 + */ +@Tag(name = "系统参数管理 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/system/option") +public class OptionController { + + private final OptionService optionService; + + @Operation(summary = "查询系统参数列表", description = "查询系统参数列表") + @GetMapping + public R> list(@Validated OptionQuery query) { + return R.ok(optionService.list(query)); + } +} \ No newline at end of file