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

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

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

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

	@Override
	public PrisonerVO entityVO(Prisoner prisoner) {
		PrisonerVO prisonerVO = Objects.requireNonNull(BeanUtil.copy(prisoner, PrisonerVO.class));

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

		return prisonerVO;
	}

}
