weizhouapache commented on a change in pull request #6032:
URL: https://github.com/apache/cloudstack/pull/6032#discussion_r812830350
##########
File path:
engine/schema/src/main/java/org/apache/cloudstack/acl/dao/ProjectRoleDaoImpl.java
##########
@@ -17,45 +17,51 @@
package org.apache.cloudstack.acl.dao;
-import java.util.List;
-
-import org.apache.cloudstack.acl.ProjectRoleVO;
-
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
+import org.apache.cloudstack.acl.ProjectRoleVO;
import org.apache.commons.lang3.StringUtils;
+import java.util.List;
+
public class ProjectRoleDaoImpl extends GenericDaoBase<ProjectRoleVO, Long>
implements ProjectRoleDao{
private final SearchBuilder<ProjectRoleVO> ProjectRoleSearch;
public ProjectRoleDaoImpl() {
super();
ProjectRoleSearch = createSearchBuilder();
- ProjectRoleSearch.and("name", ProjectRoleSearch.entity().getName(),
SearchCriteria.Op.LIKE);
+ ProjectRoleSearch.and("name", ProjectRoleSearch.entity().getName(),
SearchCriteria.Op.EQ);
ProjectRoleSearch.and("project_id",
ProjectRoleSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
+ ProjectRoleSearch.and("keyword", ProjectRoleSearch.entity().getName(),
SearchCriteria.Op.LIKE);
ProjectRoleSearch.done();
}
@Override
public List<ProjectRoleVO> findByName(String name, Long projectId) {
SearchCriteria<ProjectRoleVO> sc = ProjectRoleSearch.create();
if (StringUtils.isNotEmpty(name)) {
- sc.setParameters("name", "%" + name + "%");
+ sc.setParameters("name", name);
}
if (projectId != null) {
sc.setParameters("project_id", projectId);
}
+
return listBy(sc);
}
@Override
- public List<ProjectRoleVO> findAllRoles(Long projectId) {
+ public List<ProjectRoleVO> findAllRoles(Long projectId, String keyword) {
SearchCriteria<ProjectRoleVO> sc = ProjectRoleSearch.create();
if (projectId != null) {
sc.setParameters("project_id", projectId);
}
+ if (StringUtils.isNotEmpty(keyword)) {
+ SearchCriteria<ProjectRoleVO> ssc = createSearchCriteria();
Review comment:
@Pearl1594
why not use
```
sc.setParameters("keyword", keyword);
```
--
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]