fetch:删除角色
This commit is contained in:
@@ -91,7 +91,6 @@ spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
|
|||||||
# =======================================
|
# =======================================
|
||||||
mybatis-plus.config-location=classpath:mybatis/mybatis-config.xml
|
mybatis-plus.config-location=classpath:mybatis/mybatis-config.xml
|
||||||
mybatis-plus.mapper-locations=classpath*:mybatis/mapper/**/*.xml
|
mybatis-plus.mapper-locations=classpath*:mybatis/mapper/**/*.xml
|
||||||
mybatis-plus.type-aliases-package=com.adc.da.**.entity
|
|
||||||
|
|
||||||
# ========================================
|
# ========================================
|
||||||
# activiti 配置信息
|
# activiti 配置信息
|
||||||
|
|||||||
@@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
<artifactId>adc-da-slrs</artifactId>
|
<artifactId>adc-da-slrs</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId></groupId>
|
|
||||||
<artifactId></artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.adc</groupId>
|
<groupId>com.adc</groupId>
|
||||||
<artifactId>adc-da-base</artifactId>
|
<artifactId>adc-da-base</artifactId>
|
||||||
|
|||||||
@@ -19,14 +19,34 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface TsPositionDao extends BaseMapper<TsPosition> {
|
public interface TsPositionDao extends BaseMapper<TsPosition> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询岗位绑定的角色ID
|
||||||
|
* @param positionId:岗位ID
|
||||||
|
* @return List<String>:角色ID
|
||||||
|
*/
|
||||||
@Select("select role_id from ts_position_role where position_id=#{positionId}")
|
@Select("select role_id from ts_position_role where position_id=#{positionId}")
|
||||||
List<String> getRoleId(String positionId);
|
List<String> getRoleId(String positionId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定角色
|
||||||
|
* @param positionId:岗位ID
|
||||||
|
* @param roleId:角色ID
|
||||||
|
*/
|
||||||
@Insert("insert into ts_position_role (position_id,role_id) values (#{positionId},#{roleId})")
|
@Insert("insert into ts_position_role (position_id,role_id) values (#{positionId},#{roleId})")
|
||||||
void insertRole(String positionId, String roleId);
|
void insertRole(String positionId, String roleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解绑角色
|
||||||
|
* @param positionId:岗位ID
|
||||||
|
* @param roleId:角色ID
|
||||||
|
*/
|
||||||
@Delete("delete from ts_position_role where position_id=#{positionId} and role_id=#{roleId}")
|
@Delete("delete from ts_position_role where position_id=#{positionId} and role_id=#{roleId}")
|
||||||
void deleteRole(String positionId, String roleId);
|
void deleteRole(String positionId, String roleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询岗位绑定的角色信息
|
||||||
|
* @param positionId:岗位ID
|
||||||
|
* @return List<TsRole>
|
||||||
|
*/
|
||||||
List<TsRole> getRole(String positionId);
|
List<TsRole> getRole(String positionId);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -88,6 +88,7 @@ public class TsPositionServiceImpl extends ServiceImpl<TsPositionDao, TsPosition
|
|||||||
if(tsPositions!=null&&tsPositions.size()>0){
|
if(tsPositions!=null&&tsPositions.size()>0){
|
||||||
return Result.error("该岗位已存在");
|
return Result.error("该岗位已存在");
|
||||||
}
|
}
|
||||||
|
tsPosition.setType("2");
|
||||||
tsPositionDao.insert(tsPosition);
|
tsPositionDao.insert(tsPosition);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.adc.da.login.util.UserUtils;
|
|||||||
import com.adc.da.slrs.sarRole.service.ITsRoleService;
|
import com.adc.da.slrs.sarRole.service.ITsRoleService;
|
||||||
import com.adc.da.sys.entity.UserEO;
|
import com.adc.da.sys.entity.UserEO;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.apache.ibatis.annotations.Delete;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -62,4 +63,10 @@ public class TsRoleController extends BaseController<TsRole> {
|
|||||||
tsRole.setOperator(userEO.getUname());
|
tsRole.setOperator(userEO.getUname());
|
||||||
return tsRoleService.updateRole(tsRole);
|
return tsRoleService.updateRole(tsRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除角色")
|
||||||
|
@DeleteMapping
|
||||||
|
public ResponseMessage<Object> deleteRole(@RequestParam String roleId){
|
||||||
|
return tsRoleService.deleteRole(roleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package com.adc.da.slrs.sarRole.dao;
|
|||||||
|
|
||||||
import com.adc.da.slrs.sarRole.entity.TsRole;
|
import com.adc.da.slrs.sarRole.entity.TsRole;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -13,4 +16,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
*/
|
*/
|
||||||
public interface TsRoleDao extends BaseMapper<TsRole> {
|
public interface TsRoleDao extends BaseMapper<TsRole> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询该角色绑定的岗位ID
|
||||||
|
* @param roleId:角色ID
|
||||||
|
* @return List<String>:岗位ID
|
||||||
|
*/
|
||||||
|
@Select("select position_id from ts_position_role where role_id=#{roleId}")
|
||||||
|
List<String> getPositionIds(String roleId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,4 +42,11 @@ public interface ITsRoleService extends IService<TsRole> {
|
|||||||
* @return ResponseMessage<Object>
|
* @return ResponseMessage<Object>
|
||||||
*/
|
*/
|
||||||
ResponseMessage<Object> updateRole(TsRole tsRole);
|
ResponseMessage<Object> updateRole(TsRole tsRole);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除角色
|
||||||
|
* @param roleId:角色Id
|
||||||
|
* @return ResponseMessage<Object>
|
||||||
|
*/
|
||||||
|
ResponseMessage<Object> deleteRole(String roleId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,5 +109,30 @@ public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements
|
|||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除角色
|
||||||
|
* @param roleId:角色Id
|
||||||
|
* @return ResponseMessage<Object>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ResponseMessage<Object> deleteRole(String roleId) {
|
||||||
|
TsRole tsRole=tsRoleDao.selectById(roleId);
|
||||||
|
if(tsRole==null){
|
||||||
|
return Result.error("该角色不存在");
|
||||||
|
}
|
||||||
|
QueryWrapper<TsRole> childrenRoleQueryWrapper=new QueryWrapper<>();
|
||||||
|
childrenRoleQueryWrapper.eq("parent_id",roleId);
|
||||||
|
List<TsRole> childrenRole=tsRoleDao.selectList(childrenRoleQueryWrapper);
|
||||||
|
if(childrenRole!=null&&childrenRole.size()>0){
|
||||||
|
return Result.error("该角色有下属角色,无法删除");
|
||||||
|
}
|
||||||
|
List<String> positionIds=tsRoleDao.getPositionIds(roleId);
|
||||||
|
if(positionIds!=null&&positionIds.size()>0){
|
||||||
|
return Result.error("该角色已绑定岗位,无法删除");
|
||||||
|
}
|
||||||
|
tsRoleDao.deleteById(roleId);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.adc.da.slrs.sarPosition.dao.TsPositionDao">
|
<mapper namespace="com.adc.da.slrs.sarPosition.dao.TsPositionDao">
|
||||||
<select id="getRole" resultType="TsRole">
|
<select id="getRole" resultType="com.adc.da.slrs.sarRole.entity.TsRole">
|
||||||
select * from ts_role r
|
select * from ts_role r
|
||||||
left join ts_position_role ps
|
left join ts_position_role ps
|
||||||
on r.id=ps.role_id
|
on r.id=ps.role_id
|
||||||
|
|||||||
Reference in New Issue
Block a user