1.控制类添加服务层
This commit is contained in:
@@ -5,10 +5,13 @@ import vvpkassistant.Data.ResponseData;
|
||||
import vvpkassistant.Data.ResponseInfo;
|
||||
import vvpkassistant.FunctionConfig.mapper.FunctionConfigMapper;
|
||||
import vvpkassistant.FunctionConfig.model.FunctionConfigModel;
|
||||
import vvpkassistant.FunctionConfig.service.FunctionConfigService;
|
||||
import vvpkassistant.common.ErrorCode;
|
||||
import vvpkassistant.config.FunctionConfigHolder;
|
||||
import vvpkassistant.exception.BusinessException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("config")
|
||||
public class FunctionConfigController {
|
||||
@@ -16,6 +19,9 @@ public class FunctionConfigController {
|
||||
@Autowired
|
||||
private FunctionConfigMapper configMapper;
|
||||
|
||||
@Resource
|
||||
private FunctionConfigService functionConfigService;
|
||||
|
||||
// 获取所有配置
|
||||
@GetMapping("getAllConfig")
|
||||
public ResponseData<Object> getAllConfig() {
|
||||
@@ -26,7 +32,7 @@ public class FunctionConfigController {
|
||||
@PostMapping("updateConfigValue")
|
||||
public ResponseData<Object> updateConfigValue(@RequestBody FunctionConfigModel model) {
|
||||
// 1. 更新数据库
|
||||
configMapper.updateById(model);
|
||||
functionConfigService.updateById(model);
|
||||
// 2. 更新内存
|
||||
FunctionConfigHolder.CONFIGS.removeIf(c -> model.getFunctionName().equals(c.getFunctionName()));
|
||||
FunctionConfigHolder.CONFIGS.add(model);
|
||||
@@ -41,7 +47,7 @@ public class FunctionConfigController {
|
||||
if (isDuplicate) {
|
||||
throw new BusinessException(ErrorCode.CONFIG_NAME_DUPLICATE);
|
||||
}else {
|
||||
configMapper.insert(newModel);
|
||||
functionConfigService.save(newModel);
|
||||
FunctionConfigHolder.CONFIGS.add(newModel);
|
||||
return ResponseData.success("");
|
||||
}
|
||||
@@ -49,8 +55,7 @@ public class FunctionConfigController {
|
||||
|
||||
@PostMapping("deleteConfigById")
|
||||
public ResponseData<Object> deleteConfigById(@RequestBody FunctionConfigModel model) {
|
||||
int i = configMapper.deleteById(model);
|
||||
if (i == 1) {
|
||||
if (functionConfigService.removeById(model)) {
|
||||
FunctionConfigHolder.CONFIGS.removeIf(c -> model.getId().equals(c.getId()));
|
||||
return ResponseData.success("");
|
||||
}else {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package vvpkassistant.FunctionConfig.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import vvpkassistant.FunctionConfig.model.FunctionConfigModel;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/4 13:37
|
||||
*/
|
||||
public interface FunctionConfigService extends IService<FunctionConfigModel> {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package vvpkassistant.FunctionConfig.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import vvpkassistant.FunctionConfig.mapper.FunctionConfigMapper;
|
||||
import vvpkassistant.FunctionConfig.model.FunctionConfigModel;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/8/4 13:38
|
||||
*/
|
||||
@Service
|
||||
public class FunctionConfigServiceImpl extends ServiceImpl<FunctionConfigMapper,FunctionConfigModel> implements FunctionConfigService {
|
||||
|
||||
@Resource
|
||||
private FunctionConfigMapper functionConfigMapper;
|
||||
|
||||
}
|
||||
@@ -112,8 +112,7 @@ public class UserController {
|
||||
//否则直接返回用户
|
||||
return ResponseData.success(result);
|
||||
}
|
||||
|
||||
return ResponseData.error(ErrorCode.SYSTEM_ERROR.getCode(),"未知错误");
|
||||
throw new BusinessException(ErrorCode.SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
// 手机号登录 / 注册
|
||||
|
||||
Reference in New Issue
Block a user