package data import ( "errors" "eta/eta_api/models/data_manage" "eta/eta_api/utils" "fmt" "github.com/rdlucklib/rdluck_tools/paging" "time" ) func AddClarksonsClassify(classifyName string, parentId int) (ok bool, msg string, err error) { var count int count, err = data_manage.GetBaseFromClarksonsClassifyCount(classifyName, parentId) if err != nil { return } if count > 0 { return false, "分类已存在", nil } sort, err := data_manage.GetChildClarksonsClassifyMaxSortById(parentId) if err != nil { return false, "", err } if parentId > 0 { count, err = data_manage.GetClarksonsClassifyCountById(parentId) if err != nil { return false, "", err } if count == 0 { return false, "", errors.New("父分类不存在") } clarksonsClassify := &data_manage.BaseFromClarksonsClassify{ ClassifyName: classifyName, ParentId: parentId, Level: 2, Sort: sort + 1, ModifyTime: time.Now(), CreateTime: time.Now(), } _, err = clarksonsClassify.Add() if err != nil { return } } else { clarksonsClassify := &data_manage.BaseFromClarksonsClassify{ ClassifyName: classifyName, ParentId: 0, Level: 1, Sort: sort + 1, ModifyTime: time.Now(), CreateTime: time.Now(), } _, er := clarksonsClassify.Add() if er != nil { return false, "", er } } return true, "", nil } func DelClarksonsClassify(classifyId int) (err error) { classify, err := data_manage.GetClarksonsClassifyById(classifyId) if err != nil { return } var classifyIds []int classifyIds = append(classifyIds, classify.BaseFromClassifyId) if classify.ParentId == 0 { tmpClassifyIds, er := data_manage.GetChildClarksonsClassifyIdsById(classify.BaseFromClassifyId) if er != nil { err = er return } classifyIds = append(classifyIds, tmpClassifyIds...) } // 获取分类下的所有指标 count, err := data_manage.GetClarksonsIndexCountByClassifyIds(classifyIds) if err != nil { err = errors.New("获取分类下的指标信息失败,Err:" + err.Error()) return } if count > 0 { err = errors.New("该分类下有指标,不可删除") return } // 删除对应的分类 err = data_manage.DeleteClarksonsClassifyByClassifyId(classifyIds) if err != nil { return } return } // ResetClarksonsIndex 指标数据清除分类接口 func ResetClarksonsIndex(indexId int) (err error) { clarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId) if err != nil { return } // 更新指标在未分类下的排序,永远排在未分类的最后一个 //移动排序 classifyId := 0 updateCol := make([]string, 0) var currentSort, prevSort int currentSort = clarksonsIndex.Sort //未分类的最大的sort值 prevSort, err = data_manage.GetClarksonsIndexMaxSortByClassifyId(classifyId) if err != nil { err = errors.New("获取上一个兄弟节点指标信息失败,Err:" + err.Error()) return } //如果前面一个节点的sort值比当前大,则当前节点往下移动 if prevSort >= currentSort { //往下移动 err = data_manage.MoveDownSciIndexBySort(classifyId, prevSort, currentSort) if err != nil { err = errors.New("向下移动出错:" + err.Error()) return } clarksonsIndex.Sort = prevSort } //更新 clarksonsIndex.ModifyTime = time.Now() clarksonsIndex.ClassifyId = classifyId updateCol = append(updateCol, "Sort", "ModifyTime", "BaseFromClassifyId") err = clarksonsIndex.Update(updateCol) if err != nil { err = errors.New("移动失败,Err:" + err.Error()) return } return } // 批量删除克拉克森指标 func BatchDelClarksonsData(indexIds []int) (existIndex []*data_manage.BaseFromClarksonsIndex, err error) { clarksonsIndexList, err := data_manage.GetClarksonsIndexListByIndexIds(indexIds) if err != nil { return } indexCodes := make([]string, 0) codeToIndex := make(map[string]*data_manage.BaseFromClarksonsIndex) for _, v := range clarksonsIndexList { indexCodes = append(indexCodes, v.IndexCode) codeToIndex[v.IndexCode] = v } edbInfoList, err := data_manage.GetEdbInfoListByEdbCodes(utils.DATA_SOURCE_CLARKSONS, indexCodes) if err != nil { return } deleteIndexIds := make([]int, 0) for _, v := range edbInfoList { if index, ok := codeToIndex[v.EdbCode]; ok { existIndex = append(existIndex, index) delete(codeToIndex, v.EdbCode) } } for _, v := range codeToIndex { deleteIndexIds = append(deleteIndexIds, v.BaseFromClarksonsIndexId) } // 删除对应的指标 err = data_manage.DeleteClarksonsIndexByIds(deleteIndexIds) if err != nil { return } return } // DelClarksonsData 删除克拉克森指标 func DelClarksonsData(indexId int) (err error, errMsg string) { baseFromClarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId) if err != nil { errMsg = `获取数据失败` if err.Error() == utils.ErrNoRow() { errMsg = `该指标未入库` err = nil } return } // 获取已经加入到EDB指标库的clarksons指标 edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_CLARKSONS, baseFromClarksonsIndex.IndexCode) if err != nil && err.Error() != utils.ErrNoRow() { errMsg = "删除失败" err = errors.New("获取分类下的指标信息失败,Err:" + err.Error()) return } if edbInfo != nil { errMsg = "当前指标已被引用,不可删除" err = nil return } // 删除对应的指标 err = data_manage.DeleteClarksonsIndexById(indexId) if err != nil { return } return } // EditClarksonsIndex 编辑克拉克森指标 func EditClarksonsIndex(indexId, classifyId int) (baseFromClarksonsIndex *data_manage.BaseFromClarksonsIndex, errMsg string, err error) { baseFromClarksonsIndex, err = data_manage.GetClarksonsIndexByIndexId(indexId) if err != nil { if err.Error() == utils.ErrNoRow() { errMsg = `该指标未入库` err = nil } return } if classifyId > 0 { classify, e := data_manage.GetClarksonsClassifyById(classifyId) if e != nil { err = e if err.Error() == utils.ErrNoRow() { errMsg = `该分类不存在或已删除` err = nil } return } if classify.Level == 1 { // 顶级分类 errMsg = `不合法的编辑` err = nil return } } maxSort, err := data_manage.GetChildClarksonsClassifyMaxSortById(classifyId) if err != nil { return } baseFromClarksonsIndex.ClassifyId = classifyId baseFromClarksonsIndex.Sort = maxSort + 1 baseFromClarksonsIndex.ModifyTime = time.Now() err = baseFromClarksonsIndex.Update([]string{"classify_id", "sort", "modify_time"}) return } type ClarksonsIndexSource2EdbReq struct { EdbCode string EdbName string Frequency string Unit string ClassifyId int AdminId int AdminRealName string } // ClarksonsIndexSource2Edb 新增克拉克森数据从数据源到指标库 func ClarksonsIndexSource2Edb(req ClarksonsIndexSource2EdbReq, lang string) (edb *data_manage.EdbInfo, errMsg string, skip bool, err error) { if req.EdbCode == "" { err = fmt.Errorf("指标ID为空") return } defer func() { if err != nil { tips := fmt.Sprintf("ClarksonsIndexSource2Edb新增失败, Err: %s", err.Error()) fmt.Println(tips) utils.FileLog.Info(tips) } }() source := utils.DATA_SOURCE_CLARKSONS // 是否新增过指标 exist, e := data_manage.GetEdbInfoByEdbCode(source, req.EdbCode) if e != nil && e.Error() != utils.ErrNoRow() { err = fmt.Errorf("获取指标是否存在失败, err: %s", e.Error()) return } if exist != nil { skip = true return } // 开始结束时间 var startDate, endDate string // 新增指标库 edbInfo, e, msg, _ := EdbInfoAdd(source, utils.DATA_SUB_SOURCE_EDB, req.ClassifyId, req.EdbCode, req.EdbName, req.Frequency, req.Unit, startDate, endDate, req.AdminId, req.AdminRealName, lang) if e != nil { errMsg = msg err = fmt.Errorf("EdbInfo: 新增指标失败, err: %s", e.Error()) return } edb = edbInfo return } // MoveClarksonsClassify 移动克拉克森分类 func MoveClarksonsClassify(classifyId, parentClassifyId, prevClassifyId, nextClassifyId int) (err error, errMsg string) { //判断分类是否存在 classifyInfo, err := data_manage.GetClarksonsClassifyById(classifyId) if err != nil { errMsg = "移动失败" err = errors.New("获取分类信息失败,Err:" + err.Error()) return } updateCol := make([]string, 0) //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级 if classifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 { // 校验移动的父级目录下是否有重名分类 count, e := data_manage.GetBaseFromClarksonsClassifyCount(classifyInfo.ClassifyName, parentClassifyId) if e != nil && e.Error() != utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("获取父级目录下的同名分类失败, Err: " + e.Error()) return } if count > 0 { errMsg = "移动失败,分类名称已存在" err = errors.New("该父级目录下已存在同名分类,请重新命名") return } parentClassifyInfo, tmpErr := data_manage.GetClarksonsClassifyById(parentClassifyId) if tmpErr != nil { errMsg = "移动失败" err = errors.New("获取上级分类信息失败,Err:" + tmpErr.Error()) return } classifyInfo.ParentId = parentClassifyInfo.BaseFromClassifyId classifyInfo.Level = parentClassifyInfo.Level + 1 updateCol = append(updateCol, "ParentId", "Level") } var currentSort, prevSort, nextSort int currentSort = classifyInfo.Sort var prevClassify *data_manage.BaseFromClarksonsClassify var nextClassify *data_manage.BaseFromClarksonsClassify //如果有传入 上一个兄弟节点分类id if prevClassifyId > 0 { prevClassify, err = data_manage.GetClarksonsClassifyById(prevClassifyId) if err != nil { if err.Error() == utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("上一个兄弟节点分类信息不存在" + err.Error()) return } errMsg = "移动失败" err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + err.Error()) return } prevSort = prevClassify.Sort } if nextClassifyId > 0 { //下一个兄弟节点 nextClassify, err = data_manage.GetClarksonsClassifyById(nextClassifyId) if err != nil { if err.Error() == utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("下一个兄弟节点分类信息不存在" + err.Error()) return } errMsg = "移动失败" err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + err.Error()) return } nextSort = nextClassify.Sort } // 修改历史数据中的排序为0的情况 if prevSort == 0 && nextSort == 0 { //目标是让当前分类处于目录的最顶部 //更新为0排序的数据为当前最小排序 if nextClassify != nil { minSort, e := data_manage.GetClarksonsIndexClassifyMinSort(parentClassifyId) if e != nil { errMsg = "移动失败" err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + e.Error()) return } if minSort > 1 { minSort -= 1 } nextClassify.Sort = minSort err = nextClassify.Update([]string{"sort"}) if err != nil { errMsg = "移动失败" err = errors.New("更新下一个兄弟节点分类信息失败,Err:" + err.Error()) return } nextSort = minSort } } //移到两个排序值中间操作 if prevSort >= currentSort { //往下移动 err = data_manage.MoveDownClarksonsIndexClassifyBySort(parentClassifyId, prevSort, currentSort) if err != nil { err = errors.New("向下移动出错:" + err.Error()) return } classifyInfo.Sort = prevSort } else if nextSort <= currentSort && nextSort != 0 { //往上移动 err = data_manage.MoveUpClarksonsIndexClassifyBySort(parentClassifyId, nextSort, currentSort) if err != nil { err = errors.New("向上移动出错:" + err.Error()) return } classifyInfo.Sort = nextSort } classifyInfo.ModifyTime = time.Now() updateCol = append(updateCol, "Sort", "ModifyTime") err = classifyInfo.Update(updateCol) if err != nil { errMsg = "移动失败" err = errors.New("修改失败,Err:" + err.Error()) return } return } // MoveClarksonsData 移动克拉克森指标 func MoveClarksonsData(indexId, classifyId, prevIndexId, nextIndexId int) (err error, errMsg string) { //分类信息 clarksonsIndex, err := data_manage.GetClarksonsIndexByIndexId(indexId) if err != nil { errMsg = `获取数据失败` if err.Error() == utils.ErrNoRow() { errMsg = `该指标未入库` err = nil } return } //判断分类是否存在 if classifyId > 0 { _, err = data_manage.GetClarksonsClassifyById(classifyId) if err != nil { errMsg = "移动失败" err = errors.New("获取分类信息失败,Err:" + err.Error()) if err.Error() == utils.ErrNoRow() { errMsg = "找不到该分类" err = nil } return } } //如果改变了分类,那么移动该图表数据 if clarksonsIndex.ClassifyId != classifyId { tmpErr := data_manage.MoveClarksonsIndex(indexId, classifyId) if tmpErr != nil { errMsg = "移动失败" err = errors.New("移动失败,Err:" + tmpErr.Error()) return } } //移动排序 updateCol := make([]string, 0) var currentSort, prevSort, nextSort int currentSort = clarksonsIndex.Sort //如果有传入 上一个兄弟节点分类id var prevIndex *data_manage.BaseFromClarksonsIndex var nextIndex *data_manage.BaseFromClarksonsIndex if prevIndexId > 0 { prevIndex, err = data_manage.GetClarksonsIndexByIndexId(prevIndexId) if err != nil { if err.Error() == utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("上一个兄弟节点指标信息不存在" + err.Error()) return } errMsg = "移动失败" err = errors.New("获取上一个兄弟节点指标信息失败,Err:" + err.Error()) return } prevSort = prevIndex.Sort } if nextIndexId > 0 { //下一个兄弟节点 nextIndex, err = data_manage.GetClarksonsIndexByIndexId(nextIndexId) if err != nil { if err.Error() == utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("下一个兄弟节点指标信息不存在" + err.Error()) return } errMsg = "移动失败" err = errors.New("获取下一个兄弟节点指标信息失败,Err:" + err.Error()) return } nextSort = nextIndex.Sort } // 修改历史数据中的排序为0的情况 if prevSort == 0 && nextSort == 0 { //目标是让当前分类处于目录的最顶部, 但是历史数据里下个节点的sort为0的情况 //更新为0排序的数据为当前最小排序 if nextIndex != nil { minSort, e := data_manage.GetClarksonsIndexMinSortByClassifyId(classifyId) if e != nil { errMsg = "移动失败" err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + e.Error()) return } if minSort > 1 { minSort -= 1 } nextIndex.Sort = minSort err = nextIndex.Update([]string{"Sort"}) if err != nil { errMsg = "移动失败" err = errors.New("更新下一个兄弟节点分类信息失败,Err:" + err.Error()) return } nextSort = minSort } } //移到两个排序值中间操作 if prevSort >= currentSort { //往下移动 err = data_manage.MoveDownClarksonsIndexBySort(classifyId, prevSort, currentSort) if err != nil { err = errors.New("向下移动出错:" + err.Error()) return } clarksonsIndex.Sort = prevSort } else if nextSort <= currentSort && nextSort != 0 { //往上移动 err = data_manage.MoveUpClarksonsIndexBySort(classifyId, nextSort, currentSort) if err != nil { err = errors.New("向上移动出错:" + err.Error()) return } clarksonsIndex.Sort = nextSort } //更新 clarksonsIndex.ModifyTime = time.Now() updateCol = append(updateCol, "Sort", "ModifyTime") err = clarksonsIndex.Update(updateCol) if err != nil { errMsg = "移动失败" err = errors.New("修改失败,Err:" + err.Error()) return } return } // GetClarksonsIndexInfo 获取指标信息-分页 func GetClarksonsIndexInfo(keyWord string, classifyIdList []string, frequencyList []string, currentIndex, startSize, pageSize int) (rzdIndexInfoList *data_manage.BaseFromRzdIndexPage, err error) { // 获取指标 var condition string var pars []interface{} if keyWord != "" { condition += ` AND (index_name like ? or index_code like ?)` pars = append(pars, "%"+keyWord+"%", "%"+keyWord+"%") } if len(classifyIdList) > 0 { condition += ` AND classify_id IN (` for _, v := range classifyIdList { condition += `?,` pars = append(pars, v) } condition = condition[:len(condition)-1] + `)` } if len(frequencyList) > 0 { condition += ` AND frequency IN (` for _, v := range frequencyList { condition += `?,` pars = append(pars, v) } condition = condition[:len(condition)-1] + `)` } count, err := data_manage.GetClarksonsIndexInfoCount(condition, pars) if err != nil { return nil, err } indexPage := data_manage.BaseFromRzdIndexPage{} page := paging.GetPaging(currentIndex, pageSize, count) if count <= 0 { indexPage.Paging = page return &indexPage, nil } condition += ` ORDER BY base_from_clarksons_index_id asc` // 分页 condition += ` LIMIT ?, ?` pars = append(pars, startSize, pageSize) indexInfoPage, err := data_manage.GetClarksonsIndexInfoPage(condition, pars) if err != nil { return nil, err } var indexCodes []string for _, indexInfo := range indexInfoPage { indexCodes = append(indexCodes, indexInfo.IndexCode) } IndexDataList, err := data_manage.GetClarksonsLastUpdateTimeLastByIndexCode(indexCodes) if err != nil { return nil, err } var indexDataMap = make(map[string]*data_manage.BaseFromClarksonsData, 0) for _, data := range IndexDataList { indexDataMap[data.IndexCode] = data } for _, indexInfo := range indexInfoPage { if indexDataMap[indexInfo.IndexCode] == nil { continue } indexInfo.ModifyTimeMax = indexDataMap[indexInfo.IndexCode].DataTime indexInfo.Value = indexDataMap[indexInfo.IndexCode].Value } indexPage.List = indexInfoPage indexPage.Paging = page return &indexPage, nil } // GetClarkssonsIndexList 获取指标列表 func GetClarkssonsIndexList(searchParams string) (rzdIndexInfoList []*data_manage.BaseFromRzdIndexList, err error) { // 获取指标 var condition string var pars []interface{} if searchParams != "" { condition += ` and index_code like ? or index_name like ?` pars = append(pars, "%"+searchParams+"%", "%"+searchParams+"%") } rzdIndexList, err := data_manage.GetRzdIndex(condition, pars) if err != nil { return nil, err } return rzdIndexList, nil } // MoveClarksonsClassify 移动克拉克森分类 func MoveClarksonsClassifyV2(classifyId, parentClassifyId, prevClassifyId, nextClassifyId int) (err error, errMsg string) { //判断分类是否存在 classifyInfo, err := data_manage.GetClarksonsClassifyById(classifyId) if err != nil { errMsg = "移动失败" err = errors.New("获取分类信息失败,Err:" + err.Error()) return } updateCol := make([]string, 0) //判断上级id是否一致,如果不一致的话,那么需要移动该分类层级 if classifyInfo.ParentId != parentClassifyId && parentClassifyId != 0 { // 校验移动的父级目录下是否有重名分类 count, e := data_manage.GetBaseFromClarksonsClassifyCount(classifyInfo.ClassifyName, parentClassifyId) if e != nil && e.Error() != utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("获取父级目录下的同名分类失败, Err: " + e.Error()) return } if count > 0 { errMsg = "移动失败,分类名称已存在" err = errors.New("该父级目录下已存在同名分类,请重新命名") return } parentClassifyInfo, tmpErr := data_manage.GetClarksonsClassifyById(parentClassifyId) if tmpErr != nil { errMsg = "移动失败" err = errors.New("获取上级分类信息失败,Err:" + tmpErr.Error()) return } classifyInfo.ParentId = parentClassifyInfo.BaseFromClassifyId classifyInfo.Level = parentClassifyInfo.Level + 1 updateCol = append(updateCol, "ParentId", "Level") } //var currentSort, prevSort, nextSort int //currentSort = classifyInfo.Sort var prevClassify *data_manage.BaseFromClarksonsClassify var nextClassify *data_manage.BaseFromClarksonsClassify //如果有传入 上一个兄弟节点分类id if prevClassifyId > 0 { prevClassify, err = data_manage.GetClarksonsClassifyById(prevClassifyId) if err != nil { if err.Error() == utils.ErrNoRow() { errMsg = "移动失败" err = errors.New("上一个兄弟节点分类信息不存在" + err.Error()) return } errMsg = "移动失败" err = errors.New("获取上一个兄弟节点分类信息失败,Err:" + err.Error()) return } //如果是移动在两个兄弟节点之间 if nextClassifyId > 0 { //下一个兄弟节点 nextClassify, err = data_manage.GetClarksonsClassifyById(nextClassifyId) if err != nil { errMsg = "移动失败" err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + err.Error()) return } //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1 if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == classifyInfo.Sort { //变更兄弟节点的排序 updateSortStr := `sort + 2` _ = data_manage.UpdateClarksonsClassifySortByParentId(prevClassify.ParentId, prevClassify.BaseFromClassifyId, prevClassify.Sort, updateSortStr) } else { //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了 if nextClassify.Sort-prevClassify.Sort == 1 { //变更兄弟节点的排序 updateSortStr := `sort + 1` _ = data_manage.UpdateClarksonsClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr) } } } classifyInfo.Sort = prevClassify.Sort + 1 classifyInfo.ModifyTime = time.Now() updateCol = append(updateCol, "Sort", "ModifyTime") } else { firstClassify, e := data_manage.GetFirstClarksonsClassifyByParentId(classifyInfo.ParentId) if e != nil && e.Error() != utils.ErrNoRow() { err = e errMsg = "移动失败" err = errors.New("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()) return } //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序 if firstClassify != nil && firstClassify.Sort == 0 { updateSortStr := ` sort + 1 ` _ = data_manage.UpdateClarksonsClassifySortByParentId(firstClassify.ParentId, firstClassify.ChartClassifyId-1, 0, updateSortStr) } classifyInfo.Sort = 0 //那就是排在第一位 classifyInfo.ModifyTime = time.Now() updateCol = append(updateCol, "Sort", "ModifyTime") } //if nextClassifyId > 0 { // //下一个兄弟节点 // nextClassify, err = data_manage.GetClarksonsClassifyById(nextClassifyId) // if err != nil { // if err.Error() == utils.ErrNoRow() { // errMsg = "移动失败" // err = errors.New("下一个兄弟节点分类信息不存在" + err.Error()) // return // } // errMsg = "移动失败" // err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + err.Error()) // return // } // nextSort = nextClassify.Sort //} // //// 修改历史数据中的排序为0的情况 //if prevSort == 0 && nextSort == 0 { //目标是让当前分类处于目录的最顶部 // //更新为0排序的数据为当前最小排序 // if nextClassify != nil { // minSort, e := data_manage.GetClarksonsIndexClassifyMinSort(parentClassifyId) // if e != nil { // errMsg = "移动失败" // err = errors.New("获取下一个兄弟节点分类信息失败,Err:" + e.Error()) // return // } // if minSort > 1 { // minSort -= 1 // } // nextClassify.Sort = minSort // err = nextClassify.Update([]string{"sort"}) // if err != nil { // errMsg = "移动失败" // err = errors.New("更新下一个兄弟节点分类信息失败,Err:" + err.Error()) // return // } // nextSort = minSort // } //} ////移到两个排序值中间操作 //if prevSort >= currentSort { // //往下移动 // err = data_manage.MoveDownClarksonsIndexClassifyBySort(parentClassifyId, prevSort, currentSort) // if err != nil { // err = errors.New("向下移动出错:" + err.Error()) // return // } // classifyInfo.Sort = prevSort //} else if nextSort <= currentSort && nextSort != 0 { // //往上移动 // err = data_manage.MoveUpClarksonsIndexClassifyBySort(parentClassifyId, nextSort, currentSort) // if err != nil { // err = errors.New("向上移动出错:" + err.Error()) // return // } // classifyInfo.Sort = nextSort //} // //classifyInfo.ModifyTime = time.Now() //updateCol = append(updateCol, "Sort", "ModifyTime") //err = classifyInfo.Update(updateCol) //if err != nil { // errMsg = "移动失败" // err = errors.New("修改失败,Err:" + err.Error()) // return //} //更新 if len(updateCol) > 0 { err = classifyInfo.Update(updateCol) if err != nil { errMsg = "移动失败" err = errors.New("修改失败,Err:" + err.Error()) return } } return }