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); }
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; }
default List<DictatorConfig> findByProfileId(@NonNull Long profileId){ Weekend<DictatorConfig> weekend = DictatorConfigWeekend.of(); weekend.weekendCriteria() .andEqualTo(DictatorConfig::getProfileId,profileId); return this.findAll(weekend); }
default List<DictatorConfigHistory> findByConfigId(@NonNull Long configId) { Weekend<DictatorConfigHistory> weekend = Weekend.of(DictatorConfigHistory.class); weekend.weekendCriteria() .andEqualTo(DictatorConfigHistory::getConfigId, configId); return this.findAll(weekend); }
default List<DictatorResource> findByParentId(@NonNull Long parentId){ Weekend<DictatorResource> weekend = Weekend.of(DictatorResource.class); weekend.weekendCriteria() .andEqualTo(DictatorResource::getParentId,parentId); return this.findAll(weekend); }
default int countByProfileId(@NonNull Long profileId) { Weekend<DictatorConfigHistory> weekend = Weekend.of(DictatorConfigHistory.class); weekend.weekendCriteria() .andEqualTo(DictatorConfigHistory::getProfileId, profileId); return this.selectCountByExample(weekend); } }
default Optional<DictatorUser> findByUsername(@NonNull String username) { Weekend<DictatorUser> weekend = Weekend.of(DictatorUser.class); weekend.weekendCriteria() .andEqualTo(DictatorUser::getUserName, username); return this.findOne(weekend); }
@Override public List<TreeDto> findOrgTree(Long pId) { if (StringUtils.isEmpty(pId)) { pId = Constants.ORG_ROOT_ID; } List<TreeDto> tds = new ArrayList<>(); Weekend example = Weekend.of(Organization.class); WeekendCriteria<Organization, Object> criteria = example.weekendCriteria(); criteria.andEqualTo(Organization::getParentId, pId); organizationMapper.selectByExample(example).forEach(o -> tds.add(new TreeDto(o.getId(), o.getParentId(), o.getName(), Boolean.FALSE.equals(o.getLeaf()), o))); return tds; }
default List<DictatorApp> findAllEnabled() { Weekend<DictatorApp> weekend = Weekend.of(DictatorApp.class); weekend.weekendCriteria() .andEqualTo(DictatorApp::getEnable,Boolean.TRUE); return this.findAll(weekend); } }
default Optional<DictatorConfigHistory> findLastByConfigId(@NonNull Long configId) { Weekend<DictatorConfigHistory> weekend = Weekend.of(DictatorConfigHistory.class); weekend.weekendCriteria() .andEqualTo(DictatorConfigHistory::getConfigId, configId); weekend.orderBy("version").desc(); weekend.orderBy("updatedTime").desc(); weekend.orderBy("createdTime").desc(); return this.findFirst(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; }