| | |
| | | package com.gkhy.exam.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.exam.common.api.CommonPage; |
| | | import com.gkhy.exam.common.api.CommonResult; |
| | | import com.gkhy.exam.common.exception.ApiException; |
| | | import com.gkhy.exam.common.utils.SecurityUtils; |
| | | import com.gkhy.exam.system.domain.Catalogue; |
| | | import com.gkhy.exam.system.domain.CatalogueData; |
| | | import com.gkhy.exam.system.domain.CatalogueDataFile; |
| | | import com.gkhy.exam.system.domain.SysCompany; |
| | | import com.gkhy.exam.system.domain.*; |
| | | import com.gkhy.exam.system.domain.req.CatalogueDataReq; |
| | | import com.gkhy.exam.system.domain.req.CatalogueReq; |
| | | import com.gkhy.exam.system.domain.vo.CatalogueDataVo; |
| | | import com.gkhy.exam.system.domain.vo.CatalogueVo; |
| | | import com.gkhy.exam.system.mapper.CatalogueMapper; |
| | | import com.gkhy.exam.system.mapper.CompanyIndustryTemplateMapper; |
| | | import com.gkhy.exam.system.mapper.SysCompanyMapper; |
| | | import com.gkhy.exam.system.service.CatalogueService; |
| | | import com.gkhy.exam.system.service.SysCompanyService; |
| | |
| | | private CatalogueMapper catalogueMapper; |
| | | @Autowired |
| | | private SysCompanyMapper sysCompanyMapper; |
| | | @Autowired |
| | | private CompanyIndustryTemplateMapper companyIndustryTemplateMapper; |
| | | |
| | | /** |
| | | * 目录管理 |
| | |
| | | private List<CatalogueVo> getchildren(CatalogueVo catalogueVo, List<CatalogueVo> catalogueVos) { |
| | | List<CatalogueVo> catalogueCharlden = new ArrayList<>(); |
| | | for (CatalogueVo catalogue : catalogueVos) { |
| | | if (catalogueVo.getId() == catalogue.getParentId()){ |
| | | if (catalogueVo.getId().equals(catalogue.getParentId())){ |
| | | catalogueCharlden.add(catalogue); |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public CommonResult insertCatalogue(Catalogue catalogue) { |
| | | if (catalogue.getType()==2||catalogue.getType()==3){ |
| | | if (catalogue.getCompanyId()==null){ |
| | | throw new ApiException("企业id不能为空"); |
| | | } |
| | | } |
| | | catalogue.setCreateBy(SecurityUtils.getUsername()); |
| | | catalogue.setCreateTime(LocalDate.now()); |
| | | int insert = catalogueMapper.insert(catalogue); |
| | |
| | | |
| | | @Override |
| | | public CommonResult insertCatalogueDataFile(CatalogueDataFile catalogueDataFile) { |
| | | CompanyIndustryTemplate companyIndustryTemplate = companyIndustryTemplateMapper.selectCompanyIndustryTemplate(catalogueDataFile.getName()); |
| | | if (companyIndustryTemplate!=null){ |
| | | catalogueDataFile.setFilePath(companyIndustryTemplate.getFilePath()); |
| | | catalogueDataFile.setFileName(companyIndustryTemplate.getFileName()); |
| | | } |
| | | catalogueDataFile.setCreateTime(LocalDate.now()); |
| | | catalogueDataFile.setCreateBy(SecurityUtils.getUsername()); |
| | | catalogueMapper.insertCatalogueDataFile(catalogueDataFile); |
| | |
| | | |
| | | @Override |
| | | public CommonResult updateCatalogueDataFile(CatalogueDataFile catalogueDataFile) { |
| | | CompanyIndustryTemplate companyIndustryTemplate = companyIndustryTemplateMapper.selectCompanyIndustryTemplate(catalogueDataFile.getName()); |
| | | if (companyIndustryTemplate!=null){ |
| | | catalogueDataFile.setFilePath(companyIndustryTemplate.getFilePath()); |
| | | catalogueDataFile.setFileName(companyIndustryTemplate.getFileName()); |
| | | }else { |
| | | catalogueDataFile.setFileName(null); |
| | | catalogueDataFile.setFilePath(null); |
| | | } |
| | | catalogueDataFile.setCreateBy(SecurityUtils.getUsername()); |
| | | catalogueDataFile.setCreateTime(LocalDate.now()); |
| | | catalogueDataFile.setUpdateBy(SecurityUtils.getUsername()); |
| | | catalogueDataFile.setUpdateTime(LocalDate.now()); |
| | | catalogueMapper.updateCatalogueDataFile(catalogueDataFile); |
| | | catalogueMapper.deleteByCatalogueDataFileId(catalogueDataFile.getId()); |
| | | catalogueMapper.insertCatalogueDataFile(catalogueDataFile); |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | |
| | | public CommonResult selectCatalogueDataFileList(CatalogueReq catalogueReq) { |
| | | return CommonResult.success(catalogueMapper.selectCatalogueDataFile(catalogueReq.getCompanyId(),catalogueReq.getCatalogueId())); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult copyCatalogue(List<CatalogueVo> catalogue) { |
| | | Integer companyId = catalogue.get(0).getCompanyId(); |
| | | catalogueMapper.delete(Wrappers.<Catalogue>lambdaQuery().eq(Catalogue::getCompanyId,companyId)); |
| | | for (CatalogueVo catalogueVo : catalogue) { |
| | | Catalogue catalogue1 = new Catalogue(); |
| | | BeanUtils.copyProperties(catalogueVo,catalogue1); |
| | | catalogueMapper.insertCatalogue(catalogue1); |
| | | List<CatalogueVo> children = catalogueVo.getChildren(); |
| | | if (children.size()>0){ |
| | | saveCatalogue(children,catalogue1); |
| | | } |
| | | } |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | | private void saveCatalogue(List<CatalogueVo> children,Catalogue catalogue) { |
| | | for (CatalogueVo child : children) { |
| | | Catalogue catalogue1 = new Catalogue(); |
| | | BeanUtils.copyProperties(child,catalogue1); |
| | | catalogue1.setParentId(catalogue.getId()); |
| | | catalogue1.setCompanyId(catalogue.getCompanyId()); |
| | | catalogueMapper.insertCatalogue(catalogue1); |
| | | List<CatalogueVo> children1 = child.getChildren(); |
| | | if (children1.size()>0){ |
| | | saveCatalogue(children1,catalogue1); |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |