KPI绩效考核系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.5 KiB

package modelsschool
import (
"key_performance_indicators/overall"
"strings"
)
// 菜单
type SystemMenu struct {
Id int64 `json:"id" gorm:"primaryKey;column:m_id;type:bigint(20) unsigned;not null;comment:ID"`
Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"`
State int `json:"state" gorm:"column:m_steat;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"`
ParentId int64 `json:"parentId" gorm:"column:m_parent;type:bigint(30) unsigned;default:0;not null;comment:'父级(顶级:0)"`
ApiUrl string `json:"apiUrl" gorm:"column:m_url;type:varchar(255);not null;comment:地址"`
Time int64 `json:"time" gorm:"column:m_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"`
EiteTime int64 `json:"eiteTime" gorm:"column:m_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"`
UserId int64 `json:"userId" gorm:"column:m_user_id;type:bigint(20) unsigned;not null;default:0;comment:写入人"`
Sort int `json:"sort" gorm:"column:m_sort;type:tinyint(3) unsigned;default:0;not null;comment:排序"`
}
func (SystemMenu *SystemMenu) TableName() string {
return "system_menu"
}
// 菜单管理
type SystemMenuOperation struct {
SystemMenu
MenuPermit []MenuOperation `json:"menupermit"`
}
// 编辑内容
func (cont *SystemMenu) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
return
}
// 获取内容
func (cont *SystemMenu) GetCont(whereMap interface{}, field ...string) (err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
gormDb = gormDb.Where(whereMap)
err = gormDb.First(&cont).Error
return
}
// 根据条件获取总数
func (cont *SystemMenu) CountCont(whereMap interface{}) (countId int64) {
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
return
}
// 读取全部信息
func (cont *SystemMenu) ContMap(whereMap interface{}, field ...string) (countAry []SystemMenu, err error) {
gormDb := overall.CONSTANT_DB_KPI.Model(&cont)
if len(field) > 0 {
fieldStr := strings.Join(field, ",")
gormDb = gormDb.Select(fieldStr)
}
err = gormDb.Where(whereMap).Find(&countAry).Error
return
}
// 删除内容
func (cont *SystemMenu) DelCont(whereMap interface{}) (err error) {
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
return
}