You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@streampark.apache.org by GitBox <gi...@apache.org> on 2022/10/07 02:08:53 UTC

[GitHub] [incubator-streampark] wolfboys commented on a diff in pull request #1733: [Feature] Support the team management

wolfboys commented on code in PR #1733:
URL: https://github.com/apache/incubator-streampark/pull/1733#discussion_r989623750


##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/system/service/impl/TeamMemberServiceImpl.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.streampark.console.system.service.impl;
+
+import org.apache.streampark.common.util.AssertUtils;
+import org.apache.streampark.console.base.domain.RestRequest;
+import org.apache.streampark.console.system.entity.Team;
+import org.apache.streampark.console.system.entity.TeamMember;
+import org.apache.streampark.console.system.entity.User;
+import org.apache.streampark.console.system.mapper.TeamMemberMapper;
+import org.apache.streampark.console.system.service.RoleService;
+import org.apache.streampark.console.system.service.TeamMemberService;
+import org.apache.streampark.console.system.service.TeamService;
+import org.apache.streampark.console.system.service.UserService;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+@Service
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
+public class TeamMemberServiceImpl extends ServiceImpl<TeamMemberMapper, TeamMember>
+    implements TeamMemberService {
+
+    @Autowired
+    private UserService userService;
+
+    @Autowired
+    private RoleService roleService;
+
+    @Autowired
+    private TeamService teamService;
+
+    @Override
+    @Transactional
+    public void deleteUserRolesByRoleId(String[] roleIds) {
+        Arrays.stream(roleIds).forEach(id -> baseMapper.deleteByRoleId(Long.valueOf(id)));
+    }
+
+    @Override
+    @Transactional
+    public void deleteUserRolesByUserId(String[] userIds) {
+        Arrays.stream(userIds).forEach(id -> baseMapper.deleteByUserId(Long.valueOf(id)));
+    }
+
+    @Override
+    public IPage<TeamMember> findUsers(TeamMember teamMember, RestRequest request) {
+        AssertUtils.isTrue(teamMember.getTeamId() != null, "The team id is required.");

Review Comment:
   If admin login for the first time and no team selected (no team selected in the front-end), now visit the team-member UI will cause exception. However, this issue can be improved in the next pr.
   
   



-- 
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: issues-unsubscribe@streampark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org