| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.doumee.core.annotation.excel.ExcelColumn; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.admin.response.CompanyDTO; |
| | | import com.doumee.dao.business.CompanyMapper; |
| | | import com.doumee.dao.business.join.CompanyJoinMapper; |
| | | import com.doumee.dao.business.model.Category; |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 企业信息表Service实现 |
| | |
| | | return companyMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<CompanyDTO> findCompanyTreePage(Integer type) { |
| | | |
| | | LambdaQueryWrapper<Company> wrapper = new LambdaQueryWrapper<>(); |
| | | |
| | | wrapper.eq(Company::getIsdeleted,Constants.ZERO) |
| | | .eq(Constants.equalsInteger(type,Constants.ONE),Company::getType,type); |
| | | List<Company> companies = companyMapper.selectList(wrapper); |
| | | return getCompanyTree( companies, null); |
| | | } |
| | | |
| | | |
| | | private List<CompanyDTO> getCompanyTree(List<Company> companies, Integer parentId){ |
| | | if (CollectionUtils.isEmpty(companies)){ |
| | | return null; |
| | | } |
| | | List<Company> collect = companies.stream() |
| | | .filter(s -> Constants.equalsInteger(s.getParentId(), parentId)) |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isEmpty(companies)){ |
| | | return null; |
| | | } |
| | | List<CompanyDTO> companyDTOList = new ArrayList<>(); |
| | | for (int i = 0; i < collect.size(); i++) { |
| | | Company company = collect.get(i); |
| | | CompanyDTO companyDTO = new CompanyDTO(); |
| | | BeanUtils.copyProperties(company,companyDTO); |
| | | companyDTO.setCompanyDTOList(getCompanyTree(companies, company.getId())); |
| | | companyDTOList.add(companyDTO); |
| | | } |
| | | return companyDTOList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 劳务公司唯一性校验 |
| | | * @param company |