package com.sptg.gateway.util;

import com.sptg.ad.api.entity.AdPushApp;
import com.sptg.device.api.entity.Device;
import com.sptg.estate.api.entity.*;
import com.sptg.gateway.entity.*;
import com.sptg.pay.api.entity.PayCertificate;
import org.springframework.beans.BeanUtils;


/**
 * title: PojoToApi
 * package: com.sptg.estate.biz.security
 * description: 实体对象转Api接口数据对象
 *
 *
 *
 */
public class PojoToApi {

    public static MemberApi memberToApi(Member member){
        MemberApi m = new MemberApi();
        m.setId(member.getId());
        m.setName(member.getName());
        m.setTel(member.getTel());
        m.setSex(member.getSex());
        m.setState(member.getState());
        m.setCreateDate(member.getCreateDate());
        m.setHeadImage(member.getHeadImage());
        m.setIdcard(member.getIdcard());
        m.setBirthday(member.getBirthday());
        if(member.getVideoCallAccount()!=null){
            m.setVideoCallAccountApi(PojoToApi.videoCallAccountToApi(member.getVideoCallAccount()));
        }
        return m;
    }

    public static ResidentialApi residentialToApi(Residential residential){
        ResidentialApi r = new ResidentialApi();
        r.setId(residential.getId());
        r.setName(residential.getName());
        r.setRegion(residential.getRegion());
        r.setAddress(residential.getAddress());
        r.setRemark(residential.getRemark());
        return r;
    }

    public static BuildingApi buildingToApi(Building building){
        BuildingApi b = new BuildingApi();
        b.setId(building.getId());
        b.setName(building.getName());
        b.setResidentialName(building.getResidentialName());
        return b;
    }

    public static UnitApi unitToApi(Unit unit){
        UnitApi u = new UnitApi();
        u.setId(unit.getId());
        u.setName(unit.getName());
        u.setResidentialName(unit.getResidentialName());
        return u;
    }

    public static RoomApi roomToApi(Room room){
        RoomApi r = new RoomApi();
        r.setId(room.getId());
        r.setName(room.getName());
        r.setRelationshipType(room.getRelationshipType());
        r.setBuildingName(room.getBuildingName());
        r.setUnitName(room.getUnitName());
        r.setResidentialName(room.getResidentialName());
        r.setHouseType(room.getHouseType());
        r.setOrnament(room.getOrnament());
        r.setOrientation(room.getOrientation());
        r.setArea(room.getArea());
        r.setRemark(room.getRemark());
        r.setResidentialId(room.getResidentialId());

        r.setImageUri(room.getImageUri());
        r.setFaceEnable(room.getFaceEnable());
        r.setUserId(room.getUserId());
        r.setIdcard(room.getIdcard());
        return r;
    }

    public static RoomApi roomToApi(Room room,Integer doorNeedAudit,String personTel){
        RoomApi r = new RoomApi();
        r.setId(room.getId());
        r.setName(room.getName());
        r.setRelationshipType(room.getRelationshipType());
        r.setBuildingName(room.getBuildingName());
        r.setUnitName(room.getUnitName());
        r.setResidentialName(room.getResidentialName());
        r.setHouseType(room.getHouseType());
        r.setOrnament(room.getOrnament());
        r.setOrientation(room.getOrientation());
        r.setArea(room.getArea());
        r.setRemark(room.getRemark());
        r.setResidentialId(room.getResidentialId());
        r.setDoorNeedAudit(doorNeedAudit);
        r.setImageUri(room.getImageUri());
        r.setFaceEnable(room.getFaceEnable());
        r.setUserId(room.getUserId());
        r.setIdcard(room.getIdcard());
        r.setPersonTel(personTel);
        return r;
    }

    public static AccessRecordsApi accessRecordsToApi(AccessRecords accessRecords){
        AccessRecordsApi a = new AccessRecordsApi();
        a.setId(accessRecords.getId());
        a.setDeviceName(accessRecords.getDeviceName());
        a.setInstallPath(accessRecords.getInstallPath());
        a.setAccessCardNo(accessRecords.getAccessCardNo());
        a.setAccessDate(accessRecords.getAccessDate());
        a.setIsOut(accessRecords.getIsOut());
        a.setAccessUserType(accessRecords.getAccessUserType());
        return a;
    }

    public static ApplyUserApi applyUserToApi(ApplyUser applyUser){
        ApplyUserApi a = new ApplyUserApi();
        a.setId(applyUser.getId());
        a.setMemberId(applyUser.getMemberId());
        a.setName(applyUser.getName());
        a.setRoomId(applyUser.getRoomId());
        a.setRoomName(applyUser.getRoomName());
        a.setBuildingId(applyUser.getBuildingId());
        a.setBuildingName(applyUser.getBuildingName());
        a.setUnitName(applyUser.getUnitName());
        a.setResidentialId(applyUser.getResidentialId());
        a.setResidentialName(applyUser.getResidentialName());
        a.setCheckState(applyUser.getCheckState());
        a.setCheckOpinion(applyUser.getCheckOpinion());
        a.setType(applyUser.getType());
        a.setIdCard(applyUser.getIdCard());
        a.setCreateDate(applyUser.getCreateDate());
        a.setTel(applyUser.getTel());
        a.setSex(applyUser.getSex());
        a.setNationality(applyUser.getNationality());
        a.setPassportImgUri(applyUser.getPassportImgUri());
        a.setEntryImgUri(applyUser.getEntryImgUri());
        a.setImageUri(applyUser.getImageUri());
        return a;
    }

    public static GuestAuthorizeApi guestAuthorizeToApi(GuestAuthorize guestAuthorize){
        GuestAuthorizeApi g = new GuestAuthorizeApi();
        g.setId(guestAuthorize.getId());
        g.setGuestType(guestAuthorize.getGuestType());
        g.setRoomName(guestAuthorize.getRoomName());
        g.setUnitName(guestAuthorize.getUnitName());
        g.setBuildingName(guestAuthorize.getBuildingName());
        g.setResidentialName(guestAuthorize.getResidentialName());
        g.setPassword(guestAuthorize.getPassword());
        g.setBeginDate(guestAuthorize.getBeginDate());
        g.setEndDate(guestAuthorize.getEndDate());
        g.setValidCount(guestAuthorize.getValidCount());
        g.setCreateDate(guestAuthorize.getCreateDate());
        return g;
    }

    public static DeviceApi deviceToApi(Device device){
        DeviceApi d = new DeviceApi();
        d.setId(device.getId());
        d.setName(device.getName());
        d.setTypeNumber(device.getTypeNumber());
        d.setInstallPath(device.getInstallPath());
        d.setRemark(device.getRemark());
        d.setIsOut(device.getIsOut());
        d.setSerialNumber(device.getSerialNumber());
        d.setResidentialId(device.getXqId());
        d.setHaveCall(device.getHaveCall());
        return d;
    }

    public static UserApi userToApi(User user){
        UserApi u = new UserApi();
        u.setId(user.getId());
        u.setName(user.getName());
        u.setType(user.getType());
        u.setNationality(user.getNationality());
        u.setIdCard(user.getIdCard());
        u.setPassportImgUri(user.getPassportImgUri());
        u.setEntryImgUri(user.getEntryImgUri());
        u.setTel(user.getTel());
        u.setSex(user.getSex());
        u.setRoomId(user.getRoomId());
        u.setRoomName(user.getRoomName());
        u.setBuildingId(user.getBuildingId());
        u.setBuildingName(user.getBuildingName());
        u.setUnitName(user.getUnitName());
        u.setResidentialId(user.getResidentialId());
        u.setResidentialName(user.getResidentialName());
        u.setCreateDate(user.getCreateDate());
        u.setImageUri(user.getImageUri());
        u.setFaceEnable(user.getFaceEnable());
        return u;
    }

    public static VideoCallAccountApi videoCallAccountToApi(VideoCallAccount videoCallAccount){
        VideoCallAccountApi v = new VideoCallAccountApi();
        v.setAccountId(videoCallAccount.getAccountId());
        v.setAccountPwd(videoCallAccount.getAccountPwd());
        return v;
    }

    public static NoticePushApi noticePushToApi(NoticePush noticePush){
        NoticePushApi n = new NoticePushApi();
        n.setNoticeTitle(noticePush.getNoticeTitle());
        n.setNoticeContent(noticePush.getNoticeContent());
        n.setCreateDate(noticePush.getCreateDate());
        return n;
    }

    public static AdPushAppApi adPushAppToApi(AdPushApp a) {
        AdPushAppApi adPushAppApi = new AdPushAppApi();
        adPushAppApi.setId(a.getId());
        adPushAppApi.setAdTitle(a.getAdTitle());
        adPushAppApi.setVideoType(a.getVideoType());
        adPushAppApi.setVideoUri(a.getVideoUri());
        return adPushAppApi;
    }

    public static PayCertificateApi payCertificateToApi(PayCertificate payCertificate){
        PayCertificateApi payCertificateApi = new PayCertificateApi();
        BeanUtils.copyProperties(payCertificate,payCertificateApi);
        return payCertificateApi;
    }
}
