package org.springblade.modules.member.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.member.entity.MemberEntity;
import org.springblade.modules.member.enums.SexEnum;
import org.springblade.modules.member.service.IMemberInfoService;
import org.springblade.modules.member.vo.MemberVO;

/**
 *  包装类,返回视图层所需的字段
 *
 * @author Chill
 */
public class MemberInfoWrapper extends BaseEntityWrapper<MemberEntity, MemberVO> {

	public static MemberInfoWrapper build() {
		return new MemberInfoWrapper();
 	}

	private static IMemberInfoService memberInfoService;

	static {
		memberInfoService = SpringUtil.getBean(IMemberInfoService.class);
	}

	@Override
	public MemberVO entityVO(MemberEntity memberInfo) {
		if (Func.isEmpty(memberInfo)) {
			return null;
		}
		MemberVO member_infoVO = BeanUtil.copy(memberInfo, MemberVO.class);
		//性别
		if (Func.isNotEmpty(member_infoVO.getSex())) {
			if (member_infoVO.getSex().equals("1")) {
				member_infoVO.setSexName(SexEnum.MAN.getLabel());

			} else {
				member_infoVO.setSexName(SexEnum.WOMAN.getLabel());
			}
		}

		return member_infoVO;
	}

}
