feat: fix issues

This commit is contained in:
Rogee
2025-05-26 12:25:55 +08:00
parent 51ed5685dc
commit d634e0175b
10 changed files with 43 additions and 17 deletions

View File

@@ -48,12 +48,13 @@ func (m *Posts) CondLike(key *string) Cond {
func (m *Posts) IncrViewCount(ctx context.Context) error {
tbl := tblPosts
stmt := tbl.UPDATE(tbl.Views).SET(tbl.Views.ADD(Int64(1))).WHERE(tbl.ID.EQ(Int64(m.ID)))
stmt := tbl.UPDATE(tbl.Views).
SET(tbl.Views.ADD(Int64(1))).
WHERE(tbl.ID.EQ(Int64(m.ID))).
RETURNING(tblPosts.AllColumns)
m.log().Infof("sql: %s", stmt.DebugSql())
var post Posts
err := stmt.QueryContext(ctx, db, &post)
if err != nil {
if err := stmt.QueryContext(ctx, db, m); err != nil {
m.log().Errorf("error updating post view count: %v", err)
return err
}