|
|
|
@ -1,7 +1,5 @@
|
|
|
|
|
|
|
|
|
|
package com.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -23,89 +21,119 @@ import com.utils.ValidatorUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 登录相关
|
|
|
|
|
* 这个类作为Spring的Restful风格的控制器,用于处理与配置相关的各种请求操作,例如获取配置列表、配置详情、保存配置等
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("config")
|
|
|
|
|
@RestController
|
|
|
|
|
public class ConfigController{
|
|
|
|
|
public class ConfigController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ConfigService configService;
|
|
|
|
|
// 自动注入ConfigService,用于调用相关的业务逻辑方法来处理配置相关的操作
|
|
|
|
|
@Autowired
|
|
|
|
|
private ConfigService configService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
* 处理获取配置列表的请求,接收请求参数params和一个ConfigEntity对象(可能用于构建查询条件等),
|
|
|
|
|
* 通过ConfigService的queryPage方法查询分页数据,并返回包含查询结果的响应信息
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/page")
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params,ConfigEntity config){
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
|
|
|
|
|
// 创建一个用于构建查询条件等操作的EntityWrapper对象,针对ConfigEntity类型
|
|
|
|
|
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
|
|
|
|
|
PageUtils page = configService.queryPage(params);
|
|
|
|
|
// 调用ConfigService的queryPage方法,传入请求参数,获取分页数据
|
|
|
|
|
PageUtils page = configService.queryPage(params);
|
|
|
|
|
// 返回一个成功的响应,将分页数据放入响应体的"data"字段中
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
/**
|
|
|
|
|
* 列表
|
|
|
|
|
* 此方法与上面的page方法类似,也是用于获取配置列表,不过添加了@IgnoreAuth注解,
|
|
|
|
|
* 可能表示这个获取列表的接口不需要进行权限验证,接收请求参数params和ConfigEntity对象,
|
|
|
|
|
* 通过ConfigService查询分页数据后返回响应信息
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/list")
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
|
|
|
|
|
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
|
|
|
|
|
PageUtils page = configService.queryPage(params);
|
|
|
|
|
PageUtils page = configService.queryPage(params);
|
|
|
|
|
return R.ok().put("data", page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 信息
|
|
|
|
|
* 根据传入的配置项的id,通过ConfigService的selectById方法从数据库中查询对应的配置信息,
|
|
|
|
|
* 然后将查询到的配置信息封装在响应中返回,响应状态为成功
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/info/{id}")
|
|
|
|
|
public R info(@PathVariable("id") String id){
|
|
|
|
|
public R info(@PathVariable("id") String id) {
|
|
|
|
|
// 根据传入的id调用ConfigService的selectById方法获取对应的配置实体对象
|
|
|
|
|
ConfigEntity config = configService.selectById(id);
|
|
|
|
|
return R.ok().put("data", config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 详情
|
|
|
|
|
* 与info方法类似,也是根据id获取配置详情,不过添加了@IgnoreAuth注解,意味着该获取详情的接口不需要进行权限验证,
|
|
|
|
|
* 通过ConfigService查询配置实体后返回包含该配置信息的响应
|
|
|
|
|
*/
|
|
|
|
|
@IgnoreAuth
|
|
|
|
|
@RequestMapping("/detail/{id}")
|
|
|
|
|
public R detail(@PathVariable("id") String id){
|
|
|
|
|
public R detail(@PathVariable("id") String id) {
|
|
|
|
|
ConfigEntity config = configService.selectById(id);
|
|
|
|
|
return R.ok().put("data", config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据name获取信息
|
|
|
|
|
* 根据传入的配置项名称name,通过ConfigService的selectOne方法结合条件构造器,查询符合条件(名称为指定name)的配置信息,
|
|
|
|
|
* 并将查询到的配置信息封装在响应中返回,响应状态为成功
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/info")
|
|
|
|
|
public R infoByName(@RequestParam String name){
|
|
|
|
|
public R infoByName(@RequestParam String name) {
|
|
|
|
|
// 通过条件构造器构建查询条件(name字段等于传入的name值),然后调用ConfigService的selectOne方法查询配置实体
|
|
|
|
|
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
|
|
|
|
|
return R.ok().put("data", config);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存
|
|
|
|
|
* 接收前端传来的配置实体对象config(通过请求体传递),原本可能会使用ValidatorUtils进行实体校验(此处被注释掉了),
|
|
|
|
|
* 然后调用ConfigService的insert方法将配置实体插入到数据库中,最后返回操作成功的响应
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/save")
|
|
|
|
|
public R save(@RequestBody ConfigEntity config){
|
|
|
|
|
// ValidatorUtils.validateEntity(config);
|
|
|
|
|
configService.insert(config);
|
|
|
|
|
public R save(@RequestBody ConfigEntity config) {
|
|
|
|
|
// 原本可能用于校验传入的配置实体对象是否符合要求,此处被注释掉了,暂未生效
|
|
|
|
|
// ValidatorUtils.validateEntity(config);
|
|
|
|
|
// 将传入的配置实体插入到数据库中
|
|
|
|
|
configService.insert(config);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改
|
|
|
|
|
* 接收前端传来的配置实体对象config(通过请求体传递),同样原本有实体校验逻辑(被注释掉了),
|
|
|
|
|
* 调用ConfigService的updateById方法根据传入的配置实体的id对数据库中对应的配置记录进行全部更新操作,
|
|
|
|
|
* 最后返回操作成功的响应
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/update")
|
|
|
|
|
public R update(@RequestBody ConfigEntity config){
|
|
|
|
|
// ValidatorUtils.validateEntity(config);
|
|
|
|
|
configService.updateById(config);//全部更新
|
|
|
|
|
public R update(@RequestBody ConfigEntity config) {
|
|
|
|
|
// 原本可能用于校验传入的配置实体对象是否符合要求,此处被注释掉了,暂未生效
|
|
|
|
|
// ValidatorUtils.validateEntity(config);
|
|
|
|
|
// 根据传入配置实体的id对数据库中对应的记录进行全部更新
|
|
|
|
|
configService.updateById(config);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除
|
|
|
|
|
* 接收前端传来的要删除的配置项的id数组(通过请求体传递),将数组转换为List后调用ConfigService的deleteBatchIds方法,
|
|
|
|
|
* 批量删除数据库中对应的配置记录,最后返回操作成功的响应
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping("/delete")
|
|
|
|
|
public R delete(@RequestBody Long[] ids){
|
|
|
|
|
configService.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
public R delete(@RequestBody Long[] ids) {
|
|
|
|
|
// 将传入的id数组转换为List集合,以便调用ConfigService的批量删除方法
|
|
|
|
|
configService.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
}
|