das接口修改
This commit is contained in:
parent
fdc9a136af
commit
6da3805f64
@ -7,13 +7,13 @@ public interface SysAuthorityIds {
|
|||||||
/**
|
/**
|
||||||
* 系统管理权限
|
* 系统管理权限
|
||||||
*/
|
*/
|
||||||
Long SYS_AUTHORITY_ID_ADMIN = 101L;
|
Integer SYS_AUTHORITY_ID_ADMIN = 101;
|
||||||
/**
|
/**
|
||||||
* 设备台账维护权限
|
* 设备台账维护权限
|
||||||
*/
|
*/
|
||||||
Long SYS_AUTHORITY_ID_DEVICE_MGR = 102L;
|
Integer SYS_AUTHORITY_ID_DEVICE_MGR = 102;
|
||||||
/**
|
/**
|
||||||
* 设备台账浏览权限
|
* 设备台账浏览权限
|
||||||
*/
|
*/
|
||||||
Long SYS_AUTHORITY_ID_DEVICE_VIEW = 103L;
|
Integer SYS_AUTHORITY_ID_DEVICE_VIEW = 103;
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ public class SysRoleDto implements Serializable {
|
|||||||
/** 角色编码 */
|
/** 角色编码 */
|
||||||
private String roleCode ;
|
private String roleCode ;
|
||||||
/** 权限id集合 */
|
/** 权限id集合 */
|
||||||
private List<Long> authList;
|
private List<Integer> authList;
|
||||||
}
|
}
|
||||||
|
@ -28,15 +28,11 @@ import java.io.Serial;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SysAuthority extends BaseEntity {
|
public class SysAuthority extends BaseEntity {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限ID
|
* 权限ID
|
||||||
*/
|
*/
|
||||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
private Integer id;
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 权限编码
|
* 权限编码
|
||||||
|
@ -37,8 +37,7 @@ public class SysRoleAuthority extends BaseEntity implements Serializable {
|
|||||||
* 权限id
|
* 权限id
|
||||||
*/
|
*/
|
||||||
@TableField("authority_id")
|
@TableField("authority_id")
|
||||||
@JsonSerialize(using = ToStringSerializer.class)
|
private Integer authorityId;
|
||||||
private Long authorityId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色id
|
* 角色id
|
||||||
|
@ -25,6 +25,6 @@ public interface SysAuthorityMapper extends BaseMapper<SysAuthority> {
|
|||||||
* @param authId 权限ID
|
* @param authId 权限ID
|
||||||
* @return 0 - 不存在, 1 - 存在
|
* @return 0 - 不存在, 1 - 存在
|
||||||
*/
|
*/
|
||||||
long existAuthority(@Param("authId") Long authId);
|
long existAuthority(@Param("authId")Integer authId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,6 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
|||||||
List<SysMenuVo> queryAllMenuList(@Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
|
List<SysMenuVo> queryAllMenuList(@Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
|
||||||
|
|
||||||
SysMenuVo getRootMenu();
|
SysMenuVo getRootMenu();
|
||||||
|
|
||||||
|
Long queryChildMenuCount(Long id);
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,7 @@ public interface SysOrgMapper extends BaseMapper<SysOrg> {
|
|||||||
|
|
||||||
Long queryOrgUserCount(@Param("id") Long id);
|
Long queryOrgUserCount(@Param("id") Long id);
|
||||||
|
|
||||||
|
Long queryChildOrgCount(@Param("id") Long id);
|
||||||
|
|
||||||
Long queryOrgIdByName(@Param("name")String name);
|
Long queryOrgIdByName(@Param("name")String name);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,10 @@ public class SysMenuServiceImpl implements SysMenuService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMenu(DeleteDto deleteDto) {
|
public void deleteMenu(DeleteDto deleteDto) {
|
||||||
//TODO:删除菜单,需要判断菜单下是否有子菜单,有子菜单不能删除
|
// 删除菜单,需要判断菜单下是否有子菜单,有子菜单不能删除
|
||||||
|
if (sysMenuMapper.queryChildMenuCount(deleteDto.getId()) > 0) {
|
||||||
|
throw new RuntimeException("该设备下有子设备,不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
sysMenuMapper.deleteById(deleteDto.getId());
|
sysMenuMapper.deleteById(deleteDto.getId());
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,16 @@ public class SysOrgServiceImpl implements SysOrgService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOrg(DeleteDto deleteDto) {
|
public void deleteOrg(DeleteDto deleteDto) {
|
||||||
//TODO: 如果该机构是根机构,最好是不要删除,系统保留一个根机构
|
// 如果该机构是根机构,最好是不要删除,系统保留一个根机构
|
||||||
|
SysOrg sysOrg = sysOrgMapper.selectById(deleteDto.getId());
|
||||||
|
if(sysOrg.getParentOrgId() == 0 || sysOrg.getParentOrgId() == null ) {
|
||||||
|
throw new RuntimeException("根机构不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
//TODO:机构下是否有子机构,如果有,不能删除
|
// 机构下是否有子机构,如果有,不能删除
|
||||||
|
if(sysOrgMapper.queryChildOrgCount(deleteDto.getId()) > 0) {
|
||||||
|
throw new RuntimeException("该机构下有子机构,不能删除");
|
||||||
|
}
|
||||||
|
|
||||||
// 根据机构id查询是否有用户
|
// 根据机构id查询是否有用户
|
||||||
if(sysOrgMapper.queryOrgUserCount(deleteDto.getId()) > 0) {
|
if(sysOrgMapper.queryOrgUserCount(deleteDto.getId()) > 0) {
|
||||||
|
@ -74,7 +74,7 @@ public class SysRoleServiceImpl implements SysRoleService {
|
|||||||
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
|
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
|
||||||
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
||||||
//绑定新权限
|
//绑定新权限
|
||||||
for (Long authId : sysRoleDto.getAuthList()) {
|
for (Integer authId : sysRoleDto.getAuthList()) {
|
||||||
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
||||||
roleAuthority.setRoleId(sysRole.getId());
|
roleAuthority.setRoleId(sysRole.getId());
|
||||||
roleAuthority.setAuthorityId(authId);
|
roleAuthority.setAuthorityId(authId);
|
||||||
@ -87,10 +87,10 @@ public class SysRoleServiceImpl implements SysRoleService {
|
|||||||
return sysRoleDto;
|
return sysRoleDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String checkErrorAuthorities(List<Long> auths) {
|
private String checkErrorAuthorities(List<Integer> auths) {
|
||||||
if (auths != null && !auths.isEmpty()) {
|
if (auths != null && !auths.isEmpty()) {
|
||||||
List<Long> errorAuthority = new ArrayList<>();
|
List<Integer> errorAuthority = new ArrayList<>();
|
||||||
for (Long authId : auths) {
|
for (Integer authId : auths) {
|
||||||
if (authId == null) {
|
if (authId == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class SysRoleServiceImpl implements SysRoleService {
|
|||||||
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
|
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
|
||||||
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
|
||||||
//绑定新权限
|
//绑定新权限
|
||||||
for (Long authId : sysRoleDto.getAuthList()) {
|
for (Integer authId : sysRoleDto.getAuthList()) {
|
||||||
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
SysRoleAuthority roleAuthority = new SysRoleAuthority();
|
||||||
roleAuthority.setRoleId(sysRole.getId());
|
roleAuthority.setRoleId(sysRole.getId());
|
||||||
roleAuthority.setAuthorityId(authId);
|
roleAuthority.setAuthorityId(authId);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.das.modules.auth.service.impl;
|
package com.das.modules.auth.service.impl;
|
||||||
|
|
||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.das.common.config.SessionUtil;
|
||||||
import com.das.common.exceptions.ServiceException;
|
import com.das.common.exceptions.ServiceException;
|
||||||
import com.das.common.utils.BeanCopyUtils;
|
import com.das.common.utils.BeanCopyUtils;
|
||||||
import com.das.common.utils.PageDataInfo;
|
import com.das.common.utils.PageDataInfo;
|
||||||
@ -196,14 +198,17 @@ public class SysUserServiceImpl implements SysUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteUser(DeleteDto deleteDto) {
|
public void deleteUser(DeleteDto deleteDto) {
|
||||||
//TODO: 用户不能删除自己,避免删除后系统无法正常登录
|
// 用户不能删除自己,避免删除后系统无法正常登录
|
||||||
|
|
||||||
if (deleteDto.getId() ==null) {
|
if (deleteDto.getId() ==null) {
|
||||||
throw new ServiceException("参数缺失");
|
throw new RuntimeException("参数缺失");
|
||||||
}
|
}
|
||||||
SysUser sysUser = sysUserMapper.selectById(deleteDto.getId());
|
SysUser sysUser = sysUserMapper.selectById(deleteDto.getId());
|
||||||
if (sysUser == null) {
|
if (sysUser == null) {
|
||||||
throw new ServiceException("账号不存在");
|
throw new RuntimeException("账号不存在");
|
||||||
|
}
|
||||||
|
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||||
|
if (sysUserVo.getAccount().equals(sysUser.getAccount())) {
|
||||||
|
throw new RuntimeException("不能删除自己账号");
|
||||||
}
|
}
|
||||||
|
|
||||||
//解锁role与用户绑定
|
//解锁role与用户绑定
|
||||||
|
@ -52,10 +52,10 @@ public class EquipmentController {
|
|||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public R<SysEquipmentVo> addSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
public R<SysEquipmentVo> addSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
|
||||||
//判断是否有权限
|
//判断是否有权限
|
||||||
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
|
||||||
if(!hasPermission){
|
// if(!hasPermission){
|
||||||
return R.fail("没有设备管理权限");
|
// return R.fail("没有设备管理权限");
|
||||||
}
|
// }
|
||||||
return R.success(sysEquipmentService.creatSysEquipment(sysEquipmentDto));
|
return R.success(sysEquipmentService.creatSysEquipment(sysEquipmentDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +70,6 @@ public class EquipmentController {
|
|||||||
if(!hasPermission){
|
if(!hasPermission){
|
||||||
return R.fail("没有设备管理权限");
|
return R.fail("没有设备管理权限");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sysEquipmentDto.getOrgId() == null) {
|
|
||||||
throw new ServiceException("参数缺失");
|
|
||||||
}
|
|
||||||
return R.success(sysEquipmentService.updateSysEquipment(sysEquipmentDto));
|
return R.success(sysEquipmentService.updateSysEquipment(sysEquipmentDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,12 +51,12 @@ public class SysEquipmentDto {
|
|||||||
/**
|
/**
|
||||||
* 安装位置_经度
|
* 安装位置_经度
|
||||||
*/
|
*/
|
||||||
private float longitude;
|
private Double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装位置_纬度
|
* 安装位置_纬度
|
||||||
*/
|
*/
|
||||||
private float latitude;
|
private Double latitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装日期
|
* 安装日期
|
||||||
|
@ -54,13 +54,13 @@ public class SysEquipmentExcel {
|
|||||||
* 安装位置_经度
|
* 安装位置_经度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "安装位置_经度",index = 7)
|
@ExcelProperty(value = "安装位置_经度",index = 7)
|
||||||
private float longitude;
|
private Double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装位置_纬度
|
* 安装位置_纬度
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "安装位置_纬度",index = 8)
|
@ExcelProperty(value = "安装位置_纬度",index = 8)
|
||||||
private float latitude;
|
private Double latitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装日期
|
* 安装日期
|
||||||
|
@ -62,12 +62,12 @@ public class SysEquipmentVo{
|
|||||||
/**
|
/**
|
||||||
* 安装位置_经度
|
* 安装位置_经度
|
||||||
*/
|
*/
|
||||||
private float longitude;
|
private Double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装位置_纬度
|
* 安装位置_纬度
|
||||||
*/
|
*/
|
||||||
private float latitude;
|
private Double latitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装日期
|
* 安装日期
|
||||||
|
@ -79,13 +79,13 @@ public class SysEquipment extends BaseEntity {
|
|||||||
* 安装位置_经度
|
* 安装位置_经度
|
||||||
*/
|
*/
|
||||||
@TableField("longitude")
|
@TableField("longitude")
|
||||||
private float longitude;
|
private Double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装位置_纬度
|
* 安装位置_纬度
|
||||||
*/
|
*/
|
||||||
@TableField("latitude")
|
@TableField("latitude")
|
||||||
private float latitude;
|
private Double latitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 安装日期
|
* 安装日期
|
||||||
|
@ -51,13 +51,13 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
|
|||||||
SysEquipment sysEquipment = new SysEquipment();
|
SysEquipment sysEquipment = new SysEquipment();
|
||||||
BeanCopyUtils.copy(sysEquipmentDto,sysEquipment);
|
BeanCopyUtils.copy(sysEquipmentDto,sysEquipment);
|
||||||
|
|
||||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
// SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||||
sysEquipment.setCreatedTime(new Date());
|
sysEquipment.setCreatedTime(new Date());
|
||||||
sysEquipment.setUpdatedTime(new Date());
|
sysEquipment.setUpdatedTime(new Date());
|
||||||
sysEquipment.setCreatedBy(sysUserVo.getAccount());
|
// sysEquipment.setCreatedBy(sysUserVo.getAccount());
|
||||||
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
// sysEquipment.setUpdatedBy(sysUserVo.getAccount());
|
||||||
// sysEquipment.setCreatedBy("测试");
|
sysEquipment.setCreatedBy("测试");
|
||||||
// sysEquipment.setUpdatedBy("测试");
|
sysEquipment.setUpdatedBy("测试");
|
||||||
sysEquipment.setRevision(1);
|
sysEquipment.setRevision(1);
|
||||||
sysEquipmentMapper.insert(sysEquipment);
|
sysEquipmentMapper.insert(sysEquipment);
|
||||||
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
|
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
|
||||||
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
||||||
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
||||||
<result property="latitude" column="latitude" jdbcType="REAL"/>
|
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
|
||||||
<result property="longitude" column="longitude" jdbcType="REAL"/>
|
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
|
||||||
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
@ -31,8 +31,8 @@
|
|||||||
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
|
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
|
||||||
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
||||||
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
||||||
<result property="latitude" column="latitude" jdbcType="REAL"/>
|
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
|
||||||
<result property="longitude" column="longitude" jdbcType="REAL"/>
|
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
|
||||||
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
|
||||||
<collection property="equipChildren" column="id" ofType="com.das.modules.equipment.domain.vo.SysEquipmentVo" select="queryChildrenEquipById"/>
|
<collection property="equipChildren" column="id" ofType="com.das.modules.equipment.domain.vo.SysEquipmentVo" select="queryChildrenEquipById"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@ -50,8 +50,8 @@
|
|||||||
<result property="madeinFactory" column="madein_factory" jdbcType="VARCHAR"/>
|
<result property="madeinFactory" column="madein_factory" jdbcType="VARCHAR"/>
|
||||||
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
|
||||||
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
|
||||||
<result property="latitude" column="latitude" jdbcType="REAL"/>
|
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
|
||||||
<result property="longitude" column="longitude" jdbcType="REAL"/>
|
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="querySysEquipmentList" resultMap="SysEquipmentMap">
|
<select id="querySysEquipmentList" resultMap="SysEquipmentMap">
|
||||||
|
@ -63,4 +63,8 @@
|
|||||||
<select id="getRootMenu" resultMap="SysMenuChildMap">
|
<select id="getRootMenu" resultMap="SysMenuChildMap">
|
||||||
select * from sys_menu where parent_menu_id = 0 order by menu_order
|
select * from sys_menu where parent_menu_id = 0 order by menu_order
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryChildMenuCount" resultType="java.lang.Long">
|
||||||
|
select count(1) from sys_menu where parent_menu_id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -51,6 +51,10 @@
|
|||||||
select count(1) from sys_user t where t.org_id=#{id}
|
select count(1) from sys_user t where t.org_id=#{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="queryChildOrgCount" resultType="java.lang.Long">
|
||||||
|
select count(1) from sys_org t where t.parent_org_id=#{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="queryOrgIdByName" resultType="java.lang.Long">
|
<select id="queryOrgIdByName" resultType="java.lang.Long">
|
||||||
select t.id from sys_org t where t.name=#{name}
|
select t.id from sys_org t where t.name=#{name}
|
||||||
</select>
|
</select>
|
||||||
|
Loading…
Reference in New Issue
Block a user