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

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

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

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

	@Override
	public DrugVO entityVO(Drug drug) {
		DrugVO drugVO = Objects.requireNonNull(BeanUtil.copy(drug, DrugVO.class));

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

		return drugVO;
	}

}
