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.
80 lines
3.8 KiB
80 lines
3.8 KiB
package modelsschool
|
|
|
|
import (
|
|
"appPlatform/overall"
|
|
"strings"
|
|
)
|
|
|
|
// 试题题目
|
|
type Subject struct {
|
|
Id int64 `json:"id" gorm:"primaryKey;column:s_id;type:bigint(20) unsigned;not null;comment:ID"`
|
|
Title string `json:"title" gorm:"column:s_title;type:varchar(255);not null;comment:题目"`
|
|
State int `json:"state" gorm:"column:s_state;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"`
|
|
Examination int64 `json:"examination" gorm:"column:s_examination;type:bigint(20) unsigned;default:0;not null;comment:'分厂"`
|
|
Sset int `json:"sset" gorm:"column:s_set;type:tinyint(1) unsigned;default:1;not null;comment:是否为共享(1:非共享;2:共享)"`
|
|
Time int64 `json:"time" gorm:"column:s_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"`
|
|
EiteTime int64 `json:"eiteTime" gorm:"column:s_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"`
|
|
SystemUser int64 `json:"system_user" gorm:"column:s_system_user;type:bigint(50) unsigned;default:0;not null;comment:'创建人"`
|
|
Types int `json:"types" gorm:"column:s_type;type:tinyint(1) unsigned;default:0;not null;comment:类型(1:单选;2:多选;3:判断)"`
|
|
Work int64 `json:"work" gorm:"column:s_work;type:bigint(20) unsigned;default:0;not null;comment:'工段"`
|
|
Postiton int64 `json:"postiton" gorm:"column:s_postiton;type:bigint(20) unsigned;default:0;not null;comment:'职务"`
|
|
Weight int `json:"weight" gorm:"column:s_weight;type:tinyint(4) unsigned;default:0;not null;comment:权重"`
|
|
Keys int64 `json:"keys" gorm:"column:s_key;type:bigint(20) unsigned;default:0;not null;comment:'唯一识别符"`
|
|
TitleText string `json:"titleText" gorm:"column:s_text;type:text;comment:题目解释"`
|
|
ShareNumber int64 `json:"share_number" gorm:"column:s_share_number;type:bigint(50) unsigned;default:0;not null;comment:'共享识别符"`
|
|
SpaceNum int `json:"space_num" gorm:"column:s_space_num;type:tinyint(3) unsigned;default:0;not null;comment:空格"`
|
|
OneExam int64 `json:"one_exam" gorm:"column:s_one_exam;type:bigint(30) unsigned;default:0;not null;comment:'单一考试试题"`
|
|
Special int `json:"special" gorm:"column:s_special;type:tinyint(3) unsigned;default:0;not null;comment:专项考试(1:不是;2:是)"`
|
|
Groups int `json:"groups" gorm:"column:s_group;type:int(10) unsigned;default:0;not null;comment:归属集团"`
|
|
}
|
|
|
|
func (SystemMenu *Subject) TableName() string {
|
|
return "subject"
|
|
}
|
|
|
|
// // 菜单管理
|
|
// type SystemMenuOperation struct {
|
|
// Subject
|
|
// MenuPermit []MenuOperation `json:"menupermit"`
|
|
// }
|
|
|
|
// 编辑内容
|
|
func (cont *Subject) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
|
|
return
|
|
}
|
|
|
|
// 获取内容
|
|
func (cont *Subject) 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 *Subject) CountCont(whereMap interface{}) (countId int64) {
|
|
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
|
|
return
|
|
}
|
|
|
|
// 读取全部信息
|
|
func (cont *Subject) ContMap(whereMap interface{}, field ...string) (countAry []Subject, 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 *Subject) DelCont(whereMap interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
|
|
return
|
|
}
|
|
|