84 lines
1.5 KiB
JavaScript
84 lines
1.5 KiB
JavaScript
// caseId: 1
|
|
// content: "11"
|
|
// createBy: null
|
|
// createTime: "2024-05-29 22:45:57"
|
|
// delFlag: 0
|
|
// description: "11"
|
|
// extField1: null
|
|
// extField2: null
|
|
// extField3: null
|
|
// extField4: null
|
|
// extField5: null
|
|
// imageUrl: "11"
|
|
// remark: null
|
|
// title: "11"
|
|
// updateBy: null
|
|
// updateTime: "2024-05-29 22:45:57"
|
|
// userId: 1
|
|
export const dataToList=(data,liks,collections)=>{
|
|
if (liks === undefined || liks === null) {
|
|
liks = null;
|
|
} else {
|
|
liks = liks.map(e => e.caseId);
|
|
// console.log("喜欢",liks);
|
|
}
|
|
|
|
if (collections === undefined || collections === null) {
|
|
collections = null;
|
|
} else {
|
|
collections = collections.map(e => e.caseId);
|
|
}
|
|
|
|
return data.map(e=>{
|
|
// console.log("单个",e);
|
|
return {
|
|
id:e.caseId,
|
|
title:e.title,
|
|
text:e.content,
|
|
cover:e.imageUrl,
|
|
data:e.createTime,
|
|
userName:"",
|
|
userId:e.userId,
|
|
isLike:isLike(e,liks),
|
|
likeNumber:0,
|
|
isComments:false,
|
|
commentsNumber:0,
|
|
isCollection:isCollections(e,collections),
|
|
collectionNumber:0,
|
|
}
|
|
})
|
|
|
|
}
|
|
/**
|
|
* 根据收藏列表判断是否收藏
|
|
*/
|
|
const isCollections=(data,csIds)=>{
|
|
if(csIds==null){
|
|
return false;
|
|
}
|
|
// console.log("收藏发现喜欢",data,csIds)
|
|
let iss=false;
|
|
csIds.forEach(e=>{
|
|
if(data.caseId==e){
|
|
// console.log("发现喜欢")
|
|
iss=true;
|
|
}
|
|
})
|
|
return iss;
|
|
}
|
|
/**
|
|
* 根据点赞列表判断是否点赞
|
|
*/
|
|
const isLike=(data,caseids)=>{
|
|
if(caseids==null){
|
|
return false;
|
|
}
|
|
let iss=false;
|
|
caseids.forEach(e=>{
|
|
if(data.caseId==e){
|
|
// console.log("发现喜欢")
|
|
iss=true;
|
|
}
|
|
})
|
|
return iss;
|
|
} |