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 0000000000000000000000000000000000000000..e751d89ec7df8bf18074f7d734f084a00748253b --- /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 0000000000000000000000000000000000000000..d91b79c016a11ffd2e0fa4b7f6b3a74b84f4564a --- /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 0000000000000000000000000000000000000000..3147dcc459c74e9f4758bfb7ba6e6bcb9ed86868 --- /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 0000000000000000000000000000000000000000..17fd4ca709563accf9ac2d3c5737a8a8992c85fc --- /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 0000000000000000000000000000000000000000..e9cd1b0731f7fb5d2b00c3e98d49e717e6ca9d9a --- /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 0000000000000000000000000000000000000000..22cafb8253ac2a8bb16bc71a86c9004f0446b5bf --- /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 d2014c2940933f2a23916c43450922379e42b71a..99e44c150649fced4a5678c578a63fa41d11c03c 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 0000000000000000000000000000000000000000..7a26a8be4ba8201b39d193b5ec6e8b098a4ffa22 --- /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