package com.qnfhq.modules.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qnfhq.common.service.impl.BaseServiceImpl;
import com.qnfhq.modules.user.dao.SmsTplDao;
import com.qnfhq.modules.user.entity.SmsTplEntity;
import com.qnfhq.modules.user.service.SmsTplService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 短信模板
 *
 * @author yelz 30262728@qq.com
 * @since 1.0.0 2025-11-13
 */
@Service
public class SmsTplServiceImpl extends BaseServiceImpl<SmsTplDao, SmsTplEntity> implements SmsTplService {


    public QueryWrapper<SmsTplEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<SmsTplEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Override
    public SmsTplEntity selectSmsTplByCode(String code) {
        return baseDao.selectOne(new LambdaQueryWrapper<SmsTplEntity>()
                .eq(SmsTplEntity::getCode, code)
                .last(" limit 1")
        );
    }

}