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.
66 lines
2.1 KiB
66 lines
2.1 KiB
package modelsschool
|
|
|
|
import (
|
|
"appPlatform/overall"
|
|
"strings"
|
|
)
|
|
|
|
// 试题答案
|
|
type Answer struct {
|
|
Id int64 `json:"id" gorm:"primaryKey;column:a_id;type:bigint(20) unsigned;not null;comment:ID"`
|
|
TitleText string `json:"titleText" gorm:"column:a_text;type:text;comment:答案"`
|
|
trueFalse int `json:"trueFalse" gorm:"column:a_true_false;type:int(1) unsigned;default:1;not null;comment:是否为正确答案(1:正确;2:错误)"`
|
|
Types int `json:"types" gorm:"column:a_type;type:tinyint(1) unsigned;default:0;not null;comment:类型(1:单选;2:多选;3:判断)"`
|
|
Keys int64 `json:"keys" gorm:"column:a_key;type:bigint(50) unsigned;default:0;not null;comment:'唯一识别符"`
|
|
}
|
|
|
|
func (SystemMenu *Answer) TableName() string {
|
|
return "answer"
|
|
}
|
|
|
|
// // 菜单管理
|
|
// type SystemMenuOperation struct {
|
|
// Answer
|
|
// MenuPermit []MenuOperation `json:"menupermit"`
|
|
// }
|
|
|
|
// 编辑内容
|
|
func (cont *Answer) EiteCont(whereMap interface{}, saveData interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Updates(saveData).Error
|
|
return
|
|
}
|
|
|
|
// 获取内容
|
|
func (cont *Answer) 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 *Answer) CountCont(whereMap interface{}) (countId int64) {
|
|
overall.CONSTANT_DB_KPI.Model(&cont).Where(whereMap).Count(&countId)
|
|
return
|
|
}
|
|
|
|
// 读取全部信息
|
|
func (cont *Answer) ContMap(whereMap interface{}, field ...string) (countAry []Answer, 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 *Answer) DelCont(whereMap interface{}) (err error) {
|
|
err = overall.CONSTANT_DB_KPI.Where(whereMap).Delete(&cont).Error
|
|
return
|
|
}
|
|
|