Complete Swagger documentation and validate API contracts
This commit is contained in:
parent
84d908e292
commit
e9c657e2ed
|
|
@ -62,13 +62,8 @@ import (
|
|||
|
||||
// @title Rezina API
|
||||
// @version 1.0.1
|
||||
// @description This is server for Rezina.
|
||||
// @termsOfService http://swagger.io/terms/
|
||||
// @description Rezina LMS API. Admin panel endpoints use /api/v1/admin; customer web and mobile endpoints retain /api/v1. Use the audience-specific Swagger pages to browse each API. For protected endpoints, enter Bearer followed by a space and the access token in Authorize.
|
||||
// @contact.name API Support
|
||||
// @contact.url http://www.swagger.io/support
|
||||
// @contact.email support@swagger.io
|
||||
// @license.name Apache 2.0
|
||||
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
// @SecurityDefinitions.apiKey Bearer
|
||||
// @in header
|
||||
// @name Authorization
|
||||
|
|
|
|||
|
|
@ -72,3 +72,20 @@ endpoints are not exposed.
|
|||
Run `go test ./...` in the backend and `npm run build` in the admin and checkout repositories.
|
||||
Notification SQL isolation can be checked with `node db/tests/notification-audiences.test.cjs`, using
|
||||
the scratch PGlite setup and `REFERRAL_TEST_PACKAGE_JSON` described in `referral-system.md`.
|
||||
|
||||
## Swagger maintenance
|
||||
|
||||
Run `make swagger` (or `swag init -g cmd/main.go`) after changing handler annotations. Commit
|
||||
`docs/docs.go`, `docs/swagger.json`, and `docs/swagger.yaml` together. Documentation-only operations in
|
||||
`swagger_admin_shared.go` distinguish staff-only reads from public customer operations that share a handler;
|
||||
they are not registered as runtime handlers. Referral request and response models include decimal-string
|
||||
amounts, percentage limits, nullable reversals, and pagination bounds.
|
||||
|
||||
Run `go test ./internal/web_server -run 'TestSwagger|TestGeneratedSwagger|TestAudienceSpecifications'`
|
||||
to check every registered API method/path, path parameters, request-body coverage, authorization,
|
||||
WebSocket query-token authentication, referenced schemas, and generated artifact consistency.
|
||||
The admin and customer Swagger pages prune unrelated paths and models. Their Authorize dialogs expect
|
||||
`Bearer <access_token>`; WebSockets instead use the documented `token` query parameter.
|
||||
Authentication/authorization middleware may return plain-text errors, while application handlers also
|
||||
return the JSON error shapes documented for their operations. Payment webhook authentication uses the
|
||||
provider signature headers, not a customer Bearer token.
|
||||
|
|
|
|||
9202
docs/docs.go
9202
docs/docs.go
File diff suppressed because it is too large
Load Diff
9202
docs/swagger.json
9202
docs/swagger.json
File diff suppressed because it is too large
Load Diff
6243
docs/swagger.yaml
6243
docs/swagger.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -240,12 +240,12 @@ type AccountDeletionRequest struct {
|
|||
}
|
||||
|
||||
type RegisterUserReq struct {
|
||||
ReferralCode string `json:"referral_code"`
|
||||
ReferralCode string `json:"referral_code" example:"ABCDEF0123456789"`
|
||||
Email string `json:"email"`
|
||||
PhoneNumber string `json:"phone_number"`
|
||||
Password string `json:"password"`
|
||||
Role string `json:"role"`
|
||||
OtpMedium OtpMedium `json:"otp_medium"`
|
||||
Role string `json:"role" swaggerignore:"true"`
|
||||
OtpMedium OtpMedium `json:"otp_medium" swaggerignore:"true"`
|
||||
}
|
||||
|
||||
type CreateUserReq struct {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,13 @@ func audienceSpecification(audience string) fiber.Handler {
|
|||
}
|
||||
spec["paths"] = selected
|
||||
if info, ok := spec["info"].(map[string]any); ok {
|
||||
info["title"] = "Rezina " + audience + " API"
|
||||
if audience == "admin" {
|
||||
info["title"] = "Rezina Admin API"
|
||||
info["description"] = "Admin panel operations use /api/v1/admin. Sign in through /api/v1/admin/team/login, then enter Bearer followed by a space and the access token in Authorize. Protected endpoints require a staff account and the relevant RBAC permission. WebSockets use the token query parameter."
|
||||
} else {
|
||||
info["title"] = "Rezina Customer API"
|
||||
info["description"] = "Customer web and mobile operations retain /api/v1; there is no /client prefix. Public registration, login, and discovery endpoints do not require authorization. For protected endpoints, enter Bearer followed by a space and a customer access token in Authorize. Premium learning content requires an active EDUCATION subscription unless the account has an existing exemption. WebSockets use the token query parameter."
|
||||
}
|
||||
}
|
||||
definitions, _ := spec["definitions"].(map[string]any)
|
||||
used := map[string]any{}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ func TestAudienceSpecifications(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
var spec struct {
|
||||
Paths map[string]any `json:"paths"`
|
||||
}
|
||||
if err := json.NewDecoder(response.Body).Decode(&spec); err != nil {
|
||||
var document map[string]any
|
||||
if err := json.NewDecoder(response.Body).Decode(&document); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(spec.Paths) == 0 {
|
||||
paths, _ := document["paths"].(map[string]any)
|
||||
if len(paths) == 0 {
|
||||
t.Fatal("empty API specification")
|
||||
}
|
||||
for path := range spec.Paths {
|
||||
assertSwaggerReferences(t, document)
|
||||
for path := range paths {
|
||||
if (audience == "admin" && !strings.HasPrefix(path, "/api/v1/admin/")) || (audience == "client" && (!strings.HasPrefix(path, "/api/v1/") || strings.HasPrefix(path, "/api/v1/admin/"))) {
|
||||
t.Errorf("foreign path %s", path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ type activityLogListRes struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/activity-logs [get]
|
||||
// @Security Bearer
|
||||
// @Param search query string false "Search"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetActivityLogs(c *fiber.Ctx) error {
|
||||
var filter domain.ActivityLogFilter
|
||||
|
||||
|
|
@ -165,6 +169,9 @@ func (h *Handler) GetActivityLogs(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/activity-logs/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetActivityLogByID(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ type CreateAdminReq struct {
|
|||
// CreateAdmin godoc
|
||||
// @Summary Create Admin
|
||||
// @Description Create Admin
|
||||
// @Tags admin
|
||||
// @Tags admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param manger body CreateAdminReq true "Create admin"
|
||||
|
|
@ -37,6 +37,8 @@ type CreateAdminReq struct {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/admins [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateAdmin(c *fiber.Ctx) error {
|
||||
// var OrganizationID domain.ValidInt64
|
||||
var req CreateAdminReq
|
||||
|
|
@ -163,7 +165,7 @@ type AdminRes struct {
|
|||
// GetAllAdmins godoc
|
||||
// @Summary Get all Admins
|
||||
// @Description Get all Admins
|
||||
// @Tags admin
|
||||
// @Tags admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
|
|
@ -173,6 +175,12 @@ type AdminRes struct {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/admins [get]
|
||||
// @Security Bearer
|
||||
// @Param query query string false "Query"
|
||||
// @Param created_before query string false "Created before"
|
||||
// @Param created_after query string false "Created after"
|
||||
// @Param company_id query int false "Company id"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetAllAdmins(c *fiber.Ctx) error {
|
||||
searchQuery := c.Query("query")
|
||||
searchString := domain.ValidString{
|
||||
|
|
@ -280,7 +288,7 @@ func (h *Handler) GetAllAdmins(c *fiber.Ctx) error {
|
|||
// GetAdminByID godoc
|
||||
// @Summary Get admin by id
|
||||
// @Description Get a single admin by id
|
||||
// @Tags admin
|
||||
// @Tags admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "User ID"
|
||||
|
|
@ -289,6 +297,8 @@ func (h *Handler) GetAllAdmins(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/admins/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetAdminByID(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -334,7 +344,7 @@ type updateAdminReq struct {
|
|||
// UpdateAdmin godoc
|
||||
// @Summary Update Admin
|
||||
// @Description Update Admin
|
||||
// @Tags admin
|
||||
// @Tags admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param admin body updateAdminReq true "Update Admin"
|
||||
|
|
@ -343,6 +353,9 @@ type updateAdminReq struct {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/admins/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateAdmin(c *fiber.Ctx) error {
|
||||
var req updateAdminReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -424,10 +437,9 @@ func (h *Handler) bulkAccountsRoleFromPath(c *fiber.Ctx) (roleKey string, ok boo
|
|||
// BulkDeactivateAccountsByRole godoc
|
||||
// @Summary Bulk deactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)
|
||||
// @Description Sets all platform users with the given users.role to DEACTIVATED (except the caller) and all team_members with the given team_role to inactive. Path :role may be a role key (e.g. INSTRUCTOR, ADMIN) or a decimal RBAC roles.id from GET /api/v1/rbac/roles (resolved to RoleRecord.name uppercased). SUPER_ADMIN cannot be bulk-deactivated. ADMIN platform users must use SUPER_ADMIN to bulk change other platform ADMIN users (team_members with team_role ADMIN under path ADMIN remain allowed). Empty body allowed; optionally pass exclude_team_member_id to skip one team_members row (e.g. yourself).
|
||||
// @Tags admin
|
||||
// @Tags admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param role path string true "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)"
|
||||
// @Param body body domain.BulkAccountsByRoleRequest false "Optional exclusions"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -436,6 +448,8 @@ func (h *Handler) bulkAccountsRoleFromPath(c *fiber.Ctx) (roleKey string, ok boo
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/admins/roles/{role}/bulk-deactivate [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
func (h *Handler) BulkDeactivateAccountsByRole(c *fiber.Ctx) error {
|
||||
callerRole, ok := c.Locals("role").(domain.Role)
|
||||
if !ok {
|
||||
|
|
@ -548,10 +562,9 @@ func (h *Handler) BulkDeactivateAccountsByRole(c *fiber.Ctx) error {
|
|||
// BulkReactivateAccountsByRole godoc
|
||||
// @Summary Bulk reactivate accounts by role (SUPER_ADMIN or ADMIN platform users only)
|
||||
// @Description Sets all platform users with the given role from DEACTIVATED to ACTIVE (except the caller) and all team_members with the given team_role from inactive to active. Path :role may be a role key or decimal RBAC roles.id (see bulk-deactivate). Path role must correspond to valid platform users.role or team_members.team_role (after resolving id → name). SUPER_ADMIN cannot be bulk changed. ADMIN callers cannot bulk change other platform ADMIN users (team_members ADMIN under path ADMIN is allowed). Matches only users currently DEACTIVATED and team rows currently inactive.
|
||||
// @Tags admin
|
||||
// @Tags admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param role path string true "Role key (INSTRUCTOR etc.) or RBAC roles.id (integer string)"
|
||||
// @Param body body domain.BulkAccountsByRoleRequest false "Optional exclusions"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -560,6 +573,8 @@ func (h *Handler) BulkDeactivateAccountsByRole(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/admins/roles/{role}/bulk-reactivate [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
func (h *Handler) BulkReactivateAccountsByRole(c *fiber.Ctx) error {
|
||||
callerRole, ok := c.Locals("role").(domain.Role)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -107,6 +107,12 @@ func csvJSON(raw json.RawMessage) string {
|
|||
// @Tags payments
|
||||
// @Produce text/csv
|
||||
// @Router /api/v1/admin/payments/export [get]
|
||||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) ExportAdminPaymentsCSV(c *fiber.Ctx) error {
|
||||
filter, err := paymentListFilterFields(c)
|
||||
if err != nil {
|
||||
|
|
@ -167,6 +173,12 @@ func (h *Handler) ExportAdminPaymentsCSV(c *fiber.Ctx) error {
|
|||
// @Tags user
|
||||
// @Produce text/csv
|
||||
// @Router /api/v1/admin/users/export [get]
|
||||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
func (h *Handler) ExportUsersCSV(c *fiber.Ctx) error {
|
||||
filter, err := parseUserListFilter(c)
|
||||
if err != nil {
|
||||
|
|
@ -245,6 +257,12 @@ func (h *Handler) ExportUsersCSV(c *fiber.Ctx) error {
|
|||
// @Tags activity-logs
|
||||
// @Produce text/csv
|
||||
// @Router /api/v1/admin/activity-logs/export [get]
|
||||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) ExportActivityLogsCSV(c *fiber.Ctx) error {
|
||||
filter, err := parseActivityLogFilterFields(c)
|
||||
if err != nil {
|
||||
|
|
@ -297,6 +315,12 @@ func (h *Handler) ExportActivityLogsCSV(c *fiber.Ctx) error {
|
|||
// @Tags subscriptions
|
||||
// @Produce text/csv
|
||||
// @Router /api/v1/admin/subscriptions/export [get]
|
||||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) ExportUserSubscriptionsCSV(c *fiber.Ctx) error {
|
||||
filter, err := parseUserSubscriptionAdminFilterFields(c)
|
||||
if err != nil {
|
||||
|
|
@ -358,6 +382,12 @@ func (h *Handler) ExportUserSubscriptionsCSV(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Produce text/csv
|
||||
// @Router /api/v1/admin/team/members/export [get]
|
||||
// @Security Bearer
|
||||
// @Produce text/csv
|
||||
// @Success 200 {file} file "CSV export; filename is supplied in Content-Disposition"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ExportTeamMembersCSV(c *fiber.Ctx) error {
|
||||
filter := parseTeamMemberListFilter(c)
|
||||
ctx := exportRequestContext(c)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ func (r adminApplySubscriptionReq) recordPaymentOrDefault() bool {
|
|||
// @Tags subscriptions
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param user_id path int true "Target learner user ID"
|
||||
// @Param body body adminApplySubscriptionReq true "Plan to grant or extend"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -40,6 +39,9 @@ func (r adminApplySubscriptionReq) recordPaymentOrDefault() bool {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/users/{user_id}/subscriptions/extend [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AdminExtendOrGrantUserSubscription(c *fiber.Ctx) error {
|
||||
targetID, err := parseAdminTargetUserID(c)
|
||||
if err != nil {
|
||||
|
|
@ -157,13 +159,15 @@ func (h *Handler) AdminExtendOrGrantUserSubscription(c *fiber.Ctx) error {
|
|||
// @Description Cancels any user_subscriptions row by ID. Does not require ownership by the caller.
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Subscription ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscriptions/{id}/cancel [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AdminCancelUserSubscription(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
|
|||
|
|
@ -18,13 +18,15 @@ const adminUserDetailPageSize int32 = 200
|
|||
// @Description Returns display status, active plans by category, full subscription history, and related payments
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param user_id path int true "Target user ID"
|
||||
// @Success 200 {object} domain.Response{data=domain.AdminUserSubscriptionDetails}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/users/{user_id}/subscriptions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AdminGetUserSubscriptions(c *fiber.Ctx) error {
|
||||
targetID, err := parseAdminTargetUserID(c)
|
||||
if err != nil {
|
||||
|
|
@ -77,7 +79,6 @@ func (h *Handler) AdminGetUserSubscriptions(c *fiber.Ctx) error {
|
|||
// @Description Returns the unified catalog-course learning tree, progress summary, and recent activity timeline
|
||||
// @Tags exam-prep
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param user_id path int true "Target user ID"
|
||||
// @Param limit query int false "Max recent-activity items (default 40, max 120)"
|
||||
// @Param include_practices query bool false "Include practice completions in recent-activity feed"
|
||||
|
|
@ -86,6 +87,9 @@ func (h *Handler) AdminGetUserSubscriptions(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/users/{user_id}/learning-activity [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AdminGetUserLearningActivityDetails(c *fiber.Ctx) error {
|
||||
targetID, err := parseAdminTargetUserID(c)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ func toTime(v interface{}) time.Time {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/analytics/dashboard [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetAnalyticsDashboard(c *fiber.Ctx) error {
|
||||
filter, err := domain.ParseAnalyticsDateFilter(c)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ type paymentRes struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/subscribe [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) InitiateSubscriptionPayment(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -113,6 +116,9 @@ func (h *Handler) InitiateSubscriptionPayment(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/verify/{session_id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) VerifyPayment(c *fiber.Ctx) error {
|
||||
sessionID := c.Params("session_id")
|
||||
if sessionID == "" {
|
||||
|
|
@ -151,6 +157,10 @@ func (h *Handler) VerifyPayment(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/payments [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetMyPayments(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -190,6 +200,10 @@ func (h *Handler) GetMyPayments(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) GetPaymentByID(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -233,6 +247,9 @@ func (h *Handler) GetPaymentByID(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/{id}/cancel [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CancelPayment(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -334,6 +351,8 @@ func paymentInitiationStatus(err error) int {
|
|||
// @Param nonce query string false "Fallback payment nonce"
|
||||
// @Success 200 {string} string "HTML success page"
|
||||
// @Router /api/v1/payments/arifpay/success [get]
|
||||
// @Param sessionID query string false "Sessionid"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) HandleArifpaySuccessPage(c *fiber.Ctx) error {
|
||||
ref := firstNonEmpty(
|
||||
c.Query("session_id"),
|
||||
|
|
@ -454,6 +473,9 @@ type verifyOTPReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/direct [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) InitiateDirectPayment(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -507,6 +529,9 @@ func (h *Handler) InitiateDirectPayment(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/direct/verify-otp [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) VerifyDirectPaymentOTP(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ type loginUserRes struct {
|
|||
// @Tags auth
|
||||
// @Param idToken body string true "Google ID Token from Android"
|
||||
// @Router /api/v1/auth/google/android [post]
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GoogleAndroidLogin(c *fiber.Ctx) error {
|
||||
var req struct {
|
||||
IDToken string `json:"id_token" validate:"required" example:"<google-id-token>"`
|
||||
|
|
@ -103,6 +108,11 @@ func (h *Handler) GoogleAndroidLogin(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Param body body object true "Apple login payload"
|
||||
// @Router /api/v1/auth/apple [post]
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) AppleLogin(c *fiber.Ctx) error {
|
||||
var req struct {
|
||||
IDToken string `json:"id_token" validate:"required"`
|
||||
|
|
@ -173,6 +183,9 @@ func (h *Handler) AppleLogin(c *fiber.Ctx) error {
|
|||
// @Summary Google login redirect
|
||||
// @Tags auth
|
||||
// @Router /api/v1/auth/google/login [get]
|
||||
// @Success 302 {string} string "Redirect to Google authorization URL; see Location header"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Google OAuth is not configured"
|
||||
// @Produce plain
|
||||
func (h *Handler) GoogleLogin(c *fiber.Ctx) error {
|
||||
state := uuid.NewString()
|
||||
url := h.authSvc.GenerateGoogleLoginURL(state)
|
||||
|
|
@ -189,6 +202,12 @@ func (h *Handler) GoogleLogin(c *fiber.Ctx) error {
|
|||
// @Summary Google login callback
|
||||
// @Tags auth
|
||||
// @Router /api/v1/auth/google/callback [get]
|
||||
// @Param code query string false "Code"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GoogleCallback(c *fiber.Ctx) error {
|
||||
|
||||
code := c.Query("code")
|
||||
|
|
@ -257,6 +276,7 @@ func (h *Handler) GoogleCallback(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/auth/customer-login [post]
|
||||
// @Failure 403 {object} domain.ErrorResponse "Access denied"
|
||||
func (h *Handler) LoginUser(c *fiber.Ctx) error {
|
||||
var req domain.LoginRequest
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -406,6 +426,7 @@ type LoginAdminRes struct {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/auth/admin-login [post]
|
||||
// @Failure 403 {string} string "Access denied"
|
||||
func (h *Handler) LoginAdmin(c *fiber.Ctx) error {
|
||||
var req domain.LoginRequest
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -508,6 +529,7 @@ func (h *Handler) LoginAdmin(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/auth/super-login [post]
|
||||
// @Failure 403 {string} string "Access denied"
|
||||
func (h *Handler) LoginSuper(c *fiber.Ctx) error {
|
||||
var req domain.LoginRequest
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -614,6 +636,7 @@ type refreshToken struct {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/auth/refresh [post]
|
||||
// @Failure 403 {string} string "Access denied"
|
||||
func (h *Handler) RefreshToken(c *fiber.Ctx) error {
|
||||
|
||||
type loginUserRes struct {
|
||||
|
|
@ -754,6 +777,8 @@ type logoutReq struct {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/auth/logout [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) LogOutuser(c *fiber.Ctx) error {
|
||||
var req logoutReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ import (
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/webhook [post]
|
||||
// @Accept json
|
||||
// @Param body body domain.ChapaWebhookPayload true "Exact signed Chapa webhook payload"
|
||||
// @Param x-chapa-signature header string false "Webhook HMAC signature. Alternatively send chapa-signature; one of these headers is required."
|
||||
// @Param chapa-signature header string false "Alternative signature header"
|
||||
// @Failure 401 {object} domain.ErrorResponse "Authentication failed"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) HandleChapaWebhook(c *fiber.Ctx) error {
|
||||
body := c.Body()
|
||||
signature := c.Get("x-chapa-signature")
|
||||
|
|
@ -84,6 +90,9 @@ func (h *Handler) logChapaWebhookActivity(c *fiber.Ctx, payload domain.ChapaWebh
|
|||
// @Param status query string false "Payment status"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/payments/chapa/callback [get]
|
||||
// @Param tx_ref query string false "Tx ref"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) HandleChapaCallback(c *fiber.Ctx) error {
|
||||
query := domain.ChapaCallbackQuery{
|
||||
TrxRef: c.Query("trx_ref"),
|
||||
|
|
@ -127,6 +136,8 @@ func (h *Handler) HandleChapaCallback(c *fiber.Ctx) error {
|
|||
// @Param status query string false "Payment status from Chapa redirect"
|
||||
// @Success 200 {string} string "HTML success page"
|
||||
// @Router /api/v1/payments/chapa/success [get]
|
||||
// @Router /payment/success [get]
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) HandleChapaSuccessPage(c *fiber.Ctx) error {
|
||||
txRef := firstNonEmpty(
|
||||
c.Query("trx_ref"),
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ type authorizeChapaDirectPaymentReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/chapa/direct [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) InitiateChapaDirectPayment(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -80,6 +83,9 @@ func (h *Handler) InitiateChapaDirectPayment(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/payments/chapa/direct/authorize [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AuthorizeChapaDirectPayment(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ func mapEmailTemplateToRes(t domain.EmailTemplate) emailTemplateRes {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListEmailTemplatesAdmin(c *fiber.Ctx) error {
|
||||
status := strings.ToUpper(strings.TrimSpace(c.Query("status")))
|
||||
var statusPtr *string
|
||||
|
|
@ -151,6 +154,9 @@ func (h *Handler) ListEmailTemplatesAdmin(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetEmailTemplateByIDAdmin(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -190,6 +196,9 @@ func (h *Handler) GetEmailTemplateByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates/slug/{slug} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetEmailTemplateBySlugAdmin(c *fiber.Ctx) error {
|
||||
slug := strings.TrimSpace(c.Params("slug"))
|
||||
if slug == "" {
|
||||
|
|
@ -229,6 +238,9 @@ func (h *Handler) GetEmailTemplateBySlugAdmin(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateEmailTemplate(c *fiber.Ctx) error {
|
||||
var req createEmailTemplateReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -281,6 +293,9 @@ func (h *Handler) CreateEmailTemplate(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateEmailTemplate(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -337,6 +352,9 @@ func (h *Handler) UpdateEmailTemplate(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteEmailTemplate(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -379,6 +397,9 @@ func (h *Handler) DeleteEmailTemplate(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates/slug/{slug}/preview [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) PreviewEmailTemplateBySlug(c *fiber.Ctx) error {
|
||||
slug := strings.TrimSpace(c.Params("slug"))
|
||||
if slug == "" {
|
||||
|
|
@ -426,6 +447,9 @@ func (h *Handler) PreviewEmailTemplateBySlug(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/email-templates/{id}/preview [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) PreviewEmailTemplateByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,16 @@ func assessmentParentFromQuery(c *fiber.Ctx) (domain.ExamPrepAssessmentParent, e
|
|||
}
|
||||
|
||||
// ListExamPrepAssessments godoc
|
||||
// @Summary ListExamPrepAssessments
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary List Exam Prep Assessments
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/assessments [get]
|
||||
// @Router /api/v1/exam-prep/assessments [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) ListExamPrepAssessments(c *fiber.Ctx) error {
|
||||
parent, err := assessmentParentFromQuery(c)
|
||||
if err != nil || parent.Kind == "" {
|
||||
|
|
@ -39,10 +44,17 @@ func (h *Handler) ListExamPrepAssessments(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// LinkExamPrepAssessment godoc
|
||||
// @Summary LinkExamPrepAssessment
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Link Exam Prep Assessment
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/assessments [post]
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body domain.LinkExamPrepAssessmentInput true "Request payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) LinkExamPrepAssessment(c *fiber.Ctx) error {
|
||||
var input domain.LinkExamPrepAssessmentInput
|
||||
if err := c.BodyParser(&input); err != nil {
|
||||
|
|
@ -60,10 +72,20 @@ func (h *Handler) LinkExamPrepAssessment(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// UnlinkExamPrepAssessment godoc
|
||||
// @Summary UnlinkExamPrepAssessment
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Unlink Exam Prep Assessment
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/assessments/{questionSetId}/parents/{parentKind}/{parentId} [delete]
|
||||
// @Security Bearer
|
||||
// @Param parentId path int64 true "Parent id"
|
||||
// @Param parentKind path string true "Parent kind"
|
||||
// @Param questionSetId path int64 true "Question set id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UnlinkExamPrepAssessment(c *fiber.Ctx) error {
|
||||
questionSetID, err := parseAssessmentID(c.Params("questionSetId"))
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ import (
|
|||
// @Success 201 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepCatalogCourse(c *fiber.Ctx) error {
|
||||
var req domain.CreateExamPrepCatalogCourseInput
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -59,6 +63,10 @@ func (h *Handler) CreateExamPrepCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses [get]
|
||||
// @Router /api/v1/exam-prep/catalog-courses [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error {
|
||||
limit, _ := strconv.Atoi(c.Query("limit", "20"))
|
||||
offset, _ := strconv.Atoi(c.Query("offset", "0"))
|
||||
|
|
@ -99,6 +107,11 @@ func (h *Handler) ListExamPrepCatalogCourses(c *fiber.Ctx) error {
|
|||
// @Param body body domain.ReorderIDsRequest true "ordered_ids: every catalog course id exactly once"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/reorder [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ReorderExamPrepCatalogCourses(c *fiber.Ctx) error {
|
||||
var req domain.ReorderIDsRequest
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -140,6 +153,12 @@ func (h *Handler) ReorderExamPrepCatalogCourses(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{id} [get]
|
||||
// @Router /api/v1/exam-prep/catalog-courses/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetExamPrepCatalogCourseByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -191,6 +210,12 @@ func (h *Handler) GetExamPrepCatalogCourseByID(c *fiber.Ctx) error {
|
|||
// @Param body body domain.UpdateExamPrepCatalogCourseInput true "Fields to update"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepCatalogCourse(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -234,6 +259,13 @@ func (h *Handler) UpdateExamPrepCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Catalog course ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteExamPrepCatalogCourse(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@ import (
|
|||
// @Param moduleId path int true "Exam prep unit module ID"
|
||||
// @Param body body domain.CreateExamPrepLessonInput true "Lesson"
|
||||
// @Router /api/v1/admin/exam-prep/modules/{moduleId}/lessons [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepLesson(c *fiber.Ctx) error {
|
||||
moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -67,6 +75,14 @@ func (h *Handler) CreateExamPrepLesson(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset" default(0)
|
||||
// @Router /api/v1/admin/exam-prep/modules/{moduleId}/lessons [get]
|
||||
// @Router /api/v1/exam-prep/modules/{moduleId}/lessons [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepLessonsByUnitModule(c *fiber.Ctx) error {
|
||||
moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -129,6 +145,17 @@ func (h *Handler) ListExamPrepLessonsByUnitModule(c *fiber.Ctx) error {
|
|||
// @Summary Reorder lessons within an exam-prep unit module
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/modules/{moduleId}/lessons/reorder [put]
|
||||
// @Security Bearer
|
||||
// @Param moduleId path int64 true "Module id"
|
||||
// @Accept json
|
||||
// @Param body body domain.ReorderIDsRequest true "Request payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ReorderExamPrepLessonsInUnitModule(c *fiber.Ctx) error {
|
||||
moduleID, err := strconv.ParseInt(c.Params("moduleId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -181,6 +208,15 @@ func (h *Handler) ReorderExamPrepLessonsInUnitModule(c *fiber.Ctx) error {
|
|||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/lessons/{id} [get]
|
||||
// @Router /api/v1/exam-prep/lessons/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetExamPrepLessonByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -231,6 +267,17 @@ func (h *Handler) GetExamPrepLessonByID(c *fiber.Ctx) error {
|
|||
// @Summary Update exam-prep lesson
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/lessons/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Accept json
|
||||
// @Param body body domain.UpdateExamPrepLessonInput true "Request payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepLesson(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -272,6 +319,15 @@ func (h *Handler) UpdateExamPrepLesson(c *fiber.Ctx) error {
|
|||
// @Summary Delete exam-prep lesson
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/lessons/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteExamPrepLesson(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@ import (
|
|||
// @Param unitId path int true "Unit ID"
|
||||
// @Param body body domain.CreateExamPrepModuleInput true "Module"
|
||||
// @Router /api/v1/admin/exam-prep/units/{unitId}/modules [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepModule(c *fiber.Ctx) error {
|
||||
unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -65,6 +73,16 @@ func (h *Handler) CreateExamPrepModule(c *fiber.Ctx) error {
|
|||
// @Param unitId path int true "Unit ID"
|
||||
// @Router /api/v1/admin/exam-prep/units/{unitId}/modules [get]
|
||||
// @Router /api/v1/exam-prep/units/{unitId}/modules [get]
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0) minimum(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepModulesByUnit(c *fiber.Ctx) error {
|
||||
unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -129,6 +147,14 @@ func (h *Handler) ListExamPrepModulesByUnit(c *fiber.Ctx) error {
|
|||
// @Param unitId path int true "Unit ID"
|
||||
// @Param body body domain.ReorderIDsRequest true "ordered_ids"
|
||||
// @Router /api/v1/admin/exam-prep/units/{unitId}/modules/reorder [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ReorderExamPrepModulesInUnit(c *fiber.Ctx) error {
|
||||
unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -181,6 +207,15 @@ func (h *Handler) ReorderExamPrepModulesInUnit(c *fiber.Ctx) error {
|
|||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/modules/{id} [get]
|
||||
// @Router /api/v1/exam-prep/modules/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetExamPrepModuleByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -231,6 +266,17 @@ func (h *Handler) GetExamPrepModuleByID(c *fiber.Ctx) error {
|
|||
// @Summary Update exam-prep module
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/modules/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Accept json
|
||||
// @Param body body domain.UpdateExamPrepModuleInput true "Request payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepModule(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -272,6 +318,15 @@ func (h *Handler) UpdateExamPrepModule(c *fiber.Ctx) error {
|
|||
// @Summary Delete exam-prep module
|
||||
// @Tags exam-prep
|
||||
// @Router /api/v1/admin/exam-prep/modules/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteExamPrepModule(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,13 @@ import (
|
|||
// @Tags exam-prep
|
||||
// @Param body body domain.CreateExamPrepPracticeInput true "Practice"
|
||||
// @Router /api/v1/admin/exam-prep/practices [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepPracticeFromInput(c *fiber.Ctx) error {
|
||||
var req domain.CreateExamPrepPracticeInput
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -56,6 +63,13 @@ func (h *Handler) CreateExamPrepPracticeFromInput(c *fiber.Ctx) error {
|
|||
// @Param unlinked_only query bool false "When true, return only practices with no parent links (admin)"
|
||||
// @Router /api/v1/admin/exam-prep/practices [get]
|
||||
// @Router /api/v1/exam-prep/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListAllExamPrepPractices(c *fiber.Ctx) error {
|
||||
limit, offset, err := parseOptionalExamPrepPracticePagination(c)
|
||||
if err != nil {
|
||||
|
|
@ -132,6 +146,13 @@ func (h *Handler) CreateExamPrepPractice(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset (used when limit is provided)"
|
||||
// @Router /api/v1/admin/exam-prep/lessons/{lessonId}/practices [get]
|
||||
// @Router /api/v1/exam-prep/lessons/{lessonId}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepPracticesByLesson(c *fiber.Ctx) error {
|
||||
lessonID, err := strconv.ParseInt(c.Params("lessonId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -167,6 +188,14 @@ func (h *Handler) ListExamPrepPracticesByLesson(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id} [get]
|
||||
// @Router /api/v1/exam-prep/practices/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetExamPrepPracticeByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -208,6 +237,14 @@ func (h *Handler) GetExamPrepPracticeByID(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Param body body domain.UpdateExamPrepPracticeInput true "Fields to update"
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepPractice(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -260,6 +297,14 @@ func (h *Handler) UpdateExamPrepPractice(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Param body body domain.UpdateExamPrepPracticeParentsInput true "Parent links (replaces all; use empty array to detach)"
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id}/parents [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepPracticeParents(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -316,6 +361,14 @@ func (h *Handler) UpdateExamPrepPracticeParents(c *fiber.Ctx) error {
|
|||
// @Param parentKind path string true "Parent kind (CATALOG_COURSE, UNIT, LESSON)"
|
||||
// @Param parentId path int true "Parent entity ID"
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id}/parents/{parentKind}/{parentId} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UnlinkExamPrepPracticeParent(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -370,6 +423,14 @@ func (h *Handler) UnlinkExamPrepPracticeParent(c *fiber.Ctx) error {
|
|||
// @Tags exam-prep
|
||||
// @Param id path int true "Exam prep practice ID"
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteExamPrepPractice(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -460,6 +521,13 @@ func (h *Handler) listExamPrepPracticesResponse(c *fiber.Ctx, items []domain.Exa
|
|||
// @Param catalogCourseId path int true "Exam prep catalog course ID"
|
||||
// @Param body body domain.CreateExamPrepPracticeInput true "Practice"
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepPracticeForCatalogCourse(c *fiber.Ctx) error {
|
||||
catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -493,6 +561,13 @@ func (h *Handler) CreateExamPrepPracticeForCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset (used when limit is provided)"
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/practices [get]
|
||||
// @Router /api/v1/exam-prep/catalog-courses/{catalogCourseId}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepPracticesByCatalogCourse(c *fiber.Ctx) error {
|
||||
catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -522,6 +597,13 @@ func (h *Handler) ListExamPrepPracticesByCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param unitId path int true "Exam prep unit ID"
|
||||
// @Param body body domain.CreateExamPrepPracticeInput true "Practice"
|
||||
// @Router /api/v1/admin/exam-prep/units/{unitId}/practices [post]
|
||||
// @Security Bearer
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepPracticeForUnit(c *fiber.Ctx) error {
|
||||
unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -555,6 +637,13 @@ func (h *Handler) CreateExamPrepPracticeForUnit(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset (used when limit is provided)"
|
||||
// @Router /api/v1/admin/exam-prep/units/{unitId}/practices [get]
|
||||
// @Router /api/v1/exam-prep/units/{unitId}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepPracticesByUnit(c *fiber.Ctx) error {
|
||||
unitID, err := strconv.ParseInt(c.Params("unitId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ import (
|
|||
// @Param body body domain.CreateExamPrepUnitInput true "Unit"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreateExamPrepUnit(c *fiber.Ctx) error {
|
||||
catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -72,6 +78,13 @@ func (h *Handler) CreateExamPrepUnit(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units [get]
|
||||
// @Router /api/v1/exam-prep/catalog-courses/{catalogCourseId}/units [get]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListExamPrepUnitsByCatalogCourse(c *fiber.Ctx) error {
|
||||
catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -136,6 +149,14 @@ func (h *Handler) ListExamPrepUnitsByCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param catalogCourseId path int true "Catalog course ID"
|
||||
// @Param body body domain.ReorderIDsRequest true "ordered_ids: every unit id in this catalog course, new order"
|
||||
// @Router /api/v1/admin/exam-prep/catalog-courses/{catalogCourseId}/units/reorder [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ReorderExamPrepUnitsInCatalogCourse(c *fiber.Ctx) error {
|
||||
catalogCourseID, err := strconv.ParseInt(c.Params("catalogCourseId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -189,6 +210,14 @@ func (h *Handler) ReorderExamPrepUnitsInCatalogCourse(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Unit ID"
|
||||
// @Router /api/v1/admin/exam-prep/units/{id} [get]
|
||||
// @Router /api/v1/exam-prep/units/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetExamPrepUnitByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -241,6 +270,14 @@ func (h *Handler) GetExamPrepUnitByID(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Unit ID"
|
||||
// @Param body body domain.UpdateExamPrepUnitInput true "Fields to update"
|
||||
// @Router /api/v1/admin/exam-prep/units/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepUnit(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -283,6 +320,14 @@ func (h *Handler) UpdateExamPrepUnit(c *fiber.Ctx) error {
|
|||
// @Tags exam-prep
|
||||
// @Param id path int true "Unit ID"
|
||||
// @Router /api/v1/admin/exam-prep/units/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteExamPrepUnit(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ func (h *Handler) ListPublicFAQs(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/faqs/{id} [get]
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetPublicFAQByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -169,6 +170,9 @@ func (h *Handler) GetPublicFAQByID(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListFAQsAdmin(c *fiber.Ctx) error {
|
||||
status := strings.ToUpper(strings.TrimSpace(c.Query("status")))
|
||||
var statusPtr *string
|
||||
|
|
@ -229,6 +233,9 @@ func (h *Handler) ListFAQsAdmin(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetFAQByIDAdmin(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -268,6 +275,9 @@ func (h *Handler) GetFAQByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateFAQ(c *fiber.Ctx) error {
|
||||
var req createFAQReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -318,6 +328,9 @@ func (h *Handler) CreateFAQ(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateFAQ(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -373,6 +386,9 @@ func (h *Handler) UpdateFAQ(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/faqs/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteFAQ(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
|
|||
|
|
@ -119,6 +119,9 @@ func (h *Handler) ListFieldKeys(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/field-options [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListFieldOptionsAdmin(c *fiber.Ctx) error {
|
||||
limit, _ := strconv.Atoi(c.Query("limit", "50"))
|
||||
offset, _ := strconv.Atoi(c.Query("offset", "0"))
|
||||
|
|
@ -158,6 +161,10 @@ func (h *Handler) ListFieldOptionsAdmin(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Option ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/field-options/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) GetFieldOptionByIDAdmin(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -186,6 +193,10 @@ func (h *Handler) GetFieldOptionByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Param body body createFieldOptionReq true "Create option"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Router /api/v1/admin/field-options [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) CreateFieldOption(c *fiber.Ctx) error {
|
||||
var req createFieldOptionReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -230,6 +241,10 @@ func (h *Handler) CreateFieldOption(c *fiber.Ctx) error {
|
|||
// @Param body body updateFieldOptionReq true "Update option"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/field-options/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) UpdateFieldOption(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -271,6 +286,12 @@ func (h *Handler) UpdateFieldOption(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Option ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/field-options/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteFieldOption(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,13 @@ func (h *Handler) resolveFileURL(c *fiber.Ctx, storedPath string) string {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/files/url [get]
|
||||
// @Router /api/v1/files/url [get]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) GetFileURL(c *fiber.Ctx) error {
|
||||
key := strings.TrimSpace(c.Query("key"))
|
||||
if key == "" {
|
||||
|
|
@ -124,6 +131,12 @@ func (h *Handler) extractObjectKeyFromReference(reference string) (string, error
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/files/refresh-url [post]
|
||||
// @Router /api/v1/files/refresh-url [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) RefreshFileURL(c *fiber.Ctx) error {
|
||||
if h.minioSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -177,6 +190,12 @@ func (h *Handler) RefreshFileURL(c *fiber.Ctx) error {
|
|||
// @Success 201 {object} domain.Response
|
||||
// @Router /api/v1/admin/files/presign-upload [post]
|
||||
// @Router /api/v1/files/presign-upload [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) CreatePresignedUpload(c *fiber.Ctx) error {
|
||||
if h.minioSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -268,6 +287,13 @@ func (h *Handler) CreatePresignedUpload(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/files/complete-upload [post]
|
||||
// @Router /api/v1/files/complete-upload [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) CompletePresignedUpload(c *fiber.Ctx) error {
|
||||
if h.minioSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -389,6 +415,13 @@ func objectKeyMatchesMediaType(objectKey, mediaType string) bool {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/files/upload [post]
|
||||
// @Router /api/v1/files/upload [post]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) UploadMedia(c *fiber.Ctx) error {
|
||||
mediaType := strings.ToLower(strings.TrimSpace(c.FormValue("media_type")))
|
||||
sourceURL := strings.TrimSpace(c.FormValue("source_url"))
|
||||
|
|
@ -633,6 +666,13 @@ func normalizeAndValidateMediaContentType(mediaType, contentType, fileName strin
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/files/audio [post]
|
||||
// @Router /api/v1/files/audio [post]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) UploadAudio(c *fiber.Ctx) error {
|
||||
if h.minioSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -752,6 +792,13 @@ func (h *Handler) UploadAudio(c *fiber.Ctx) error {
|
|||
// @Param file formData file true "Audio recording"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/questions/audio-answer [post]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) SubmitAudioAnswer(c *fiber.Ctx) error {
|
||||
if h.minioSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
|
|||
|
|
@ -60,13 +60,14 @@ func mapIssueToRes(issue domain.ReportedIssue) issueRes {
|
|||
// @Tags issues
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param body body createIssueReq true "Issue report payload"
|
||||
// @Success 201 {object} domain.Response{data=issueRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/issues [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateIssue(c *fiber.Ctx) error {
|
||||
var req createIssueReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -133,12 +134,14 @@ func (h *Handler) CreateIssue(c *fiber.Ctx) error {
|
|||
// @Description Returns a single issue report by its ID (admin only)
|
||||
// @Tags issues
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Issue ID"
|
||||
// @Success 200 {object} domain.Response{data=issueRes}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetIssueByID(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -169,7 +172,6 @@ func (h *Handler) GetIssueByID(c *fiber.Ctx) error {
|
|||
// @Description Returns paginated issues reported by a specific user (admin only)
|
||||
// @Tags issues
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param user_id path int true "User ID"
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
|
|
@ -177,6 +179,9 @@ func (h *Handler) GetIssueByID(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues/user/{user_id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetUserIssues(c *fiber.Ctx) error {
|
||||
userIDStr := c.Params("user_id")
|
||||
userID, err := strconv.ParseInt(userIDStr, 10, 64)
|
||||
|
|
@ -223,12 +228,14 @@ func (h *Handler) GetUserIssues(c *fiber.Ctx) error {
|
|||
// @Description Returns paginated issues reported by the authenticated user
|
||||
// @Tags issues
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response{data=issueListRes}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/issues/me [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetMyIssues(c *fiber.Ctx) error {
|
||||
userID := c.Locals("user_id").(int64)
|
||||
|
||||
|
|
@ -268,12 +275,14 @@ func (h *Handler) GetMyIssues(c *fiber.Ctx) error {
|
|||
// @Description Returns all reported issues with pagination (admin only)
|
||||
// @Tags issues
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response{data=issueListRes}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetAllIssues(c *fiber.Ctx) error {
|
||||
limit, _ := strconv.Atoi(c.Query("limit", "20"))
|
||||
offset, _ := strconv.Atoi(c.Query("offset", "0"))
|
||||
|
|
@ -312,13 +321,15 @@ func (h *Handler) GetAllIssues(c *fiber.Ctx) error {
|
|||
// @Tags issues
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Issue ID"
|
||||
// @Param body body updateIssueStatusReq true "Status update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues/{id}/status [patch]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateIssueStatus(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -381,12 +392,14 @@ func (h *Handler) UpdateIssueStatus(c *fiber.Ctx) error {
|
|||
// @Description Deletes an issue report (admin only)
|
||||
// @Tags issues
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Issue ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/issues/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteIssue(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ type listPersonasData struct {
|
|||
// @Param body body domain.CreateLmsPersonaInput true "Persona"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Router /api/v1/admin/personas [post]
|
||||
// @Security Bearer
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CreatePersona(c *fiber.Ctx) error {
|
||||
var req domain.CreateLmsPersonaInput
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -63,6 +69,13 @@ func (h *Handler) CreatePersona(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset"
|
||||
// @Router /api/v1/admin/personas [get]
|
||||
// @Router /api/v1/personas [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListPersonas(c *fiber.Ctx) error {
|
||||
activeOnlyStr := strings.ToLower(strings.TrimSpace(c.Query("active_only", "true")))
|
||||
activeOnly := activeOnlyStr != "false"
|
||||
|
|
@ -98,6 +111,14 @@ func (h *Handler) ListPersonas(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Persona ID"
|
||||
// @Router /api/v1/admin/personas/{id} [get]
|
||||
// @Router /api/v1/personas/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetPersona(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -123,6 +144,14 @@ func (h *Handler) GetPersona(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Persona ID"
|
||||
// @Param body body domain.UpdateLmsPersonaInput true "Fields to update"
|
||||
// @Router /api/v1/admin/personas/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdatePersona(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -155,6 +184,13 @@ func (h *Handler) UpdatePersona(c *fiber.Ctx) error {
|
|||
// @Tags personas
|
||||
// @Param id path int true "Persona ID"
|
||||
// @Router /api/v1/admin/personas/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeletePersona(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ func (h *Handler) GetMyLMSProgress(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/exam-prep/progress-summary [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetMyLMSProgressSummary(c *fiber.Ctx) error {
|
||||
uid := c.Locals("user_id").(int64)
|
||||
role := c.Locals("role").(domain.Role)
|
||||
|
|
@ -109,7 +112,6 @@ func (h *Handler) AdminGetUserLMSLearningActivity(c *fiber.Ctx) error {
|
|||
// @Description Reverse-chronological feed for profile UI: account joined plus LMS completion milestones (lessons/modules/courses/programs). Optional practice completions via include_practices. Does not include "started learning path" unless you add persisted engagement events—the schema stores completions only.
|
||||
// @Tags lms
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param user_id path int true "Target user ID"
|
||||
// @Param limit query int false "Max items after merge (default 40, max 120)"
|
||||
// @Param include_practices query bool false "Include completed LMS practices (more verbose)"
|
||||
|
|
@ -118,6 +120,9 @@ func (h *Handler) AdminGetUserLMSLearningActivity(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/users/{user_id}/recent-activity [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AdminGetUserRecentActivity(c *fiber.Ctx) error {
|
||||
targetIDStr := c.Params("user_id")
|
||||
targetID, err := strconv.ParseInt(targetIDStr, 10, 64)
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ func (h *Handler) CheckMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Summary List mobile app versions (admin)
|
||||
// @Tags app-versions
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param platform query string false "Filter by ANDROID or IOS"
|
||||
// @Param status query string false "Filter by ACTIVE or INACTIVE"
|
||||
// @Param limit query int false "Limit (default 20)"
|
||||
|
|
@ -136,6 +135,9 @@ func (h *Handler) CheckMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListMobileAppVersionsAdmin(c *fiber.Ctx) error {
|
||||
var platformPtr *string
|
||||
if platform := strings.TrimSpace(c.Query("platform")); platform != "" {
|
||||
|
|
@ -193,13 +195,15 @@ func (h *Handler) ListMobileAppVersionsAdmin(c *fiber.Ctx) error {
|
|||
// @Summary Get mobile app version by ID (admin)
|
||||
// @Tags app-versions
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "App version ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetMobileAppVersionByIDAdmin(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -236,12 +240,14 @@ func (h *Handler) GetMobileAppVersionByIDAdmin(c *fiber.Ctx) error {
|
|||
// @Tags app-versions
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param body body createMobileAppVersionReq true "App version payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateMobileAppVersion(c *fiber.Ctx) error {
|
||||
var req createMobileAppVersionReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -293,7 +299,6 @@ func (h *Handler) CreateMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Tags app-versions
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "App version ID"
|
||||
// @Param body body updateMobileAppVersionReq true "App version payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -301,6 +306,9 @@ func (h *Handler) CreateMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateMobileAppVersion(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -358,13 +366,15 @@ func (h *Handler) UpdateMobileAppVersion(c *fiber.Ctx) error {
|
|||
// @Summary Delete mobile app version (admin)
|
||||
// @Tags app-versions
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "App version ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/app-versions/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteMobileAppVersion(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import (
|
|||
// @Success 200 {object} domain.LogResponse "Paginated list of application logs"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request parameters"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Staff account and logs.list permission required"
|
||||
// @Router /api/v1/admin/logs [get]
|
||||
func GetLogsHandler(appCtx context.Context) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
|
|
|
|||
|
|
@ -34,11 +34,13 @@ func notificationRequestContext(c *fiber.Ctx) context.Context {
|
|||
}
|
||||
|
||||
// ConnectSocket godoc
|
||||
// @Summary ConnectSocket
|
||||
// @Tags client
|
||||
// @Summary Connect Socket
|
||||
// @Tags ws
|
||||
// @Param token query string true "Access token"
|
||||
// @Router /api/v1/admin/ws/connect [get]
|
||||
// @Router /api/v1/ws/connect [get]
|
||||
// @Success 101 {string} string "WebSocket protocol upgrade; subsequent messages are notification events"
|
||||
// @Failure 401 {string} string "Authentication failed"
|
||||
func (h *Handler) ConnectSocket(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(int64)
|
||||
if !ok || userID == 0 {
|
||||
|
|
@ -156,6 +158,8 @@ func (w *hijackResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/{id} [get]
|
||||
// @Router /api/v1/notifications/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
func (h *Handler) GetNotificationByID(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -216,11 +220,18 @@ func (h *Handler) GetNotificationByID(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// MarkNotificationAsRead godoc
|
||||
// @Summary MarkNotificationAsRead
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Mark Notification As Read
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/{id}/read [patch]
|
||||
// @Router /api/v1/notifications/{id}/read [patch]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) MarkNotificationAsRead(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -256,11 +267,16 @@ func (h *Handler) MarkNotificationAsRead(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// MarkAllNotificationsAsRead godoc
|
||||
// @Summary MarkAllNotificationsAsRead
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Mark All Notifications As Read
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/mark-all-read [post]
|
||||
// @Router /api/v1/notifications/mark-all-read [post]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) MarkAllNotificationsAsRead(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok || userID == 0 {
|
||||
|
|
@ -293,11 +309,18 @@ func (h *Handler) MarkAllNotificationsAsRead(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// MarkNotificationAsUnread godoc
|
||||
// @Summary MarkNotificationAsUnread
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Mark Notification As Unread
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/{id}/unread [patch]
|
||||
// @Router /api/v1/notifications/{id}/unread [patch]
|
||||
// @Security Bearer
|
||||
// @Param id path int64 true "Id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) MarkNotificationAsUnread(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -333,11 +356,16 @@ func (h *Handler) MarkNotificationAsUnread(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// MarkAllNotificationsAsUnread godoc
|
||||
// @Summary MarkAllNotificationsAsUnread
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Mark All Notifications As Unread
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/mark-all-unread [post]
|
||||
// @Router /api/v1/notifications/mark-all-unread [post]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) MarkAllNotificationsAsUnread(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok || userID == 0 {
|
||||
|
|
@ -370,11 +398,16 @@ func (h *Handler) MarkAllNotificationsAsUnread(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// DeleteUserNotifications godoc
|
||||
// @Summary DeleteUserNotifications
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Delete User Notifications
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications [delete]
|
||||
// @Router /api/v1/notifications [delete]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) DeleteUserNotifications(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok || userID == 0 {
|
||||
|
|
@ -418,6 +451,9 @@ func (h *Handler) DeleteUserNotifications(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/{id} [delete]
|
||||
// @Router /api/v1/notifications/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteInAppNotification(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -478,6 +514,9 @@ func (h *Handler) DeleteInAppNotification(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/delete-in-app [post]
|
||||
// @Router /api/v1/notifications/delete-in-app [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteInAppNotifications(c *fiber.Ctx) error {
|
||||
type request struct {
|
||||
IDs []int64 `json:"ids"`
|
||||
|
|
@ -536,10 +575,18 @@ func (h *Handler) DeleteInAppNotifications(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// CreateAndSendNotification godoc
|
||||
// @Summary CreateAndSendNotification
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Create And Send Notification
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/create [post]
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body handlers.CreateAndSendNotification.Request true "Notification recipient and delivery settings"
|
||||
// @Success 201 {object} NotificationDispatchResponse
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) CreateAndSendNotification(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
RecipientID int64 `json:"recipient_id" validate:"required_if=DeliveryScheme single"`
|
||||
|
|
@ -702,11 +749,19 @@ func (h *Handler) CreateAndSendNotification(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// GetUserNotification godoc
|
||||
// @Summary GetUserNotification
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Get User Notification
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications [get]
|
||||
// @Router /api/v1/notifications [get]
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param offset query int false "Offset" default(0) minimum(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) GetUserNotification(c *fiber.Ctx) error {
|
||||
limitStr := c.Query("limit", "10")
|
||||
offsetStr := c.Query("offset", "0")
|
||||
|
|
@ -769,11 +824,16 @@ func (h *Handler) GetUserNotification(c *fiber.Ctx) error {
|
|||
// }
|
||||
|
||||
// CountUnreadNotifications godoc
|
||||
// @Summary CountUnreadNotifications
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Count Unread Notifications
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/unread [get]
|
||||
// @Router /api/v1/notifications/unread [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) CountUnreadNotifications(c *fiber.Ctx) error {
|
||||
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
|
|
@ -804,10 +864,24 @@ func (h *Handler) CountUnreadNotifications(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// GetAllNotifications godoc
|
||||
// @Summary GetAllNotifications
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Get All Notifications
|
||||
// @Tags notifications
|
||||
// @Router /api/v1/admin/notifications/all [get]
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(10)
|
||||
// @Param page query int false "Page" default(1)
|
||||
// @Param channel query string false "Channel"
|
||||
// @Param type query string false "Type"
|
||||
// @Param user_id query int false "User id"
|
||||
// @Param is_read query bool false "Is read"
|
||||
// @Param after query string false "After"
|
||||
// @Param before query string false "Before"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) GetAllNotifications(c *fiber.Ctx) error {
|
||||
limitStr := c.Query("limit", "10")
|
||||
pageStr := c.Query("page", "1")
|
||||
|
|
@ -891,6 +965,9 @@ type SendSingleAfroSMSReq struct {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/sendSMS [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SendSingleAfroSMS(c *fiber.Ctx) error {
|
||||
var req SendSingleAfroSMSReq
|
||||
|
||||
|
|
@ -952,11 +1029,19 @@ func (h *Handler) SendSingleAfroSMS(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// RegisterDeviceToken godoc
|
||||
// @Summary RegisterDeviceToken
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Register Device Token
|
||||
// @Tags devices
|
||||
// @Router /api/v1/admin/devices/register [post]
|
||||
// @Router /api/v1/devices/register [post]
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body handlers.RegisterDeviceToken.Request true "Device token and platform"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) RegisterDeviceToken(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
DeviceToken string `json:"device_token" validate:"required"`
|
||||
|
|
@ -1038,6 +1123,8 @@ func (h *Handler) RegisterDeviceToken(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/test-push [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SendTestPushNotification(c *fiber.Ctx) error {
|
||||
title := c.FormValue("title", "Test Push Notification")
|
||||
message := c.FormValue("message", "This is a test push notification from Rezina")
|
||||
|
|
@ -1141,6 +1228,10 @@ func (h *Handler) SendTestPushNotification(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-push [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error {
|
||||
title := c.FormValue("title")
|
||||
message := c.FormValue("message")
|
||||
|
|
@ -1348,6 +1439,10 @@ func (h *Handler) SendBulkPushNotification(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-sms [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkSMS(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
Message string `json:"message" validate:"required"`
|
||||
|
|
@ -1532,6 +1627,10 @@ func (h *Handler) SendBulkSMS(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-in-app [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
Title string `json:"title" validate:"required"`
|
||||
|
|
@ -1704,6 +1803,9 @@ func (h *Handler) SendBulkInAppNotification(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/scheduled/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetScheduledNotification(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -1744,6 +1846,9 @@ func (h *Handler) GetScheduledNotification(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/scheduled [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListScheduledNotifications(c *fiber.Ctx) error {
|
||||
limit, err := strconv.Atoi(c.Query("limit", "20"))
|
||||
if err != nil || limit <= 0 {
|
||||
|
|
@ -1813,6 +1918,9 @@ func (h *Handler) ListScheduledNotifications(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/scheduled/{id}/cancel [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CancelScheduledNotification(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -1876,6 +1984,16 @@ func (h *Handler) parseEmailAttachment(c *fiber.Ctx) []*resend.Attachment {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/send-email [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Param email_template_slug formData string false "Saved template slug; otherwise subject and message or html are required"
|
||||
// @Param template_variables formData string false "JSON object of template variables"
|
||||
// @Param subject formData string false "Subject, required when no template is selected"
|
||||
// @Param message formData string false "Plain-text body, required without a template unless html is supplied"
|
||||
// @Param html formData string false "HTML body alternative to message"
|
||||
// @Param file formData file false "Optional attachment"
|
||||
// @Param recipient formData string true "Recipient email address"
|
||||
func (h *Handler) SendSingleEmail(c *fiber.Ctx) error {
|
||||
recipient := strings.TrimSpace(c.FormValue("recipient"))
|
||||
if recipient == "" {
|
||||
|
|
@ -1931,6 +2049,22 @@ func (h *Handler) SendSingleEmail(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/notifications/bulk-email [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Param email_template_slug formData string false "Saved template slug; otherwise subject and message or html are required"
|
||||
// @Param template_variables formData string false "JSON object of template variables"
|
||||
// @Param subject formData string false "Subject, required when no template is selected"
|
||||
// @Param message formData string false "Plain-text body, required without a template unless html is supplied"
|
||||
// @Param html formData string false "HTML body alternative to message"
|
||||
// @Param file formData file false "Optional attachment"
|
||||
// @Param emails formData string false "Comma-separated direct email addresses"
|
||||
// @Param user_ids formData string false "Comma-separated customer IDs"
|
||||
// @Param role formData string false "Customer role used to select recipients"
|
||||
// @Param team_member_ids formData string false "Comma-separated team-member IDs"
|
||||
// @Param team_role formData string false "Team role used to select recipients"
|
||||
// @Param scheduled_at formData string false "Optional future delivery time in RFC3339 format"
|
||||
// @Success 201 {object} domain.Response "Scheduled notification created when scheduled_at is provided"
|
||||
func (h *Handler) SendBulkEmail(c *fiber.Ctx) error {
|
||||
role := c.FormValue("role")
|
||||
userIDsRaw := c.FormValue("user_ids")
|
||||
|
|
@ -2119,11 +2253,19 @@ func (h *Handler) SendBulkEmail(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// UnregisterDeviceToken godoc
|
||||
// @Summary UnregisterDeviceToken
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Unregister Device Token
|
||||
// @Tags devices
|
||||
// @Router /api/v1/admin/devices/unregister [post]
|
||||
// @Router /api/v1/devices/unregister [post]
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body handlers.UnregisterDeviceToken.Request true "Device token to unregister"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) UnregisterDeviceToken(c *fiber.Ctx) error {
|
||||
type Request struct {
|
||||
DeviceToken string `json:"device_token" validate:"required"`
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ type listAdminPaymentsRes struct {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/payments [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListAdminPayments(c *fiber.Ctx) error {
|
||||
filter, err := parsePaymentListFilter(c)
|
||||
if err != nil {
|
||||
|
|
@ -133,6 +137,13 @@ func (h *Handler) ListAdminPayments(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/payments/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Param limit query int false "Limit" default(20)
|
||||
// @Param offset query int false "Offset" default(0) minimum(0)
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetAdminPayment(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -240,6 +240,10 @@ func (h *Handler) GetLmsPracticeFull(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id}/full [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetExamPrepPracticeFull(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -381,6 +385,10 @@ func (h *Handler) UpdateLmsPracticeFull(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/exam-prep/practices/{id}/full [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) UpdateExamPrepPracticeFull(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ func parseOptionalGroupIDQuery(c *fiber.Ctx) (*int64, error) {
|
|||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/questions/component-catalog [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionTypeComponentCatalog(c *fiber.Ctx) error {
|
||||
return c.JSON(domain.Response{
|
||||
Message: "Component catalog",
|
||||
|
|
@ -126,6 +129,9 @@ func (h *Handler) GetQuestionTypeComponentCatalog(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/validate-question-type-definition [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ValidateQuestionTypeDefinition(c *fiber.Ctx) error {
|
||||
var req validateQuestionTypeDefinitionReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -159,6 +165,10 @@ func (h *Handler) ValidateQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) CreateQuestionTypeDefinition(c *fiber.Ctx) error {
|
||||
var req createQuestionTypeDefinitionReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -223,6 +233,10 @@ func (h *Handler) CreateQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) ListQuestionTypeDefinitions(c *fiber.Ctx) error {
|
||||
status := strings.ToUpper(strings.TrimSpace(c.Query("status")))
|
||||
var statusPtr *string
|
||||
|
|
@ -301,6 +315,9 @@ func (h *Handler) ListQuestionTypeDefinitions(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionTypeDefinitionByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -336,6 +353,10 @@ func (h *Handler) GetQuestionTypeDefinitionByID(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id}/practices [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListPracticesByQuestionTypeDefinition(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -383,6 +404,10 @@ func (h *Handler) ListPracticesByQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) UpdateQuestionTypeDefinition(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -456,6 +481,9 @@ func (h *Handler) UpdateQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definitions/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteQuestionTypeDefinition(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -491,6 +519,10 @@ func (h *Handler) DeleteQuestionTypeDefinition(c *fiber.Ctx) error {
|
|||
// @Param body body createQuestionTypeDefinitionGroupReq true "Group payload"
|
||||
// @Success 201 {object} domain.Response
|
||||
// @Router /api/v1/admin/questions/type-definition-groups [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) CreateQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
||||
var req createQuestionTypeDefinitionGroupReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -539,6 +571,11 @@ func (h *Handler) CreateQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Page offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/questions/type-definition-groups [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) ListQuestionTypeDefinitionGroups(c *fiber.Ctx) error {
|
||||
status := strings.ToUpper(strings.TrimSpace(c.Query("status")))
|
||||
var statusPtr *string
|
||||
|
|
@ -593,6 +630,11 @@ func (h *Handler) ListQuestionTypeDefinitionGroups(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/type-definition-groups/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetQuestionTypeDefinitionGroupByID(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -631,6 +673,11 @@ func (h *Handler) GetQuestionTypeDefinitionGroupByID(c *fiber.Ctx) error {
|
|||
// @Param body body updateQuestionTypeDefinitionGroupReq true "Update group payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/questions/type-definition-groups/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) UpdateQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
@ -687,6 +734,11 @@ func (h *Handler) UpdateQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Group id"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/questions/type-definition-groups/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) DeleteQuestionTypeDefinitionGroup(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || id <= 0 {
|
||||
|
|
|
|||
|
|
@ -216,6 +216,9 @@ func activityLogQuestionSummary(questionType string, stored string, payload *dom
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateQuestion(c *fiber.Ctx) error {
|
||||
var req createQuestionReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -370,6 +373,10 @@ func (h *Handler) CreateQuestion(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetQuestionByID(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -416,6 +423,9 @@ func (h *Handler) GetQuestionByID(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListQuestions(c *fiber.Ctx) error {
|
||||
questionType := c.Query("question_type")
|
||||
difficulty := c.Query("difficulty")
|
||||
|
|
@ -479,6 +489,9 @@ func (h *Handler) ListQuestions(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/search [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SearchQuestions(c *fiber.Ctx) error {
|
||||
query := c.Query("q")
|
||||
if query == "" {
|
||||
|
|
@ -552,6 +565,10 @@ type updateQuestionReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) UpdateQuestion(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -722,6 +739,9 @@ func (h *Handler) UpdateQuestion(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/questions/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteQuestion(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -842,6 +862,9 @@ func (h *Handler) enforcePracticeSequenceForStudent(c *fiber.Ctx, set domain.Que
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateQuestionSet(c *fiber.Ctx) error {
|
||||
var req createQuestionSetReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -911,6 +934,9 @@ func (h *Handler) CreateQuestionSet(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionSetByID(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -976,6 +1002,9 @@ func (h *Handler) GetQuestionSetByID(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionSetsByType(c *fiber.Ctx) error {
|
||||
setType := c.Query("set_type")
|
||||
if setType == "" {
|
||||
|
|
@ -1039,6 +1068,9 @@ func (h *Handler) GetQuestionSetsByType(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/by-owner [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionSetsByOwner(c *fiber.Ctx) error {
|
||||
ownerType := c.Query("owner_type")
|
||||
ownerIDStr := c.Query("owner_id")
|
||||
|
|
@ -1117,6 +1149,10 @@ type updateQuestionSetReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -1199,6 +1235,9 @@ func (h *Handler) UpdateQuestionSet(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteQuestionSet(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
@ -1344,6 +1383,9 @@ func questionSetItemsToRes(
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AddQuestionToSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
@ -1416,6 +1458,9 @@ func (h *Handler) AddQuestionToSet(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/question-types [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionTypesInSet(c *fiber.Ctx) error {
|
||||
setID, err := strconv.ParseInt(c.Params("setId"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -1502,6 +1547,10 @@ func (h *Handler) questionSetStimulusContexts(ctx context.Context, setID int64)
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) GetQuestionsInSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
@ -1632,6 +1681,9 @@ func (h *Handler) GetQuestionsInSet(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/exam-prep/practices/{practiceId}/questions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetQuestionsByPractice(c *fiber.Ctx) error {
|
||||
practiceIDStr := c.Params("practiceId")
|
||||
practiceID, err := strconv.ParseInt(practiceIDStr, 10, 64)
|
||||
|
|
@ -1741,6 +1793,12 @@ func (h *Handler) GetQuestionsByPractice(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/exam-prep/progress/practices/{id}/complete [post]
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body domain.CompletePracticeInput false "Optional practice parent scope"
|
||||
// @Param parent_kind query string false "Parent kind"
|
||||
// @Param parent_id query int false "Parent id"
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
func (h *Handler) CompletePractice(c *fiber.Ctx) error {
|
||||
role := c.Locals("role").(domain.Role)
|
||||
if !role.IsCustomerLearnerRole() {
|
||||
|
|
@ -1903,6 +1961,9 @@ func (h *Handler) CompletePractice(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions/{questionId} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) RemoveQuestionFromSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
@ -1963,6 +2024,9 @@ type updateQuestionOrderReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/questions/{questionId}/order [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateQuestionOrderInSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
@ -2047,6 +2111,9 @@ type addUserPersonaReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/personas [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetUserPersonasByQuestionSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
@ -2096,6 +2163,9 @@ func (h *Handler) GetUserPersonasByQuestionSet(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/personas [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AddUserPersonaToQuestionSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
@ -2149,6 +2219,9 @@ func (h *Handler) AddUserPersonaToQuestionSet(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/question-sets/{setId}/personas/{userId} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) RemoveUserPersonaFromQuestionSet(c *fiber.Ctx) error {
|
||||
setIDStr := c.Params("setId")
|
||||
setID, err := strconv.ParseInt(setIDStr, 10, 64)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ func isValidTargetType(t string) bool {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/ratings [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SubmitRating(c *fiber.Ctx) error {
|
||||
userID := c.Locals("user_id").(int64)
|
||||
|
||||
|
|
@ -114,6 +117,9 @@ func (h *Handler) SubmitRating(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/ratings/me [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetMyRating(c *fiber.Ctx) error {
|
||||
userID := c.Locals("user_id").(int64)
|
||||
|
||||
|
|
@ -164,6 +170,9 @@ func (h *Handler) GetMyRating(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/ratings [get]
|
||||
// @Router /api/v1/ratings [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetRatingsByTarget(c *fiber.Ctx) error {
|
||||
targetType := c.Query("target_type")
|
||||
if !isValidTargetType(targetType) {
|
||||
|
|
@ -231,6 +240,9 @@ func (h *Handler) GetRatingsByTarget(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/ratings/summary [get]
|
||||
// @Router /api/v1/ratings/summary [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetRatingSummary(c *fiber.Ctx) error {
|
||||
targetType := c.Query("target_type")
|
||||
if !isValidTargetType(targetType) {
|
||||
|
|
@ -276,6 +288,9 @@ func (h *Handler) GetRatingSummary(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/ratings/me/all [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetMyRatings(c *fiber.Ctx) error {
|
||||
userID := c.Locals("user_id").(int64)
|
||||
|
||||
|
|
@ -309,6 +324,9 @@ func (h *Handler) GetMyRatings(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/ratings/{id} [delete]
|
||||
// @Router /api/v1/ratings/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteRating(c *fiber.Ctx) error {
|
||||
userID := c.Locals("user_id").(int64)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import (
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param query query string false "Search by role name"
|
||||
// @Param is_system query bool false "Filter by system role (true/false)"
|
||||
// @Param page query int false "Page number (default: 1)"
|
||||
|
|
@ -26,6 +25,9 @@ import (
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListRoles(c *fiber.Ctx) error {
|
||||
filter := domain.RoleListFilter{
|
||||
Query: c.Query("query"),
|
||||
|
|
@ -70,13 +72,15 @@ func (h *Handler) ListRoles(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Role ID"
|
||||
// @Success 200 {object} domain.Response{data=domain.RoleWithPermissions}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetRoleByID(c *fiber.Ctx) error {
|
||||
roleID, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || roleID <= 0 {
|
||||
|
|
@ -131,12 +135,14 @@ func (h *Handler) GetRoleByID(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param body body domain.CreateRoleReq true "Role creation payload"
|
||||
// @Success 201 {object} domain.Response{data=domain.RoleRecord}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CreateRole(c *fiber.Ctx) error {
|
||||
var req domain.CreateRoleReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -202,13 +208,15 @@ func (h *Handler) CreateRole(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Role ID"
|
||||
// @Param body body domain.UpdateRoleReq true "Role update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateRole(c *fiber.Ctx) error {
|
||||
roleID, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || roleID <= 0 {
|
||||
|
|
@ -280,12 +288,14 @@ func (h *Handler) UpdateRole(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Role ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteRole(c *fiber.Ctx) error {
|
||||
roleID, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || roleID <= 0 {
|
||||
|
|
@ -333,13 +343,15 @@ func (h *Handler) DeleteRole(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Role ID"
|
||||
// @Param body body domain.SetRolePermissionsReq true "Permission IDs payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id}/permissions [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SetRolePermissions(c *fiber.Ctx) error {
|
||||
roleID, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || roleID <= 0 {
|
||||
|
|
@ -411,12 +423,14 @@ func (h *Handler) SetRolePermissions(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Role ID"
|
||||
// @Success 200 {object} domain.Response{data=[]domain.Permission}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/roles/{id}/permissions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetRolePermissions(c *fiber.Ctx) error {
|
||||
roleID, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || roleID <= 0 {
|
||||
|
|
@ -454,10 +468,12 @@ func (h *Handler) GetRolePermissions(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response{data=[]domain.Permission}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/permissions [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListPermissions(c *fiber.Ctx) error {
|
||||
permissions, err := h.rbacSvc.ListPermissions(c.Context())
|
||||
if err != nil {
|
||||
|
|
@ -491,10 +507,12 @@ func (h *Handler) ListPermissions(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response{data=[]string}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/permissions/groups [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListPermissionGroups(c *fiber.Ctx) error {
|
||||
groups, err := h.rbacSvc.ListPermissionGroups(c.Context())
|
||||
if err != nil {
|
||||
|
|
@ -523,10 +541,12 @@ func (h *Handler) ListPermissionGroups(c *fiber.Ctx) error {
|
|||
// @Tags rbac
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/rbac/permissions/sync [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SyncPermissions(c *fiber.Ctx) error {
|
||||
if err := h.rbacSvc.SeedPermissions(c.Context()); err != nil {
|
||||
h.mongoLoggerSvc.Error("Failed to seed permissions",
|
||||
|
|
|
|||
|
|
@ -58,8 +58,15 @@ func referralPagination(c *fiber.Ctx) (int32, int32, error) {
|
|||
|
||||
// CreateReferralCode creates or returns the authenticated learner's stable share code.
|
||||
// @Router /api/v1/referrals/code [post]
|
||||
// @Summary CreateReferralCode
|
||||
// @Tags client
|
||||
// @Summary Create Referral Code
|
||||
// @Tags referrals
|
||||
// @Security Bearer
|
||||
// @Description Creates or returns the authenticated learner's stable share code. Requires an active STUDENT or OPEN_LEARNER account; a subscription is not required.
|
||||
// @Success 200 {object} domain.Response{data=ReferralCodeData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
func (h *Handler) CreateReferralCode(c *fiber.Ctx) error {
|
||||
id, err := referralLearner(c)
|
||||
if err != nil {
|
||||
|
|
@ -68,17 +75,31 @@ func (h *Handler) CreateReferralCode(c *fiber.Ctx) error {
|
|||
code, err := h.referralSvc.Code(c.Context(), id)
|
||||
return referralResponse(c, fiber.Map{"code": code}, err)
|
||||
}
|
||||
|
||||
// GetReferralCode godoc
|
||||
// @Summary GetReferralCode
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Get Referral Code
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/referrals/code [get]
|
||||
func (h *Handler) GetReferralCode(c *fiber.Ctx) error { return h.CreateReferralCode(c) }
|
||||
// GetMyReferrals godoc
|
||||
// @Summary GetMyReferrals
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Description Returns the authenticated learner's stable share code, creating it when necessary. Codes are case-insensitive.
|
||||
// @Success 200 {object} domain.Response{data=ReferralCodeData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
func (h *Handler) GetReferralCode(c *fiber.Ctx) error { return h.CreateReferralCode(c) }
|
||||
|
||||
// GetMyReferrals godoc
|
||||
// @Summary Get My Referrals
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/referrals/me [get]
|
||||
// @Security Bearer
|
||||
// @Description Returns the learner's code, current commission percentage, referral/conversion counts, and commission-wallet balances by currency.
|
||||
// @Success 200 {object} domain.Response{data=ReferralOverviewData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
func (h *Handler) GetMyReferrals(c *fiber.Ctx) error {
|
||||
id, err := referralLearner(c)
|
||||
if err != nil {
|
||||
|
|
@ -87,29 +108,47 @@ func (h *Handler) GetMyReferrals(c *fiber.Ctx) error {
|
|||
data, err := h.referralSvc.Overview(c.Context(), id)
|
||||
return referralResponse(c, data, err)
|
||||
}
|
||||
|
||||
// ApplyReferralCode godoc
|
||||
// @Summary ApplyReferralCode
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Apply Referral Code
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/referrals/apply [post]
|
||||
// @Security Bearer
|
||||
// @Description Attributes the authenticated learner to one referrer. Apply within seven days of account creation and before any successful positive payment. Codes are case-insensitive and surrounding whitespace is ignored. Self referral, reassignment, inactive referrers, and invalid codes are rejected.
|
||||
// @Accept json
|
||||
// @Param body body applyReferralReq true "Referral share code"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request or ineligible referral"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
func (h *Handler) ApplyReferralCode(c *fiber.Ctx) error {
|
||||
id, err := referralLearner(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var input struct {
|
||||
Code string `json:"code"`
|
||||
}
|
||||
var input applyReferralReq
|
||||
if c.BodyParser(&input) != nil {
|
||||
return fiber.NewError(400, "Invalid request body")
|
||||
}
|
||||
return referralResponse(c, nil, h.referralSvc.Apply(c.Context(), id, input.Code))
|
||||
}
|
||||
|
||||
// ListMyReferrals godoc
|
||||
// @Summary ListMyReferrals
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary List My Referrals
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/referrals [get]
|
||||
// @Security Bearer
|
||||
// @Description Returns only the authenticated learner's referral history and conversion flags. Referred learners' names, emails, and phone numbers are not exposed.
|
||||
// @Success 200 {object} domain.Response{data=ReferralHistoryData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid pagination"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
// @Param limit query int false "Page size" default(20) minimum(1) maximum(100)
|
||||
// @Param offset query int false "Number of entries to skip" default(0) minimum(0)
|
||||
func (h *Handler) ListMyReferrals(c *fiber.Ctx) error {
|
||||
id, err := referralLearner(c)
|
||||
if err != nil {
|
||||
|
|
@ -122,11 +161,21 @@ func (h *Handler) ListMyReferrals(c *fiber.Ctx) error {
|
|||
data, err := h.referralSvc.List(c.Context(), id, limit, offset)
|
||||
return referralResponse(c, fiber.Map{"items": data, "limit": limit, "offset": offset}, err)
|
||||
}
|
||||
|
||||
// GetReferralWallet godoc
|
||||
// @Summary GetReferralWallet
|
||||
// @Tags client
|
||||
// @Security Bearer
|
||||
// @Summary Get Referral Wallet
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/referrals/wallet [get]
|
||||
// @Security Bearer
|
||||
// @Description Returns wallet balances separately by currency and a paginated commission ledger. Decimal amounts and percentages are strings. Only the first successful positive subscription payment earns a commission; duplicate callbacks and renewals do not. Reversed credits are excluded from balances. This endpoint does not initiate cash payouts.
|
||||
// @Success 200 {object} domain.Response{data=ReferralWalletData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid pagination"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
// @Param limit query int false "Page size" default(20) minimum(1) maximum(100)
|
||||
// @Param offset query int false "Number of entries to skip" default(0) minimum(0)
|
||||
func (h *Handler) GetReferralWallet(c *fiber.Ctx) error {
|
||||
id, err := referralLearner(c)
|
||||
if err != nil {
|
||||
|
|
@ -143,11 +192,18 @@ func (h *Handler) GetReferralWallet(c *fiber.Ctx) error {
|
|||
entries, err := h.referralSvc.Commissions(c.Context(), id, limit, offset)
|
||||
return referralResponse(c, fiber.Map{"balances": overview.Wallet, "transactions": entries, "limit": limit, "offset": offset}, err)
|
||||
}
|
||||
|
||||
// GetReferralSettings godoc
|
||||
// @Summary GetReferralSettings
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Get Referral Settings
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/admin/referrals/settings [get]
|
||||
// @Security Bearer
|
||||
// @Description Returns the saved referral commission percentage. Restricted to ADMIN and SUPER_ADMIN. The initial percentage is 0, which disables new credits.
|
||||
// @Success 200 {object} domain.Response{data=ReferralSettingsData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
func (h *Handler) GetReferralSettings(c *fiber.Ctx) error {
|
||||
if _, err := referralAdmin(c); err != nil {
|
||||
return err
|
||||
|
|
@ -155,19 +211,27 @@ func (h *Handler) GetReferralSettings(c *fiber.Ctx) error {
|
|||
data, err := h.referralSvc.Settings(c.Context())
|
||||
return referralResponse(c, data, err)
|
||||
}
|
||||
|
||||
// UpdateReferralSettings godoc
|
||||
// @Summary UpdateReferralSettings
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Update Referral Settings
|
||||
// @Tags referrals
|
||||
// @Router /api/v1/admin/referrals/settings [put]
|
||||
// @Security Bearer
|
||||
// @Description Sets the percentage credited on a referred learner's first successful positive subscription payment. Accepts 0 through 100 with at most two decimal places. Zero disables new credits. Changes affect future conversions only; existing credits retain their rate. Restricted to ADMIN and SUPER_ADMIN; changes are audited.
|
||||
// @Accept json
|
||||
// @Param body body updateReferralSettingsReq true "Commission percentage configuration"
|
||||
// @Success 200 {object} domain.Response{data=ReferralSettingsData}
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Missing or invalid commission_percent; use 0 through 100 with at most two decimal places"
|
||||
// @Failure 500 {string} string "Unable to process referral request"
|
||||
func (h *Handler) UpdateReferralSettings(c *fiber.Ctx) error {
|
||||
id, err := referralAdmin(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var input struct {
|
||||
Percent *float64 `json:"commission_percent"`
|
||||
}
|
||||
var input updateReferralSettingsReq
|
||||
if c.BodyParser(&input) != nil || input.Percent == nil {
|
||||
return fiber.NewError(400, "commission_percent is required")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,15 @@ import (
|
|||
)
|
||||
|
||||
// GetGlobalSettingList godoc
|
||||
// @Summary GetGlobalSettingList
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Get Global Setting List
|
||||
// @Tags settings
|
||||
// @Router /api/v1/admin/settings [get]
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) GetGlobalSettingList(c *fiber.Ctx) error {
|
||||
settingsList, err := h.settingSvc.GetGlobalSettingList(c.Context())
|
||||
|
||||
|
|
@ -36,10 +41,16 @@ func (h *Handler) GetGlobalSettingList(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// GetGlobalSettingByKey godoc
|
||||
// @Summary GetGlobalSettingByKey
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Get Global Setting By Key
|
||||
// @Tags settings
|
||||
// @Router /api/v1/admin/settings/{key} [get]
|
||||
// @Security Bearer
|
||||
// @Param key path string true "Key"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
func (h *Handler) GetGlobalSettingByKey(c *fiber.Ctx) error {
|
||||
settingKey := c.Params("key")
|
||||
if settingKey == "" {
|
||||
|
|
@ -68,10 +79,18 @@ func (h *Handler) GetGlobalSettingByKey(c *fiber.Ctx) error {
|
|||
}
|
||||
|
||||
// UpdateGlobalSettingList godoc
|
||||
// @Summary UpdateGlobalSettingList
|
||||
// @Tags admin
|
||||
// @Security Bearer
|
||||
// @Summary Update Global Setting List
|
||||
// @Tags settings
|
||||
// @Router /api/v1/admin/settings [put]
|
||||
// @Security Bearer
|
||||
// @Accept json
|
||||
// @Param body body domain.SaveSettingListReq true "Request payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Produce json
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {string} string "Invalid request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
func (h *Handler) UpdateGlobalSettingList(c *fiber.Ctx) error {
|
||||
|
||||
var req domain.SaveSettingListReq
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ type requestCheckoutLinkRes struct {
|
|||
// @Failure 429 {object} domain.ErrorResponse
|
||||
// @Failure 503 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscriptions/request-checkout-link [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) RequestSubscriptionCheckoutLink(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -121,6 +121,10 @@ type autoRenewReq struct {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 409 {object} domain.ErrorResponse "Resource conflict"
|
||||
func (h *Handler) CreateSubscriptionPlan(c *fiber.Ctx) error {
|
||||
var req createPlanReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -201,12 +205,11 @@ func (h *Handler) CreateSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Description Returns subscription plans. Optional category filter: EDUCATION.
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param active_only query bool false "Return only active plans (default true)"
|
||||
// @Param active_only query bool false "Customer requests always return active plans; false is honored only by the admin endpoint" default(true)
|
||||
// @Param category query string false "Filter by plan category (EDUCATION)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans [get]
|
||||
// @Router /api/v1/subscription-plans [get]
|
||||
func (h *Handler) ListSubscriptionPlans(c *fiber.Ctx) error {
|
||||
activeOnly := c.Query("active_only", "true") == "true"
|
||||
|
|
@ -253,8 +256,8 @@ func (h *Handler) ListSubscriptionPlans(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Plan ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans/{id} [get]
|
||||
// @Router /api/v1/subscription-plans/{id} [get]
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) GetSubscriptionPlan(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -292,6 +295,11 @@ func (h *Handler) GetSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans/{id} [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 409 {object} domain.ErrorResponse "Resource conflict"
|
||||
func (h *Handler) UpdateSubscriptionPlan(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -393,6 +401,12 @@ func (h *Handler) UpdateSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/subscription-plans/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
// @Failure 409 {object} domain.ErrorResponse "Resource conflict"
|
||||
func (h *Handler) DeleteSubscriptionPlan(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -449,6 +463,9 @@ func (h *Handler) DeleteSubscriptionPlan(c *fiber.Ctx) error {
|
|||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @deprecated Use POST /api/v1/payments/subscribe for user subscriptions with payment
|
||||
// @Router /api/v1/subscriptions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) Subscribe(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -517,6 +534,10 @@ func (h *Handler) Subscribe(c *fiber.Ctx) error {
|
|||
// @Failure 409 {object} domain.ErrorResponse "User already has active subscription"
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscriptions/checkout [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) SubscribeWithPayment(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -625,6 +646,10 @@ func (h *Handler) SubscribeWithPayment(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/subscriptions/me [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetMySubscription(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -661,6 +686,10 @@ func (h *Handler) GetMySubscription(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset" default(0)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/subscriptions/history [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) GetMySubscriptionHistory(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -698,6 +727,10 @@ func (h *Handler) GetMySubscriptionHistory(c *fiber.Ctx) error {
|
|||
// @Produce json
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/subscriptions/status [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) CheckSubscriptionStatus(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -731,6 +764,11 @@ func (h *Handler) CheckSubscriptionStatus(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscriptions/{id}/cancel [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) CancelSubscription(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -784,6 +822,11 @@ func (h *Handler) CancelSubscription(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/subscriptions/{id}/auto-renew [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 404 {object} domain.ErrorResponse "Resource not found"
|
||||
func (h *Handler) SetAutoRenew(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
|
|||
69
internal/web_server/handlers/swagger_admin_shared.go
Normal file
69
internal/web_server/handlers/swagger_admin_shared.go
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package handlers
|
||||
|
||||
// Documentation-only operations distinguish protected admin reads from their public customer counterparts.
|
||||
// These functions are never registered as HTTP handlers.
|
||||
|
||||
// DocumentAdminListSubscriptionPlans godoc
|
||||
// @Summary List subscription plans
|
||||
// @Description Returns subscription plans. Optional category filter: EDUCATION.
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param active_only query bool false "Return only active plans (default true)"
|
||||
// @Param category query string false "Filter by plan category (EDUCATION)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/subscription-plans [get]
|
||||
func documentAdminListSubscriptionPlans() {}
|
||||
|
||||
// DocumentAdminGetSubscriptionPlan godoc
|
||||
// @Summary Get a subscription plan
|
||||
// @Description Returns a single subscription plan by ID
|
||||
// @Tags subscriptions
|
||||
// @Produce json
|
||||
// @Param id path int true "Plan ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/subscription-plans/{id} [get]
|
||||
func documentAdminGetSubscriptionPlan() {}
|
||||
|
||||
// DocumentAdminGetSampleVideo godoc
|
||||
// @Summary Get a sample Vimeo video with iframe embed
|
||||
// @Description Fetches a sample video from Vimeo and returns video details along with an embeddable iframe for client-side integration
|
||||
// @Tags Vimeo
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param video_id query string false "Vimeo Video ID to use as sample" default(76979871)
|
||||
// @Param width query int false "Player width" default(640)
|
||||
// @Param height query int false "Player height" default(360)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/vimeo/sample [get]
|
||||
func documentAdminGetSampleVideo() {}
|
||||
|
||||
// DocumentAdminGetOEmbed godoc
|
||||
// @Summary Get oEmbed data for a Vimeo URL
|
||||
// @Description Fetches oEmbed metadata for a Vimeo video URL
|
||||
// @Tags Vimeo
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param url query string true "Vimeo video URL"
|
||||
// @Param width query int false "Desired width"
|
||||
// @Param height query int false "Desired height"
|
||||
// @Success 200 {object} vimeo.OEmbedResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/vimeo/oembed [get]
|
||||
func documentAdminGetOEmbed() {}
|
||||
68
internal/web_server/handlers/swagger_referral_models.go
Normal file
68
internal/web_server/handlers/swagger_referral_models.go
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package handlers
|
||||
|
||||
// ReferralCodeData is the learner's stable, case-insensitive share code.
|
||||
type ReferralCodeData struct {
|
||||
Code string `json:"code" validate:"required" example:"ABCDEF0123456789"`
|
||||
}
|
||||
|
||||
type applyReferralReq struct {
|
||||
Code string `json:"code" validate:"required" example:"ABCDEF0123456789"`
|
||||
}
|
||||
|
||||
type updateReferralSettingsReq struct {
|
||||
// Percentage of the first successful positive subscription payment, with at most two decimal places. Zero disables new commissions.
|
||||
Percent *float64 `json:"commission_percent" validate:"required" minimum:"0" maximum:"100" example:"10.25"`
|
||||
}
|
||||
|
||||
type ReferralWalletBalance struct {
|
||||
Currency string `json:"currency" example:"ETB"`
|
||||
// Decimal string; balances are not combined across currencies.
|
||||
Balance string `json:"balance" example:"125.50"`
|
||||
}
|
||||
|
||||
type ReferralOverviewData struct {
|
||||
Code string `json:"code" validate:"required" example:"ABCDEF0123456789"`
|
||||
CommissionPercent string `json:"commission_percent" example:"10.25"`
|
||||
TotalReferrals int64 `json:"total_referrals" example:"12"`
|
||||
ConvertedReferrals int64 `json:"converted_referrals" example:"3"`
|
||||
Wallet []ReferralWalletBalance `json:"wallet"`
|
||||
}
|
||||
|
||||
type ReferralHistoryItem struct {
|
||||
ID int64 `json:"id" example:"14"`
|
||||
CreatedAt string `json:"created_at" format:"date-time" example:"2026-10-28T09:00:00Z"`
|
||||
Converted bool `json:"converted" example:"true"`
|
||||
}
|
||||
type ReferralHistoryData struct {
|
||||
Items []ReferralHistoryItem `json:"items"`
|
||||
Limit int32 `json:"limit" example:"20"`
|
||||
Offset int32 `json:"offset" example:"0"`
|
||||
}
|
||||
type ReferralCommissionItem struct {
|
||||
ID int64 `json:"id" example:"7"`
|
||||
PaymentID int64 `json:"payment_id" example:"42"`
|
||||
CommissionPercent string `json:"commission_percent" example:"10.25"`
|
||||
Amount string `json:"amount" example:"51.25"`
|
||||
Currency string `json:"currency" example:"ETB"`
|
||||
CreatedAt string `json:"created_at" format:"date-time" example:"2026-10-28T09:00:00Z"`
|
||||
// Null until the qualifying payment leaves SUCCESS; reversed credits no longer contribute to the balance.
|
||||
ReversedAt *string `json:"reversed_at" format:"date-time" extensions:"x-nullable"`
|
||||
}
|
||||
type ReferralWalletData struct {
|
||||
Balances []ReferralWalletBalance `json:"balances"`
|
||||
Transactions []ReferralCommissionItem `json:"transactions"`
|
||||
Limit int32 `json:"limit" example:"20"`
|
||||
Offset int32 `json:"offset" example:"0"`
|
||||
}
|
||||
type ReferralSettingsData struct {
|
||||
CommissionPercent string `json:"commission_percent" example:"10.25"`
|
||||
UpdatedAt string `json:"updated_at" format:"date-time" example:"2026-10-28T09:00:00Z"`
|
||||
}
|
||||
|
||||
// NotificationDispatchResponse describes immediate single or bulk notification delivery.
|
||||
type NotificationDispatchResponse struct {
|
||||
Message string `json:"message"`
|
||||
NotificationID string `json:"notification_id,omitempty"`
|
||||
RecipientCount *int `json:"recipient_count,omitempty"`
|
||||
NotificationIDs []string `json:"notification_ids,omitempty"`
|
||||
}
|
||||
|
|
@ -186,6 +186,7 @@ func (h *Handler) TeamMemberLogin(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/refresh [post]
|
||||
// @Failure 403 {object} domain.ErrorResponse "Access denied"
|
||||
func (h *Handler) TeamMemberRefresh(c *fiber.Ctx) error {
|
||||
var req teamMemberRefreshReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -258,7 +259,6 @@ func (h *Handler) TeamMemberRefresh(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param body body domain.CreateTeamMemberReq true "Team member creation payload"
|
||||
// @Success 201 {object} domain.Response{data=domain.TeamMemberResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
|
|
@ -266,6 +266,7 @@ func (h *Handler) TeamMemberRefresh(c *fiber.Ctx) error {
|
|||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members [post]
|
||||
// @Security Bearer
|
||||
func (h *Handler) CreateTeamMember(c *fiber.Ctx) error {
|
||||
var req domain.CreateTeamMemberReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -354,7 +355,6 @@ func (h *Handler) CreateTeamMember(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Success 200 {object} domain.Response{data=domain.TeamMemberResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
|
|
@ -362,6 +362,8 @@ func (h *Handler) CreateTeamMember(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetTeamMember(c *fiber.Ctx) error {
|
||||
memberIDStr := c.Params("id")
|
||||
memberID, err := strconv.ParseInt(memberIDStr, 10, 64)
|
||||
|
|
@ -406,7 +408,6 @@ func (h *Handler) GetTeamMember(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param team_role query string false "Filter by team role (super_admin, admin, content_manager, support_agent, instructor, finance, hr, analyst)"
|
||||
// @Param department query string false "Filter by department"
|
||||
// @Param status query string false "Filter by status (active, inactive, suspended, terminated)"
|
||||
|
|
@ -418,6 +419,7 @@ func (h *Handler) GetTeamMember(c *fiber.Ctx) error {
|
|||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members [get]
|
||||
// @Security Bearer
|
||||
func (h *Handler) GetAllTeamMembers(c *fiber.Ctx) error {
|
||||
filter := domain.TeamMemberFilter{}
|
||||
|
||||
|
|
@ -496,7 +498,6 @@ func (h *Handler) GetAllTeamMembers(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Param body body domain.UpdateTeamMemberReq true "Team member update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -506,6 +507,7 @@ func (h *Handler) GetAllTeamMembers(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id} [put]
|
||||
// @Security Bearer
|
||||
func (h *Handler) UpdateTeamMember(c *fiber.Ctx) error {
|
||||
memberIDStr := c.Params("id")
|
||||
memberID, err := strconv.ParseInt(memberIDStr, 10, 64)
|
||||
|
|
@ -586,7 +588,6 @@ func (h *Handler) UpdateTeamMember(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Param body body domain.UpdateTeamMemberStatusReq true "Status update payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -596,6 +597,7 @@ func (h *Handler) UpdateTeamMember(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id}/status [patch]
|
||||
// @Security Bearer
|
||||
func (h *Handler) UpdateTeamMemberStatus(c *fiber.Ctx) error {
|
||||
memberIDStr := c.Params("id")
|
||||
memberID, err := strconv.ParseInt(memberIDStr, 10, 64)
|
||||
|
|
@ -688,7 +690,6 @@ func (h *Handler) UpdateTeamMemberStatus(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
|
|
@ -697,6 +698,7 @@ func (h *Handler) UpdateTeamMemberStatus(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id} [delete]
|
||||
// @Security Bearer
|
||||
func (h *Handler) DeleteTeamMember(c *fiber.Ctx) error {
|
||||
memberIDStr := c.Params("id")
|
||||
memberID, err := strconv.ParseInt(memberIDStr, 10, 64)
|
||||
|
|
@ -751,12 +753,12 @@ func (h *Handler) DeleteTeamMember(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response{data=domain.TeamMemberStats}
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/stats [get]
|
||||
// @Security Bearer
|
||||
func (h *Handler) GetTeamMemberStats(c *fiber.Ctx) error {
|
||||
stats, err := h.teamSvc.GetTeamMemberStats(c.Context())
|
||||
if err != nil {
|
||||
|
|
@ -785,7 +787,6 @@ func (h *Handler) GetTeamMemberStats(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param id path int true "Team Member ID"
|
||||
// @Param body body changePasswordReq true "Password change payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
|
|
@ -794,6 +795,8 @@ func (h *Handler) GetTeamMemberStats(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id}/change-password [post]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ChangeTeamMemberPassword(c *fiber.Ctx) error {
|
||||
memberIDStr := c.Params("id")
|
||||
memberID, err := strconv.ParseInt(memberIDStr, 10, 64)
|
||||
|
|
@ -864,13 +867,14 @@ func (h *Handler) ChangeTeamMemberPassword(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response{data=domain.TeamMemberResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 401 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/me [get]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetMyTeamProfile(c *fiber.Ctx) error {
|
||||
memberID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
@ -914,7 +918,6 @@ func (h *Handler) GetMyTeamProfile(c *fiber.Ctx) error {
|
|||
// @Tags team
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Param body body domain.UpdateMyTeamProfileReq true "Profile update payload"
|
||||
// @Success 200 {object} domain.Response{data=domain.TeamMemberResponse}
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
|
|
@ -922,6 +925,8 @@ func (h *Handler) GetMyTeamProfile(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/me [put]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateMyTeamProfile(c *fiber.Ctx) error {
|
||||
memberID, ok := c.Locals("user_id").(int64)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ func mapTeamInvitationListItem(row domain.TeamInvitationWithMember) teamInvitati
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/invite [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) InviteTeamMember(c *fiber.Ctx) error {
|
||||
if err := requireSuperAdminForTeamInvitation(c); err != nil {
|
||||
return err
|
||||
|
|
@ -116,6 +119,9 @@ func (h *Handler) InviteTeamMember(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/team/members/{id}/resend-invite [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ResendTeamInvitation(c *fiber.Ctx) error {
|
||||
if err := requireSuperAdminForTeamInvitation(c); err != nil {
|
||||
return err
|
||||
|
|
@ -159,6 +165,10 @@ func (h *Handler) ResendTeamInvitation(c *fiber.Ctx) error {
|
|||
// @Param offset query int false "Offset (default 0)"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/team/invitations [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) ListTeamInvitations(c *fiber.Ctx) error {
|
||||
status := strings.TrimSpace(c.Query("status"))
|
||||
var statusPtr *string
|
||||
|
|
@ -200,6 +210,10 @@ func (h *Handler) ListTeamInvitations(c *fiber.Ctx) error {
|
|||
// @Param id path int true "Invitation ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/team/invitations/{id}/revoke [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) RevokeTeamInvitation(c *fiber.Ctx) error {
|
||||
invitationID, err := strconv.ParseInt(c.Params("id"), 10, 64)
|
||||
if err != nil || invitationID <= 0 {
|
||||
|
|
@ -230,6 +244,8 @@ func (h *Handler) RevokeTeamInvitation(c *fiber.Ctx) error {
|
|||
// @Param token query string true "Invitation token"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/team/invitations/verify [get]
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) VerifyTeamInvitation(c *fiber.Ctx) error {
|
||||
token := strings.TrimSpace(c.Query("token"))
|
||||
if token == "" {
|
||||
|
|
@ -262,6 +278,7 @@ func (h *Handler) VerifyTeamInvitation(c *fiber.Ctx) error {
|
|||
// @Param body body domain.AcceptTeamInvitationReq true "Accept invitation payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Router /api/v1/admin/team/invitations/accept [post]
|
||||
// @Failure 400 {object} domain.ErrorResponse "Invalid request"
|
||||
func (h *Handler) AcceptTeamInvitation(c *fiber.Ctx) error {
|
||||
var req domain.AcceptTeamInvitationReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
|
|||
|
|
@ -29,10 +29,12 @@ import (
|
|||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security Bearer
|
||||
// @Success 200 {object} domain.Response{data=domain.UserSummary}
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/users/summary [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetUserSummary(c *fiber.Ctx) error {
|
||||
summary, err := h.userSvc.GetUserSummary(c.Context())
|
||||
if err != nil {
|
||||
|
|
@ -62,6 +64,9 @@ func (h *Handler) GetUserSummary(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user/{user_id}/is-profile-completed [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) CheckProfileCompleted(c *fiber.Ctx) error {
|
||||
userIDParam := c.Params("user_id")
|
||||
if userIDParam == "" {
|
||||
|
|
@ -109,13 +114,15 @@ func (h *Handler) CheckProfileCompleted(c *fiber.Ctx) error {
|
|||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param user_id path int true "User ID"
|
||||
// @Param body body domain.UpdateUserReq true "Update user payload"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user [put]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateUser(c *fiber.Ctx) error {
|
||||
// Extract user ID from context
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
|
|
@ -195,6 +202,8 @@ func (h *Handler) UpdateUser(c *fiber.Ctx) error {
|
|||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user/knowledge-level [put]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateUserKnowledgeLevel(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok || userID <= 0 {
|
||||
|
|
@ -381,12 +390,12 @@ func (h *Handler) ResendOtp(c *fiber.Ctx) error {
|
|||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param user_id path string true "User ID"
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/user/{user_name}/is-pending [get]
|
||||
// @Param user_name path string true "User name"
|
||||
func (h *Handler) CheckUserPending(c *fiber.Ctx) error {
|
||||
userID, err := strconv.ParseInt(c.Params("user_id"), 10, 64)
|
||||
if err != nil {
|
||||
|
|
@ -444,6 +453,9 @@ func (h *Handler) CheckUserPending(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/users [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetAllUsers(c *fiber.Ctx) error {
|
||||
filter, err := parseUserListFilter(c)
|
||||
if err != nil {
|
||||
|
|
@ -591,6 +603,9 @@ func (h *Handler) GetAllUsers(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/users/deletion-requests [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListAccountDeletionRequests(c *fiber.Ctx) error {
|
||||
parseRFC3339 := func(value string) (domain.ValidTime, error) {
|
||||
if value == "" {
|
||||
|
|
@ -675,6 +690,9 @@ func (h *Handler) ListAccountDeletionRequests(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/user/status [patch]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UpdateUserStatus(c *fiber.Ctx) error {
|
||||
var req struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
|
|
@ -1029,7 +1047,6 @@ func (h *Handler) SendRegisterCode(c *fiber.Ctx) error {
|
|||
|
||||
// RegisterUser godoc
|
||||
// @Summary Register user
|
||||
// @Description Register user
|
||||
// @Tags user
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
|
|
@ -1038,6 +1055,7 @@ func (h *Handler) SendRegisterCode(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/user/register [post]
|
||||
// @Description Registers a learner with email or phone and password. The server assigns the learner role and selects the OTP medium from the contact method. An optional referral_code attributes the new account atomically; invalid or ineligible codes reject registration.
|
||||
func (h *Handler) RegisterUser(c *fiber.Ctx) error {
|
||||
var req domain.RegisterUserReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -1374,8 +1392,10 @@ func (h *Handler) ResetTenantPassword(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} domain.UserProfileResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/user/user-profile [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetUserProfile(c *fiber.Ctx) error {
|
||||
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
|
|
@ -1496,8 +1516,10 @@ type AdminProfileRes struct {
|
|||
// @Success 200 {object} AdminProfileRes
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/user/admin-profile [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) AdminProfile(c *fiber.Ctx) error {
|
||||
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
|
|
@ -1629,6 +1651,9 @@ type SearchUserByNameOrPhoneReq struct {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/user/search [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) SearchUserByNameOrPhone(c *fiber.Ctx) error {
|
||||
var req SearchUserByNameOrPhoneReq
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
@ -1765,6 +1790,8 @@ func (h *Handler) SearchUserByNameOrPhone(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/user/single/{id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) GetUserByID(c *fiber.Ctx) error {
|
||||
userIDstr := c.Params("id")
|
||||
userID, err := strconv.ParseInt(userIDstr, 10, 64)
|
||||
|
|
@ -1883,6 +1910,9 @@ func (h *Handler) GetUserByID(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Router /api/v1/admin/user/delete/{id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) DeleteUser(c *fiber.Ctx) error {
|
||||
userIDstr := c.Params("id")
|
||||
userID, err := strconv.ParseInt(userIDstr, 10, 64)
|
||||
|
|
@ -1943,8 +1973,8 @@ const (
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 403 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/user/me [delete]
|
||||
// @Security Bearer
|
||||
func (h *Handler) DeleteMyUserAccount(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok || userID <= 0 {
|
||||
|
|
@ -1996,8 +2026,8 @@ func (h *Handler) DeleteMyUserAccount(c *fiber.Ctx) error {
|
|||
// @Failure 401 {object} response.APIResponse
|
||||
// @Failure 403 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/user/me/deletion/cancel [post]
|
||||
// @Security Bearer
|
||||
func (h *Handler) CancelMyUserAccountDeletion(c *fiber.Ctx) error {
|
||||
userID, ok := c.Locals("user_id").(int64)
|
||||
if !ok || userID <= 0 {
|
||||
|
|
@ -2043,8 +2073,10 @@ func (h *Handler) CancelMyUserAccountDeletion(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/internal/users/purge-due-deletions [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) PurgeDueDeletedUsers(c *fiber.Ctx) error {
|
||||
limit := int32(c.QueryInt("limit", int(defaultDeletePurgeBatchSize)))
|
||||
if limit <= 0 {
|
||||
|
|
@ -2094,9 +2126,11 @@ type UpdateUserSuspendRes struct {
|
|||
// @Success 200 {object} response.APIResponse
|
||||
// @Failure 400 {object} response.APIResponse
|
||||
// @Failure 500 {object} response.APIResponse
|
||||
// @Security Bearer
|
||||
// @Router /api/v1/admin/user/{id}/profile-picture [post]
|
||||
// @Router /api/v1/user/{id}/profile-picture [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) UploadProfilePicture(c *fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
userID, err := strconv.ParseInt(idStr, 10, 64)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ import (
|
|||
// @Failure 403 {object} domain.ErrorResponse
|
||||
// @Failure 404 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/exam-prep/videos/engagement/heartbeat [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 500 {object} domain.ErrorResponse "Internal server error"
|
||||
func (h *Handler) RecordVideoEngagementHeartbeat(c *fiber.Ctx) error {
|
||||
var req domain.VideoEngagementHeartbeatInput
|
||||
if err := c.BodyParser(&req); err != nil {
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ func vimeoVideoInfoToResponse(info *vimeoservice.VideoInfo) VimeoVideoResponse {
|
|||
// @Failure 503 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
func (h *Handler) ListVimeoVideos(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -193,6 +196,10 @@ func (h *Handler) ListVimeoVideos(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id} [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) GetVimeoVideo(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -236,6 +243,10 @@ func (h *Handler) GetVimeoVideo(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/uploads/pull [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) CreatePullUpload(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -293,6 +304,10 @@ func (h *Handler) CreatePullUpload(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/uploads/tus [post]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) CreateTusUpload(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -356,6 +371,10 @@ func (h *Handler) CreateTusUpload(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id}/embed [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) GetEmbedCode(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -418,10 +437,14 @@ func (h *Handler) GetEmbedCode(c *fiber.Ctx) error {
|
|||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param video_id path string true "Vimeo Video ID"
|
||||
// @Success 204
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id} [delete]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) DeleteVimeoVideo(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -466,6 +489,10 @@ func (h *Handler) DeleteVimeoVideo(c *fiber.Ctx) error {
|
|||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/videos/{video_id}/status [get]
|
||||
// @Security Bearer
|
||||
// @Failure 401 {string} string "Missing, invalid, or expired Bearer token"
|
||||
// @Failure 403 {string} string "Account audience, status, permission, or subscription does not allow this operation"
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) GetTranscodeStatus(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -512,8 +539,8 @@ func (h *Handler) GetTranscodeStatus(c *fiber.Ctx) error {
|
|||
// @Param height query int false "Player height" default(360)
|
||||
// @Success 200 {object} domain.Response
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/sample [get]
|
||||
// @Router /api/v1/vimeo/sample [get]
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) GetSampleVideo(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
@ -557,8 +584,8 @@ func (h *Handler) GetSampleVideo(c *fiber.Ctx) error {
|
|||
// @Success 200 {object} vimeo.OEmbedResponse
|
||||
// @Failure 400 {object} domain.ErrorResponse
|
||||
// @Failure 500 {object} domain.ErrorResponse
|
||||
// @Router /api/v1/admin/vimeo/oembed [get]
|
||||
// @Router /api/v1/vimeo/oembed [get]
|
||||
// @Failure 503 {object} domain.ErrorResponse "Service unavailable"
|
||||
func (h *Handler) GetOEmbed(c *fiber.Ctx) error {
|
||||
if h.vimeoSvc == nil {
|
||||
return c.Status(fiber.StatusServiceUnavailable).JSON(domain.ErrorResponse{
|
||||
|
|
|
|||
333
internal/web_server/swagger_contract_test.go
Normal file
333
internal/web_server/swagger_contract_test.go
Normal file
|
|
@ -0,0 +1,333 @@
|
|||
package httpserver
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"Rezina-Backend/docs"
|
||||
openapiswag "github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
type documentedParameter struct {
|
||||
Name string `json:"name"`
|
||||
In string `json:"in"`
|
||||
Required bool `json:"required"`
|
||||
Type string `json:"type"`
|
||||
Schema map[string]any `json:"schema"`
|
||||
}
|
||||
type documentedOperation struct {
|
||||
Summary string `json:"summary"`
|
||||
Parameters []documentedParameter `json:"parameters"`
|
||||
Responses map[string]json.RawMessage `json:"responses"`
|
||||
Security []map[string][]string `json:"security"`
|
||||
}
|
||||
type swaggerRouteContract struct {
|
||||
Method, Path, Handler string
|
||||
Bearer, WebSocket bool
|
||||
}
|
||||
|
||||
var fiberPathParameter = regexp.MustCompile(`:(\w+)(?:<[^>]+>)?`)
|
||||
var swaggerPathParameter = regexp.MustCompile(`\{([^}]+)\}`)
|
||||
|
||||
func registeredSwaggerContracts(t *testing.T) []swaggerRouteContract {
|
||||
t.Helper()
|
||||
var result []swaggerRouteContract
|
||||
for _, audience := range []string{"admin", "client", "integration"} {
|
||||
file, err := parser.ParseFile(token.NewFileSet(), "routes_"+audience+".go", nil, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ast.Inspect(file, func(node ast.Node) bool {
|
||||
call, ok := node.(*ast.CallExpr)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
selector, ok := call.Fun.(*ast.SelectorExpr)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
receiver, ok := selector.X.(*ast.Ident)
|
||||
if !ok || receiver.Name != "api" {
|
||||
return true
|
||||
}
|
||||
method := strings.ToLower(selector.Sel.Name)
|
||||
switch method {
|
||||
case "get", "post", "put", "patch", "delete":
|
||||
default:
|
||||
return true
|
||||
}
|
||||
literal, ok := call.Args[0].(*ast.BasicLit)
|
||||
if !ok {
|
||||
t.Fatal("API route must use a string literal")
|
||||
}
|
||||
path, err := strconv.Unquote(literal.Value)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
prefix := "/api/v1"
|
||||
if audience == "admin" {
|
||||
prefix += "/admin"
|
||||
}
|
||||
contract := swaggerRouteContract{Method: method, Path: prefix + fiberPathParameter.ReplaceAllString(path, "{$1}")}
|
||||
for _, argument := range call.Args[1:] {
|
||||
member, ok := argument.(*ast.SelectorExpr)
|
||||
if !ok {
|
||||
if factory, ok := argument.(*ast.CallExpr); ok {
|
||||
member, _ = factory.Fun.(*ast.SelectorExpr)
|
||||
}
|
||||
}
|
||||
if member == nil {
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(member.Sel.Name, "WebsocketAuthMiddleware") {
|
||||
contract.WebSocket = true
|
||||
}
|
||||
if member.Sel.Name == "adminAuthMiddleware" || member.Sel.Name == "clientAuthMiddleware" {
|
||||
contract.Bearer = true
|
||||
}
|
||||
if owner, ok := member.X.(*ast.Ident); ok && (owner.Name == "h" || owner.Name == "handlers") {
|
||||
contract.Handler = member.Sel.Name
|
||||
}
|
||||
}
|
||||
result = append(result, contract)
|
||||
return true
|
||||
})
|
||||
}
|
||||
result = append(result, swaggerRouteContract{Method: "get", Path: "/payment/success", Handler: "HandleChapaSuccessPage"})
|
||||
return result
|
||||
}
|
||||
|
||||
func TestSwaggerMatchesRegisteredRoutes(t *testing.T) {
|
||||
var spec struct {
|
||||
Paths map[string]map[string]documentedOperation `json:"paths"`
|
||||
SecurityDefinitions map[string]any `json:"securityDefinitions"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(docs.SwaggerInfo.ReadDoc()), &spec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expected := map[string]bool{}
|
||||
for _, route := range registeredSwaggerContracts(t) {
|
||||
key := strings.ToUpper(route.Method) + " " + route.Path
|
||||
expected[key] = true
|
||||
t.Run(key, func(t *testing.T) {
|
||||
operation, ok := spec.Paths[route.Path][route.Method]
|
||||
if !ok {
|
||||
t.Fatal("registered operation is missing from Swagger")
|
||||
}
|
||||
if operation.Summary == "" {
|
||||
t.Error("operation has no summary")
|
||||
}
|
||||
if len(operation.Responses) == 0 {
|
||||
t.Error("operation has no responses")
|
||||
}
|
||||
success := false
|
||||
for code := range operation.Responses {
|
||||
if strings.HasPrefix(code, "2") || code == "101" || strings.HasPrefix(code, "3") {
|
||||
success = true
|
||||
}
|
||||
}
|
||||
if !success {
|
||||
t.Error("operation has no documented success response")
|
||||
}
|
||||
bearer := false
|
||||
for _, requirement := range operation.Security {
|
||||
for scheme := range requirement {
|
||||
if _, exists := spec.SecurityDefinitions[scheme]; !exists {
|
||||
t.Errorf("unknown security scheme %s", scheme)
|
||||
}
|
||||
}
|
||||
if _, ok := requirement["Bearer"]; ok {
|
||||
bearer = true
|
||||
}
|
||||
}
|
||||
if bearer != route.Bearer {
|
||||
t.Errorf("Bearer security=%v; route requires=%v", bearer, route.Bearer)
|
||||
}
|
||||
actual := map[string]bool{}
|
||||
for _, parameter := range operation.Parameters {
|
||||
if parameter.In == "path" {
|
||||
if !parameter.Required {
|
||||
t.Errorf("path parameter %s is optional", parameter.Name)
|
||||
}
|
||||
if parameter.Type == "" {
|
||||
t.Errorf("path parameter %s has no type", parameter.Name)
|
||||
}
|
||||
actual[parameter.Name] = true
|
||||
}
|
||||
if parameter.In == "body" && len(parameter.Schema) == 0 {
|
||||
t.Error("body parameter has no schema")
|
||||
}
|
||||
}
|
||||
for _, match := range swaggerPathParameter.FindAllStringSubmatch(route.Path, -1) {
|
||||
if !actual[match[1]] {
|
||||
t.Errorf("missing path parameter %s", match[1])
|
||||
}
|
||||
delete(actual, match[1])
|
||||
}
|
||||
for name := range actual {
|
||||
t.Errorf("documented path parameter %s does not exist in route", name)
|
||||
}
|
||||
if route.WebSocket {
|
||||
found := false
|
||||
for _, parameter := range operation.Parameters {
|
||||
if parameter.Name == "token" && parameter.In == "query" && parameter.Required {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Error("WebSocket query-token authentication is undocumented")
|
||||
}
|
||||
if _, exists := operation.Responses["101"]; !exists {
|
||||
t.Error("WebSocket upgrade response is undocumented")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
for path, operations := range spec.Paths {
|
||||
for method := range operations {
|
||||
if !expected[strings.ToUpper(method)+" "+path] {
|
||||
t.Errorf("Swagger documents an unregistered operation: %s %s", method, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSwaggerDocumentsParsedRequestBodies(t *testing.T) {
|
||||
parsedBodies := map[string]bool{"HandleChapaWebhook": true, "SendSingleEmail": true, "SendBulkEmail": true}
|
||||
files, err := filepath.Glob(filepath.Join("handlers", "*.go"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range files {
|
||||
if strings.HasSuffix(name, "_test.go") {
|
||||
continue
|
||||
}
|
||||
file, err := parser.ParseFile(token.NewFileSet(), name, nil, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, declaration := range file.Decls {
|
||||
fn, ok := declaration.(*ast.FuncDecl)
|
||||
if !ok || fn.Recv == nil || fn.Body == nil {
|
||||
continue
|
||||
}
|
||||
ast.Inspect(fn.Body, func(node ast.Node) bool {
|
||||
if call, ok := node.(*ast.CallExpr); ok {
|
||||
if member, ok := call.Fun.(*ast.SelectorExpr); ok && member.Sel.Name == "BodyParser" {
|
||||
parsedBodies[fn.Name.Name] = true
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
var spec struct {
|
||||
Paths map[string]map[string]documentedOperation `json:"paths"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(docs.SwaggerInfo.ReadDoc()), &spec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, route := range registeredSwaggerContracts(t) {
|
||||
if !parsedBodies[route.Handler] {
|
||||
continue
|
||||
}
|
||||
operation := spec.Paths[route.Path][route.Method]
|
||||
found := false
|
||||
for _, parameter := range operation.Parameters {
|
||||
if parameter.In == "body" || parameter.In == "formData" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("%s %s parses a request body but documents no body or form fields", route.Method, route.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGeneratedSwaggerArtifactsStayInSync(t *testing.T) {
|
||||
var runtimeDoc map[string]any
|
||||
if err := json.Unmarshal([]byte(docs.SwaggerInfo.ReadDoc()), &runtimeDoc); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, name := range []string{"swagger.json", "swagger.yaml"} {
|
||||
raw, err := os.ReadFile(filepath.Join("..", "..", "docs", name))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.HasSuffix(name, ".yaml") {
|
||||
document, err := openapiswag.BytesToYAMLDoc(raw)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
raw, err = openapiswag.YAMLToJSON(document)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
var exported map[string]any
|
||||
if err := json.Unmarshal(raw, &exported); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Runtime host/scheme placeholders may be omitted in the static exports.
|
||||
for _, section := range []string{"swagger", "info", "paths", "definitions", "securityDefinitions"} {
|
||||
runtimeJSON, _ := json.Marshal(runtimeDoc[section])
|
||||
exportedJSON, _ := json.Marshal(exported[section])
|
||||
if string(runtimeJSON) != string(exportedJSON) {
|
||||
t.Errorf("%s section %s differs from docs.go; run make swagger", name, section)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertSwaggerReferences(t *testing.T, document map[string]any) {
|
||||
t.Helper()
|
||||
var visit func(any)
|
||||
visit = func(value any) {
|
||||
switch node := value.(type) {
|
||||
case map[string]any:
|
||||
if reference, ok := node["$ref"].(string); ok {
|
||||
if !strings.HasPrefix(reference, "#/") {
|
||||
t.Errorf("unexpected external schema reference: %s", reference)
|
||||
} else {
|
||||
var current any = document
|
||||
for _, segment := range strings.Split(strings.TrimPrefix(reference, "#/"), "/") {
|
||||
segment = strings.ReplaceAll(strings.ReplaceAll(segment, "~1", "/"), "~0", "~")
|
||||
object, ok := current.(map[string]any)
|
||||
if !ok {
|
||||
current = nil
|
||||
break
|
||||
}
|
||||
current = object[segment]
|
||||
}
|
||||
if current == nil {
|
||||
t.Errorf("unresolved schema reference: %s", reference)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, child := range node {
|
||||
visit(child)
|
||||
}
|
||||
case []any:
|
||||
for _, child := range node {
|
||||
visit(child)
|
||||
}
|
||||
}
|
||||
}
|
||||
visit(document)
|
||||
}
|
||||
|
||||
func TestSwaggerSchemaReferences(t *testing.T) {
|
||||
var document map[string]any
|
||||
if err := json.Unmarshal([]byte(docs.SwaggerInfo.ReadDoc()), &document); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertSwaggerReferences(t, document)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user