mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-02 23:40:24 +08:00
65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package application
|
|
|
|
import (
|
|
"mayfly-go/internal/machine/domain/entity"
|
|
"mayfly-go/internal/machine/domain/repository"
|
|
"mayfly-go/pkg/biz"
|
|
"mayfly-go/pkg/model"
|
|
)
|
|
|
|
type AuthCert interface {
|
|
GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult
|
|
|
|
Save(ac *entity.AuthCert)
|
|
|
|
GetById(id uint64) *entity.AuthCert
|
|
|
|
GetByIds(ids ...uint64) []*entity.AuthCert
|
|
|
|
DeleteById(id uint64)
|
|
}
|
|
|
|
func newAuthCertApp(authCertRepo repository.AuthCert) AuthCert {
|
|
return &authCertAppImpl{
|
|
authCertRepo: authCertRepo,
|
|
}
|
|
}
|
|
|
|
type authCertAppImpl struct {
|
|
authCertRepo repository.AuthCert
|
|
}
|
|
|
|
func (a *authCertAppImpl) GetPageList(condition *entity.AuthCert, pageParam *model.PageParam, toEntity interface{}, orderBy ...string) *model.PageResult {
|
|
return a.authCertRepo.GetPageList(condition, pageParam, toEntity)
|
|
}
|
|
|
|
func (a *authCertAppImpl) Save(ac *entity.AuthCert) {
|
|
oldAc := &entity.AuthCert{Name: ac.Name}
|
|
err := a.authCertRepo.GetByCondition(oldAc, "Id", "Name")
|
|
|
|
ac.PwdEncrypt()
|
|
if ac.Id == 0 {
|
|
biz.IsTrue(err != nil, "该凭证名已存在")
|
|
a.authCertRepo.Insert(ac)
|
|
return
|
|
}
|
|
|
|
// 如果存在该库,则校验修改的库是否为该库
|
|
if err == nil {
|
|
biz.IsTrue(oldAc.Id == ac.Id, "该凭证名已存在")
|
|
}
|
|
a.authCertRepo.Update(ac)
|
|
}
|
|
|
|
func (a *authCertAppImpl) GetById(id uint64) *entity.AuthCert {
|
|
return a.authCertRepo.GetById(id)
|
|
}
|
|
|
|
func (a *authCertAppImpl) GetByIds(ids ...uint64) []*entity.AuthCert {
|
|
return a.authCertRepo.GetByIds(ids...)
|
|
}
|
|
|
|
func (a *authCertAppImpl) DeleteById(id uint64) {
|
|
a.authCertRepo.DeleteById(id)
|
|
}
|