public_chart_classify.go 18 KB

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