first commit
This commit is contained in:
71
schemas/base_util.go
Normal file
71
schemas/base_util.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package schemas
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CustomTime struct {
|
||||
Time *time.Time
|
||||
}
|
||||
|
||||
// MarshalJSON 实现 JSON 序列化
|
||||
func (ct CustomTime) MarshalJSON() ([]byte, error) {
|
||||
if ct.Time == nil {
|
||||
return []byte(`""`), nil
|
||||
}
|
||||
return json.Marshal(ct.Time.Format("2006-01-02 15:04:05"))
|
||||
}
|
||||
|
||||
// UnmarshalJSON 实现 JSON 反序列化
|
||||
func (ct *CustomTime) UnmarshalJSON(data []byte) error {
|
||||
var timeStr string
|
||||
if err := json.Unmarshal(data, &timeStr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if timeStr == "" {
|
||||
ct.Time = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
parsedTime, err := time.Parse("2006-01-02 15:04:05", timeStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ct.Time = &parsedTime
|
||||
return nil
|
||||
}
|
||||
|
||||
// Scan 实现 sql.Scanner 接口,用于数据库扫描
|
||||
func (ct *CustomTime) Scan(value interface{}) error {
|
||||
if value == nil {
|
||||
ct.Time = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
switch v := value.(type) {
|
||||
case time.Time:
|
||||
ct.Time = &v
|
||||
case *time.Time:
|
||||
ct.Time = v
|
||||
default:
|
||||
ct.Time = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value 实现 driver.Valuer 接口,用于数据库存储
|
||||
func (ct CustomTime) Value() (driver.Value, error) {
|
||||
if ct.Time == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return *ct.Time, nil
|
||||
}
|
||||
|
||||
// NewCustomTime 创建新的 CustomTime 实例
|
||||
func NewCustomTime(t *time.Time) CustomTime {
|
||||
return CustomTime{Time: t}
|
||||
}
|
||||
78
schemas/cron_schemas.go
Normal file
78
schemas/cron_schemas.go
Normal file
@@ -0,0 +1,78 @@
|
||||
// Package schemas/cron_repository.go
|
||||
package schemas
|
||||
|
||||
type CronListRequest struct {
|
||||
PageIndex int `json:"page_index" form:"page_index" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
Name string `json:"name" form:"name"`
|
||||
StartDate CustomTime `json:"start_date" form:"start_date"`
|
||||
EndDate CustomTime `json:"end_date" form:"end_date"`
|
||||
}
|
||||
|
||||
type CronListResponse struct {
|
||||
Item []*CronJob `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
PageIndex int `json:"page_index"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
type CronJob struct {
|
||||
// 任务ID
|
||||
ID int `json:"id" db:"id"`
|
||||
// 任务名称
|
||||
Name string `json:"name" db:"name"`
|
||||
// 任务计划
|
||||
Schedule string `json:"schedule" db:"schedule"`
|
||||
// 任务处理程序
|
||||
Handler string `json:"handler" db:"handler"`
|
||||
// 任务是否启用
|
||||
Enabled int `json:"enabled" db:"enabled"`
|
||||
// 任务描述
|
||||
Description string `json:"description" db:"description"`
|
||||
// 创建时间
|
||||
CreatedAt CustomTime `json:"create_time" db:"create_time"`
|
||||
// 更新时间
|
||||
UpdatedAt CustomTime `json:"update_time" db:"update_time"`
|
||||
}
|
||||
|
||||
type CronJobLogListRequest struct {
|
||||
PageIndex int `json:"page_index" form:"page_index" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
Id int `json:"id" form:"id" binding:"required"`
|
||||
StartDate CustomTime `json:"start_date" form:"start_date"`
|
||||
EndDate CustomTime `json:"end_date" form:"end_date"`
|
||||
}
|
||||
|
||||
type CronJobLogListResponse struct {
|
||||
Item []*CronJobLog `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
PageIndex int `json:"page_index"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
type CronJobLog struct {
|
||||
ID int `json:"id" db:"id"`
|
||||
JobID int `json:"job_id" db:"job_id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Handler string `json:"handler" db:"handler"`
|
||||
Schedule string `json:"schedule" db:"schedule"`
|
||||
Message string `json:"message" db:"message"`
|
||||
Status string `json:"status" db:"status"`
|
||||
StartTime CustomTime `json:"start_time" db:"start_time"`
|
||||
EndTime CustomTime `json:"end_time" db:"end_time"`
|
||||
}
|
||||
|
||||
type CronJobUpdateRequest struct {
|
||||
// 任务ID 传参代表修改 不传参代表新增
|
||||
ID int `json:"id" db:"id"`
|
||||
// 任务名称
|
||||
Name string `json:"name" db:"name"`
|
||||
// 任务计划
|
||||
Schedule string `json:"schedule" db:"schedule"`
|
||||
// 任务处理程序
|
||||
Handler string `json:"handler" db:"handler"`
|
||||
// 任务是否启用
|
||||
//Enabled int `json:"enabled" db:"enabled"`
|
||||
// 任务描述
|
||||
Description string `json:"description" db:"description"`
|
||||
}
|
||||
66
schemas/pms_schemas.go
Normal file
66
schemas/pms_schemas.go
Normal file
@@ -0,0 +1,66 @@
|
||||
// Package schemas/note.go
|
||||
package schemas
|
||||
|
||||
// MenuItems 表示菜单项
|
||||
type MenuItems struct {
|
||||
// ID 菜单项ID
|
||||
ID int `json:"id" db:"id"`
|
||||
// 父级菜单项ID
|
||||
ParentID int `json:"parent_id" db:"parent_id"`
|
||||
// 菜单项标题
|
||||
Title string `json:"title" db:"title"`
|
||||
// 菜单项路径
|
||||
Path string `json:"path" db:"path"`
|
||||
// 组件名称
|
||||
Component string `json:"component" db:"component"`
|
||||
// 菜单项图标
|
||||
Icon string `json:"icon" db:"icon"`
|
||||
// 排序
|
||||
Sort int `json:"sort" db:"sort"`
|
||||
// 是否可见
|
||||
Visible int `json:"visible" db:"visible"`
|
||||
// 状态
|
||||
Status int `json:"status" db:"status"`
|
||||
// 创建时间
|
||||
CreateTime CustomTime `json:"create_time" db:"create_time"`
|
||||
}
|
||||
|
||||
// Routes 路由
|
||||
type Routes struct {
|
||||
ID int `json:"id" db:"id"`
|
||||
ParentID int `json:"parent_id" db:"parent_id"`
|
||||
Path string `json:"index" db:"path"`
|
||||
Icon string `json:"icon" db:"icon"`
|
||||
Title string `json:"title" db:"title"`
|
||||
Component string `json:"component" db:"component"`
|
||||
Sort int `json:"sort" db:"sort"`
|
||||
Visible int `json:"visible" db:"visible"`
|
||||
Status int `json:"status" db:"status"`
|
||||
Children []*Routes `json:"children,omitempty"`
|
||||
}
|
||||
|
||||
type MenuListRequest struct {
|
||||
PageIndex int `json:"page_index" form:"page_index" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
}
|
||||
|
||||
type MenuListResponse struct {
|
||||
Item []*MenuItems `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
PageIndex int `json:"page_index"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
type PermissionItems struct {
|
||||
ID int64 `json:"id" db:"id"`
|
||||
Name string `json:"name" db:"name"`
|
||||
Title string `json:"title" db:"title"`
|
||||
Path string `json:"path" db:"path"`
|
||||
Type string `json:"type" db:"type"`
|
||||
Module string `json:"module" db:"module"`
|
||||
Action string `json:"action" db:"action"`
|
||||
ParentID int64 `json:"parent_id" db:"parent_id"`
|
||||
Sort int `json:"sort" db:"sort"`
|
||||
Status int `json:"status" db:"status"`
|
||||
Children []*PermissionItems `json:"children"`
|
||||
}
|
||||
187
schemas/user_schemas.go
Normal file
187
schemas/user_schemas.go
Normal file
@@ -0,0 +1,187 @@
|
||||
// Package schemas user_schemas.go
|
||||
package schemas
|
||||
|
||||
// LoginRequest 登录请求参数
|
||||
type LoginRequest struct {
|
||||
// Username 用户名,用于登录验证
|
||||
Username string `json:"username" binding:"required"`
|
||||
|
||||
// Password 密码,用于登录验证
|
||||
Password string `json:"password" binding:"required"`
|
||||
}
|
||||
|
||||
// UserInfo 用户信息
|
||||
type UserInfo struct {
|
||||
// 用户ID
|
||||
ID int `json:"id" db:"id"`
|
||||
// 角色编码
|
||||
RoleCode int `json:"rolecode" db:"rolecode"`
|
||||
// 角色名称
|
||||
RoleName string `json:"rolename" db:"rolename"`
|
||||
// 用户编码
|
||||
SessionCode string `json:"sessioncode" db:"sessioncode"`
|
||||
// 用户名
|
||||
Username string `json:"username" db:"username"`
|
||||
// 密码
|
||||
Password string `json:"password" binding:"required" db:"password"`
|
||||
// 昵称
|
||||
Nickname string `json:"nickname" binding:"required" db:"nickname"`
|
||||
// 邮箱地址
|
||||
Email string `json:"email" binding:"required" db:"email"`
|
||||
// 头像URL
|
||||
Avatar string `json:"avatar" db:"avatar"`
|
||||
// 用户状态
|
||||
Status int `json:"status" db:"status"`
|
||||
// 注册时间
|
||||
RegisterTime CustomTime `json:"register_time" db:"register_time"`
|
||||
// 最后登录时间
|
||||
LastLoginTime CustomTime `json:"last_login_time" db:"last_login_time"`
|
||||
}
|
||||
|
||||
// CreateUser 创建用户请求参数
|
||||
type CreateUser struct {
|
||||
// ID 用户ID,数据库自动生成, 不传
|
||||
ID int `json:"id" db:"id"`
|
||||
|
||||
// RoleCode 角色编码, 不传, 默认0
|
||||
RoleCode int `json:"rolecode" db:"rolecode"`
|
||||
|
||||
// RoleName 角色名称, 不传
|
||||
RoleName string `json:"rolename" db:"rolename"`
|
||||
|
||||
// SessionCode 用户编码 系统生成
|
||||
SessionCode string `json:"sessioncode" db:"sessioncode"`
|
||||
|
||||
// Username 用户名,系统唯一标识,系统生成, 不传
|
||||
Username string `json:"username" db:"username"`
|
||||
|
||||
// Password 密码,将被加密存储
|
||||
Password string `json:"password" binding:"required" db:"password"`
|
||||
|
||||
// Nickname 用户昵称,显示名称
|
||||
Nickname string `json:"nickname" binding:"required" db:"nickname"`
|
||||
|
||||
// Email 邮箱地址,用于联系和找回密码
|
||||
Email string `json:"email" binding:"required" db:"email"`
|
||||
|
||||
// Avatar 头像URL
|
||||
Avatar string `json:"avatar" db:"avatar"`
|
||||
|
||||
// Status 用户状态,不传
|
||||
Status int `json:"status" db:"status"`
|
||||
|
||||
// RegisterTime 注册时间,系统生成
|
||||
RegisterTime CustomTime `json:"register_time" db:"register_time"`
|
||||
|
||||
// LastLoginTime 最后登录时间,系统生成
|
||||
LastLoginTime CustomTime `json:"last_login_time" db:"last_login_time"`
|
||||
}
|
||||
|
||||
// UserResponse 用户创建响应模型
|
||||
type UserResponse struct {
|
||||
Authorization string `json:"authorization"`
|
||||
}
|
||||
|
||||
// UpdateUser 用户选择性更新请求参数
|
||||
type UpdateUser struct {
|
||||
// ID 用户编码,用于定位用户
|
||||
ID int `json:"id" binding:"required"`
|
||||
|
||||
// Password 密码,将被加密存储
|
||||
Password string `json:"password"`
|
||||
|
||||
// Nickname 用户昵称,显示名称
|
||||
Nickname string `json:"nickname"`
|
||||
|
||||
// Email 邮箱地址,用于联系和找回密码
|
||||
Email string `json:"email"`
|
||||
|
||||
// Avatar 头像URL
|
||||
Avatar string `json:"avatar"`
|
||||
}
|
||||
|
||||
// UserStatus 用户状态常量
|
||||
const (
|
||||
UserStatusDisabled = 0 // 禁用
|
||||
UserStatusNormal = 1 // 正常
|
||||
)
|
||||
|
||||
type UserListRequest struct {
|
||||
PageIndex int `json:"page_index" form:"page_index" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
// 昵称(用户名)
|
||||
NickName string `json:"nickname" form:"nickname"`
|
||||
StartDate CustomTime `json:"start_time" form:"register_time"`
|
||||
EndDate CustomTime `json:"end_time" form:"register_time"`
|
||||
}
|
||||
|
||||
type UserListResponse struct {
|
||||
Item []*UserInfo `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
PageIndex int `json:"page_index"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
type RoleListRequest struct {
|
||||
PageIndex int `json:"page_index" form:"page_index" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
StartDate CustomTime `json:"start_date" form:"start_date"`
|
||||
EndDate CustomTime `json:"end_date" form:"end_date"`
|
||||
}
|
||||
|
||||
type RoleListResponse struct {
|
||||
Item []*RoleResponseList `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
PageIndex int `json:"page_index"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
type RoleResponseList struct {
|
||||
// ID 角色ID
|
||||
ID int `json:"id" db:"id"`
|
||||
// Name 角色名称
|
||||
Name string `json:"name" db:"name"`
|
||||
// Code 角色编码
|
||||
Code string `json:"code" db:"code"`
|
||||
// Desc 角色描述
|
||||
Desc string `json:"description" db:"description"`
|
||||
// Status 角色状态
|
||||
Status int `json:"status" db:"status"`
|
||||
// CreateTime 创建时间
|
||||
CreateTime CustomTime `json:"create_time" db:"create_time"`
|
||||
}
|
||||
|
||||
// LoginLog 登录日志结构体
|
||||
type LoginLog struct {
|
||||
ID int64 `json:"id" db:"id"`
|
||||
UserID int `json:"user_id" db:"user_id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
IPAddress string `json:"ip_address" db:"ip_address"`
|
||||
Location string `json:"location" db:"location"`
|
||||
UserAgent string `json:"user_agent" db:"user_agent"`
|
||||
LoginTime CustomTime `json:"login_time" db:"login_time"`
|
||||
Status int `json:"status" db:"status"`
|
||||
FailureReason string `json:"failure_reason" db:"failure_reason"`
|
||||
CreateTime CustomTime `json:"create_time" db:"create_time"`
|
||||
UpdateTime CustomTime `json:"update_time" db:"update_time"`
|
||||
IsDel int `json:"isdel" db:"isdel"`
|
||||
}
|
||||
|
||||
type LoginLogListRequest struct {
|
||||
PageIndex int `json:"page_index" form:"page_index" binding:"required"`
|
||||
PageSize int `json:"page_size" form:"page_size" binding:"required"`
|
||||
StartDate CustomTime `json:"start_date" form:"start_date"`
|
||||
EndDate CustomTime `json:"end_date" form:"end_date"`
|
||||
}
|
||||
|
||||
type LoginLogListResponse struct {
|
||||
Item []*LoginLog `json:"items"`
|
||||
Total int64 `json:"total"`
|
||||
PageIndex int `json:"page_index"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
type CreateRole struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
ID int `json:"id"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
Reference in New Issue
Block a user