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

/**
 * 包装类,返回视图层所需的字段
 *
 * @author BladeX
 * @since 2021-05-28
 */
public class AdolescentWrapper extends BaseEntityWrapper<Adolescent, AdolescentVO>  {
	private HouseUserService houseUserService;

	public AdolescentWrapper(){};
	public static AdolescentWrapper build() {
		return new AdolescentWrapper();
 	}

 	public AdolescentWrapper(HouseUserService houseUserService){this.houseUserService = houseUserService;}
 	public static AdolescentWrapper build(HouseUserService houseUserService){
		return new AdolescentWrapper(houseUserService);
	}
	@Override
	public AdolescentVO entityVO(Adolescent adolescent) {
		AdolescentVO adolescentVO = Objects.requireNonNull(BeanUtil.copy(adolescent, AdolescentVO.class));

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

		return adolescentVO;
	}
}
