|
|
package repository
|
|
|
|
|
|
import (
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
|
|
|
)
|
|
|
|
|
|
type AdminUserRepository struct {
|
|
|
transactionContext *transaction.TransactionContext
|
|
|
}
|
|
|
|
|
|
var (
|
|
|
_ domain.AdminUserRepository = (*AdminUserRepository)(nil)
|
|
|
)
|
|
|
|
|
|
func NewAdminUserRepository(transactionContext *transaction.TransactionContext) (*AdminUserRepository, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, ERR_EMPTY_TC
|
|
|
}
|
|
|
return &AdminUserRepository{transactionContext: transactionContext}, nil
|
|
|
}
|
|
|
func (reponsitory AdminUserRepository) transformPgModelToDomainModel(adminuserModel *models.AdminUser) (domain.AdminUser, error) {
|
|
|
result := domain.AdminUser{}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
func (reponsitory AdminUserRepository) FindOne(queryOption domain.AdminUserFindOneQuery) (*domain.AdminUser, error) {
|
|
|
db := reponsitory.transactionContext.PgDd
|
|
|
adminuserModel := new(models.AdminUser)
|
|
|
query := db.Model(adminuserModel)
|
|
|
|
|
|
if queryOption.AdminUserId > 0 {
|
|
|
query = query.Where("id=?", queryOption.AdminUserId)
|
|
|
}
|
|
|
if len(queryOption.AccountEqual) > 0 {
|
|
|
query = query.Where("admin_account=?", queryOption.AccountEqual)
|
|
|
}
|
|
|
err := query.First()
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
adminUser, err := reponsitory.transformPgModelToDomainModel(adminuserModel)
|
|
|
return &adminUser, err
|
|
|
} |
...
|
...
|
|