fix: offset

This commit is contained in:
Rogee
2024-09-04 18:57:58 +08:00
parent c34547a3f1
commit e6d808934d
4 changed files with 19 additions and 32 deletions

View File

@@ -23,7 +23,6 @@ type DBChannel struct {
UUID int64
Username string
Title string
Offset int
MinID int
}
@@ -86,28 +85,18 @@ func (c *DBChannel) Get(ctx context.Context) error {
}
}
c.MinID = int(m.MinID)
c.Offset = int(m.Offset)
return nil
}
func (c *DBChannel) Update(ctx context.Context, offsetID int) error {
if c.Offset == 0 {
c.Offset = offsetID
}
if c.Offset > offsetID {
c.Offset = offsetID
}
if c.MinID < offsetID {
c.MinID = offsetID
func (c *DBChannel) Update(ctx context.Context, msgID int) error {
if c.MinID < msgID {
c.MinID = msgID
}
tbl := table.Channels
_, err := tbl.UPDATE().
SET(
tbl.Offset.SET(Int64(int64(c.Offset))),
tbl.MinID.SET(Int64(int64(c.MinID))),
).
WHERE(tbl.UUID.EQ(Int64(c.UUID))).