Browse Source

Increase the judgment of whether it is admin (#1136)

* rename from DatasourceUserMapper to DataSourceUserMapper

* add unit test in UserMapper and WorkerGroupMapper

* change cn.escheduler to org.apache.dolphinscheduler

* add unit test in UdfFuncMapperTest

* add unit test in UdfFuncMapperTest

* remove DatabaseConfiguration

* add ConnectionFactoryTest

* cal duration in processInstancesList

* change desc to description

* change table name in mysql ddl

* change table name in mysql ddl

* change escheduler to dolphinscheduler

* change escheduler to dolphinscheduler

* change escheduler to dolphinscheduler

* remove log4j-1.2-api and modify AlertMapperTest

* remove log4j-1.2-api

* Add alertDao to spring management

* Add alertDao to spring management

* get SqlSessionFactory from MybatisSqlSessionFactoryBean

* get processDao by DaoFactory

* read druid properties in ConneciontFactory

* read druid properties in ConneciontFactory

* change get alertDao by spring to DaoFactory

* add log4j to resolve #967

* resole verify udf name error and delete udf error

* Determine if principal is empty

* Determine whether the logon user has the right to delete the project

* Fixed an issue that produced attatch file named such as ATT00002.bin

* fix too many connection in upgrade or create

* fix NEED_FAULT_TOLERANCE and WAITTING_THREAD count fail

* Added a judgment on whether the currently login user is an administrator

* fix update udf database not change and create time is changed

* add enterprise.wechat.enable to decide whether to send enterprise WeChat

* change method check

* Remove the administrator's judgment on query access token list

* only admin can create worker group

* delete alert group need delete the relation of user and alert group

* add timeout in proxy when upload large resource

* add gets scheduled times by expect fire times

* add gets scheduled times by expect fire times

* Increase the judgment of whether it is admin

* Increase the judgment of whether it is admin
pull/2/head
lgcareer 5 years ago committed by qiaozhanwei
parent
commit
aa575d84d6
  1. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java
  2. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java
  3. 6
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java
  4. 10
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
  5. 5
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java

@ -179,7 +179,7 @@ public class DataAnalysisService extends BaseService{
Integer[] projectIdArray = getProjectIdsArrays(loginUser, projectId);
List<DefinitionGroupByUser> defineGroupByUsers = processDefinitionMapper.countDefinitionGroupByUser(
loginUser.getId(), projectIdArray);
loginUser.getId(), projectIdArray,isAdmin(loginUser));
DefineUserDto dto = new DefineUserDto(defineGroupByUsers);
result.put(Constants.DATA_LIST, dto);

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java

@ -210,7 +210,7 @@ public class ProcessDefinitionService extends BaseDAGService {
Page<ProcessDefinition> page = new Page(pageNo, pageSize);
IPage<ProcessDefinition> processDefinitionIPage = processDefineMapper.queryDefineListPaging(
page, searchVal, userId, project.getId());
page, searchVal, userId, project.getId(),isAdmin(loginUser));
PageInfo pageInfo = new PageInfo<ProcessData>(pageNo, pageSize);
pageInfo.setTotalCount((int)processDefinitionIPage.getTotal());

6
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.java

@ -35,7 +35,8 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
IPage<ProcessDefinition> queryDefineListPaging(IPage<ProcessDefinition> page,
@Param("searchVal") String searchVal,
@Param("userId") int userId,
@Param("projectId") int projectId);
@Param("projectId") int projectId,
@Param("isAdmin") boolean isAdmin);
List<ProcessDefinition> queryAllDefinitionList(@Param("projectId") int projectId);
@ -45,5 +46,6 @@ public interface ProcessDefinitionMapper extends BaseMapper<ProcessDefinition> {
List<DefinitionGroupByUser> countDefinitionGroupByUser(
@Param("userId") Integer userId,
@Param("projectIds") Integer[] projectIds);
@Param("projectIds") Integer[] projectIds,
@Param("isAdmin") boolean isAdmin);
}

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

@ -12,10 +12,14 @@
and pd.name = #{processDefinitionName}
</select>
<select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
SELECT td.*,sc.schedule_release_state
SELECT td.*,sc.schedule_release_state,tu.user_name
FROM t_ds_process_definition td
left join (select process_definition_id,release_state as schedule_release_state from t_ds_schedules group by process_definition_id,release_state) sc on sc.process_definition_id = td.id
left join t_ds_user tu on td.user_id = tu.id
where td.project_id = #{projectId}
<if test=" isAdmin == false ">
and tu.user_type=1
</if>
<if test=" searchVal != null and searchVal != ''">
and td.name like concat('%', #{searchVal}, '%')
</if>
@ -24,6 +28,7 @@
</if>
order by sc.schedule_release_state desc,td.update_time desc
</select>
<select id="queryAllDefinitionList" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
select *
from t_ds_process_definition
@ -48,6 +53,9 @@
FROM t_ds_process_definition td
JOIN t_ds_user tu on tu.id=td.user_id
where 1 = 1
<if test=" isAdmin == false ">
and tu.user_type=1
</if>
<if test="projectIds != null and projectIds.length != 0">
and td.project_id in
<foreach collection="projectIds" index="index" item="i" open="(" separator="," close=")">

5
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java

@ -138,7 +138,7 @@ public class ProcessDefinitionMapperTest {
public void testQueryDefineListPaging() {
ProcessDefinition processDefinition = insertOne();
Page<ProcessDefinition> page = new Page(1,3);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(page, "def", 101, 1010);
IPage<ProcessDefinition> processDefinitionIPage = processDefinitionMapper.queryDefineListPaging(page, "def", 101, 1010,true);
Assert.assertNotEquals(processDefinitionIPage.getTotal(), 0);
processDefinitionMapper.deleteById(processDefinition.getId());
}
@ -189,7 +189,8 @@ public class ProcessDefinitionMapperTest {
projectIds[0] = processDefinition.getProjectId();
List<DefinitionGroupByUser> processDefinitions = processDefinitionMapper.countDefinitionGroupByUser(
processDefinition.getUserId(),
projectIds
projectIds,
user.getUserType() == UserType.ADMIN_USER
);
processDefinitionMapper.deleteById(processDefinition.getId());
Assert.assertNotEquals(processDefinitions.size(), 0);

Loading…
Cancel
Save