handlers

package
v0.0.0-...-be8c906 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogTypeMod    string = "Mod"
	LogTypeUser   string = "User"
	LogTypeRecord string = "Record"

	LogDescriptionUserLoginSuccess         string = "LoginSuccess"
	LogDescriptionUserLoginFailToken       string = "LoginTokenFail"
	LogDescriptionUserLoginFailValidate    string = "LoginValidateFail"
	LogDescriptionUserLoginFailSummary     string = "LoginSummaryFail"
	LogDescriptionUserUpdateSuccess        string = "UpdateSuccess"
	LogDescriptionUserUpdateFail           string = "UpdateFail"
	LogDescriptionUserUpdateSummaryFail    string = "UpdateSummaryFail"
	LogDescriptionUserUpdateCountrySuccess string = "UpdateCountrySuccess"
	LogDescriptionUserUpdateCountryFail    string = "UpdateCountryFail"

	LogDescriptionMapSummaryCreateSuccess    string = "MapSummaryCreateSuccess"
	LogDescriptionMapSummaryCreateFail       string = "MapSummaryCreateFail"
	LogDescriptionMapSummaryEditSuccess      string = "MapSummaryEditSuccess"
	LogDescriptionMapSummaryEditFail         string = "MapSummaryEditFail"
	LogDescriptionMapSummaryEditImageSuccess string = "MapSummaryEditImageSuccess"
	LogDescriptionMapSummaryEditImageFail    string = "MapSummaryEditImageFail"
	LogDescriptionMapSummaryDeleteSuccess    string = "MapSummaryDeleteSuccess"
	LogDescriptionMapSummaryDeleteFail       string = "MapSummaryDeleteFail"

	LogDescriptionCreateRecordSuccess            string = "CreateRecordSuccess"
	LogDescriptionCreateRecordInsertRecordFail   string = "InsertRecordFail"
	LogDescriptionCreateRecordInsertDemoFail     string = "InsertDemoFail"
	LogDescriptionCreateRecordProcessDemoFail    string = "ProcessDemoFail"
	LogDescriptionCreateRecordCreateDemoFail     string = "CreateDemoFail"
	LogDescriptionCreateRecordOpenDemoFail       string = "OpenDemoFail"
	LogDescriptionCreateRecordSaveDemoFail       string = "SaveDemoFail"
	LogDescriptionCreateRecordInvalidRequestFail string = "InvalidRequestFail"
	LogDescriptionDeleteRecordSuccess            string = "DeleteRecordSuccess"
	LogDescriptionDeleteRecordFail               string = "DeleteRecordFail"
)

Variables

This section is empty.

Functions

func CreateLog

func CreateLog(userID string, logType string, logDescription string, logMessage ...string) (err error)

func CreateMapDiscussion

func CreateMapDiscussion(c *gin.Context)

POST Map Discussion

@Description	Create map discussion with specified map id.
@Tags			maps / discussions
@Produce		json
@Param			Authorization	header		string						true	"JWT Token"
@Param			mapid			path		int							true	"Map ID"
@Param			request			body		CreateMapDiscussionRequest	true	"Body"
@Success		200				{object}	models.Response{data=CreateMapDiscussionRequest}
@Router			/maps/{mapid}/discussions [post]

func CreateMapDiscussionComment

func CreateMapDiscussionComment(c *gin.Context)

POST Map Discussion Comment

@Description	Create map discussion comment with specified map id.
@Tags			maps / discussions
@Produce		json
@Param			Authorization	header		string								true	"JWT Token"
@Param			mapid			path		int									true	"Map ID"
@Param			discussionid	path		int									true	"Discussion ID"
@Param			request			body		CreateMapDiscussionCommentRequest	true	"Body"
@Success		200				{object}	models.Response{data=CreateMapDiscussionCommentRequest}
@Router			/maps/{mapid}/discussions/{discussionid} [post]

func CreateMapSummary

func CreateMapSummary(c *gin.Context)

POST Map Summary

@Description	Create map summary with specified map id.
@Tags			maps / summary
@Produce		json
@Param			Authorization	header		string					true	"JWT Token"
@Param			mapid			path		int						true	"Map ID"
@Param			request			body		CreateMapSummaryRequest	true	"Body"
@Success		200				{object}	models.Response{data=CreateMapSummaryRequest}
@Router			/maps/{mapid}/summary [post]

func CreateRecordWithDemo

func CreateRecordWithDemo(c *gin.Context)

POST Record

@Description	Post record with demo of a specific map.
@Tags			maps / leaderboards
@Accept			mpfd
@Produce		json
@Param			mapid				path		int		true	"Map ID"
@Param			Authorization		header		string	true	"JWT Token"
@Param			host_demo			formData	file	true	"Host Demo"
@Param			partner_demo		formData	file	false	"Partner Demo"
@Param			is_partner_orange	formData	boolean	false	"Is Partner Orange"
@Param			partner_id			formData	string	false	"Partner ID"
@Success		200					{object}	models.Response{data=RecordResponse}
@Router			/maps/{mapid}/record [post]

func DeleteCookie

func DeleteCookie(c *gin.Context)

DELETE Token

@Description	Deletes the token cookie from the user.
@Tags			auth
@Produce		json

@Success		200	{object}	models.Response{data=LoginResponse}
@Failure		404	{object}	models.Response
@Router			/token [delete]

func DeleteMapDiscussion

func DeleteMapDiscussion(c *gin.Context)

DELETE Map Discussion

@Description	Delete map discussion with specified map id.
@Tags			maps / discussions
@Produce		json
@Param			Authorization	header		string	true	"JWT Token"
@Param			mapid			path		int		true	"Map ID"
@Param			discussionid	path		int		true	"Discussion ID"
@Success		200				{object}	models.Response
@Router			/maps/{mapid}/discussions/{discussionid} [delete]

func DeleteMapSummary

func DeleteMapSummary(c *gin.Context)

DELETE Map Summary

@Description	Delete map summary with specified map id.
@Tags			maps / summary
@Produce		json
@Param			Authorization	header		string					true	"JWT Token"
@Param			mapid			path		int						true	"Map ID"
@Param			request			body		DeleteMapSummaryRequest	true	"Body"
@Success		200				{object}	models.Response{data=DeleteMapSummaryRequest}
@Router			/maps/{mapid}/summary [delete]

func DeleteRecord

func DeleteRecord(c *gin.Context)

DELETE Record

@Description	Delete record with specified map and record id.
@Tags			maps / leaderboards
@Produce		json
@Param			mapid			path		int		true	"Map ID"
@Param			recordid		path		int		true	"Record ID"
@Param			Authorization	header		string	true	"JWT Token"
@Success		200				{object}	models.Response
@Router			/maps/{mapid}/record/{recordid} [delete]

func DownloadDemoWithID

func DownloadDemoWithID(c *gin.Context)

GET Demo

@Description	Get demo with specified demo uuid.
@Tags			demo
@Accept			json
@Produce		octet-stream
@Param			uuid	query	string	true	"Demo UUID"
@Success		200		{file}	binary	"Demo File"
@Router			/demos [get]

func EditMapDiscussion

func EditMapDiscussion(c *gin.Context)

PUT Map Discussion

@Description	Edit map discussion with specified map id.
@Tags			maps / discussions
@Produce		json
@Param			Authorization	header		string						true	"JWT Token"
@Param			mapid			path		int							true	"Map ID"
@Param			discussionid	path		int							true	"Discussion ID"
@Param			request			body		EditMapDiscussionRequest	true	"Body"
@Success		200				{object}	models.Response{data=EditMapDiscussionRequest}
@Router			/maps/{mapid}/discussions/{discussionid} [put]

func EditMapImage

func EditMapImage(c *gin.Context)

PUT Map Image

@Description	Edit map image with specified map id.
@Tags			maps / summary
@Produce		json
@Param			Authorization	header		string				true	"JWT Token"
@Param			mapid			path		int					true	"Map ID"
@Param			request			body		EditMapImageRequest	true	"Body"
@Success		200				{object}	models.Response{data=EditMapImageRequest}
@Router			/maps/{mapid}/image [put]

func EditMapSummary

func EditMapSummary(c *gin.Context)

PUT Map Summary

@Description	Edit map summary with specified map id.
@Tags			maps / summary
@Produce		json
@Param			Authorization	header		string					true	"JWT Token"
@Param			mapid			path		int						true	"Map ID"
@Param			request			body		EditMapSummaryRequest	true	"Body"
@Success		200				{object}	models.Response{data=EditMapSummaryRequest}
@Router			/maps/{mapid}/summary [put]

func FetchChapterMaps

func FetchChapterMaps(c *gin.Context)

GET Maps of a Chapter

@Description	Get maps from the specified chapter id.
@Tags			games & chapters
@Produce		json
@Param			chapterid	path		int	true	"Chapter ID"
@Success		200			{object}	models.Response{data=ChapterMapsResponse}
@Failure		400			{object}	models.Response
@Router			/chapters/{chapterid} [get]

func FetchChapters

func FetchChapters(c *gin.Context)

GET Chapters of a Game

@Description	Get chapters from the specified game id.
@Tags			games & chapters
@Produce		json
@Param			gameid	path		int	true	"Game ID"
@Success		200		{object}	models.Response{data=ChaptersResponse}
@Router			/games/{gameid} [get]

func FetchGames

func FetchGames(c *gin.Context)

GET Games

@Description	Get games from the leaderboards.
@Tags			games & chapters
@Produce		json
@Success		200	{object}	models.Response{data=[]models.Game}
@Failure		400	{object}	models.Response
@Router			/games [get]

func FetchMapDiscussion

func FetchMapDiscussion(c *gin.Context)

GET Map Discussion

@Description	Get map discussion with specified map and discussion id.
@Tags			maps / discussions
@Produce		json
@Param			mapid			path		int	true	"Map ID"
@Param			discussionid	path		int	true	"Discussion ID"
@Success		200				{object}	models.Response{data=MapDiscussionResponse}
@Router			/maps/{mapid}/discussions/{discussionid} [get]

func FetchMapDiscussions

func FetchMapDiscussions(c *gin.Context)

GET Map Discussions

@Description	Get map discussions with specified map id.
@Tags			maps / discussions
@Produce		json
@Param			mapid	path		int	true	"Map ID"
@Success		200		{object}	models.Response{data=MapDiscussionsResponse}
@Router			/maps/{mapid}/discussions [get]

func FetchMapLeaderboards

func FetchMapLeaderboards(c *gin.Context)

GET Map Leaderboards

@Description	Get map leaderboards with specified id.
@Tags			maps / leaderboards
@Produce		json
@Param			mapid		path		int	true	"Map ID"
@Param			page		query		int	false	"Page Number (default: 1)"
@Param			pageSize	query		int	false	"Number of Records Per Page (default: 20)"
@Success		200			{object}	models.Response{data=MapLeaderboardsResponse}
@Router			/maps/{mapid}/leaderboards [get]

func FetchMapSummary

func FetchMapSummary(c *gin.Context)

GET Map Summary

@Description	Get map summary with specified id.
@Tags			maps / summary
@Produce		json
@Param			mapid	path		int	true	"Map ID"
@Success		200		{object}	models.Response{data=MapSummaryResponse}
@Router			/maps/{mapid}/summary [get]

func FetchMaps

func FetchMaps(c *gin.Context)

GET Maps of a Game

@Description	Get maps from the specified game id.
@Tags			games & chapters
@Produce		json
@Param			gameid	path		int	true	"Game ID"
@Success		200		{object}	models.Response{data=ChaptersResponse}
@Router			/games/{gameid}/maps [get]

func FetchUser

func FetchUser(c *gin.Context)

GET User

@Description	Get profile page of another user.
@Tags			users
@Accept			json
@Produce		json
@Param			userid	path		int	true	"User ID"
@Success		200		{object}	models.Response{data=ProfileResponse}
@Router			/users/{userid} [get]

func GetCookie

func GetCookie(c *gin.Context)

GET Token

@Description	Gets the token cookie value from the user.
@Tags			auth
@Produce		json

@Success		200	{object}	models.Response{data=LoginResponse}
@Failure		404	{object}	models.Response
@Router			/token [get]

func GetPlayerSummaries

func GetPlayerSummaries(steamId, apiKey string) (models.PlayerSummaries, error)

func Login

func Login(c *gin.Context)

Login

@Description	Get (redirect) login page for Steam auth.
@Tags			login
@Accept			json
@Produce		json
@Success		200	{object}	models.Response{data=LoginResponse}
@Router			/login [get]

func ModLogs

func ModLogs(c *gin.Context)

GET Mod Logs

@Description	Get mod logs.
@Tags			logs
@Produce		json
@Param			Authorization	header		string	true	"JWT Token"
@Success		200				{object}	models.Response{data=LogsResponse}
@Router			/logs/mod [get]

func Profile

func Profile(c *gin.Context)

GET Profile

@Description	Get profile page of session user.
@Tags			users
@Accept			json
@Produce		json
@Param			Authorization	header		string	true	"JWT Token"
@Success		200				{object}	models.Response{data=ProfileResponse}
@Router			/profile [get]

func Rankings

func Rankings(c *gin.Context)

GET Rankings

@Description	Get rankings of every player.
@Tags			rankings
@Produce		json
@Success		200	{object}	models.Response{data=RankingsResponse}
@Router			/rankings [get]

func ScoreLogs

func ScoreLogs(c *gin.Context)

GET Score Logs

@Description	Get score logs of every player.
@Tags			logs
@Produce		json
@Success		200	{object}	models.Response{data=ScoreLogsResponse}
@Router			/logs/score [get]

func SearchWithQuery

func SearchWithQuery(c *gin.Context)

GET Search With Query

@Description	Get all user and map data matching to the query.
@Tags			search
@Produce		json
@Param			q	query		string	false	"Search user or map name."
@Success		200	{object}	models.Response{data=SearchResponse}
@Router			/search [get]

func UpdateCountryCode

func UpdateCountryCode(c *gin.Context)

PUT Profile/CountryCode

@Description	Update country code of session user.
@Tags			users
@Accept			json
@Produce		json
@Param			Authorization	header		string	true	"JWT Token"
@Param			country_code	query		string	true	"Country Code [XX]"
@Success		200				{object}	models.Response
@Router			/profile [put]

func UpdateUser

func UpdateUser(c *gin.Context)

PUT Profile

@Description	Update profile page of session user.
@Tags			users
@Accept			json
@Produce		json
@Param			Authorization	header		string	true	"JWT Token"
@Success		200				{object}	models.Response{data=ProfileResponse}
@Router			/profile [post]

Types

type ChapterMapsResponse

type ChapterMapsResponse struct {
	Chapter models.Chapter    `json:"chapter"`
	Maps    []models.MapShort `json:"maps"`
}

type ChaptersResponse

type ChaptersResponse struct {
	Game     models.Game      `json:"game"`
	Chapters []models.Chapter `json:"chapters"`
}

type CreateMapDiscussionCommentRequest

type CreateMapDiscussionCommentRequest struct {
	Comment string `json:"comment" binding:"required"`
}

type CreateMapDiscussionRequest

type CreateMapDiscussionRequest struct {
	Title   string `json:"title" binding:"required"`
	Content string `json:"content" binding:"required"`
}

type CreateMapSummaryRequest

type CreateMapSummaryRequest struct {
	CategoryID  int       `json:"category_id" binding:"required"`
	Description string    `json:"description" binding:"required"`
	Showcase    string    `json:"showcase"`
	UserName    string    `json:"user_name" binding:"required"`
	ScoreCount  *int      `json:"score_count"`
	RecordDate  time.Time `json:"record_date" binding:"required"`
}

type DeleteMapSummaryRequest

type DeleteMapSummaryRequest struct {
	RouteID int `json:"route_id" binding:"required"`
}

type EditMapDiscussionRequest

type EditMapDiscussionRequest struct {
	Title   string `json:"title" binding:"required"`
	Content string `json:"content" binding:"required"`
}

type EditMapImageRequest

type EditMapImageRequest struct {
	Image string `json:"image" binding:"required"`
}

type EditMapSummaryRequest

type EditMapSummaryRequest struct {
	RouteID     int       `json:"route_id" binding:"required"`
	Description string    `json:"description" binding:"required"`
	Showcase    string    `json:"showcase"`
	UserName    string    `json:"user_name" binding:"required"`
	ScoreCount  int       `json:"score_count"`
	RecordDate  time.Time `json:"record_date" binding:"required"`
}

type GameMapsResponse

type GameMapsResponse struct {
	Game models.Game       `json:"game"`
	Maps []models.MapShort `json:"maps"`
}

type Log

type Log struct {
	User        models.UserShort `json:"user"`
	Type        string           `json:"type"`
	Description string           `json:"description"`
	Message     string           `json:"message"`
	Date        time.Time        `json:"date"`
}

type LoginResponse

type LoginResponse struct {
	Token string `json:"token"`
}

type LogsResponse

type LogsResponse struct {
	Logs []LogsResponseDetails `json:"logs"`
}

type LogsResponseDetails

type LogsResponseDetails struct {
	User    models.UserShort `json:"user"`
	Log     string           `json:"detail"`
	Message string           `json:"message"`
	Date    time.Time        `json:"date"`
}

type MapDiscussion

type MapDiscussion struct {
	ID      int                        `json:"id"`
	Creator models.UserShortWithAvatar `json:"creator"`
	Title   string                     `json:"title"`
	Content string                     `json:"content"`
	// Upvotes   int                        `json:"upvotes"`
	CreatedAt time.Time              `json:"created_at"`
	UpdatedAt time.Time              `json:"updated_at"`
	Comments  []MapDiscussionComment `json:"comments"`
}

type MapDiscussionComment

type MapDiscussionComment struct {
	User    models.UserShortWithAvatar `json:"user"`
	Comment string                     `json:"comment"`
	Date    time.Time                  `json:"date"`
}

type MapDiscussionResponse

type MapDiscussionResponse struct {
	Discussion MapDiscussion `json:"discussion"`
}

type MapDiscussionsResponse

type MapDiscussionsResponse struct {
	Discussions []MapDiscussion `json:"discussions"`
}

type MapLeaderboardsResponse

type MapLeaderboardsResponse struct {
	Map        models.Map        `json:"map"`
	Records    any               `json:"records"`
	Pagination models.Pagination `json:"pagination"`
}

type MapShortWithGame

type MapShortWithGame struct {
	ID      int    `json:"id"`
	Game    string `json:"game"`
	Chapter string `json:"chapter"`
	Map     string `json:"map"`
}

type MapSummaryResponse

type MapSummaryResponse struct {
	Map     models.Map        `json:"map"`
	Summary models.MapSummary `json:"summary"`
}

type ProfileRankings

type ProfileRankings struct {
	Overall      ProfileRankingsDetails `json:"overall"`
	Singleplayer ProfileRankingsDetails `json:"singleplayer"`
	Cooperative  ProfileRankingsDetails `json:"cooperative"`
}

type ProfileRankingsDetails

type ProfileRankingsDetails struct {
	Rank            int `json:"rank"`
	CompletionCount int `json:"completion_count"`
	CompletionTotal int `json:"completion_total"`
}

type ProfileRecords

type ProfileRecords struct {
	GameID     int             `json:"game_id"`
	CategoryID int             `json:"category_id"`
	MapID      int             `json:"map_id"`
	MapName    string          `json:"map_name"`
	MapWRCount int             `json:"map_wr_count"`
	Placement  int             `json:"placement"`
	Scores     []ProfileScores `json:"scores"`
}

type ProfileResponse

type ProfileResponse struct {
	Profile     bool              `json:"profile"`
	SteamID     string            `json:"steam_id"`
	UserName    string            `json:"user_name"`
	AvatarLink  string            `json:"avatar_link"`
	CountryCode string            `json:"country_code"`
	Titles      []models.Title    `json:"titles"`
	Links       models.Links      `json:"links"`
	Rankings    ProfileRankings   `json:"rankings"`
	Records     []ProfileRecords  `json:"records"`
	Pagination  models.Pagination `json:"pagination"`
}

type ProfileScores

type ProfileScores struct {
	RecordID   int       `json:"record_id"`
	DemoID     string    `json:"demo_id"`
	ScoreCount int       `json:"score_count"`
	ScoreTime  int       `json:"score_time"`
	Date       time.Time `json:"date"`
}

type RankingsResponse

type RankingsResponse struct {
	Overall      []models.UserRanking `json:"rankings_overall"`
	Singleplayer []models.UserRanking `json:"rankings_singleplayer"`
	Multiplayer  []models.UserRanking `json:"rankings_multiplayer"`
}

type RecordMultiplayer

type RecordMultiplayer struct {
	Placement     int                        `json:"placement"`
	RecordID      int                        `json:"record_id"`
	ScoreCount    int                        `json:"score_count"`
	ScoreTime     int                        `json:"score_time"`
	Host          models.UserShortWithAvatar `json:"host"`
	Partner       models.UserShortWithAvatar `json:"partner"`
	HostDemoID    string                     `json:"host_demo_id"`
	PartnerDemoID string                     `json:"partner_demo_id"`
	RecordDate    time.Time                  `json:"record_date"`
}

type RecordRequest

type RecordRequest struct {
	HostDemo        *multipart.FileHeader `json:"host_demo" form:"host_demo" binding:"required" swaggerignore:"true"`
	PartnerDemo     *multipart.FileHeader `json:"partner_demo" form:"partner_demo" swaggerignore:"true"`
	IsPartnerOrange bool                  `json:"is_partner_orange" form:"is_partner_orange"`
	PartnerID       string                `json:"partner_id" form:"partner_id"`
}

type RecordResponse

type RecordResponse struct {
	ScoreCount int `json:"score_count"`
	ScoreTime  int `json:"score_time"`
}

type RecordSingleplayer

type RecordSingleplayer struct {
	Placement  int                        `json:"placement"`
	RecordID   int                        `json:"record_id"`
	ScoreCount int                        `json:"score_count"`
	ScoreTime  int                        `json:"score_time"`
	User       models.UserShortWithAvatar `json:"user"`
	DemoID     string                     `json:"demo_id"`
	RecordDate time.Time                  `json:"record_date"`
}

type ScoreLogsResponse

type ScoreLogsResponse struct {
	Logs []ScoreLogsResponseDetails `json:"scores"`
}

type ScoreLogsResponseDetails

type ScoreLogsResponseDetails struct {
	Game       models.Game      `json:"game"`
	User       models.UserShort `json:"user"`
	Map        models.MapShort  `json:"map"`
	ScoreCount int              `json:"score_count"`
	ScoreTime  int              `json:"score_time"`
	DemoID     string           `json:"demo_id"`
	Date       time.Time        `json:"date"`
}

type ScoreResponse

type ScoreResponse struct {
	MapID   int `json:"map_id"`
	Records any `json:"records"`
}

type SearchResponse

type SearchResponse struct {
	Players []models.UserShortWithAvatar `json:"players"`
	Maps    []MapShortWithGame           `json:"maps"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL