package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.dao.RdSmsLogDao;
import io.renren.common.entity.RdSmsLogEntity;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.sys.dto.RdSmsLogDTO;
import io.renren.modules.sys.service.RdSmsLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 短信验证码记录
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-06-05
 */
@Service
public class RdSmsLogServiceImpl extends CrudServiceImpl<RdSmsLogDao, RdSmsLogEntity, RdSmsLogDTO> implements RdSmsLogService {

    @Override
    public QueryWrapper<RdSmsLogEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String mobile = (String)params.get("mobile");
        String pageId = (String)params.get("pageId");
        String channel = (String)params.get("channel");

        QueryWrapper<RdSmsLogEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id).eq("status",1)
                .eq(StringUtils.isNotBlank(mobile), "mobile", mobile)
                .eq(StringUtils.isNotBlank(channel), "channel", channel)
                .eq(StringUtils.isNotBlank(pageId), "page_id", pageId)
                .orderByDesc("id");

        return wrapper;
    }


}