mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
3c07a186fc
* fix: pub sub in new eventstore * fix: todos * fix: todos * fix: todos * fix: todos * fix: todos
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package view
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/domain"
|
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
"github.com/caos/zitadel/internal/iam/repository/view/model"
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
"github.com/jinzhu/gorm"
|
|
)
|
|
|
|
func GetMailTemplateByAggregateID(db *gorm.DB, table, aggregateID string) (*model.MailTemplateView, error) {
|
|
template := new(model.MailTemplateView)
|
|
aggregateIDQuery := &model.MailTemplateSearchQuery{Key: iam_model.MailTemplateSearchKeyAggregateID, Value: aggregateID, Method: domain.SearchMethodEquals}
|
|
query := repository.PrepareGetByQuery(table, aggregateIDQuery)
|
|
err := query(db, template)
|
|
if caos_errs.IsNotFound(err) {
|
|
return nil, caos_errs.ThrowNotFound(nil, "VIEW-iPnmU", "Errors.IAM.MailTemplate.NotExisting")
|
|
}
|
|
return template, err
|
|
}
|
|
|
|
func PutMailTemplate(db *gorm.DB, table string, template *model.MailTemplateView) error {
|
|
save := repository.PrepareSave(table)
|
|
return save(db, template)
|
|
}
|
|
|
|
func DeleteMailTemplate(db *gorm.DB, table, aggregateID string) error {
|
|
delete := repository.PrepareDeleteByKey(table, model.MailTemplateSearchKey(iam_model.MailTemplateSearchKeyAggregateID), aggregateID)
|
|
|
|
return delete(db)
|
|
}
|