ouyangyewei commented on a change in pull request #7111:
URL: https://github.com/apache/dolphinscheduler/pull/7111#discussion_r761140561
##########
File path:
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
##########
@@ -590,6 +590,60 @@ public Result queryUserList(User loginUser, String
searchVal, Integer pageNo, In
return result;
}
+ /**
+ * grant project by code
+ *
+ * @param loginUser login user
+ * @param userId user id
+ * @param projectCodes project code array
+ * @return grant result code
+ */
+ @Override
+ @Transactional(rollbackFor = RuntimeException.class)
+ public Map<String, Object> grantProjectByCode(final User loginUser, final
int userId, final String projectCodes) {
+ Map<String, Object> result = new HashMap<>();
+ result.put(Constants.STATUS, false);
+
+ // 1. only admin can operate
+ if (this.check(result, !this.isAdmin(loginUser),
Status.USER_NO_OPERATION_PERM)) {
+ return result;
+ }
+
+ // 2. check if user is existed
+ User tempUser = this.userMapper.selectById(userId);
+ if (tempUser == null) {
+ putMsg(result, Status.USER_NOT_EXIST, userId);
+ return result;
+ }
+
+ // 3. if the selected projectCodes are empty, delete all items
associated with the user
+ if (this.check(result, StringUtils.isEmpty(projectCodes),
Status.SUCCESS)) {
+ this.projectUserMapper.deleteProjectRelation(0, userId);
+ return result;
+ }
+
+ // 4. maintain the relationship between project and user
+ String[] projectCodeArr = projectCodes.split(",");
+ for (String projectCode : projectCodeArr) {
Review comment:
change to `for (String projectCode : projectCodes.split(","))`
--
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]