public WeekendCriteria<T, Object> createCriteriaAddOn() { WeekendCriteria<T, Object> weekendCriteria = new WeekendCriteria<>(this.propertyMap, this.exists, this.notNull); return weekendCriteria; }
public WeekendCriteria<A, B> andIsNull(Fn<A, B> fn) { this.andIsNull(Reflections.fnToFieldName(fn)); return this; }
default Optional<DictatorConfigProfile> findByCodeAndEnable(@NonNull String profileCode) { Weekend<DictatorConfigProfile> weekend = Weekend.of(DictatorConfigProfile.class); weekend.weekendCriteria() .andEqualTo(DictatorConfigProfile::getEnable,true) .andEqualTo(DictatorConfigProfile::getProfileCode, profileCode); return this.findOne(weekend); }
criteria.andLike(Log::getUsername, "%" + log.getUsername() + "%"); criteria.andLike(Log::getIp, "%" + log.getIp() + "%"); criteria.andLike(Log::getReqMethod, "%" + log.getReqMethod() + "%"); criteria.andLike(Log::getExecMethod, "%" + log.getExecMethod() + "%"); criteria.andLike(Log::getExecDesc, "%" + log.getExecDesc() + "%"); criteria.andLike(Log::getStatus, "%" + log.getStatus() + "%"); criteria.andGreaterThanOrEqualTo(Log::getCreateTime, log.getStartDate()).andLessThanOrEqualTo(Log::getCreateTime, log.getEndDate());
public static Weekend<DictatorConfig> from(@NonNull CommonParam commonParam, @NonNull Long profileId, Date lastUpdatedTime) { Weekend<DictatorConfig> weekend = Weekend.of(DictatorConfig.class); WeekendCriteria<DictatorConfig, Object> dictatorConfigObjectWeekendCriteria = weekend.weekendCriteria(); dictatorConfigObjectWeekendCriteria .andEqualTo(DictatorConfig::getAppId, commonParam.getAppCode()) .andEqualTo(DictatorConfig::getProfileId, profileId) .andEqualTo(DictatorConfig::getConfigName, commonParam.getKey()); if (lastUpdatedTime != null) { dictatorConfigObjectWeekendCriteria.andGreaterThanOrEqualTo(DictatorConfig::getUpdatedTime, lastUpdatedTime); } return weekend; }
@Override public PageResultSet<UserDto> findByPage(UserQuery userQuery) { if(!StringUtils.isEmpty(userQuery.getOrderBy())) { PageHelper.orderBy(userQuery.getOrderBy()); } Weekend<User> example = Weekend.of(User.class); WeekendCriteria<User, Object> criteria = example.weekendCriteria(); if (!StringUtils.isEmpty(userQuery.getUsername())) { criteria.andLike(User::getUsername, "%" + userQuery.getUsername() + "%"); } if(userQuery.getLocked() != null) { criteria.andEqualTo(User::getLocked,userQuery.getLocked()); } List<UserDto> dtoList = new ArrayList<>(); PageHelper.offsetPage(userQuery.getOffset(), userQuery.getLimit()); userMapper.selectByExample(example).forEach(u -> { UserDto dto = new UserDto(u); dto.setOrganizationName(getOrganizationName(Long.valueOf(dto.getOrganizationId()))); dto.setRoleNames(getRoleNames(dto.getRoleIdList())); dto.setGroupNames(getGroupNames(dto.getGroupIdList())); dtoList.add(dto); }); long total = userMapper.selectCountByExample(example); PageResultSet<UserDto> resultSet = new PageResultSet<>(); resultSet.setRows(dtoList); resultSet.setTotal(total); return resultSet; }
public List<Country> getAllByWeekend(Country country) { if (country.getPage() != null && country.getRows() != null) { PageHelper.startPage(country.getPage(), country.getRows()); } Weekend<Country> weekend = Weekend.of(Country.class); WeekendCriteria<Country, Object> criteria = weekend.weekendCriteria(); if (country.getCountryname() != null && country.getCountryname().length() > 0) { criteria.andLike(Country::getCountryname, "%" + country.getCountryname() + "%"); } if (country.getCountrycode() != null && country.getCountrycode().length() > 0) { criteria.andLike(Country::getCountrycode, "%" + country.getCountrycode() + "%"); } return countryMapper.selectByExample(weekend); }
@Override public List<Organization> findAllWithExclude(Organization exclude) { Weekend weekend = Weekend.of(Organization.class); WeekendCriteria<Organization, Object> criteria = weekend.weekendCriteria(); criteria.andNotEqualTo(Organization::getId, exclude.getId()).andNotLike(Organization::getParentIds, exclude.makeSelfAsParentIds() + "%"); return organizationMapper.selectByExample(weekend); }
default List<DictatorConfigHistory> findLastHour() { Weekend<DictatorConfigHistory> weekend = Weekend.of(DictatorConfigHistory.class); weekend.weekendCriteria() .andGreaterThanOrEqualTo(DictatorConfigHistory::getHistoryCreatedTime, LocalDateTime.now().minusHours(1)); return this.selectByExample(weekend); }
default Map<Long, String> findConfigNameMapByGroupIdList(@NonNull List<Long> configIdList) { if (configIdList.isEmpty()) { return Maps.newHashMap(); } Weekend<DictatorConfigGroup> weekend = Weekend.of(DictatorConfigGroup.class); weekend.weekendCriteria() .andIn(DictatorConfigGroup::getId, configIdList); return this.findAll(weekend).stream() .collect(Collectors.toMap(DictatorConfigGroup::getId, DictatorConfigGroup::getGroupName)); } }
default List<DictatorConfig> findByProfileId(@NonNull Long profileId){ Weekend<DictatorConfig> weekend = DictatorConfigWeekend.of(); weekend.weekendCriteria() .andEqualTo(DictatorConfig::getProfileId,profileId); return this.findAll(weekend); }
@Override public PageResultSet<RoleDto> findByPage(RoleQuery roleQuery) { PageHelper.offsetPage(roleQuery.getOffset(), roleQuery.getLimit()); if(!StringUtils.isEmpty(roleQuery.getOrderBy())) { PageHelper.orderBy(roleQuery.getOrderBy()); } Weekend<Role> example = Weekend.of(Role.class); WeekendCriteria<Role, Object> criteria = example.weekendCriteria(); if(!StringUtils.isEmpty(roleQuery.getRole())) { criteria.andLike(Role::getRole,"%" + roleQuery.getRole() + "%"); } if(!StringUtils.isEmpty(roleQuery.getDescription())) { criteria.andLike(Role::getDescription,"%" + roleQuery.getDescription() + "%"); } PageResultSet<RoleDto> resultSet = new PageResultSet<>(); List<RoleDto> dtoList = new ArrayList<>(); roleMapper.selectByExample(example).forEach(r -> { RoleDto dto = new RoleDto(r); dto.setResourceNames(getResourceNames(r.getResourceIdList())); dtoList.add(dto); }); long total = roleMapper.selectCountByExample(example); resultSet.setRows(dtoList); resultSet.setTotal(total); return resultSet; }
default Map<Long, String> findProfileNameByIdList(@NonNull List<Long> profileIdList) { if (profileIdList.isEmpty()) { return Maps.newHashMap(); } Weekend<DictatorConfigProfile> weekend = Weekend.of(DictatorConfigProfile.class); weekend.weekendCriteria() .andIn(DictatorConfigProfile::getId, profileIdList); return this.findAll(weekend).stream() .collect(Collectors.toMap(DictatorConfigProfile::getId, DictatorConfigProfile::getProfileName)); }
default List<DictatorResource> findByParentId(@NonNull Long parentId){ Weekend<DictatorResource> weekend = Weekend.of(DictatorResource.class); weekend.weekendCriteria() .andEqualTo(DictatorResource::getParentId,parentId); return this.findAll(weekend); }
public WeekendCriteria<A, B> andIsNull(Fn<A, B> fn) { this.andIsNull(Reflections.fnToFieldName(fn)); return this; }
public WeekendCriteria<T, Object> createCriteriaAddOn() { WeekendCriteria<T, Object> weekendCriteria = new WeekendCriteria<>(this.propertyMap, this.exists, this.notNull); return weekendCriteria; }
@Override public PageResultSet<Group> findByPage(GroupQuery groupQuery) { if (!StringUtils.isEmpty(groupQuery.getOrderBy())) { PageHelper.orderBy(groupQuery.getOrderBy()); } Weekend<Group> weekend = Weekend.of(Group.class); WeekendCriteria<Group, Object> criteria = weekend.weekendCriteria(); if (!StringUtils.isEmpty(groupQuery.getName())) { criteria.andLike(Group::getName, groupQuery.getName()); } PageResultSet<Group> resultSet = new PageResultSet<>(); Page page = PageHelper.offsetPage(groupQuery.getOffset(), groupQuery.getLimit()).doSelectPage(() -> groupMapper.selectByExample(weekend)); resultSet.setRows(page); resultSet.setTotal(page.getTotal()); return resultSet; }
default Map<Long, DictatorConfigProfile> findMapByIdList(@NonNull List<Long> profileIdList) { Weekend<DictatorConfigProfile> weekend = Weekend.of(DictatorConfigProfile.class); weekend.weekendCriteria() .andIn(DictatorConfigProfile::getId, profileIdList); return this.findAll(weekend).stream() .collect(Collectors.toMap(DictatorConfigProfile::getId, e -> e)); }
default int countByProfileId(@NonNull Long profileId) { Weekend<DictatorConfigHistory> weekend = Weekend.of(DictatorConfigHistory.class); weekend.weekendCriteria() .andEqualTo(DictatorConfigHistory::getProfileId, profileId); return this.selectCountByExample(weekend); } }
public WeekendCriteria<A, B> andIsNull(Fn<A, B> fn) { this.andIsNull(Reflections.fnToFieldName(fn)); return this; }