permission.go
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package service
import (
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/adminPermission/query"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/lib"
)
//AdminUserService 管理员相关服务
type AdminPermissionService struct {
}
func NewAdminPermissionService(option map[string]interface{}) *AdminPermissionService {
newAdminPermissionService := new(AdminPermissionService)
return newAdminPermissionService
}
func (adminPermissionSrv AdminPermissionService) ListAdminPermission(queryOption query.ListAdminPermissionQuery) ([]domain.AdminPermission, error) {
//实际业务
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var (
permissionRepository domain.AdminPermissionRepository
permissions []domain.AdminPermission
)
if value, err := factory.CreateAdminPermissionRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
} else {
permissionRepository = value
}
permissions, err = permissionRepository.Find(domain.AdminPermissionFindQuery{
NotCode: queryOption.NotCode,
ParentId: queryOption.ParentId,
})
if err != nil {
return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
}
return permissions, nil
}