Commit d597c7aa authored by haoyanbin's avatar haoyanbin

League

parent f7c10bb1
......@@ -2,7 +2,6 @@ package apis
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/go-admin-team/go-admin-core/sdk/api"
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
......@@ -89,3 +88,38 @@ func (e OrgPlayerRank) GetPageTeam(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
// GetPage <手机端>获取联赛列表
// @Summary <手机端>获取联赛列表
// @Description <手机端>获取联赛列表
// @Tags <手机端>联赛列表
// @Param data body dto.OrgLeagueGetPageReq true "data"
// @Success 200 {string} string "{"code": 200, "data": [...]}"
// @Router /api/v1/org-player-rank/league [get]
// @Security Bearer
func (e OrgPlayerRank) GetPageLeague(c *gin.Context) {
req := dto.OrgLeagueGetPageReq{}
s := service.OrgLeague{}
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
e.Error(500, err, err.Error())
return
}
p := actions.GetPermissionFromContext(c)
list := make([]dto.OrgLeagueGetPageReply, 0)
var count int64
err = s.GetPage(&req, p, &list, &count)
if err != nil {
e.Error(500, err, fmt.Sprintf("获取联赛 失败,\r\n失败信息 %s", err.Error()))
return
}
e.PageOK(list, int(count), 1, 999, "查询成功")
}
......@@ -16,5 +16,6 @@ func registerOrgPlayerRankRouter(v1 *gin.RouterGroup) {
{
r.GET("", api.GetPage)
r.GET("/team", api.GetPageTeam)
r.GET("/league", api.GetPageLeague)
}
}
......@@ -2,25 +2,16 @@ package dto
import (
"go-admin/app/operate/models"
"go-admin/common/dto"
common "go-admin/common/models"
"time"
)
type OrgLeagueGetPageReq struct {
dto.Pagination `search:"-"`
OrgLeagueOrder
PlayerId string `form:"playerId" json:"playerId" comment:""` //
}
type OrgLeagueOrder struct {Id int `form:"idOrder" search:"type:order;column:id;table:org_league"`
LeagueName string `form:"leagueNameOrder" search:"type:order;column:league_name;table:org_league"`
Status string `form:"statusOrder" search:"type:order;column:status;table:org_league"`
CreateBy string `form:"createByOrder" search:"type:order;column:create_by;table:org_league"`
UpdateBy string `form:"updateByOrder" search:"type:order;column:update_by;table:org_league"`
CreatedAt time.Time `form:"createdAtOrder" search:"type:order;column:created_at;table:org_league"`
UpdatedAt time.Time `form:"updatedAtOrder" search:"type:order;column:updated_at;table:org_league"`
DeletedAt time.Time `form:"deletedAtOrder" search:"type:order;column:deleted_at;table:org_league"`
type OrgLeagueGetPageReply struct {
Id string `json:"id" comment:""` //
LeagueName string `json:"leagueName" comment:"联赛级别"`
}
func (m *OrgLeagueGetPageReq) GetNeedSearch() interface{} {
......@@ -36,7 +27,7 @@ type OrgLeagueInsertReq struct {
func (s *OrgLeagueInsertReq) Generate(model *models.OrgLeague) {
if s.Id == 0 {
model.Model = common.Model{ Id: s.Id }
model.Model = common.Model{Id: s.Id}
}
model.LeagueName = s.LeagueName
model.Status = s.Status
......@@ -55,7 +46,7 @@ type OrgLeagueUpdateReq struct {
func (s *OrgLeagueUpdateReq) Generate(model *models.OrgLeague) {
if s.Id == 0 {
model.Model = common.Model{ Id: s.Id }
model.Model = common.Model{Id: s.Id}
}
model.LeagueName = s.LeagueName
model.Status = s.Status
......@@ -69,6 +60,7 @@ func (s *OrgLeagueUpdateReq) GetId() interface{} {
type OrgLeagueGetReq struct {
Id int `uri:"id"`
}
func (s *OrgLeagueGetReq) GetId() interface{} {
return s.Id
}
......
......@@ -2,14 +2,12 @@ package service
import (
"errors"
"github.com/go-admin-team/go-admin-core/sdk/service"
"gorm.io/gorm"
"go-admin/app/mobile/service/dto"
"go-admin/app/operate/models"
"go-admin/app/operate/service/dto"
"go-admin/common/actions"
cDto "go-admin/common/dto"
)
type OrgLeague struct {
......@@ -17,17 +15,37 @@ type OrgLeague struct {
}
// GetPage 获取OrgLeague列表
func (e *OrgLeague) GetPage(c *dto.OrgLeagueGetPageReq, p *actions.DataPermission, list *[]models.OrgLeague, count *int64) error {
func (e *OrgLeague) GetPage(c *dto.OrgLeagueGetPageReq, p *actions.DataPermission, list *[]dto.OrgLeagueGetPageReply, count *int64) error {
var err error
var data models.OrgLeague
err = e.Orm.Model(&data).
Scopes(
cDto.MakeCondition(c.GetNeedSearch()),
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
actions.Permission(data.TableName(), p),
).
Find(list).Limit(-1).Offset(-1).
err = e.Orm.Table("org_match_team_player as omtp").
Select("ol.id, ol.league_name").
Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds").
Joins("left join org_league as ol on ol.id = om.league_id").
Where("ol.status=?", 1).
Where("omtp.player_id=?", c.PlayerId).
Group("om.league_id").
Find(list).
Count(count).Error
if err != nil {
e.Log.Errorf("OrgLeagueService GetPage error:%s \r\n", err)
return err
}
return nil
}
// GetPage 获取OrgLeague列表
func (e *OrgLeague) GetPageForOwn(c *dto.OrgLeagueGetPageReq, p *actions.DataPermission, list *[]dto.OrgLeagueGetPageReply, count *int64) error {
var err error
err = e.Orm.Table("org_match_team_player as omtp").
Select("ol.id, ol.league_name").
Joins("left join org_match as om on omtp.match_id = om.id and omtp.rounds = om.rounds").
Joins("left join org_league as ol on ol.id = om.league_id").
Where("ol.status=?", 1).
Where("omtp.player_id=?", c.PlayerId).
Group("om.league_id").
Find(list).
Count(count).Error
if err != nil {
e.Log.Errorf("OrgLeagueService GetPage error:%s \r\n", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment