package models import ( "eta/eta_forum_admin/utils" "github.com/beego/beego/v2/client/orm" ) // AI预测模型分类项 type AiPredictModelClassifyItems struct { AiPredictModelClassifyId int `json:"ai_predict_model_classify_id" orm:"column(ai_predict_model_classify_id)"` ClassifyName string `json:"classify_name"` // 分类名称 ParentId int `json:"parent_id"` // 父级ID LevelPath string `json:"level_path"` // 层级路径 Sort int `json:"sort"` // 排序 } // AI预测模型分类列表 type AiPredictModelClassifyItemList []*AiPredictModelClassifyItems // 实现sort.Interface接口 func (s AiPredictModelClassifyItemList) Len() int { return len(s) } func (s AiPredictModelClassifyItemList) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s AiPredictModelClassifyItemList) Less(i, j int) bool { return s[i].Sort < s[j].Sort } // 商家AI预测模型分类响应 type BusinessAiPredictModelClassifyResp struct { List []*AiPredictModelClassifyItems `json:"list"` // 分类列表 CheckList []int `json:"check_list"` // 已选中的分类ID列表 } // 根据关键字获取AI预测模型分类列表 func GetAiPredictModelClassifyListByKeyword(keyword string) (list []*AiPredictModelClassifyItems, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM ai_predict_model_classify WHERE classify_name LIKE ?` _, err = o.Raw(sql, "%"+keyword+"%").QueryRows(&list) return } // 根据ID列表获取AI预测模型分类列表 func GetAiPredictModelClassifyItemsByIdList(ids []int) (list []*AiPredictModelClassifyItems, err error) { if len(ids) == 0 { return } o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM ai_predict_model_classify WHERE ai_predict_model_classify_id IN (`+utils.GetOrmInReplace(len(ids))+`)` _, err = o.Raw(sql, ids).QueryRows(&list) return } // 获取所有AI预测模型分类 func GetAiPredictModelClassify() (list []*AiPredictModelClassifyItems, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM ai_predict_model_classify ORDER BY sort ASC, ai_predict_model_classify_id ASC` _, err = o.Raw(sql).QueryRows(&list) return }