package org.sky.resource.wrapper;

import org.sky.core.mp.support.BaseEntityWrapper;
import org.sky.core.tool.utils.BeanUtil;
import org.sky.resource.pojo.entity.Sms;
import org.sky.resource.pojo.vo.SmsVO;
import org.sky.system.cache.DictCache;
import org.sky.system.pojo.enums.DictEnum;

import java.util.Objects;

/**
 * 短信配置表包装类,返回视图层所需的字段
 *
 */
public class SmsWrapper extends BaseEntityWrapper<Sms, SmsVO> {

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

	@Override
	public SmsVO entityVO(Sms sms) {
		SmsVO smsVO = Objects.requireNonNull(BeanUtil.copyProperties(sms, SmsVO.class));
		String categoryName = DictCache.getValue(DictEnum.SMS, sms.getCategory());
		String statusName = DictCache.getValue(DictEnum.YES_NO, sms.getStatus());
		smsVO.setCategoryName(categoryName);
		smsVO.setStatusName(statusName);
		return smsVO;
	}

}
