List of usage examples for org.hibernate.criterion DetachedCriteria createAlias
public DetachedCriteria createAlias(String associationPath, String alias)
From source file:com.sccl.attech.modules.sys.service.LogService.java
License:Open Source License
/** * ?//w ww. j av a 2s .co m * @param paramMap * @return */ public List<Log> getList(Map<String, Object> paramMap) { DetachedCriteria dc = logDao.createDetachedCriteria(); Long createById = StringUtils.toLong(paramMap.get("createById")); if (createById > 0) { dc.add(Restrictions.eq("createBy.id", createById)); } String manageName = ObjectUtils.toString(paramMap.get("manageName")); if (StringUtils.isNotBlank(manageName)) { dc.createAlias("createBy", "createBy"); dc.add(Restrictions.like("createBy.name", EncodedUtil.decodeValue(manageName))); } String requestUri = ObjectUtils.toString(paramMap.get("requestUri")); if (StringUtils.isNotBlank(requestUri)) { dc.add(Restrictions.like("requestUri", "%" + requestUri + "%")); } String exception = ObjectUtils.toString(paramMap.get("exception")); if (StringUtils.isNotBlank(exception)) { dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION)); } Date beginDate = DateUtils.parseDate(paramMap.get("start")); if (beginDate == null) { beginDate = DateUtils.setDays(new Date(), 1); paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd")); } Date endDate = DateUtils.parseDate(paramMap.get("end")); if (endDate == null) { endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1); paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd")); } dc.add(Restrictions.between("createDate", beginDate, endDate)); dc.addOrder(Order.desc("createDate")); return logDao.find(dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ??//from ww w . j a v a 2 s .c o m * @param user * @return */ public List<User> findAllUserConditon(User user) { DetachedCriteria dc = userDao.createDetachedCriteria(); dc.add(Restrictions.eq("userType", "2")); User currentUser = UserUtils.getUser(); dc.createAlias("office", "office"); dc.add(dataScopeFilter(currentUser, "office", "createBy")); dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL)); return userDao.find(dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ??/* w ww . j ava 2 s .co m*/ * @param user * @return */ public List<User> findAllUserConditonAll(User user) { DetachedCriteria dc = userDao.createDetachedCriteria(); //dc.add(Restrictions.eq("userType", "2")); User currentUser = UserUtils.getUser(); dc.createAlias("office", "office"); dc.add(dataScopeFilter(currentUser, "office", "createBy")); dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL)); return userDao.find(dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ?// w w w . ja v a 2 s . com * @return * / /** * ?? * @return */ public List<User> getListByCompany() { User user = UserUtils.getUser(); DetachedCriteria dc = userDao.createDetachedCriteria(); dc.createAlias("company", "company"); if (user.getCompany() != null && StringUtils.isNotBlank(user.getCompany().getId())) { dc.add(Restrictions.eq("company.id", user.getCompany().getId())); } dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL)); return userDao.find(dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ?/* w w w . j a v a 2s .c om*/ * @param user * @return */ public List<User> getList(User user) { User currentUser = UserUtils.getUser(); DetachedCriteria dc = userDao.createDetachedCriteria(); dc.createAlias("company", "company"); if (user.getCompany() != null && StringUtils.isNotBlank(user.getCompany().getId())) { dc.add(Restrictions.or(Restrictions.eq("company.id", user.getCompany().getId()), Restrictions.like("company.parentIds", "%," + user.getCompany().getId() + ",%"))); } dc.createAlias("office", "office"); if (user.getOffice() != null && StringUtils.isNotBlank(user.getOffice().getId())) { dc.add(Restrictions.or(Restrictions.eq("office.id", user.getOffice().getId()), Restrictions.like("office.parentIds", "%," + user.getOffice().getId() + ",%"))); } // ???? if (!currentUser.isAdmin()) { dc.add(Restrictions.ne("id", "1")); } if (user.getUserType() != null && !"".equals(user.getUserType())) { dc.add(Restrictions.eq("userType", user.getUserType())); } dc.add(dataScopeFilter(currentUser, "office", "")); if (StringUtils.isNotEmpty(user.getLoginName())) { dc.add(Restrictions.like("loginName", "%" + user.getLoginName() + "%")); } if (StringUtils.isNotEmpty(user.getName())) { String userName = EncodedUtil.decodeValue(user.getName()); dc.add(Restrictions.like("name", "%" + userName + "%")); } if (StringUtils.isNotEmpty(user.getUserType())) { dc.add(Restrictions.eq("userType", user.getUserType())); } dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL)); return userDao.find(dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ??//from ww w . ja va 2 s.c o m * @param companyId * @param offerId * @return */ public List<Role> findByOrangAllRole(String companyId, String offerId) { List<Role> list = null; User user = UserUtils.getUser(); DetachedCriteria dc = roleDao.createDetachedCriteria(); dc.createAlias("office", "office"); dc.add(Restrictions.like("office.parentIds", "%" + companyId + "%")); dc.add(Restrictions.eq(Role.FIELD_DEL_FLAG, Role.DEL_FLAG_NORMAL)); // dc.addOrder(Order.asc("office.code")).addOrder(Order.asc("name")); list = roleDao.find(dc); return list; }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * /*from w ww. j av a 2 s. c o m*/ * @param page * @param area * @return */ public Page<Role> findRole(Page<Role> page, Role role) { User user = UserUtils.getUser(); DetachedCriteria dc = roleDao.createDetachedCriteria(); if (StringUtils.isNotEmpty(role.getName())) { dc.add(Restrictions.like("name", "%" + role.getName() + "%")); } dc.createAlias("office", "office"); // dc.createAlias("userList","userList"); // dc.createAlias("userList", "userList", JoinType.LEFT_OUTER_JOIN); // dc.add(dataScopeFilter(user, "office", "userList")); if (role.getOffice() != null) { dc.add(Restrictions.eq("office.id", role.getOffice().getId())); } dc.add(dataScopeFilter(user, "office", "createBy")); //dc.createAlias("createBy","createBy"); //dc.add(Restrictions.eq("createBy.id",UserUtils.getUser().getId())); dc.add(Restrictions.eq(Role.FIELD_DEL_FLAG, Role.DEL_FLAG_NORMAL)); return roleDao.find(page, dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ?/*from w w w. j av a 2 s. c o m*/ * @param role * @return */ public List<Role> getRoleList(Role role) { DetachedCriteria dc = roleDao.createDetachedCriteria(); if (StringUtils.isNotEmpty(role.getName())) { dc.add(Restrictions.like("name", "%" + role.getName() + "%")); } dc.createAlias("office", "office"); if (role.getOffice() != null) { dc.add(Restrictions.eq("office.id", role.getOffice().getId())); } dc.createAlias("createBy", "createBy"); dc.add(Restrictions.eq("createBy.id", UserUtils.getUser().getId())); dc.add(Restrictions.eq(Role.FIELD_DEL_FLAG, Role.DEL_FLAG_NORMAL)); return roleDao.find(dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ?id??//from www . ja v a 2 s . c o m * @param page * @param searchName * @param officeId * @return */ public Page<User> findByOffice(Page<User> page, String searchName, String officeId) { DetachedCriteria dc = userDao.createDetachedCriteria(); dc.createAlias("office", "office"); if (StringUtils.isNotBlank(officeId)) { dc.add(Restrictions.eq("office.id", officeId)); } if (StringUtils.isNotBlank(searchName)) { dc.add(Restrictions.or(Restrictions.like("name", "%" + searchName + "%"), Restrictions.like("mobile", "%" + searchName + "%"))); } dc.add(Restrictions.ne("userType", "2"));// dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL)); return userDao.find(page, dc); }
From source file:com.sccl.attech.modules.sys.service.SystemService.java
License:Open Source License
/** * ?id?//from ww w . j a va2 s .c o m * @param page * @param searchName * @param officeId * @return */ public Page<User> findWorkOutByOffice(Page<User> page, String searchName, String officeId) { DetachedCriteria dc = userDao.createDetachedCriteria(); dc.createAlias("office", "office"); if (StringUtils.isNotBlank(officeId)) { dc.add(Restrictions.eq("office.id", officeId)); } if (StringUtils.isNotBlank(searchName)) { dc.add(Restrictions.or(Restrictions.like("name", "%" + searchName + "%"), Restrictions.like("mobile", "%" + searchName + "%"))); } dc.add(Restrictions.eq("userType", "2"));// dc.add(Restrictions.eq(User.FIELD_DEL_FLAG, User.DEL_FLAG_NORMAL)); return userDao.find(page, dc); }