/*
 *      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.Veterans;
import org.springblade.person.service.HouseUserService;
import org.springblade.person.vo.VeteransVO;
import java.util.Objects;

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

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

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

	@Override
	public VeteransVO entityVO(Veterans veterans) {
		VeteransVO veteransVO = Objects.requireNonNull(BeanUtil.copy(veterans, VeteransVO.class));

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

		return veteransVO;
	}

}
