feat: update ppid files

This commit is contained in:
hanif salafi 2024-07-02 10:24:55 +07:00
parent 63b76cd743
commit ba29705e17
5 changed files with 25 additions and 4 deletions

View File

@ -111,6 +111,7 @@ func (_i *ppidDataFilesController) Show(c *fiber.Ctx) error {
// @Tags PPID Files
// @Security Bearer
// @Produce json
// @Param titles formData string false "Titles"
// @Param types formData string false "Types"
// @Param positions formData string false "Positions"
// @Param urls formData string false "Upload Url"

View File

@ -92,6 +92,8 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
Format(time.RFC3339)).Str("Service", "Save").
Interface("form", form).Msg("")
titlesString := form.Value["titles"]
titles := strings.Split(titlesString[0], ",")
typesString := form.Value["types"]
types := strings.Split(typesString[0], ",")
positionsString := form.Value["positions"]
@ -118,7 +120,9 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
}
positionInt := int(positionInt64)
statusId := 1
title := titles[index]
req := request.PpidDataFilesCreateRequest{
Title: &title,
PpidDataId: int(id),
Type: &fileType,
Position: &positionInt,
@ -132,11 +136,11 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
if fileType == "url" {
url := urls[urlCounter]
filename := path.Base(url)
filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))])
//filenameWithoutExt := filepath.Clean(filename[:len(filename)-len(filepath.Ext(filename))])
extension := filepath.Ext(filename)[1:]
title := strings.ReplaceAll(filenameWithoutExt, "-", " ")
//title := strings.ReplaceAll(filenameWithoutExt, "-", " ")
req.Title = &title
//req.Title = &title
req.FileType = &extension
req.FileName = &filename
req.FileUrl = &url
@ -184,7 +188,7 @@ func (_i *ppidDataFilesService) Save(c *fiber.Ctx) (err error) {
fileUrl := "/ppid-data-files/viewer/"
fileUrl += host + port + newFilename
req.Title = &newFilenameWithoutExt
//req.Title = &newFilenameWithoutExt
req.FileType = &extension
req.FileName = &newFilename
req.FilePath = &objectName

View File

@ -4521,6 +4521,12 @@ const docTemplate = `{
],
"summary": "Create PpidDataFiles",
"parameters": [
{
"type": "string",
"description": "Titles",
"name": "titles",
"in": "formData"
},
{
"type": "string",
"description": "Types",

View File

@ -4510,6 +4510,12 @@
],
"summary": "Create PpidDataFiles",
"parameters": [
{
"type": "string",
"description": "Titles",
"name": "titles",
"in": "formData"
},
{
"type": "string",
"description": "Types",

View File

@ -3599,6 +3599,10 @@ paths:
post:
description: API for create PpidDataFiles
parameters:
- description: Titles
in: formData
name: titles
type: string
- description: Types
in: formData
name: types