ruanwenjun commented on code in PR #15219:
URL: 
https://github.com/apache/dolphinscheduler/pull/15219#discussion_r1404706787


##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/SessionDaoImpl.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.dolphinscheduler.dao.repository.impl;
+
+import org.apache.dolphinscheduler.dao.entity.Session;
+import org.apache.dolphinscheduler.dao.mapper.SessionMapper;
+import org.apache.dolphinscheduler.dao.repository.BaseDao;
+import org.apache.dolphinscheduler.dao.repository.SessionDao;
+
+import java.util.List;
+
+import lombok.NonNull;
+
+import org.springframework.stereotype.Repository;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+
+@Repository
+public class SessionDaoImpl extends BaseDao<Session, SessionMapper> implements 
SessionDao {
+
+    public SessionDaoImpl(@NonNull SessionMapper sessionMapper) {
+        super(sessionMapper);
+    }
+
+    public void deleteByUserId(Integer userId) {
+        mybatisMapper.delete(new 
QueryWrapper<>(Session.builder().userId(userId).build()));
+    }
+
+    @Override
+    public List<Session> queryByUserId(Integer userId) {
+        return mybatisMapper.selectList(new 
QueryWrapper<>(Session.builder().userId(userId).build()));

Review Comment:
   Agree with you, we shouldn't expose wrapper to service. I change this method 
to 
   ```
   /**
    * Query the entity by condition.
    */
   List<Entity> queryByCondition(Entity queryCondition);
   ```
   And add implementation in BaseDao
   ```
   @Override
   public List<ENTITY> queryByCondition(ENTITY queryCondition) {
       if (queryCondition == null) {
           throw new IllegalArgumentException("queryCondition can not be null");
       }
       return mybatisMapper.selectList(new QueryWrapper<>(queryCondition));
   }
   ```
   
   Then we can avoid using wrapper in` dao`, then we can use this method for 
simple query, and remove a lot of method like `queryByCode`, `queryByName`, 
`queryByXX`, for this kind of query we can directly use 
dao.queryByCondition(entity).



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