|
|
|
@ -0,0 +1,99 @@
|
|
|
|
|
package com.controller;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; // 导入Java的Arrays类,用于操作数组
|
|
|
|
|
import java.util.Map; // 导入Java的Map接口,用于存储键值对
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; // 导入Spring框架的@Autowired注解,用于自动注入依赖
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable; // 导入Spring MVC的@PathVariable注解,用于从URL路径中获取变量
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping; // 导入Spring MVC的@PostMapping注解,用于映射HTTP POST请求到特定的处理方法
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; // 导入Spring MVC的@RequestBody注解,用于将HTTP请求体绑定到方法参数上
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; // 导入Spring MVC的@RequestMapping注解,用于映射HTTP请求到控制器的方法
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; // 导入Spring MVC的@RequestParam注解,用于从HTTP请求中获取查询参数
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController; // 导入Spring MVC的@RestController注解,用于定义RESTful Web服务的控制器
|
|
|
|
|
|
|
|
|
|
import com.annotation.IgnoreAuth; // 导入自定义的IgnoreAuth注解,可能用于忽略某些认证逻辑
|
|
|
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper; // 导入MyBatis-Plus的EntityWrapper类,用于构建查询条件
|
|
|
|
|
import com.entity.ConfigEntity; // 导入ConfigEntity实体类,表示配置信息的数据模型
|
|
|
|
|
import com.service.ConfigService; // 导入ConfigService服务接口,提供配置相关的业务逻辑
|
|
|
|
|
import com.utils.PageUtils; // 导入PageUtils工具类,用于分页处理
|
|
|
|
|
import com.utils.R; // 导入R工具类,用于封装统一的响应结果
|
|
|
|
|
import com.utils.ValidatorUtils; // 导入ValidatorUtils工具类,用于数据验证
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//登录相关
|
|
|
|
|
@RequestMapping("config") // 映射请求路径为 "config"
|
|
|
|
|
@RestController // 声明这是一个控制器,并且返回的数据直接写入 HTTP 响应体中
|
|
|
|
|
public class ConfigController {
|
|
|
|
|
|
|
|
|
|
@Autowired // 自动注入 ConfigService 实例
|
|
|
|
|
private ConfigService configService;
|
|
|
|
|
|
|
|
|
|
/**列表*/
|
|
|
|
|
@RequestMapping("/page") // 映射请求路径为 "/page"
|
|
|
|
|
public R page(@RequestParam Map<String, Object> params, ConfigEntity config) {
|
|
|
|
|
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件包装器
|
|
|
|
|
PageUtils page = configService.queryPage(params); // 调用服务层方法获取分页数据
|
|
|
|
|
return R.ok().put("data", page); // 返回封装好的分页数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**列表*/
|
|
|
|
|
@IgnoreAuth // 忽略认证注解
|
|
|
|
|
@RequestMapping("/list") // 映射请求路径为 "/list"
|
|
|
|
|
public R list(@RequestParam Map<String, Object> params, ConfigEntity config) {
|
|
|
|
|
EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>(); // 创建查询条件包装器
|
|
|
|
|
PageUtils page = configService.queryPage(params); // 调用服务层方法获取分页数据
|
|
|
|
|
return R.ok().put("data", page); // 返回封装好的分页数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//信息
|
|
|
|
|
@RequestMapping("/info/{id}") // 映射请求路径为 "/info/{id}"
|
|
|
|
|
public R info(@PathVariable("id") String id) { // 从路径变量中获取 id 参数
|
|
|
|
|
ConfigEntity config = configService.selectById(id); // 根据 id 查询配置实体
|
|
|
|
|
return R.ok().put("data", config); // 返回查询到的配置实体
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 详情
|
|
|
|
|
@IgnoreAuth // 忽略认证注解
|
|
|
|
|
@RequestMapping("/detail/{id}") // 映射请求路径为 "/detail/{id}"
|
|
|
|
|
public R detail(@PathVariable("id") String id) { // 从路径变量中获取 id 参数
|
|
|
|
|
ConfigEntity config = configService.selectById(id); // 根据 id 查询配置实体
|
|
|
|
|
return R.ok().put("data", config); // 返回查询到的配置实体
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据name获取信息
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/info") // 映射请求路径为 "/info"
|
|
|
|
|
public R infoByName(@RequestParam String name) { // 从请求参数中获取 name 参数
|
|
|
|
|
ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile")); // 根据 name 查询配置实体
|
|
|
|
|
return R.ok().put("data", config); // 返回查询到的配置实体
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存
|
|
|
|
|
@PostMapping("/save") // 映射请求路径为 "/save",并指定请求方法为 POST
|
|
|
|
|
public R save(@RequestBody ConfigEntity config) { // 从请求体中获取配置实体对象
|
|
|
|
|
// ValidatorUtils.validateEntity(config); // 验证实体(注释掉)
|
|
|
|
|
configService.insert(config); // 插入新的配置实体
|
|
|
|
|
return R.ok(); // 返回成功响应
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/update") // 映射请求路径为 "/update"
|
|
|
|
|
public R update(@RequestBody ConfigEntity config) { // 从请求体中获取配置实体对象
|
|
|
|
|
// ValidatorUtils.validateEntity(config); // 验证实体(注释掉)
|
|
|
|
|
configService.updateById(config); // 更新配置实体(全部字段)
|
|
|
|
|
return R.ok(); // 返回成功响应
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//删除/
|
|
|
|
|
@RequestMapping("/delete") // 映射请求路径为 "/delete"
|
|
|
|
|
public R delete(@RequestBody Long[] ids) { // 从请求体中获取要删除的 ID 数组
|
|
|
|
|
configService.deleteBatchIds(Arrays.asList(ids)); // 批量删除配置实体
|
|
|
|
|
return R.ok(); // 返回成功响应
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|