SbloodyS commented on code in PR #10832:
URL: https://github.com/apache/dolphinscheduler/pull/10832#discussion_r923133172
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java:
##########
@@ -541,13 +551,34 @@ private int queryPermission(User user, Project project) {
* @return project list
*/
@Override
- public Map<String, Object> queryAllProjectList(User user) {
- Map<String, Object> result = new HashMap<>();
+ public Result queryAllProjectList(User user) {
+ Result result = new Result();
List<Project> projects =
projectMapper.queryAllProject(user.getUserType() == UserType.ADMIN_USER ? 0 :
user.getId());
- result.put(Constants.DATA_LIST, projects);
+ result.setData(projects);
putMsg(result, Status.SUCCESS);
return result;
}
+ /**
+ * check project and authorization
+ *
+ * @param result result
+ * @param loginUser login user
+ * @param project project
+ * @param projectCode project code
+ * @return true if the login user have permission to see the project
+ */
+ @Override
+ public void checkProjectAndAuth(Result result, User loginUser, Project
project, long projectCode, String perm) {
Review Comment:
Would it be better to use full names instead of abbreviations?
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java:
##########
@@ -541,13 +551,34 @@ private int queryPermission(User user, Project project) {
* @return project list
*/
@Override
- public Map<String, Object> queryAllProjectList(User user) {
- Map<String, Object> result = new HashMap<>();
+ public Result queryAllProjectList(User user) {
+ Result result = new Result();
List<Project> projects =
projectMapper.queryAllProject(user.getUserType() == UserType.ADMIN_USER ? 0 :
user.getId());
- result.put(Constants.DATA_LIST, projects);
+ result.setData(projects);
putMsg(result, Status.SUCCESS);
return result;
}
+ /**
+ * check project and authorization
+ *
+ * @param result result
+ * @param loginUser login user
+ * @param project project
+ * @param projectCode project code
+ * @return true if the login user have permission to see the project
+ */
+ @Override
+ public void checkProjectAndAuth(Result result, User loginUser, Project
project, long projectCode, String perm) {
+ if (project == null) {
+ putMsg(result, Status.PROJECT_NOT_EXIST);
+ } else if (!canOperatorPermissions(loginUser, new
Object[]{project.getId()},AuthorizationType.PROJECTS,perm)) {
Review Comment:
Please format this line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]