package com.fdkankan.fusion.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.fdkankan.fusion.common.util.UploadToOssUtil;
import com.fdkankan.fusion.entity.CaseFiles;
import com.fdkankan.fusion.entity.CaseOverview;
import com.fdkankan.fusion.entity.CaseTabulation;
import com.fdkankan.fusion.httpClient.client.FdKKClient;
import com.fdkankan.fusion.httpClient.request.AddMediaLibraryParam;
import com.fdkankan.fusion.mapper.ICaseTabulationMapper;
import com.fdkankan.fusion.request.ExportOverviewParam;
import com.fdkankan.fusion.service.ICaseFilesService;
import com.fdkankan.fusion.service.ICaseOverviewService;
import com.fdkankan.fusion.service.ICaseTabulationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
*
* 服务实现类
*
*
* @author
* @since 2025-05-13
*/
@Service
public class CaseTabulationServiceImpl extends ServiceImpl implements ICaseTabulationService {
@Autowired
ICaseFilesService caseFilesService;
@Autowired
ICaseOverviewService caseOverviewService;
@Autowired
FdKKClient fdKKClient;
@Autowired
UploadToOssUtil uploadToOssUtil;
@Override
public List getByCaseId(String caseId) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CaseTabulation::getCaseId,caseId);
wrapper.orderByDesc(CaseTabulation::getId);
return this.list(wrapper);
}
@Override
public List getByOverviewId(String overviewId) {
LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CaseTabulation::getOverviewId,overviewId);
wrapper.orderByDesc(CaseTabulation::getId);
return this.list(wrapper);
}
@Override
public void addOrUpdate(CaseTabulation caseTabulation) {
this.saveOrUpdate(caseTabulation);
caseTabulation = this.getById(caseTabulation.getId());
if(StringUtils.isNotBlank(caseTabulation.getTitle()) && caseTabulation.getOverviewId() != null){
caseOverviewService.updateTitleById(caseTabulation.getOverviewId(),caseTabulation.getTitle());
}
if(StringUtils.isNotBlank(caseTabulation.getListCover()) && caseTabulation.getOverviewId() != null){
caseOverviewService.updateListCoverById(caseTabulation.getOverviewId(),caseTabulation.getListCover());
}
caseFilesService.addOrUpdateOver(caseTabulation);
}
@Override
public void updateTitleById(Integer tabulationId, String filesTitle) {
LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(CaseTabulation::getId,tabulationId);
wrapper.set(CaseTabulation::getTitle,filesTitle);
this.update(wrapper);
}
@Override
public void updateCaseByOverIds(List overviewIds, Integer caseId) {
LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>();
wrapper.in(CaseTabulation::getOverviewId,overviewIds);
wrapper.set(CaseTabulation::getCaseId,caseId);
this.update(wrapper);
}
@Override
public void updateCaseByIds(List tabulationIds, Integer caseId) {
LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>();
wrapper.in(CaseTabulation::getId,tabulationIds);
wrapper.set(CaseTabulation::getCaseId,caseId);
this.update(wrapper);
}
@Override
public Long getNo(Long sysUserId) {
LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(CaseTabulation::getSysUserId,sysUserId);
return this.count(wrapper);
}
}