增加:管理员->系统管理模块接口
This commit is contained in:
parent
8076c0cafa
commit
feaa50fb77
|
@ -2,8 +2,9 @@ package com.moyz.adi.admin.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.moyz.adi.common.dto.SysConfigDto;
|
import com.moyz.adi.common.dto.SysConfigDto;
|
||||||
|
import com.moyz.adi.common.dto.SysConfigEditDto;
|
||||||
|
import com.moyz.adi.common.dto.SysConfigSearchReq;
|
||||||
import com.moyz.adi.common.entity.SysConfig;
|
import com.moyz.adi.common.entity.SysConfig;
|
||||||
import com.moyz.adi.common.service.KnowledgeBaseService;
|
|
||||||
import com.moyz.adi.common.service.SysConfigService;
|
import com.moyz.adi.common.service.SysConfigService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
|
@ -11,6 +12,8 @@ import jakarta.validation.constraints.NotNull;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/sys-config")
|
@RequestMapping("/admin/sys-config")
|
||||||
@Validated
|
@Validated
|
||||||
|
@ -19,13 +22,13 @@ public class SystemConfigController {
|
||||||
@Resource
|
@Resource
|
||||||
private SysConfigService sysConfigService;
|
private SysConfigService sysConfigService;
|
||||||
|
|
||||||
@GetMapping("/search")
|
@PostMapping("/search")
|
||||||
public Page<SysConfig> search(@RequestParam String keyword, @NotNull @Min(1) Integer currentPage, @NotNull @Min(10) Integer pageSize) {
|
public Page<SysConfigDto> search(@RequestBody SysConfigSearchReq searchReq, @NotNull @Min(1) Integer currentPage, @NotNull @Min(10) Integer pageSize) {
|
||||||
return sysConfigService.search(keyword, currentPage, pageSize);
|
return sysConfigService.search(searchReq, currentPage, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/edit")
|
@PostMapping("/edit")
|
||||||
public void edit(@Validated @RequestBody SysConfigDto sysConfigDto) {
|
public void edit(@Validated @RequestBody SysConfigEditDto sysConfigDto) {
|
||||||
sysConfigService.edit(sysConfigDto);
|
sysConfigService.edit(sysConfigDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,9 @@
|
||||||
package com.moyz.adi.common.dto;
|
package com.moyz.adi.common.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Validated
|
|
||||||
public class SysConfigDto {
|
public class SysConfigDto {
|
||||||
|
|
||||||
@Min(1)
|
|
||||||
private Long id;
|
|
||||||
@NotBlank
|
|
||||||
private String name;
|
private String name;
|
||||||
@NotBlank
|
|
||||||
private String value;
|
private String value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.moyz.adi.common.dto;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Validated
|
||||||
|
public class SysConfigEditDto {
|
||||||
|
@NotBlank
|
||||||
|
private String name;
|
||||||
|
@NotBlank
|
||||||
|
private String value;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.moyz.adi.common.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SysConfigSearchReq {
|
||||||
|
private String keyword;
|
||||||
|
private List<String> names;
|
||||||
|
}
|
|
@ -5,12 +5,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.moyz.adi.common.cosntant.AdiConstant;
|
import com.moyz.adi.common.cosntant.AdiConstant;
|
||||||
import com.moyz.adi.common.dto.SysConfigDto;
|
import com.moyz.adi.common.dto.SysConfigDto;
|
||||||
|
import com.moyz.adi.common.dto.SysConfigEditDto;
|
||||||
|
import com.moyz.adi.common.dto.SysConfigSearchReq;
|
||||||
import com.moyz.adi.common.entity.SysConfig;
|
import com.moyz.adi.common.entity.SysConfig;
|
||||||
|
import com.moyz.adi.common.enums.ErrorEnum;
|
||||||
|
import com.moyz.adi.common.exception.BaseException;
|
||||||
import com.moyz.adi.common.mapper.SysConfigMapper;
|
import com.moyz.adi.common.mapper.SysConfigMapper;
|
||||||
import com.moyz.adi.common.util.JsonUtil;
|
import com.moyz.adi.common.util.JsonUtil;
|
||||||
import com.moyz.adi.common.util.LocalCache;
|
import com.moyz.adi.common.util.LocalCache;
|
||||||
|
import com.moyz.adi.common.util.MPPageUtil;
|
||||||
import com.moyz.adi.common.vo.RequestRateLimit;
|
import com.moyz.adi.common.vo.RequestRateLimit;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
@ -54,10 +60,18 @@ public class SysConfigService extends ServiceImpl<SysConfigMapper, SysConfig> {
|
||||||
LocalCache.IMAGE_RATE_LIMIT_CONFIG.setType(RequestRateLimit.TYPE_IMAGE);
|
LocalCache.IMAGE_RATE_LIMIT_CONFIG.setType(RequestRateLimit.TYPE_IMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void edit(SysConfigDto sysConfigDto) {
|
public void edit(SysConfigEditDto sysConfigDto) {
|
||||||
SysConfig sysConfig = new SysConfig();
|
LambdaQueryWrapper<SysConfig> lambdaQueryWrapper = new LambdaQueryWrapper();
|
||||||
BeanUtils.copyProperties(sysConfigDto, sysConfig);
|
lambdaQueryWrapper.eq(SysConfig::getName, sysConfigDto.getName());
|
||||||
baseMapper.updateById(sysConfig);
|
lambdaQueryWrapper.eq(SysConfig::getIsDeleted, false);
|
||||||
|
SysConfig existOne = baseMapper.selectOne(lambdaQueryWrapper);
|
||||||
|
if (null == existOne) {
|
||||||
|
throw new BaseException(ErrorEnum.A_DATA_NOT_FOUND);
|
||||||
|
}
|
||||||
|
SysConfig updateOne = new SysConfig();
|
||||||
|
updateOne.setId(existOne.getId());
|
||||||
|
updateOne.setValue(sysConfigDto.getValue());
|
||||||
|
baseMapper.updateById(updateOne);
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
@ -88,13 +102,18 @@ public class SysConfigService extends ServiceImpl<SysConfigMapper, SysConfig> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<SysConfig> search(String keyword, Integer currentPage, Integer pageSize) {
|
public Page<SysConfigDto> search(SysConfigSearchReq searchReq, Integer currentPage, Integer pageSize) {
|
||||||
LambdaQueryWrapper<SysConfig> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysConfig> wrapper = new LambdaQueryWrapper<>();
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(searchReq.getKeyword())) {
|
||||||
wrapper.like(SysConfig::getName, keyword);
|
wrapper.like(SysConfig::getName, searchReq.getKeyword());
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(searchReq.getNames())) {
|
||||||
|
wrapper.in(SysConfig::getName, searchReq.getNames());
|
||||||
}
|
}
|
||||||
wrapper.eq(SysConfig::getIsDeleted, false);
|
wrapper.eq(SysConfig::getIsDeleted, false);
|
||||||
return baseMapper.selectPage(new Page<>(currentPage, pageSize), wrapper);
|
Page<SysConfig> page = baseMapper.selectPage(new Page<>(currentPage, pageSize), wrapper);
|
||||||
|
Page<SysConfigDto> result = new Page<>();
|
||||||
|
return MPPageUtil.convertToPage(page, result, SysConfigDto.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,13 +403,13 @@ create trigger trigger_ai_model
|
||||||
execute procedure update_modified_column();
|
execute procedure update_modified_column();
|
||||||
|
|
||||||
INSERT INTO adi_sys_config (name, value)
|
INSERT INTO adi_sys_config (name, value)
|
||||||
VALUES ('openai_setting', '{"secret_key":"","models":[]}');
|
VALUES ('openai_setting', '{"secret_key":""}');
|
||||||
INSERT INTO adi_sys_config (name, value)
|
INSERT INTO adi_sys_config (name, value)
|
||||||
VALUES ('dashscope_setting', '{"api_key":"","models":[]}');
|
VALUES ('dashscope_setting', '{"api_key":""}');
|
||||||
INSERT INTO adi_sys_config (name, value)
|
INSERT INTO adi_sys_config (name, value)
|
||||||
VALUES ('qianfan_setting', '{"api_key":"","secret_key":"","models":[]}');
|
VALUES ('qianfan_setting', '{"api_key":"","secret_key":""}');
|
||||||
INSERT INTO adi_sys_config (name, value)
|
INSERT INTO adi_sys_config (name, value)
|
||||||
VALUES ('ollama_setting', '{"base_url":"","models":[]}');
|
VALUES ('ollama_setting', '{"base_url":""}');
|
||||||
INSERT INTO adi_sys_config (name, value)
|
INSERT INTO adi_sys_config (name, value)
|
||||||
VALUES ('google_setting',
|
VALUES ('google_setting',
|
||||||
'{"url":"https://www.googleapis.com/customsearch/v1","key":"","cx":""}');
|
'{"url":"https://www.googleapis.com/customsearch/v1","key":"","cx":""}');
|
||||||
|
|
Loading…
Reference in New Issue