2020-05-11 10:16:29 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
|
|
"github.com/caos/zitadel/internal/project/repository/view"
|
|
|
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
2020-06-25 06:01:13 +00:00
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
2020-05-11 10:16:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
applicationTable = "management.applications"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) ApplicationByID(appID string) (*model.ApplicationView, error) {
|
|
|
|
return view.ApplicationByID(v.Db, applicationTable, appID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) SearchApplications(request *proj_model.ApplicationSearchRequest) ([]*model.ApplicationView, int, error) {
|
|
|
|
return view.SearchApplications(v.Db, applicationTable, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) PutApplication(project *model.ApplicationView) error {
|
|
|
|
err := view.PutApplication(v.Db, applicationTable, project)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedApplicationSequence(project.Sequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) DeleteApplication(appID string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteApplication(v.Db, applicationTable, appID)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return v.ProcessedApplicationSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) GetLatestApplicationSequence() (uint64, error) {
|
|
|
|
return v.latestSequence(applicationTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedApplicationSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(applicationTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestApplicationFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestFailedEvent(applicationTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedApplicationFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|