feat: 添加顾客权限控制和订单时间限制
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.example.building.controller;
|
||||
|
||||
import com.example.building.common.Result;
|
||||
import com.example.building.entity.SystemConfig;
|
||||
import com.example.building.mapper.SystemConfigMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 系统配置控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/system-config")
|
||||
public class SystemConfigController {
|
||||
|
||||
@Autowired
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
/**
|
||||
* 获取所有配置
|
||||
*/
|
||||
@GetMapping
|
||||
public Result<Map<String, String>> getAllConfig() {
|
||||
List<SystemConfig> configs = systemConfigMapper.selectList(null);
|
||||
Map<String, String> result = new HashMap<>();
|
||||
for (SystemConfig config : configs) {
|
||||
result.put(config.getConfigKey(), config.getConfigValue());
|
||||
}
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
*/
|
||||
@PutMapping
|
||||
public Result<Void> updateConfig(@RequestBody SystemConfig config) {
|
||||
// 检查是否存在
|
||||
SystemConfig existing = systemConfigMapper.selectOne(
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<SystemConfig>()
|
||||
.eq(SystemConfig::getConfigKey, config.getConfigKey())
|
||||
);
|
||||
|
||||
if (existing != null) {
|
||||
existing.setConfigValue(config.getConfigValue());
|
||||
existing.setRemark(config.getRemark());
|
||||
systemConfigMapper.updateById(existing);
|
||||
} else {
|
||||
config.setConfigId(java.util.UUID.randomUUID().toString());
|
||||
systemConfigMapper.insert(config);
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user