* TP-50862| created api to get slack conversation pre signed url * TP-50862| added unit tests * TP-50862| fixed authentication bug
34 lines
825 B
Go
34 lines
825 B
Go
package rcaInput
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"houston/model/rcaInput"
|
|
)
|
|
|
|
type Repository struct {
|
|
gormClient *gorm.DB
|
|
}
|
|
|
|
func NewRcaInputRepository(gormClient *gorm.DB) *Repository {
|
|
return &Repository{
|
|
gormClient: gormClient,
|
|
}
|
|
}
|
|
|
|
func (r *Repository) CreateRcaInput(rcaInputEntity *rcaInput.RcaInputEntity) error {
|
|
result := r.gormClient.Create(rcaInputEntity)
|
|
if result.Error != nil {
|
|
return result.Error
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (r *Repository) GetLatestRcaInputByIncidentIdAndDocumentType(incidentId uint, documentType string) (*rcaInput.RcaInputEntity, error) {
|
|
rcaInputEntity := rcaInput.RcaInputEntity{}
|
|
result := r.gormClient.Where("incident_id = ? AND document_type = ?", incidentId, documentType).Last(&rcaInputEntity)
|
|
if result.Error != nil {
|
|
return nil, result.Error
|
|
}
|
|
return &rcaInputEntity, nil
|
|
}
|