model

package
v0.0.0-...-9c0a3f4 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: MulanPSL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package model 模型层只定义数据库表对应的模型,不实现相关操作

数据库相关操作放到 service 层完成

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	ID string `gorm:"primaryKey;type:varchar(25)" json:"id"`
	// 在创建时,如果该字段值为零值,则使用当前时间填充
	CreatedAt time.Time `json:"created_at" `
	// 可为空
	UpdatedAt *time.Time `json:"updated_at"`
	// 软删除标识
	RemoveFlag bool `json:"remove_flag"`

	CreatedBy string `json:"created_by" gorm:"type:varchar(25)"`
	UpdatedBy string `json:"updated_by" gorm:"type:varchar(25)"`
}

Base 数据模型的公共字段

func (*Base) SetCreateInfo

func (b *Base) SetCreateInfo()

SetCreateInfo 创建时的审计信息

func (*Base) SetRemove

func (b *Base) SetRemove()

SetRemove 设置移除信息

func (*Base) SetUpdateInfo

func (b *Base) SetUpdateInfo()

SetUpdateInfo 更新时的审计信息

type CasbinRule

type CasbinRule struct {
	PType string `json:"p_type" gorm:"size:100;"`
	V0    string `json:"v0" gorm:"size:100;"`
	V1    string `json:"v1" gorm:"size:100;"`
	V2    string `json:"v2" gorm:"size:100;"`
	V3    string `json:"v3" gorm:"size:100;"`
	V4    string `json:"v4" gorm:"size:100;"`
	V5    string `json:"v5" gorm:"size:100;"`
}

CasbinRule casbin规则表 因为有适配器中间件,尽量不对这张表的数据进行操作 这里写出来以备额外需求

func (CasbinRule) TableName

func (CasbinRule) TableName() string

TableName 指定表名 casbin_rule

type DBMigrateError

type DBMigrateError error

DBMigrateError 数据库迁移错误 此错误仅用于 wire 工具

func DBMigrate

func DBMigrate(db *gorm.DB) DBMigrateError

DBMigrate 模型注册 自动进行数据库迁移

type Role

type Role struct {
	Base
	// RoleName 角色代号,全英文。用在系统内逻辑判断
	RoleName string `json:"role_name" gorm:"type:varchar(100)"`
	// DisplayName 显示名。给用户看的。
	DisplayName string `json:"display_name" gorm:"type:varchar(100)"`
	// Remark 备注
	Remark string `json:"remark" gorm:"type:varchar(200)"`
}

Role 角色

type User

type User struct {
	Base
	Username string `json:"username" gorm:"type:varchar(200)"`
	Password string `json:"password" gorm:"type:varchar(200)"`
}

User 用户模型

type UserRole

type UserRole struct {
	ID     string `gorm:"primaryKey;type:varchar(25)" json:"id"`
	UserID string `gorm:"type:varchar(25)" json:"user_id"`
	RoleID string `gorm:"type:varchar(25)" json:"role_id"`
}

UserRole 用户-角色关系表

Jump to

Keyboard shortcuts

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