feat(device): 实现设备逻辑删除与真实删除功能

- 添加设备逻辑删除接口,更新查询SQL过滤已删除数据
- 添加设备真实删除接口,需管理员权限
- 在DeviceService中实现逻辑删除与真实删除方法
- 在DeviceMapper中添加逻辑删除SQL语句
- 新增设备相关错误码:删除失败、类型删除失败等
- 更新UserController中修改密码与更新用户名接口的请求方式为PUT
- 优化DeviceController中创建设备与查询设备接口的注解使用
- 引入Spring Security注解支持接口权限控制
This commit is contained in:
Chaos
2025-11-21 07:30:17 +08:00
parent 72a1e4d309
commit d4bbaf6715
6 changed files with 78 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ public interface DeviceMapper extends BaseMapper<Device> {
* @param id 设备id
* @return 设备信息
*/
@Select("SELECT * FROM t_device WHERE id = #{id}")
@Select("SELECT * FROM t_device WHERE id = #{id} AND deleted = 0 ")
@Results(id = "DeviceResultMap", value ={
@Result(id = true, property = "id", column = "id"),
@Result(property = "name", column = "name"),
@@ -27,4 +27,14 @@ public interface DeviceMapper extends BaseMapper<Device> {
one = @One(select = "cn.nopj.chaos_api.mapper.DriveTypeMapper.selectById"))
})
Device selectOneWithTypeById(Long id);
/**
* 逻辑删除设备
* @param id 设备id
* @return 逻辑删除影响行数
*/
@Update("UPDATE t_device SET deleted = 1 WHERE id = #{id}")
int deleteDevice(Long id);
}