das接口修改

This commit is contained in:
chenhaojie 2024-07-12 15:26:33 +08:00
parent fdc9a136af
commit 6da3805f64
20 changed files with 69 additions and 51 deletions

View File

@ -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;
}

View File

@ -17,5 +17,5 @@ public class SysRoleDto implements Serializable {
/** 角色编码 */
private String roleCode ;
/** 权限id集合 */
private List<Long> authList;
private List<Integer> authList;
}

View File

@ -28,15 +28,11 @@ import java.io.Serial;
@AllArgsConstructor
public class SysAuthority extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 权限ID
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private Integer id;
/**
* 权限编码

View File

@ -37,8 +37,7 @@ public class SysRoleAuthority extends BaseEntity implements Serializable {
* 权限id
*/
@TableField("authority_id")
@JsonSerialize(using = ToStringSerializer.class)
private Long authorityId;
private Integer authorityId;
/**
* 角色id

View File

@ -25,6 +25,6 @@ public interface SysAuthorityMapper extends BaseMapper<SysAuthority> {
* @param authId 权限ID
* @return 0 - 不存在 1 - 存在
*/
long existAuthority(@Param("authId") Long authId);
long existAuthority(@Param("authId")Integer authId);
}

View File

@ -23,4 +23,6 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
List<SysMenuVo> queryAllMenuList(@Param("sysMenu") SysMenuQueryDto sysMenuQueryDto);
SysMenuVo getRootMenu();
Long queryChildMenuCount(Long id);
}

View File

@ -22,5 +22,7 @@ public interface SysOrgMapper extends BaseMapper<SysOrg> {
Long queryOrgUserCount(@Param("id") Long id);
Long queryChildOrgCount(@Param("id") Long id);
Long queryOrgIdByName(@Param("name")String name);
}

View File

@ -46,7 +46,10 @@ public class SysMenuServiceImpl implements SysMenuService {
@Override
public void deleteMenu(DeleteDto deleteDto) {
//TODO:删除菜单需要判断菜单下是否有子菜单有子菜单不能删除
// 删除菜单需要判断菜单下是否有子菜单有子菜单不能删除
if (sysMenuMapper.queryChildMenuCount(deleteDto.getId()) > 0) {
throw new RuntimeException("该设备下有子设备,不能删除");
}
sysMenuMapper.deleteById(deleteDto.getId());
}

View File

@ -44,9 +44,16 @@ public class SysOrgServiceImpl implements SysOrgService {
@Override
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查询是否有用户
if(sysOrgMapper.queryOrgUserCount(deleteDto.getId()) > 0) {

View File

@ -74,7 +74,7 @@ public class SysRoleServiceImpl implements SysRoleService {
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
//绑定新权限
for (Long authId : sysRoleDto.getAuthList()) {
for (Integer authId : sysRoleDto.getAuthList()) {
SysRoleAuthority roleAuthority = new SysRoleAuthority();
roleAuthority.setRoleId(sysRole.getId());
roleAuthority.setAuthorityId(authId);
@ -87,10 +87,10 @@ public class SysRoleServiceImpl implements SysRoleService {
return sysRoleDto;
}
private String checkErrorAuthorities(List<Long> auths) {
private String checkErrorAuthorities(List<Integer> auths) {
if (auths != null && !auths.isEmpty()) {
List<Long> errorAuthority = new ArrayList<>();
for (Long authId : auths) {
List<Integer> errorAuthority = new ArrayList<>();
for (Integer authId : auths) {
if (authId == null) {
continue;
}
@ -147,7 +147,7 @@ public class SysRoleServiceImpl implements SysRoleService {
authorityInfoQueryWrapper.eq("role_id", sysRoleDto.getId());
sysRoleAuthorityMapper.delete(authorityInfoQueryWrapper);
//绑定新权限
for (Long authId : sysRoleDto.getAuthList()) {
for (Integer authId : sysRoleDto.getAuthList()) {
SysRoleAuthority roleAuthority = new SysRoleAuthority();
roleAuthority.setRoleId(sysRole.getId());
roleAuthority.setAuthorityId(authId);

View File

@ -1,8 +1,10 @@
package com.das.modules.auth.service.impl;
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.metadata.IPage;
import com.das.common.config.SessionUtil;
import com.das.common.exceptions.ServiceException;
import com.das.common.utils.BeanCopyUtils;
import com.das.common.utils.PageDataInfo;
@ -196,14 +198,17 @@ public class SysUserServiceImpl implements SysUserService {
@Override
public void deleteUser(DeleteDto deleteDto) {
//TODO: 用户不能删除自己避免删除后系统无法正常登录
// 用户不能删除自己避免删除后系统无法正常登录
if (deleteDto.getId() ==null) {
throw new ServiceException("参数缺失");
throw new RuntimeException("参数缺失");
}
SysUser sysUser = sysUserMapper.selectById(deleteDto.getId());
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与用户绑定

View File

@ -52,10 +52,10 @@ public class EquipmentController {
@PostMapping("/add")
public R<SysEquipmentVo> addSysEquipment(@RequestBody SysEquipmentDto sysEquipmentDto) {
//判断是否有权限
boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
if(!hasPermission){
return R.fail("没有设备管理权限");
}
// boolean hasPermission = StpUtil.hasPermission(SysAuthorityIds.SYS_AUTHORITY_ID_DEVICE_MGR.toString());
// if(!hasPermission){
// return R.fail("没有设备管理权限");
// }
return R.success(sysEquipmentService.creatSysEquipment(sysEquipmentDto));
}
@ -70,10 +70,6 @@ public class EquipmentController {
if(!hasPermission){
return R.fail("没有设备管理权限");
}
if (sysEquipmentDto.getOrgId() == null) {
throw new ServiceException("参数缺失");
}
return R.success(sysEquipmentService.updateSysEquipment(sysEquipmentDto));
}

View File

@ -51,12 +51,12 @@ public class SysEquipmentDto {
/**
* 安装位置_经度
*/
private float longitude;
private Double longitude;
/**
* 安装位置_纬度
*/
private float latitude;
private Double latitude;
/**
* 安装日期

View File

@ -54,13 +54,13 @@ public class SysEquipmentExcel {
* 安装位置_经度
*/
@ExcelProperty(value = "安装位置_经度",index = 7)
private float longitude;
private Double longitude;
/**
* 安装位置_纬度
*/
@ExcelProperty(value = "安装位置_纬度",index = 8)
private float latitude;
private Double latitude;
/**
* 安装日期

View File

@ -62,12 +62,12 @@ public class SysEquipmentVo{
/**
* 安装位置_经度
*/
private float longitude;
private Double longitude;
/**
* 安装位置_纬度
*/
private float latitude;
private Double latitude;
/**
* 安装日期

View File

@ -79,13 +79,13 @@ public class SysEquipment extends BaseEntity {
* 安装位置_经度
*/
@TableField("longitude")
private float longitude;
private Double longitude;
/**
* 安装位置_纬度
*/
@TableField("latitude")
private float latitude;
private Double latitude;
/**
* 安装日期

View File

@ -51,13 +51,13 @@ public class SysEquipmentServiceImpl implements SysEquipmentService {
SysEquipment sysEquipment = new 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.setUpdatedTime(new Date());
sysEquipment.setCreatedBy(sysUserVo.getAccount());
sysEquipment.setUpdatedBy(sysUserVo.getAccount());
// sysEquipment.setCreatedBy("测试");
// sysEquipment.setUpdatedBy("测试");
// sysEquipment.setCreatedBy(sysUserVo.getAccount());
// sysEquipment.setUpdatedBy(sysUserVo.getAccount());
sysEquipment.setCreatedBy("测试");
sysEquipment.setUpdatedBy("测试");
sysEquipment.setRevision(1);
sysEquipmentMapper.insert(sysEquipment);
SysEquipmentVo sysEquipmentVo = new SysEquipmentVo();

View File

@ -14,8 +14,8 @@
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
<result property="latitude" column="latitude" jdbcType="REAL"/>
<result property="longitude" column="longitude" jdbcType="REAL"/>
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
</resultMap>
@ -31,8 +31,8 @@
<result property="parentEquipmentId" column="parent_equipment_id" jdbcType="BIGINT"/>
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
<result property="latitude" column="latitude" jdbcType="REAL"/>
<result property="longitude" column="longitude" jdbcType="REAL"/>
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
<result property="iotModelId" column="iot_model_id" jdbcType="BIGINT"/>
<collection property="equipChildren" column="id" ofType="com.das.modules.equipment.domain.vo.SysEquipmentVo" select="queryChildrenEquipById"/>
</resultMap>
@ -50,8 +50,8 @@
<result property="madeinFactory" column="madein_factory" jdbcType="VARCHAR"/>
<result property="installDate" column="install_date" jdbcType="TIMESTAMP"/>
<result property="remarks" column="remarks" jdbcType="VARCHAR"/>
<result property="latitude" column="latitude" jdbcType="REAL"/>
<result property="longitude" column="longitude" jdbcType="REAL"/>
<result property="latitude" column="latitude" jdbcType="DOUBLE"/>
<result property="longitude" column="longitude" jdbcType="DOUBLE"/>
</resultMap>
<select id="querySysEquipmentList" resultMap="SysEquipmentMap">

View File

@ -63,4 +63,8 @@
<select id="getRootMenu" resultMap="SysMenuChildMap">
select * from sys_menu where parent_menu_id = 0 order by menu_order
</select>
<select id="queryChildMenuCount" resultType="java.lang.Long">
select count(1) from sys_menu where parent_menu_id = #{id}
</select>
</mapper>

View File

@ -51,6 +51,10 @@
select count(1) from sys_user t where t.org_id=#{id}
</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 t.id from sys_org t where t.name=#{name}
</select>