2025-10-27 15:24:08 +08:00

42 lines
1.5 KiB
Go

package system
import (
"context"
"time"
"management/internal/erpserver/model/dto"
"github.com/google/uuid"
)
type UserRepository interface {
Initialize(ctx context.Context, departId, roleId int32) error
Create(ctx context.Context, obj *User) (*User, error)
Update(ctx context.Context, obj *User) (*User, error)
Get(ctx context.Context, id int32) (*User, error)
GetByEmail(ctx context.Context, email string) (*User, error)
All(ctx context.Context) ([]*User, error)
Count(ctx context.Context, filter dto.SearchDto) (int64, error)
List(ctx context.Context, filter dto.SearchDto) ([]*User, error)
}
type User struct {
ID int32 `db:"id" json:"id"`
Uuid uuid.UUID `db:"uuid" json:"uuid"`
Email string `db:"email" json:"email"`
Username string `db:"username" json:"username"`
HashedPassword []byte `db:"hashed_password" json:"-"`
Salt string `db:"salt" json:"-"`
Avatar string `db:"avatar" json:"avatar"`
Gender int32 `db:"gender" json:"gender"`
DepartmentID int32 `db:"department_id" json:"department_id"`
RoleID int32 `db:"role_id" json:"role_id"`
Status int32 `db:"status" json:"status"`
ChangePasswordAt time.Time `db:"change_password_at" json:"-"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Role *Role `json:"role"`
Department *Department `json:"department"`
}