123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668 |
- package ai_predict_model
- import (
- "encoding/json"
- "eta/eta_api/controllers"
- "eta/eta_api/models"
- aiPredictModel "eta/eta_api/models/ai_predict_model"
- "eta/eta_api/utils"
- "fmt"
- "strings"
- "time"
- )
- // 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 = "获取成功"
- }
- // Add
- // @Title 新增框架
- // @Description 新增框架
- // @Param request body aiPredictModel.AiPredictModelFrameworkAddReq true "type json string"
- // @Success 200 Ret=200 操作成功
- // @router /framework/add [post]
- func (c *AiPredictModelFrameworkController) Add() {
- 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
- }
- // 参数校验
- var req aiPredictModel.AiPredictModelFrameworkAddReq
- if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
- return
- }
- req.FrameworkName = strings.TrimSpace(req.FrameworkName)
- if req.FrameworkName == "" {
- br.Msg = "框架名称不可为空"
- return
- }
- // 重名校验
- {
- ob := new(aiPredictModel.AiPredictModelFramework)
- cond := fmt.Sprintf(` AND %s = ? AND %s = ?`, aiPredictModel.AiPredictModelFrameworkColumns.FrameworkName, aiPredictModel.AiPredictModelFrameworkColumns.AdminId)
- pars := make([]interface{}, 0)
- pars = append(pars, req.FrameworkName, sysUser.AdminId)
- exist, e := ob.GetItemByCondition(cond, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "操作失败"
- br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
- return
- }
- if exist != nil {
- br.Msg = "框架名称已存在,请重新输入"
- return
- }
- }
- now := time.Now().Local()
- frameworkCode := utils.MD5(fmt.Sprint(now.UnixMilli()))
- item := new(aiPredictModel.AiPredictModelFramework)
- item.FrameworkName = req.FrameworkName
- item.FrameworkCode = frameworkCode
- item.FrameworkImg = req.FrameworkImg
- item.FrameworkContent = req.FrameworkContent
- item.AdminId = sysUser.AdminId
- item.AdminName = sysUser.RealName
- item.CreateTime = now
- item.ModifyTime = now
- nodes := make([]*aiPredictModel.AiPredictModelFrameworkNode, 0)
- itemNodes := make([]*aiPredictModel.AiPredictModelFrameworkNodeItem, 0)
- if len(req.Nodes) > 0 {
- for _, v := range req.Nodes {
- if v.AiPredictModelIndexId <= 0 {
- continue
- }
- t := new(aiPredictModel.AiPredictModelFrameworkNode)
- t.FrameworkName = req.FrameworkName
- t.NodeId = v.NodeId
- t.NodeName = v.NodeName
- t.AiPredictModelIndexId = v.AiPredictModelIndexId
- t.CreateTime = now
- nodes = append(nodes, t)
- num := 1
- // 响应节点数据
- td := aiPredictModel.FormatAiPredictModelFrameworkNode2Item(t, num, map[int]*aiPredictModel.AiPredictModelIndex{})
- itemNodes = append(itemNodes, td)
- }
- }
- if e := item.CreateFrameworkAndNodes(item, nodes); e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "新增框架及节点失败, Err: " + e.Error()
- return
- }
- detail := aiPredictModel.FormatAiPredictModelFramework2Item(item, itemNodes)
- br.Data = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // Edit
- // @Title 编辑框架
- // @Description 编辑框架
- // @Param request body aiPredictModel.AiPredictModelFrameworkEditReq true "type json string"
- // @Success 200 Ret=200 操作成功
- // @router /framework/edit [post]
- func (c *AiPredictModelFrameworkController) Edit() {
- 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
- }
- // 参数校验
- var req aiPredictModel.AiPredictModelFrameworkEditReq
- if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
- return
- }
- if req.AiPredictModelFrameworkId <= 0 {
- br.Msg = "参数有误"
- br.ErrMsg = fmt.Sprintf("参数有误, AiPredictModelFrameworkId: %d", req.AiPredictModelFrameworkId)
- return
- }
- req.FrameworkName = strings.TrimSpace(req.FrameworkName)
- if req.FrameworkName == "" {
- br.Msg = "框架名称不可为空"
- return
- }
- frameworkOb := new(aiPredictModel.AiPredictModelFramework)
- item, e := frameworkOb.GetItemById(req.AiPredictModelFrameworkId)
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Msg = "框架不存在, 请刷新页面"
- return
- }
- br.Msg = "操作失败"
- br.ErrMsg = "获取框架失败, Err: " + e.Error()
- return
- }
- // 操作权限校验
- if item.AdminId != sysUser.AdminId && !utils.IsAdminRole(sysUser.RoleTypeCode) {
- br.Msg = "您没有权限操作该框架"
- return
- }
- // 重名校验
- {
- ob := new(aiPredictModel.AiPredictModelFramework)
- cond := fmt.Sprintf(` AND %s <> ? AND %s = ? AND %s = ?`, ob.PrimaryId(), aiPredictModel.AiPredictModelFrameworkColumns.FrameworkName, aiPredictModel.AiPredictModelFrameworkColumns.AdminId)
- pars := make([]interface{}, 0)
- pars = append(pars, req.AiPredictModelFrameworkId, req.FrameworkName, sysUser.AdminId)
- exist, e := ob.GetItemByCondition(cond, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "操作失败"
- br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
- return
- }
- if exist != nil {
- br.Msg = "框架名称已存在,请重新输入"
- return
- }
- }
- now := time.Now().Local()
- item.FrameworkName = req.FrameworkName
- item.FrameworkImg = req.FrameworkImg
- item.FrameworkContent = req.FrameworkContent
- item.ModifyTime = now
- updateCols := []string{"FrameworkName", "FrameworkImg", "FrameworkContent", "ModifyTime"}
- nodes := make([]*aiPredictModel.AiPredictModelFrameworkNode, 0)
- itemNodes := make([]*aiPredictModel.AiPredictModelFrameworkNodeItem, 0)
- if len(req.Nodes) > 0 {
- for _, v := range req.Nodes {
- if v.AiPredictModelIndexId <= 0 {
- continue
- }
- t := new(aiPredictModel.AiPredictModelFrameworkNode)
- t.AiPredictModelFrameworkId = req.AiPredictModelFrameworkId
- t.FrameworkName = req.FrameworkName
- t.NodeId = v.NodeId
- t.NodeName = v.NodeName
- t.AiPredictModelIndexId = v.AiPredictModelIndexId
- t.CreateTime = now
- nodes = append(nodes, t)
- // 响应节点数据
- td := aiPredictModel.FormatAiPredictModelFrameworkNode2Item(t, 1, map[int]*aiPredictModel.AiPredictModelIndex{})
- itemNodes = append(itemNodes, td)
- }
- }
- if e := item.EditFrameworkAndNodes(item, updateCols, nodes); e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "编辑框架及节点失败, Err: " + e.Error()
- return
- }
- detail := aiPredictModel.FormatAiPredictModelFramework2Item(item, itemNodes)
- br.Data = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // Remove
- // @Title 删除框架
- // @Description 删除视频
- // @Param request body aiPredictModel.AiPredictModelFrameworkRemoveReq true "type json string"
- // @Success 200 Ret=200 操作成功
- // @router /framework/remove [post]
- func (c *AiPredictModelFrameworkController) Remove() {
- 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
- }
- // 参数校验
- var req aiPredictModel.AiPredictModelFrameworkRemoveReq
- if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
- return
- }
- if req.AiPredictModelFrameworkId <= 0 {
- br.Msg = "参数有误"
- br.ErrMsg = fmt.Sprintf("参数有误, AiPredictModelFrameworkId: %d", req.AiPredictModelFrameworkId)
- return
- }
- ob := new(aiPredictModel.AiPredictModelFramework)
- item, e := ob.GetItemById(req.AiPredictModelFrameworkId)
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- br.Msg = "操作失败"
- br.ErrMsg = "获取框架失败, Err: " + e.Error()
- return
- }
- if sysUser.RoleTypeCode != utils.ROLE_TYPE_CODE_ADMIN && item.AdminId != sysUser.AdminId {
- br.Msg = "无权操作"
- return
- }
- if e := item.RemoveFrameworkAndNodes(req.AiPredictModelFrameworkId); e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "删除框架失败, Err: " + e.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- br.IsAddLog = true
- }
- // Rename
- // @Title 重命名框架
- // @Description 重命名框架
- // @Param request body aiPredictModel.AiPredictModelFrameworkRenameReq true "type json string"
- // @Success 200 Ret=200 操作成功
- // @router /framework/rename [post]
- func (c *AiPredictModelFrameworkController) Rename() {
- 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
- }
- // 参数校验
- var req aiPredictModel.AiPredictModelFrameworkRenameReq
- if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
- return
- }
- if req.AiPredictModelFrameworkId <= 0 {
- br.Msg = "参数有误"
- br.ErrMsg = fmt.Sprintf("参数有误, AiPredictModelFrameworkId: %d", req.AiPredictModelFrameworkId)
- return
- }
- req.FrameworkName = strings.TrimSpace(req.FrameworkName)
- if req.FrameworkName == "" {
- br.Msg = "框架名称不可为空"
- return
- }
- frameworkOb := new(aiPredictModel.AiPredictModelFramework)
- item, e := frameworkOb.GetItemById(req.AiPredictModelFrameworkId)
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Msg = "框架不存在, 请刷新页面"
- return
- }
- br.Msg = "操作失败"
- br.ErrMsg = "获取框架失败, Err: " + e.Error()
- return
- }
- // 操作权限校验
- if item.AdminId != sysUser.AdminId && !utils.IsAdminRole(sysUser.RoleTypeCode) {
- br.Msg = "您没有权限操作该框架"
- return
- }
- // 重名校验
- {
- ob := new(aiPredictModel.AiPredictModelFramework)
- cond := fmt.Sprintf(` AND %s <> ? AND %s = ? AND %s = ?`, ob.PrimaryId(), aiPredictModel.AiPredictModelFrameworkColumns.FrameworkName, aiPredictModel.AiPredictModelFrameworkColumns.AdminId)
- pars := make([]interface{}, 0)
- pars = append(pars, req.AiPredictModelFrameworkId, req.FrameworkName, sysUser.AdminId)
- exist, e := ob.GetItemByCondition(cond, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "操作失败"
- br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
- return
- }
- if exist != nil {
- br.Msg = "框架名称已存在,请重新输入"
- return
- }
- }
- now := time.Now().Local()
- item.FrameworkName = req.FrameworkName
- item.ModifyTime = now
- updateCols := []string{"FrameworkName", "ModifyTime"}
- if e := item.Update(updateCols); e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "框架重命名失败, Err: " + e.Error()
- return
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
- // Move
- // @Title 移动排序
- // @Description 移动排序
- // @Param request body aiPredictModel.AiPredictModelFrameworkMoveReq true "type json string"
- // @Success 200 Ret=200 操作成功
- // @router /framework/move [post]
- func (c *AiPredictModelFrameworkController) Move() {
- 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
- }
- // 参数校验
- var req aiPredictModel.AiPredictModelFrameworkMoveReq
- if e := json.Unmarshal(c.Ctx.Input.RequestBody, &req); e != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + e.Error()
- return
- }
- if req.AiPredictModelFrameworkId <= 0 {
- br.Msg = "参数有误"
- br.ErrMsg = fmt.Sprintf("参数有误, AiPredictModelFrameworkId: %d", req.AiPredictModelFrameworkId)
- return
- }
- frameworkOb := new(aiPredictModel.AiPredictModelFramework)
- item, e := frameworkOb.GetItemById(req.AiPredictModelFrameworkId)
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Msg = "框架不存在, 请刷新页面"
- return
- }
- br.Msg = "操作失败"
- br.ErrMsg = "获取框架失败, Err: " + e.Error()
- return
- }
- updateCols := make([]string, 0)
- // 上一个兄弟节点
- if req.PrevAiPredictModelFrameworkId > 0 {
- prev, e := frameworkOb.GetItemById(req.PrevAiPredictModelFrameworkId)
- if e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取上一个兄弟节点失败, Err: " + e.Error()
- return
- }
- // 两个兄弟节点之间
- if req.NextAiPredictModelFrameworkId > 0 {
- next, e := frameworkOb.GetItemById(req.PrevAiPredictModelFrameworkId)
- if e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "获取下一个兄弟节点失败, Err: " + e.Error()
- return
- }
- // 如果上一个与下一个排序权重是一致的, 那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2, 自己变成上一个兄弟的排序权重+1
- if prev.Sort == next.Sort || prev.Sort == item.Sort {
- strUpdate := `sort + 2`
- _ = aiPredictModel.UpdateAiPredictModelFrameworkSort(sysUser.AdminId, prev.AiPredictModelFrameworkId, prev.Sort, strUpdate)
- } else {
- // 如果下一个排序权重正好是上一个节点的下一层, 那么需要再加一层了
- if next.Sort-prev.Sort == 1 {
- //变更兄弟节点的排序
- strUpdate := `sort + 1`
- _ = aiPredictModel.UpdateAiPredictModelFrameworkSort(sysUser.AdminId, 0, prev.Sort, strUpdate)
- }
- }
- }
- // 上一个兄弟节点sort+1
- item.Sort = prev.Sort + 1
- item.ModifyTime = time.Now()
- updateCols = append(updateCols, "Sort", "ModifyTime")
- } else {
- first, err := aiPredictModel.GetFirstAiPredictModelFramework()
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "操作失败"
- br.ErrMsg = "获取我的模型框架排首位的数据失败, Err:" + err.Error()
- return
- }
- if first != nil && first.Sort == 0 {
- strUpdate := ` sort + 1 `
- _ = aiPredictModel.UpdateAiPredictModelFrameworkSort(sysUser.AdminId, first.AiPredictModelFrameworkId-1, 0, strUpdate)
- }
- // 排首位
- item.Sort = 0
- item.ModifyTime = time.Now()
- updateCols = append(updateCols, "Sort", "ModifyTime")
- }
- if len(updateCols) > 0 {
- if e := item.Update(updateCols); e != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "更新框架排序失败, Err: " + e.Error()
- return
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
- // Detail
- // @Title 框架详情
- // @Description 框架详情
- // @Param AiPredictModelFrameworkId query int true "框架ID"
- // @Success 200 Ret=200 操作成功
- // @router /framework/detail [get]
- func (c *AiPredictModelFrameworkController) Detail() {
- 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
- }
- frameworkId, _ := c.GetInt("AiPredictModelFrameworkId")
- if frameworkId <= 0 {
- br.Msg = "参数有误"
- br.ErrMsg = fmt.Sprintf("参数有误, AiPredictModelFrameworkId: %d", frameworkId)
- return
- }
- frameworkOb := new(aiPredictModel.AiPredictModelFramework)
- item, e := frameworkOb.GetItemById(frameworkId)
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Msg = "框架不存在, 请刷新页面"
- return
- }
- br.Msg = "获取失败"
- br.ErrMsg = "获取框架失败, Err: " + e.Error()
- return
- }
- // 获取节点
- nodeOb := new(aiPredictModel.AiPredictModelFrameworkNode)
- nodeCond := ` AND ai_predict_model_framework_id = ?`
- nodePars := make([]interface{}, 0)
- nodePars = append(nodePars, frameworkId)
- nodes, e := nodeOb.GetItemsByCondition(nodeCond, nodePars, []string{}, "")
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取框架节点失败, Err: " + e.Error()
- return
- }
- // 模型标的map
- aiPredictModelIndexMap := make(map[int]*aiPredictModel.AiPredictModelIndex)
- {
- aiPredictModelIndexIdList := make([]interface{}, 0)
- for _, v := range nodes {
- if v.AiPredictModelIndexId > 0 {
- aiPredictModelIndexIdList = append(aiPredictModelIndexIdList, v.AiPredictModelIndexId)
- }
- }
- indexIdNum := len(aiPredictModelIndexIdList)
- if indexIdNum > 0 {
- indexObj := aiPredictModel.AiPredictModelIndex{}
- indexList, e := indexObj.GetItemsByCondition(` AND ai_predict_model_index_id in (`+utils.GetOrmInReplace(indexIdNum)+`)`, aiPredictModelIndexIdList, []string{}, "")
- if e != nil {
- if e.Error() == utils.ErrNoRow() {
- br.Msg = "框架不存在, 请刷新页面"
- return
- }
- br.Msg = "获取失败"
- br.ErrMsg = "获取标的列表失败, Err: " + e.Error()
- return
- }
- for _, v := range indexList {
- aiPredictModelIndexMap[v.AiPredictModelIndexId] = v
- }
- }
- }
- // 格式化响应数据
- itemNodes := make([]*aiPredictModel.AiPredictModelFrameworkNodeItem, 0)
- for _, v := range nodes {
- if v.NodeId == "" {
- continue
- }
- num := 1
- itemNodes = append(itemNodes, aiPredictModel.FormatAiPredictModelFrameworkNode2Item(v, num, aiPredictModelIndexMap))
- }
- detail := aiPredictModel.FormatAiPredictModelFramework2Item(item, itemNodes)
- br.Data = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- }
|