1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package com.fdkankan.fusion.service.impl;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
- import com.fdkankan.fusion.common.ResultCode;
- import com.fdkankan.fusion.common.util.UploadToOssUtil;
- import com.fdkankan.fusion.entity.CaseOverview;
- import com.fdkankan.fusion.entity.CaseTabulation;
- import com.fdkankan.fusion.exception.BusinessException;
- import com.fdkankan.fusion.mapper.ICaseOverviewMapper;
- import com.fdkankan.fusion.service.ICaseOverviewService;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.fdkankan.fusion.service.ICaseTabulationService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.io.IOException;
- import java.util.List;
- import java.util.stream.Collectors;
- /**
- * <p>
- * 服务实现类
- * </p>
- *
- * @author
- * @since 2025-05-13
- */
- @Service
- public class CaseOverviewServiceImpl extends ServiceImpl<ICaseOverviewMapper, CaseOverview> implements ICaseOverviewService {
- @Autowired
- ICaseTabulationService caseTabulationService;
- @Autowired
- UploadToOssUtil uploadToOssUtil;
- @Override
- public List<CaseOverview> getByCaseId(Integer caseId) {
- LambdaQueryWrapper<CaseOverview> wrapper = new LambdaQueryWrapper<>();
- wrapper.eq(CaseOverview::getCaseId,caseId);
- wrapper.orderByDesc(CaseOverview::getId);
- return this.list(wrapper);
- }
- @Override
- public void del(Integer overviewId) {
- if(overviewId == null ){
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
- }
- CaseOverview caseOverview = this.getById(overviewId);
- if(caseOverview == null){
- return;
- }
- this.removeById(overviewId);
- this.delFile(caseOverview);
- List<CaseTabulation> caseTabulations = caseTabulationService.getByOverId(overviewId);
- if(!caseTabulations.isEmpty()){
- caseTabulationService.delByIds(caseTabulations.stream().map(CaseTabulation::getId).collect(Collectors.toList()));
- }
- }
- private void delFile(CaseOverview caseOverview) {
- List<CaseOverview> list = this.getByCover(caseOverview.getListCover());
- if(list.isEmpty()){
- uploadToOssUtil.delete(caseOverview.getListCover());
- }
- List<CaseOverview> list2 = this.getByCover(caseOverview.getKankanCover());
- if(list2.isEmpty()){
- uploadToOssUtil.delete(caseOverview.getKankanCover());
- }
- }
- private List<CaseOverview> getByCover(String listCover) {
- LambdaQueryWrapper<CaseOverview> wrapper = new LambdaQueryWrapper<>();
- wrapper.and(e -> e.eq(CaseOverview::getListCover,listCover).or().eq(CaseOverview::getKankanCover,listCover));
- return this.list(wrapper);
- }
- @Override
- public void updateTitleById(Integer overviewId, String filesTitle) {
- LambdaUpdateWrapper<CaseOverview> wrapper = new LambdaUpdateWrapper<>();
- wrapper.eq(CaseOverview::getId,overviewId);
- wrapper.set(CaseOverview::getTitle,filesTitle);
- this.update(wrapper);
- }
- }
|