model

package
v0.0.0-...-b6dbd3c Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const TimeLayout = "2006-01-02T15:04"

Variables

View Source
var AppIss = "github.com/dejavuzhou/felix"
View Source
var AppSecret = ""
View Source
var ExpireTime = time.Hour * 24

Functions

func CreateGodUser

func CreateGodUser(user, password string) error

func CreateSQLiteDb

func CreateSQLiteDb(verbose bool)

func FlushSqliteDb

func FlushSqliteDb() error

func MachineAdd

func MachineAdd(name, addr, ip, user, password, key, auth string, port uint) error

MachineAdd

func MachineDelete

func MachineDelete(idx uint) error

func MachineDeleteAll

func MachineDeleteAll() error

func MachineDuplicate

func MachineDuplicate(idx uint) error

func MachineUpdate

func MachineUpdate(name, addr, user, password, pkey, t string, id, port uint) error

func TaskAdd

func TaskAdd(content, cate, deadLine string) error

func TaskRm

func TaskRm(id uint) error

func TaskUpdate

func TaskUpdate(id uint, status string) error

func TranslateCh2En

func TranslateCh2En(text string) (string, error)

func TranslateEn2Ch

func TranslateEn2Ch(text string) (string, error)

Types

type BaseModel

type BaseModel struct {
	Id        uint      `gorm:"primary_key" json:"id" form:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Comment

type Comment struct {
	BaseModel
	PageUrl     string        `json:"page_url" gorm:"index" form:"page_url"`
	ParentPath  string        `json:"parent_path" form:"parent_path" gorm:"default:'0';index" comment:"父级评论的id路径使用like %查询"`
	UserId      uint          `json:"user_id"`
	Content     string        `json:"content"`
	LikeUids    JsonArrayUint `gorm:"type:json" json:"like_uids"`
	DislikeUids JsonArrayUint `gorm:"type:json" json:"dislike_uids"`
	ThankUids   JsonArrayUint `gorm:"type:json" json:"thank_uids"`
	AtUids      JsonArrayUint `gorm:"type:json" json:"at_uids" comment:"at用户IDs json uint array"`
	User        User          `json:"user"`
}

func (*Comment) Action

func (m *Comment) Action(id, uid uint, action string) (err error)

func (*Comment) AfterFind

func (m *Comment) AfterFind() (err error)

func (*Comment) Create

func (m *Comment) Create() (err error)

CreateUserOfRole

func (*Comment) Delete

func (m *Comment) Delete() (err error)

Delete

func (*Comment) One

func (m *Comment) One() error

One

type CommentQ

type CommentQ struct {
	PaginationQ
	Comment
}

func (*CommentQ) SearchAll

func (cq *CommentQ) SearchAll() (data *PaginationQ, err error)

type Ginbro

type Ginbro struct {
	BaseModel
	IsSuccess  bool   `json:"is_success" form:"is_success"`
	AppSecret  string `json:"app_secret" form:"app_secret"`
	AppAddr    string `json:"app_addr" form:"app_addr"`
	AppDir     string `json:"app_dir" form:"app_dir"`
	AppPkg     string `json:"app_pkg" form:"app_pkg"`
	AuthTable  string `json:"auth_table" form:"auth_table"`
	AuthColumn string `json:"auth_column" form:"auth_column"`
	DbUser     string `json:"db_user" form:"db_user"`
	DbPassword string `json:"db_password" form:"db_password"`
	DbAddr     string `json:"db_addr" form:"db_addr"`
	DbName     string `json:"db_name" form:"db_name"`
	DbChar     string `json:"db_char" form:"db_char"`
	DbType     string `json:"db_type" form:"db_type"`
}

func (Ginbro) All

func (m Ginbro) All(q *PaginationQ) (list *[]Ginbro, total uint, err error)

All

func (*Ginbro) Create

func (m *Ginbro) Create() (err error)

CreateUserOfRole

type HackNew

type HackNew struct {
	BaseModel
	TitleZh string `json:"title_zh" form:"title_zh"`
	TitleEn string `json:"title_en" form:"title_en"`
	Url     string `gorm:"index" json:"url" form:"url"`
	Cate    string `json:"cate" comment:"news or show" form:"cate"`
}

func (*HackNew) CreateOrUpdate

func (m *HackNew) CreateOrUpdate() (err error)

func (HackNew) Delete

func (m HackNew) Delete(ids []uint) (err error)

Delete

func (HackNew) TodayRowBy

func (m HackNew) TodayRowBy(cate string) (list []HackNew, err error)

func (*HackNew) Update

func (m *HackNew) Update() (err error)

Update a row

type HackNewQ

type HackNewQ struct {
	PaginationQ
	HackNew
}

func (*HackNewQ) SearchAll

func (cq *HackNewQ) SearchAll() (data *PaginationQ, err error)

type JsonArrayUint

type JsonArrayUint []uint

func (JsonArrayUint) AppendOrRemove

func (j JsonArrayUint) AppendOrRemove(e uint) (isExist bool, a JsonArrayUint)

func (JsonArrayUint) Equals

func (j JsonArrayUint) Equals(j1 JsonArrayUint) bool

func (JsonArrayUint) IsNull

func (j JsonArrayUint) IsNull() bool

func (JsonArrayUint) MarshalJSONArrayUint

func (m JsonArrayUint) MarshalJSONArrayUint() ([]byte, error)

func (*JsonArrayUint) Scan

func (o *JsonArrayUint) Scan(input interface{}) (err error)

func (*JsonArrayUint) UnmarshalJSONArrayUint

func (m *JsonArrayUint) UnmarshalJSONArrayUint(data []byte) error

func (JsonArrayUint) Value

func (o JsonArrayUint) Value() (driver.Value, error)

type LogicSshWsSession

type LogicSshWsSession struct {
	IsFlagged bool `comment:"当前session是否包含禁止命令"`
	// contains filtered or unexported fields
}

func NewLogicSshWsSession

func NewLogicSshWsSession(cols, rows int, isAdmin bool, sshClient *ssh.Client, wsConn *websocket.Conn) (*LogicSshWsSession, error)

func (*LogicSshWsSession) Close

func (sws *LogicSshWsSession) Close()

Close 关闭

func (*LogicSshWsSession) LogString

func (sws *LogicSshWsSession) LogString() string

func (*LogicSshWsSession) Start

func (sws *LogicSshWsSession) Start(quitChan chan bool)

func (*LogicSshWsSession) Wait

func (sws *LogicSshWsSession) Wait(quitChan chan bool)

type Machine

type Machine struct {
	BaseModel
	Name     string `json:"name" gorm:"type:varchar(50);unique_index"`
	Host     string `json:"host" gorm:"type:varchar(50)"`
	Ip       string `json:"ip" gorm:"type:varchar(80)"`
	Port     uint   `json:"port" gorm:"type:int(6)"`
	User     string `json:"user" gorm:"type:varchar(20)"`
	Password string `json:"password,omitempty"`
	Key      string `json:"key,omitempty"`
	Type     string `json:"type" gorm:"type:varchar(20)"`
}

Machine

func MachineAll

func MachineAll(search string) ([]Machine, error)

func MachineFind

func MachineFind(idx uint) (*Machine, error)

func (*Machine) All

func (m *Machine) All(q *PaginationQ) (list *[]Machine, total uint, err error)

All get all for pagination

func (*Machine) ChangeUpdateTime

func (m *Machine) ChangeUpdateTime() (err error)

func (*Machine) Create

func (m *Machine) Create() (err error)

CreateUserOfRole insert a row

func (*Machine) Delete

func (m *Machine) Delete() (err error)

Delete destroy a row

func (*Machine) One

func (m *Machine) One() (err error)

func (*Machine) Update

func (m *Machine) Update() (err error)

Update a row

type PaginationQ

type PaginationQ struct {
	Ok    bool        `json:"ok"`
	Size  uint        `form:"size" json:"size"`
	Page  uint        `form:"page" json:"page"`
	Data  interface{} `json:"data" comment:"muster be a pointer of slice gorm.Model"` // save pagination list
	Total uint        `json:"total"`
}

PaginationQ gin handler query binding struct

func (*PaginationQ) SearchAll

func (p *PaginationQ) SearchAll(queryTx *gorm.DB) (data *PaginationQ, err error)

SearchAll optimized pagination method for gorm

type SlackMsg

type SlackMsg struct {
	Text        string `json:"text"`
	Username    string `json:"username"`
	IconURL     string `json:"icon_url"`
	IconEmoji   string `json:"icon_emoji"`
	Channel     string `json:"channel"`
	UnfurlLinks bool   `json:"unfurl_links"`
	Attachments []struct {
		Title    string `json:"title"`
		Fallback string `json:"fallback"`
		Text     string `json:"text"`
		Pretext  string `json:"pretext"`
		Color    string `json:"color"`
		Fields   []struct {
			Title string `json:"title"`
			Value string `json:"value"`
			Short bool   `json:"short"`
		} `json:"fields"`
	} `json:"attachments"`
}

func (*SlackMsg) Scan

func (o *SlackMsg) Scan(input interface{}) error

func (SlackMsg) Value

func (o SlackMsg) Value() (driver.Value, error)

type SshLog

type SshLog struct {
	BaseModel
	UserId    uint      `gorm:"index" json:"user_id" form:"user_id"`
	MachineId uint      `gorm:"index" json:"machine_id" form:"machine_id"`
	SshUser   string    `json:"ssh_user" comment:"ssh账号"`
	ClientIp  string    `json:"client_ip" form:"client_ip"`
	StartedAt time.Time `json:"started_at" form:"started_at"`
	Status    uint      `json:"status" comment:"0-未标记 2-正常 4-警告 8-危险 16-致命"`
	Remark    string    `json:"remark"`
	Log       string    `gorm:"type:text" json:"log"`
	Machine   Machine   `gorm:"association_autoupdate:false;association_autocreate:false" json:"machine"`
	User      User      `gorm:"association_autoupdate:false;association_autocreate:false" json:"user"`
}

func (*SshLog) AfterFind

func (m *SshLog) AfterFind() (err error)

func (SshLog) All

func (m SshLog) All(q *PaginationQ) (list *[]SshLog, total uint, err error)

All

func (*SshLog) Create

func (m *SshLog) Create() (err error)

CreateUserOfRole

func (*SshLog) Delete

func (m *SshLog) Delete() (err error)

Delete

func (*SshLog) One

func (m *SshLog) One() error

One

func (*SshLog) Update

func (m *SshLog) Update() (err error)

Update

type SshLogQ

type SshLogQ struct {
	SshLog
	PaginationQ
	FromTime string `form:"from_time"`
	ToTime   string `form:"to_time"`
}

func (SshLogQ) Search

func (m SshLogQ) Search() (list *[]SshLog, total uint, err error)

type Task

type Task struct {
	BaseModel
	Content  string    `json:"content" gorm:"type:varchar(255)"`
	Deadline time.Time `json:"deadline"`
	Category string    `json:"category" gorm:"type:varchar(20)"`
	Status   string    `json:"type" gorm:"type:varchar(20)"`
}

func TaskAll

func TaskAll(search string) ([]Task, error)

type User

type User struct {
	BaseModel
	Username       string        `` /* 147-byte string literal not displayed */
	NickName       string        `gorm:"column:nick_name" form:"nick_name" json:"nick_name" comment:"真实姓名"`
	Email          string        `gorm:"column:email" form:"email" json:"email" comment:"邮箱" columnType:"varchar(255)" dataType:"varchar" columnKey:"UNI"`
	Mobile         string        `` /* 131-byte string literal not displayed */
	Password       string        `` /* 139-byte string literal not displayed */
	RoleId         uint          `` /* 172-byte string literal not displayed */
	Status         uint          `` /* 149-byte string literal not displayed */
	Avatar         string        `` /* 129-byte string literal not displayed */
	Remark         string        `gorm:"column:remark" form:"remark" json:"remark" comment:"备注" columnType:"varchar(255)" dataType:"varchar" columnKey:""`
	FriendIds      JsonArrayUint `gorm:"type:json" json:"friend_ids" comment:"json uint 数组"`
	Karma          uint          `json:"karma"`
	CommentIds     JsonArrayUint `gorm:"type:json" json:"comment_ids"`
	HashedPassword string        `gorm:"-" json:"-"`
}

User

func JwtParseUser

func JwtParseUser(tokenString string) (*User, error)

JwtParseUser

func (*User) AfterFind

func (m *User) AfterFind() (err error)

func (*User) All

func (m *User) All(q *PaginationQ) (list *[]User, total uint, err error)

All

func (*User) CreateUserOfRole

func (m *User) CreateUserOfRole(role uint) (err error)

CreateUserOfRole

func (*User) Delete

func (m *User) Delete() (err error)

Delete

func (*User) Login

func (m *User) Login(ip string, roleId uint) (string, error)

Login

func (*User) One

func (m *User) One() error

One

func (*User) Update

func (m *User) Update() (err error)

Update

type WslogHook

type WslogHook struct {
	BaseModel
	Name     string    `json:"name" gorm:"type:varchar(50);unique_index"`
	UserId   uint      `json:"user_id"`
	Token    string    `json:"token"`
	ExpireAt time.Time `json:"expire_at"`
}

func WslogHookCheckToken

func WslogHookCheckToken(token string) (*WslogHook, error)

func (WslogHook) All

func (m WslogHook) All(q *PaginationQ) (list *[]WslogHook, total uint, err error)

func (*WslogHook) Create

func (m *WslogHook) Create() error

func (WslogHook) Delete

func (m WslogHook) Delete() (err error)

func (*WslogHook) One

func (m *WslogHook) One() error

func (*WslogHook) Update

func (m *WslogHook) Update() error

update renew token and other infos

type WslogMsg

type WslogMsg struct {
	BaseModel
	HookId   uint     `gorm:"index" json:"hook_id"`
	UserId   uint     `gorm:"index" json:"user_id"`
	ToUid    uint     `gorm:"index" json:"to_uid"`
	SlackMsg SlackMsg `gorm:"type:json" json:"slack_msg"`
}

func (WslogMsg) All

func (m WslogMsg) All(q *PaginationQ) (list *[]WslogMsg, total uint, err error)

func (*WslogMsg) Create

func (m *WslogMsg) Create() error

func (WslogMsg) Delete

func (m WslogMsg) Delete(ids []int) (err error)

func (WslogMsg) Truncate

func (m WslogMsg) Truncate() (err error)

func (*WslogMsg) Update

func (m *WslogMsg) Update() error

update renew token and other infos

Jump to

Keyboard shortcuts

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