|
|
package com.controller;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.annotation.IgnoreAuth;
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.entity.ConfigEntity;
|
|
|
import com.service.ConfigService;
|
|
|
import com.utils.MPUtil;
|
|
|
import com.utils.PageUtils;
|
|
|
import com.utils.R;
|
|
|
import com.utils.ValidatorUtils;
|
|
|
|
|
|
/**
|
|
|
* 配置管理相关接口
|
|
|
*/
|
|
|
@RequestMapping("config")
|
|
|
@RestController
|
|
|
public class ConfigController {
|
|
|
|
|
|
@Autowired
|
|
|
private ConfigService configService; // 注入配置服务
|
|
|
|
|
|
/**
|
|
|
* 查询配置列表(带分页)
|
|
|
* @param params 查询参数
|
|
|
* @param config 查询条件对象
|
|
|
* @return 返回分页数据
|
|
|
*/
|
|
|
@RequestMapping("/page")
|
|
|
public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
|
|
|
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
|
|
|
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
|
|
|
return R.ok().put("data", page); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询配置列表(忽略认证)
|
|
|
* @param params 查询参数
|
|
|
* @param config 查询条件对象
|
|
|
* @return 返回分页数据
|
|
|
*/
|
|
|
@IgnoreAuth
|
|
|
@RequestMapping("/list")
|
|
|
public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
|
|
|
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件
|
|
|
PageUtils page = configService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, config), params), params)); // 查询分页数据
|
|
|
return R.ok().put("data", page); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据ID查询配置信息
|
|
|
* @param id 配置ID
|
|
|
* @return 返回配置信息
|
|
|
*/
|
|
|
@RequestMapping("/info/{id}")
|
|
|
public R info(@PathVariable("id") String id) {
|
|
|
ConfigEntity config = configService.selectById(id); // 根据ID查询配置
|
|
|
return R.ok().put("data", config); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据ID查询配置详情(忽略认证)
|
|
|
* @param id 配置ID
|
|
|
* @return 返回配置详情
|
|
|
*/
|
|
|
@IgnoreAuth
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
public R detail(@PathVariable("id") String id) {
|
|
|
ConfigEntity config = configService.selectById(id); // 根据ID查询配置
|
|
|
return R.ok().put("data", config); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据名称查询配置信息
|
|
|
* @param name 配置名称
|
|
|
* @return 返回配置信息
|
|
|
*/
|
|
|
@RequestMapping("/info")
|
|
|
public R infoByName(@RequestParam String name) {
|
|
|
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 根据名称查询配置
|
|
|
return R.ok().put("data", config); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存配置信息
|
|
|
* @param config 配置对象
|
|
|
* @return 返回操作结果
|
|
|
*/
|
|
|
@PostMapping("/save")
|
|
|
public R save(@RequestBody ConfigEntity config) {
|
|
|
// ValidatorUtils.validateEntity(config); // 验证配置对象
|
|
|
configService.insert(config); // 插入配置
|
|
|
return R.ok(); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新配置信息
|
|
|
* @param config 配置对象
|
|
|
* @return 返回操作结果
|
|
|
*/
|
|
|
@RequestMapping("/update")
|
|
|
public R update(@RequestBody ConfigEntity config) {
|
|
|
// ValidatorUtils.validateEntity(config); // 验证配置对象
|
|
|
configService.updateById(config); // 根据ID更新配置
|
|
|
return R.ok(); // 返回成功结果
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除配置信息
|
|
|
* @param ids 配置ID数组
|
|
|
* @return 返回操作结果
|
|
|
*/
|
|
|
@RequestMapping("/delete")
|
|
|
public R delete(@RequestBody Long[] ids) {
|
|
|
configService.deleteBatchIds(Arrays.asList(ids)); // 批量删除配置
|
|
|
return R.ok(); // 返回成功结果
|
|
|
}
|
|
|
}
|