Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.nebula.boxes.mould.fetcher.async.RecruitTrunkApi Maven / Gradle / Ivy
package com.nebula.boxes.mould.fetcher.async;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import java.util.Optional;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.nebula.boxes.mould.entity.Recruit;
import com.nebula.boxes.mould.service.IRecruitService;
import com.spring.boxes.dollar.$;
import com.spring.boxes.dollar.enums.EnableEnum;
import com.spring.boxes.dollar.enums.YesOrNoEnum;
import com.spring.boxes.dollar.support.ContextAwarePoolExecutor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
@Lazy
@Slf4j
@Service
public class RecruitTrunkApi {
@Autowired
private IRecruitService recruitService;
@Autowired
private ContextAwarePoolExecutor contextAwarePoolExecutor;
public CompletableFuture selectOneById(Long id) {
Recruit one = Optional.ofNullable(id)
.map(x -> recruitService.getById(id))
.orElse(null);
return CompletableFuture.supplyAsync(() -> one, contextAwarePoolExecutor);
}
public CompletableFuture> selectListByIds(Collection ids) {
if (CollectionUtils.isEmpty(ids)) {
return CompletableFuture.supplyAsync(ArrayList::new, contextAwarePoolExecutor);
}
Collection list = recruitService.listByIds(ids);
return CompletableFuture.supplyAsync(() -> list, contextAwarePoolExecutor);
}
public CompletableFuture> selectMapByIds(List ids) {
Collection list = recruitService.listByIds(ids);
if (CollectionUtils.isEmpty(list)) {
return CompletableFuture.supplyAsync(HashMap::new, contextAwarePoolExecutor);
}
// 针对重复key的 覆盖之前的value
Map map = list.stream().collect(Collectors.toMap(Recruit::getId, Function.identity(), (k, v) -> v));
return CompletableFuture.supplyAsync(() -> map, contextAwarePoolExecutor);
}
public CompletableFuture selectOneByUuid(String uuid) {
QueryWrapper wp = new QueryWrapper<>();
wp.lambda().eq(Recruit::getUuid, uuid);
Recruit one = recruitService.getOne(wp);
return CompletableFuture.supplyAsync(() -> one, contextAwarePoolExecutor);
}
public CompletableFuture> selectListByUuids(Collection uuids) {
QueryWrapper wp = new QueryWrapper<>();
wp.lambda().in(Recruit::getUuid, uuids);
List list = recruitService.list(wp);
return CompletableFuture.supplyAsync(() -> list, contextAwarePoolExecutor);
}
public CompletableFuture> selectMapByUuids(Collection uuids) {
QueryWrapper wp = new QueryWrapper<>();
wp.lambda().in(Recruit::getUuid, uuids);
List list = recruitService.list(wp);
if (CollectionUtils.isEmpty(list)) {
return CompletableFuture.supplyAsync(HashMap::new, contextAwarePoolExecutor);
}
// 针对重复key的 覆盖之前的value
Map map = list.stream().collect(Collectors.toMap(Recruit::getUuid, Function.identity(), (k, v) -> v));
return CompletableFuture.supplyAsync(() -> map, contextAwarePoolExecutor);
}
public CompletableFuture> selectListByWrapper(QueryWrapper wp) throws Exception {
List list = this.recruitService.list(wp);
return CompletableFuture.supplyAsync(() -> list, contextAwarePoolExecutor);
}
public CompletableFuture selectRecruitTotal(YesOrNoEnum online) {
LambdaQueryWrapper wp = Wrappers.lambdaQuery();
wp.eq(Recruit::getEnabled, EnableEnum.ENABLED.getValue()).eq(Recruit::getOnline, online.getValue());
long total = recruitService.count(wp);
return CompletableFuture.supplyAsync(() -> total, contextAwarePoolExecutor);
}
public CompletableFuture selectFirmRecruitTotal(long firmId) {
LambdaQueryWrapper wp = Wrappers.lambdaQuery();
wp.eq(Recruit::getEnabled, EnableEnum.ENABLED.getValue()).eq(Recruit::getOnline, YesOrNoEnum.YES.getValue())
.eq(Recruit::getFirmId, firmId);
long total = recruitService.count(wp);
return CompletableFuture.supplyAsync(() -> total, contextAwarePoolExecutor);
}
public CompletableFuture> selectFirmRecruitTotal(Collection firmIds) {
QueryWrapper wp = new QueryWrapper<>();
wp.select("firm_id as item", "count(0) as total");
wp.eq("enabled", EnableEnum.ENABLED.getValue()).eq("online", YesOrNoEnum.YES.getValue()).in("firm_id", firmIds);
wp.groupBy("firm_id").orderByDesc("total");
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
public CompletableFuture selectStaffRecruitTotal(long userId) {
LambdaQueryWrapper wp = Wrappers.lambdaQuery();
wp.eq(Recruit::getEnabled, EnableEnum.ENABLED.getValue()).eq(Recruit::getOnline, YesOrNoEnum.YES.getValue())
.eq(Recruit::getUserId, userId);
long total = recruitService.count(wp);
return CompletableFuture.supplyAsync(() -> total, contextAwarePoolExecutor);
}
public CompletableFuture> selectStaffRecruitTotal(Collection userIds) {
QueryWrapper wp = new QueryWrapper<>();
wp.select("user_id as item", "count(0) as total");
wp.eq("enabled", EnableEnum.ENABLED.getValue()).eq("online", YesOrNoEnum.NO.getValue()).in("user_id", userIds);
wp.groupBy("user_id").orderByDesc("total");
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
// select firm_id, count(0) count from recruit GROUP BY firm_id order by count desc limit 10;
public CompletableFuture> selectWorkFirmIdGroupBy(int size) {
QueryWrapper wp = new QueryWrapper<>();
wp.select("firm_id as item", "count(0) as total");
wp.groupBy("firm_id").orderByDesc("total").last("limit " + Math.abs(size));
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
// select city_id, count(0) count from recruit GROUP BY city_id order by count desc limit 10;
public CompletableFuture> selectWorkCityIdGroupBy(int size) {
QueryWrapper wp = new QueryWrapper<>();
wp.select("city_id as item", "count(0) as total");
wp.groupBy("city_id").orderByDesc("total").last("limit " + Math.abs(size));
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
// select work_wage, count(0) count from recruit GROUP BY work_wage order by count desc ;
public CompletableFuture> selectWorkWageGroupBy() {
QueryWrapper wp = new QueryWrapper<>();
wp.select("work_wage as item", "count(0) as total");
wp.groupBy("work_wage").orderByDesc("total");
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
// select work_year, count(0) count from recruit GROUP BY work_year order by count desc ;
public CompletableFuture> selectWorkYearGroupBy() {
QueryWrapper wp = new QueryWrapper<>();
wp.select("work_year as item", "count(0) as total");
wp.groupBy("work_year").orderByDesc("total");
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
// select work_edu, count(0) count from recruit GROUP BY work_edu order by count desc ;
public CompletableFuture> selectWorEduGroupBy() {
QueryWrapper wp = new QueryWrapper<>();
wp.select("work_edu as item", "count(0) as total");
wp.groupBy("work_edu").orderByDesc("total");
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "item", "total"), contextAwarePoolExecutor);
}
public CompletableFuture> selectMonthTotalGroupBy() {
QueryWrapper wp = new QueryWrapper<>();
wp.select("DATE_FORMAT(create_time,'%Y/%m') date", "count(0) as total");
wp.eq("enabled", EnableEnum.ENABLED.getValue());
wp.groupBy("date").orderByDesc("date");
List> list = recruitService.listMaps(wp);
return CompletableFuture.supplyAsync(() -> $.getPairMap(list, "date", "total"), contextAwarePoolExecutor);
}
}