lasdf1234 commented on code in PR #11140:
URL: https://github.com/apache/gravitino/pull/11140#discussion_r3265752176


##########
plugins/idp-basic/src/main/java/org/apache/gravitino/idp/storage/mapper/provider/base/IdpGroupUserRelBaseSQLProvider.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.gravitino.idp.storage.mapper.provider.base;
+
+import java.util.List;
+import org.apache.gravitino.idp.storage.mapper.IdpGroupMetaMapper;
+import org.apache.gravitino.idp.storage.mapper.IdpGroupUserRelMapper;
+import org.apache.gravitino.idp.storage.mapper.IdpUserMetaMapper;
+import org.apache.gravitino.idp.storage.po.IdpGroupUserRelPO;
+import org.apache.ibatis.annotations.Param;
+
+public class IdpGroupUserRelBaseSQLProvider {
+
+  public String selectGroupNamesByUserId(@Param("userId") Long userId) {
+    return "SELECT g.group_name"
+        + " FROM "
+        + IdpGroupUserRelMapper.IDP_GROUP_USER_REL_TABLE_NAME
+        + " r JOIN "
+        + IdpGroupMetaMapper.IDP_GROUP_TABLE_NAME
+        + " g ON g.group_id = r.group_id"
+        + " WHERE r.user_id = #{userId}"
+        + " AND r.deleted_at = 0"
+        + " AND g.deleted_at = 0"
+        + " ORDER BY g.group_name";
+  }
+
+  public String selectUserNamesByGroupId(@Param("groupId") Long groupId) {
+    return "SELECT u.user_name"
+        + " FROM "
+        + IdpGroupUserRelMapper.IDP_GROUP_USER_REL_TABLE_NAME
+        + " r JOIN "
+        + IdpUserMetaMapper.IDP_USER_TABLE_NAME
+        + " u ON u.user_id = r.user_id"
+        + " WHERE r.group_id = #{groupId}"
+        + " AND r.deleted_at = 0"
+        + " AND u.deleted_at = 0"
+        + " ORDER BY u.user_name";
+  }
+
+  public String selectRelatedUserIds(
+      @Param("groupId") Long groupId, @Param("userIds") List<Long> userIds) {
+    return "<script>"
+        + "SELECT user_id"
+        + " FROM "
+        + IdpGroupUserRelMapper.IDP_GROUP_USER_REL_TABLE_NAME
+        + " WHERE group_id = #{groupId} AND deleted_at = 0 "
+        + "<foreach collection='userIds' item='userId'"
+        + " open='AND user_id IN (' separator=',' close=')'>"
+        + "#{userId}"
+        + "</foreach>"
+        + "</script>";
+  }
+
+  public String batchInsertIdpGroupUsers(@Param("relations") 
List<IdpGroupUserRelPO> relations) {
+    return "<script>"
+        + "INSERT INTO "
+        + IdpGroupUserRelMapper.IDP_GROUP_USER_REL_TABLE_NAME
+        + " (id, group_id, user_id, current_version, last_version, deleted_at)"
+        + " VALUES "
+        + "<foreach item='item' collection='relations' separator=','>"
+        + "(#{item.id}, #{item.groupId}, #{item.userId}, 
#{item.currentVersion},"
+        + " #{item.lastVersion}, #{item.deletedAt})"
+        + "</foreach>"
+        + "</script>";
+  }
+
+  public String softDeleteIdpGroupUsers(

Review Comment:
   Got .The method name has been modified. All the input parameters of 'Id' 
have been changed to 'name' parameters.



-- 
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]

Reply via email to