model

package
v0.0.0-...-2381096 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_OPEN  = 1
	STATE_CLOSE = 0
)

Variables

This section is empty.

Functions

func NewDBEngine

func NewDBEngine(databaseSetting *setting.DatabaseSettingS) (*gorm.DB, error)

Types

type AdminMenu

type AdminMenu struct {
	*Model
	Name       string `gorm:"column:name;NOT NULL" json:"name"`           // 菜单名称
	Icon       string `gorm:"column:icon" json:"icon"`                    // 图标
	Url        string `gorm:"column:url" json:"url"`                      // URL地址
	Pid        int    `gorm:"column:pid;default:0;NOT NULL" json:"pid"`   // 上级ID
	Type       int    `gorm:"column:type;default:0;NOT NULL" json:"type"` // 类型:1模块 2导航 3菜单 4节点
	IsShow     int    `gorm:"column:is_show;default:1" json:"is_show"`    // 是否显示:1显示 2不显示
	Sort       int    `gorm:"column:sort" json:"sort"`                    // 显示顺序
	Permission string `gorm:"column:permission" json:"permission"`        // 权限标识
	Remark     string `gorm:"column:remark" json:"remark"`                // 菜单备注
	Status     int    `gorm:"column:status;default:1" json:"status"`      // 状态1-在用 2-禁用
}

func (*AdminMenu) Create

func (m *AdminMenu) Create(ctx context.Context, db *gorm.DB) error

Create 插入数据

func (*AdminMenu) Delete

func (m *AdminMenu) Delete(ctx context.Context, db *gorm.DB, id int) error

Delete 删除

func (*AdminMenu) Get

func (m *AdminMenu) Get(ctx context.Context, db *gorm.DB) (*AdminMenu, error)

Get 根据条件查询单条数据

func (*AdminMenu) List

func (m *AdminMenu) List(ctx context.Context, db *gorm.DB, params *dto.GetAdminMenuListRequest) ([]*AdminMenu, int64, error)

func (*AdminMenu) TableName

func (m *AdminMenu) TableName() string

func (*AdminMenu) Update

func (m *AdminMenu) Update(ctx context.Context, db *gorm.DB) error

Update 更新

type AdminRole

type AdminRole struct {
	*Model
	Name   string `gorm:"column:name;NOT NULL" json:"name"`      // 角色名称
	Code   string `gorm:"column:code;NOT NULL" json:"code"`      // 角色编码
	Sort   int    `gorm:"column:sort;default:0" json:"sort"`     // 排序
	Status int    `gorm:"column:status;default:1" json:"status"` // 状态 1-启用2-禁用
}

func (*AdminRole) Create

func (m *AdminRole) Create(ctx context.Context, db *gorm.DB) error

Create 创建

func (*AdminRole) DeleteBatch

func (m *AdminRole) DeleteBatch(ctx context.Context, db *gorm.DB, ids []int64) error

DeleteBatch 批量删除

func (*AdminRole) Get

func (m *AdminRole) Get(ctx context.Context, db *gorm.DB, id int64) (*AdminRole, error)

Get 查询

func (*AdminRole) List

func (m *AdminRole) List(ctx context.Context, db *gorm.DB, params *dto.GetAdminRoleListRequest) ([]*AdminRole, int64, error)

List 列表

func (*AdminRole) TableName

func (role *AdminRole) TableName() string

func (*AdminRole) Update

func (m *AdminRole) Update(ctx context.Context, db *gorm.DB) error

Update 更新

type AdminRoleMenu

type AdminRoleMenu struct {
	*Model
	RoleId int `gorm:"column:role_id;default:0;NOT NULL" json:"role_id"` // 角色id
	MenuId int `gorm:"column:menu_id;default:0;NOT NULL" json:"menu_id"` // 菜单id
}

func (*AdminRoleMenu) BatchCreate

func (roleMenu *AdminRoleMenu) BatchCreate(ctx context.Context, db *gorm.DB, record []*AdminRoleMenu) (int64, error)

BatchCreate 批量创建

func (*AdminRoleMenu) Delete

func (roleMenu *AdminRoleMenu) Delete(ctx context.Context, db *gorm.DB) error

Delete 删除

func (*AdminRoleMenu) List

func (roleMenu *AdminRoleMenu) List(ctx context.Context, db *gorm.DB) ([]*AdminRoleMenu, error)

List 列表

func (*AdminRoleMenu) TableName

func (roleMenu *AdminRoleMenu) TableName() string

type AdminUser

type AdminUser struct {
	*Model
	Realname  string `gorm:"column:realname;NOT NULL" json:"realname"`               // 真实姓名
	Username  string `gorm:"column:username;NOT NULL" json:"username"`               // 登录用户名
	Gender    int    `gorm:"column:gender;default:0;NOT NULL" json:"gender"`         // 性别:1男 2女 3保密
	Avatar    string `gorm:"column:avatar;NOT NULL" json:"avatar"`                   // 头像
	Mobile    string `gorm:"column:mobile;NOT NULL" json:"mobile"`                   // 手机号
	Email     string `gorm:"column:email;NOT NULL" json:"email"`                     // 邮箱地址
	Address   string `gorm:"column:address;NOT NULL" json:"address"`                 // 地址
	Password  string `gorm:"column:password;NOT NULL" json:"password"`               // 登录密码
	Salt      string `gorm:"column:salt;NOT NULL" json:"salt"`                       // 盐加密
	Intro     string `gorm:"column:intro" json:"intro"`                              // 备注
	Status    int    `gorm:"column:status;default:1;NOT NULL" json:"status"`         // 状态:1正常 2禁用
	LoginNum  int    `gorm:"column:login_num;default:0;NOT NULL" json:"login_num"`   // 登录次数
	LoginIp   string `gorm:"column:login_ip;NOT NULL" json:"login_ip"`               // 最近登录ip
	LoginTime int64  `gorm:"column:login_time;default:0;NOT NULL" json:"login_time"` // 最近登录时间
}

func (*AdminUser) Create

func (a *AdminUser) Create(ctx context.Context, db *gorm.DB) (*AdminUser, error)

Create 创建

func (*AdminUser) Delete

func (m *AdminUser) Delete(ctx context.Context, db *gorm.DB, id int) error

Delete 删除

func (*AdminUser) Get

func (a *AdminUser) Get(ctx context.Context, db *gorm.DB) (*AdminUser, error)

Get 获取一条记录

func (*AdminUser) List

func (a *AdminUser) List(ctx context.Context, db *gorm.DB, params *dto.GetAdminUserListRequest) ([]*AdminUser, int64, error)

List 列表

func (*AdminUser) TableName

func (a *AdminUser) TableName() string

func (*AdminUser) Update

func (a *AdminUser) Update(ctx context.Context, db *gorm.DB) error

Update 更新

type AdminUserRole

type AdminUserRole struct {
	*Model
	UserId int `gorm:"column:user_id;default:0;NOT NULL" json:"user_id"` // 用户id
	RoleId int `gorm:"column:role_id;default:0;NOT NULL" json:"role_id"` // 角色id
}

func (*AdminUserRole) BatchCreate

func (userRole *AdminUserRole) BatchCreate(ctx context.Context, db *gorm.DB, record []*AdminUserRole) (int64, error)

BatchCreate 批量创建

func (*AdminUserRole) Delete

func (userRole *AdminUserRole) Delete(ctx context.Context, db *gorm.DB) error

Delete 删除

func (*AdminUserRole) TableName

func (userRole *AdminUserRole) TableName() string
type Link struct {
	*Model
	Name   string `gorm:"column:name;NOT NULL" json:"name"`               // 友链名称
	Url    string `gorm:"column:url;NOT NULL" json:"url"`                 // 友链地址
	Image  string `gorm:"column:image" json:"image"`                      // logo
	Status int    `gorm:"column:status;default:1;NOT NULL" json:"status"` // 状态 1-启用 2-禁用
	Sort   int    `gorm:"column:sort;default:0;NOT NULL" json:"sort"`     // 排序
}

func (*Link) Create

func (l *Link) Create(ctx context.Context, db *gorm.DB) error

Create 插入数据

func (*Link) Delete

func (l *Link) Delete(ctx context.Context, db *gorm.DB, id int) error

Delete 删除

func (*Link) Get

func (l *Link) Get(ctx context.Context, db *gorm.DB) (*Link, error)

Get 根据条件查询单条数据

func (*Link) List

func (l *Link) List(ctx context.Context, db *gorm.DB, params *dto.GetLinkListRequest) ([]*Link, int64, error)

func (*Link) TableName

func (l *Link) TableName() string

func (*Link) Update

func (l *Link) Update(ctx context.Context, db *gorm.DB) error

Update 更新

type LoggerWriter

type LoggerWriter struct {
	// contains filtered or unexported fields
}

func (*LoggerWriter) New

func (lw *LoggerWriter) New(loggerLevel logger.LogLevel) LoggerWriter

func (LoggerWriter) Printf

func (lw LoggerWriter) Printf(msg string, v ...interface{})

type Model

type Model struct {
	ID          int    `gorm:"primary_key" json:"id"`
	CreatedTime MyTime `json:"created_time" gorm:"column:created_time"`
	UpdatedTime MyTime `json:"updated_time" gorm:"column:updated_time"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate(db *gorm.DB) error

func (*Model) BeforeUpdate

func (m *Model) BeforeUpdate(db *gorm.DB) error

type MyTime

type MyTime time.Time

MyTime 自定义时间

func (MyTime) MarshalJSON

func (t MyTime) MarshalJSON() ([]byte, error)

func (*MyTime) MyTime2Date

func (t *MyTime) MyTime2Date() string

func (*MyTime) Scan

func (t *MyTime) Scan(v interface{}) error

func (*MyTime) String

func (t *MyTime) String() string

func (*MyTime) UnmarshalJSON

func (t *MyTime) UnmarshalJSON(data []byte) error

func (MyTime) Value

func (t MyTime) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL