public_chart_classify.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. package data_manage
  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/models/data_manage/request"
  8. "eta_gn/eta_api/models/system"
  9. "eta_gn/eta_api/services/data"
  10. "eta_gn/eta_api/utils"
  11. "sort"
  12. )
  13. // ChartPublicClassifyController 数据管理-公共分类模块
  14. type ChartPublicClassifyController struct {
  15. controllers.BaseAuthController
  16. }
  17. // SimpleList
  18. // @Title 单层公共分类列表
  19. // @Description 单层公共分类列表
  20. // @Success 200 {object} data_manage.ChartClassifyListResp
  21. // @router /chart_public/classify/simple [get]
  22. func (c *ChartPublicClassifyController) SimpleList() {
  23. br := new(models.BaseResponse).Init()
  24. defer func() {
  25. c.Data["json"] = br
  26. c.ServeJSON()
  27. }()
  28. // 公共分类来源筛选
  29. // 目前只有图库会涉及到公共分类
  30. source := utils.CHART_TYPE_CURVE
  31. // 默认查一级公共分类和一级公共分类下的指标信息,
  32. // 如果是 子级公共分类,查询该子级公共分类的下一级公共分类和指标信息
  33. // 增加标识判断是文件夹还是指标列表
  34. parentId, _ := c.GetInt("ParentId")
  35. chartPublicClassifyObj := data_manage.ChartPublicClassify{}
  36. rootList, err := chartPublicClassifyObj.GetChartClassifyItemsByParentId(parentId, int8(source))
  37. if err != nil && !utils.IsErrNoRow(err) {
  38. br.Msg = "获取失败"
  39. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  40. return
  41. }
  42. nodeAll := make([]*data_manage.ChartClassifyItems, 0)
  43. var sortList data_manage.ChartClassifyItemList
  44. if parentId > 0 {
  45. allChartInfo, err := data_manage.GetChartInfoByPublicClassifyId(parentId, source)
  46. if err != nil {
  47. br.Msg = "获取指标数据失败"
  48. br.ErrMsg = "获取指标数据失败,Err:" + err.Error()
  49. return
  50. }
  51. // 查询当前公共分类信息
  52. for _, v := range allChartInfo {
  53. v.HaveOperaAuth = true
  54. button := data.GetChartOpButton(c.SysUser, v.SysUserId, v.HaveOperaAuth)
  55. button.AddButton = false //不管有没有权限,指标都是没有添加按钮的
  56. v.Button = button
  57. v.Children = make([]*data_manage.ChartClassifyItems, 0)
  58. v.ParentId = parentId
  59. nodeAll = append(nodeAll, v)
  60. }
  61. }
  62. for _, v := range rootList {
  63. // 数据权限
  64. v.HaveOperaAuth = true
  65. // 按钮权限
  66. button := data.GetChartClassifyOpButton(c.SysUser, v.SysUserId, v.HaveOperaAuth)
  67. v.Button = button
  68. v.Children = make([]*data_manage.ChartClassifyItems, 0)
  69. nodeAll = append(nodeAll, v)
  70. }
  71. if len(nodeAll) > 0 {
  72. //根据sort值排序
  73. sortList = nodeAll
  74. sort.Sort(sortList)
  75. }
  76. language := `CN`
  77. // 指标显示的语言
  78. {
  79. configDetail, _ := system.GetConfigDetailByCode(c.SysUser.AdminId, system.ChartLanguageVar)
  80. if configDetail != nil {
  81. language = configDetail.ConfigValue
  82. } else {
  83. configDetail, _ = system.GetDefaultConfigDetailByCode(system.ChartLanguageVar)
  84. if configDetail != nil {
  85. language = configDetail.ConfigValue
  86. }
  87. }
  88. }
  89. // 是否允许添加一级公共分类
  90. canOpClassify := true
  91. button := data.GetChartClassifyOpButton(c.SysUser, 0, true)
  92. if !button.AddButton {
  93. canOpClassify = false
  94. }
  95. resp := new(data_manage.ChartClassifyListResp)
  96. resp.AllNodes = sortList
  97. resp.Language = language
  98. resp.CanOpClassify = canOpClassify
  99. br.Ret = 200
  100. br.Success = true
  101. br.Msg = "获取成功"
  102. br.Data = resp
  103. }
  104. // ClassifyTree
  105. // @Title 多层公共分类列表树
  106. // @Description 多层公共分类列表树
  107. // @Success 200 {object} data_manage.ChartClassifyListResp
  108. // @router /chart_public/classify/tree [get]
  109. func (c *ChartPublicClassifyController) ClassifyTree() {
  110. br := new(models.BaseResponse).Init()
  111. defer func() {
  112. c.Data["json"] = br
  113. c.ServeJSON()
  114. }()
  115. // 公共分类来源筛选
  116. classifyType := utils.CHART_TYPE_CURVE
  117. chartPublicClassifyObj := data_manage.ChartPublicClassify{}
  118. allList, err := chartPublicClassifyObj.GetAllChartClassifyByType(int8(classifyType))
  119. if err != nil && !utils.IsErrNoRow(err) {
  120. br.Msg = "获取失败"
  121. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  122. return
  123. }
  124. var sortList data_manage.ChartClassifyItemList
  125. if len(allList) > 0 {
  126. for k, v := range allList {
  127. // 数据权限
  128. v.HaveOperaAuth = true
  129. // 按钮权限
  130. button := data.GetChartClassifyOpButton(c.SysUser, v.SysUserId, v.HaveOperaAuth)
  131. allList[k].Button = button
  132. }
  133. allList = data.GetChartClassifyTreeRecursive(allList, 0)
  134. //根据sort值排序
  135. sortList = allList
  136. sort.Sort(sortList)
  137. }
  138. language := `CN`
  139. // 是否允许添加一级公共分类
  140. canOpClassify := true
  141. button := data.GetChartClassifyOpButton(c.SysUser, 0, true)
  142. if !button.AddButton {
  143. canOpClassify = false
  144. }
  145. resp := new(data_manage.ChartClassifyListResp)
  146. resp.AllNodes = sortList
  147. resp.Language = language
  148. resp.CanOpClassify = canOpClassify
  149. br.Ret = 200
  150. br.Success = true
  151. br.Msg = "获取成功"
  152. br.Data = resp
  153. }
  154. // AddChartClassify
  155. // @Title 新增公共分类
  156. // @Description 新增公共分类接口
  157. // @Param request body data_manage.AddChartClassifyReq true "type json string"
  158. // @Success 200 Ret=200 保存成功
  159. // @router /chart_public/classify/add [post]
  160. func (c *ChartPublicClassifyController) AddClassify() {
  161. br := new(models.BaseResponse).Init()
  162. defer func() {
  163. c.Data["json"] = br
  164. c.ServeJSON()
  165. }()
  166. var req data_manage.AddChartClassifyReq
  167. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  168. if err != nil {
  169. br.Msg = "参数解析异常!"
  170. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  171. return
  172. }
  173. if req.ChartClassifyName == "" {
  174. br.Msg = "请输入公共分类名称"
  175. br.IsSendEmail = false
  176. return
  177. }
  178. if req.ParentId < 0 {
  179. br.Msg = "参数错误"
  180. br.IsSendEmail = false
  181. return
  182. }
  183. // 公共分类来源筛选
  184. source := utils.CHART_TYPE_CURVE
  185. //添加指标
  186. _, err, errMsg := data.AddChartPublicClassify(req.ChartClassifyName, req.ParentId, source, c.SysUser.AdminId, c.SysUser.RealName)
  187. if errMsg != `` {
  188. br.Msg = errMsg
  189. br.ErrMsg = errMsg
  190. if err != nil {
  191. br.ErrMsg = errMsg + ";Err:" + err.Error()
  192. } else {
  193. br.IsSendEmail = false
  194. }
  195. return
  196. }
  197. //count, err := data_manage.GetChartClassifyCount(req.ClassifyName, req.ParentId)
  198. //if err != nil {
  199. // br.Msg = "判断名称是否已存在失败"
  200. // br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
  201. // return
  202. //}
  203. //if count > 0 {
  204. // br.Msg = "公共分类名称已存在,请重新输入"
  205. // br.IsSendEmail = false
  206. // return
  207. //}
  208. ////获取该层级下最大的排序数
  209. //maxSort, err := data_manage.GetChartClassifyMaxSort(req.ParentId, req.ClassifyType)
  210. //
  211. //classify := new(data_manage.ChartClassify)
  212. //classify.ClassifyType = req.ClassifyType
  213. //classify.ParentId = req.ParentId
  214. //classify.ClassifyName = req.ClassifyName
  215. //classify.HasData = 0
  216. //classify.CreateTime = time.Now()
  217. //classify.ModifyTime = time.Now()
  218. //classify.SysUserId = c.SysUser.AdminId
  219. //classify.SysUserRealName = c.SysUser.RealName
  220. //classify.Level = req.Level + 1
  221. //timestamp := strconv.FormatInt(time.Now().UnixNano(), 10)
  222. //classify.UniqueCode = utils.MD5(utils.DATA_PREFIX + "_" + timestamp)
  223. //classify.Sort = maxSort
  224. //
  225. //_, err = data_manage.AddChartClassify(classify)
  226. //if err != nil {
  227. // br.Msg = "保存公共分类失败"
  228. // br.ErrMsg = "保存公共分类失败,Err:" + err.Error()
  229. // return
  230. //}
  231. br.Ret = 200
  232. br.Msg = "新增成功"
  233. br.Success = true
  234. br.IsAddLog = true
  235. }
  236. // EditChartClassify
  237. // @Title 修改公共分类
  238. // @Description 修改公共分类接口
  239. // @Param request body data_manage.EditChartClassifyReq true "type json string"
  240. // @Success 200 Ret=200 修改成功
  241. // @router /chart_public/classify/edit [post]
  242. func (c *ChartPublicClassifyController) EditChartClassify() {
  243. br := new(models.BaseResponse).Init()
  244. defer func() {
  245. c.Data["json"] = br
  246. c.ServeJSON()
  247. }()
  248. var req data_manage.EditChartClassifyReq
  249. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  250. if err != nil {
  251. br.Msg = "参数解析异常!"
  252. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  253. return
  254. }
  255. if req.ChartClassifyName == "" {
  256. br.Msg = "请输入公共分类名称"
  257. br.IsSendEmail = false
  258. return
  259. }
  260. if req.ChartClassifyId <= 0 {
  261. br.Msg = "请选择指标"
  262. br.IsSendEmail = false
  263. return
  264. }
  265. err, errMsg := data.EditChartPublicClassify(req.ChartClassifyId, req.ChartClassifyName, c.SysUser)
  266. if errMsg != `` {
  267. br.Msg = errMsg
  268. br.ErrMsg = errMsg
  269. if err != nil {
  270. br.ErrMsg = errMsg + ";Err:" + err.Error()
  271. } else {
  272. br.IsSendEmail = false
  273. }
  274. return
  275. }
  276. br.Ret = 200
  277. br.Msg = "修改成功"
  278. br.Success = true
  279. br.IsAddLog = true
  280. }
  281. // DeleteClassifyCheck
  282. // @Title 删除检测接口
  283. // @Description 删除检测接口
  284. // @Param request body request.PublicChartClassifyDeleteCheckReq true "type json string"
  285. // @Success 200 Ret=200 检测成功
  286. // @router /chart_public/classify/delete/check [post]
  287. func (c *ChartPublicClassifyController) DeleteClassifyCheck() {
  288. br := new(models.BaseResponse).Init()
  289. defer func() {
  290. c.Data["json"] = br
  291. c.ServeJSON()
  292. }()
  293. var req request.PublicChartClassifyDeleteCheckReq
  294. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  295. if err != nil {
  296. br.Msg = "参数解析异常!"
  297. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  298. return
  299. }
  300. if req.ChartClassifyId <= 0 {
  301. br.Msg = "参数错误"
  302. br.IsSendEmail = false
  303. return
  304. }
  305. deleteStatus, tipsMsg, _, tableList, err, errMsg := data.DeleteChartPublicClassifyCheck(req.ChartClassifyId, c.SysUser)
  306. if errMsg != `` {
  307. br.Msg = errMsg
  308. br.ErrMsg = errMsg
  309. if err != nil {
  310. br.ErrMsg = err.Error()
  311. } else {
  312. br.IsSendEmail = false
  313. }
  314. return
  315. }
  316. if c.Lang == "en" {
  317. if utils.ViperConfig.InConfig(tipsMsg) {
  318. tipsMsg = utils.ViperConfig.GetString(tipsMsg)
  319. }
  320. }
  321. //var deleteStatus int
  322. //var tipsMsg string
  323. ////删除公共分类
  324. //if req.ClassifyId > 0 && req.ChartInfoId == 0 {
  325. // //判断公共分类下,是否含有指标
  326. // count, err := data_manage.GetChartInfoCountByClassifyId(req.ClassifyId)
  327. // if err != nil {
  328. // br.Msg = "删除失败"
  329. // br.ErrMsg = "公共分类下是否含有指标失败,Err:" + err.Error()
  330. // return
  331. // }
  332. //
  333. // if count > 0 {
  334. // deleteStatus = 1
  335. // tipsMsg = "若目录关联指标不可删除"
  336. // }
  337. //}
  338. //
  339. //if deleteStatus != 1 && req.ChartInfoId == 0 {
  340. // classifyCount, err := data_manage.GetClassifyCountByClassifyId(req.ClassifyId)
  341. // if err != nil && !utils.IsErrNoRow(err) {
  342. // br.Msg = "删除失败"
  343. // br.ErrMsg = "公共分类下是否含有指标失败,Err:" + err.Error()
  344. // return
  345. // }
  346. // if classifyCount > 0 {
  347. // deleteStatus = 2
  348. // tipsMsg = "确认删除当前目录及包含的子目录吗"
  349. // }
  350. //}
  351. //
  352. ////删除指标
  353. //if req.ChartInfoId > 0 {
  354. // //判断指标是否用于作图,如果用于作图,则不可删除
  355. // chartCount, err := data_manage.GetChartChartMappingCount(req.ChartInfoId)
  356. // if err != nil && !utils.IsErrNoRow(err) {
  357. // br.Msg = "删除失败"
  358. // br.ErrMsg = "判断指标是否被用于作图失败,Err:" + err.Error()
  359. // return
  360. // }
  361. // if chartCount > 0 {
  362. // deleteStatus = 3
  363. // tipsMsg = "当前指标已用作画图,不可删除"
  364. // }
  365. // //判断指标是否用于计算
  366. // {
  367. // calculateCount, err := data_manage.GetChartInfoCalculateMappingCount(req.ChartInfoId)
  368. // if err != nil && !utils.IsErrNoRow(err) {
  369. // br.Msg = "删除失败"
  370. // br.ErrMsg = "判断指标是否被用于计算失败,GetChartInfoCalculateCount Err:" + err.Error()
  371. // return
  372. // }
  373. // if calculateCount > 0 {
  374. // deleteStatus = 4
  375. // tipsMsg = "当前指标已用作,指标运算,不可删除"
  376. // }
  377. // }
  378. //}
  379. resp := new(data_manage.ClassifyDeleteCheckResp)
  380. resp.DeleteStatus = deleteStatus
  381. resp.TipsMsg = tipsMsg
  382. resp.TableList = tableList
  383. br.Ret = 200
  384. br.Msg = "检测成功"
  385. br.Success = true
  386. br.Data = resp
  387. }
  388. // DeleteClassify
  389. // @Title 删除公共分类/指标
  390. // @Description 删除公共分类/指标接口
  391. // @Param request body request.PublicChartClassifyDeleteCheckReq true "type json string"
  392. // @Success 200 Ret=200 删除成功
  393. // @router /chart_public/classify/delete [post]
  394. func (c *ChartPublicClassifyController) DeleteClassify() {
  395. br := new(models.BaseResponse).Init()
  396. defer func() {
  397. c.Data["json"] = br
  398. c.ServeJSON()
  399. }()
  400. sysUser := c.SysUser
  401. if sysUser == nil {
  402. br.Msg = "请登录"
  403. br.ErrMsg = "请登录,SysUser Is Empty"
  404. br.Ret = 408
  405. return
  406. }
  407. var req request.PublicChartClassifyDeleteCheckReq
  408. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  409. if err != nil {
  410. br.Msg = "参数解析异常!"
  411. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  412. return
  413. }
  414. if req.ChartClassifyId <= 0 {
  415. br.Msg = "参数错误"
  416. br.IsSendEmail = false
  417. return
  418. }
  419. nextItem, _, err, errMsg := data.DeleteChartPublicClassify(req.ChartClassifyId, sysUser, string(c.Ctx.Input.RequestBody), c.Ctx.Input.URI())
  420. if errMsg != `` {
  421. br.Msg = errMsg
  422. br.ErrMsg = errMsg
  423. if err != nil {
  424. br.ErrMsg = err.Error()
  425. } else {
  426. br.IsSendEmail = false
  427. }
  428. return
  429. }
  430. resp := data_manage.AddChartInfoResp{}
  431. if nextItem != nil {
  432. resp = data_manage.AddChartInfoResp{
  433. ChartInfoId: nextItem.ChartInfoId,
  434. UniqueCode: nextItem.UniqueCode,
  435. }
  436. }
  437. br.Ret = 200
  438. br.Msg = "删除成功"
  439. br.Success = true
  440. br.IsAddLog = true
  441. br.Data = resp
  442. }
  443. // ChartClassifyMove
  444. // @Title 分类移动接口
  445. // @Description 分类移动接口
  446. // @Success 200 {object} data_manage.MoveChartClassifyReq
  447. // @router /chart_public/chart_classify/move [post]
  448. func (c *ChartPublicClassifyController) ChartClassifyMove() {
  449. br := new(models.BaseResponse).Init()
  450. defer func() {
  451. c.Data["json"] = br
  452. c.ServeJSON()
  453. }()
  454. sysUser := c.SysUser
  455. if sysUser == nil {
  456. br.Msg = "请登录"
  457. br.ErrMsg = "请登录,SysUser Is Empty"
  458. br.Ret = 408
  459. return
  460. }
  461. var req data_manage.MoveChartClassifyReq
  462. err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
  463. if err != nil {
  464. br.Msg = "参数解析异常!"
  465. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  466. return
  467. }
  468. if req.ClassifyId <= 0 && req.ChartInfoId <= 0 {
  469. br.Msg = "参数错误"
  470. br.ErrMsg = "请选择拖动目标,分类目录或者指标"
  471. return
  472. }
  473. //if chartClassifyInfo.Source != utils.CHART_SOURCE_DEFAULT {
  474. // br.Msg = "分类异常"
  475. // br.ErrMsg = "分类异常,不是ETA图库的分类"
  476. // return
  477. //}
  478. err, errMsg := data.MoveChartPublicClassify(req, sysUser)
  479. if errMsg != `` {
  480. br.Msg = errMsg
  481. br.ErrMsg = errMsg
  482. if err != nil {
  483. br.ErrMsg = err.Error()
  484. } else {
  485. br.IsSendEmail = false
  486. }
  487. return
  488. }
  489. ////判断分类是否存在
  490. //edbClassifyInfo, err := data_manage.GetEdbClassifyById(req.ClassifyId)
  491. //if err != nil {
  492. // br.Msg = "移动失败"
  493. // br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
  494. // return
  495. //}
  496. //updateCol := make([]string, 0)
  497. //
  498. ////判断上级id是否一致,如果不一致的话,那么需要移动该分类层级
  499. //if edbClassifyInfo.ParentId != req.ParentClassifyId && req.ParentClassifyId != 0 {
  500. // parentEdbClassifyInfo, err := data_manage.GetEdbClassifyById(req.ParentClassifyId)
  501. // if err != nil {
  502. // br.Msg = "移动失败"
  503. // br.ErrMsg = "获取上级分类信息失败,Err:" + err.Error()
  504. // return
  505. // }
  506. // edbClassifyInfo.ParentId = parentEdbClassifyInfo.ClassifyId
  507. // edbClassifyInfo.Level = parentEdbClassifyInfo.Level + 1
  508. // edbClassifyInfo.ModifyTime = time.Now()
  509. // updateCol = append(updateCol, "ParentId", "Level", "ModifyTime")
  510. //}
  511. //
  512. ////如果有传入 上一个兄弟节点分类id
  513. //if req.PrevClassifyId > 0 {
  514. // prevClassify, err := data_manage.GetEdbClassifyById(req.PrevClassifyId)
  515. // if err != nil {
  516. // br.Msg = "移动失败"
  517. // br.ErrMsg = "获取上一个兄弟节点分类信息失败,Err:" + err.Error()
  518. // return
  519. // }
  520. //
  521. // //如果是移动在两个兄弟节点之间
  522. // if req.NextClassifyId > 0 {
  523. // //下一个兄弟节点
  524. // nextClassify, err := data_manage.GetEdbClassifyById(req.NextClassifyId)
  525. // if err != nil {
  526. // br.Msg = "移动失败"
  527. // br.ErrMsg = "获取下一个兄弟节点分类信息失败,Err:" + err.Error()
  528. // return
  529. // }
  530. // //如果上一个兄弟与下一个兄弟的排序权重是一致的,那么需要将下一个兄弟(以及下个兄弟的同样排序权重)的排序权重+2,自己变成上一个兄弟的排序权重+1
  531. // if prevClassify.Sort == nextClassify.Sort || prevClassify.Sort == edbClassifyInfo.Sort {
  532. // //变更兄弟节点的排序
  533. // updateSortStr := `sort + 2`
  534. // _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, prevClassify.ClassifyId, prevClassify.Sort, updateSortStr)
  535. // } else {
  536. // //如果下一个兄弟的排序权重正好是上个兄弟节点的下一层,那么需要再加一层了
  537. // if nextClassify.Sort-prevClassify.Sort == 1 {
  538. // //变更兄弟节点的排序
  539. // updateSortStr := `sort + 1`
  540. // _ = data_manage.UpdateEdbClassifySortByParentId(prevClassify.ParentId, 0, prevClassify.Sort, updateSortStr)
  541. // }
  542. // }
  543. // }
  544. //
  545. // edbClassifyInfo.Sort = prevClassify.Sort + 1
  546. // edbClassifyInfo.ModifyTime = time.Now()
  547. // updateCol = append(updateCol, "Sort", "ModifyTime")
  548. //} else {
  549. // firstClassify, err := data_manage.GetFirstEdbClassifyByParentId(edbClassifyInfo.ParentId)
  550. // if err != nil && !utils.IsErrNoRow(err) {
  551. // br.Msg = "移动失败"
  552. // br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
  553. // return
  554. // }
  555. //
  556. // //如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
  557. // if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
  558. // updateSortStr := ` sort + 1 `
  559. // _ = data_manage.UpdateEdbClassifySortByParentId(firstClassify.ParentId, firstClassify.ClassifyId-1, 0, updateSortStr)
  560. // }
  561. //
  562. // edbClassifyInfo.Sort = 0 //那就是排在第一位
  563. // edbClassifyInfo.ModifyTime = time.Now()
  564. // updateCol = append(updateCol, "Sort", "ModifyTime")
  565. //}
  566. //
  567. ////更新
  568. //if len(updateCol) > 0 {
  569. // err = edbClassifyInfo.Update(updateCol)
  570. // if err != nil {
  571. // br.Msg = "移动失败"
  572. // br.ErrMsg = "修改失败,Err:" + err.Error()
  573. // return
  574. // }
  575. //}
  576. br.Ret = 200
  577. br.Success = true
  578. br.Msg = "移动成功"
  579. }