/*
 *      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.Disabler;
import org.springblade.person.entity.HouseUser;
import org.springblade.person.service.HouseUserService;
import org.springblade.person.vo.DisablerVO;

import java.util.Objects;

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

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

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

	@Override
	public DisablerVO entityVO(Disabler disabler) {
		DisablerVO disablerVO = Objects.requireNonNull(BeanUtil.copy(disabler, DisablerVO.class));

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


		return disablerVO;
	}

}
