package com.hzs.third.sms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.domain.third.sms.TSmsTemplate;
import com.hzs.third.sms.mapper.TSmsTemplateMapper;
import com.hzs.third.sms.service.ITSmsTemplateService;
import org.springframework.stereotype.Service;

/**
 * 短信模板 服务实现类
 *
 * @author hzs
 * @since 2022-08-22
 */
@Service
public class TSmsTemplateServiceImpl extends ServiceImpl<TSmsTemplateMapper, TSmsTemplate> implements ITSmsTemplateService {

    @Override
    public boolean checkTemplateCode(String templateCode, Integer pkCountry, Integer pkId) {
        QueryWrapper<TSmsTemplate> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("TEMPLATE_CODE", templateCode);
        queryWrapper.eq(SystemFieldConstants.PK_COUNTRY, pkCountry);
        if (null != pkId) {
            queryWrapper.ne(SystemFieldConstants.PK_ID, pkId);
        }
        return null == this.getOne(queryWrapper);
    }

}
