feat: 更新服务方法,显式接受用户ID参数,简化上下文调用

This commit is contained in:
2025-12-30 23:23:56 +08:00
parent e6a8e3f321
commit 317db2daad
10 changed files with 216 additions and 91 deletions

View File

@@ -50,7 +50,7 @@ func (s *NotificationTestSuite) Test_CRUD() {
err := Notification.Send(ctx, uID, "system", "Welcome", "Hello World")
So(err, ShouldBeNil)
list, err := Notification.List(ctx, 1, "")
list, err := Notification.List(ctx, uID, 1, "")
So(err, ShouldBeNil)
So(list.Total, ShouldEqual, 1)
@@ -61,7 +61,7 @@ func (s *NotificationTestSuite) Test_CRUD() {
// Mark Read
// Need ID
n, _ := models.NotificationQuery.WithContext(ctx).Where(models.NotificationQuery.UserID.Eq(uID)).First()
err = Notification.MarkRead(ctx, cast.ToString(n.ID))
err = Notification.MarkRead(ctx, uID, cast.ToString(n.ID))
So(err, ShouldBeNil)
nReload, _ := models.NotificationQuery.WithContext(ctx).Where(models.NotificationQuery.ID.Eq(n.ID)).First()