47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package entities
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type TAssignmentEntity struct {
|
|
ID uuid.UUID `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()" json:"id"`
|
|
DocumentType string `gorm:"type:varchar(100);" json:"document_type"`
|
|
|
|
DocumentID uuid.UUID `gorm:"type:uuid;index;" json:"document_id"`
|
|
ClientID uuid.UUID `gorm:"type:uuid;index;" json:"client_id"`
|
|
|
|
AssignmentUsers []TAssignmentUserEntity `gorm:"foreignKey:AssignmentID;references:ID"`
|
|
Client M_Client `gorm:"foreignKey:ClientID;references:ID"`
|
|
|
|
FullAuditTrail
|
|
}
|
|
|
|
func (TAssignmentEntity) TableName() string {
|
|
return "t_assignments"
|
|
}
|
|
|
|
// ...existing code...
|
|
|
|
// func GetDocumentByAssignment(db *gorm.DB, assignment TAssignmentEntity) (interface{}, error) {
|
|
// switch assignment.DocumentType {
|
|
// case "InventoryReceipt":
|
|
// var receipt TInventoryReceiptEntity
|
|
// if err := db.First(&receipt, "id = ?", assignment.DocumentID).Error; err != nil {
|
|
// return nil, err
|
|
// }
|
|
// return receipt, nil
|
|
// case "InventoryRequest":
|
|
// var request TInventoryRequestEntity
|
|
// if err := db.First(&request, "id = ?", assignment.DocumentID).Error; err != nil {
|
|
// return nil, err
|
|
// }
|
|
// return request, nil
|
|
// // Tambahkan case lain sesuai kebutuhan dokumen
|
|
// default:
|
|
// return nil, fmt.Errorf("unknown document type: %s", assignment.DocumentType)
|
|
// }
|
|
// }
|
|
|
|
// ...existing code...
|