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

/**
 * 包装类,返回视图层所需的字段
 *
 * @author BladeX
 * @since 2021-06-02
 */
public class AllowancesPeopleWrapper extends BaseEntityWrapper<AllowancesPeople, AllowancesPeopleVO>  {

	private HouseUserService houseUserService;

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

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

	@Override
	public AllowancesPeopleVO entityVO(AllowancesPeople allowancesPeople) {
		AllowancesPeopleVO allowancesPeopleVO = Objects.requireNonNull(BeanUtil.copy(allowancesPeople, AllowancesPeopleVO.class));

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

		return allowancesPeopleVO;
	}

}
