mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	feat: 新增网站配置修改功能
This commit is contained in:
		| @@ -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.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; | ||||
| } | ||||
| @@ -0,0 +1,46 @@ | ||||
| /* | ||||
|  * 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; | ||||
| } | ||||
| @@ -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); | ||||
| } | ||||
| @@ -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(); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Bull-BCLS
					Bull-BCLS