package com.yc.ship.module.trade.api.sms;

import com.yc.ship.framework.common.pojo.CommonResult;
import com.yc.ship.framework.common.util.object.BeanUtils;
import com.yc.ship.module.trade.api.sms.dto.SmsReqDTO;
import com.yc.ship.module.trade.api.sms.dto.SmsSendLogDTO;
import com.yc.ship.module.trade.dal.dataobject.smsSendLog.SmsSendLogDO;
import com.yc.ship.module.trade.dal.mysql.smsSendLog.SmsSendLogMapper;
import com.yc.ship.module.trade.service.sms.SmsServiceImpl;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/***
 *&#064;Description 短信公共服务
 *@author qsl
 *@date 2025/8/6 22:10
 *@param
 *@return
 */
@RestController
@Validated
public class SmsApiImpl implements SmsApi {

    @Resource
    private SmsServiceImpl smsService;

    @Resource
    private SmsSendLogMapper smsSendLogMapper;


    @Override
    public CommonResult<String> sendMsg(SmsReqDTO smsReqDTO) {
        return CommonResult.success(smsService.sendMsg(smsReqDTO));
    }

    @Override
    public CommonResult<Integer> insertSmsLog(SmsSendLogDTO smsReqDTO) {
        SmsSendLogDO smsSendLogDO = BeanUtils.toBean(smsReqDTO, SmsSendLogDO.class);
        return CommonResult.success(smsSendLogMapper.insert(smsSendLogDO));
    }

    @Override
    public CommonResult<Integer> queryStatus(String smsId) {
        return CommonResult.success(smsService.queryStatus(smsId));
    }
}
