feat: There is no way the, TO optimize the query
This commit is contained in:
@@ -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);
|
||||
|
||||
+18
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,12 @@
|
||||
<if test="collectResId != null">
|
||||
and collect_res_id ${collectResIdOperator} #{collectResId}
|
||||
</if>
|
||||
<if test="collectResIds != null and collectResIds.size !=0">
|
||||
and collect_res_id IN
|
||||
<foreach collection="collectResIds" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="collectInfoUri != null">
|
||||
and collect_info_uri ${collectInfoUriOperator} #{collectInfoUri}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user