This commit is contained in:
xing 2023-02-06 18:51:58 +08:00
parent b1859409da
commit 0b0e701bef

View File

@ -170,19 +170,15 @@ func MonthPost(args ...any) (r []uint64, err error) {
ctx := args[0].(context.Context) ctx := args[0].(context.Context)
year, month := args[1].(string), args[2].(string) year, month := args[1].(string), args[2].(string)
where := model.SqlBuilder{ where := model.SqlBuilder{
{"post_type", "in", ""}, {"post_type", "post"},
{"post_status", "in", ""}, {"post_status", "publish"},
{"year(post_date)", year}, {"year(post_date)", year},
{"month(post_date)", month}, {"month(post_date)", month},
} }
postType := []any{"post"} return model.Column[models.Posts, uint64](ctx, func(v models.Posts) (uint64, bool) {
status := []any{"publish"} return v.Id, true
ids, err := model.Find[models.Posts](ctx, where, "ID", "", model.SqlBuilder{{"Id", "asc"}}, nil, nil, 0, postType, status) }, model.Conditions(
if err != nil { model.Where(where),
return model.Order(model.SqlBuilder{{"Id", "asc"}}),
} ))
for _, post := range ids {
r = append(r, post.Id)
}
return
} }