Files
easygoadmin/app/model/menu.go
yaoyilin 1b36bd8fbe feat: 初始化项目
初始化项目
2022-10-31 22:29:16 +08:00

49 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import "easygoadmin/utils"
type Menu struct {
Id int `json:"id" xorm:"not null pk autoincr comment('唯一性标识') INT(10)"`
Name string `json:"name" xorm:"not null comment('菜单名称') index VARCHAR(30)"`
Icon string `json:"icon" xorm:"comment('图标') VARCHAR(50)"`
Url string `json:"url" xorm:"comment('URL地址') VARCHAR(150)"`
Param string `json:"param" xorm:"comment('参数') VARCHAR(150)"`
Pid int `json:"pid" xorm:"not null default 0 comment('上级ID') index INT(10)"`
Type int `json:"type" xorm:"not null default 0 comment('类型1模块 2导航 3菜单 4节点') TINYINT(1)"`
Permission string `json:"permission" xorm:"comment('权限标识') VARCHAR(150)"`
Status int `json:"status" xorm:"not null default 1 comment('是否显示1显示 2不显示') TINYINT(1)"`
Target int `json:"target" xorm:"not null default 1 comment('打开方式1内部打开 2外部打开') TINYINT(1)"`
Note string `json:"note" xorm:"comment('菜单备注') VARCHAR(255)"`
Sort int `json:"sort" xorm:"default 125 comment('显示顺序') SMALLINT(5)"`
CreateUser int `json:"create_user" xorm:"default 0 comment('添加人') INT(11)"`
CreateTime int64 `json:"create_time" xorm:"default 0 comment('创建时间') INT(11)"`
UpdateUser int `json:"update_user" xorm:"default 0 comment('更新人') INT(11)"`
UpdateTime int64 `json:"update_time" xorm:"default 0 comment('更新时间') INT(11)"`
Mark int `json:"mark" xorm:"not null default 1 comment('有效标识') TINYINT(1)"`
}
// 根据条件查询单条数据
func (r *Menu) Get() (bool, error) {
return utils.XormDb.Get(r)
}
// 插入数据
func (r *Menu) Insert() (int64, error) {
return utils.XormDb.Insert(r)
}
// 更新数据
func (r *Menu) Update() (int64, error) {
return utils.XormDb.Id(r.Id).Update(r)
}
// 删除
func (r *Menu) Delete() (int64, error) {
return utils.XormDb.Id(r.Id).Delete(&Menu{})
}
// 批量删除
func (r *Menu) BatchDelete(ids ...int64) (int64, error) {
return utils.XormDb.In("id", ids).Delete(&Menu{})
}