From 8ac6210dd2165abecfd960881900d8893bf074e2 Mon Sep 17 00:00:00 2001 From: haoyanbin <605649647@qq.com> Date: Wed, 26 Jan 2022 18:40:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E5=BD=A9=E6=97=B6=E5=88=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mobile/apis/org_player.go | 61 ++++++++++++++++------------ app/mobile/service/dto/org_player.go | 39 +++++++++++------- app/mobile/service/org_player.go | 34 ++++++++++++++-- 3 files changed, 91 insertions(+), 43 deletions(-) diff --git a/app/mobile/apis/org_player.go b/app/mobile/apis/org_player.go index d0315f1..3370ee1 100755 --- a/app/mobile/apis/org_player.go +++ b/app/mobile/apis/org_player.go @@ -8,7 +8,6 @@ import ( "go-admin/app/mobile/service" "go-admin/app/mobile/service/dto" "go-admin/common/actions" - cDto "go-admin/common/dto" "strconv" ) @@ -238,6 +237,7 @@ func (e OrgPlayer) GetOrgMatchSeason(c *gin.Context) { // @Param matchId path string false "matchId" // @Param rounds path string false "rounds" // @Param playerId path string false "playerId" +// @Param type path string false "type" // @Success 200 {string} string "{"code": 200, "data": [...]}" // @Router /mobile/v1/org-player/evaluate [get] // @Security Bearer @@ -255,7 +255,7 @@ func (e OrgPlayer) GetOrgMatchEvaluate(c *gin.Context) { return } - list := make([]dto.OrgMatchEvaluateList, 0) + list := make([]dto.OrgPlayerGetOrgMatchEvaluateReply, 0) var count int64 //p := actions.GetPermissionFromContext(c) @@ -265,31 +265,42 @@ func (e OrgPlayer) GetOrgMatchEvaluate(c *gin.Context) { return } - reply := make([]dto.OrgMatchEvaluate, 0) - - for _, v := range list { - replyV := dto.OrgMatchEvaluate{} - imgList := make([]cDto.Wonderful, 0) - err = s.GetPageWonderful(v.Id, &imgList, 1) - if err != nil { - e.Error(500, err, fmt.Sprintf("èŽ·å–æ¯”èµ›çƒå‘˜ä¿¡æ¯ 失败,\r\nå¤±è´¥ä¿¡æ¯ %s", err.Error())) - return - } - replyV.MatchImg = imgList - - mvList := make([]cDto.Wonderful, 0) - err = s.GetPageWonderful(v.Id, &imgList, 2) - if err != nil { - e.Error(500, err, fmt.Sprintf("èŽ·å–æ¯”èµ›çƒå‘˜ä¿¡æ¯ 失败,\r\nå¤±è´¥ä¿¡æ¯ %s", err.Error())) - return - } - replyV.MatchMv = mvList - replyV.Id = v.Id - replyV.Content = v.Content - reply = append(reply, replyV) + e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询æˆåŠŸ") +} + +// Get <手机端>获å–çƒå‘˜è¯„论 +// @Summary <手机端>获å–çƒå‘˜è¯„论 +// @Description <手机端>获å–çƒå‘˜è¯„论 +// @Tags <手机端>çƒå‘˜æ•°æ® +// @Param playerId path string false "playerId" +// @Success 200 {string} string "{"code": 200, "data": [...]}" +// @Router /mobile/v1/org-player/evaluate-content [get] +// @Security Bearer +func (e OrgPlayer) GetOrgMatchEvaluateContent(c *gin.Context) { + req := dto.OrgPlayerGetOrgMatchEvaluateContentReq{} + s := service.OrgPlayer{} + err := c.Bind(&req) + err = e.MakeContext(c). + MakeOrm(). + MakeService(&s.Service). + Errors + if err != nil { + e.Logger.Error(err) + e.Error(500, err, err.Error()) + return } - e.OK(reply, "查询æˆåŠŸ") + list := make([]dto.OrgPlayerGetOrgMatchEvaluateContentReply, 0) + var count int64 + + //p := actions.GetPermissionFromContext(c) + err = s.GetOrgMatchEvaluateContent(&req, &list, &count) + if err != nil { + e.Error(500, err, fmt.Sprintf("获å–çƒå‘˜å¤±è´¥ï¼Œ\r\nå¤±è´¥ä¿¡æ¯ %s", err.Error())) + return + } + + e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询æˆåŠŸ") } // Get <手机端>精彩时刻比赛轮次列表 diff --git a/app/mobile/service/dto/org_player.go b/app/mobile/service/dto/org_player.go index 9ea90a8..76da132 100755 --- a/app/mobile/service/dto/org_player.go +++ b/app/mobile/service/dto/org_player.go @@ -121,27 +121,38 @@ type GetRoundsReply struct { } type OrgPlayerGetOrgMatchEvaluateReq struct { - LeagueId string `form:"leagueId" json:"leagueId"` - SeasonId string `form:"seasonId" json:"seasonId"` - MatchId string `form:"matchId" json:"matchId"` - Rounds string `form:"rounds" json:"rounds"` - PlayerId string `form:"playerId" json:"playerId"` + dto.Pagination `search:"-"` + LeagueId string `form:"leagueId" json:"leagueId"` + SeasonId string `form:"seasonId" json:"seasonId"` + MatchId string `form:"matchId" json:"matchId"` + Rounds string `form:"rounds" json:"rounds"` + PlayerId string `form:"playerId" json:"playerId"` + Type string `form:"type" json:"type"` } type OrgPlayerGetOrgMatchEvaluateReply struct { - OrgMatchEvaluate []OrgMatchEvaluate `json:"orgMatchEvaluate"` + Id string `json:"id"` + WonderfulId string `json:"wonderfulId" comment:"精彩时刻id"` + WonderfulUrl string `json:"wonderfulUrl" comment:"精彩时刻url"` + WonderfulTitle string `json:"wonderfulTitle" comment:"ç²¾å½©æ—¶åˆ»æ ‡é¢˜"` + FileId string `json:"fileId" comment:"文件id"` } -type OrgMatchEvaluate struct { - Id string `json:"id"` - Content string `json:"content"` - MatchImg []dto.Wonderful `json:"matchImg"` - MatchMv []dto.Wonderful `json:"matchMv"` +type OrgPlayerGetOrgMatchEvaluateContentReq struct { + dto.Pagination `search:"-"` + PlayerId string `form:"playerId" json:"playerId"` } -type OrgMatchEvaluateList struct { - Id string `json:"id"` - Content string `json:"content"` +type OrgPlayerGetOrgMatchEvaluateContentReply struct { + Id string `json:"id"` + LeagueName string `json:"leagueName"` + DivisionName string `json:"divisionName"` + SeasonName string `json:"seasonName"` + MatchId string `json:"matchId"` + Rounds string `json:"rounds"` + Content string `json:"content"` + ContentDate string `json:"contentDate"` + ContentImg string `json:"contentImg"` } // OrgPlayerGetReq 功能获å–è¯·æ±‚å‚æ•° diff --git a/app/mobile/service/org_player.go b/app/mobile/service/org_player.go index af76d9a..10cc6d1 100755 --- a/app/mobile/service/org_player.go +++ b/app/mobile/service/org_player.go @@ -324,19 +324,45 @@ func (e *OrgPlayer) GetOrgRounds(c *dto.GetRoundsReq, list *[]dto.GetRoundsReply } return nil } -func (e *OrgPlayer) GetOrgMatchEvaluate(c *dto.OrgPlayerGetOrgMatchEvaluateReq, list *[]dto.OrgMatchEvaluateList, count *int64) error { +func (e *OrgPlayer) GetOrgMatchEvaluate(c *dto.OrgPlayerGetOrgMatchEvaluateReq, list *[]dto.OrgPlayerGetOrgMatchEvaluateReply, count *int64) error { var err error - err = e.Orm.Table("org_match_evaluate as ome"). - Select("ome.id, ome.content"). + err = e.Orm.Table("org_match_evaluate_wonderful as omew"). + Select("omew.id, omew.wonderful_url, omew.wonderful_title, omew.file_id"). + Joins("left join org_match_evaluate as ome on ome.id = omew.match_evaluate_id"). Joins("left join org_match as om on om.id = ome.match_id"). Scopes( - cDto.PassDel("ome"), + cDto.PassDel("omew"), cDto.SetWhere("om", "league_id", c.LeagueId), cDto.SetWhere("om", "season_id", c.SeasonId), cDto.SetWhere("ome", "match_id", c.MatchId), cDto.SetWhere("ome", "rounds", c.Rounds), ). + Where("omew.type=?", c.Type). + Where("ome.player_id=?", c.PlayerId). + Find(list).Limit(-1).Offset(-1). + Count(count).Error + if err != nil { + e.Log.Errorf("OrgMatchService GetPage error:%s \r\n", err) + return err + } + return nil +} + +func (e *OrgPlayer) GetOrgMatchEvaluateContent(c *dto.OrgPlayerGetOrgMatchEvaluateContentReq, list *[]dto.OrgPlayerGetOrgMatchEvaluateContentReply, count *int64) error { + var err error + + err = e.Orm.Table("org_match_evaluate as ome"). + Select("ome.id, ome.content, ome.content_date, ome.content_img, ol.league_name,"+ + "os.season_name, od.division_name, ome.match_id, ome.rounds"). + Joins("left join org_match as om on om.id = ome.match_id"). + Joins("left join org_league as ol on om.league_id = ol.id"). + Joins("left join org_season as os on om.season_id = os.id"). + Joins("left join org_division as od on om.division_id = od.id"). + Scopes( + cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), + cDto.PassDel("ome"), + ). Where("ome.player_id=?", c.PlayerId). Find(list).Limit(-1).Offset(-1). Count(count).Error -- 2.18.1