66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
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
|
|
}
|