package top.imwork.window.silos.convert.upms;

import org.springframework.util.ObjectUtils;
import top.imwork.window.silos.entity.upms.Organization;
import top.imwork.window.silos.pojo.upms.bo.OrganizationBO;
import top.imwork.window.silos.pojo.upms.bo.OrganizationResultBO;
import top.imwork.window.silos.pojo.upms.dto.OrganizationListDTO;
import top.imwork.window.silos.pojo.upms.po.OrganizationListParamVO;
import top.imwork.window.silos.pojo.upms.po.OrganizationParamVO;
import top.imwork.window.silos.pojo.upms.vo.OrganizationResultVO;
import top.imwork.window.silos.pojo.upms.vo.OrganizationVO;
import top.imwork.window.silos.pojo.upms.dto.OrganizationDTO;

import java.util.ArrayList;
import java.util.List;

/**
 * 组织信息
 * 实体转换
 *
 * @author jiangxiaowei
 * email: e-jiangxiaowei@outlook.com
 * date: 2025-12-11 12:57:50
 */
public class OrganizationConvert {
    private OrganizationConvert() {}

    public static Organization organizationDtoToDo(OrganizationDTO organizationDTO) {
        if (organizationDTO == null) {
            return new Organization();
        }
        Organization organization = new Organization();
        return organization;
    }

    public static OrganizationBO organizationDoToBo(Organization organization) {
       if (organization == null) {
           return new OrganizationBO();
       }
       OrganizationBO organizationBO = new OrganizationBO();
       return organizationBO;
    }

    public static OrganizationDTO organizationParamVoToDto(OrganizationParamVO organizationParamVO) {
        if (organizationParamVO == null) {
            return new OrganizationDTO();
        }
        OrganizationDTO organizationDTO = new OrganizationDTO();
        return organizationDTO;
    }

    public static List<OrganizationBO> organizationListToOrganizationBOList(List<Organization> records) {
         if (ObjectUtils.isEmpty(records)) {
             return new ArrayList<>();
         }
         List<OrganizationBO> organizationBOList = new ArrayList<>();
         for (Organization organization : records) {
             organizationBOList.add(organizationDoToBo(organization));
         }
         return organizationBOList;
    }

    public static OrganizationVO organizationBoToVo(OrganizationBO organizationBO) {
         if (organizationBO == null) {
         return new OrganizationVO();
         }
         OrganizationVO organizationVO = new OrganizationVO();
         return organizationVO;
    }

    public static OrganizationListDTO organizationListParamVoToDTO(OrganizationListParamVO organizationListParamVO) {
        if (organizationListParamVO == null) {
            return new OrganizationListDTO();
        }
        OrganizationListDTO organizationListDTO = new OrganizationListDTO();
        organizationListDTO.setOrganizationName(organizationListParamVO.getOrganizationName());
        organizationListDTO.setPageNo(organizationListParamVO.getPageNo());
        organizationListDTO.setPageRows(organizationListParamVO.getPageRows());
        organizationListDTO.setDelFlag(organizationListParamVO.getDelFlag());
        organizationListDTO.setCreator(organizationListParamVO.getCreator());
        organizationListDTO.setCreateBeginTime(organizationListParamVO.getCreateBeginTime());
        organizationListDTO.setCreateEndTime(organizationListParamVO.getCreateEndTime());
        organizationListDTO.setModifier(organizationListParamVO.getModifier());
        organizationListDTO.setUpdateBeginTime(organizationListParamVO.getUpdateBeginTime());
        organizationListDTO.setUpdateEndTime(organizationListParamVO.getUpdateEndTime());
        organizationListDTO.setRemark(organizationListParamVO.getRemark());
        return organizationListDTO;
    }
        
    public static OrganizationListParamVO organizationListParamDtoToVo(OrganizationListDTO organizationListDTO) {
        if (organizationListDTO == null) {
            return new OrganizationListParamVO();
        }
        OrganizationListParamVO organizationListParamVO = new OrganizationListParamVO();
        organizationListParamVO.setOrganizationName(organizationListDTO.getOrganizationName());
        organizationListParamVO.setPageNo(organizationListDTO.getPageNo());
        organizationListParamVO.setPageRows(organizationListDTO.getPageRows());
        organizationListParamVO.setDelFlag(organizationListDTO.getDelFlag());
        organizationListParamVO.setCreator(organizationListDTO.getCreator());
        organizationListParamVO.setCreateBeginTime(organizationListDTO.getCreateBeginTime());
        organizationListParamVO.setCreateEndTime(organizationListDTO.getCreateEndTime());
        organizationListParamVO.setModifier(organizationListDTO.getModifier());
        organizationListParamVO.setUpdateBeginTime(organizationListDTO.getUpdateBeginTime());
        organizationListParamVO.setUpdateEndTime(organizationListDTO.getUpdateEndTime());
        organizationListParamVO.setRemark(organizationListDTO.getRemark());
        return organizationListParamVO;
    }

    private static List<OrganizationVO> organizationBoListToOrganizationVoList(List<OrganizationBO> dataList) {
        if (ObjectUtils.isEmpty(dataList)) {
            return new ArrayList<>();
        }
        List<OrganizationVO> organizationVOList = new ArrayList<>();
        for (OrganizationBO organizationBO : dataList) {
             organizationVOList.add(organizationBoToVo(organizationBO));
        }
        return organizationVOList;
    }

    public static OrganizationResultVO organizationResultBoToVo(OrganizationResultBO organizationResultBO) {
        if (organizationResultBO == null) {
            return new OrganizationResultVO();
        }
        OrganizationResultVO organizationResultVO = new OrganizationResultVO();
        organizationResultVO.setPageNo(organizationResultBO.getPageNo());
        organizationResultVO.setPageRows(organizationResultBO.getPageRows());
        organizationResultVO.setPageCount(organizationResultBO.getPageCount());
        organizationResultVO.setTotalRows(organizationResultBO.getTotalRows());
        organizationResultVO.setDataList(organizationBoListToOrganizationVoList(organizationResultBO.getDataList()));
        organizationResultVO.setParams(organizationListParamDtoToVo(organizationResultBO.getParams()));
        return organizationResultVO;
    }
}