package com.xxfc.platform.vehicle.pojo;

import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.entity.SysRegion;
import lombok.Data;

import java.util.List;

@Data
public class CompanyDetail extends BranchCompany {
    List<SysRegion> sysRegions;

    public String detailAddr() {
        StringBuilder detailAddrStr = new StringBuilder("");
        if(null != this.getSysRegions() && this.getSysRegions().size() > 0) {
            for(SysRegion sysRegion : this.getSysRegions()) {
                String name = sysRegion.getName()
                        .replace("省", "")
                        .replace("市", "")
                        .replace("县", "")
                        .replace("区", "");
                if( !detailAddrStr.toString().contains(name)) {
                    detailAddrStr.append(sysRegion.getName());
                }
            }
        }
        if(this.getAddrDetail().contains(detailAddrStr)) {
            return this.getAddrDetail();
        }
        detailAddrStr.append(this.getAddrDetail());
        return detailAddrStr.toString();
    }
}