refactor(iot): 调整设备映射和数据库脚本
- 修改 DeviceMapper.xml 中 name 字段的属性映射,从 name 改为 productName -移除 gateway.sql 中的冗余数据插入和表删除语句- 优化 RoleServiceImpl 中的角色权限更新逻辑
This commit is contained in:
parent
bd6f4c2ed6
commit
bc82a1bfd1
@ -65,11 +65,10 @@ public class ApiExceptionHandler {
|
||||
return new ResponseEntity<>(objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
//TODO 冲突
|
||||
@ExceptionHandler(value = {Exception.class})
|
||||
public ResponseEntity<Object> handleException(Exception ex) throws JsonProcessingException {
|
||||
log.error("Exception: {}", objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())));
|
||||
return new ResponseEntity<>(objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
// @ExceptionHandler(value = {Exception.class})
|
||||
// public ResponseEntity<Object> handleException(Exception ex) throws JsonProcessingException {
|
||||
// log.error("Exception: {}", objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())));
|
||||
// return new ResponseEntity<>(objectMapper.writeValueAsString(Map.of("msg", ex.getMessage())), HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import javax.sql.DataSource;
|
||||
@AllArgsConstructor
|
||||
@EnableMethodSecurity
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SpringSecurityConfig {
|
||||
|
||||
private final UserDetailsService userDetailsService;
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.zsc.edu.gateway.modules.iot.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zsc.edu.gateway.modules.iot.device.dto.BatchDeviceDto;
|
||||
import com.zsc.edu.gateway.modules.iot.device.dto.DeviceDto;
|
||||
import com.zsc.edu.gateway.modules.iot.device.dto.DeviceServeDto;
|
||||
import com.zsc.edu.gateway.modules.iot.device.entity.Device;
|
||||
import com.zsc.edu.gateway.modules.iot.device.entity.DeviceDiff;
|
||||
import com.zsc.edu.gateway.modules.iot.device.query.DeviceQuery;
|
||||
import com.zsc.edu.gateway.modules.iot.device.vo.DeviceVo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.zsc.edu.gateway.modules.iot.tsl.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zsc.edu.gateway.exception.ApiException;
|
||||
import com.zsc.edu.gateway.modules.iot.tsl.dto.PropertyDto;
|
||||
import com.zsc.edu.gateway.modules.iot.tsl.entity.Property;
|
||||
import com.zsc.edu.gateway.modules.iot.tsl.mapper.PropertyMapper;
|
||||
@ -25,7 +26,7 @@ public class PropertyServiceImpl extends ServiceImpl<PropertyRepository, Propert
|
||||
@Override
|
||||
public Property create(PropertyDto dto) {
|
||||
if (baseMapper.findByName(dto.getName()) != null) {
|
||||
throw new RuntimeException("该属性已存在!");
|
||||
throw new ApiException("该属性已存在!");
|
||||
}
|
||||
Property property = mapper.toEntity(dto);
|
||||
save(property);
|
||||
@ -40,7 +41,7 @@ public class PropertyServiceImpl extends ServiceImpl<PropertyRepository, Propert
|
||||
public Property update(PropertyDto dto, Long id) {
|
||||
Property property = baseMapper.selectById(id);
|
||||
if (property == null) {
|
||||
throw new RuntimeException("Serve not found with id: " + id);
|
||||
throw new ApiException("Serve not found with id: " + id);
|
||||
}
|
||||
mapper.convert(dto, property);
|
||||
baseMapper.updateById(property);
|
||||
@ -51,7 +52,7 @@ public class PropertyServiceImpl extends ServiceImpl<PropertyRepository, Propert
|
||||
public Property detail(Long id) {
|
||||
Property property = baseMapper.selectById(id);
|
||||
if (property == null) {
|
||||
throw new RuntimeException("属性不存在!请检查输入ID是否正确!");
|
||||
throw new ApiException("属性不存在!请检查输入ID是否正确!");
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
@ -86,8 +86,10 @@ public class RoleServiceImpl extends ServiceImpl<RoleRepository, Role> implement
|
||||
throw new ConstraintException("name", dto.getName(), "同名角色已存在");
|
||||
}
|
||||
mapper.convert(dto, existingRole);
|
||||
if (existingRole.getAuthorities() != null) {
|
||||
roleAuthService.remove(new LambdaQueryWrapper<RoleAuthority>().eq(RoleAuthority::getRoleId, id));
|
||||
saveRoleAuths(id, dto.getAuthorities());
|
||||
}
|
||||
return updateById(existingRole);
|
||||
}
|
||||
|
||||
|
@ -688,29 +688,3 @@ comment on column sys_user.enable_state is '状态';
|
||||
alter table sys_user
|
||||
owner to gitea;
|
||||
|
||||
-- 插入备份的数据
|
||||
INSERT INTO sys_user (dept_id, role_id, username, password, phone, email, name, avatar, address, create_by, update_by,
|
||||
create_time, update_time, remark, enable_state)
|
||||
SELECT dept_id,
|
||||
role_id,
|
||||
username,
|
||||
password,
|
||||
phone,
|
||||
email,
|
||||
name,
|
||||
avatar,
|
||||
address,
|
||||
create_by,
|
||||
update_by,
|
||||
create_time,
|
||||
update_time,
|
||||
remark,
|
||||
enable_state
|
||||
FROM sys_user_backup;
|
||||
|
||||
-- 删除备份表
|
||||
DROP TABLE sys_user_backup;
|
||||
|
||||
|
||||
ALTER TABLE iot_property
|
||||
ALTER COLUMN id ADD GENERATED ALWAYS AS IDENTITY;
|
@ -22,7 +22,7 @@
|
||||
<result column="create_time" jdbcType="DATE" property="deviceCreateTime"/>
|
||||
<result column="update_time" jdbcType="DATE" property="deviceUpdateTime"/>
|
||||
<result column="remark" jdbcType="VARCHAR" property="deviceRemark"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="name" property="productName"/>
|
||||
<result column="product_type" jdbcType="VARCHAR" property="productType"/>
|
||||
<result column="model" property="model"/>
|
||||
<result column="link" property="link"/>
|
||||
|
Loading…
Reference in New Issue
Block a user