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

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

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

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

	@Override
	public CorrectionalStaffVO entityVO(CorrectionalStaff correctionalStaff) {
		CorrectionalStaffVO correctionalStaffVO = Objects.requireNonNull(BeanUtil.copy(correctionalStaff, CorrectionalStaffVO.class));

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

		return correctionalStaffVO;
	}

}
