package ai_predict_model import ( "eta/eta_mobile/controllers" "eta/eta_mobile/models" aiPredictModel "eta/eta_mobile/models/ai_predict_model" "eta/eta_mobile/utils" "fmt" "strings" ) // AiPredictModelFrameworkController 模型框架 type AiPredictModelFrameworkController struct { controllers.BaseAuthController } // List // @Title 列表 // @Description 列表 // @Param AdminId query int false "创建人ID" // @Param Visibility query int false "范围: 0-所有; 1-私有; 2-公开" // @Param Keyword query string false "关键词" // @Success 200 Ret=200 获取成功 // @router /framework/list [get] func (c *AiPredictModelFrameworkController) List() { br := new(models.BaseResponse).Init() defer func() { if br.ErrMsg == "" { br.IsSendEmail = false } c.Data["json"] = br c.ServeJSON() }() sysUser := c.SysUser if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } adminId, _ := c.GetInt("AdminId") keyword := c.GetString("Keyword") keyword = strings.TrimSpace(keyword) frameworkOb := new(aiPredictModel.AiPredictModelFramework) cond := `` pars := make([]interface{}, 0) if adminId > 0 { cond += fmt.Sprintf(` AND %s = ?`, aiPredictModel.AiPredictModelFrameworkColumns.AdminId) pars = append(pars, adminId) } if keyword != "" { cond += fmt.Sprintf(` AND %s LIKE ?`, aiPredictModel.AiPredictModelFrameworkColumns.FrameworkName) pars = append(pars, "%"+keyword+"%") } orderRule := `sort ASC, create_time DESC` list, e := frameworkOb.GetItemsByCondition(cond, pars, []string{}, orderRule) if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取框架列表失败, Err: " + e.Error() return } resp := make([]*aiPredictModel.AiPredictModelFrameworkItem, 0) for _, v := range list { t := aiPredictModel.FormatAiPredictModelFramework2Item(v, make([]*aiPredictModel.AiPredictModelFrameworkNodeItem, 0)) if t.AdminId == sysUser.AdminId || utils.IsAdminRole(sysUser.RoleTypeCode) { t.Button.OpButton = true t.Button.DeleteButton = true t.Button.MoveButton = true } resp = append(resp, t) } br.Data = resp br.Ret = 200 br.Success = true br.Msg = "获取成功" }