/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.person.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.person.entity.ElderlyPeople;
import org.springblade.person.entity.HouseUser;
import org.springblade.person.service.HouseUserService;
import org.springblade.person.vo.ElderlyPeopleVO;

import java.util.Objects;

/**
 * 包装类,返回视图层所需的字段
 *
 * @author BladeX
 * @since 2021-04-14
 */
public class ElderlyPeopleWrapper extends BaseEntityWrapper<ElderlyPeople, ElderlyPeopleVO>  {

	private HouseUserService houseUserService;
	public ElderlyPeopleWrapper(){}
	public static ElderlyPeopleWrapper build() {
		return new ElderlyPeopleWrapper();
 	}

 	public ElderlyPeopleWrapper(HouseUserService houseUserService){this.houseUserService = houseUserService;}
 	public static ElderlyPeopleWrapper build(HouseUserService houseUserService){
		return new ElderlyPeopleWrapper(houseUserService);
	}

	@Override
	public ElderlyPeopleVO entityVO(ElderlyPeople elderlyPeople) {
		ElderlyPeopleVO elderlyPeopleVO = Objects.requireNonNull(BeanUtil.copy(elderlyPeople, ElderlyPeopleVO.class));

		HouseUser houseUser = houseUserService.getById(elderlyPeople.getParentId());
		elderlyPeopleVO.setAgencyId(houseUser.getAgencyId());
		elderlyPeopleVO.setAgencyName(houseUser.getAgencyName());
		elderlyPeopleVO.setBirthday(houseUser.getBirthday());
		elderlyPeopleVO.setBuildingId(houseUser.getBuildingId());
		elderlyPeopleVO.setBuildingName(houseUser.getBuildingName());
		elderlyPeopleVO.setResidentialId(houseUser.getResidentialId());
		elderlyPeopleVO.setResidentialName(houseUser.getResidentialName());
		elderlyPeopleVO.setFloorId(houseUser.getFloorId());
		elderlyPeopleVO.setFloorName(houseUser.getFloorName());
		elderlyPeopleVO.setResidentialName(houseUser.getFloorName());
		elderlyPeopleVO.setRoomId(houseUser.getRoomId());
		elderlyPeopleVO.setRoomName(houseUser.getRoomName());
		elderlyPeopleVO.setPhone(houseUser.getPhone());
		elderlyPeopleVO.setIdCard(houseUser.getIdCard());
		elderlyPeopleVO.setSex(houseUser.getSex());
		elderlyPeopleVO.setNation(houseUser.getNation());
		elderlyPeopleVO.setNativePlace(houseUser.getNativePlace());
		elderlyPeopleVO.setNationality(houseUser.getNationality());
		elderlyPeopleVO.setEntryImgUri(houseUser.getEntryImgUri());
		elderlyPeopleVO.setPassportImgUri(houseUser.getPassportImgUri());
		elderlyPeopleVO.setPolitical(houseUser.getPolitical());
		elderlyPeopleVO.setMaritalStatus(houseUser.getMaritalStatus());
		elderlyPeopleVO.setEducationalLevel(houseUser.getEducationalLevel());
		elderlyPeopleVO.setWorkplace(houseUser.getWorkplace());
		elderlyPeopleVO.setEmail(houseUser.getEmail());
		elderlyPeopleVO.setTags(houseUser.getTags());
		elderlyPeopleVO.setRemark(houseUser.getRemark());
		elderlyPeopleVO.setCreateType(houseUser.getCreateType());
		elderlyPeopleVO.setType(houseUser.getType());
		elderlyPeopleVO.setImageMd5(houseUser.getImageMd5());
		elderlyPeopleVO.setImageUri(houseUser.getFaceUrl());
		elderlyPeopleVO.setCheckState(houseUser.getAuditStatus());
		elderlyPeopleVO.setFaceEnable(houseUser.getFaceEnable());
		elderlyPeopleVO.setFaceBeginDate(houseUser.getFaceBeginDate());
		elderlyPeopleVO.setFaceEndDate(houseUser.getFaceEndDate());
		elderlyPeopleVO.setOldId(houseUser.getOldId());
		elderlyPeopleVO.setRegionProvince(houseUser.getRegionProvince());
		elderlyPeopleVO.setRegionCity(houseUser.getRegionCity());
		elderlyPeopleVO.setRegionArea(houseUser.getRegionArea());
		elderlyPeopleVO.setUnitId(houseUser.getUnitId());
		elderlyPeopleVO.setUnitName(houseUser.getUnitName());

		return elderlyPeopleVO;
	}

}
