refactor(工作台): 获取权限项目逻辑优化以及保存空布局

This commit is contained in:
guoyuqi 2024-11-19 11:45:35 +08:00 committed by Craftsman
parent 005458be62
commit 71d0091a83
3 changed files with 7 additions and 34 deletions

View File

@ -331,8 +331,12 @@ public class DashboardService {
UserLayout userLayout = new UserLayout();
userLayout.setUserId(userId);
userLayout.setOrgId(organizationId);
if (CollectionUtils.isEmpty(saveList)) {
userLayout.setConfiguration(new byte[0]);
} else {
String configuration = JSON.toJSONString(saveList);
userLayout.setConfiguration(configuration.getBytes());
}
if (CollectionUtils.isEmpty(userLayouts)) {
userLayout.setId(IDGenerator.nextStr());
userLayoutMapper.insert(userLayout);
@ -347,7 +351,7 @@ public class DashboardService {
UserLayoutExample userLayoutExample = new UserLayoutExample();
userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId);
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)) {
return new ArrayList<>();
}

View File

@ -34,14 +34,6 @@ public interface ExtProjectMapper {
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);
}

View File

@ -132,27 +132,4 @@
</foreach>
</if>
</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>