26 lines
564 B
Go
26 lines
564 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogf/gf/v2/database/gdb"
|
|
|
|
"36wisdom/biz/consts"
|
|
"36wisdom/biz/dao"
|
|
)
|
|
|
|
type badge struct{}
|
|
|
|
var Badge = &badge{}
|
|
|
|
// GetByPk 徽章定义。
|
|
func (s *badge) GetByPk(ctx context.Context, id int64) (gdb.Record, error) {
|
|
return dao.Badge.GetOneByPk(ctx, id)
|
|
}
|
|
|
|
// ListEnabled 启用徽章定义(内容缓存)。
|
|
func (s *badge) ListEnabled(ctx context.Context) ([]gdb.Record, error) {
|
|
return dao.Badge.Model().Ctx(ctx).Cache(contentCache(ctx)).
|
|
Where("status", consts.StatusEnabled).Order("id ASC").All()
|
|
}
|