// =================================================================================
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
// =================================================================================

package dao

import (
	"context"
	"github.com/gogf/gf/v2/os/gtime"
	"hotgo/internal/dao/internal"
)

// internalSysSmsLogDao is internal type for wrapping internal DAO implements.
type internalSysSmsLogDao = *internal.SysSmsLogDao

// sysSmsLogDao is the data access object for table hg_sys_sms_log.
// You can define custom methods on it to extend its functionality as you wish.
type sysSmsLogDao struct {
	internalSysSmsLogDao
}

var (
	// SysSmsLog is globally public accessible object for table hg_sys_sms_log operations.
	SysSmsLog = sysSmsLogDao{
		internal.NewSysSmsLogDao(),
	}
)

// Fill with you ideas below.

// NowDayCount 当天发送次数
func (dao *sysSmsLogDao) NowDayCount(ctx context.Context, event, mobile string) (count int, err error) {
	count, err = dao.Ctx(ctx).
		Where("mobile", mobile).
		Where("event", event).
		WhereGTE("created_at", gtime.Now().Format("Y-m-d")).
		Count()
	if err != nil {
		return 0, err
	}

	return
}
