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.

25 lines
786 B

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. package channel
  2. import (
  3. "context"
  4. "practice_Go/api/channel/v1"
  5. "practice_Go/internal/dao"
  6. "practice_Go/internal/model/dto"
  7. "practice_Go/internal/model/entity"
  8. )
  9. func (c *ControllerV1) GetChannel(ctx context.Context, req *v1.GetChannelReq) (*dto.Result, error) {
  10. res := v1.GetChannelRes{}
  11. err := dao.GoChannels.Ctx(ctx).WherePri(req.Id).Scan(&res.Channel)
  12. query := dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).Where("channel_id =?", req.Id)
  13. if req.FlagType != 0 {
  14. query = query.Where("flag_type =?", req.FlagType)
  15. }
  16. err = query.Scan(&res.List)
  17. res.Channel.Status, err = dao.GoChannelSubscriptions.Ctx(ctx).Wheref("channel_id =? and user_id =?", req.Id, req.UserId).Exist()
  18. if err != nil {
  19. return dto.Error(err.Error()), nil
  20. }
  21. return dto.SuccessWithData(res), nil
  22. }