You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: login_log.go
    path of file: ./repos/next-terminal/server/repository
    
    the code of the file until where you have to start completion: package repository

import (
	"context"
	"time"

	"next-terminal/server/dto"
	"next-terminal/server/model"
)

var LoginLogRepository = new(loginLogRepository)

type loginLogRepository struct {
	baseRepository
}

func (r loginLogRepository) Find(c context.Context, pageIndex, pageSize int,
    
func (r loginLogRepository) Find(c context.Context, pageIndex, pageSize int, username, clientIp, state string) (o []model.LoginLog, total int64, err error) {
	m := model.LoginLog{}
	db := r.GetDB(c).Table(m.TableName())
	dbCounter := r.GetDB(c).Table(m.TableName())

	if username != "" {
		db = db.Where("username like ?", "%"+username+"%")
		dbCounter = dbCounter.Where("username like ?", "%"+username+"%")
	}

	if clientIp != "" {
		db = db.Where("client_ip like ?", "%"+clientIp+"%")
		dbCounter = dbCounter.Where("client_ip like ?", "%"+clientIp+"%")
	}

	if state != "" {
		db = db.Where("state = ?", state)
		dbCounter = dbCounter.Where("state = ?", state)
	}

	err = dbCounter.Count(&total).Error
	if err != nil {
		return nil, 0, err
	}

	err = db.Order("login_time desc").Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&o).Error
	if o == nil {
		o = make([]model.LoginLog, 0)
	}
	return
}