75 lines
2.0 KiB
Go
75 lines
2.0 KiB
Go
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/go-admin-team/go-admin-core/logger"
|
|
"gorm.io/gorm"
|
|
"time"
|
|
)
|
|
|
|
type Strategy struct {
|
|
Model
|
|
Name string `json:"name" gorm:"index"`
|
|
Domain string `json:"domain" gorm:"index"`
|
|
OperatingInterval string `json:"operating_interval"`
|
|
PageDepth uint32 `json:"page_depth"`
|
|
AdClickCount uint32 `json:"ad_click_count"`
|
|
SearchBehavior uint32 `json:"search_behavior"`
|
|
PageTime uint32 `json:"page_time"`
|
|
StartTime time.Time `json:"start_time"`
|
|
EndTime time.Time `json:"end_time"`
|
|
}
|
|
|
|
type StrategyUpdate struct {
|
|
Model
|
|
Name string `json:"name" gorm:"index"`
|
|
Domain string `json:"domain" gorm:"index"`
|
|
OperatingInterval string `json:"operating_interval"`
|
|
PageDepth uint32 `json:"page_depth"`
|
|
AdClickCount uint32 `json:"ad_click_count"`
|
|
SearchBehavior uint32 `json:"search_behavior"`
|
|
PageTime uint32 `json:"page_time"`
|
|
StartTime string `json:"start_time"`
|
|
EndTime string `json:"end_time"`
|
|
}
|
|
|
|
type StrategyListReq struct {
|
|
PageNum int `json:"page_num"`
|
|
PageSize int `json:"page_size"`
|
|
}
|
|
|
|
type StrategyListResp struct {
|
|
List []Strategy `json:"list"`
|
|
Count int `json:"count"`
|
|
PageSize int `json:"page_size"`
|
|
PageNum int `json:"page_num"`
|
|
TotalPage int `json:"total_page"`
|
|
}
|
|
|
|
type StrategyDetailReq struct {
|
|
Domain string `json:"domain"`
|
|
}
|
|
|
|
func (m *StrategyListReq) List() (*StrategyListResp, error) {
|
|
|
|
//resp.CardTotalStock = int(rentStock)
|
|
//resp.CardTotalCount = int(totalCount)
|
|
return nil, nil
|
|
}
|
|
|
|
type RecordExist struct {
|
|
RecordExist int64 `json:"record_exist"`
|
|
}
|
|
|
|
func QueryRecordExist(sql string, Db *gorm.DB) (bool, error) {
|
|
var recordExist RecordExist
|
|
existSql := fmt.Sprintf("SELECT EXISTS (%s) AS record_exist;", sql)
|
|
err := Db.Raw(existSql).Scan(&recordExist).Error
|
|
if err != nil {
|
|
logger.Errorf("err:", err)
|
|
return false, err
|
|
}
|
|
|
|
return recordExist.RecordExist == 1, nil
|
|
}
|