28 lines
632 B
Go
28 lines
632 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
"36wisdom/biz/dao"
|
|
)
|
|
|
|
type userBadge struct{}
|
|
|
|
var UserBadge = &userBadge{}
|
|
|
|
// ListByUser 孩子已获徽章。
|
|
func (s *userBadge) ListByUser(ctx context.Context, userId int64) ([]gdb.Record, error) {
|
|
return dao.UserBadge.Model().Ctx(ctx).Where("user_id", userId).Order("id ASC").All()
|
|
}
|
|
|
|
// Insert 记录孩子获得徽章。
|
|
func (s *userBadge) Insert(ctx context.Context, userId, badgeId int64) (int64, error) {
|
|
return dao.UserBadge.InsertAndReturnId(ctx, g.Map{
|
|
"user_id": userId,
|
|
"badge_id": badgeId,
|
|
})
|
|
}
|