controllers

package
v0.0.0-...-e1d4789 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSessionInfo

func GetSessionInfo(ctx *gin.Context) (*dto.SessionInfo, error)

세션 정보를 추출하는 함수

func RegisterRoutes

func RegisterRoutes(controllers Controllers, rg *gin.RouterGroup)

Types

type CommentController

type CommentController struct {
	CommentService services.CommentService
	// contains filtered or unexported fields
}

func NewCommentController

func NewCommentController(commentservice services.CommentService) CommentController

func (*CommentController) CreateComment

func (cc *CommentController) CreateComment(ctx *gin.Context)

CreateComment godoc

@Summary		write the comment
@Tags			CRUD comment
@Description	write the comment to mongodb
@Description	id string | post id for comment
@Description	content string | comment content
@Accept			json
@Produce		json
@Param			comment	body		dto.CreateCommentRequest	true	"Comment Data"
@Success		200		{string}	success
@Router			/comment/create [post]

func (*CommentController) DeleteComment

func (cc *CommentController) DeleteComment(ctx *gin.Context)

DeleteComment godoc

@Summary		delete the comment
@Tags			CRUD comment
@Description	comment owner delete the comment from DB
@Accept			json
@Produce		json
@Param			comment_id	path		string	true	"comment_id"
@Success		200			{string}	success
@Router			/comment/delete/{comment_id} [delete]

func (*CommentController) GetComments

func (cc *CommentController) GetComments(ctx *gin.Context)

GetComments godoc

@Summary		get post comments
@Tags			CRUD comment
@Description	get post comments to mongodb
@Description	type = 1, 2 | search comments type 1: post id, type 2: comment author
@Description	body sring | Check whether the search body is included in the type search results
@Accept			json
@Produce		json
@Param			id	body		dto.GetCommentRequest	true	"post id"
@Success		200	{object}	[]models.Comment
@Router			/comment/get/ [post]

func (*CommentController) RegisterCommentRoutes

func (cc *CommentController) RegisterCommentRoutes(rg *gin.RouterGroup)

func (*CommentController) UpdateComment

func (cc *CommentController) UpdateComment(ctx *gin.Context)

UpdateComment godoc

@Summary		update regular user data
@Tags			CRUD comment
@Description	comment owner update regular user informations to mongodb
@Accept			json
@Produce		json
@Param			comment	request		body	dto.CreateCommentRequest	true	"Comment update request"
@Success		200		{string}	success
@Router			/comment/update [patch]

type Controllers

type Controllers struct {
	UserController    UserController
	PostController    PostController
	CommentController CommentController
}

func New

func New(redisclient *redis.Client, services services.Services, googleOauthConfig *oauth2.Config, oauthStateString string) Controllers

type PostController

type PostController struct {
	PostService services.PostService
	// contains filtered or unexported fields
}

func NewPostController

func NewPostController(postservice services.PostService) PostController

func (*PostController) CreatePost

func (pc *PostController) CreatePost(ctx *gin.Context)

CreatePost godoc

@Summary		upload the post
@Tags			CRUD post
@Description	write post data to mongodb
@Accept			json
@Produce		json
@Param			post_request	body		dto.CreatePostRequest	true	"Post request"
@Success		200				{string}	success
@Router			/post/create [post]

func (*PostController) DeletePost

func (pc *PostController) DeletePost(ctx *gin.Context)

DeletePost godoc

@Summary		delete the post
@Tags			CRUD post
@Description	delete the post from DB
@Description	parameter post_id | specific post id
@Accept			json
@Produce		json
@Param			post_id	path		string	true	"post_id"
@Success		200		{string}	success
@Router			/post/delete/{post_id} [delete]

func (*PostController) GetAllPosts

func (pc *PostController) GetAllPosts(ctx *gin.Context)

GetAllPosts godoc

@Summary		get all posts
@Tags			CRUD post
@Description	get all posts by pagination
@Description	page_num int64 | page number
@Description	page_size int64 | number of post in page
@Accept			json
@Produce		json
@Param			page_request	body		dto.PaginationRequest	true	"Page request"
@Success		200				{string}	success
@Router			/post/getall [post]

func (*PostController) GetPosts

func (pc *PostController) GetPosts(ctx *gin.Context)

GetPosts godoc

@Summary		get posts
@Tags			CRUD post
@Description	get posts from DB
@Description	type = 1, 2, 3 | search posts type 1: title, type 2: content, type 3: author
@Description	body = string | Check whether the search body is included in the type search results
@Accept			json
@Produce		json
@Param			user	body		dto.GetPostRequest	true	"Post request"
@Success		200		{object}	models.User
@Router			/post/get [POST]

func (*PostController) JudgePost

func (pc *PostController) JudgePost(ctx *gin.Context)

JudgePost godoc

@Summary		report the post
@Tags			CRUD post
@Description	write report of the post to DB
@Description	type uint8 | type 1: insult, type 2: sexual, type 3: violent
@Description	id	string | specific violated post id
@Description	body string | details of violation
@Accept			json
@Produce		json
@Param			judge_request	body		models.Judge	true	"Judge request"
@Success		200				{string}	success
@Router			/post/judge [post]

func (*PostController) LikePost

func (pc *PostController) LikePost(ctx *gin.Context)

LikePost godoc

@Summary		sign up regular user
@Tags			CRUD post
@Description	write user informations to mongodb
@Description	id string | specific post id
@Description	like bool | true: like it, false: unlike it
@Accept			json
@Produce		json
@Param			like_request	body		dto.PostLikeRequest	true	"Like request"
@Success		200				{string}	success
@Router			/post/like [post]

func (*PostController) RegisterPostRoutes

func (pc *PostController) RegisterPostRoutes(rg *gin.RouterGroup)

func (*PostController) UpdatePost

func (pc *PostController) UpdatePost(ctx *gin.Context)

UpdateUser godoc

@Summary		update the post
@Tags			CRUD post
@Description	post owner update the post
@Description	parameter post_id | specific post id
@Description	title string | title you want to change
@Description	content string | content you want to change
@Accept			json
@Produce		json
@Param			post	body		dto.CreatePostRequest	true	"Update data"
@Param			post_id	path		string					true	"post_id"
@Success		200		{string}	success
@Router			/post/update/{post_id} [patch]

type UserController

type UserController struct {
	UserService services.UserService
	// contains filtered or unexported fields
}

func NewUserController

func NewUserController(redisclient *redis.Client, userservice services.UserService, googleOauthConfig *oauth2.Config, oauthStateString string) UserController

func (*UserController) CreateUser

func (uc *UserController) CreateUser(ctx *gin.Context)

RegisterUser godoc

@Summary		sign up regular user
@Tags			CRUD user
@Description	write user informations to mongodb
@Accept			json
@Produce		json
@Param			user	body		models.User	true	"User Data"
@Success		200		{string}	success
@Router			/register/create [post]

func (*UserController) DeleteUser

func (uc *UserController) DeleteUser(ctx *gin.Context)

DeleteUser godoc

@Summary		delete regular user data
@Tags			CRUD user
@Description	delete user information in mongodb
@Accept			json
@Produce		json
@Param			id	path		string	true	"regular_user_id"
@Success		200	{string}	success
@Router			/register/delete/{id} [delete]

func (*UserController) GetAll

func (uc *UserController) GetAll(ctx *gin.Context)

GetAllUser godoc

@Summary		get user data
@Tags			CRUD user
@Description	get all regular user informations to mongodb
@Accept			json
@Produce		json
@Success		200	{object}	[]models.User
@Router			/register/getall [get]

func (*UserController) GetUser

func (uc *UserController) GetUser(ctx *gin.Context)

GetUser godoc

@Summary		get user data
@Tags			CRUD user
@Description	get regular user informations to mongodb
@Accept			json
@Produce		json
@Param			id	path		string	true	"regular_user_id"
@Success		200	{object}	models.User
@Router			/register/get/{id} [get]

func (*UserController) GoogleSignIn

func (uc *UserController) GoogleSignIn(ctx *gin.Context)

GoogleSignIn godoc

@Summary		sign up google user
@Tags			sign in/out google user
@Description	sign out google user
@Accept			json
@Produce		json
@Success		200	{string}	success
@Header			200	{string}	Set-Cookie	"Session Cookie"
@Router			/login/glogin [get]

func (*UserController) GoogleSignInCallback

func (uc *UserController) GoogleSignInCallback(ctx *gin.Context)

func (*UserController) GoogleSignOut

func (uc *UserController) GoogleSignOut(ctx *gin.Context)

GoogleSignOut godoc

@Summary		sign out google user
@Tags			sign in/out google user
@Description	sign out google user
@Accept			json
@Produce		json
@Param			google_user_session	header		string	true	"Session Cookie"
@Success		200					{string}	success
@Router			/login/glogout [get]

func (*UserController) RegisterUserRoutes

func (uc *UserController) RegisterUserRoutes(rg *gin.RouterGroup)

func (*UserController) SignIn

func (uc *UserController) SignIn(ctx *gin.Context)

SignIn godoc

@Summary		sign in regular user
@Tags			sign in/out regular user
@Description	sign in regular user
@Accept			json
@Produce		json
@Param			user	body		dto.SignInRequest	true	"regular login data"
@Success		200		{string}	success
@Header			200		{string}	Set-Cookie	"Session Cookie"
@Router			/login/signin [post]

func (*UserController) SignOut

func (uc *UserController) SignOut(ctx *gin.Context)

SignOut godoc

@Summary		sign out regular user
@Tags			sign in/out regular user
@Description	sign out regular user
@Accept			json
@Produce		json
@Param			regular_user_session	header		string	true	"Session Cookie"
@Success		200						{string}	success
@Router			/login/signout [post]

func (*UserController) UpdateUser

func (uc *UserController) UpdateUser(ctx *gin.Context)

UpdateUser godoc

@Summary		update regular user data
@Tags			CRUD user
@Description	update regular user informations to mongodb
@Accept			json
@Produce		json
@Param			user	body		models.User	true	"User data"
@Success		200		{string}	success
@Router			/register/update [patch]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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