未验证 提交 f52bad5e 编写于 作者: L lgcareer 提交者: GitHub

fix #2449:It's should successful to cancel authorize a resource of a user if...

fix #2449:It's should successful to cancel authorize a resource of a user if all the online process definitions created by this user didn't use this resource. (#2725)
上级 c08fa12f
......@@ -511,7 +511,7 @@ public class UsersService extends BaseService {
if (CollectionUtils.isNotEmpty(oldAuthorizedResIds)) {
// get all resource id of process definitions those is released
List<Map<String, Object>> list = processDefinitionMapper.listResources();
List<Map<String, Object>> list = processDefinitionMapper.listResourcesByUser(userId);
Map<Integer, Set<Integer>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list);
Set<Integer> resourceIdSet = resourceProcessMap.keySet();
......
......@@ -102,4 +102,11 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
*/
@MapKey("id")
List<Map<String, Object>> listResources();
/**
* list all resource ids by user id
* @return resource ids list
*/
@MapKey("id")
List<Map<String, Object>> listResourcesByUser(@Param("userId") Integer userId);
}
......@@ -96,4 +96,10 @@
FROM t_ds_process_definition
WHERE release_state = 1 and resource_ids is not null and resource_ids != ''
</select>
<select id="listResourcesByUser" resultType="java.util.HashMap">
SELECT id,resource_ids
FROM t_ds_process_definition
WHERE user_id = #{userId} and release_state = 1 and resource_ids is not null and resource_ids != ''
</select>
</mapper>
\ No newline at end of file
......@@ -242,4 +242,13 @@ public class ProcessDefinitionMapperTest {
List<Map<String, Object>> maps = processDefinitionMapper.listResources();
Assert.assertNotNull(maps);
}
@Test
public void listResourcesByUserTest(){
ProcessDefinition processDefinition = insertOne();
processDefinition.setResourceIds("3,5");
processDefinition.setReleaseState(ReleaseState.ONLINE);
List<Map<String, Object>> maps = processDefinitionMapper.listResourcesByUser(processDefinition.getUserId());
Assert.assertNotNull(maps);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册