classify.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. package cross_variety
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_api/controllers"
  5. "eta_gn/eta_api/models"
  6. "eta_gn/eta_api/models/data_manage"
  7. "eta_gn/eta_api/services/data"
  8. "eta_gn/eta_api/utils"
  9. "time"
  10. )
  11. // ClassifyController
  12. // @Description: 跨品种分析分类
  13. type ClassifyController struct {
  14. controllers.BaseAuthController
  15. }
  16. // List
  17. // @Title 跨品种分析分类列表
  18. // @Description 跨品种分析分类列表接口
  19. // @Param IsShowMe query bool true "是否只看我的,true、false"
  20. // @Param Source query int true "图表类型,3:跨品种分析,4:滚动跨品种分析"
  21. // @Success 200 {object} data_manage.ChartClassifyListResp
  22. // @router /classify/list [get]
  23. func (c *ClassifyController) List() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. c.Data["json"] = br
  27. c.ServeJSON()
  28. }()
  29. resp := new(data_manage.ChartClassifyListResp)
  30. // 获取当前账号的不可见指标
  31. noPermissionChartIdMap := make(map[int]bool)
  32. {
  33. obj := data_manage.EdbInfoNoPermissionAdmin{}
  34. confList, err := obj.GetAllChartListByAdminId(c.SysUser.AdminId)
  35. if err != nil && !utils.IsErrNoRow(err) {
  36. br.Msg = "获取失败"
  37. br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
  38. return
  39. }
  40. for _, v := range confList {
  41. noPermissionChartIdMap[v.ChartInfoId] = true
  42. }
  43. }
  44. isShowMe, _ := c.GetBool("IsShowMe")
  45. source, _ := c.GetInt("Source")
  46. if source <= 0 {
  47. source = utils.CHART_SOURCE_CROSS_HEDGING
  48. }
  49. rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_CROSS_HEDGING)
  50. if err != nil && !utils.IsErrNoRow(err) {
  51. br.Msg = "获取失败"
  52. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  53. return
  54. }
  55. allChartInfo, err := data_manage.GetChartInfoAll([]int{source})
  56. if err != nil && !utils.IsErrNoRow(err) {
  57. br.Msg = "获取失败"
  58. br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
  59. return
  60. }
  61. chartInfoMap := make(map[int][]*data_manage.ChartClassifyItems)
  62. for _, v := range allChartInfo {
  63. if !isShowMe {
  64. chartInfoMap[v.ChartClassifyId] = append(chartInfoMap[v.ChartClassifyId], v)
  65. continue
  66. }
  67. if v.SysUserId != c.SysUser.AdminId {
  68. continue
  69. }
  70. chartInfoMap[v.ChartClassifyId] = append(chartInfoMap[v.ChartClassifyId], v)
  71. }
  72. rootChildMap := make(map[int][]*data_manage.ChartClassifyItems)
  73. // 移除没有图表的分类
  74. allNodes := make([]*data_manage.ChartClassifyItems, 0)
  75. for _, v := range rootList {
  76. if v.SysUserId == c.SysUser.AdminId || c.SysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
  77. v.Button.OpButton = true
  78. }
  79. rootChildMap[v.ParentId] = append(rootChildMap[v.ParentId], v)
  80. if existItems, ok := chartInfoMap[v.ChartClassifyId]; ok {
  81. v.Children = existItems
  82. allNodes = append(allNodes, v)
  83. }
  84. }
  85. // 移除没有权限的图表
  86. allNodes = data.HandleNoPermissionChart(allNodes, noPermissionChartIdMap, c.SysUser.AdminId)
  87. resp.AllNodes = allNodes
  88. br.Ret = 200
  89. br.Success = true
  90. br.Msg = "获取成功"
  91. br.Data = resp
  92. }
  93. // EditChartClassify
  94. // @Title 修改跨品种分析图表分类
  95. // @Description 修改跨品种分析图表分类接口
  96. // @Param request body data_manage.EditChartClassifyReq true "type json string"
  97. // @Success 200 Ret=200 修改成功
  98. // @router /classify/edit [post]
  99. func (c *ClassifyController) EditChartClassify() {
  100. br := new(models.BaseResponse).Init()
  101. defer func() {
  102. c.Data["json"] = br
  103. c.ServeJSON()
  104. }()
  105. var req data_manage.EditChartClassifyReq
  106. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  107. if err != nil {
  108. br.Msg = "参数解析异常!"
  109. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  110. return
  111. }
  112. if req.ChartClassifyName == "" {
  113. br.Msg = "请输入分类名称"
  114. br.IsSendEmail = false
  115. return
  116. }
  117. if req.ChartClassifyId <= 0 {
  118. br.Msg = "参数错误"
  119. br.IsSendEmail = false
  120. return
  121. }
  122. // 编辑图表分类
  123. _, err, errMsg, isSendEmail := data.EditChartClassify(req.ChartClassifyId, utils.CHART_SOURCE_CROSS_HEDGING, req.ChartClassifyName, c.Lang, c.SysUser)
  124. if err != nil {
  125. br.Msg = errMsg
  126. br.ErrMsg = "保存分类失败,Err:" + err.Error()
  127. br.IsSendEmail = isSendEmail
  128. return
  129. }
  130. br.Ret = 200
  131. br.Msg = "修改成功"
  132. br.Success = true
  133. br.IsAddLog = true
  134. }
  135. // DeleteChartClassifyCheck
  136. // @Title 删除图表检测接口
  137. // @Description 删除图表检测接口
  138. // @Param request body data_manage.ChartClassifyDeleteCheckResp true "type json string"
  139. // @Success 200 Ret=200 检测成功
  140. // @router /classify/delete/check [post]
  141. func (c *ClassifyController) DeleteChartClassifyCheck() {
  142. br := new(models.BaseResponse).Init()
  143. defer func() {
  144. c.Data["json"] = br
  145. c.ServeJSON()
  146. }()
  147. var req data_manage.ChartClassifyDeleteCheckReq
  148. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  149. if err != nil {
  150. br.Msg = "参数解析异常!"
  151. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  152. return
  153. }
  154. if req.ChartClassifyId < 0 && req.ChartInfoId <= 0 {
  155. br.Msg = "参数错误"
  156. br.IsSendEmail = false
  157. return
  158. }
  159. var deleteStatus int
  160. var tipsMsg string
  161. childIds := make([]int, 0)
  162. //删除分类
  163. if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
  164. //判断跨品种分析图表分类下,是否含有图表
  165. classifyAll, err := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_CROSS_HEDGING)
  166. if err != nil {
  167. br.Msg = "删除失败"
  168. br.ErrMsg = "获取分类数据失败,Err:" + err.Error()
  169. return
  170. }
  171. classifyAllMap := make(map[int]*data_manage.ChartClassifyItems)
  172. for _, v := range classifyAll {
  173. classifyAllMap[v.ChartClassifyId] = v
  174. }
  175. data.GetChartClassifyChildIds(req.ChartClassifyId, classifyAllMap, &childIds)
  176. condition := ``
  177. pars := make([]interface{}, 0)
  178. if len(childIds) > 0 {
  179. ids := utils.IntArr2joinString(childIds, ",")
  180. condition = ` AND chart_classify_id IN (` + ids + `) `
  181. } else {
  182. condition = ` AND chart_classify_id = ? `
  183. pars = append(pars, req.ChartClassifyId)
  184. }
  185. count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
  186. if err != nil {
  187. br.Msg = "判断图表名称是否存在失败"
  188. br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
  189. return
  190. }
  191. //count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
  192. //if err != nil {
  193. // br.Msg = "删除失败"
  194. // br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
  195. // return
  196. //}
  197. if count > 0 {
  198. deleteStatus = 1
  199. tipsMsg = "该分类下关联图表不可删除"
  200. }
  201. }
  202. if deleteStatus != 1 && req.ChartInfoId == 0 {
  203. //classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
  204. //if err != nil && !utils.IsErrNoRow(err) {
  205. // br.Msg = "删除失败"
  206. // br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
  207. // return
  208. //}
  209. if len(childIds) > 0 {
  210. deleteStatus = 2
  211. tipsMsg = "确认删除当前目录及包含的子目录吗"
  212. }
  213. }
  214. if deleteStatus == 0 {
  215. tipsMsg = "可删除,进行删除操作"
  216. }
  217. resp := new(data_manage.ChartClassifyDeleteCheckResp)
  218. resp.DeleteStatus = deleteStatus
  219. resp.TipsMsg = tipsMsg
  220. br.Ret = 200
  221. br.Msg = "检测成功"
  222. br.Success = true
  223. br.Data = resp
  224. }
  225. // DeleteChartClassify
  226. // @Title 删除跨品种分析图表分类/图表
  227. // @Description 删除跨品种分析图表分类/图表接口
  228. // @Param request body data_manage.DeleteChartClassifyReq true "type json string"
  229. // @Success 200 Ret=200 删除成功
  230. // @router /classify/delete [post]
  231. func (c *ClassifyController) DeleteChartClassify() {
  232. br := new(models.BaseResponse).Init()
  233. defer func() {
  234. c.Data["json"] = br
  235. c.ServeJSON()
  236. }()
  237. sysUser := c.SysUser
  238. if sysUser == nil {
  239. br.Msg = "请登录"
  240. br.ErrMsg = "请登录,SysUser Is Empty"
  241. br.Ret = 408
  242. return
  243. }
  244. var req data_manage.DeleteChartClassifyReq
  245. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  246. if err != nil {
  247. br.Msg = "参数解析异常!"
  248. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  249. return
  250. }
  251. if req.ChartClassifyId < 0 && req.ChartInfoId <= 0 {
  252. br.Msg = "参数错误"
  253. br.IsSendEmail = false
  254. return
  255. }
  256. //删除分类
  257. if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
  258. //判断是否含有指标
  259. childIds := make([]int, 0)
  260. classifyAll, err := data_manage.GetChartClassifyAllBySource(utils.CHART_SOURCE_CROSS_HEDGING)
  261. if err != nil {
  262. br.Msg = "删除失败"
  263. br.ErrMsg = "获取分类数据失败,Err:" + err.Error()
  264. return
  265. }
  266. classifyAllMap := make(map[int]*data_manage.ChartClassifyItems)
  267. for _, v := range classifyAll {
  268. classifyAllMap[v.ChartClassifyId] = v
  269. }
  270. data.GetChartClassifyChildIds(req.ChartClassifyId, classifyAllMap, &childIds)
  271. condition := ``
  272. pars := make([]interface{}, 0)
  273. if len(childIds) > 0 {
  274. ids := utils.IntArr2joinString(childIds, ",")
  275. condition = ` AND chart_classify_id IN (` + ids + `) `
  276. } else {
  277. condition = ` AND chart_classify_id = ? `
  278. pars = append(pars, req.ChartClassifyId)
  279. }
  280. count, err := data_manage.GetChartInfoCountByCondition(condition, pars)
  281. if err != nil {
  282. br.Msg = "判断图表名称是否存在失败"
  283. br.ErrMsg = "判断图表名称是否存在失败,Err:" + err.Error()
  284. return
  285. }
  286. //count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
  287. //if err != nil && !utils.IsErrNoRow(err) {
  288. // br.Msg = "删除失败"
  289. // br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
  290. // return
  291. //}
  292. if count > 0 {
  293. br.Msg = "该目录下存在关联指标,不可删除"
  294. br.IsSendEmail = false
  295. return
  296. }
  297. delIds := append(childIds, req.ChartClassifyId)
  298. err = data_manage.DeleteChartClassifyByIds(delIds)
  299. //err = data_manage.DeleteChartClassify(req.ChartClassifyId)
  300. if err != nil {
  301. br.Msg = "删除失败"
  302. br.ErrMsg = "删除失败,Err:" + err.Error()
  303. return
  304. }
  305. }
  306. resp := new(data_manage.AddChartInfoResp)
  307. //删除图表
  308. if req.ChartInfoId > 0 {
  309. chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
  310. if err != nil {
  311. if utils.IsErrNoRow(err) {
  312. br.Msg = "图表已删除,请刷新页面"
  313. br.ErrMsg = "指标不存在,Err:" + err.Error()
  314. return
  315. } else {
  316. br.Msg = "删除失败"
  317. br.ErrMsg = "删除失败,获取指标信息失败,Err:" + err.Error()
  318. return
  319. }
  320. }
  321. if chartInfo == nil {
  322. br.Msg = "图表已删除,请刷新页面"
  323. return
  324. }
  325. //图表操作权限
  326. ok := data.CheckOpChartPermission(sysUser, chartInfo.SysUserId, true)
  327. if !ok {
  328. br.Msg = "没有该图表的操作权限"
  329. br.ErrMsg = "没有该图表的操作权限"
  330. return
  331. }
  332. // 获取引用该图表的MyCharts, 用于ES删除
  333. var myCond string
  334. var myPars []interface{}
  335. myCond += ` AND a.chart_info_id = ? `
  336. myPars = append(myPars, chartInfo.ChartInfoId)
  337. myCharts, e := data_manage.GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition(myCond, myPars)
  338. if e != nil {
  339. br.Msg = "删除失败"
  340. br.ErrMsg = "获取引用图表的MyChats失败, Err: " + e.Error()
  341. return
  342. }
  343. myIds := make([]int, 0)
  344. for _, m := range myCharts {
  345. myIds = append(myIds, m.MyChartId)
  346. }
  347. source := chartInfo.Source // 跨品种分析图表(滚动跨品种分析)
  348. //删除图表及关联指标
  349. err = data_manage.DeleteChartInfoAndData(chartInfo.ChartInfoId)
  350. if err != nil {
  351. br.Msg = "删除失败"
  352. br.ErrMsg = "删除失败,Err:" + err.Error()
  353. return
  354. }
  355. //删除ES
  356. {
  357. go data.EsDeleteChartInfo(chartInfo.ChartInfoId)
  358. // 删除MY ETA 图表 es数据
  359. //go data.EsDeleteMyChartInfoByChartInfoId(chartInfo.ChartInfoId)
  360. go data.EsDeleteMyChartInfoByMyChartIds(myIds)
  361. }
  362. var condition string
  363. var pars []interface{}
  364. condition += " AND chart_classify_id=? AND source = ? "
  365. pars = append(pars, chartInfo.ChartClassifyId, source)
  366. condition += " AND chart_info_id>? ORDER BY create_time ASC LIMIT 1 "
  367. pars = append(pars, req.ChartInfoId)
  368. nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
  369. if err != nil && !utils.IsErrNoRow(err) {
  370. br.Msg = "删除失败"
  371. br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
  372. return
  373. }
  374. if nextItem != nil {
  375. resp.UniqueCode = nextItem.UniqueCode
  376. resp.ChartInfoId = nextItem.ChartInfoId
  377. } else {
  378. var condition string
  379. var pars []interface{}
  380. condition += " AND level=1 "
  381. //pars = append(pars, chartInfo.ChartClassifyId)
  382. condition += " AND chart_classify_id>? ORDER BY chart_classify_id ASC LIMIT 1 "
  383. pars = append(pars, chartInfo.ChartClassifyId)
  384. classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
  385. if err != nil && !utils.IsErrNoRow(err) {
  386. br.Msg = "删除失败"
  387. br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
  388. return
  389. }
  390. if classifyItem != nil {
  391. nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
  392. if err != nil && !utils.IsErrNoRow(err) {
  393. br.Msg = "删除失败"
  394. br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
  395. return
  396. }
  397. if nextItem != nil {
  398. resp.UniqueCode = nextItem.UniqueCode
  399. resp.ChartInfoId = nextItem.ChartInfoId
  400. }
  401. }
  402. }
  403. //新增操作日志
  404. {
  405. chartLog := new(data_manage.ChartInfoLog)
  406. chartLog.ChartName = chartInfo.ChartName
  407. chartLog.ChartInfoId = req.ChartInfoId
  408. chartLog.ChartClassifyId = chartInfo.ChartClassifyId
  409. chartLog.SysUserId = sysUser.AdminId
  410. chartLog.SysUserRealName = sysUser.RealName
  411. chartLog.UniqueCode = chartInfo.UniqueCode
  412. chartLog.CreateTime = time.Now()
  413. chartLog.Content = string(c.Ctx.Input.RequestBody)
  414. chartLog.Status = "删除图表"
  415. chartLog.Method = c.Ctx.Input.URI()
  416. go data_manage.AddChartInfoLog(chartLog)
  417. }
  418. }
  419. br.Ret = 200
  420. br.Msg = "删除成功"
  421. br.Success = true
  422. br.Data = resp
  423. br.IsAddLog = true
  424. }
  425. // ChartClassifyMove
  426. // @Title 相关性图表分类移动接口
  427. // @Description 相关性图表分类移动接口
  428. // @Success 200 {object} data_manage.MoveChartClassifyReq
  429. // @router /classify/move [post]
  430. func (c *ClassifyController) ChartClassifyMove() {
  431. br := new(models.BaseResponse).Init()
  432. defer func() {
  433. c.Data["json"] = br
  434. c.ServeJSON()
  435. }()
  436. sysUser := c.SysUser
  437. if sysUser == nil {
  438. br.Msg = "请登录"
  439. br.ErrMsg = "请登录,SysUser Is Empty"
  440. br.Ret = 408
  441. return
  442. }
  443. var req data_manage.MoveChartClassifyReq
  444. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  445. if err != nil {
  446. br.Msg = "参数解析异常!"
  447. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  448. return
  449. }
  450. if req.ClassifyId <= 0 {
  451. br.Msg = "参数错误"
  452. br.ErrMsg = "分类id小于等于0"
  453. return
  454. }
  455. //判断分类是否存在
  456. chartClassifyInfo, err := data_manage.GetChartClassifyById(req.ClassifyId)
  457. if err != nil {
  458. br.Msg = "移动失败"
  459. br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
  460. return
  461. }
  462. if chartClassifyInfo.Source != utils.CHART_SOURCE_CROSS_HEDGING {
  463. br.Msg = "分类异常"
  464. br.ErrMsg = "分类异常,不是跨品种分析图表的分类"
  465. return
  466. }
  467. updateCol := make([]string, 0)
  468. //如果有传入 上一个兄弟节点分类id
  469. if req.PrevClassifyId > 0 {
  470. //上一个兄弟节点
  471. prevClassify, err := data_manage.GetChartClassifyById(req.PrevClassifyId)
  472. if err != nil {
  473. br.Msg = "移动失败"
  474. br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
  475. return
  476. }
  477. if prevClassify.Source != utils.CHART_SOURCE_CROSS_HEDGING {
  478. br.Msg = "上级节点分类异常"
  479. br.ErrMsg = "上级节点分类异常,不是跨品种分析图表的分类"
  480. return
  481. }
  482. //如果是移动在两个兄弟节点之间
  483. if req.NextClassifyId > 0 {
  484. //下一个兄弟节点
  485. nextClassify, err := data_manage.GetChartClassifyById(req.NextClassifyId)
  486. if err != nil {
  487. br.Msg = "移动失败"
  488. br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
  489. return
  490. }
  491. //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  492. if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == chartClassifyInfo.Sort {
  493. //变更兄弟节点的排序
  494. updateSortStr := `sort + 2`
  495. _ = data_manage.UpdateChartClassifySortByParentId(prevClassify.ParentId, prevClassify.ChartClassifyId, prevClassify.Sort, updateSortStr)
  496. } else {
  497. //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  498. if nextClassify.Sort-prevClassify.Sort == 1 {
  499. //变更兄弟节点的排序
  500. updateSortStr := `sort + 1`
  501. _ = data_manage.UpdateChartClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
  502. }
  503. }
  504. }
  505. chartClassifyInfo.Sort = prevClassify.Sort + 1
  506. chartClassifyInfo.ModifyTime = time.Now()
  507. updateCol = append(updateCol, "Sort", "ModifyTime")
  508. } else {
  509. firstClassify, err := data_manage.GetFirstChartClassifyByParentIdAndSource(chartClassifyInfo.ParentId, chartClassifyInfo.Source)
  510. if err != nil && !utils.IsErrNoRow(err) {
  511. br.Msg = "移动失败"
  512. br.ErrMsg = "获取跨品种分析图表分类排序第一条的分类信息失败,Err:" + err.Error()
  513. return
  514. }
  515. if firstClassify != nil && firstClassify.Source != utils.CHART_SOURCE_CROSS_HEDGING {
  516. br.Msg = "上级节点分类异常"
  517. br.ErrMsg = "上级节点分类异常,不是跨品种分析图表的分类"
  518. return
  519. }
  520. //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  521. if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
  522. updateSortStr := ` sort + 1 `
  523. _ = data_manage.UpdateChartClassifySortByParentId(firstClassify.ParentId, firstClassify.ChartClassifyId-1, 0, updateSortStr)
  524. }
  525. chartClassifyInfo.Sort = 0 //那就是排在第一位
  526. chartClassifyInfo.ModifyTime = time.Now()
  527. updateCol = append(updateCol, "Sort", "ModifyTime")
  528. }
  529. //更新
  530. if len(updateCol) > 0 {
  531. err = chartClassifyInfo.Update(updateCol)
  532. if err != nil {
  533. br.Msg = "移动失败"
  534. br.ErrMsg = "修改失败,Err:" + err.Error()
  535. return
  536. }
  537. }
  538. br.Ret = 200
  539. br.Success = true
  540. br.Msg = "移动成功"
  541. }