/**
 * 
 */
package org.springblade.resource;

import org.springblade.modules.system.entity.Sms;
import org.springblade.modules.system.service.normal.SmsService;
import org.springblade.system.client.SmsClient;
import org.springblade.system.client.model.SmsModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.core.bean.BeanUtil;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author wookvn
 *
 */
@ApiIgnore
@RestController
public class SmsResource implements SmsClient {
	
	@Autowired
	private SmsService smsService;

	@Override
	public SmsModel getById(Integer id) {
		Sms sms = smsService.getById(id);
		//禁用状态不能返回
		if(sms == null || sms.getStatus() == 0) {
			return null;
		}
		SmsModel smsModel = BeanUtil.copyProperties(sms, SmsModel.class);
		if(smsModel != null) {
			smsModel.setCategoryVal(sms.getCategory().getValue());
		}
		return smsModel;
	}

}
