classify.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. package services
  2. import (
  3. "errors"
  4. "eta_gn/eta_api/models"
  5. "eta_gn/eta_api/models/report_approve"
  6. "eta_gn/eta_api/utils"
  7. "fmt"
  8. "sort"
  9. "time"
  10. )
  11. func MoveReportClassify(req models.ClassifyMoveReq) (err error, errMsg string) {
  12. classifyId := req.ClassifyId
  13. prevClassifyId := req.PrevClassifyId
  14. nextClassifyId := req.NextClassifyId
  15. var (
  16. classifyInfo *models.Classify
  17. prevClassify *models.Classify
  18. nextClassify *models.Classify
  19. prevSort int
  20. nextSort int
  21. )
  22. classifyInfo, err = models.GetClassifyById(classifyId)
  23. if err != nil {
  24. if utils.IsErrNoRow(err) {
  25. errMsg = "分类不存在, 请刷新页面"
  26. err = fmt.Errorf("获取分类信息失败,Err:" + err.Error())
  27. return
  28. }
  29. errMsg = "移动失败"
  30. err = fmt.Errorf("获取分类信息失败,Err:" + err.Error())
  31. return
  32. } else if classifyInfo.Id == 0 {
  33. errMsg = "分类不存在, 请刷新页面"
  34. err = fmt.Errorf("获取分类信息失败,Err:" + err.Error())
  35. return
  36. }
  37. parentClassifyId := classifyInfo.ParentId
  38. if prevClassifyId > 0 {
  39. prevClassify, err = models.GetClassifyById(prevClassifyId)
  40. if err != nil {
  41. if utils.IsErrNoRow(err) {
  42. errMsg = "上一个分类不存在, 请刷新页面"
  43. err = fmt.Errorf("获取分类信息失败,Err:" + err.Error())
  44. return
  45. }
  46. errMsg = "移动失败"
  47. err = fmt.Errorf("获取上一个兄弟节点分类信息失败,Err:" + err.Error())
  48. return
  49. }
  50. if prevClassify.ParentId != parentClassifyId {
  51. errMsg = "禁止拖动到其他节点"
  52. err = fmt.Errorf(errMsg)
  53. return
  54. }
  55. prevSort = prevClassify.Sort
  56. }
  57. if nextClassifyId > 0 {
  58. nextClassify, err = models.GetClassifyById(nextClassifyId)
  59. if err != nil {
  60. if utils.IsErrNoRow(err) {
  61. errMsg = "下一个分类不存在, 请刷新页面"
  62. err = fmt.Errorf("获取分类信息失败,Err:" + err.Error())
  63. return
  64. }
  65. errMsg = "移动失败"
  66. err = fmt.Errorf("获取下一个兄弟节点分类信息失败,Err:" + err.Error())
  67. return
  68. }
  69. if nextClassify.ParentId != parentClassifyId {
  70. errMsg = "禁止拖动到其他节点"
  71. err = fmt.Errorf(errMsg)
  72. return
  73. }
  74. nextSort = nextClassify.Sort
  75. }
  76. err, errMsg = moveReportClassify(classifyInfo, prevClassify, nextClassify, parentClassifyId, prevSort, nextSort)
  77. return
  78. }
  79. func moveReportClassify(classifyInfo, prevClassify, nextClassify *models.Classify, parentId, prevSort, nextSort int) (err error, errMsg string) {
  80. ob := new(models.Classify)
  81. updateCol := make([]string, 0)
  82. if classifyInfo.ParentId != parentId {
  83. errMsg = "移动失败"
  84. err = fmt.Errorf("不支持目录层级变更")
  85. return
  86. }
  87. if prevSort > 0 {
  88. if nextSort > 0 {
  89. if prevSort == nextSort || prevSort == classifyInfo.Sort {
  90. updateSortStr := `sort + 2`
  91. if prevClassify != nil {
  92. _ = models.UpdateClassifySortByParentId(parentId, prevClassify.Id, prevClassify.Sort, updateSortStr)
  93. } else {
  94. _ = models.UpdateClassifySortByParentId(parentId, 0, prevSort, updateSortStr)
  95. }
  96. } else {
  97. if nextSort-prevSort == 1 {
  98. updateSortStr := `sort + 1`
  99. if prevClassify != nil {
  100. _ = models.UpdateClassifySortByParentId(parentId, prevClassify.Id, prevSort, updateSortStr)
  101. } else {
  102. _ = models.UpdateClassifySortByParentId(parentId, 0, prevSort, updateSortStr)
  103. }
  104. }
  105. }
  106. }
  107. classifyInfo.Sort = prevSort + 1
  108. classifyInfo.ModifyTime = time.Now()
  109. updateCol = append(updateCol, "Sort", "ModifyTime")
  110. } else if prevClassify == nil && nextClassify == nil && parentId > 0 {
  111. var maxSort int
  112. maxSort, err = ob.GetMaxSortByParentId(parentId)
  113. if err != nil {
  114. errMsg = "移动失败"
  115. err = fmt.Errorf("查询组内排序信息失败,Err:" + err.Error())
  116. return
  117. }
  118. classifyInfo.Sort = maxSort + 1 //那就是排在组内最后一位
  119. classifyInfo.ModifyTime = time.Now()
  120. updateCol = append(updateCol, "Sort", "ModifyTime")
  121. } else {
  122. firstPermission, tmpErr := ob.GetFirstClassifyByParentId(parentId)
  123. if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
  124. errMsg = "移动失败"
  125. err = fmt.Errorf("获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + tmpErr.Error())
  126. return
  127. }
  128. if firstPermission != nil && firstPermission.Id > 0 && firstPermission.Sort == 0 {
  129. updateSortStr := ` sort + 1 `
  130. _ = models.UpdateClassifySortByParentId(parentId, firstPermission.Id-1, 0, updateSortStr)
  131. }
  132. classifyInfo.Sort = 0 //那就是排在第一位
  133. classifyInfo.ModifyTime = time.Now()
  134. updateCol = append(updateCol, "Sort", "ModifyTime")
  135. }
  136. if len(updateCol) > 0 {
  137. err = classifyInfo.UpdateClassify(updateCol)
  138. if err != nil {
  139. errMsg = "移动失败"
  140. err = fmt.Errorf("修改失败,Err:" + err.Error())
  141. return
  142. }
  143. }
  144. return
  145. }
  146. func AddReportClassify(classifyName string, parentId int, chartPermissionIdList []int) (err error, errMsg string, isSendEmail bool) {
  147. isSendEmail = true
  148. errMsg = `添加失败`
  149. item, err := models.GetClassifyByName(classifyName, parentId)
  150. if err != nil && !utils.IsErrNoRow(err) {
  151. errMsg = "获取分类信息失败"
  152. if utils.IsErrNoRow(err) {
  153. errMsg = "分类名称:" + classifyName + "已存在"
  154. isSendEmail = false
  155. }
  156. return
  157. }
  158. if item != nil && item.Id > 0 {
  159. errMsg = "分类名称:" + classifyName + "已存在"
  160. isSendEmail = false
  161. err = errors.New(errMsg)
  162. return
  163. }
  164. level := 1
  165. var parentClassifyItem *models.Classify
  166. var childClassifyCount int
  167. if parentId > 0 {
  168. parentClassifyItem, err = models.GetClassifyById(parentId)
  169. if err != nil {
  170. errMsg = "获取父级分类信息失败"
  171. if utils.IsErrNoRow(err) {
  172. errMsg = "父级分类不存在"
  173. }
  174. return
  175. }
  176. level = parentClassifyItem.Level + 1
  177. if level > 3 {
  178. errMsg = "分类层级不可超过三级"
  179. isSendEmail = false
  180. return
  181. }
  182. err, errMsg = checkClassifyApprove(parentClassifyItem)
  183. if err != nil {
  184. return
  185. }
  186. childClassifyCount, err = models.GetCountClassifyChildByParentId(parentId)
  187. if err != nil {
  188. errMsg = "获取父级分类的子分类信息失败"
  189. return
  190. }
  191. }
  192. nowTime := time.Now().Local()
  193. classify := new(models.Classify)
  194. maxSort, err := classify.GetMaxSort()
  195. if err != nil {
  196. errMsg = "操作失败"
  197. err = errors.New("查询品种排序失败, Err: " + err.Error())
  198. return
  199. }
  200. classify.ClassifyName = classifyName
  201. classify.ParentId = parentId
  202. classify.CreateTime = nowTime
  203. classify.ModifyTime = nowTime
  204. classify.Sort = maxSort + 1
  205. classify.Enabled = 1
  206. classify.ShowType = 1 //默认列表格式
  207. classify.ReportDetailShowType = 1 //默认列表格式
  208. classify.IsShow = 1
  209. classify.Level = level
  210. err = models.AddClassify(classify)
  211. if err != nil {
  212. return
  213. }
  214. if parentClassifyItem != nil {
  215. parentClassifyItem.HasChild = 1
  216. parentClassifyItem.UpdateClassify([]string{"HasChild"})
  217. if childClassifyCount <= 0 {
  218. tmpErr := inheritReportChapterType(parentId, classify.Id)
  219. if tmpErr != nil {
  220. return
  221. }
  222. go inheritReportApproveFlow(parentClassifyItem, classify)
  223. moveReportByAddClassify(parentClassifyItem, classify)
  224. }
  225. }
  226. return
  227. }
  228. func checkClassifyApprove(currClassify *models.Classify) (err error, errMsg string) {
  229. errMsg = `判断是否有审批流关联失败`
  230. var firstClassifyId, secondClassifyId int
  231. if currClassify.ParentId > 0 {
  232. parentClassifyItem, tmpErr := models.GetClassifyById(currClassify.ParentId)
  233. if tmpErr != nil {
  234. err = tmpErr
  235. errMsg = "获取父级分类信息失败"
  236. if utils.IsErrNoRow(tmpErr) {
  237. errMsg = "父级分类不存在"
  238. }
  239. return
  240. }
  241. firstClassifyId = parentClassifyItem.Id
  242. secondClassifyId = currClassify.Id
  243. } else {
  244. firstClassifyId = currClassify.Id
  245. }
  246. {
  247. flowOb := new(report_approve.ReportApproveFlow)
  248. existCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveFlowCols.ReportType, report_approve.ReportApproveFlowCols.ClassifyFirstId, report_approve.ReportApproveFlowCols.ClassifySecondId, report_approve.ReportApproveFlowCols.ClassifyThirdId)
  249. existPars := make([]interface{}, 0)
  250. existPars = append(existPars, report_approve.FlowReportTypeChinese, firstClassifyId, secondClassifyId, 0)
  251. flowItem, e := flowOb.GetItemByCondition(existCond, existPars, "")
  252. if e != nil {
  253. if !utils.IsErrNoRow(e) {
  254. err = errors.New("获取审批流是否已存在失败, Err: " + e.Error())
  255. return
  256. }
  257. err = nil
  258. return
  259. }
  260. if flowItem == nil {
  261. return
  262. }
  263. approvingOb := new(report_approve.ReportApprove)
  264. approvingCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveCols.FlowId, report_approve.ReportApproveCols.FlowVersion, report_approve.ReportApproveCols.State)
  265. approvingPars := make([]interface{}, 0)
  266. approvingPars = append(approvingPars, flowItem.ReportApproveFlowId, flowItem.CurrVersion, report_approve.ReportApproveStateApproving)
  267. count, e := approvingOb.GetCountByCondition(approvingCond, approvingPars)
  268. if e != nil {
  269. err = errors.New("获取审批流关联进行中的审批数失败. Err: " + e.Error())
  270. return
  271. }
  272. if count > 0 {
  273. errMsg = "当前有未走完流程的报告,请走完流程后再做变更"
  274. err = errors.New(errMsg)
  275. return
  276. }
  277. }
  278. return
  279. }
  280. func moveReportByAddClassify(parentClassifyInfo, currClassifyInfo *models.Classify) (err error) {
  281. defer func() {
  282. if err != nil {
  283. utils.FileLog.Error(fmt.Sprint("历史报告更改分类失败,父级分类ID:", parentClassifyInfo.Id, ";当前分类ID:", currClassifyInfo.Id, ";错误信息:", err.Error()))
  284. }
  285. }()
  286. if currClassifyInfo.Level > 3 {
  287. err = errors.New("父级分类不支持三级分类以上")
  288. return
  289. }
  290. var condition, updateStr string
  291. pars := make([]interface{}, 0)
  292. switch currClassifyInfo.Level {
  293. case 3: // 当前分类是3级分类
  294. updateStr += ` classify_id_third = ?,classify_name_third = ?`
  295. condition += ` AND classify_id_second = ? `
  296. case 2: // 当前分类是2级分类
  297. updateStr += ` classify_id_second = ?,classify_name_second = ?`
  298. condition += ` AND classify_id_first = ? `
  299. default:
  300. err = errors.New("错误的分类层级")
  301. return
  302. }
  303. pars = append(pars, currClassifyInfo.Id, currClassifyInfo.ClassifyName, parentClassifyInfo.Id)
  304. currReportChapterTypeList, err := models.GetAllReportChapterTypeListByClassifyId(currClassifyInfo.Id)
  305. if err != nil {
  306. return
  307. }
  308. chapterTypeIdMap := make(map[int]int)
  309. for _, v := range currReportChapterTypeList {
  310. chapterTypeIdMap[v.ReportChapterTypeId] = v.InheritReportChapterTypeId
  311. }
  312. err = models.ModifyReportClassifyAndReportChapterTypeByCondition(condition, pars, updateStr, chapterTypeIdMap, parentClassifyInfo.Id, currClassifyInfo.Id, currClassifyInfo.ClassifyName)
  313. if err != nil {
  314. return
  315. }
  316. return
  317. }
  318. func inheritReportChapterType(parentClassifyId, currClassifyId int) (err error) {
  319. defer func() {
  320. if err != nil {
  321. utils.FileLog.Error(fmt.Sprint("继承父级分类下的章节类型失败,父级分类ID:", parentClassifyId, ";当前分类ID:", currClassifyId, ";错误信息:", err.Error()))
  322. }
  323. }()
  324. parentReportChapterTypeList, err := models.GetAllReportChapterTypeListByClassifyId(parentClassifyId)
  325. if err != nil {
  326. return
  327. }
  328. if len(parentReportChapterTypeList) <= 0 {
  329. return
  330. }
  331. addList := make([]*models.ReportChapterType, 0)
  332. for _, v := range parentReportChapterTypeList {
  333. addList = append(addList, &models.ReportChapterType{
  334. ReportChapterTypeKey: v.ReportChapterTypeKey,
  335. ReportChapterTypeThumb: v.ReportChapterTypeThumb,
  336. BannerUrl: v.BannerUrl,
  337. ReportChapterTypeName: v.ReportChapterTypeName,
  338. Sort: v.Sort,
  339. Enabled: v.Enabled,
  340. CreatedTime: time.Now(),
  341. LastUpdatedTime: time.Now(),
  342. ResearchType: v.ResearchType,
  343. SelectedImage: v.SelectedImage,
  344. UnselectedImage: v.UnselectedImage,
  345. PcSelectedImage: v.PcSelectedImage,
  346. PcUnselectedImage: v.PcUnselectedImage,
  347. EditImgUrl: v.EditImgUrl,
  348. TickerTitle: v.TickerTitle,
  349. IsShow: v.IsShow,
  350. PauseStartTime: v.PauseStartTime,
  351. PauseEndTime: v.PauseEndTime,
  352. IsSet: v.IsSet,
  353. YbIconUrl: v.YbIconUrl,
  354. YbBottomIcon: v.YbBottomIcon,
  355. ReportClassifyId: currClassifyId,
  356. InheritReportChapterTypeId: v.ReportChapterTypeId,
  357. })
  358. }
  359. obj := models.ReportChapterType{}
  360. err = obj.MultiCreate(addList)
  361. go func() {
  362. var syncReq ChapterTypeSyncReq
  363. _, _ = ReportChapterTypeSync(&syncReq)
  364. }()
  365. return
  366. }
  367. func inheritReportApproveFlow(parentClassifyItem, currClassifyItem *models.Classify) (err error) {
  368. defer func() {
  369. if err != nil {
  370. utils.FileLog.Error(fmt.Sprint("继承父级分类下的审批流失败,父级分类ID:", parentClassifyItem.Id, ";当前分类ID:", currClassifyItem.Id, ";错误信息:", err.Error()))
  371. }
  372. }()
  373. var firstClassify, secondClassify, thirdClassify *models.Classify
  374. if parentClassifyItem.ParentId > 0 {
  375. firstClassify, err = models.GetClassifyById(parentClassifyItem.ParentId)
  376. if err != nil {
  377. return
  378. }
  379. secondClassify = parentClassifyItem
  380. thirdClassify = currClassifyItem
  381. } else {
  382. firstClassify = parentClassifyItem
  383. secondClassify = currClassifyItem
  384. }
  385. flowObj := report_approve.ReportApproveFlow{}
  386. existCond := fmt.Sprintf(` AND %s = ? AND %s = ? `, report_approve.ReportApproveFlowCols.ReportType, report_approve.ReportApproveFlowCols.ClassifyFirstId)
  387. existPars := make([]interface{}, 0)
  388. existPars = append(existPars, report_approve.FlowReportTypeChinese, firstClassify.Id)
  389. if thirdClassify != nil {
  390. existCond = fmt.Sprintf(`%s AND %s = ?`, existCond, report_approve.ReportApproveFlowCols.ClassifySecondId)
  391. existPars = append(existPars, secondClassify.Id)
  392. }
  393. parentFlow, err := flowObj.GetItemByCondition(existCond, existPars, "")
  394. if err != nil {
  395. if utils.IsErrNoRow(err) {
  396. err = nil
  397. }
  398. return
  399. }
  400. nodeObj := report_approve.ReportApproveNode{}
  401. nodeCond := fmt.Sprintf(` AND %s = ? AND %s = ?`, report_approve.ReportApproveNodeCols.ReportApproveFlowId, report_approve.ReportApproveNodeCols.CurrVersion)
  402. nodePars := make([]interface{}, 0)
  403. nodePars = append(nodePars, parentFlow.ReportApproveFlowId, parentFlow.CurrVersion)
  404. parentNodeList, err := nodeObj.GetItemsByCondition(nodeCond, nodePars, []string{}, "")
  405. if err != nil {
  406. return
  407. }
  408. currFlow := &report_approve.ReportApproveFlow{
  409. ReportApproveFlowId: 0,
  410. FlowName: currClassifyItem.ClassifyName,
  411. ReportType: parentFlow.ReportType,
  412. ClassifyFirstId: firstClassify.Id,
  413. ClassifySecondId: secondClassify.Id,
  414. CurrVersion: 1,
  415. Enabled: 1,
  416. CreateTime: time.Now().Local(),
  417. ModifyTime: time.Now().Local(),
  418. }
  419. if thirdClassify != nil {
  420. currFlow.ClassifyThirdId = thirdClassify.Id
  421. }
  422. nodeItems := make([]*report_approve.ReportApproveNode, 0)
  423. for _, v := range parentNodeList {
  424. n := &report_approve.ReportApproveNode{
  425. PrevNodeId: 0,
  426. NextNodeId: 0,
  427. NodeType: v.NodeType,
  428. ApproveType: v.ApproveType,
  429. Users: v.Users,
  430. CurrVersion: 1,
  431. CreateTime: time.Now().Local(),
  432. }
  433. nodeItems = append(nodeItems, n)
  434. }
  435. err = flowObj.CreateFlowAndNodes(currFlow, nodeItems)
  436. if err != nil {
  437. return
  438. }
  439. parentFlow.Enabled = 0
  440. err = parentFlow.Update([]string{"Enabled"})
  441. return
  442. }
  443. func EditReportClassify(classifyId int, classifyName string, chartPermissionIdList []int) (err error, errMsg string, isSendEmail bool) {
  444. isSendEmail = true
  445. errMsg = `修改失败`
  446. item, err := models.GetClassifyById(classifyId)
  447. if err != nil {
  448. errMsg = "获取分类信息失败"
  449. if utils.IsErrNoRow(err) {
  450. errMsg = "分类不存在, 或已被删除"
  451. isSendEmail = false
  452. }
  453. return
  454. }
  455. existName, e := models.GetClassifyByName(classifyName, item.ParentId)
  456. if e != nil && !utils.IsErrNoRow(e) {
  457. errMsg = "获取信息失败"
  458. err = errors.New("获取重名分类失败, Err: " + err.Error())
  459. return
  460. }
  461. if existName != nil && existName.Id > 0 && existName.Id != item.Id {
  462. errMsg = "分类名称:" + classifyName + "已存在"
  463. err = errors.New(errMsg)
  464. isSendEmail = false
  465. return
  466. }
  467. item.ClassifyName = classifyName
  468. item.ModifyTime = time.Now().Local()
  469. cols := make([]string, 0)
  470. cols = append(cols, "ClassifyName", "ModifyTime")
  471. err = item.UpdateClassify(cols)
  472. if err != nil {
  473. return
  474. }
  475. return
  476. }
  477. func GetClassifyTreeRecursive(list []*models.ClassifyItem, parentId int) []*models.ClassifyItem {
  478. res := make([]*models.ClassifyItem, 0)
  479. for _, v := range list {
  480. if v.ParentId == parentId {
  481. v.Child = GetClassifyTreeRecursive(list, v.Id)
  482. res = append(res, v)
  483. }
  484. }
  485. return res
  486. }
  487. func GetParentClassifyListByParentIdList(parentClassifyIdList []int) (list []*models.ClassifyList, err error) {
  488. num := len(parentClassifyIdList)
  489. if num <= 0 {
  490. return
  491. }
  492. list, err = models.GetClassifyListByParentIdList(parentClassifyIdList)
  493. if err != nil {
  494. return
  495. }
  496. {
  497. currParentClassifyIdList := make([]int, 0)
  498. for _, v := range list {
  499. if v.ParentId > 0 {
  500. currParentClassifyIdList = append(currParentClassifyIdList, v.ParentId)
  501. }
  502. }
  503. if len(currParentClassifyIdList) > 0 {
  504. tmpList, tmpErr := GetParentClassifyListByParentIdList(currParentClassifyIdList)
  505. if tmpErr != nil {
  506. err = tmpErr
  507. return
  508. }
  509. list = append(tmpList, list...)
  510. }
  511. }
  512. return
  513. }
  514. func GetClassifyListTreeRecursive(list []*models.ClassifyList, parentId int) []*models.ClassifyList {
  515. res := make([]*models.ClassifyList, 0)
  516. for _, v := range list {
  517. if v.ParentId == parentId {
  518. v.Child = GetClassifyListTreeRecursive(list, v.Id)
  519. res = append(res, v)
  520. }
  521. }
  522. if len(res) <= 0 {
  523. res = nil
  524. }
  525. return res
  526. }
  527. type BySortAndCreateTime []*models.ClassifyList
  528. func (a BySortAndCreateTime) Len() int {
  529. return len(a)
  530. }
  531. func (a BySortAndCreateTime) Swap(i, j int) {
  532. a[i], a[j] = a[j], a[i]
  533. }
  534. func (a BySortAndCreateTime) Less(i, j int) bool {
  535. if a[i].Sort == a[j].Sort {
  536. return a[i].CreateTime.Before(a[j].CreateTime)
  537. }
  538. return a[i].Sort < a[j].Sort
  539. }
  540. func SortClassifyListBySortAndCreateTime(classifyList []*models.ClassifyList) {
  541. sort.Sort(BySortAndCreateTime(classifyList))
  542. }