refactor(工作台): 获取权限项目逻辑优化以及保存空布局
This commit is contained in:
parent
005458be62
commit
71d0091a83
|
@ -331,8 +331,12 @@ public class DashboardService {
|
||||||
UserLayout userLayout = new UserLayout();
|
UserLayout userLayout = new UserLayout();
|
||||||
userLayout.setUserId(userId);
|
userLayout.setUserId(userId);
|
||||||
userLayout.setOrgId(organizationId);
|
userLayout.setOrgId(organizationId);
|
||||||
|
if (CollectionUtils.isEmpty(saveList)) {
|
||||||
|
userLayout.setConfiguration(new byte[0]);
|
||||||
|
} else {
|
||||||
String configuration = JSON.toJSONString(saveList);
|
String configuration = JSON.toJSONString(saveList);
|
||||||
userLayout.setConfiguration(configuration.getBytes());
|
userLayout.setConfiguration(configuration.getBytes());
|
||||||
|
}
|
||||||
if (CollectionUtils.isEmpty(userLayouts)) {
|
if (CollectionUtils.isEmpty(userLayouts)) {
|
||||||
userLayout.setId(IDGenerator.nextStr());
|
userLayout.setId(IDGenerator.nextStr());
|
||||||
userLayoutMapper.insert(userLayout);
|
userLayoutMapper.insert(userLayout);
|
||||||
|
@ -347,7 +351,7 @@ public class DashboardService {
|
||||||
UserLayoutExample userLayoutExample = new UserLayoutExample();
|
UserLayoutExample userLayoutExample = new UserLayoutExample();
|
||||||
userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId);
|
userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId);
|
||||||
List<UserLayout> userLayouts = userLayoutMapper.selectByExampleWithBLOBs(userLayoutExample);
|
List<UserLayout> userLayouts = userLayoutMapper.selectByExampleWithBLOBs(userLayoutExample);
|
||||||
List<Project> allPermissionProjects = extProjectMapper.getUserProjectIdName(organizationId, null, userId);
|
List<Project>allPermissionProjects = extProjectMapper.getProjectNameModule(organizationId, null);
|
||||||
if (CollectionUtils.isEmpty(allPermissionProjects)) {
|
if (CollectionUtils.isEmpty(allPermissionProjects)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,6 @@ public interface ExtProjectMapper {
|
||||||
|
|
||||||
List<Project> getProjectNameModule(@Param("organizationId") String organizationId, @Param("ids") List<String>projectIds);
|
List<Project> getProjectNameModule(@Param("organizationId") String organizationId, @Param("ids") List<String>projectIds);
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户在所选项目中仍然有任意权限的项目
|
|
||||||
* @param organizationId 组织id
|
|
||||||
* @param projectIds 所选项目ids
|
|
||||||
* @param userId 用户
|
|
||||||
* @return List<Project>
|
|
||||||
*/
|
|
||||||
List<Project> getUserProjectIdName(@Param("organizationId") String organizationId, @Param("ids") List<String>projectIds, @Param("userId") String userId);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,27 +132,4 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUserProjectIdName" resultType="io.metersphere.project.domain.Project">
|
|
||||||
SELECT DISTINCT p.id, p.name, p.module_setting
|
|
||||||
FROM user_role u
|
|
||||||
JOIN user_role_relation urr ON u.id = urr.role_id
|
|
||||||
JOIN project p ON p.id = urr.source_id
|
|
||||||
JOIN user on urr.user_id = user.id
|
|
||||||
where urr.user_id = #{userId} and u.type = 'PROJECT'
|
|
||||||
<if test="organizationId != null and organizationId != ''">
|
|
||||||
and
|
|
||||||
p.organization_id = #{organizationId}
|
|
||||||
</if>
|
|
||||||
<if test="ids != null and ids.size() > 0">
|
|
||||||
and p.id in
|
|
||||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
|
||||||
#{id}
|
|
||||||
</foreach>
|
|
||||||
</if>
|
|
||||||
and p.enable = 1 and user.deleted = 0
|
|
||||||
order by
|
|
||||||
CONVERT( p.name USING GBK) ASC
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue