c4eede1114
CI / changes (push) Successful in 1m32s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 0s
CI / analysis (push) Successful in 3m45s
CI / bff (push) Successful in 31s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 0s
CI / express (push) Successful in 1s
CI / factory (push) Successful in 0s
CI / message (push) Successful in 0s
CI / order (push) Successful in 0s
CI / payment (push) Successful in 0s
CI / percutaneous (push) Successful in 1s
CI / product (push) Successful in 0s
CI / sale (push) Successful in 0s
CI / record (push) Successful in 0s
CI / store (push) Successful in 0s
CI / support (push) Successful in 0s
CI / user (push) Successful in 1s
CI / task (push) Successful in 0s
CI / water (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 0s
41 lines
848 B
Go
41 lines
848 B
Go
package model
|
|
|
|
import "lone-services/pkg/modelbase"
|
|
|
|
type ImageModel struct {
|
|
modelbase.Base
|
|
}
|
|
|
|
func (m ImageModel) TableName() string {
|
|
return modelbase.Prefix() + "images"
|
|
}
|
|
|
|
func (m ImageModel) Init() ImageModel {
|
|
m.Table = m.TableName()
|
|
return m
|
|
}
|
|
|
|
func (m ImageModel) Dates(userId int64, status int, start, end string) ([]string, error) {
|
|
m = m.Init()
|
|
var rows []struct {
|
|
Day string `gorm:"column:day"`
|
|
}
|
|
err := m.Session().
|
|
Select("DATE_FORMAT(create_time, '%Y-%m-%d') AS day").
|
|
Where("user_id = ? AND status = ?", userId, status).
|
|
Where("create_time BETWEEN ? AND ?", start, end).
|
|
Group("day").
|
|
Order("day ASC").
|
|
Scan(&rows).Error
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
dates := make([]string, 0, len(rows))
|
|
for _, row := range rows {
|
|
if row.Day != "" {
|
|
dates = append(dates, row.Day)
|
|
}
|
|
}
|
|
return dates, nil
|
|
}
|