Blame view

ServiceCompanyFilesServiceImpl.java 2.62 KB
涂亚平 committed
1 2
package com.subsidy.service.impl;

3 4 5 6 7 8
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.dto.company.CompanyFilesDTO;
import com.subsidy.dto.company.UploadFileDTO;
import com.subsidy.mapper.ServiceCompanyMappingMapper;
涂亚平 committed
9
import com.subsidy.mapper.ServiceFileTreeMapper;
涂亚平 committed
10 11
import com.subsidy.model.ServiceCompanyFilesDO;
import com.subsidy.mapper.ServiceCompanyFilesMapper;
12
import com.subsidy.model.ServiceCompanyMappingDO;
涂亚平 committed
13
import com.subsidy.model.ServiceFileTreeDO;
涂亚平 committed
14 15 16
import com.subsidy.service.ServiceCompanyFilesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
17 18
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
涂亚平 committed
19 20
import org.springframework.stereotype.Service;

涂亚平 committed
21
import java.util.ArrayList;
涂亚平 committed
22 23 24 25 26 27 28 29 30 31 32 33 34
import java.util.List;

/**
 * <p>
 * 协议管理材料表 服务实现类
 * </p>
 *
 * @author Tuyp
 * @since 2024-01-11
 */
@Service
public class ServiceCompanyFilesServiceImpl extends ServiceImpl<ServiceCompanyFilesMapper, ServiceCompanyFilesDO> implements ServiceCompanyFilesService {

35
    @Autowired
涂亚平 committed
36
    private ServiceFileTreeMapper serviceFileTreeMapper;
涂亚平 committed
37

38 39
    public IPage<ServiceCompanyFilesDO> companyFiles(CompanyFilesDTO companyFilesDTO) {
        Page pager = new Page(companyFilesDTO.getPageNum(), companyFilesDTO.getPageSize());
涂亚平 committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

        List<Long> treeIds = new ArrayList<>();
        treeIds.add(companyFilesDTO.getTreeId());

        ServiceFileTreeDO serviceFileTreeDO = serviceFileTreeMapper.selectById(companyFilesDTO.getTreeId());

        if (null == serviceFileTreeDO.getParentId()){
            //找出二级节点
            List<ServiceFileTreeDO> serviceFileTreeDOS = serviceFileTreeMapper.selectList(new QueryWrapper<ServiceFileTreeDO>()
                    .lambda()
                    .eq(ServiceFileTreeDO::getParentId,serviceFileTreeDO.getId()));
            for (ServiceFileTreeDO serviceFileTreeDO1 : serviceFileTreeDOS){
                treeIds.add(serviceFileTreeDO1.getId());
            }
        }
        return this.baseMapper.companyFiles(pager,treeIds, companyFilesDTO.getFileName());
涂亚平 committed
56 57 58 59 60 61 62
    }

    public String deleteFile(ServiceCompanyFilesDO serviceCompanyFilesDO) {
        this.baseMapper.deleteById(serviceCompanyFilesDO.getId());
        return ConstantUtils.DELETE_SUCCESS;
    }

涂亚平 committed
63
    public String uploadFile(ServiceCompanyFilesDO serviceCompanyFilesDO) {
涂亚平 committed
64 65 66 67 68
        this.baseMapper.insert(serviceCompanyFilesDO);
        return ConstantUtils.ADD_SUCCESS;
    }

}