/*
 *      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.HouseUser;
import org.springblade.person.entity.Psychiatric;
import org.springblade.person.service.HouseUserService;
import org.springblade.person.vo.PsychiatricVO;
import java.util.Objects;

/**
 * 包装类,返回视图层所需的字段
 *
 * @author BladeX
 * @since 2021-05-28
 */
public class PsychiatricWrapper extends BaseEntityWrapper<Psychiatric, PsychiatricVO>  {

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

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

	@Override
	public PsychiatricVO entityVO(Psychiatric psychiatric) {
		PsychiatricVO psychiatricVO = Objects.requireNonNull(BeanUtil.copy(psychiatric, PsychiatricVO.class));

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

		return psychiatricVO;
	}

}
