| package com.doumee.service.business.impl; | 
|   | 
| import com.doumee.biz.system.SystemDictDataBiz; | 
| import com.doumee.core.constants.ResponseStatus; | 
| import com.doumee.core.exception.BusinessException; | 
| import com.doumee.core.utils.Constants; | 
| import com.doumee.core.utils.Utils; | 
| import com.doumee.dao.business.CompanyDocumentsMapper; | 
| import com.doumee.dao.business.model.Category; | 
| import com.doumee.dao.business.model.Company; | 
| import com.doumee.dao.business.model.CompanyDocuments; | 
| import com.doumee.dao.business.model.Member; | 
| import com.doumee.dao.system.model.SystemUser; | 
| import com.doumee.service.business.CompanyDocumentsService; | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
| import com.baomidou.mybatisplus.core.metadata.IPage; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.doumee.service.business.third.model.LoginUserInfo; | 
| import com.doumee.service.business.third.model.PageData; | 
| import com.doumee.service.business.third.model.PageWrap; | 
| import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
| import org.apache.commons.lang3.StringUtils; | 
| import org.checkerframework.checker.units.qual.A; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.util.CollectionUtils; | 
|   | 
| import java.util.Date; | 
| import java.util.List; | 
| import java.util.Objects; | 
|   | 
| /** | 
|  * 隐患区域配置类型信息表Service实现 | 
|  * @author 江蹄蹄 | 
|  * @date 2025/06/27 16:01 | 
|  */ | 
| @Service | 
| public class CompanyDocumentsServiceImpl implements CompanyDocumentsService { | 
|   | 
|     @Autowired | 
|     private CompanyDocumentsMapper companyDocumentsMapper; | 
|   | 
|     @Autowired | 
|     private SystemDictDataBiz systemDictDataBiz; | 
|   | 
|     @Override | 
|     public Integer create(CompanyDocuments companyDocuments) { | 
|         if(Objects.isNull(companyDocuments) | 
|                 || Objects.isNull(companyDocuments.getCompanyId()) | 
|                 || Objects.isNull(companyDocuments.getCategoryId()) | 
|                 || StringUtils.isBlank(companyDocuments.getName()) | 
|                 || StringUtils.isBlank(companyDocuments.getFileurl()) | 
|         ){ | 
|             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|         } | 
|         companyDocuments.setId(null); | 
|         companyDocuments.setCreateDate(new Date()); | 
|         companyDocuments.setCreator(companyDocuments.getLoginUserInfo().getId()); | 
|         companyDocuments.setIsdeleted(Constants.ZERO); | 
|         companyDocuments.setStatus(Constants.ZERO); | 
|         companyDocumentsMapper.insert(companyDocuments); | 
|         return companyDocuments.getId(); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteById(Integer id, LoginUserInfo user) { | 
|         UpdateWrapper<CompanyDocuments> deleteWrapper = new UpdateWrapper<>(); | 
|         deleteWrapper.lambda().set(CompanyDocuments::getIsdeleted,Constants.ONE) | 
|                 .eq(CompanyDocuments::getId,id) | 
|                 .set(CompanyDocuments::getEditDate,new Date()) | 
|                 .set(CompanyDocuments::getEditor,user.getId()); | 
|         companyDocumentsMapper.update(deleteWrapper); | 
|     } | 
|   | 
|     @Override | 
|     public void delete(CompanyDocuments companyDocuments) { | 
|         UpdateWrapper<CompanyDocuments> deleteWrapper = new UpdateWrapper<>(companyDocuments); | 
|         companyDocumentsMapper.update(deleteWrapper); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) { | 
|         if (CollectionUtils.isEmpty(ids)) { | 
|             return; | 
|         } | 
|         companyDocumentsMapper.deleteBatchIds(ids); | 
|     } | 
|   | 
|     @Override | 
|     public void updateById(CompanyDocuments companyDocuments) { | 
|         if(Objects.isNull(companyDocuments) | 
|                 || Objects.isNull(companyDocuments.getId()) | 
|                 || Objects.isNull(companyDocuments.getCompanyId()) | 
|                 || Objects.isNull(companyDocuments.getCategoryId()) | 
|                 || StringUtils.isBlank(companyDocuments.getName()) | 
|                 || StringUtils.isBlank(companyDocuments.getFileurl()) | 
|         ){ | 
|             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|         } | 
|         companyDocuments.setId(null); | 
|         companyDocuments.setEditDate(new Date()); | 
|         companyDocuments.setEditor(companyDocuments.getLoginUserInfo().getId()); | 
|         companyDocumentsMapper.updateById(companyDocuments); | 
|     } | 
|   | 
|     @Override | 
|     public void updateByIdInBatch(List<CompanyDocuments> companyDocumentss) { | 
|         if (CollectionUtils.isEmpty(companyDocumentss)) { | 
|             return; | 
|         } | 
|         for (CompanyDocuments companyDocuments: companyDocumentss) { | 
|             this.updateById(companyDocuments); | 
|         } | 
|     } | 
|   | 
|     @Override | 
|     public CompanyDocuments findById(Integer id) { | 
|         CompanyDocuments companyDocuments = companyDocumentsMapper.selectById(id); | 
|         if(Objects.isNull(companyDocuments)){ | 
|             throw new BusinessException(ResponseStatus.DATA_EMPTY); | 
|         } | 
|         if(StringUtils.isNotBlank(companyDocuments.getFileurl())){ | 
|             String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_LOCAL_RESOURCE_PATH).getCode() | 
|                     +systemDictDataBiz.queryByCode(Constants.FTP,Constants.COMPANY_DOCUMENTS).getCode(); | 
|             companyDocuments.setFileurlFull(path + companyDocuments.getFileurl()); | 
|         } | 
|         return companyDocuments; | 
|     } | 
|   | 
|     @Override | 
|     public CompanyDocuments findOne(CompanyDocuments companyDocuments) { | 
|         QueryWrapper<CompanyDocuments> wrapper = new QueryWrapper<>(companyDocuments); | 
|         return companyDocumentsMapper.selectOne(wrapper); | 
|     } | 
|   | 
|     @Override | 
|     public List<CompanyDocuments> findList(CompanyDocuments companyDocuments) { | 
|         QueryWrapper<CompanyDocuments> wrapper = new QueryWrapper<>(companyDocuments); | 
|         return companyDocumentsMapper.selectList(wrapper); | 
|     } | 
|    | 
|     @Override | 
|     public PageData<CompanyDocuments> findPage(PageWrap<CompanyDocuments> pageWrap) { | 
|         IPage<CompanyDocuments> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         MPJLambdaWrapper<CompanyDocuments> queryWrapper = new MPJLambdaWrapper<>(); | 
|         Utils.MP.blankToNull(pageWrap.getModel()); | 
|         CompanyDocuments queryModel = pageWrap.getModel(); | 
|         queryWrapper.selectAll(CompanyDocuments.class) | 
|                 .selectAs(Company::getName,CompanyDocuments::getCompanyName) | 
|                 .selectAs(Category::getName,CompanyDocuments::getCategoryName) | 
|                 .selectAs(SystemUser::getRealname,CompanyDocuments::getCreatorName) | 
|                 .leftJoin(Company.class,Company::getId,CompanyDocuments::getCompanyId) | 
|                 .leftJoin(Category.class,Category::getId,CompanyDocuments::getCategoryId) | 
|                 .leftJoin(SystemUser.class,SystemUser::getId,CompanyDocuments::getCreator) | 
|                 .eq(CompanyDocuments::getIsdeleted,Constants.ZERO) | 
|                 .like(Objects.nonNull(queryModel)&&StringUtils.isNotBlank(queryModel.getName()),CompanyDocuments::getName,queryModel.getName()) | 
|                 .eq(Objects.nonNull(queryModel)&&Objects.nonNull(queryModel.getCategoryId()),CompanyDocuments::getCategoryId,queryModel.getCategoryId()) | 
|                 .eq(Objects.nonNull(queryModel)&&Objects.nonNull(queryModel.getCompanyId()),CompanyDocuments::getCompanyId,queryModel.getCompanyId()) | 
|                 .orderByDesc(CompanyDocuments::getSortnum) | 
|                 .orderByDesc(CompanyDocuments::getCreateDate); | 
|         IPage<CompanyDocuments> iPage = companyDocumentsMapper.selectJoinPage(page, CompanyDocuments.class,queryWrapper); | 
|         String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_LOCAL_RESOURCE_PATH).getCode() | 
|                 +systemDictDataBiz.queryByCode(Constants.FTP,Constants.COMPANY_DOCUMENTS).getCode(); | 
|         for (CompanyDocuments companyDocuments:iPage.getRecords()) { | 
|             companyDocuments.setFileurlFull(path + companyDocuments.getFileurl()); | 
|         } | 
|         return PageData.from(iPage); | 
|     } | 
|   | 
|     @Override | 
|     public long count(CompanyDocuments companyDocuments) { | 
|         QueryWrapper<CompanyDocuments> wrapper = new QueryWrapper<>(companyDocuments); | 
|         return companyDocumentsMapper.selectCount(wrapper); | 
|     } | 
| } |