feat: There is no way the, TO optimize the query

This commit is contained in:
super_liu
2021-10-22 15:50:07 +08:00
parent d8053efe8e
commit 9eff2340a2
16 changed files with 503 additions and 101 deletions
@@ -25,6 +25,7 @@ public class PersonCollectEOPage extends BasePage {
private String validFlag;
private String validFlagOperator = "=";
private String collectResId;
private List<String> collectResIds;
private String collectResIdOperator = "LIKE";
private String collectInfoUri;
private String collectInfoUriOperator = "LIKE";
@@ -40,6 +41,14 @@ public class PersonCollectEOPage extends BasePage {
private List<String> collectTypeList = new ArrayList<>();
public List<String> getCollectResIds() {
return collectResIds;
}
public void setCollectResIds(List<String> collectResIds) {
this.collectResIds = collectResIds;
}
public String getModifyTime() {
return this.modifyTime;
}
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
public interface IPersonCollectEOService extends IService<TsPersonCollect> {
@@ -18,6 +19,8 @@ public interface IPersonCollectEOService extends IService<TsPersonCollect> {
public String queryCollectByUserAndId(String collectResId);
public Map<String,String> queryCollectByUserAndIds(List<String> collectResIds);
public int deleteByIdList(List<String> idList);
public int deleteByResId(String resId);
@@ -19,7 +19,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -96,6 +97,22 @@ public class PersonCollectEOServiceImpl extends ServiceImpl<PersonCollectEODao,
return collectId;
}
public Map<String,String> queryCollectByUserAndIds(List<String> collectResIds) {
Map<String,String> resultMap = new TreeMap<>();
String userId = LoginUserUtil.getUserId();
PersonCollectEOPage page = new PersonCollectEOPage();
page.setUserId(userId);
page.setValidFlag("0");
page.setCollectResIds(collectResIds);
List<TsPersonCollect> getCollects = this.baseMapper.queryByList(page);
List<TsPersonCollect> distinctList = getCollects.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(o -> o.getCollectResId()))), ArrayList::new));
resultMap = distinctList.stream().collect(Collectors.toMap(TsPersonCollect::getCollectResId, TsPersonCollect::getId));
return resultMap;
}
public int deleteByIdList(List<String> idList){
return this.baseMapper.deleteByIdList(idList);
}