model

package
v0.0.0-...-521817c Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

DB ...

View Source
var Enforcer *casbin.Enforcer

Enforcer ...

View Source
var RedisClient *redis.Client

RedisClient ...

View Source
var RedisContext = context.Background()

RedisContext ...

Functions

This section is empty.

Types

type Building

type Building struct {
	Model
	Building  string     `json:"building" gorm:"unique"`
	Locations []Location `json:"locations" gorm:"foreignkey:BuildingID"`
}

Building ...

type Department

type Department struct {
	Model
	Department    string `json:"department"`
	OU            string `json:"ou" gorm:"unique"`
	InstitutionID uint   `json:"-"`
}

Department ...

type DepartmentEmployee

type DepartmentEmployee struct {
	Model
	EmployeeUserID uint       `json:"-"`
	DepartmentID   uint       `json:"-"`
	Department     Department `json:"department"`
	Employee       User       `json:"employee" gorm:"foreignkey:EmployeeUserID"`
}

DepartmentEmployee ...

type Employee

type Employee struct {
	UserID      uint         `json:"user_id" gorm:"primary_key;auto_increment:false"`
	Name        string       `json:"name"`
	Account     string       `json:"account" gorm:"unique"`
	Title       string       `json:"title"`
	Departments []Department `json:"departments" gorm:"many2many:department_employees"`
}

Employee ...

func (*Employee) Mask

func (employee *Employee) Mask(target MaskTarget)

Mask ...

type Follower

type Follower struct {
	VisitID uint   `json:"visit_id" gorm:"primary_key;auto_increment:false"`
	Name    string `json:"name" gorm:"primary_key"`
}

Follower ...

type Guest

type Guest struct {
	UserID             uint                 `json:"user_id" gorm:"primary_key;auto_increment:false"`
	Name               string               `json:"name"`
	Phone              string               `json:"phone"`
	PhoneVerify        bool                 `json:"phone_verify" gorm:"default:false"`
	PhoneToken         string               `json:"phone_token"`
	PhoneOTP           string               `json:"phone_otp" gorm:"-"`
	IDCard             string               `json:"id_card"`
	IDCardVerify       bool                 `json:"id_card_verify" gorm:"default:false"`
	VisitedDepartments []DepartmentEmployee `json:"visited_departments" gorm:"many2many:visits"`
}

Guest ...

func (*Guest) Mask

func (guest *Guest) Mask(target MaskTarget)

Mask ...

func (*Guest) User

func (guest *Guest) User() User

User ...

type Institution

type Institution struct {
	Model
	Institution string       `json:"institution"`
	OU          string       `json:"ou" gorm:"unique"`
	Departments []Department `json:"departments" gorm:"foreignkey:InstitutionID"`
}

Institution ...

type Location

type Location struct {
	Model
	Location   string   `json:"location"`
	BuildingID uint     `json:"-"`
	Building   Building `json:"building" gorm:"foreignkey:BuildingID"`
}

Location ...

type MaskTarget

type MaskTarget int

MaskTarget ...

const (
	// RegisterMask ...
	RegisterMask MaskTarget = iota

	// VisitMask ...
	VisitMask
)

type Model

type Model struct {
	ID        uint       `json:"id" gorm:"primary_key"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at" sql:"index"`
}

Model override gorm.Model

type Result

type Result struct {
	Status ResultStatus `json:"status"`
	Info   []string     `json:"info"`
	Data   interface{}  `json:"data"`
	Time   time.Time    `json:"time"`
	Logger *log.Entry   `json:"-"`
}

Result ...

func New

func New(status ResultStatus) *Result

New ...

func NewFailureResult

func NewFailureResult() *Result

NewFailureResult ...

func NewSuccessResult

func NewSuccessResult() *Result

NewSuccessResult ...

func (*Result) AddInfo

func (r *Result) AddInfo(info string)

AddInfo ...

func (*Result) JSON

func (r *Result) JSON() []byte

JSON ...

func (*Result) SetData

func (r *Result) SetData(data interface{})

SetData ...

func (*Result) SetLogger

func (r *Result) SetLogger(logger *log.Entry) *Result

SetLogger ...

type ResultStatus

type ResultStatus string

ResultStatus ...

const (
	// Success ...
	Success ResultStatus = "success"

	// Failure ...
	Failure ResultStatus = "failure"
)

type TccgUser

type TccgUser struct {
	Account  string `json:"account" binding:"required"`
	Password string `json:"password" binding:"required"`
	Name     string `json:"name"`
	Title    string `json:"title"`
	Enabled  bool   `json:"enabled"`
	OU       string `json:"ou"`
}

TccgUser ...

func (*TccgUser) User

func (tccgUser *TccgUser) User() User

User ...

type TcpassVisit

type TcpassVisit struct {
	Model
	DepartmentEmployeeID uint               `json:"-"`
	LocationID           uint               `json:"location_id"`
	DepartmentEmployee   DepartmentEmployee `json:"department_employee" gorm:"DepartmentEmployeeID"`
	Location             Location           `json:"location" gorm:"foreignkey:LocationID"`
	UUID                 string             `json:"uuid"`
}

TcpassVisit ...

func (*TcpassVisit) Mask

func (visit *TcpassVisit) Mask()

Mask ...

type Token

type Token struct {
	Token  string    `json:"token"`
	Expire time.Time `json:"expire"`
}

Token ...

type User

type User struct {
	Model
	Username string   `json:"username" gorm:"unique;not null" binding:"required"`
	Password string   `json:"password" gorm:"-"`
	Name     string   `json:"name"`
	Type     UserType `json:"type"`
	Employee Employee `json:"employee" gorm:"foreignkey:UserID"`
	Guest    Guest    `json:"guest" gorm:"foreignkey:UserID"`
	Token    Token    `json:"token" gorm:"-"`
}

User ...

func (*User) Mask

func (user *User) Mask(target MaskTarget)

Mask ...

type UserType

type UserType int

UserType ...

const (
	// EmployeeUser ...
	EmployeeUser UserType = iota

	// GuestUser ...
	GuestUser
)

type Visit

type Visit struct {
	Model
	GuestUserID          uint               `json:"-"`
	DepartmentEmployeeID uint               `json:"-"`
	LocationID           uint               `json:"location_id"`
	Guest                User               `json:"guest" gorm:"foreignkey:GuestUserID"`
	DepartmentEmployee   DepartmentEmployee `json:"department_employee" gorm:"DepartmentEmployeeID"`
	Location             Location           `json:"location" gorm:"foreignkey:LocationID"`
	Followers            []Follower         `json:"followers" gorm:"foreignkey:VisitID"`
}

Visit ...

func (*Visit) Mask

func (visit *Visit) Mask()

Mask ...

Jump to

Keyboard shortcuts

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