Commit 448f77e7 authored by luzhuang's avatar luzhuang

上传

parent fa8156ca
...@@ -34,7 +34,7 @@ public class SysRoleController extends PaginationController<SysRole> { ...@@ -34,7 +34,7 @@ public class SysRoleController extends PaginationController<SysRole> {
private SysRoleService sysRoleServiceImpl; private SysRoleService sysRoleServiceImpl;
@ApiOperation(value="1001 分页查询角色", notes="分页查询角色") @ApiOperation(value="1001 分页查询所有角色", notes="分页查询所有角色")
@GetMapping(value = "/queryRoles") @GetMapping(value = "/queryRoles")
public GridModel queryRolesByPagination(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){ public GridModel queryRolesByPagination(CurUser curUser, @Valid FindRolePaginDTO findRolePaginDTO, BindingResult bindingResult){
sysRoleServiceImpl.queryRolesByPagination(getPaginationUtility(), findRolePaginDTO); sysRoleServiceImpl.queryRolesByPagination(getPaginationUtility(), findRolePaginDTO);
...@@ -52,38 +52,16 @@ public class SysRoleController extends PaginationController<SysRole> { ...@@ -52,38 +52,16 @@ public class SysRoleController extends PaginationController<SysRole> {
} }
@ApiOperation(value="1003 增加/修改角色", notes="增加/修改角色") @ApiOperation(value="1003 数据权限分配", notes="数据权限分配")
@PostMapping(value = "/add") @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "角色id", required = true, dataType = "varchar"),
public Result roleAdd(CurUser curUser, @Valid AddOrUpdateRoleDTO addOrUpdateRoleDTO, BindingResult bindingResult){ @ApiImplicitParam(name = "type", value = "0:仅可看自己 1:可看全部 2:查看指定", required = true, dataType = "varchar"),
int line = sysRoleServiceImpl.persistRole(addOrUpdateRoleDTO); @ApiImplicitParam(name = "departIds", value = "部门id,逗号间隔", required = true, dataType = "varchar")})
return Result.builder(new PersistModel(line), @PostMapping(value = "/roleData")
public Result roleData(CurUser curUser,@Valid SysRole sysRole,BindingResult br){
return Result.builder(sysRoleServiceImpl.updateRoleData(sysRole),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
addOrUpdateRoleDTO); sysRole);
}
@ApiOperation(value="1004 删除角色", notes="删除角色")
@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar", paramType = "path")
@PostMapping(value = "/delete")
public Result roleDelete(CurUser curUser, String businessId, BindingResult bindingResult){
int line = sysRoleServiceImpl.removeRole(businessId);
return Result.builder(new PersistModel(line),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
@ApiOperation(value="权限分配", notes="权限分配")
@ApiImplicitParams({@ApiImplicitParam(name = "roleId", value = "businessId", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "menus", value = "菜单id,逗号间隔", required = true, dataType = "varchar")})
@PostMapping(value = "/rolePermission")
public Result rolePermission(@RequestParam("roleId") String roleId, @RequestParam("menus") String menus ){
return Result.builder(sysRoleServiceImpl.doAuthorization(roleId,menus),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
roleId);
} }
} }
...@@ -199,11 +199,6 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -199,11 +199,6 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
List<SysRole> queryRolesByName(SysRole sysRole); List<SysRole> queryRolesByName(SysRole sysRole);
// @Select("SELECT COUNT(*) FROM s_menu sm \n" +
// "LEFT JOIN s_role_menu rm ON sm.BUSINESS_ID = rm.MENU_ID\n" +
// "LEFT JOIN s_role sr ON rm.ROLE_ID = sr.business_id\n" +
// "WHERE sr.`code` = #{roleCode} AND sm.BUSINESS_ID = #{businessId}")
// int queryRoleByRoleCode(@Param("roleCode") String roleCode, @Param("businessId") String businessId);
@Select("SELECT count(*) FROM s_menu \n" + @Select("SELECT count(*) FROM s_menu \n" +
"LEFT JOIN s_role_menu ON s_menu.BUSINESS_ID = s_role_menu.MENU_ID " + "LEFT JOIN s_role_menu ON s_menu.BUSINESS_ID = s_role_menu.MENU_ID " +
...@@ -211,35 +206,6 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -211,35 +206,6 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"WHERE s_menu.MODEL_ID = #{modelId} AND ROLE_ID = #{roleId}") "WHERE s_menu.MODEL_ID = #{modelId} AND ROLE_ID = #{roleId}")
int queryRoleByRoleCode(@Param("modelId") String modelId, @Param("roleId") String roleId); int queryRoleByRoleCode(@Param("modelId") String modelId, @Param("roleId") String roleId);
/**
* 根据子表id 删除 s_r_user_role
*
* @param tableByKey
* @param businessId
* @return
*/
@Delete("DELETE\n" +
"FROM\n" +
"\ts_r_user_role\n" +
"WHERE\n" +
"\ts_r_user_role.business_id = (\n" +
"\t\tSELECT\n" +
"\t\t\tab.*\n" +
"\t\tFROM\n" +
"\t\t\t(\n" +
"\t\t\t\tSELECT\n" +
"\t\t\t\t\ts_r_user_role.business_id\n" +
"\t\t\t\tFROM\n" +
"\t\t\t\t\ts_r_user_role\n" +
"\t\t\t\tLEFT JOIN s_user ON s_r_user_role.user_id = s_user.business_id\n" +
"\t\t\t\tLEFT JOIN ${tb} ON ${tb}.`code` = s_user.login_name\n" +
"\t\t\t\tWHERE\n" +
"\t\t\t\t\t${tb}.business_id = #{cid}\n" +
"\t\t\t) ab\n" +
"\t)")
int deleteUserRoleByChildrenId(@Param("tb") String tableByKey, @Param("cid") String businessId);
@Select("<script>select count(1) " + @Select("<script>select count(1) " +
"from tm_admin_role " + "from tm_admin_role " +
"where corp_id = #{corpId} " + "where corp_id = #{corpId} " +
...@@ -263,4 +229,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -263,4 +229,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"values(#{businessId},#{userId},#{roleId}) " + "values(#{businessId},#{userId},#{roleId}) " +
"</script>") "</script>")
int addUserRole(UserRoleDTO param); int addUserRole(UserRoleDTO param);
@Update("update tm_admin_role set type = #{type} , depart_ids = #{departIds} where r_id = #{businessId}")
int updateRoleData(SysRole sysRole);
} }
...@@ -22,9 +22,10 @@ public class SysRole extends IdEntity<SysRole> { ...@@ -22,9 +22,10 @@ public class SysRole extends IdEntity<SysRole> {
@Length(min = 1,max = 64,message = "长度最小为1,最大为50") @Length(min = 1,max = 64,message = "长度最小为1,最大为50")
@NotBlank @NotBlank
private String roleName; private String roleName;
@Length(min = 1,max = 64,message = "长度最小为1,最大为50")
@NotBlank private String type;
private String businessId;
private String departIds;
@Transient @Transient
private int userNum; private int userNum;
......
...@@ -22,6 +22,8 @@ public interface SysRoleService { ...@@ -22,6 +22,8 @@ public interface SysRoleService {
*/ */
int persistRole(AddOrUpdateRoleDTO addOrUpdateRoleDTO); int persistRole(AddOrUpdateRoleDTO addOrUpdateRoleDTO);
PersistModel updateRoleData(SysRole sysRole);
/** /**
* 删除 * 删除
......
...@@ -64,6 +64,12 @@ public class SysRoleServiceImpl implements SysRoleService { ...@@ -64,6 +64,12 @@ public class SysRoleServiceImpl implements SysRoleService {
return line; return line;
} }
@Override
public PersistModel updateRoleData(SysRole sysRole) {
int line = sysRoleRepository.updateRoleData(sysRole);
return new PersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<!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="org.rcisoft.sys.role.dao.SysRoleRepository"> <mapper namespace="org.rcisoft.sys.role.dao.SysRoleRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.sys.role.entity.SysRole"> <resultMap id="BaseResultMap" type="org.rcisoft.sys.role.entity.SysRole">
<id column="business_id" jdbcType="VARCHAR" property="businessId" />
<result column="role_name" jdbcType="VARCHAR" property="roleName" /> <result column="role_name" jdbcType="VARCHAR" property="roleName" />
<result column="CODE" jdbcType="VARCHAR" property="code" /> <result column="CODE" jdbcType="VARCHAR" property="code" />
<result column="checked" jdbcType="VARCHAR" property="checked" /> <result column="checked" jdbcType="VARCHAR" property="checked" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment