|
@@ -163,9 +163,10 @@ func DoSql(sql string, result interface{}, values ...interface{}) (err error) {
|
|
|
func GetListOrderByCondition(week bool, column string, limit int, order models.Order) (reports []Report, err error) {
|
|
|
db := models.Main()
|
|
|
if week {
|
|
|
- end := time.Now()
|
|
|
- begin := date.GetBeginOfTheWeek(end, time.Monday)
|
|
|
- err = db.Select(CommonColumns).Where("status = ?", StatusPublish).Where("DATE(published_time) BETWEEN ? AND ?", begin, end).Order(fmt.Sprintf("%s %s", column, order)).Limit(limit).Find(&reports).Error
|
|
|
+ current := time.Now()
|
|
|
+ begin := date.GetBeginOfTheWeek(current, time.Monday).Format(time.DateOnly)
|
|
|
+ end := current.Format(time.DateOnly)
|
|
|
+ err = db.Select(CommonColumns).Where("status = ?", StatusPublish).Where(" STR_TO_DATE(published_time,'%Y-%m-%d') BETWEEN ? AND ?", begin, end).Order(fmt.Sprintf("%s %s", column, order)).Limit(limit).Find(&reports).Error
|
|
|
} else {
|
|
|
err = db.Select(CommonColumns).Where("status = ?", StatusPublish).Order(fmt.Sprintf("%s %s", column, order)).Limit(limit).Find(&reports).Error
|
|
|
}
|