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.
75 lines
4.0 KiB
75 lines
4.0 KiB
package modelsschool
|
|
|
|
import (
|
|
"appPlatform/overall"
|
|
"strings"
|
|
)
|
|
|
|
// 权限矩阵基础字段框架表
|
|
type TestPaper struct {
|
|
Id int64 `json:"id" gorm:"primaryKey;column:tp_id;type:bigint(20) unsigned;not null;comment:Id;index"`
|
|
UserKey int64 `json:"tp_u_key" gorm:"column:tp_u_key;type:bigint(20) unsigned;default:0;not null;comment:员工唯一识别符"`
|
|
ExamKey int64 `json:"tp_exa_key" gorm:"column:tp_exa_key;type:bigint(20) unsigned;default:0;not null;comment:考试项目唯一识别符"`
|
|
RightKey string `json:"tp_right_key" gorm:"column:tp_right_key;type:mediumtext;default:'';comment:正确答案"`
|
|
TpExaQue string `json:"tp_exa_que" gorm:"column:tp_exa_que;type:mediumtext;default:'';comment:试卷Json格式"`
|
|
UserReply string `json:"tp_reply" gorm:"column:tp_reply;type:mediumtext;default:'';comment:员工提交答案"`
|
|
Fraction int `json:"tp_fraction" gorm:"column:tp_fraction;type:int(5);default:1;not null;comment:分数"`
|
|
SumFraction int `json:"tp_sum_fraction" gorm:"column:tp_sum_fraction;type:int(5);default:1;not null;comment:总分"`
|
|
PasseLine int `json:"tp_pass_line" gorm:"column:tp_pass_line;type:int(3);default:1;not null;comment:及格线"`
|
|
FrequencyCount int `json:"tp_frequency" gorm:"column:tp_frequency;type:int(2);default:1;not null;comment:考试次数"`
|
|
DepartmentId int64 `json:"tp_bf_id" gorm:"column:tp_bf_id;type:bigint(20) unsigned;default:0;not null;comment:分厂"`
|
|
PosticsId int64 `json:"tp_ws_id" gorm:"column:tp_ws_id;type:bigint(20) unsigned;default:0;not null;comment:工段"`
|
|
DutiesId int64 `json:"tp_wp_id" gorm:"column:tp_wp_id;type:bigint(20) unsigned;default:0;not null;comment:职务"`
|
|
Group int64 `json:"tp_group" gorm:"column:tp_group;type:bigint(20) unsigned;default:0;not null;comment:集团"`
|
|
Start int64 `json:"tp_start" gorm:"column:tp_start;type:bigint(20) unsigned;default:0;not null;comment:开始考试时间"`
|
|
EiteTime int64 `json:"tp_eite" gorm:"column:tp_eite;type:bigint(20) unsigned;default:0;not null;comment:修改时间"`
|
|
SetUp int `json:"tp_set" gorm:"column:tp_set;type:int(1);default:1;not null;comment:状态(1:考试中;2:结束考试)"`
|
|
ExamCount int `json:"tp_exam_sum" gorm:"column:tp_exam_sum;type:int(4);default:1;not null;comment:考题总数"`
|
|
Grade int `json:"tp_grade" gorm:"column:tp_grade;type:int(1);default:1;not null;comment:考试评级(1:不及格;2:及格;3:良好;4:优秀)"`
|
|
UnifiedExamination int `json:"ps_gen_exa" gorm:"column:ps_gen_exa;type:int(1);default:1;not null;comment:统考(1:是;2:否)"`
|
|
}
|
|
|
|
func (TestPaper *TestPaper) TableName() string {
|
|
return "test_paper"
|
|
}
|
|
|
|
// 编辑内容
|
|
func (cont *TestPaper) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Updates(saveData).Error
|
|
return
|
|
}
|
|
|
|
// 获取内容
|
|
func (cont *TestPaper) GetCont(whereMap interface{}, field ...string) (err error) {
|
|
gormDb := overall.CONSTANT_DB_Master.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 *TestPaper) CountCont(whereMap interface{}) (countId int64) {
|
|
overall.CONSTANT_DB_Master.Model(&cont).Where(whereMap).Count(&countId)
|
|
return
|
|
}
|
|
|
|
// 读取全部信息
|
|
func (cont *TestPaper) ContMap(whereMap interface{}, field ...string) (countAry []TestPaper, err error) {
|
|
gormDb := overall.CONSTANT_DB_Master.Model(&cont)
|
|
if len(field) > 0 {
|
|
fieldStr := strings.Join(field, ",")
|
|
gormDb = gormDb.Select(fieldStr)
|
|
}
|
|
err = gormDb.Where(whereMap).Find(&countAry).Error
|
|
return
|
|
}
|
|
|
|
// 删除内容
|
|
func (cont *TestPaper) DelCont(whereMap interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_Master.Where(whereMap).Delete(&cont).Error
|
|
return
|
|
}
|
|
|