新增接口
This commit is contained in:
parent
c83c8a36af
commit
382d104935
@ -1,6 +1,7 @@
|
||||
package ink.wgink.service.role.controller.resources;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.role.RoleUserDTO;
|
||||
@ -79,4 +80,17 @@ public class RoleUserResourceController extends DefaultBaseController {
|
||||
return roleUserService.listRolePOByUserId(userId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户ID列表", notes = "通过角色和用户ID列表获取用户ID列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "roleId", value = "角色ID", paramType = "path", dataType = "String"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PostMapping("list-user-id/role-id/{roleId}/user-ids")
|
||||
public List<String> listUserIdByRoleIdAndUserIds(@PathVariable("userId") String roleId, @RequestBody IdsVO idsVO) {
|
||||
if (idsVO.getIds().isEmpty()) {
|
||||
throw new ParamsException("id列表不能为空");
|
||||
}
|
||||
return roleUserService.listUserIdByRoleIdAndUserIds(roleId, idsVO.getIds());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ package ink.wgink.service.role.service.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.interfaces.role.IRoleUserDeleteAfterHandler;
|
||||
import ink.wgink.interfaces.role.IRoleUserSaveAfterHandler;
|
||||
import ink.wgink.interfaces.user.IUserBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.dtos.role.RoleSimpleDTO;
|
||||
@ -40,6 +42,10 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
private IRoleService roleService;
|
||||
@Autowired
|
||||
private IUserBaseService userBaseService;
|
||||
@Autowired(required = false)
|
||||
private IRoleUserSaveAfterHandler roleUserSaveAfterHandler;
|
||||
@Autowired(required = false)
|
||||
private IRoleUserDeleteAfterHandler roleUserDeleteAfterHandler;
|
||||
|
||||
@Override
|
||||
public void update(String roleId, List<String> userIds) {
|
||||
@ -52,6 +58,9 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
roleUserDao.save(params);
|
||||
}
|
||||
}
|
||||
if (roleUserSaveAfterHandler != null) {
|
||||
roleUserSaveAfterHandler.handle(roleId, userIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,6 +69,9 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
params.put("roleId", roleId);
|
||||
params.put("userIds", userIds);
|
||||
roleUserDao.delete(params);
|
||||
if (roleUserDeleteAfterHandler != null) {
|
||||
roleUserSaveAfterHandler.handle(roleId, userIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -122,6 +134,20 @@ public class RoleUserServiceImpl extends DefaultBaseService implements IRoleUser
|
||||
return roleSimpleDTOs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listUserIdByRoleIdAndUserIds(String roleId, List<String> userIds) {
|
||||
if (StringUtils.isBlank(roleId)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
if (userIds == null || userIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<String, Object> params = getHashMap(4);
|
||||
params.put("roleId", roleId);
|
||||
params.put("userIds", userIds);
|
||||
return roleUserDao.listUserId(params);
|
||||
}
|
||||
|
||||
|
||||
private List<String> listGroupUserId(Map<String, Object> params) {
|
||||
return roleUserDao.listGroupUserId(params);
|
||||
|
@ -56,17 +56,25 @@
|
||||
user_id
|
||||
FROM
|
||||
sys_role_user
|
||||
WHERE
|
||||
<where>
|
||||
<if test="roleId != null and roleId != ''">
|
||||
role_id = #{roleId}
|
||||
</if>
|
||||
<if test="roleIds != null and roleIds.size > 0">
|
||||
role_id IN (
|
||||
AND
|
||||
role_id IN
|
||||
<foreach collection="roleIds" index="index" open="(" separator="," close=")">
|
||||
#{roleIds[${index}]}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="userIds != null and userIds.size > 0">
|
||||
AND
|
||||
user_id IN
|
||||
<foreach collection="userIds" index="index" open="(" separator="," close=")">
|
||||
#{userIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 角色ID列表 -->
|
||||
|
Loading…
Reference in New Issue
Block a user