mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 11:26:50 +08:00
Merge branch 'refs/heads/zcwy0813-yang' into dev0525
This commit is contained in:
@@ -17,6 +17,7 @@ import com.xboe.module.boecase.vo.CasesQueryRecommendRankVo;
|
||||
import com.xboe.module.dict.entity.DictItem;
|
||||
import com.xboe.module.excel.ExportsExcelSenderUtil;
|
||||
|
||||
import com.xboe.module.interaction.dto.FavoriteCaseDto;
|
||||
import com.xboe.system.user.dao.UserDao;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -126,6 +127,7 @@ public class CasesApi extends ApiBaseController {
|
||||
public JsonResponse<PageList<Cases>> queryCaseBreV2(@Validated @RequestBody CasePageVo req) {
|
||||
String type = req.getType();
|
||||
req.setUserId(getCurrent().getAccountId());
|
||||
req.setUserId("965342027497607168");
|
||||
PageList<Cases> views = null;
|
||||
if (type.equals("recommend")) {
|
||||
views = casesService.queryRecommendPageCasesV2(req);
|
||||
@@ -613,7 +615,8 @@ public class CasesApi extends ApiBaseController {
|
||||
if (ids.isEmpty()) {
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
List<Cases> cases = casesService.ids(ids);
|
||||
String accountId = getCurrent().getAccountId();
|
||||
List<Cases> cases = casesService.ids(ids,accountId);
|
||||
return success(cases);
|
||||
}
|
||||
|
||||
@@ -687,7 +690,8 @@ public class CasesApi extends ApiBaseController {
|
||||
public JsonResponse<List<Cases>> queryPopularityOfMajor(@RequestParam(required = false) Integer pageSize,
|
||||
@RequestParam Long majorId,
|
||||
@RequestParam LocalDateTime rankMonth) {
|
||||
List<Cases> caseRankingVoList =casesService.queryPopularityOfMajor(pageSize,majorId,rankMonth);
|
||||
String accountId = getCurrent().getAccountId();
|
||||
List<Cases> caseRankingVoList =casesService.queryPopularityOfMajor(pageSize,majorId,rankMonth,accountId);
|
||||
return success(caseRankingVoList);
|
||||
}
|
||||
|
||||
@@ -733,4 +737,17 @@ public class CasesApi extends ApiBaseController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询收藏
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@GetMapping("/queryFavoriteCaseOfIndex")
|
||||
public JsonResponse<PageList<FavoriteCaseDto>> queryFavoriteCaseOfIndex(Integer pageIndex,Integer pageSize,String order) {
|
||||
// String aid = this.getCurrent().getAccountId();
|
||||
String aid = "965342027497607168";
|
||||
PageList<FavoriteCaseDto> casesList = casesService.queryFavoriteCaseOfIndex(pageIndex,pageSize,order,aid);
|
||||
return success(casesList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CasesRankDao extends BaseDao<CasesRank> {
|
||||
|
||||
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
|
||||
String sql =
|
||||
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank \n" +
|
||||
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank,bcvr.major_id \n" +
|
||||
"FROM\n" +
|
||||
" boe_cases_rank bcvr\n" +
|
||||
"JOIN boe_dict_major_type bdmt \n" +
|
||||
@@ -33,9 +33,9 @@ public class CasesRankDao extends BaseDao<CasesRank> {
|
||||
for (Object[] o : list) {
|
||||
CasesRank casesRank = new CasesRank();
|
||||
casesRank.setMajorName(o[0].toString());
|
||||
|
||||
casesRank.setSysCreateTime(((Timestamp) o[1]).toLocalDateTime());
|
||||
casesRank.setRiseRankTime(((Timestamp) o[1]).toLocalDateTime());
|
||||
casesRank.setRank(Integer.valueOf(o[2].toString()));
|
||||
casesRank.setMajorId(Long.valueOf(o[3].toString()));
|
||||
resultList.add(casesRank);
|
||||
}
|
||||
return resultList;
|
||||
|
||||
@@ -21,50 +21,79 @@ import java.util.List;
|
||||
*/
|
||||
@Repository
|
||||
public interface CasesRecordDao extends JpaRepository<Cases, String>, JpaSpecificationExecutor<Cases> {
|
||||
@Query(nativeQuery = true, value = "select c.* from ( select b.*" +
|
||||
" from boe_cases_recommend_push_record a left JOIN boe_cases b on a.case_id = b.id" +
|
||||
" where b.deleted=0 and a.push_status = 3 and a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
|
||||
" and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
|
||||
" and if(:#{#condition.caseIdsEmpty}, 1=1, b.id in (:#{#condition.caseIds}))" +
|
||||
" and ("+
|
||||
" if(:#{#condition.allOrgEmpty}, 1=1, 1=2)" +
|
||||
" or if(:#{#condition.org1Empty}, 1=2, b.org_domain_parent in (:#{#condition.org1}))" +
|
||||
" or if(:#{#condition.org2Empty}, 1=2, b.org_domain_parent2 in (:#{#condition.org2}))" +
|
||||
" or if(:#{#condition.org3Empty}, 1=2, b.org_domain_parent3 in (:#{#condition.org3}))" +
|
||||
")" +
|
||||
" and if(:#{#condition.isSysType1Empty} , 1=1, b.sys_type1 = :#{#condition.sysType1} )"+
|
||||
" and if(:#{#condition.isSysType2Empty} , 1=1, b.sys_type2 = :#{#condition.sysType2} )"+
|
||||
" and if(:#{#condition.isSysType3Empty} , 1=1, b.sys_type3 = :#{#condition.sysType3} )"+
|
||||
" order by a.sys_create_time DESC, a.read_flag ASC) as c group by c.id",
|
||||
countQuery = "select count(*) FROM (select c.* from ( select b.*" +
|
||||
" from boe_cases_recommend_push_record a left JOIN boe_cases b on a.case_id = b.id " +
|
||||
" where b.deleted=0 and a.push_status = 3 and a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
|
||||
" and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
|
||||
" and if(:#{#condition.caseIdsEmpty}, 1=1, b.id in (:#{#condition.caseIds}))" +
|
||||
" and ("+
|
||||
" if(:#{#condition.allOrgEmpty}, 1=1, 1=2)" +
|
||||
" or if(:#{#condition.org1Empty}, 1=1, b.org_domain_parent in (:#{#condition.org1}))" +
|
||||
" or if(:#{#condition.org2Empty}, 1=1, b.org_domain_parent2 in (:#{#condition.org2}))" +
|
||||
" or if(:#{#condition.org3Empty}, 1=1, b.org_domain_parent3 in (:#{#condition.org3}))" +
|
||||
")" +
|
||||
" and if(:#{#condition.isSysType1Empty} , 1=1, b.sys_type1 = :#{#condition.sysType1} )"+
|
||||
" and if(:#{#condition.isSysType2Empty} , 1=1, b.sys_type2 = :#{#condition.sysType2} )"+
|
||||
" and if(:#{#condition.isSysType3Empty} , 1=1, b.sys_type3 = :#{#condition.sysType3} )"+
|
||||
" order by a.sys_create_time DESC, a.read_flag ASC ) as c group by c.id) as d")
|
||||
@Query(nativeQuery = true, value =
|
||||
" SELECT c.* FROM ( " +
|
||||
" SELECT b.* " +
|
||||
" FROM boe_cases_recommend_push_record a " +
|
||||
" LEFT JOIN boe_cases b ON a.case_id = b.id " +
|
||||
" WHERE b.deleted = 0 " +
|
||||
" AND a.push_status = 5 " +
|
||||
" AND a.deleted = 0 " +
|
||||
" AND a.push_user_id = :#{#condition.userId} " +
|
||||
" AND IF(IFNULL(:#{#condition.keyWord}, '') != '', " +
|
||||
" b.title LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.author_name LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword1 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword2 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword3 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword4 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword5 LIKE CONCAT('%', :#{#condition.keyWord}, '%'), " +
|
||||
" 1 = 1) " +
|
||||
" AND IF(:#{#condition.yearsEmpty}, 1 = 1, YEAR(b.sys_create_time) IN (:#{#condition.years})) " +
|
||||
" AND IF(:#{#condition.caseIdsEmpty}, 1 = 1, b.id IN (:#{#condition.caseIds})) " +
|
||||
" AND ( " +
|
||||
" IF(:#{#condition.allOrgEmpty}, 1 = 1, 1 = 2) " +
|
||||
" OR IF(:#{#condition.org1Empty}, 1 = 2, b.org_domain_parent IN (:#{#condition.org1})) " +
|
||||
" OR IF(:#{#condition.org2Empty}, 1 = 2, b.org_domain_parent2 IN (:#{#condition.org2})) " +
|
||||
" OR IF(:#{#condition.org3Empty}, 1 = 2, b.org_domain_parent3 IN (:#{#condition.org3})) " +
|
||||
" ) " +
|
||||
" AND IF(:#{#condition.isSysType1Empty}, 1 = 1, b.sys_type1 = :#{#condition.sysType1}) " +
|
||||
" AND IF(:#{#condition.isSysType2Empty}, 1 = 1, b.sys_type2 = :#{#condition.sysType2}) " +
|
||||
" AND IF(:#{#condition.isSysType3Empty}, 1 = 1, b.sys_type3 = :#{#condition.sysType3}) " +
|
||||
" ) AS c GROUP BY c.id " +
|
||||
" ORDER BY " +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=true,c.views, null) asc," +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=false,c.views, null) desc," +
|
||||
" IF(:#{#condition.orderField}='sys_create_time' and :#{#condition.orderAsc}=true ,c.sys_create_time,null) asc," +
|
||||
" IF(:#{#condition.orderField}='sys_create_time' and :#{#condition.orderAsc}=false , c.sys_create_time,null) desc ," +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderField}!='sys_create_time' , c.sys_create_time , null) desc",
|
||||
countQuery =
|
||||
" SELECT count(*) FROM ( " +
|
||||
" SELECT b.* " +
|
||||
" FROM boe_cases_recommend_push_record a " +
|
||||
" LEFT JOIN boe_cases b ON a.case_id = b.id " +
|
||||
" WHERE b.deleted = 0 " +
|
||||
" AND a.push_status = 5 " +
|
||||
" AND a.deleted = 0 " +
|
||||
" AND a.push_user_id = :#{#condition.userId} " +
|
||||
" AND IF(IFNULL(:#{#condition.keyWord}, '') != '', " +
|
||||
" b.title LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.author_name LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword1 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword2 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword3 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword4 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword5 LIKE CONCAT('%', :#{#condition.keyWord}, '%'), " +
|
||||
" 1 = 1) " +
|
||||
" AND IF(:#{#condition.yearsEmpty}, 1 = 1, YEAR(b.sys_create_time) IN (:#{#condition.years})) " +
|
||||
" AND IF(:#{#condition.caseIdsEmpty}, 1 = 1, b.id IN (:#{#condition.caseIds})) " +
|
||||
" AND ( " +
|
||||
" IF(:#{#condition.allOrgEmpty}, 1 = 1, 1 = 2) " +
|
||||
" OR IF(:#{#condition.org1Empty}, 1 = 2, b.org_domain_parent IN (:#{#condition.org1})) " +
|
||||
" OR IF(:#{#condition.org2Empty}, 1 = 2, b.org_domain_parent2 IN (:#{#condition.org2})) " +
|
||||
" OR IF(:#{#condition.org3Empty}, 1 = 2, b.org_domain_parent3 IN (:#{#condition.org3})) " +
|
||||
" ) " +
|
||||
" AND IF(:#{#condition.isSysType1Empty}, 1 = 1, b.sys_type1 = :#{#condition.sysType1}) " +
|
||||
" AND IF(:#{#condition.isSysType2Empty}, 1 = 1, b.sys_type2 = :#{#condition.sysType2}) " +
|
||||
" AND IF(:#{#condition.isSysType3Empty}, 1 = 1, b.sys_type3 = :#{#condition.sysType3}) " +
|
||||
" ) AS c GROUP BY c.id " +
|
||||
" ORDER BY " +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=true,c.views, null) asc," +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=false,c.views, null) desc," +
|
||||
" IF(:#{#condition.orderField}='sys_create_time' and :#{#condition.orderAsc}=true ,c.sys_create_time,null) asc," +
|
||||
" IF(:#{#condition.orderField}='sys_create_time' and :#{#condition.orderAsc}=false , c.sys_create_time,null) desc," +
|
||||
" IF(:#{#condition.orderField}!='views' and :#{#condition.orderField}!='sys_create_time' , c.sys_create_time , null) desc"
|
||||
)
|
||||
Page<Cases> queryList(Pageable pageable, @Param("condition") CasePageVo casePage);
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xboe.module.boecase.entity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import com.xboe.module.boecase.vo.CaseViewRankingItemVo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -322,7 +323,7 @@ public class Cases extends BaseEntity {
|
||||
private String excellentTag;
|
||||
|
||||
@Transient
|
||||
private List<String> viewRankTags;
|
||||
private List<CaseViewRankingItemVo> viewRankTags;
|
||||
|
||||
@Transient
|
||||
private List<String> authorTags;
|
||||
|
||||
@@ -54,8 +54,9 @@ public class CasesRecommend extends BaseEntity {
|
||||
public CasesRecommend() {
|
||||
}
|
||||
|
||||
public CasesRecommend(String id, String recommendOrgName) {
|
||||
public CasesRecommend(String id, String recommendOrgName,LocalDateTime recommendTime) {
|
||||
this.setId(id);
|
||||
this.recommendOrgName = recommendOrgName;
|
||||
this.recommendTime = recommendTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.module.boecase.vo.CaseRankingVo;
|
||||
import com.xboe.module.boecase.vo.CasesQueryRecommendRankVo;
|
||||
import com.xboe.module.dict.entity.DictItem;
|
||||
import com.xboe.module.interaction.dto.FavoriteCaseDto;
|
||||
import com.xboe.school.vo.CasesVo;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
@@ -95,7 +96,7 @@ public interface ICasesService{
|
||||
/**
|
||||
* 用于二次查询
|
||||
* */
|
||||
List<Cases> ids(List<String> ids);
|
||||
List<Cases> ids(List<String> ids, String accountId);
|
||||
|
||||
/**
|
||||
*二期 首页的推荐案例
|
||||
@@ -129,7 +130,8 @@ public interface ICasesService{
|
||||
|
||||
List<CaseRankingVo> queryRank(Integer pageSize, Integer rankType);
|
||||
|
||||
List<Cases> queryPopularityOfMajor(Integer pageSize, Long majorId, LocalDateTime month);
|
||||
List<Cases> queryPopularityOfMajor(Integer pageSize, Long majorId, LocalDateTime month, String accountId);
|
||||
|
||||
PageList<FavoriteCaseDto> queryFavoriteCaseOfIndex(Integer pageIndex, Integer pageSize, String order, String aid);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,15 @@ import com.xboe.module.boecase.dto.*;
|
||||
import com.xboe.module.boecase.entity.*;
|
||||
import com.xboe.module.boecase.service.ICasesService;
|
||||
import com.xboe.module.boecase.vo.CaseRankingVo;
|
||||
import com.xboe.module.boecase.vo.CaseViewRankingItemVo;
|
||||
import com.xboe.module.boecase.vo.CasesQueryRecommendRankVo;
|
||||
import com.xboe.module.dict.dao.SysDictionaryDao;
|
||||
import com.xboe.module.dict.entity.DictItem;
|
||||
import com.xboe.module.interaction.dto.FavoriteCaseDto;
|
||||
import com.xboe.module.interaction.entity.Favorites;
|
||||
import com.xboe.orm.CustomFieldInFilter;
|
||||
import com.xboe.school.vo.CasesVo;
|
||||
import com.xboe.standard.enums.BoedxResourceType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -40,6 +44,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@@ -330,54 +335,19 @@ public class CasesServiceImpl implements ICasesService {
|
||||
query.setPageIndex(caseVo.getPageIndex());
|
||||
query.setPageSize(caseVo.getPageSize());
|
||||
page = casesDao.findPage(query.builder());
|
||||
List<Cases> list = page.getList();
|
||||
list.forEach(it->{
|
||||
List<Cases> casesList = page.getList();
|
||||
casesList.forEach(it->{
|
||||
it.setBreCommend(0);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(list) && StrUtil.isNotBlank(caseVo.getUserId())) {
|
||||
List<String> caseIds = list.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
|
||||
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.eq("pushUserId", caseVo.getUserId()));
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
.addOrder("sysCreateTime", OrderDirection.DESC)
|
||||
.addGroupBy("caseId");
|
||||
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
|
||||
if (CollUtil.isNotEmpty(pushRecords)) {
|
||||
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
|
||||
builder.addField("new CasesRecommend(id,recommendOrgName)");
|
||||
List<IFieldFilter> recommendFilters = new ArrayList<>();
|
||||
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
recommendFilters.add(FieldFilters.in("id", rIds));
|
||||
builder.addFilters(recommendFilters);
|
||||
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
|
||||
if (CollUtil.isNotEmpty(recommands)) {
|
||||
Map<String, String> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), v -> v.getRecommendOrgName()));
|
||||
list.forEach(it -> {
|
||||
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
|
||||
if (Objects.nonNull(one)) {
|
||||
String recommendOrgName = collect.get(one.getRecommendId());
|
||||
it.setBreCommend(1);
|
||||
it.setRecommendOrgName(recommendOrgName);
|
||||
} else {
|
||||
it.setBreCommend(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
addAuthorTagAndCaseNewTag(list);
|
||||
}
|
||||
casesList = addTags(casesList, caseVo.getUserId());
|
||||
page.setList(casesList);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加案例标签、作者标签(最佳案例N篇、上榜浏览量TOP榜单N次)、案例标签(xx分类浏览量TOP、最佳案例)
|
||||
*/
|
||||
private void addAuthorTagAndCaseNewTag(List<Cases> caseList) {
|
||||
if (CollUtil.isEmpty(caseList)) {
|
||||
return;
|
||||
@@ -393,14 +363,21 @@ public class CasesServiceImpl implements ICasesService {
|
||||
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
|
||||
if (CollUtil.isNotEmpty(viewsRankRecords)) {
|
||||
// 拼接生成浏览量排行榜的标签
|
||||
List<String> viewRankTags = viewsRankRecords.stream().map(casesRank -> {
|
||||
String pattern = casesRank.getSysCreateTime().getMonthValue() < 10 ? "yyyy年M月" : "yyyy年MM月";
|
||||
List<CaseViewRankingItemVo> viewRankTags = viewsRankRecords.stream().map(casesRank -> {
|
||||
String pattern = casesRank.getRiseRankTime().getMonthValue() < 10 ? "yyyy年M月" : "yyyy年MM月";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
String time = casesRank.getSysCreateTime().format(formatter);
|
||||
String time = casesRank.getRiseRankTime().format(formatter);
|
||||
|
||||
// 2023年6月 经营管理类 浏览量 TOP1
|
||||
String viewRankTag = time + casesRank.getMajorName() + "类浏览量TOP" + (casesRank.getRank() + 1);
|
||||
return viewRankTag;
|
||||
|
||||
CaseViewRankingItemVo caseViewRankingItemVo = new CaseViewRankingItemVo();
|
||||
caseViewRankingItemVo.setMajorId(casesRank.getMajorId());
|
||||
caseViewRankingItemVo.setMajorName(casesRank.getMajorName());
|
||||
caseViewRankingItemVo.setTagName(viewRankTag);
|
||||
caseViewRankingItemVo.setRiseRankTime(casesRank.getRiseRankTime());
|
||||
|
||||
return caseViewRankingItemVo;
|
||||
}).collect(Collectors.toList());
|
||||
e.setViewRankTags(viewRankTags);
|
||||
|
||||
@@ -480,45 +457,9 @@ public class CasesServiceImpl implements ICasesService {
|
||||
pageList.setCount((int) cases.getTotalElements());
|
||||
pageList.setPageSize(cases.getSize());
|
||||
List<Cases> content = cases.getContent();
|
||||
List<String> caseIds = content.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
String userId = caseVo.getUserId();
|
||||
if (CollUtil.isNotEmpty(caseIds)) {
|
||||
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
|
||||
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.eq("pushUserId", userId));
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
.addOrder("sysCreateTime", OrderDirection.DESC)
|
||||
.addGroupBy("caseId");
|
||||
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
|
||||
if (CollUtil.isNotEmpty(pushRecords)) {
|
||||
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
|
||||
List<IFieldFilter> recommendFilters = new ArrayList<>();
|
||||
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
recommendFilters.add(FieldFilters.in("id", rIds));
|
||||
builder.addFilters(recommendFilters);
|
||||
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
|
||||
if (CollUtil.isNotEmpty(recommands)) {
|
||||
Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item->item));
|
||||
content.forEach(it -> {
|
||||
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
|
||||
if (Objects.nonNull(one)) {
|
||||
CasesRecommend recommend = collect.get(one.getRecommendId());
|
||||
it.setBreCommend(1);
|
||||
it.setRefId(one.getId());
|
||||
it.setRecommendOrgName(recommend.getRecommendOrgName());
|
||||
it.setSysCreateTime(recommend.getRecommendTime());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
addAuthorTagAndCaseNewTag(content);
|
||||
addTags(content, caseVo.getUserId());
|
||||
|
||||
pageList.setList(content);
|
||||
return pageList;
|
||||
}
|
||||
@@ -1013,11 +954,12 @@ public class CasesServiceImpl implements ICasesService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cases> ids(List<String> ids) {
|
||||
public List<Cases> ids(List<String> ids, String accountId) {
|
||||
QueryBuilder builder = QueryBuilder.from(Cases.class);
|
||||
builder.addFilter(FieldFilters.in("id", ids));
|
||||
builder.addFields("new Cases(id,title,summary,coverUrl,authorId,authorName,sysCreateTime,breCommend,views,comments,praises,shares,favorites,deleted,sysCreateBy,sysCreateAid)");
|
||||
List<Cases> cases = casesDao.findList(builder.builder());
|
||||
cases = addTags(cases, accountId);
|
||||
return cases;
|
||||
}
|
||||
|
||||
@@ -1246,7 +1188,7 @@ public class CasesServiceImpl implements ICasesService {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Cases> queryPopularityOfMajor(Integer pageSize, Long majorId, LocalDateTime month) {
|
||||
public List<Cases> queryPopularityOfMajor(Integer pageSize, Long majorId, LocalDateTime month, String accountId) {
|
||||
if (pageSize == null) {
|
||||
pageSize = 10;
|
||||
}
|
||||
@@ -1259,51 +1201,70 @@ public class CasesServiceImpl implements ICasesService {
|
||||
query.addFilter(FieldFilters.in("id",caseIdList));
|
||||
query.addFilter(FieldFilters.eq("deleted",false));
|
||||
|
||||
List<Cases> casesList = casesDao.findList(query.builder());
|
||||
List<Cases> casesList = casesDao.findList(query.builder());
|
||||
casesList = addTags(casesList, accountId);
|
||||
|
||||
if (CollUtil.isNotEmpty(casesList)) {
|
||||
List<String> caseIds = casesList.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
|
||||
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
return casesList;
|
||||
}
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
private List<Cases> addTags(List<Cases> casesList, String accountId) {
|
||||
if (CollUtil.isEmpty(casesList)) {
|
||||
return casesList;
|
||||
}
|
||||
//1.推荐案例处理,获取的数据主要用于生成推荐案例标签
|
||||
recommendCasesTagDataHandle(casesList, accountId);
|
||||
//2.标签处理,添加作者标签和新的案例标签
|
||||
addAuthorTagAndCaseNewTag(casesList);
|
||||
|
||||
return casesList;
|
||||
}
|
||||
|
||||
private void recommendCasesTagDataHandle(List<Cases> casesList, String accountId) {
|
||||
if (StrUtil.isNotBlank(accountId)) {
|
||||
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
QueryBuilder queryBuilder = QueryBuilder.from(CasesRecommendPushRecord.class)
|
||||
.addField("new CasesRecommendPushRecord(id,recommendId,caseId)")
|
||||
.addFilters(Arrays.asList(
|
||||
FieldFilters.eq("pushUserId", accountId),
|
||||
FieldFilters.in("caseId", caseIdList),
|
||||
FieldFilters.eq("pushStatus", 3),
|
||||
FieldFilters.eq("deleted", Boolean.FALSE)
|
||||
))
|
||||
.addOrder("sysCreateTime", OrderDirection.DESC)
|
||||
.addGroupBy("caseId");
|
||||
|
||||
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
|
||||
|
||||
if (CollUtil.isNotEmpty(pushRecords)) {
|
||||
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
|
||||
builder.addField("new CasesRecommend(id,recommendOrgName)");
|
||||
List<IFieldFilter> recommendFilters = new ArrayList<>();
|
||||
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
recommendFilters.add(FieldFilters.in("id", rIds));
|
||||
builder.addFilters(recommendFilters);
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class)
|
||||
.addField("new CasesRecommend(id,recommendOrgName,recommendTime)")
|
||||
.addFilters(Arrays.asList(
|
||||
FieldFilters.eq("deleted", Boolean.FALSE),
|
||||
FieldFilters.in("id", rIds)
|
||||
));
|
||||
|
||||
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
|
||||
if (CollUtil.isNotEmpty(recommands)) {
|
||||
Map<String, String> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), v -> v.getRecommendOrgName()));
|
||||
Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item -> item));
|
||||
casesList.forEach(it -> {
|
||||
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
|
||||
if (Objects.nonNull(one)) {
|
||||
String recommendOrgName = collect.get(one.getRecommendId());
|
||||
CasesRecommend recommend = collect.get(one.getRecommendId());
|
||||
it.setBreCommend(1);
|
||||
it.setRecommendOrgName(recommendOrgName);
|
||||
it.setRefId(one.getId());
|
||||
it.setRecommendOrgName(recommend.getRecommendOrgName());
|
||||
it.setSysCreateTime(recommend.getRecommendTime());
|
||||
} else {
|
||||
it.setBreCommend(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
addAuthorTagAndCaseNewTag(casesList);
|
||||
}
|
||||
|
||||
return casesList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CasesQueryRecommendRankVo> queryRecommendRank() {
|
||||
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
|
||||
@@ -1406,6 +1367,54 @@ public class CasesServiceImpl implements ICasesService {
|
||||
recommendRank.forEach(casesDao::update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageList<FavoriteCaseDto> queryFavoriteCaseOfIndex(Integer pageIndex, Integer pageSize, String order, String aid) {
|
||||
String from = Favorites.class.getSimpleName()+" f,"+ Cases.class.getSimpleName()+" c";
|
||||
QueryBuilder builder = QueryBuilder.from(from);
|
||||
builder.addFields("f.id","f.sysCreateTime","c");
|
||||
|
||||
builder.addFilter(FieldFilters.eqField("f.objId","c.id"));
|
||||
builder.addFilter(FieldFilters.eq("f.objType", BoedxResourceType.Case.value()));
|
||||
builder.addFilter(FieldFilters.eq("f.sysCreateAid",aid));
|
||||
builder.addFilter(FieldFilters.eq("c.deleted", false));
|
||||
|
||||
if ("desc".equals(order)){
|
||||
builder.addOrder(OrderCondition.desc("f.sysCreateTime"));
|
||||
}else if ("asc".equals(order)){
|
||||
builder.addOrder(OrderCondition.asc("f.sysCreateTime"));
|
||||
}
|
||||
|
||||
builder.setPageIndex(pageIndex);
|
||||
builder.setPageSize(pageSize);
|
||||
|
||||
PageList<Object[]> pageFields=null;
|
||||
try {
|
||||
pageFields = casesDao.findPageFields(builder.builder());
|
||||
} catch (Exception e) {
|
||||
log.error("收藏案例查询错误",e);
|
||||
}
|
||||
|
||||
List<Object[]> list = pageFields.getList();
|
||||
// 提取出 Cases 对象,添加标签
|
||||
List<Cases> casesList = list.stream().map(o -> (Cases) o[2]).collect(Collectors.toList());
|
||||
casesList = addTags(casesList, aid);
|
||||
Map<String, Cases> caseMap = casesList.stream().collect(Collectors.toMap(Cases::getId, Function.identity()));
|
||||
|
||||
PageList<FavoriteCaseDto> favoriteCaseDtoPageList = new PageList<>();
|
||||
favoriteCaseDtoPageList.setList(new ArrayList<>());
|
||||
favoriteCaseDtoPageList.setPageSize(pageSize);
|
||||
favoriteCaseDtoPageList.setCount(pageFields.getCount());
|
||||
for (Object[] o: list) {
|
||||
FavoriteCaseDto favoriteCaseDto = new FavoriteCaseDto();
|
||||
favoriteCaseDto.setId(o[0].toString());
|
||||
favoriteCaseDto.setTime(LocalDateTime.parse(o[1].toString()));
|
||||
Cases cases = caseMap.get(((Cases) o[2]).getId());
|
||||
favoriteCaseDto.setCases(cases);
|
||||
favoriteCaseDtoPageList.getList().add(favoriteCaseDto);
|
||||
}
|
||||
|
||||
return favoriteCaseDtoPageList;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CaseViewRankingItemVo {
|
||||
|
||||
private Long majorId;
|
||||
|
||||
private String majorName;
|
||||
|
||||
private LocalDateTime riseRankTime;
|
||||
|
||||
private String tagName;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user