197 lines
5.7 KiB
Go
197 lines
5.7 KiB
Go
package equipment
|
|
|
|
import (
|
|
"jannex/admin-dashboard-backend/modules/equipment"
|
|
"jannex/admin-dashboard-backend/modules/structs"
|
|
"jannex/admin-dashboard-backend/modules/utils"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func CreateEquipmentDocumentation(c *fiber.Ctx) error {
|
|
// swagger:operation POST /equipment/documentation/create equipment equipmentCreateEquipmentDocumentation
|
|
// ---
|
|
// summary: Create a new equipment documentation
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: X-Api-Key
|
|
// in: header
|
|
// description: You can create a new api key in your user profile
|
|
// - name: body
|
|
// in: body
|
|
// schema:
|
|
// "$ref": "#/definitions/ApiCreateEquipmentDocumentationRequest"
|
|
// responses:
|
|
// '200':
|
|
// description: New equipment documentation created successfully
|
|
// '400':
|
|
// description: Invalid request body
|
|
// '401':
|
|
// description: No permissions
|
|
// '500':
|
|
// description: Failed to create equipment documentation
|
|
|
|
var body structs.ApiCreateEquipmentDocumentationRequest
|
|
|
|
if err := utils.BodyParserHelper(c, &body); err != nil {
|
|
return c.SendStatus(fiber.StatusBadRequest)
|
|
}
|
|
|
|
return equipment.CreateEquipmentDocumentation(c, body)
|
|
}
|
|
|
|
func GetEquipmentDocumentations(c *fiber.Ctx) error {
|
|
// swagger:operation GET /equipment/documentations/{stockItemId} equipment equipmentGetEquipmentDocumentations
|
|
// ---
|
|
// summary: Get equipment documentations
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: X-Api-Key
|
|
// in: header
|
|
// description: You can create a new api key in your user profile
|
|
// - name: stockItemId
|
|
// in: path
|
|
// description: Stock item id
|
|
// required: true
|
|
// type: string
|
|
// responses:
|
|
// '200':
|
|
// description: Equipment documentations. Status 200 if equipment documentations found, status 404 if stock item not found on invex, status 401 if backend has no permissions to access invex
|
|
// schema:
|
|
// "$ref": "#/definitions/ApiEquipmentDocumentationResponse"
|
|
// '400':
|
|
// description: Invalid request body
|
|
// '401':
|
|
// description: No permissions
|
|
// '500':
|
|
// description: Failed to get equipment documentations
|
|
|
|
var params structs.ApiEquipmentRequest
|
|
|
|
if err := utils.ParamsParserHelper(c, ¶ms); err != nil {
|
|
return c.SendStatus(fiber.StatusBadRequest)
|
|
}
|
|
|
|
return equipment.GetEquipmentDocumentations(params.StockItemId, c)
|
|
}
|
|
|
|
func GetEquipmentDocumentation(c *fiber.Ctx) error {
|
|
// swagger:operation GET /equipment/documentation/{stockItemId}/{documentationId} equipment equipmentGetEquipmentDocumentation
|
|
// ---
|
|
// summary: Get equipment documentation
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: X-Api-Key
|
|
// in: header
|
|
// description: You can create a new api key in your user profile
|
|
// - name: stockItemId
|
|
// in: path
|
|
// description: Stock item id
|
|
// required: true
|
|
// type: string
|
|
// - name: documentationId
|
|
// in: path
|
|
// description: Documentation id
|
|
// required: true
|
|
// type: string
|
|
// responses:
|
|
// '200':
|
|
// description: Equipment documentation
|
|
// schema:
|
|
// "$ref": "#/definitions/EquipmentDocumentation"
|
|
// '400':
|
|
// description: Invalid request body
|
|
// '401':
|
|
// description: No permissions
|
|
// '500':
|
|
// description: Failed to get equipment documentation
|
|
|
|
var params structs.ApiGetDocumentationEquipmentRequest
|
|
|
|
if err := utils.ParamsParserHelper(c, ¶ms); err != nil {
|
|
return c.SendStatus(fiber.StatusBadRequest)
|
|
}
|
|
|
|
return equipment.GetEquipmentDocumentation(params.StockItemId, params.DocumentationId, c)
|
|
}
|
|
|
|
func EditEquipmentDocumentation(c *fiber.Ctx) error {
|
|
// swagger:operation POST /equipment/documentation/edit equipment equipmentEditEquipmentDocumentation
|
|
// ---
|
|
// summary: Edit equipment documentation
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: X-Api-Key
|
|
// in: header
|
|
// description: You can create a new api key in your user profile
|
|
// - name: body
|
|
// in: body
|
|
// schema:
|
|
// "$ref": "#/definitions/ApiEditEquipmentDocumentationRequest"
|
|
// responses:
|
|
// '200':
|
|
// description: Equipment documentation edited successfully
|
|
// '400':
|
|
// description: Invalid request body
|
|
// '401':
|
|
// description: No permissions
|
|
// '500':
|
|
// description: Failed to edit equipment documentation
|
|
|
|
var body structs.ApiEditEquipmentDocumentationRequest
|
|
|
|
if err := utils.BodyParserHelper(c, &body); err != nil {
|
|
return c.SendStatus(fiber.StatusBadRequest)
|
|
}
|
|
|
|
return equipment.EditEquipmentDocumentation(c, body)
|
|
}
|
|
|
|
func GetEquipmentThumbnail(c *fiber.Ctx) error {
|
|
// swagger:operation GET /equipment/thumbnail/{stockItemId} equipment equipmentGetEquipmentThumbnail
|
|
// ---
|
|
// summary: Get equipment thumbnail
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - application/json
|
|
// parameters:
|
|
// - name: X-Api-Key
|
|
// in: header
|
|
// description: You can create a new api key in your user profile
|
|
// - name: stockItemId
|
|
// in: path
|
|
// description: Stock item id
|
|
// required: true
|
|
// type: string
|
|
// responses:
|
|
// '200':
|
|
// description: Equipment thumbnail picture. Backend server is just proxying the request to invex server and returning the response
|
|
// '400':
|
|
// description: Invalid request body
|
|
// '401':
|
|
// description: No permissions
|
|
// '500':
|
|
// description: Failed to get equipment thumbnail
|
|
|
|
var params structs.ApiEquipmentRequest
|
|
|
|
if err := utils.ParamsParserHelper(c, ¶ms); err != nil {
|
|
return c.SendStatus(fiber.StatusBadRequest)
|
|
}
|
|
|
|
return equipment.GetEquipmentInvexThumbnail(c, params.StockItemId)
|
|
}
|