package com.sptg.estate.api.dto;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.estate.api.entity.Agency;
import com.sptg.estate.api.entity.Residential;
import com.sptg.permissions.api.entity.Account;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * title: AgencyDto
 * package: com.sptg.estate.api.dto
 * description: 社区 业务传输对象
 *
 *
 *
 */
@Getter
@Setter
public class AgencyDto extends Agency {

    /**
     * 分页条件
     */
    @TableField(exist = false)
    private Page<Agency> page;

    /**
     * 排序条件
     */
    @TableField(exist = false)
    private String sortField;

    /**
     * 排序顺序
     */
    @TableField(exist = false)
    private String sortOrder;

    /**
     * 当前登陆用户
     */
    @TableField(exist = false)
    private Account onLineUser;

    /**
     * 所选树节点Id
     */
    @TableField(exist = false)
    private Long selectTreeId;

    /**
     * 批量删除所选id集合
     */
    @TableField(exist = false)
    private List<String> ids;

    /**
     * 省市区名称拼接
     */
    @TableField(exist = false)
    private String region;


    /**
     * 导入数据产生错误的原因信息
     */
    @TableField(exist = false)
    private String importErrorMsg;

    public void setAgency(Agency agency){
        if (StringUtils.isNotBlank(agency.getAgencyName())){
            this.setAgencyName(agency.getAgencyName());
        }
        if (StringUtils.isNotBlank(agency.getAgencyNo())){
            this.setAgencyNo(agency.getAgencyNo());
        }
        if (StringUtils.isNotBlank(agency.getAgencyArea())){
            this.setAgencyArea(agency.getAgencyArea());
        }

        if (StringUtils.isNotBlank(agency.getPersonName())){
            this.setPersonName(agency.getPersonName());
        }
        if (StringUtils.isNotBlank(agency.getPersonPhone())){
            this.setPersonPhone(agency.getPersonPhone());
        }

        if (StringUtils.isNotBlank(agency.getRemark())){
            this.setRemark(agency.getRemark());
        }
        if (agency.getCreateDate() != null){
            this.setCreateDate(agency.getCreateDate());
        }

        if (agency.getStatus() != null){
            this.setStatus(agency.getStatus());
        }

        if (agency.getResidentialCount() != null){
            this.setResidentialCount(agency.getResidentialCount());
        }

        if (agency.getUnitCount() != null){
            this.setUnitCount(agency.getUnitCount());
        }

        if (agency.getRoomCount() != null){
            this.setRoomCount(agency.getRoomCount());
        }

        if (agency.getPersonCount() != null){
            this.setPersonCount(agency.getPersonCount());
        }

        if (agency.getCarCount() != null){
            this.setCarCount(agency.getCarCount());
        }

        if (StringUtils.isNotBlank(agency.getRegionProvince())){
            this.setRegionProvince(agency.getRegionProvince());
        }
        if (StringUtils.isNotBlank(agency.getRegionCity())){
            this.setRegionCity(agency.getRegionCity());
        }
        if (StringUtils.isNotBlank(agency.getRegionArea())){
            this.setRegionArea(agency.getRegionArea());
        }
        if (StringUtils.isNotBlank(agency.getAddress())){
            this.setAddress(agency.getAddress());
        }
        if (StringUtils.isNotBlank(agency.getLongitude())){
            this.setLongitude(agency.getLongitude());
        }
        if (StringUtils.isNotBlank(agency.getLatitude())){
            this.setLatitude(agency.getLatitude());
        }
        if (StringUtils.isNotBlank(agency.getPic())){
            this.setPic(agency.getPic());
        }
        if (StringUtils.isNotBlank(agency.getRegionStreet())){
            this.setRegionStreet(agency.getRegionStreet());
        }
        if (StringUtils.isNotBlank(agency.getOrgPosition())){
            this.setOrgPosition(agency.getOrgPosition());
        }
        if (agency.getRootOrgId() != null){
            this.setRootOrgId(agency.getRootOrgId());
        }
        if (agency.getOrgPid() != null){
            this.setOrgPid(agency.getOrgPid());
        }
        if (StringUtils.isNotBlank(agency.getProvinceName())){
            this.setProvinceName(agency.getProvinceName());
        }
        if (StringUtils.isNotBlank(agency.getCityName())){
            this.setCityName(agency.getCityName());
        }
        if (StringUtils.isNotBlank(agency.getAreaName())){
            this.setAreaName(agency.getAreaName());
        }
        if (StringUtils.isNotBlank(agency.getStreetName())){
            this.setStreetName(agency.getStreetName());
        }
        if (StringUtils.isNotBlank(agency.getOrgName())){
            this.setOrgName(agency.getOrgName());
        }
    }

}
