|
|
@@ -9,7 +9,6 @@ import com.zhongshu.card.server.core.dao.org.extend.OrganizationUserDaoExtend;
|
|
|
import com.zhongshu.card.server.core.domain.org.Department;
|
|
|
import com.zhongshu.card.server.core.domain.org.OrganizationUser;
|
|
|
import com.zhongshu.card.server.core.domain.org.Role;
|
|
|
-import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -39,22 +38,38 @@ public class OrganizationUserDaoImpl extends BaseImpl implements OrganizationUse
|
|
|
private DBHelper dbHelper;
|
|
|
|
|
|
@Autowired
|
|
|
- RoleDao roleDao;
|
|
|
+ private RoleDao roleDao;
|
|
|
|
|
|
@Autowired
|
|
|
- DepartmentDao departmentDao;
|
|
|
+ private DepartmentDao departmentDao;
|
|
|
|
|
|
@Override
|
|
|
public Page<OrganizationUser> page(Pageable pageable, OrganizationUserSearch param) {
|
|
|
+ Criteria criteria = buildFilterCriteria(param);
|
|
|
+
|
|
|
+ Sort sort = buildSort(param);
|
|
|
+ Query query = Query.query(criteria);
|
|
|
+ query.with(sort);
|
|
|
+ return dbHelper.pages(query, pageable, OrganizationUser.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countUser(OrganizationUserSearch param) {
|
|
|
+ Criteria criteria = buildFilterCriteria(param);
|
|
|
+ Query query = Query.query(criteria);
|
|
|
+ return mongoTemplate.count(query, OrganizationUser.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria buildFilterCriteria(OrganizationUserSearch param) {
|
|
|
Criteria criteria = buildCriteriaNotOid(param);
|
|
|
|
|
|
// 用户ID
|
|
|
- if (ObjectUtils.isNotEmpty(param.getUserId())) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserId())) {
|
|
|
criteria.and("userId").is(param.getUserId());
|
|
|
}
|
|
|
|
|
|
// 机构ID
|
|
|
- if (ObjectUtils.isNotEmpty(param.getOid())) {
|
|
|
+ if (StringUtils.isNotEmpty(param.getOid())) {
|
|
|
criteria.and("oid").is(param.getOid());
|
|
|
}
|
|
|
|
|
|
@@ -88,16 +103,21 @@ public class OrganizationUserDaoImpl extends BaseImpl implements OrganizationUse
|
|
|
criteria.and("position.id").is(param.getPositionId());
|
|
|
}
|
|
|
|
|
|
+ // 性别
|
|
|
+ if (param.getSex() != null) {
|
|
|
+ criteria.and("sex").is(param.getSex());
|
|
|
+ }
|
|
|
+
|
|
|
// 角色
|
|
|
List<String> roleIds = param.getRoleIds();
|
|
|
- if (!CollectionUtils.isEmpty(roleIds)) {
|
|
|
+ if (ObjectUtils.isNotEmpty(roleIds)) {
|
|
|
List<Role> roles = roleDao.findByIdIn(roleIds);
|
|
|
criteria.and("roles").in(roles);
|
|
|
}
|
|
|
|
|
|
// 部门
|
|
|
List<String> departmentIds = param.getDepartmentIds();
|
|
|
- if (!CollectionUtils.isEmpty(departmentIds)) {
|
|
|
+ if (ObjectUtils.isNotEmpty(departmentIds)) {
|
|
|
List<Department> roles = departmentDao.findByIdIn(departmentIds);
|
|
|
criteria.and("departments").in(roles);
|
|
|
}
|
|
|
@@ -137,11 +157,7 @@ public class OrganizationUserDaoImpl extends BaseImpl implements OrganizationUse
|
|
|
Pattern pattern = Pattern.compile("^.*" + param.getKeyWord() + ".*$");
|
|
|
criteria.orOperator(Criteria.where("name").regex(pattern), Criteria.where("phone").regex(pattern), Criteria.where("code").regex(pattern));
|
|
|
}
|
|
|
-
|
|
|
- Sort sort = buildSort(param);
|
|
|
- Query query = Query.query(criteria);
|
|
|
- query.with(sort);
|
|
|
- return dbHelper.pages(query, pageable, OrganizationUser.class);
|
|
|
+ return criteria;
|
|
|
}
|
|
|
|
|
|
}
|