feat (user): adjust for auth, hide pass
This commit is contained in:
No files matched your search
@@ -7,9 +7,9 @@ import (
|
||||
)
|
||||
|
||||
type Base struct {
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"type:timestamptz"`
|
||||
UpdatedAt string `json:"updatedAt" gorm:"type:timestamptz"`
|
||||
DeteledAt gorm.DeletedAt `json:"deletedAt,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt" gorm:"column:CreatedAt;type:timestamptz"`
|
||||
UpdatedAt time.Time `json:"updatedAt" gorm:"column:UpdatedAt;type:timestamptz"`
|
||||
DeletedAt gorm.DeletedAt `json:"deletedAt,omitempty" gorm:"column:DeletedAt"`
|
||||
}
|
||||
|
||||
type Main struct {
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package user
|
||||
|
||||
import erc "simrs-vx/internal/domain/references/common"
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CreateDto struct {
|
||||
Name string `json:"name"`
|
||||
@@ -22,12 +26,12 @@ type ReadDetailDto struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Updatedto struct {
|
||||
type UpdateDto struct {
|
||||
Id uint `json:"id"`
|
||||
CreateDto
|
||||
}
|
||||
|
||||
type Deletedto struct {
|
||||
type DeleteDto struct {
|
||||
Id uint `json:"id"`
|
||||
}
|
||||
|
||||
@@ -36,3 +40,38 @@ type MetaDto struct {
|
||||
PageSize int `json:"page_size"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type LoginDto struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Duration uint32 `json:"duration"` // in minutes
|
||||
}
|
||||
|
||||
type ResponseDto struct {
|
||||
ecore.Main
|
||||
Name string `json:"name"`
|
||||
Status_Code erc.StatusCode `json:"status_code"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount"`
|
||||
LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"`
|
||||
LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"`
|
||||
}
|
||||
|
||||
func (u User) ToResponse() ResponseDto {
|
||||
resp := ResponseDto{
|
||||
Name: u.Name,
|
||||
Status_Code: u.Status_Code,
|
||||
FailedLoginCount: u.FailedLoginCount,
|
||||
LastSuccessLogin: u.LastSuccessLogin,
|
||||
LastAllowdLogin: u.LastAllowdLogin,
|
||||
}
|
||||
resp.Main = u.Main
|
||||
return resp
|
||||
}
|
||||
|
||||
func ToResponseList(users []User) []ResponseDto {
|
||||
resp := make([]ResponseDto, len(users))
|
||||
for i, u := range users {
|
||||
resp[i] = u.ToResponse()
|
||||
}
|
||||
return resp
|
||||
}
|
||||
@@ -3,12 +3,16 @@ package user
|
||||
import (
|
||||
ecore "simrs-vx/internal/domain/base-entities/core"
|
||||
erc "simrs-vx/internal/domain/references/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ecore.Main // adjust this according to the needs
|
||||
Name string `json:"name" gorm:"not null;size:25"`
|
||||
Password string `json:"password" gorm:"not null;size:255"`
|
||||
Status_Code erc.StatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount" gorm:"type:smallint"`
|
||||
ecore.Main // adjust this according to the needs
|
||||
Name string `json:"name" gorm:"not null;size:25"`
|
||||
Password string `json:"password" gorm:"not null;size:255"`
|
||||
Status_Code erc.StatusCode `json:"status_code" gorm:"not null;size:10"`
|
||||
FailedLoginCount uint8 `json:"failedLoginCount" gorm:"type:smallint"`
|
||||
LoginAttemptCount int `json:"-"`
|
||||
LastSuccessLogin *time.Time `json:"lastSuccessLogin,omitempty"`
|
||||
LastAllowdLogin *time.Time `json:"lastAllowdLogin,omitempty"`
|
||||
}
|
||||
@@ -35,6 +35,8 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
SCActive StatusCode = "active"
|
||||
SCInactive StatusCode = "inactive"
|
||||
SCNew StatusCode = "new"
|
||||
SCActive StatusCode = "active"
|
||||
SCBlocked StatusCode = "blocked"
|
||||
SCSuspended StatusCode = "suspended"
|
||||
)
|
||||
Reference in New Issue
Block a user