/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 运维系统
 * 创建日期:2022/8/22
 */
package org.springblade.modules.yjxt.base.servicePerson.wrapper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springblade.modules.yjxt.base.servicePerson.entity.YjxtServicePersonEntity;
import org.springblade.modules.yjxt.base.servicePerson.vo.YjxtServicePersonVO;

import java.util.Objects;

/***
 * Date:2022/8/22
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
public class YjxtServicePersonWrapper extends BaseEntityWrapper<YjxtServicePersonEntity, YjxtServicePersonVO> {
	public static YjxtServicePersonWrapper build() {
		return new YjxtServicePersonWrapper();
	}

	private static IUserService userService;

	private static IUserService getUserService() {
		if (userService == null) {
			userService = SpringUtil.getBean(IUserService.class);
		}
		return userService;
	}

	@Override
	public YjxtServicePersonVO entityVO(YjxtServicePersonEntity entity) {
		YjxtServicePersonVO servicePersonVO = Objects.requireNonNull(BeanUtil.copy(entity, YjxtServicePersonVO.class));
		User user = getUserService().getById(entity.getUserId());
		servicePersonVO.setUserAccount(user.getAccount());
		servicePersonVO.setUserName(user.getRealName());
		servicePersonVO.setPhone(user.getPhone());
		return servicePersonVO;
	}
}
