refactor(系统设置): 优化系统管理员登陆逻辑
This commit is contained in:
parent
6f271c0dd8
commit
e9009168dd
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.CommentUserInfo;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
|
@ -41,8 +42,15 @@ public interface BaseUserMapper {
|
|||
|
||||
/**
|
||||
* 获取评论用户信息
|
||||
*
|
||||
* @param ids 用户ID集合
|
||||
* @return 评论用户信息集合
|
||||
*/
|
||||
List<CommentUserInfo> getCommentUserInfoByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 获取开启的项目和组织
|
||||
*/
|
||||
Project getEnableProjectAndOrganization();
|
||||
|
||||
}
|
||||
|
|
|
@ -132,4 +132,11 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getEnableProjectAndOrganization" resultType="io.metersphere.project.domain.Project">
|
||||
SELECT p.*
|
||||
FROM project p
|
||||
LEFT JOIN organization o ON p.organization_id = o.id
|
||||
WHERE p.enable = 1
|
||||
AND o.enable = 1 limit 1
|
||||
</select>
|
||||
</mapper>
|
|
@ -237,35 +237,27 @@ public class UserLoginService {
|
|||
organizationExample.createCriteria().andIdEqualTo(user.getLastOrganizationId()).andEnableEqualTo(true);
|
||||
List<Organization> organizations = organizationMapper.selectByExample(organizationExample);
|
||||
if (CollectionUtils.isNotEmpty(organizations)) {
|
||||
Organization organization = organizations.get(0);
|
||||
Organization organization = organizations.getFirst();
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(organization.getId()).andEnableEqualTo(true);
|
||||
List<Project> projectList = projectMapper.selectByExample(projectExample);
|
||||
if (CollectionUtils.isNotEmpty(projectList)) {
|
||||
Project project = projectList.get(0);
|
||||
Project project = projectList.getFirst();
|
||||
user.setLastProjectId(project.getId());
|
||||
updateUser(user);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//项目和组织都没有权限
|
||||
OrganizationExample organizationExample = new OrganizationExample();
|
||||
organizationExample.createCriteria().andEnableEqualTo(true);
|
||||
List<Organization> organizations = organizationMapper.selectByExample(organizationExample);
|
||||
if (CollectionUtils.isNotEmpty(organizations)) {
|
||||
Organization organization = organizations.get(0);
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(organization.getId()).andEnableEqualTo(true);
|
||||
List<Project> projectList = projectMapper.selectByExample(projectExample);
|
||||
if (CollectionUtils.isNotEmpty(projectList)) {
|
||||
Project project = projectList.get(0);
|
||||
user.setLastProjectId(project.getId());
|
||||
user.setLastOrganizationId(organization.getId());
|
||||
updateUser(user);
|
||||
return true;
|
||||
}
|
||||
Project project = baseUserMapper.getEnableProjectAndOrganization();
|
||||
if (project != null) {
|
||||
user.setLastProjectId(project.getId());
|
||||
user.setLastOrganizationId(project.getOrganizationId());
|
||||
updateUser(user);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue