diff --git a/cmd/main-migration/migrations/atlas.sum b/cmd/main-migration/migrations/atlas.sum index c29695a0..ceca9be1 100644 --- a/cmd/main-migration/migrations/atlas.sum +++ b/cmd/main-migration/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:l9TShSJKxWO7Ag2+PYB7DcVDd3pz/M2Sm0hpZYpUNBA= +h1:/ysf2SIdpKcuSzvAPNWONxzu08MCf8eE5krteU4Chas= 20250904105930.sql h1:MEM6blCgke9DzWQSTnLzasbPIrcHssNNrJqZpSkEo6k= 20250904141448.sql h1:J8cmYNk4ZrG9fhfbi2Z1IWz7YkfvhFqTzrLFo58BPY0= 20250908062237.sql h1:Pu23yEW/aKkwozHoOuROvHS/GK4ngARJGdO7FB7HZuI= @@ -108,4 +108,4 @@ h1:l9TShSJKxWO7Ag2+PYB7DcVDd3pz/M2Sm0hpZYpUNBA= 20251110093522.sql h1:nsz8jCxGjEdr/bz9g+4ozfZzIP803xONjVmucad1GMc= 20251110100258.sql h1:IBqt1VZj5WjQ+l9aAFGHOCCBtzb03KlLLihFLut7itg= 20251110100545.sql h1:6/LV7751iyKxE2xI6vO1zly+aHUwxXD/IBwLcVpKxqM= -20251111040358.sql h1:dbHqvkf0FWQVGpmTQAY0bdx6v2cXAxrPSH5byP0r/eU= +20251111040358.sql h1:c/RQSoA8yZl7cAcOv7n1RchmudPj7LdL3PEBdNvCUrA= diff --git a/internal/domain/main-entities/file-attachment/dto.go b/internal/domain/main-entities/file-attachment/dto.go index aeb01291..38941ec1 100644 --- a/internal/domain/main-entities/file-attachment/dto.go +++ b/internal/domain/main-entities/file-attachment/dto.go @@ -3,7 +3,6 @@ package file_attachment import ( "mime/multipart" eru "simrs-vx/internal/domain/references/upload" - // internal - domain - base-entities ecore "simrs-vx/internal/domain/base-entities/core" @@ -69,7 +68,7 @@ type ResponseDto struct { Name string `json:"name"` FilePath *string `json:"filePath"` FileName *string `json:"fileName"` - Upload_Employee_Id *string `json:"upload_employee_id"` + Upload_Employee_Id *uint `json:"upload_employee_id"` Upload_Employee *ee.Employee `json:"upload_employee,omitempty"` } diff --git a/internal/domain/main-entities/file-attachment/entity.go b/internal/domain/main-entities/file-attachment/entity.go index 8f224ce0..61b63e9e 100644 --- a/internal/domain/main-entities/file-attachment/entity.go +++ b/internal/domain/main-entities/file-attachment/entity.go @@ -14,6 +14,6 @@ type FileAttachment struct { Name string `json:"name"` FilePath *string `json:"filePath"` FileName *string `json:"fileName"` - Upload_Employee_Id *string `json:"upload_employee_id"` + Upload_Employee_Id *uint `json:"upload_employee_id"` Upload_Employee *ee.Employee `json:"upload_employee,omitempty" gorm:"foreignKey:Upload_Employee_Id;references:Id"` } diff --git a/internal/interface/main-handler/file-attachment/handler.go b/internal/interface/main-handler/file-attachment/handler.go index e391566a..4d64ec8d 100644 --- a/internal/interface/main-handler/file-attachment/handler.go +++ b/internal/interface/main-handler/file-attachment/handler.go @@ -41,14 +41,22 @@ func (obj myBase) Create(w http.ResponseWriter, r *http.Request) { refID = &id } } - employeeIdStr := r.FormValue("employee_id") + + employeeIdStr := r.FormValue("upload_employee_id") + var employeeId *uint + if employeeIdStr != "" { + if id64, err := strconv.ParseUint(employeeIdStr, 10, 32); err == nil { + id := uint(id64) + employeeId = &id + } + } dto := e.CreateDto{ EntityType_Code: eru.EntityTypeCode(r.FormValue("entityType_code")), Ref_Id: refID, Type_Code: eru.UploadCode(r.FormValue("type_code")), Name: r.FormValue("name"), - Upload_Employee_Id: &employeeIdStr, + Upload_Employee_Id: employeeId, File: file, FileHeader: header, Filename: header.Filename, @@ -114,14 +122,22 @@ func (obj myBase) Update(w http.ResponseWriter, r *http.Request) { refID = &id } } - employeeIdStr := r.FormValue("employee_id") + + employeeIdStr := r.FormValue("upload_employee_id") + var employeeId *uint + if employeeIdStr != "" { + if id64, err := strconv.ParseUint(employeeIdStr, 10, 32); err == nil { + id := uint(id64) + employeeId = &id + } + } dto := e.CreateDto{ EntityType_Code: eru.EntityTypeCode(r.FormValue("entityType_code")), Ref_Id: refID, Type_Code: eru.UploadCode(r.FormValue("type_code")), Name: r.FormValue("name"), - Upload_Employee_Id: &employeeIdStr, + Upload_Employee_Id: employeeId, File: file, FileHeader: header, Filename: header.Filename, diff --git a/internal/use-case/main-use-case/file-attachement/helper.go b/internal/use-case/main-use-case/file-attachement/helper.go index 8cb79b99..755f6896 100644 --- a/internal/use-case/main-use-case/file-attachement/helper.go +++ b/internal/use-case/main-use-case/file-attachement/helper.go @@ -49,7 +49,7 @@ func uploadAndGenerateFileUrl(input e.CreateDto, event *pl.Event) (string, error if !puh.IsValidFileType(ext, bucket) { return "", fmt.Errorf("invalid file type: %s", input.Filename) } - objectName := fmt.Sprintf("%s%s%s%d%s", input.EntityType_Code, input.Ref_Id, input.Type_Code, time.Now().UnixNano(), ext) + objectName := fmt.Sprintf("%s%d%s", input.Type_Code, time.Now().UnixNano(), ext) uploadInput := pmh.UploadReaderInput{ BucketName: bucket,