MSP-1068 refactor structure: make domain directory

This commit is contained in:
novikovmu committed 2022-10-06 17:14:09 +03:00
1 parent 06818e5616
commit 7feb2d6507
8 files changed
+99 -52

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
package domain
const AdminAuthHeaderName = "x-auth-admin"
type Auth struct {
Token string
Expired string `json:",omitempty"`
HeaderName string
}
type AuthRequest struct {
Email string `valid:"required"`
Password string ` valid:"required"`
}
type SudirAuthRequest struct {
AuthCode string `valid:"required"`
}
+14
View File
@@ -0,0 +1,14 @@
package domain
import (
"github.com/pkg/errors"
)
var (
ErrNotFound = errors.New("not found")
ErrUnauthenticated = errors.New("authentication failure")
ErrSudirAuthorization = errors.New("User is authorized only with SUDIR")
ErrSudirAuthIsMissed = errors.New("SUDIR authorization is not configured on the server")
ErrInvalid = errors.New("entity is invalid")
ErrAlreadyExists = errors.New("already exists")
)
+7
View File
@@ -0,0 +1,7 @@
package domain
type GrpcError struct {
ErrorMessage string `json:"errorMessage"`
ErrorCode string `json:"errorCode"`
Details []interface{} `json:"details"`
}
+60
View File
@@ -0,0 +1,60 @@
package domain
import (
"time"
)
type User struct {
SudirUserId *string `json:",omitempty"`
Id int64
RoleId int
FirstName string
LastName string
Email string
Password string `json:",omitempty"`
UpdatedAt time.Time
CreatedAt time.Time
}
type UsersResponse struct {
Items []User
}
type UsersRequest struct {
Ids []int64
Offset int
Limit int
Email string
}
type AdminUserShort struct {
FirstName string
LastName string
Email string `valid:"required"`
Role string
}
type CreateUserRequest struct {
RoleId int
FirstName string
LastName string
Email string `valid:"required"`
Password string `valid:"required"`
}
type UpdateUserRequest struct {
Id int64 `valid:"required"`
RoleId int
FirstName string
LastName string
Email string
Password string
}
type DeleteResponse struct {
Deleted int
}
type IdentitiesRequest struct {
Ids []int64 `valid:"required"`
}
-16
View File
@@ -1,16 +0,0 @@
package structure
type Auth struct {
Token string `json:"token"`
Expired string `json:"expired,omitempty"`
HeaderName string `json:"headerName"`
}
type AuthRequest struct {
Email string `json:"email" valid:"required~Required"`
Password string `json:"password" valid:"required~Required"`
}
type SudirAuthRequest struct {
AuthCode string `json:"authCode" valid:"required~Required"`
}
-5
View File
@@ -1,5 +0,0 @@
package structure
type IdentitiesRequest struct {
Ids []int64 `json:"ids"`
}
-5
View File
@@ -1,5 +0,0 @@
package structure
type DeleteResponse struct {
Deleted int
}
-26
View File
@@ -1,26 +0,0 @@
package structure
import (
"msp-admin-service/entity"
)
type UsersResponse struct {
Items *[]entity.AdminUser `json:"items,omitempty"`
}
type UsersRequest struct {
Ids []int64 `json:"ids"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Email string `json:"email"`
Phone string `json:"phone"`
}
type AdminUserShort struct {
Image string `json:"image"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Email string `json:"email" valid:"required~Required"`
Phone string `json:"phone"`
Role string `json:"role"`
}