feat: update user levels
This commit is contained in:
parent
c0c35c6dd9
commit
02b11e3a46
|
|
@ -15,6 +15,8 @@ type FeedbacksQueryRequest struct {
|
|||
Message *string `json:"message"`
|
||||
CommentFromName *string `json:"commentFromName"`
|
||||
CommentFromEmail *string `json:"commentFromEmail"`
|
||||
StartDate *string `json:"startDate"`
|
||||
EndDate *string `json:"endDate"`
|
||||
StatusId *int `json:"statusId"`
|
||||
Pagination *paginator.Pagination `json:"pagination"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"go-humas-be/app/module/user_levels/service"
|
||||
"go-humas-be/utils/paginator"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
utilRes "go-humas-be/utils/response"
|
||||
utilVal "go-humas-be/utils/validator"
|
||||
|
|
@ -220,27 +221,29 @@ func (_i *userLevelsController) Delete(c *fiber.Ctx) error {
|
|||
// @Tags UserLevels
|
||||
// @Security Bearer
|
||||
// @Param Authorization header string false "Insert your access token" default(Bearer <Add access token here>)
|
||||
// @Param id query int false "user level id"
|
||||
// @Param isApprovalActive query string false "approval status"
|
||||
// @Param payload body request.UserLevelsApprovalRequest true "Required payload"
|
||||
// @Success 200 {object} response.Response
|
||||
// @Failure 400 {object} response.BadRequestError
|
||||
// @Failure 401 {object} response.UnauthorizedError
|
||||
// @Failure 500 {object} response.InternalServerError
|
||||
// @Router /articles/enable-approval [post]
|
||||
// @Router /user-levels/enable-approval [post]
|
||||
func (_i *userLevelsController) EnableApproval(c *fiber.Ctx) error {
|
||||
id, err := strconv.ParseUint(c.Query("id"), 10, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
isApprovalActive, err := strconv.ParseBool(c.Query("isPublish"))
|
||||
if err != nil {
|
||||
req := new(request.UserLevelsApprovalRequest)
|
||||
if err := utilVal.ParseAndValidate(c, req); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = _i.userLevelsService.EnableApproval(uint(id), isApprovalActive)
|
||||
ids := strings.Split(req.Ids, ",")
|
||||
for _, id := range ids {
|
||||
idUint, err := strconv.ParseUint(id, 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = _i.userLevelsService.EnableApproval(uint(idUint), req.IsApprovalActive)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return utilRes.Resp(c, utilRes.Response{
|
||||
Success: true,
|
||||
|
|
|
|||
|
|
@ -66,6 +66,11 @@ func (req UserLevelsUpdateRequest) ToEntity() *entity.UserLevels {
|
|||
}
|
||||
}
|
||||
|
||||
type UserLevelsApprovalRequest struct {
|
||||
Ids string `json:"ids" validate:"required"`
|
||||
IsApprovalActive bool `json:"isApprovalActive" validate:"required"`
|
||||
}
|
||||
|
||||
type UserLevelsQueryRequestContext struct {
|
||||
Name string `json:"name"`
|
||||
LevelNumber string `json:"levelNumber"`
|
||||
|
|
|
|||
|
|
@ -507,6 +507,14 @@ const docTemplate = `{
|
|||
],
|
||||
"summary": "Update Publish Advertisement",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Advertisement ID",
|
||||
|
|
@ -3319,67 +3327,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/articles/enable-approval": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for Enable Approval of Article",
|
||||
"tags": [
|
||||
"UserLevels"
|
||||
],
|
||||
"summary": "EnableApproval Articles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "user level id",
|
||||
"name": "id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "approval status",
|
||||
"name": "isApprovalActive",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/articles/publish-scheduling": {
|
||||
"post": {
|
||||
"security": [
|
||||
|
|
@ -4773,11 +4720,21 @@ const docTemplate = `{
|
|||
"name": "commentFromName",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "endDate",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "message",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "startDate",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "statusId",
|
||||
|
|
@ -7163,6 +7120,64 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/user-levels/enable-approval": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for Enable Approval of Article",
|
||||
"tags": [
|
||||
"UserLevels"
|
||||
],
|
||||
"summary": "EnableApproval Articles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.UserLevelsApprovalRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user-levels/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -9927,6 +9942,21 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.UserLevelsApprovalRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ids",
|
||||
"isApprovalActive"
|
||||
],
|
||||
"properties": {
|
||||
"ids": {
|
||||
"type": "string"
|
||||
},
|
||||
"isApprovalActive": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.UserLevelsCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -496,6 +496,14 @@
|
|||
],
|
||||
"summary": "Update Publish Advertisement",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Advertisement ID",
|
||||
|
|
@ -3308,67 +3316,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/articles/enable-approval": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for Enable Approval of Article",
|
||||
"tags": [
|
||||
"UserLevels"
|
||||
],
|
||||
"summary": "EnableApproval Articles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "user level id",
|
||||
"name": "id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "approval status",
|
||||
"name": "isApprovalActive",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/articles/publish-scheduling": {
|
||||
"post": {
|
||||
"security": [
|
||||
|
|
@ -4762,11 +4709,21 @@
|
|||
"name": "commentFromName",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "endDate",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "message",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "startDate",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "statusId",
|
||||
|
|
@ -7152,6 +7109,64 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/user-levels/enable-approval": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"Bearer": []
|
||||
}
|
||||
],
|
||||
"description": "API for Enable Approval of Article",
|
||||
"tags": [
|
||||
"UserLevels"
|
||||
],
|
||||
"summary": "EnableApproval Articles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"default": "Bearer \u003cAdd access token here\u003e",
|
||||
"description": "Insert your access token",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"description": "Required payload",
|
||||
"name": "payload",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.UserLevelsApprovalRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.BadRequestError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Unauthorized",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.UnauthorizedError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/response.InternalServerError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user-levels/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -9916,6 +9931,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"request.UserLevelsApprovalRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"ids",
|
||||
"isApprovalActive"
|
||||
],
|
||||
"properties": {
|
||||
"ids": {
|
||||
"type": "string"
|
||||
},
|
||||
"isApprovalActive": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.UserLevelsCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -589,6 +589,16 @@ definitions:
|
|||
username:
|
||||
type: string
|
||||
type: object
|
||||
request.UserLevelsApprovalRequest:
|
||||
properties:
|
||||
ids:
|
||||
type: string
|
||||
isApprovalActive:
|
||||
type: boolean
|
||||
required:
|
||||
- ids
|
||||
- isApprovalActive
|
||||
type: object
|
||||
request.UserLevelsCreateRequest:
|
||||
properties:
|
||||
aliasName:
|
||||
|
|
@ -1321,6 +1331,12 @@ paths:
|
|||
put:
|
||||
description: API for Update Publish Advertisement
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
required: true
|
||||
type: string
|
||||
- description: Advertisement ID
|
||||
in: path
|
||||
name: id
|
||||
|
|
@ -3100,45 +3116,6 @@ paths:
|
|||
summary: Update Banner Articles
|
||||
tags:
|
||||
- Articles
|
||||
/articles/enable-approval:
|
||||
post:
|
||||
description: API for Enable Approval of Article
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
type: string
|
||||
- description: user level id
|
||||
in: query
|
||||
name: id
|
||||
type: integer
|
||||
- description: approval status
|
||||
in: query
|
||||
name: isApprovalActive
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.BadRequestError'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.UnauthorizedError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.InternalServerError'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: EnableApproval Articles
|
||||
tags:
|
||||
- UserLevels
|
||||
/articles/publish-scheduling:
|
||||
post:
|
||||
description: API for Publish Schedule of Article
|
||||
|
|
@ -3924,9 +3901,15 @@ paths:
|
|||
- in: query
|
||||
name: commentFromName
|
||||
type: string
|
||||
- in: query
|
||||
name: endDate
|
||||
type: string
|
||||
- in: query
|
||||
name: message
|
||||
type: string
|
||||
- in: query
|
||||
name: startDate
|
||||
type: string
|
||||
- in: query
|
||||
name: statusId
|
||||
type: integer
|
||||
|
|
@ -5539,6 +5522,43 @@ paths:
|
|||
summary: Get one UserLevels
|
||||
tags:
|
||||
- UserLevels
|
||||
/user-levels/enable-approval:
|
||||
post:
|
||||
description: API for Enable Approval of Article
|
||||
parameters:
|
||||
- default: Bearer <Add access token here>
|
||||
description: Insert your access token
|
||||
in: header
|
||||
name: Authorization
|
||||
type: string
|
||||
- description: Required payload
|
||||
in: body
|
||||
name: payload
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.UserLevelsApprovalRequest'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/response.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/response.BadRequestError'
|
||||
"401":
|
||||
description: Unauthorized
|
||||
schema:
|
||||
$ref: '#/definitions/response.UnauthorizedError'
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/response.InternalServerError'
|
||||
security:
|
||||
- Bearer: []
|
||||
summary: EnableApproval Articles
|
||||
tags:
|
||||
- UserLevels
|
||||
/user-role-accesses:
|
||||
get:
|
||||
description: API for getting all UserRoleAccesses
|
||||
|
|
|
|||
Loading…
Reference in New Issue