WIP: Restructing auth api and service
Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
65
service/service_user/list_user_full_table.go
Normal file
65
service/service_user/list_user_full_table.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package service_user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"nixcn-cms/data"
|
||||
"nixcn-cms/internal/exception"
|
||||
"nixcn-cms/service/shared"
|
||||
)
|
||||
|
||||
type UserTablePayload struct {
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
type UserTableResult struct {
|
||||
Common shared.CommonResult
|
||||
Data *[]data.User `json:"user_table"`
|
||||
}
|
||||
|
||||
// ListUserFullTable
|
||||
func (self *UserServiceImpl) GetUserFullTable(payload *UserTablePayload) (result *UserTableResult) {
|
||||
var err error
|
||||
|
||||
userFullTable, err := new(data.User).
|
||||
GetFullTable(payload.Context)
|
||||
|
||||
if err != nil {
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceFull).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorDatabase).
|
||||
SetError(err).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &UserTableResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 500,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: nil,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
exception := new(exception.Builder).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceFull).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonSuccess).
|
||||
SetError(nil).
|
||||
Throw(payload.Context)
|
||||
|
||||
result = &UserTableResult{
|
||||
Common: shared.CommonResult{
|
||||
HttpCode: 200,
|
||||
Exception: exception,
|
||||
},
|
||||
Data: userFullTable,
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user