This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SearchUserVerificationDto swagger model
|
|
||||||
type SearchUserVerificationDto struct {
|
type SearchUserVerificationDto struct {
|
||||||
PaginationDto
|
PaginationDto
|
||||||
Sort string `json:"sort" query:"sort" validate:"omitempty,oneof=id created_at reviewed_at status"`
|
Sort string `json:"sort" query:"sort" validate:"omitempty,oneof=id created_at reviewed_at status"`
|
||||||
@@ -17,14 +16,12 @@ type SearchUserVerificationDto struct {
|
|||||||
CreatedTo *time.Time `json:"created_to" query:"created_to"`
|
CreatedTo *time.Time `json:"created_to" query:"created_to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateUserVerificationDto swagger model
|
|
||||||
type CreateUserVerificationDto struct {
|
type CreateUserVerificationDto struct {
|
||||||
VerifyType string `json:"verify_type" validate:"required,oneof=ID_CARD EDUCATION EXPERT OTHER"`
|
VerifyType string `json:"verify_type" validate:"required,oneof=ID_CARD EDUCATION EXPERT OTHER"`
|
||||||
Content string `json:"content" validate:"required,min=10"`
|
Content string `json:"content" validate:"required,min=10"`
|
||||||
MediaIDs []string `json:"media_ids" validate:"omitempty,dive,uuid"`
|
MediaIDs []string `json:"media_ids" validate:"omitempty,dive,uuid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateVerificationStatusDto swagger model
|
|
||||||
type UpdateVerificationStatusDto struct {
|
type UpdateVerificationStatusDto struct {
|
||||||
Status string `json:"status" validate:"required,oneof=PENDING APPROVED REJECTED"`
|
Status string `json:"status" validate:"required,oneof=PENDING APPROVED REJECTED"`
|
||||||
ReviewNote string `json:"review_note" validate:"required,min=5,max=3000"`
|
ReviewNote string `json:"review_note" validate:"required,min=5,max=3000"`
|
||||||
|
|||||||
@@ -11,17 +11,6 @@ import (
|
|||||||
|
|
||||||
func MediaRoutes(app *fiber.App, controller *controllers.MediaController, userRepo repositories.UserRepository) {
|
func MediaRoutes(app *fiber.App, controller *controllers.MediaController, userRepo repositories.UserRepository) {
|
||||||
route := app.Group("/media")
|
route := app.Group("/media")
|
||||||
route.Get(
|
|
||||||
"/",
|
|
||||||
middlewares.JwtAccess(userRepo),
|
|
||||||
middlewares.RequireAnyRole(constants.ADMIN, constants.MOD),
|
|
||||||
controller.SearchMedia,
|
|
||||||
)
|
|
||||||
route.Delete(
|
|
||||||
"/",
|
|
||||||
middlewares.JwtAccess(userRepo),
|
|
||||||
controller.BulkDeleteMedia,
|
|
||||||
)
|
|
||||||
|
|
||||||
route.Post(
|
route.Post(
|
||||||
"/upload",
|
"/upload",
|
||||||
@@ -55,4 +44,16 @@ func MediaRoutes(app *fiber.App, controller *controllers.MediaController, userRe
|
|||||||
controller.DeleteMedia,
|
controller.DeleteMedia,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
route.Get(
|
||||||
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
|
middlewares.RequireAnyRole(constants.ADMIN, constants.MOD),
|
||||||
|
controller.SearchMedia,
|
||||||
|
)
|
||||||
|
route.Delete(
|
||||||
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
|
controller.BulkDeleteMedia,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,16 @@ import (
|
|||||||
|
|
||||||
func RoleRoutes(app *fiber.App, controller *controllers.RoleController, userRepo repositories.UserRepository) {
|
func RoleRoutes(app *fiber.App, controller *controllers.RoleController, userRepo repositories.UserRepository) {
|
||||||
route := app.Group("/roles")
|
route := app.Group("/roles")
|
||||||
route.Get(
|
|
||||||
"/",
|
|
||||||
middlewares.JwtAccess(userRepo),
|
|
||||||
controller.GetAllRole,
|
|
||||||
)
|
|
||||||
|
|
||||||
route.Get(
|
route.Get(
|
||||||
"/:id",
|
"/:id",
|
||||||
middlewares.JwtAccess(userRepo),
|
middlewares.JwtAccess(userRepo),
|
||||||
controller.GetRoleById,
|
controller.GetRoleById,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
route.Get(
|
||||||
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
|
controller.GetAllRole,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,6 @@ import (
|
|||||||
func UserRoutes(app *fiber.App, controller *controllers.UserController, userRepo repositories.UserRepository) {
|
func UserRoutes(app *fiber.App, controller *controllers.UserController, userRepo repositories.UserRepository) {
|
||||||
route := app.Group("/users")
|
route := app.Group("/users")
|
||||||
|
|
||||||
route.Get(
|
|
||||||
"/",
|
|
||||||
middlewares.JwtAccess(userRepo),
|
|
||||||
middlewares.RequireAnyRole(constants.ADMIN, constants.MOD),
|
|
||||||
controller.SearchUser,
|
|
||||||
)
|
|
||||||
|
|
||||||
route.Get(
|
route.Get(
|
||||||
"/current",
|
"/current",
|
||||||
middlewares.JwtAccess(userRepo),
|
middlewares.JwtAccess(userRepo),
|
||||||
@@ -90,4 +83,12 @@ func UserRoutes(app *fiber.App, controller *controllers.UserController, userRepo
|
|||||||
middlewares.JwtAccess(userRepo),
|
middlewares.JwtAccess(userRepo),
|
||||||
controller.ChangePassword,
|
controller.ChangePassword,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
route.Get(
|
||||||
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
|
middlewares.RequireAnyRole(constants.ADMIN, constants.MOD),
|
||||||
|
controller.SearchUser,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,19 +11,6 @@ import (
|
|||||||
|
|
||||||
func VerificationRoutes(app *fiber.App, controller *controllers.VerificationController, userRepo repositories.UserRepository) {
|
func VerificationRoutes(app *fiber.App, controller *controllers.VerificationController, userRepo repositories.UserRepository) {
|
||||||
route := app.Group("/historian/application")
|
route := app.Group("/historian/application")
|
||||||
route.Get(
|
|
||||||
"/",
|
|
||||||
middlewares.JwtAccess(userRepo),
|
|
||||||
middlewares.RequireAnyRole(constants.ADMIN, constants.MOD),
|
|
||||||
controller.SearchVerification,
|
|
||||||
)
|
|
||||||
|
|
||||||
route.Post(
|
|
||||||
"/",
|
|
||||||
middlewares.JwtAccess(userRepo),
|
|
||||||
middlewares.ForbidRoles(constants.HISTORIAN),
|
|
||||||
controller.CreateVerification,
|
|
||||||
)
|
|
||||||
|
|
||||||
route.Get(
|
route.Get(
|
||||||
"/:id",
|
"/:id",
|
||||||
@@ -45,4 +32,18 @@ func VerificationRoutes(app *fiber.App, controller *controllers.VerificationCont
|
|||||||
controller.UpdateVerificationStatus,
|
controller.UpdateVerificationStatus,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
route.Get(
|
||||||
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
|
middlewares.RequireAnyRole(constants.ADMIN, constants.MOD),
|
||||||
|
controller.SearchVerification,
|
||||||
|
)
|
||||||
|
|
||||||
|
route.Post(
|
||||||
|
"/",
|
||||||
|
middlewares.JwtAccess(userRepo),
|
||||||
|
middlewares.ForbidRoles(constants.HISTORIAN),
|
||||||
|
controller.CreateVerification,
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -285,6 +285,7 @@ func (a *authService) Signup(ctx context.Context, dto *request.SignUpDto) (*resp
|
|||||||
String: string(hashed),
|
String: string(hashed),
|
||||||
Valid: len(hashed) != 0,
|
Valid: len(hashed) != 0,
|
||||||
},
|
},
|
||||||
|
AuthProvider: constants.LocalProvider.String(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -226,8 +226,9 @@ func (m *mediaService) SearchMedia(ctx context.Context, dto *request.SearchMedia
|
|||||||
if err := g.Wait(); err != nil {
|
if err := g.Wait(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
media := models.MediaEntitiesToResponse(rows)
|
||||||
|
|
||||||
return response.BuildPaginatedResponse(rows, totalRecords, dto.Page, dto.Limit), nil
|
return response.BuildPaginatedResponse(media, totalRecords, dto.Page, dto.Limit), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mediaService) UploadServerSide(ctx context.Context, userId string, fileHeader *multipart.FileHeader) (*response.MediaResponse, error) {
|
func (m *mediaService) UploadServerSide(ctx context.Context, userId string, fileHeader *multipart.FileHeader) (*response.MediaResponse, error) {
|
||||||
|
|||||||
@@ -376,7 +376,9 @@ func (u *userService) SearchUser(ctx context.Context, dto *request.SearchUserDto
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.BuildPaginatedResponse(rows, totalRecords, dto.Page, dto.Limit), nil
|
users := models.UsersEntityToResponse(rows)
|
||||||
|
|
||||||
|
return response.BuildPaginatedResponse(users, totalRecords, dto.Page, dto.Limit), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *userService) GetUserByID(ctx context.Context, userId string) (*response.UserResponse, error) {
|
func (u *userService) GetUserByID(ctx context.Context, userId string) (*response.UserResponse, error) {
|
||||||
|
|||||||
@@ -265,7 +265,9 @@ func (v *verificationService) SearchVerification(ctx context.Context, dto *reque
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.BuildPaginatedResponse(rows, totalRecords, dto.Page, dto.Limit), nil
|
verifications := models.UserVerificationsEntitiesToResponse(rows)
|
||||||
|
|
||||||
|
return response.BuildPaginatedResponse(verifications, totalRecords, dto.Page, dto.Limit), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *verificationService) UpdateStatusVerification(ctx context.Context, userId string, verificationId string, dto *request.UpdateVerificationStatusDto) (*response.UserVerificationResponse, error) {
|
func (v *verificationService) UpdateStatusVerification(ctx context.Context, userId string, verificationId string, dto *request.UpdateVerificationStatusDto) (*response.UserVerificationResponse, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user