Browse Source

[Fix-10595][api] Fix Dependent Node Only View Projects Created By Self (#10834)

* [Fix-10595][api] Fix Dependent Node Only View Projects Created By Self
3.0.0/version-upgrade
Assert 2 years ago committed by caishunfeng
parent
commit
85e5031786
  1. 10
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml
  2. 30
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java

10
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProjectMapper.xml

@ -162,11 +162,13 @@
<select id="queryAllProject" resultType="org.apache.dolphinscheduler.dao.entity.Project"> <select id="queryAllProject" resultType="org.apache.dolphinscheduler.dao.entity.Project">
select select
<include refid="baseSql"/> <include refid="baseSqlV2">
from t_ds_project <property name="alias" value="p"/>
where 1=1 </include>
from t_ds_project p
<if test="userId != 0"> <if test="userId != 0">
and user_id = #{userId} right join t_ds_relation_project_user rpu on p.id = rpu.project_id
where rpu.user_id = #{userId}
</if> </if>
</select> </select>
</mapper> </mapper>

30
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProjectMapperTest.java

@ -19,6 +19,7 @@ package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.BaseDaoTest; import org.apache.dolphinscheduler.dao.BaseDaoTest;
import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectUser;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date; import java.util.Date;
@ -39,6 +40,9 @@ public class ProjectMapperTest extends BaseDaoTest {
@Autowired @Autowired
private UserMapper userMapper; private UserMapper userMapper;
@Autowired
private ProjectUserMapper projectUserMapper;
/** /**
* insert * insert
* *
@ -168,7 +172,7 @@ public class ProjectMapperTest extends BaseDaoTest {
} }
/** /**
* test query authed prject list by userId * test query authed project list by userId
*/ */
@Test @Test
public void testQueryAuthedProjectListByUserId() { public void testQueryAuthedProjectListByUserId() {
@ -187,9 +191,31 @@ public class ProjectMapperTest extends BaseDaoTest {
Project project = insertOne(); Project project = insertOne();
List<Project> projects = projectMapper.queryProjectExceptUserId( List<Project> projects = projectMapper.queryProjectExceptUserId(
100000 100000
); );
Assert.assertNotEquals(projects.size(), 0); Assert.assertNotEquals(projects.size(), 0);
} }
@Test
public void testQueryAllProject() {
User user = new User();
user.setUserName("ut user");
userMapper.insert(user);
Project project = insertOne();
project.setUserId(user.getId());
projectMapper.updateById(project);
ProjectUser projectUser = new ProjectUser();
projectUser.setProjectId(project.getId());
projectUser.setUserId(user.getId());
projectUser.setCreateTime(new Date());
projectUser.setUpdateTime(new Date());
projectUserMapper.insert(projectUser);
List<Project> allProject = projectMapper.queryAllProject(user.getId());
Assert.assertNotEquals(allProject.size(), 0);
}
} }
Loading…
Cancel
Save