You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

  1. package clubs
  2. import (
  3. "context"
  4. "github.com/gogf/gf/v2/frame/g"
  5. "practice_Go/internal/dao"
  6. "practice_Go/internal/model/do"
  7. "practice_Go/internal/model/entity"
  8. "practice_Go/internal/service"
  9. )
  10. // 1.注册
  11. func init() {
  12. service.RegisterClubs(&sClubs{})
  13. }
  14. type sClubs struct{}
  15. func (c sClubs) GetClubs(ctx context.Context) (clubs []entity.GoClubs, err error) {
  16. clubId := g.RequestFromCtx(ctx).Get("id").Int()
  17. if clubId == 0 {
  18. panic("获取俱乐部信息时id不能为空")
  19. } else {
  20. err = dao.GoClubs.Ctx(ctx).Where("id", clubId).Scan(&clubs) //查询数据库, 并将可能出现的错误赋给err
  21. }
  22. return
  23. }
  24. func (c sClubs) GetClubShows(ctx context.Context) (shows []entity.GoShows, err error) {
  25. clubId := g.RequestFromCtx(ctx).Get("id").Int()
  26. if clubId == 0 {
  27. panic("获取俱乐部内容时id不能为空")
  28. } else {
  29. err = dao.GoShows.Ctx(ctx).FieldsEx("club").With(entity.GoUsers{}).Where("club_id", clubId).Scan(&shows)
  30. }
  31. return
  32. }
  33. func (c sClubs) AddClub(ctx context.Context, club do.GoShows) (err error) {
  34. //TODO implement me
  35. panic("implement me")
  36. }
  37. func (c sClubs) EditClub(ctx context.Context, club do.GoClubs) (err error) {
  38. //TODO implement me
  39. panic("implement me")
  40. }
  41. func (c sClubs) DeleteClub(ctx context.Context) (err error) {
  42. //TODO implement me
  43. panic("implement me")
  44. }