Browse Source

合并冲突

kobe6258 1 week ago
parent
commit
efaed8f35e
100 changed files with 3073 additions and 936 deletions
  1. 53 0
      cache/wechat_platform.go
  2. 4 4
      controllers/ai/ai.go
  3. 3 3
      controllers/ai/ai_file.go
  4. 4 4
      controllers/ai/ai_pormpt.go
  5. 18 18
      controllers/ai/ai_summary.go
  6. 2 2
      controllers/base_auth.go
  7. 7 7
      controllers/bi_dashboard.go
  8. 2 2
      controllers/business_conf.go
  9. 4 3
      controllers/classify.go
  10. 4 4
      controllers/cloud_disk.go
  11. 2 2
      controllers/commodity_trade_base_index.go
  12. 4 4
      controllers/company_seller.go
  13. 4 4
      controllers/data_manage/ai_predict_model/classify.go
  14. 14 14
      controllers/data_manage/ai_predict_model/framework.go
  15. 7 7
      controllers/data_manage/ai_predict_model/index.go
  16. 5 5
      controllers/data_manage/baiinfo_data.go
  17. 3 2
      controllers/data_manage/base_from_ly_index_controller.go
  18. 1 1
      controllers/data_manage/base_from_rzd_index_controller.go
  19. 4 4
      controllers/data_manage/base_from_ths_hf.go
  20. 2 2
      controllers/data_manage/base_from_ths_hf_classify.go
  21. 2 2
      controllers/data_manage/business_data.go
  22. 2 2
      controllers/data_manage/ccf_data.go
  23. 24 24
      controllers/data_manage/chart_classify.go
  24. 1 1
      controllers/data_manage/chart_common.go
  25. 2 2
      controllers/data_manage/chart_edb_config.go
  26. 13 13
      controllers/data_manage/chart_framework.go
  27. 51 55
      controllers/data_manage/chart_info.go
  28. 4 4
      controllers/data_manage/chart_theme.go
  29. 8 8
      controllers/data_manage/clarksons_data.go
  30. 5 5
      controllers/data_manage/com_trade.go
  31. 10 10
      controllers/data_manage/correlation/correlation_chart_classify.go
  32. 28 28
      controllers/data_manage/correlation/correlation_chart_info.go
  33. 22 22
      controllers/data_manage/cross_variety/chart_info.go
  34. 10 10
      controllers/data_manage/cross_variety/classify.go
  35. 5 5
      controllers/data_manage/cross_variety/tag.go
  36. 5 5
      controllers/data_manage/cross_variety/variety.go
  37. 2 2
      controllers/data_manage/data_manage_permission/message.go
  38. 18 18
      controllers/data_manage/edb_classify.go
  39. 116 118
      controllers/data_manage/edb_info.go
  40. 12 7
      controllers/data_manage/edb_info_calculate.go
  41. 11 11
      controllers/data_manage/edb_info_refresh.go
  42. 8 8
      controllers/data_manage/edb_info_relation.go
  43. 2 2
      controllers/data_manage/eia_steo.go
  44. 7 7
      controllers/data_manage/excel/balance_table.go
  45. 9 9
      controllers/data_manage/excel/custom_analysis.go
  46. 1 1
      controllers/data_manage/excel/custom_analysis_edb.go
  47. 15 15
      controllers/data_manage/excel/excel_classify.go
  48. 21 21
      controllers/data_manage/excel/excel_info.go
  49. 2 2
      controllers/data_manage/factor_edb_series.go
  50. 1 1
      controllers/data_manage/fenwei_data.go
  51. 15 0
      controllers/data_manage/fix.go
  52. 12 12
      controllers/data_manage/future_good/future_good_chart_classify.go
  53. 38 38
      controllers/data_manage/future_good/future_good_chart_info.go
  54. 6 6
      controllers/data_manage/future_good/future_good_edb_info.go
  55. 9 9
      controllers/data_manage/future_good/future_good_profit_chart_info.go
  56. 7 7
      controllers/data_manage/gpr_risk_data.go
  57. 12 12
      controllers/data_manage/line_equation/line_chart_classify.go
  58. 21 21
      controllers/data_manage/line_equation/line_chart_info.go
  59. 43 39
      controllers/data_manage/line_feature/chart_info.go
  60. 12 12
      controllers/data_manage/line_feature/classify.go
  61. 11 13
      controllers/data_manage/manual.go
  62. 17 10
      controllers/data_manage/multiple_graph_config.go
  63. 41 45
      controllers/data_manage/my_chart.go
  64. 6 6
      controllers/data_manage/mysteel_chemical_data.go
  65. 3 3
      controllers/data_manage/predict_edb_classify.go
  66. 16 20
      controllers/data_manage/predict_edb_info.go
  67. 12 12
      controllers/data_manage/range_analysis/chart_classify.go
  68. 21 21
      controllers/data_manage/range_analysis/chart_info.go
  69. 5 5
      controllers/data_manage/sci_data.go
  70. 7 7
      controllers/data_manage/sci_hq_data.go
  71. 4 4
      controllers/data_manage/smm_data.go
  72. 8 8
      controllers/data_manage/supply_analysis/variety.go
  73. 6 6
      controllers/data_manage/supply_analysis/variety_edb.go
  74. 8 8
      controllers/data_manage/supply_analysis/variety_plant.go
  75. 6 6
      controllers/data_manage/usda_fas_data.go
  76. 7 7
      controllers/data_manage/wind_data.go
  77. 10 8
      controllers/data_manage/yongyi_data.go
  78. 14 1
      controllers/data_source/data_source.go
  79. 7 8
      controllers/data_source/sci99.go
  80. 7 6
      controllers/data_stat/edb_source_stat.go
  81. 5 3
      controllers/document_manage/document_manage_controller.go
  82. 14 2
      controllers/english_report/email.go
  83. 5 5
      controllers/english_report/en_permission.go
  84. 8 8
      controllers/english_report/english_classify.go
  85. 3 3
      controllers/english_report/english_company.go
  86. 2 2
      controllers/english_report/english_company_todo.go
  87. 5 5
      controllers/english_report/english_video.go
  88. 1 1
      controllers/english_report/policy_report.go
  89. 10 10
      controllers/english_report/report.go
  90. 1 1
      controllers/eta_trial/questionnaire.go
  91. 12 10
      controllers/hisugar_data.go
  92. 420 0
      controllers/llm/abstract.go
  93. 186 0
      controllers/llm/chat_ws_controller.go
  94. 51 0
      controllers/llm/kb_controller.go
  95. 20 0
      controllers/llm/llm_http/request.go
  96. 17 0
      controllers/llm/llm_http/response.go
  97. 233 0
      controllers/llm/question.go
  98. 332 0
      controllers/llm/user_chat_controller.go
  99. 777 0
      controllers/llm/wechat_platform.go
  100. 16 16
      controllers/material/material.go

+ 53 - 0
cache/wechat_platform.go

@@ -0,0 +1,53 @@
+package cache
+
+import (
+	"eta/eta_api/utils"
+	"fmt"
+)
+
+type WechatArticleOp struct {
+	Source           string
+	WechatPlatformId int
+}
+
+// AddWechatArticleOpToCache
+// @Description: 将公众号文章操作加入缓存
+// @param wechatPlatformId
+// @param source
+// @return bool
+func AddWechatArticleOpToCache(wechatPlatformId int, source string) bool {
+	record := new(WechatArticleOp)
+	record.Source = source
+	record.WechatPlatformId = wechatPlatformId
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CACHE_WECHAT_PLATFORM_ARTICLE, record)
+
+		utils.FileLog.Info(fmt.Sprintf("将公众号文章操作 加入缓存 AddWechatArticleOpToCache LPush: 操作类型:%s,公众号id:%d", source, wechatPlatformId))
+		if err != nil {
+			fmt.Println("AddWechatArticleOpToCache LPush Err:" + err.Error())
+		}
+		return true
+	}
+	return false
+}
+
+// AddWechatArticleLlmOpToCache
+// @Description: 将公众号文章llm操作加入缓存
+// @param wechatPlatformId
+// @param source
+// @return bool
+func AddWechatArticleLlmOpToCache(wechatPlatformId int, source string) bool {
+	record := new(WechatArticleOp)
+	record.Source = source
+	record.WechatPlatformId = wechatPlatformId
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CACHE_WECHAT_PLATFORM_ARTICLE_KNOWLEDGE, record)
+
+		utils.FileLog.Info(fmt.Sprintf("将公众号文章llm操作加入缓存 加入缓存 AddWechatArticleLlmOpToCache LPush: 操作类型:%s,公众号id:%d", source, wechatPlatformId))
+		if err != nil {
+			fmt.Println("AddWechatArticleOpToCache LPush Err:" + err.Error())
+		}
+		return true
+	}
+	return false
+}

+ 4 - 4
controllers/ai/ai.go

@@ -71,7 +71,7 @@ func (this *AiController) List() {
 	//根据提问,获取信息
 	askUuid := utils.MD5(req.Ask)
 	chatMode, err := aimod.GetAiChatByAsk(askUuid)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取数据失败!"
 		br.ErrMsg = "获取数据失败,GetAiChatByAsk,Err:" + err.Error()
 		return
@@ -88,7 +88,7 @@ func (this *AiController) List() {
 		//获取主题下的所有信息
 		//AiChatTopicId
 		historyList, err := aimod.GetAiChatList(req.AiChatTopicId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取主题历史数据失败!"
 			br.ErrMsg = "获取主题历史数据失败,Err:" + err.Error()
 			return
@@ -317,12 +317,12 @@ func (this *AiController) TopicEdit() {
 		return
 	}
 	topic, err := aimod.GetAiChatTopicByTopicName(req.TopicName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "编辑失败!"
 		br.ErrMsg = "获取数据失败!Err:" + err.Error()
 		return
 	}
-	if topic != nil && topic.AiChatTopicId != req.AiChatTopicId {
+	if topic != nil && topic.AiChatTopicId != req.AiChatTopicId && topic.AiChatTopicId > 0 {
 		br.Msg = "话题名称已存在,请重新修改!"
 		return
 	}

+ 3 - 3
controllers/ai/ai_file.go

@@ -110,7 +110,7 @@ func (this *AiFileController) FileUpload() {
 		aiChatTopicObj.AiChatTopicId = aiChatTopicId
 		topic, err := aiChatTopicObj.GetAiChatTopicById()
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "获取数据失败!"
 				br.ErrMsg = "获取数据失败,主题不存在,Err:" + err.Error()
 				return
@@ -283,7 +283,7 @@ func (this *AiFileController) FileRetrieve() {
 		aiChatTopicObj.AiChatTopicId = req.AiChatTopicId
 		topic, err := aiChatTopicObj.GetAiChatTopicById()
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "获取数据失败!"
 				br.ErrMsg = "获取数据失败,主题不存在,Err:" + err.Error()
 				return
@@ -301,7 +301,7 @@ func (this *AiFileController) FileRetrieve() {
 	//获取主题下的所有信息
 	//AiChatTopicId
 	historyList, err := aimod.GetAiChatList(req.AiChatTopicId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取主题历史数据失败!"
 		br.ErrMsg = "获取主题历史数据失败,Err:" + err.Error()
 		return

+ 4 - 4
controllers/ai/ai_pormpt.go

@@ -302,7 +302,7 @@ func (this *AiController) MoveAiPrompt() {
 
 	prompt, err := ai_summary.GetAiPromptById(req.AiPromptId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "当前提示词不存在"
 			br.ErrMsg = "当前提示词不存在"
 			return
@@ -321,7 +321,7 @@ func (this *AiController) MoveAiPrompt() {
 	if req.PrevAiPromptId > 0 {
 		prevPrompt, err = ai_summary.GetAiPromptById(req.PrevAiPromptId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				err = errors.New("目录下的提示词不存在")
 				return
 			}
@@ -334,7 +334,7 @@ func (this *AiController) MoveAiPrompt() {
 	if req.NextAiPromptId > 0 {
 		nextPrompt, err = ai_summary.GetAiPromptById(req.NextAiPromptId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				err = errors.New("目录下的提示词不存在")
 				return
 			}
@@ -410,4 +410,4 @@ func (this *AiController) SharePrompt() {
 	br.Msg = "操作成功"
 
 	return
-}
+}

+ 18 - 18
controllers/ai/ai_summary.go

@@ -58,7 +58,7 @@ func (this *AiController) AiSummaryClassifyItems() {
 	}
 
 	rootList, err := ai_summary.GetAiSummaryClassifyAndInfoByParentId(aiSummaryClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -68,7 +68,7 @@ func (this *AiController) AiSummaryClassifyItems() {
 	}
 
 	classifyAll, err := ai_summary.GetAiSummaryClassifyAndInfoByParentId(aiSummaryClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -243,7 +243,7 @@ func (this *AiController) DeleteSandboxClassifyCheck() {
 
 	if deleteStatus != 1 {
 		classifyCount, err := ai_summary.GetAiSummaryInfoCountByClassifyId(req.AiSummaryClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有沙盘失败,Err:" + err.Error()
 			return
@@ -304,7 +304,7 @@ func (this *AiController) DeleteAiSummaryClassify() {
 	if req.AiSummaryClassifyId > 0 && req.AiSummaryId == 0 {
 		//判断是否含有纪要
 		count, err := ai_summary.GetAiSummaryInfoCountByClassifyId(req.AiSummaryClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -328,7 +328,7 @@ func (this *AiController) DeleteAiSummaryClassify() {
 	if req.AiSummaryId > 0 {
 		summaryInfo, err := ai_summary.GetAiSummaryById(req.AiSummaryId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "纪要已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -581,7 +581,7 @@ func (this *AiController) AiSummaryClassifyMove() {
 		} else {
 			// prevId为0,也就是沙盘移到最前端
 			firstClassify, err := ai_summary.GetFirstAiSummaryByClassifyId(req.AiSummaryClassifyId)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "移动失败"
 				br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 				return
@@ -770,7 +770,7 @@ func (this *AiController) AiSummaryClassifyMove() {
 
 		} else {
 			firstClassify, err := ai_summary.GetFirstAiSummaryClassifyByParentId(aiSummaryClassifyInfo.ParentId)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "移动失败"
 				br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 				return
@@ -849,7 +849,7 @@ func (this *AiController) AiSummaryList() {
 
 	if aiSummaryClassifyId > 0 {
 		sandboxClassifyIds, err := ai_summary.GetAiSummaryClassify(aiSummaryClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -870,7 +870,7 @@ func (this *AiController) AiSummaryList() {
 
 	//获取图表信息
 	list, err := ai_summary.GetAiSummaryListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取纪要信息失败"
 		br.ErrMsg = "获取纪要信息失败,Err:" + err.Error()
@@ -887,7 +887,7 @@ func (this *AiController) AiSummaryList() {
 		list[i].ParentIds = ids
 	}
 	resp := new(ai_summary.AiSummaryListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*ai_summary.AiSummaryItems, 0)
 		resp.Paging = page
 		resp.List = items
@@ -898,7 +898,7 @@ func (this *AiController) AiSummaryList() {
 	}
 
 	dataCount, err := ai_summary.GetAiSummaryListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -934,7 +934,7 @@ func (this *AiController) AiSummaryDetail() {
 	aiSummaryId, _ := this.GetInt("AiSummaryId")
 
 	detail, err := ai_summary.GetAiSummaryItemById(aiSummaryId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取沙盘信息失败"
 		br.ErrMsg = "获取沙盘信息失败,Err:" + err.Error()
@@ -948,7 +948,7 @@ func (this *AiController) AiSummaryDetail() {
 		item := new(saModel.SaDoc)
 		e := item.GetItemById(detail.SaDocId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "文档已被删除, 请刷新页面"
 				return
 			}
@@ -1137,7 +1137,7 @@ func (this *AiController) GenerateAiSummary() {
 		//获取主题下的所有信息
 		//AiChatTopicId
 		historyList, err := aimod.GetAiChatList(req.AiChatTopicId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取主题历史数据失败!"
 			br.ErrMsg = "获取主题历史数据失败,Err:" + err.Error()
 			return
@@ -1225,7 +1225,7 @@ func (this *AiController) GenerateAiSummary() {
 			aiChatTopicObj.AiChatTopicId = req.AiChatTopicId
 			topic, err := aiChatTopicObj.GetAiChatTopicById()
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "获取数据失败!"
 					br.ErrMsg = "获取数据失败,主题不存在,Err:" + err.Error()
 					return
@@ -1461,7 +1461,7 @@ func (this *AiController) GenerateAiSummary() {
 //		aiChatTopicObj.AiChatTopicId = aiChatTopicId
 //		topic, err := aiChatTopicObj.GetAiChatTopicById()
 //		if err != nil {
-//			if err.Error() == utils.ErrNoRow() {
+//			if utils.IsErrNoRow(err) {
 //				br.Msg = "获取数据失败!"
 //				br.ErrMsg = "获取数据失败,主题不存在,Err:" + err.Error()
 //				return
@@ -1585,14 +1585,14 @@ func (this *AiController) AiSummaryClassifyList() {
 	resp := new(ai_summary.AiSummaryClassifyListResp)
 
 	rootList, err := ai_summary.GetAiSummaryClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := ai_summary.GetAiSummaryClassifyAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 2 - 2
controllers/base_auth.go

@@ -119,7 +119,7 @@ func (c *BaseAuthController) Prepare() {
 
 			session, err := system.GetSysSessionByToken(token)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					c.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "Token 信息已变更:Token: " + token}, false, false)
 					c.StopRun()
 					return
@@ -148,7 +148,7 @@ func (c *BaseAuthController) Prepare() {
 			}
 			admin, err := system.GetSysUserById(session.SysUserId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					c.JSON(models.BaseResponse{Ret: 408, Msg: "信息已变更,请重新登陆!", ErrMsg: "获取admin 信息失败 " + strconv.Itoa(session.SysUserId)}, false, false)
 					c.StopRun()
 					return

+ 7 - 7
controllers/bi_dashboard.go

@@ -70,7 +70,7 @@ func (this *BIDaShboardController) AddDashboard() {
 		return
 	}
 	nameItem, err := bi_dashboard.GetDashboardByName(req.BiDashboardName, this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "查询失败"
 		br.ErrMsg = "查询失败,Err:" + err.Error()
 		return
@@ -151,7 +151,7 @@ func (this *BIDaShboardController) EditDashboard() {
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
 	}
-	
+
 	// 修改
 	item.BiDashboardName = req.BiDashboardName
 	item.ModifyTime = time.Now()
@@ -728,7 +728,7 @@ func (this *BIDaShboardController) EditDashboardClassify() {
 		return
 	}
 	item, err := bi_dashboard.GetBiDashboardClassifyById(req.BiDashboardClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取数据异常!"
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
@@ -1035,7 +1035,7 @@ func (this *BIDaShboardController) PublicCancel() {
 	}
 
 	item, err := bi_dashboard.GetDashboardById(req.BiDashboardId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取数据异常!"
 		br.ErrMsg = "获取数据异常,Err:" + err.Error()
 		return
@@ -1069,7 +1069,7 @@ func (this *BIDaShboardController) HomePage() {
 	}()
 
 	item, err := bi_dashboard.GetBiDashboardHomePageById(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "数据不存在"
 		br.ErrMsg = "数据不存在,Err:" + err.Error()
 		return
@@ -1127,7 +1127,7 @@ func (this *BIDaShboardController) HomePageSave() {
 	}
 
 	item, err := bi_dashboard.GetBiDashboardHomePageById(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "首页看板查询失败"
 		br.ErrMsg = "首页看板查询失败,Err:" + err.Error()
 		return
@@ -1257,7 +1257,7 @@ func (this *BIDaShboardController) ChartExcelPermission() {
 	//共享客户组下的用户
 	shareSellerMap := make(map[int]bool, 0)
 	subAdmins, err := system.GetAdminByGroupId(groupId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取销售失败"
 		br.ErrMsg = "获取销售失败,Err:" + err.Error()
 		return

+ 2 - 2
controllers/business_conf.go

@@ -326,7 +326,7 @@ func (this *BusinessConfController) SingleSave() {
 	// 获取配置信息
 	confOb, e := models.GetBusinessConfByKey(req.ConfKey)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "配置不存在"
 			return
 		}
@@ -419,7 +419,7 @@ func (this *BusinessConfController) GetSingle() {
 	// 获取配置信息
 	confOb, e := models.GetBusinessConfByKey(confKey)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "配置不存在"
 			return
 		}

+ 4 - 3
controllers/classify.go

@@ -355,7 +355,7 @@ func (this *ClassifyController) ParentClassify() {
 	parentMenus, e := models.GetClassifyMenuList(menuCond, menuPars)
 	if e != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取一级分类子目录列表失败"
+		br.ErrMsg = fmt.Sprintf("获取一级分类子目录列表失败, %v", e)
 		return
 	}
 	for i := range parentMenus {
@@ -494,7 +494,7 @@ func (this *ClassifyController) ListClassify() {
 	parentMenus, e := models.GetClassifyMenuList(menuCond, menuPars)
 	if e != nil {
 		br.Msg = "获取失败"
-		br.ErrMsg = "获取一级分类子目录列表失败"
+		br.ErrMsg = fmt.Sprintf("获取一级分类子目录列表失败, %v", e)
 		return
 	}
 	for i := range parentMenus {
@@ -677,6 +677,7 @@ func (this *ClassifyController) TelListClassify() {
 		condition += ` AND classify_name <> '晨报' AND classify_name <> '周报' `
 	}
 	telList, e := models.GetClassifyByCondition(condition, orderRule, pars)
+
 	if e != nil {
 		return
 	}
@@ -766,7 +767,7 @@ func (this *ClassifyController) SetEnabled() {
 	}
 	item, err := models.GetClassifyById(req.ClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}

+ 4 - 4
controllers/cloud_disk.go

@@ -64,7 +64,7 @@ func (this *CloudDiskController) MenuCreate() {
 	existCond := ` AND menu_name = ? AND parent_id = ? `
 	existPars := make([]interface{}, 0)
 	existPars = append(existPars, req.MenuName, req.ParentId)
-	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && e.Error() != utils.ErrNoRow() {
+	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "操作失败"
 		br.ErrMsg = "获取重名目录失败, Err: " + e.Error()
 		return
@@ -144,7 +144,7 @@ func (this *CloudDiskController) MenuRename() {
 	existCond := ` AND menu_name = ? AND parent_id = ? AND menu_id <> ? `
 	existPars := make([]interface{}, 0)
 	existPars = append(existPars, req.MenuName, menuItem.ParentId, menuItem.MenuId)
-	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && e.Error() != utils.ErrNoRow() {
+	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "操作失败"
 		br.ErrMsg = "获取重名目录失败, Err: " + e.Error()
 		return
@@ -578,7 +578,7 @@ func (this *CloudDiskController) ResourceUpload() {
 	existCond := ` AND resource_name = ? AND menu_id = ? `
 	existPars := make([]interface{}, 0)
 	existPars = append(existPars, fileName, menuId)
-	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && e.Error() != utils.ErrNoRow() {
+	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "操作失败"
 		br.ErrMsg = "获取重名文件失败, Err: " + e.Error()
 		return
@@ -729,7 +729,7 @@ func (this *CloudDiskController) ResourceRename() {
 	existCond := ` AND resource_name = ? AND menu_id = ? AND resource_id <> ? `
 	existPars := make([]interface{}, 0)
 	existPars = append(existPars, req.ResourceName, resourceItem.MenuId, resourceItem.ResourceId)
-	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && e.Error() != utils.ErrNoRow() {
+	if e := existItem.GetItemByCondition(existCond, existPars); e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "操作失败"
 		br.ErrMsg = "获取重名文件失败, Err: " + e.Error()
 		return

+ 2 - 2
controllers/commodity_trade_base_index.go

@@ -2639,7 +2639,7 @@ func (this *TradeCommonController) MtjhData() {
 		product.CreateTime = v.CreateTime
 
 		modifyTime, err := data_manage.GetMtjhIndexLatestDate(v.IndexCode)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取更新时间失败"
 			br.ErrMsg = "获取更新时间失败,Err:" + err.Error()
 			return
@@ -2741,7 +2741,7 @@ func (this *TradeCommonController) MtjhSingleData() {
 	}
 
 	modifyTime, err := data_manage.GetMtjhIndexLatestDate(indexCode)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取更新时间失败"
 		br.ErrMsg = "获取更新时间失败,Err:" + err.Error()
 		return

+ 4 - 4
controllers/company_seller.go

@@ -41,9 +41,9 @@ func (this *CompanySellerController) CheckListV2() {
 	productId := services.GetProductId(sysUser.RoleTypeCode)
 	switch productId {
 	case 1:
-		roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_FICC_SELLER + `","` + utils.ROLE_TYPE_CODE_FICC_GROUP + `","` + utils.ROLE_TYPE_CODE_FICC_TEAM + `"`
+		roleCodeTypeStr = `'` + utils.ROLE_TYPE_CODE_FICC_SELLER + `','` + utils.ROLE_TYPE_CODE_FICC_GROUP + `','` + utils.ROLE_TYPE_CODE_FICC_TEAM + `'`
 	case 2:
-		roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_RAI_SELLER + `","` + utils.ROLE_TYPE_CODE_RAI_GROUP + `"`
+		roleCodeTypeStr = `'` + utils.ROLE_TYPE_CODE_RAI_SELLER + `','` + utils.ROLE_TYPE_CODE_RAI_GROUP + `'`
 	}
 
 	// ficc管理员,不要只查销售
@@ -51,7 +51,7 @@ func (this *CompanySellerController) CheckListV2() {
 		roleCodeTypeStr = ``
 	} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
 		// 权益管理员,查看所有权益的账号
-		roleCodeTypeStr = `"` + utils.ROLE_TYPE_CODE_RAI_SELLER + `","` + utils.ROLE_TYPE_CODE_RAI_GROUP + `","` + utils.ROLE_TYPE_CODE_RAI_RESEARCHR + `","` + utils.ROLE_TYPE_CODE_RAI_ADMIN + `"`
+		roleCodeTypeStr = `'` + utils.ROLE_TYPE_CODE_RAI_SELLER + `','` + utils.ROLE_TYPE_CODE_RAI_GROUP + `','` + utils.ROLE_TYPE_CODE_RAI_RESEARCHR + `','` + utils.ROLE_TYPE_CODE_RAI_ADMIN + `'`
 	}
 
 	getAllSeller, _ := this.GetBool("AllSeller", false)
@@ -1726,7 +1726,7 @@ func (this *CompanySellerController) CheckListV2() {
 
 	// 海外销售部-目前无权限, 均可见
 	seaDepartment, e := system.GetSysDepartmentByName("海外销售部")
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取海外销售部失败, Err: " + e.Error()
 		return

+ 4 - 4
controllers/data_manage/ai_predict_model/classify.go

@@ -269,7 +269,7 @@ func (this *AiPredictModelClassifyController) Edit() {
 	classifyOb := new(aiPredictModel.AiPredictModelClassify)
 	classifyItem, e := classifyOb.GetItemById(req.ClassifyId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "分类不存在, 请刷新页面"
 			return
 		}
@@ -359,7 +359,7 @@ func (this *AiPredictModelClassifyController) RemoveCheck() {
 
 	if deleteStatus != 1 && req.IndexId == 0 {
 		classifyCount, err := aiPredictModel.GetAiPredictModelClassifyCountByClassifyId(req.ClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -411,7 +411,7 @@ func (this *AiPredictModelClassifyController) Remove() {
 	// 删除分类
 	if req.ClassifyId > 0 && req.IndexId == 0 {
 		count, err := aiPredictModel.GetAiPredictModelIndexCountByClassifyId(req.ClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -434,7 +434,7 @@ func (this *AiPredictModelClassifyController) Remove() {
 		indexOb := new(aiPredictModel.AiPredictModelIndex)
 		aiIndex, e := indexOb.GetItemById(req.IndexId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Ret = 200
 				br.Msg = "删除成功"
 				br.Success = true

+ 14 - 14
controllers/data_manage/ai_predict_model/framework.go

@@ -124,12 +124,12 @@ func (c *AiPredictModelFrameworkController) Add() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.FrameworkName, sysUser.AdminId)
 		exist, e := ob.GetItemByCondition(cond, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.AiPredictModelFrameworkId > 0 {
 			br.Msg = "框架名称已存在,请重新输入"
 			return
 		}
@@ -223,7 +223,7 @@ func (c *AiPredictModelFrameworkController) Edit() {
 	frameworkOb := new(aiPredictModel.AiPredictModelFramework)
 	item, e := frameworkOb.GetItemById(req.AiPredictModelFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -245,12 +245,12 @@ func (c *AiPredictModelFrameworkController) Edit() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.AiPredictModelFrameworkId, req.FrameworkName, sysUser.AdminId)
 		exist, e := ob.GetItemByCondition(cond, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.AiPredictModelFrameworkId > 0 {
 			br.Msg = "框架名称已存在,请重新输入"
 			return
 		}
@@ -335,7 +335,7 @@ func (c *AiPredictModelFrameworkController) Remove() {
 	ob := new(aiPredictModel.AiPredictModelFramework)
 	item, e := ob.GetItemById(req.AiPredictModelFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "操作成功"
@@ -405,7 +405,7 @@ func (c *AiPredictModelFrameworkController) Rename() {
 	frameworkOb := new(aiPredictModel.AiPredictModelFramework)
 	item, e := frameworkOb.GetItemById(req.AiPredictModelFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -427,12 +427,12 @@ func (c *AiPredictModelFrameworkController) Rename() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.AiPredictModelFrameworkId, req.FrameworkName, sysUser.AdminId)
 		exist, e := ob.GetItemByCondition(cond, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.AiPredictModelFrameworkId > 0 {
 			br.Msg = "框架名称已存在,请重新输入"
 			return
 		}
@@ -491,7 +491,7 @@ func (c *AiPredictModelFrameworkController) Move() {
 	frameworkOb := new(aiPredictModel.AiPredictModelFramework)
 	item, e := frameworkOb.GetItemById(req.AiPredictModelFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -538,7 +538,7 @@ func (c *AiPredictModelFrameworkController) Move() {
 		updateCols = append(updateCols, "Sort", "ModifyTime")
 	} else {
 		first, err := aiPredictModel.GetFirstAiPredictModelFramework()
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取我的模型框架排首位的数据失败, Err:" + err.Error()
 			return
@@ -599,7 +599,7 @@ func (c *AiPredictModelFrameworkController) Detail() {
 	frameworkOb := new(aiPredictModel.AiPredictModelFramework)
 	item, e := frameworkOb.GetItemById(frameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -633,9 +633,9 @@ func (c *AiPredictModelFrameworkController) Detail() {
 		indexIdNum := len(aiPredictModelIndexIdList)
 		if indexIdNum > 0 {
 			indexObj := aiPredictModel.AiPredictModelIndex{}
-			indexList, e := indexObj.GetItemsByCondition(` AND ai_predict_model_index_id in (`+utils.GetOrmInReplace(indexIdNum)+`)`, aiPredictModelIndexIdList, []string{}, "")
+			indexList, e := indexObj.GetItemsByCondition(` AND ai_predict_model_index_id in (`+utils.GetOrmInReplace(indexIdNum)+`)`, []interface{}{aiPredictModelIndexIdList}, []string{}, "")
 			if e != nil {
-				if e.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(e) {
 					br.Msg = "框架不存在, 请刷新页面"
 					return
 				}

+ 7 - 7
controllers/data_manage/ai_predict_model/index.go

@@ -648,7 +648,7 @@ func (this *AiPredictModelIndexController) Detail() {
 	indexOb := new(aiPredictModel.AiPredictModelIndex)
 	indexItem, e := indexOb.GetItemById(indexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "标的已被删除,请刷新页面"
 			return
 		}
@@ -756,7 +756,7 @@ func (this *AiPredictModelIndexController) Save() {
 	indexOb := new(aiPredictModel.AiPredictModelIndex)
 	indexItem, e := indexOb.GetItemById(req.IndexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "标的已被删除,请刷新页面"
 			return
 		}
@@ -837,7 +837,7 @@ func (this *AiPredictModelIndexController) DashboardSave() {
 	indexOb := new(aiPredictModel.AiPredictModelIndex)
 	_, e := indexOb.GetItemById(req.IndexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "标的已被删除,请刷新页面"
 			return
 		}
@@ -855,12 +855,12 @@ func (this *AiPredictModelIndexController) DashboardSave() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.IndexId)
 		item, e := dashboardItem.GetItemByCondition(cond, pars, "")
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = fmt.Sprintf("获取标的看板失败, %v", e)
 			return
 		}
-		if item != nil {
+		if item != nil && item.AiPredictModelIndexId > 0 {
 			isUpdate = true
 			dashboardItem = item
 			dashboardItem.DashboardName = req.DashboardName
@@ -930,7 +930,7 @@ func (this *AiPredictModelIndexController) DashboardDetail() {
 	indexOb := new(aiPredictModel.AiPredictModelIndex)
 	indexItem, e := indexOb.GetItemById(indexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "标的已被删除,请刷新页面"
 			return
 		}
@@ -949,7 +949,7 @@ func (this *AiPredictModelIndexController) DashboardDetail() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, indexId)
 		item, e := dashboardOb.GetItemByCondition(cond, pars, "")
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = fmt.Sprintf("获取标的看板失败, %v", e)
 			return

+ 5 - 5
controllers/data_manage/baiinfo_data.go

@@ -36,14 +36,14 @@ func (this *EdbInfoController) BaiinfoClassify() {
 	}
 
 	rootList, err := data_manage.GetBaseFromBaiinfoClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromBaiinfoClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -52,7 +52,7 @@ func (this *EdbInfoController) BaiinfoClassify() {
 	baseFromBaiinfoIndexMap := make(map[int][]*data_manage.BaseFromBaiinfoClassifyItems)
 
 	allBaseFromBaiinfoIndex, err := data_manage.GetBaiinfoIndexAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -144,14 +144,14 @@ func (this *EdbInfoController) BaiinfoClassifyName() {
 	}
 
 	rootList, err := data_manage.GetBaseFromBaiinfoClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromBaiinfoClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 3 - 2
controllers/data_manage/base_from_ly_index_controller.go

@@ -114,8 +114,9 @@ func (this *BaseFromLyIndexController) LyIndexDataList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
+	startSize := utils.StartIndex(currentIndex, pageSize)
 
-	indexDataList, err := data.GetIndexDataPage(indexId, currentIndex, pageSize)
+	indexDataList, err := data.GetIndexDataPage(indexId, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取指标数据列表失败"
 		br.ErrMsg = "获取指标数据列表失败,Err:" + err.Error()
@@ -459,7 +460,7 @@ func (this *BaseFromLyIndexController) LyIndexDataExport() {
 
 			var lyDataList []*data_manage.BaseFromLyData
 			lyDataList, err = data_manage.GetBaseFromLyDataByIndexCode(v.IndexCode)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.ErrMsg = "GetBaseFromLyDataByIndexCode,Err:" + err.Error()
 				br.Msg = "获取数据失败"
 				return

+ 1 - 1
controllers/data_manage/base_from_rzd_index_controller.go

@@ -580,7 +580,7 @@ func (this *BaseFromRzdIndexController) RzdIndexDataExport() {
 
 			var dataList []*data_manage.BaseFromRzdData
 			dataList, err = data_manage.GetBaseFormRzdDataByIndexCode(v.IndexCode)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.ErrMsg = "GetBaseFormRzdDataByIndexCode,Err:" + err.Error()
 				br.Msg = "获取数据失败"
 				return

+ 4 - 4
controllers/data_manage/base_from_ths_hf.go

@@ -728,7 +728,7 @@ func (this *BaseFromThsHfController) Edit() {
 	indexOb := new(data_manage.BaseFromThsHfIndex)
 	item, e := indexOb.GetItemById(params.IndexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "指标不存在, 请刷新页面"
 			return
 		}
@@ -819,7 +819,7 @@ func (this *BaseFromThsHfController) Detail() {
 	indexOb := new(data_manage.BaseFromThsHfIndex)
 	item, e := indexOb.GetItemById(indexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "指标不存在, 请刷新页面"
 			return
 		}
@@ -899,7 +899,7 @@ func (this *BaseFromThsHfController) Refresh() {
 	indexOb := new(data_manage.BaseFromThsHfIndex)
 	_, e := indexOb.GetItemById(params.IndexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "指标不存在, 请刷新页面"
 			return
 		}
@@ -959,7 +959,7 @@ func (this *BaseFromThsHfController) Remove() {
 	indexOb := new(data_manage.BaseFromThsHfIndex)
 	item, e := indexOb.GetItemById(params.IndexId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "操作成功"

+ 2 - 2
controllers/data_manage/base_from_ths_hf_classify.go

@@ -301,7 +301,7 @@ func (this *BaseFromThsHfController) ClassifyEdit() {
 	classifyOb := new(data_manage.BaseFromThsHfClassify)
 	classifyItem, e := classifyOb.GetItemById(req.ClassifyId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "分类不存在, 请刷新页面"
 			return
 		}
@@ -382,7 +382,7 @@ func (this *BaseFromThsHfController) ClassifyRemove() {
 	classifyOb := new(data_manage.BaseFromThsHfClassify)
 	classifyItem, e := classifyOb.GetItemById(req.ClassifyId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"

+ 2 - 2
controllers/data_manage/business_data.go

@@ -38,7 +38,7 @@ func (c *EdbBusinessController) SourceList() {
 
 	obj := data_manage.EdbBusinessSource{}
 	list, err := obj.GetAllList()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -600,7 +600,7 @@ func (c *EdbBusinessController) DataList() {
 
 	// 获取分页数据
 	dataCount, dataList, err := data.GetPageBaseBusinessIndexData(req.IndexCode, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return

+ 2 - 2
controllers/data_manage/ccf_data.go

@@ -751,7 +751,7 @@ func (this *EdbInfoController) CCFStockTable() {
 	// 若无tableDate默认取最近的有数据的表格
 	item, e := excelOb.GetItemByCondition(cond, pars, fmt.Sprintf("%s DESC", excelOb.Cols().ExcelDate))
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "该日期暂无数据"
@@ -1075,7 +1075,7 @@ func (this *EdbInfoController) CCFIndexNameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_CCF, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取钢联已存在信息失败,Err:" + err.Error()
 			return

+ 24 - 24
controllers/data_manage/chart_classify.go

@@ -82,7 +82,7 @@ func (this *ChartClassifyController) ChartClassifyListV2() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -135,21 +135,21 @@ func (this *ChartClassifyController) ChartClassifyListV2() {
 	}
 
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoAll([]int{utils.CHART_SOURCE_DEFAULT})
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -208,19 +208,19 @@ func (this *ChartClassifyController) ChartClassifyListV2() {
 // getChartClassifyListForMe 获取我创建的图表
 func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_DEFAULT}, adminInfo.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -509,7 +509,7 @@ func (this *ChartClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -596,7 +596,7 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -620,7 +620,7 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -710,7 +710,7 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 		pars = append(pars, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -730,14 +730,14 @@ func (this *ChartClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return
@@ -812,7 +812,7 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 	//判断分类是否存在
 	chartClassifyInfo, err := data_manage.GetChartClassifyById(req.ClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在,请刷新页面"
 			return
 		}
@@ -823,12 +823,12 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 
 	// 校验移动的父级目录下是否有重名分类
 	exists, e := data_manage.GetChartClassifyByParentIdAndName(req.ParentClassifyId, chartClassifyInfo.ChartClassifyName, req.ClassifyId)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "移动失败"
 		br.ErrMsg = "获取父级目录下的同名分类失败, Err: " + e.Error()
 		return
 	}
-	if exists != nil {
+	if exists != nil && exists.ChartClassifyId > 0 {
 		br.Msg = "移动失败,分类名称已存在"
 		return
 	}
@@ -912,7 +912,7 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartClassifyByParentId(chartClassifyInfo.ParentId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
@@ -946,13 +946,13 @@ func (this *ChartClassifyController) ChartClassifyMove() {
 // getChartClassifyListForMe 获取我创建的图表分类
 func getChartClassifyListForMeV2(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_DEFAULT)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_DEFAULT)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -1011,7 +1011,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV2() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1024,7 +1024,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV2() {
 	isShowMe, _ := this.GetBool("IsShowMe")
 	if isShowMe {
 		allChartInfo, err := data_manage.GetChartInfoByAdminIdAndClassify([]int{utils.CHART_SOURCE_DEFAULT}, sysUser.AdminId, chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取全部数据失败,Err:" + err.Error()
 			return
@@ -1042,7 +1042,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV2() {
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoAllByClassifyId(utils.CHART_SOURCE_DEFAULT, chartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -1101,7 +1101,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV3() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1114,7 +1114,7 @@ func (this *ChartClassifyController) ChartClassifyChartListV3() {
 	isShowMe, _ := this.GetBool("IsShowMe")
 	if isShowMe {
 		allChartInfo, err := data_manage.GetChartClassifyAndInfoByParentIdForMe(chartClassifyId, sysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return

+ 1 - 1
controllers/data_manage/chart_common.go

@@ -54,7 +54,7 @@ func (this *ChartInfoController) CommonChartInfoDetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"

+ 2 - 2
controllers/data_manage/chart_edb_config.go

@@ -148,7 +148,7 @@ func (this *EdbInfoController) ModifyNoPermissionAdmin() {
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
 		br.Msg = "修改失败"
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "找不到该指标"
 			br.IsSendEmail = false
 		}
@@ -208,7 +208,7 @@ func (this *EdbInfoController) DelNoPermissionAdmin() {
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
 		br.Msg = "删除失败"
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "找不到该指标"
 			br.IsSendEmail = false
 		}

+ 13 - 13
controllers/data_manage/chart_framework.go

@@ -227,12 +227,12 @@ func (this *ChartFrameworkController) Add() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.FrameworkName, sysUser.AdminId)
 		exist, e := ob.GetItemByCondition(cond, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ChartFrameworkId > 0 {
 			br.Msg = "框架名称已存在"
 			return
 		}
@@ -337,7 +337,7 @@ func (this *ChartFrameworkController) Edit() {
 	frameworkOb := new(data_manage.ChartFramework)
 	item, e := frameworkOb.GetItemById(req.ChartFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -353,12 +353,12 @@ func (this *ChartFrameworkController) Edit() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.ChartFrameworkId, req.FrameworkName, sysUser.AdminId)
 		exist, e := ob.GetItemByCondition(cond, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ChartFrameworkId > 0 {
 			br.Msg = "框架名称已存在"
 			return
 		}
@@ -451,7 +451,7 @@ func (this *ChartFrameworkController) Remove() {
 	ob := new(data_manage.ChartFramework)
 	item, e := ob.GetItemById(req.ChartFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "操作成功"
@@ -521,7 +521,7 @@ func (this *ChartFrameworkController) Rename() {
 	frameworkOb := new(data_manage.ChartFramework)
 	item, e := frameworkOb.GetItemById(req.ChartFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -537,12 +537,12 @@ func (this *ChartFrameworkController) Rename() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, req.ChartFrameworkId, req.FrameworkName, sysUser.AdminId)
 		exist, e := ob.GetItemByCondition(cond, pars)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取重名框架失败, Err: " + e.Error()
 			return
 		}
-		if exist != nil {
+		if exist != nil && exist.ChartFrameworkId > 0 {
 			br.Msg = "框架名称已存在"
 			return
 		}
@@ -606,7 +606,7 @@ func (this *ChartFrameworkController) EditPublic() {
 	frameworkOb := new(data_manage.ChartFramework)
 	item, e := frameworkOb.GetItemById(req.ChartFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -673,7 +673,7 @@ func (this *ChartFrameworkController) Move() {
 	frameworkOb := new(data_manage.ChartFramework)
 	item, e := frameworkOb.GetItemById(req.ChartFrameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}
@@ -720,7 +720,7 @@ func (this *ChartFrameworkController) Move() {
 		updateCols = append(updateCols, "Sort", "ModifyTime")
 	} else {
 		first, err := data_manage.GetFirstChartFramework(sysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "操作失败"
 			br.ErrMsg = "获取我的图库框架排首位的数据失败, Err:" + err.Error()
 			return
@@ -781,7 +781,7 @@ func (this *ChartFrameworkController) Detail() {
 	frameworkOb := new(data_manage.ChartFramework)
 	item, e := frameworkOb.GetItemById(frameworkId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "框架不存在, 请刷新页面"
 			return
 		}

+ 51 - 55
controllers/data_manage/chart_info.go

@@ -68,7 +68,7 @@ func (this *ChartInfoController) ChartInfoSave() {
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面!"
 			br.ErrMsg = "图表已被删除,请刷新页面,ChartInfoId:" + strconv.Itoa(req.ChartInfoId)
 			return
@@ -336,7 +336,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -359,7 +359,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 		edbInfoId := v.EdbInfoId
 		edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表不存在!"
 				br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 				return
@@ -369,7 +369,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 				return
 			}
 		}
-		if edbInfo == nil {
+		if edbInfo == nil || edbInfo.EdbInfoId <= 0 {
 			br.Msg = "指标不存在!"
 			br.ErrMsg = "指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 			return
@@ -391,7 +391,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 
 			edbExist, err := data_manage.GetEdbInfoByCondition(edbCondition, edbPars)
 			if err != nil {
-				if err.Error() != utils.ErrNoRow() {
+				if !utils.IsErrNoRow(err) {
 					br.Msg = "判断英文指标名称是否存在失败"
 					br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + err.Error()
 					return
@@ -420,7 +420,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return
@@ -449,7 +449,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 		edbInfoId := v.EdbInfoId
 		edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表不存在!"
 				br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 				return
@@ -459,7 +459,7 @@ func (this *ChartInfoController) ChartEnInfoEdit() {
 				return
 			}
 		}
-		if edbInfo != nil {
+		if edbInfo != nil && edbInfo.EdbInfoId > 0 {
 			go data.AddOrEditEdbInfoToEs(edbInfoId)
 		}
 	}
@@ -528,7 +528,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -551,7 +551,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
 		edbInfoId := v.EdbInfoId
 		edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表不存在!"
 				br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 				return
@@ -586,7 +586,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
 
 			edbExist, err := data_manage.GetEdbInfoByCondition(edbCondition, edbPars)
 			if err != nil {
-				if err.Error() != utils.ErrNoRow() {
+				if !utils.IsErrNoRow(err) {
 					br.Msg = "判断英文指标名称是否存在失败"
 					br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + err.Error()
 					return
@@ -618,7 +618,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
 
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return
@@ -647,7 +647,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
 		edbInfoId := v.EdbInfoId
 		edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表不存在!"
 				br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 				return
@@ -657,7 +657,7 @@ func (this *ChartInfoController) ChartInfoBaseEdit() {
 				return
 			}
 		}
-		if edbInfo != nil {
+		if edbInfo != nil && edbInfo.EdbInfoId > 0 {
 			go data.AddOrEditEdbInfoToEs(edbInfoId)
 		}
 	}
@@ -700,7 +700,7 @@ func (this *ChartInfoController) ChartInfoNewest() {
 		this.ServeJSON()
 	}()
 	item, err := data_manage.GetChartInfoByNewest(1)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取最新图表失败"
 		br.ErrMsg = "获取最新图表失败,Err:" + err.Error()
 		return
@@ -788,12 +788,12 @@ func (this *ChartInfoController) ChartInfoMove() {
 	if chartInfo.ChartClassifyId != req.ChartClassifyId {
 		//查询需要修改的分类下是否存在同一个图表名称
 		tmpChartInfo, tmpErr := data_manage.GetChartInfoByClassifyIdAndName(req.ChartClassifyId, chartInfo.ChartName)
-		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
 			return
 		}
-		if tmpChartInfo != nil {
+		if tmpChartInfo != nil && tmpChartInfo.ChartInfoId > 0 {
 			br.Msg = "移动失败,同一个分类下图表名称不允许重复"
 			br.ErrMsg = "移动失败,同一个分类下图表名称不允许重复"
 			return
@@ -847,14 +847,14 @@ func (this *ChartInfoController) ChartInfoMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
 		}
 
 		//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-		if firstClassify != nil && firstClassify.Sort == 0 {
+		if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
 			updateSortStr := ` sort + 1 `
 			_ = data_manage.UpdateChartInfoSortByClassifyId(firstClassify.ChartClassifyId, 0, firstClassify.ChartInfoId-1, []int{chartInfo.Source}, updateSortStr)
 		}
@@ -961,7 +961,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
 	if chartInfoId > 0 {
 		chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "该图表已删除,自动查看下一图表"
 				br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
 				br.Ret = 406
@@ -1030,7 +1030,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
 	extraConfigStr := chartInfo.ExtraConfig
 	// 柱方图的一些配置
 	var barConfig data_manage.BarChartInfoReq
-	if chartInfo != nil && chartInfo.ChartType == 7 {
+	if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
 		if chartInfo.BarConfig == `` {
 			br.Msg = "柱方图未配置"
 			br.ErrMsg = "柱方图未配置"
@@ -1130,7 +1130,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
 		if len(warnEdbList) > 0 {
 			chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
 		}
-		if chartInfoId > 0 && chartInfo != nil {
+		if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
 			//判断是否加入我的图库
 			{
 				var myChartCondition string
@@ -1141,7 +1141,7 @@ func (this *ChartInfoController) ChartInfoDetail() {
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "获取失败"
 					br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -1361,7 +1361,7 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 	extraConfigStr := chartInfo.ExtraConfig
 	// 柱方图的一些配置
 	var barConfig data_manage.BarChartInfoReq
-	if chartInfo != nil && chartInfo.ChartType == 7 {
+	if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
 		if chartInfo.BarConfig == `` {
 			br.Msg = "柱方图未配置"
 			br.ErrMsg = "柱方图未配置"
@@ -1374,9 +1374,9 @@ func (this *ChartInfoController) PreviewChartInfoDetail() {
 			return
 		}
 		extraConfigStr = chartInfo.BarConfig
-	} else if chartInfo != nil && chartInfo.ChartType == utils.CHART_TYPE_SECTION_COMBINE {
+	} else if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == utils.CHART_TYPE_SECTION_COMBINE {
 		extraConfigStr = req.ExtraConfig
-	} else if chartInfo != nil && chartInfo.ChartType == utils.CHART_TYPE_AREA {
+	} else if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == utils.CHART_TYPE_AREA {
 		extraConfigStr = req.ExtraConfig
 	}
 
@@ -1589,7 +1589,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 	}
 	chartInfo, err := data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "该图表已删除,自动查看下一图表"
 			br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
 			br.Ret = 406
@@ -1700,7 +1700,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 	extraConfigStr := chartInfo.ExtraConfig
 	// 柱方图的一些配置
 	var barConfig data_manage.BarChartInfoReq
-	if chartInfo != nil && chartInfo.ChartType == 7 {
+	if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
 		if chartInfo.BarConfig == `` {
 			br.Msg = "柱方图未配置"
 			br.ErrMsg = "柱方图未配置"
@@ -1740,7 +1740,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 		if len(warnEdbList) > 0 {
 			chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
 		}
-		if chartInfoId > 0 && chartInfo != nil {
+		if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
 			//判断是否加入我的图库
 			{
 				var myChartCondition string
@@ -1751,7 +1751,7 @@ func (this *ChartInfoController) ChartInfoDetailV2() {
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "获取失败"
 					br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -2184,7 +2184,7 @@ func (this *ChartInfoController) ChartInfoSearch() {
 	for _, v := range keyWordArr {
 		v = strings.Replace(v, " ", "%", -1)
 		newSearchList, err := data_manage.ChartInfoSearchByKeyWord(v, showSysId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -2304,7 +2304,7 @@ func (this *ChartInfoController) ChartInfoSearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -2321,7 +2321,7 @@ func (this *ChartInfoController) ChartInfoSearchByEs() {
 		isEs = true
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, []int{utils.CHART_SOURCE_DEFAULT}, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -2475,7 +2475,7 @@ func (this *EdbInfoController) ChartInfoRefresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -2594,7 +2594,7 @@ func (this *ChartInfoController) ChartInfoDetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -2664,7 +2664,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -2842,7 +2842,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 	extraConfigStr := chartInfo.ExtraConfig //图表额外数据参数
 	var barConfig data_manage.BarChartInfoReq
 	// 柱方图的一些配置
-	if chartInfo != nil && chartInfo.ChartType == 7 {
+	if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
 		if chartInfo.BarConfig == `` {
 			msg = "柱方图未配置"
 			errMsg = "柱方图未配置"
@@ -2888,7 +2888,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 	*/
 
 	chartViewClassify, _ := data_manage.GetChartClassifyViewById(chartInfo.ChartClassifyId)
-	if chartViewClassify != nil {
+	if chartViewClassify != nil && chartViewClassify.ChartClassifyId > 0 {
 		chartClassifyParent, _ := data_manage.GetChartClassifyViewById(chartClassify.ParentId)
 		chartInfo.ChartClassify = append(chartInfo.ChartClassify, chartClassifyParent)
 	}
@@ -3188,7 +3188,7 @@ func (this *ChartInfoController) CopyChartInfo() {
 	}
 	chartClassify, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -3317,7 +3317,7 @@ func (this *ChartInfoController) CopyChartInfo() {
 				ChartStyle:    v.ChartStyle,
 				ChartColor:    v.ChartColor,
 				ChartWidth:    v.ChartWidth,
-				Source:        v.Source,
+				Source:        oldChartInfo.Source,
 				EdbAliasName:  v.EdbAliasName,
 				IsConvert:     v.IsConvert,
 				ConvertType:   v.ConvertType,
@@ -3854,10 +3854,6 @@ func (this *EdbInfoController) GetBatchChartRefreshResult() {
 //	fmt.Println("end")
 //}
 
-//func init() {
-//	data.AddAllChartInfo()
-//}
-
 // 截面散点示例数据
 //func init() {
 //
@@ -4163,7 +4159,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
 	if chartInfoId > 0 {
 		chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "该图表已删除,自动查看下一图表"
 				br.ErrMsg = "该图表已删除,自动查看下一图表,Err:" + err.Error()
 				br.Ret = 406
@@ -4251,7 +4247,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
 		extraConfigStr := chartInfo.ExtraConfig
 		// 柱方图的一些配置
 		var barConfig data_manage.BarChartInfoReq
-		if chartInfo != nil && chartInfo.ChartType == 7 {
+		if chartInfo != nil && chartInfo.ChartInfoId > 0 && chartInfo.ChartType == 7 {
 			if chartInfo.BarConfig == `` {
 				br.Msg = "柱方图未配置"
 				br.ErrMsg = "柱方图未配置"
@@ -4312,7 +4308,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
 		if len(warnEdbList) > 0 {
 			chartInfo.WarnMsg = `图表引用指标异常,异常指标:` + strings.Join(warnEdbList, ",")
 		}
-		if chartInfoId > 0 && chartInfo != nil {
+		if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
 			//判断是否加入我的图库
 			{
 				var myChartCondition string
@@ -4323,7 +4319,7 @@ func (this *ChartInfoController) ChartInfoConvertDetail() {
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "获取失败"
 					br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -4725,7 +4721,7 @@ func (this *ChartInfoController) ChartList() {
 	if len(chartClassifyIdsStr) > 0 {
 		if !subClassify {
 			chartClassifyId, err := data_manage.GetChartClassifyByIdsNoSubClassify(chartClassifyIds)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取图表信息失败"
 				br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 				return
@@ -4805,7 +4801,7 @@ func (this *ChartInfoController) ChartList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -4823,7 +4819,7 @@ func (this *ChartInfoController) ChartList() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -4831,7 +4827,7 @@ func (this *ChartInfoController) ChartList() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -4923,7 +4919,7 @@ func (this *ChartInfoController) ChartList() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -4934,7 +4930,7 @@ func (this *ChartInfoController) ChartList() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -5002,7 +4998,7 @@ func (this *ChartInfoController) ModifyChartList() {
 		if len(chartClassifyIds) > 0 {
 			if !req.SubClassify {
 				chartClassifyId, err := data_manage.GetChartClassifyByIdsNoSubClassify(chartClassifyIds)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "获取图表信息失败"
 					br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 					return

+ 4 - 4
controllers/data_manage/chart_theme.go

@@ -404,7 +404,7 @@ func (c *ChartThemeController) Edit() {
 	// 获取配置
 	chartTheme, err := chart_theme.GetChartThemeId(req.ChartThemeId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "主题不存在或已删除"
 			br.ErrMsg = "主题不存在或已删除"
 			br.IsSendEmail = false
@@ -474,7 +474,7 @@ func (c *ChartThemeController) Delete() {
 	// 获取配置
 	chartTheme, err := chart_theme.GetChartThemeId(req.ChartThemeId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "主题不存在或已删除"
 			br.ErrMsg = "主题不存在或已删除"
 			br.IsSendEmail = false
@@ -562,7 +562,7 @@ func (c *ChartThemeController) SetDefaultTheme() {
 	// 获取图表配置
 	chartTheme, err := chart_theme.GetChartThemeId(req.ChartThemeId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "主题不存在或已删除"
 			br.ErrMsg = "主题不存在或已删除"
 			br.IsSendEmail = false
@@ -576,7 +576,7 @@ func (c *ChartThemeController) SetDefaultTheme() {
 	// 获取图表类型
 	chartThemeType, err := chart_theme.GetChartThemeTypeById(req.ChartThemeTypeId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "获取图表类型不存在或已删除"
 			br.ErrMsg = "获取图表类型不存在或已删除"
 			br.IsSendEmail = false

+ 8 - 8
controllers/data_manage/clarksons_data.go

@@ -179,7 +179,7 @@ func (this *ClarksonsDataController) EditClassify() {
 	}
 	classify, err := data_manage.GetClarksonsClassifyById(req.BaseFromClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}
@@ -271,7 +271,7 @@ func (this *ClarksonsDataController) IndexList() {
 	}()
 	classifyId, _ := this.GetInt("BaseFromClassifyId", 0)
 	indexList, err := data_manage.GetClarksonsIndexBaseInfoByClassifyId(classifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -411,7 +411,7 @@ func (this *ClarksonsDataController) SingleData() {
 		return
 	}
 	edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_CLARKSONS, indexInfo.IndexCode)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标数据失败"
 		br.ErrMsg = "获取指标库数据失败,Err:" + err.Error()
 		return
@@ -613,7 +613,7 @@ func (this *ClarksonsDataController) MoveClarksonsData() {
 //
 //	_, err = data_manage.GetClarksonsIndexByIndexCode(req.EdbCode)
 //	if err != nil {
-//		if err.Error() == utils.ErrNoRow() {
+//		if utils.IsErrNoRow(err) {
 //			br.Msg = "指标不存在"
 //			return
 //		}
@@ -824,7 +824,7 @@ func (c *ClarksonsDataController) NameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_CLARKSONS, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取克拉克森已存在信息失败,Err:" + err.Error()
 			return
@@ -1539,7 +1539,7 @@ func (this *ClarksonsDataController) ClarksonsData() {
 		product.ModifyTime = v.ModifyTime
 
 		modifyTime, err := data_manage.GetClarksonsIndexLatestDate(v.IndexCode)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取更新时间失败"
 			br.ErrMsg = "获取更新时间失败,Err:" + err.Error()
 			return
@@ -1605,7 +1605,7 @@ func (this *ClarksonsDataController) IndexPageList() {
 		}
 		total = tmpTotal
 		tmpIndexList, err := data_manage.GetClarksonsIndexByPage(startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -1633,7 +1633,7 @@ func (this *ClarksonsDataController) IndexPageList() {
 		}
 		total = tmpTotal
 		tmpIndexList, err := data_manage.GetClarksonsIndexByClassifyId(classifyIds, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return

+ 5 - 5
controllers/data_manage/com_trade.go

@@ -29,7 +29,7 @@ func (this *EdbInfoController) ComTradeCountryList() {
 	}
 
 	list, err := data_manage.GetComTradeCountryItemAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -161,14 +161,14 @@ func (this *EdbInfoController) ComTradeDataList() {
 	sortStr = fmt.Sprintf("%s %s,modify_time desc ", sortParam, sortType)
 
 	total, err := data_manage.GetComTradeListCount(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	list, err := data_manage.GetComTradeList(condition, pars, startSize, pageSize, sortStr)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -178,7 +178,7 @@ func (this *EdbInfoController) ComTradeDataList() {
 	lastUpdateTimeStr := ``
 	// 获取用到的指标信息
 	comTradeList, err := data_manage.GetAllComTradeIndexList()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -247,7 +247,7 @@ func (this *EdbInfoController) ComTradeList() {
 	}
 
 	list, err := data_manage.GetComTradeIndexList(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 10 - 10
controllers/data_manage/correlation/correlation_chart_classify.go

@@ -62,7 +62,7 @@ func (this *CorrelationChartClassifyController) ChartClassifyList() {
 	nodeAll := make([]*data_manage.ChartClassifyItems, 0)
 	// 查询分类节点
 	rootList, err := data_manage.GetChartClassifyByParentId(parentId, utils.CHART_SOURCE_CORRELATION)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -155,19 +155,19 @@ func (this *CorrelationChartClassifyController) ChartClassifyList() {
 // getChartClassifyListForMe 获取我创建的图表
 func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_CORRELATION)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_CORRELATION)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_CORRELATION, utils.CHART_SOURCE_CORRELATION}, adminInfo.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -367,7 +367,7 @@ func (this *CorrelationChartClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -429,7 +429,7 @@ func (this *CorrelationChartClassifyController) DeleteChartClassify() {
 	if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -454,7 +454,7 @@ func (this *CorrelationChartClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -525,7 +525,7 @@ func (this *CorrelationChartClassifyController) DeleteChartClassify() {
 		pars = append(pars, chartInfo.ChartClassifyId, source, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -542,14 +542,14 @@ func (this *CorrelationChartClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId, source)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartByClassifyIdAndSource(chartInfo.ChartClassifyId, source)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return

+ 28 - 28
controllers/data_manage/correlation/correlation_chart_info.go

@@ -335,7 +335,7 @@ func (this *CorrelationChartInfoController) Move() {
 	if chartInfo.ChartClassifyId != req.ChartClassifyId {
 		//查询需要修改的分类下是否存在同一个图表名称
 		tmpChartInfo, tmpErr := data_manage.GetChartInfoByClassifyIdAndName(req.ChartClassifyId, chartInfo.ChartName)
-		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
 			return
@@ -394,7 +394,7 @@ func (this *CorrelationChartInfoController) Move() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
@@ -510,7 +510,7 @@ func (this *CorrelationChartInfoController) List() {
 
 	if chartClassifyId > 0 {
 		chartClassifyId, err := data_manage.GetChartClassify(chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -550,7 +550,7 @@ func (this *CorrelationChartInfoController) List() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -568,7 +568,7 @@ func (this *CorrelationChartInfoController) List() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -576,7 +576,7 @@ func (this *CorrelationChartInfoController) List() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -620,7 +620,7 @@ func (this *CorrelationChartInfoController) List() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -631,7 +631,7 @@ func (this *CorrelationChartInfoController) List() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -682,7 +682,7 @@ func (this *CorrelationChartInfoController) Detail() {
 	chartInfo := new(data_manage.ChartInfoView)
 	chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图被删除,请刷新页面"
 			br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 			return
@@ -807,7 +807,7 @@ func (this *CorrelationChartInfoController) Detail() {
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -963,7 +963,7 @@ func (this *CorrelationChartInfoController) DetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -1001,7 +1001,7 @@ func (this *CorrelationChartInfoController) DetailFromUniqueCode() {
 					myCond += ` AND a.chart_info_id=? `
 					myPars = append(myPars, chartInfo.ChartInfoId)
 					myList, err := data_manage.GetMyChartByCondition(myCond, myPars)
-					if err != nil && err.Error() != utils.ErrNoRow() {
+					if err != nil && !utils.IsErrNoRow(err) {
 						br.Msg = "获取失败"
 						br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 						return
@@ -1072,7 +1072,7 @@ func (this *CorrelationChartInfoController) Refresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -1191,7 +1191,7 @@ func (this *CorrelationChartInfoController) Copy() {
 
 		_, e = data_manage.GetChartClassifyById(req.ChartClassifyId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -1204,7 +1204,7 @@ func (this *CorrelationChartInfoController) Copy() {
 	// 图表信息
 	originChart, e := data_manage.GetChartInfoById(req.ChartInfoId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "原图表不存在"
 			return
 		}
@@ -1221,7 +1221,7 @@ func (this *CorrelationChartInfoController) Copy() {
 	// 相关性图
 	originCorrelate := new(data_manage.ChartInfoCorrelation)
 	if e = originCorrelate.GetItemById(req.ChartInfoId); e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "原相关性图表不存在"
 			return
 		}
@@ -1234,7 +1234,7 @@ func (this *CorrelationChartInfoController) Copy() {
 	chartInfo := new(data_manage.ChartInfo)
 	if originCorrelate.AnalysisMode != 1 {
 		multipleGraphConfigChartMapping, err := data_manage.GetMultipleGraphConfigChartMappingByChartId(req.ChartInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = `保存失败`
 			br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 			return
@@ -1503,7 +1503,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -1724,7 +1724,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -1840,7 +1840,7 @@ func (this *CorrelationChartInfoController) EnInfoEdit() {
 	pars = append(pars, req.ChartInfoId, req.ChartNameEn, utils.CHART_SOURCE_CORRELATION)
 	existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "判断英文图表名称是否存在失败"
 			br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 			return
@@ -1953,7 +1953,7 @@ func (this *CorrelationChartInfoController) SearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1967,7 +1967,7 @@ func (this *CorrelationChartInfoController) SearchByEs() {
 		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -2042,7 +2042,7 @@ func (this *CorrelationChartInfoController) Newest() {
 		this.ServeJSON()
 	}()
 	item, err := data_manage.GetChartInfoByNewest(utils.CHART_SOURCE_CORRELATION)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取最新图表失败"
 		br.ErrMsg = "获取最新图表失败,Err:" + err.Error()
 		return
@@ -2115,7 +2115,7 @@ func (this *CorrelationChartInfoController) BaseInfoEdit() {
 	pars = append(pars, req.ChartName)
 	existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "判断英文图表名称是否存在失败"
 			br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 			return
@@ -2307,7 +2307,7 @@ func (this *CorrelationChartInfoController) MultiFactorAdd() {
 
 		_, e = data_manage.GetChartClassifyById(req.ClassifyId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -2663,7 +2663,7 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
 
 	chartInfo, e := data_manage.GetChartInfoById(req.ChartInfoId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "图表已被删除, 请刷新页面"
 			return
 		}
@@ -2715,7 +2715,7 @@ func (this *CorrelationChartInfoController) MultiFactorEdit() {
 
 		_, e = data_manage.GetChartClassifyById(req.ClassifyId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -2916,7 +2916,7 @@ func (this *CorrelationChartInfoController) MultiFactorDetail() {
 
 	chartInfo, e := data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "图表已被删除, 请刷新页面"
 			return
 		}

+ 22 - 22
controllers/data_manage/cross_variety/chart_info.go

@@ -84,7 +84,7 @@ func (c *ChartInfoController) List() {
 
 	if chartClassifyId > 0 {
 		chartClassifyId, err := data_manage.GetChartClassify(chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -124,7 +124,7 @@ func (c *ChartInfoController) List() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(c.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -142,7 +142,7 @@ func (c *ChartInfoController) List() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -150,7 +150,7 @@ func (c *ChartInfoController) List() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -194,7 +194,7 @@ func (c *ChartInfoController) List() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -205,7 +205,7 @@ func (c *ChartInfoController) List() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -491,7 +491,7 @@ func (c *ChartInfoController) Detail() {
 	chartInfo := new(data_manage.ChartInfoView)
 	chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图被删除,请刷新页面"
 			br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 			return
@@ -584,7 +584,7 @@ func (c *ChartInfoController) Detail() {
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -703,7 +703,7 @@ func (c *ChartInfoController) Relation() {
 	chartInfo := new(data_manage.ChartInfoView)
 	chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图被删除,请刷新页面"
 			br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 			return
@@ -973,7 +973,7 @@ func (c *ChartInfoController) Move() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(chartInfo.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
@@ -1075,7 +1075,7 @@ func (c *ChartInfoController) Refresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -1160,7 +1160,7 @@ func (c *ChartInfoController) EnInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -1279,7 +1279,7 @@ func (c *ChartInfoController) DeleteChart() {
 	//删除图表
 	chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已删除,请刷新页面"
 			br.ErrMsg = "指标不存在,Err:" + err.Error()
 			return
@@ -1342,7 +1342,7 @@ func (c *ChartInfoController) DeleteChart() {
 	pars = append(pars, req.ChartInfoId)
 
 	nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "删除失败"
 		br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 		return
@@ -1362,14 +1362,14 @@ func (c *ChartInfoController) DeleteChart() {
 		tmpPars = append(tmpPars, chartInfo.ChartClassifyId)
 
 		classifyItem, err := data_manage.GetChartClassifyByCondition(tmpCondition, tmpPars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 			return
 		}
 		if classifyItem != nil {
 			nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 				return
@@ -1460,7 +1460,7 @@ func (c *ChartInfoController) SearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(c.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1474,7 +1474,7 @@ func (c *ChartInfoController) SearchByEs() {
 		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -1558,7 +1558,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -1701,7 +1701,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -1796,7 +1796,7 @@ func (c *ChartInfoController) Save() {
 
 	chartItem, e := data_manage.GetChartInfoById(req.ChartInfoId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "图表已被删除, 请刷新页面"
 			return
 		}
@@ -1883,7 +1883,7 @@ func (c *ChartInfoController) BaseInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return

+ 10 - 10
controllers/data_manage/cross_variety/classify.go

@@ -36,7 +36,7 @@ func (c *ClassifyController) List() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(c.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -54,14 +54,14 @@ func (c *ClassifyController) List() {
 	}
 
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_CROSS_HEDGING)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoAll([]int{source})
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -195,7 +195,7 @@ func (c *ClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -257,7 +257,7 @@ func (c *ClassifyController) DeleteChartClassify() {
 	if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -281,7 +281,7 @@ func (c *ClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -344,7 +344,7 @@ func (c *ClassifyController) DeleteChartClassify() {
 		pars = append(pars, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -364,14 +364,14 @@ func (c *ClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return
@@ -497,7 +497,7 @@ func (c *ClassifyController) ChartClassifyMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartClassifyByParentIdAndSource(chartClassifyInfo.ParentId, chartClassifyInfo.Source)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取跨品种分析图表分类排序第一条的分类信息失败,Err:" + err.Error()
 			return

+ 5 - 5
controllers/data_manage/cross_variety/tag.go

@@ -45,12 +45,12 @@ func (c *TagController) Add() {
 	}
 	TagName := utils.TrimStr(req.TagName)
 	item, err := cross_variety.GetTagByName(TagName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "添加失败"
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.ChartTagId > 0 {
 		br.Msg = "添加失败,标签名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -110,12 +110,12 @@ func (c *TagController) Edit() {
 	TagName := utils.TrimStr(req.TagName)
 
 	item, err := cross_variety.GetTagByName(TagName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "添加失败"
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.ChartTagId != req.ChartTagId {
+	if item != nil && item.ChartTagId != req.ChartTagId && item.ChartTagId > 0 {
 		br.Msg = "添加失败,标签名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -248,7 +248,7 @@ func (c *TagController) Delete() {
 
 	varietyInfo, err := cross_variety.GetTagById(req.ChartTagId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "该标签不存在或已删除"
 			br.IsSendEmail = false
 		} else {

+ 5 - 5
controllers/data_manage/cross_variety/variety.go

@@ -44,12 +44,12 @@ func (c *VarietyController) Add() {
 	}
 	varietyName := utils.TrimStr(req.VarietyName)
 	item, err := cross_variety.GetVarietyByName(varietyName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "添加失败"
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.ChartVarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -109,12 +109,12 @@ func (c *VarietyController) Edit() {
 	varietyName := utils.TrimStr(req.VarietyName)
 
 	item, err := cross_variety.GetVarietyByName(varietyName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "添加失败"
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.ChartVarietyId != req.ChartVarietyId {
+	if item != nil && item.ChartVarietyId != req.ChartVarietyId && item.ChartVarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -246,7 +246,7 @@ func (c *VarietyController) Delete() {
 
 	varietyInfo, err := cross_variety.GetVarietyById(req.ChartVarietyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "该品种不存在或已删除"
 			br.IsSendEmail = false
 		} else {

+ 2 - 2
controllers/data_manage/data_manage_permission/message.go

@@ -129,7 +129,7 @@ func (c *DataMangePermissionController) MessageRead() {
 	messageOb := new(data_manage_permission.DataPermissionMessage)
 	messageItem, e := messageOb.GetItemById(req.MessageId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "消息不存在, 请刷新页面"
 			return
 		}
@@ -221,7 +221,7 @@ func (c *DataMangePermissionController) MessageDetail() {
 	messageOb := new(data_manage_permission.DataPermissionMessage)
 	messageItem, e := messageOb.GetItemById(messageId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "消息不存在, 请刷新页面"
 			return
 		}

+ 18 - 18
controllers/data_manage/edb_classify.go

@@ -32,13 +32,13 @@ func (this *EdbClassifyController) ListV2() {
 		this.ServeJSON()
 	}()
 	rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 	classifyAll, err := data_manage.GetEdbClassifyAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -60,7 +60,7 @@ func (this *EdbClassifyController) ListV2() {
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}
 	confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 		return
@@ -70,7 +70,7 @@ func (this *EdbClassifyController) ListV2() {
 		noPermissionEdbInfoIdMap[v.EdbInfoId] = true
 	}
 	allEdbInfo, err := data_manage.GetEdbInfoAll(utils.EDB_INFO_TYPE)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -653,13 +653,13 @@ func (this *EdbClassifyController) ItemsV2() {
 		this.ServeJSON()
 	}()
 	rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 	classifyAll, err := data_manage.GetEdbClassifyAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -778,7 +778,7 @@ func (this *EdbClassifyController) ClassifyEdbInfoList() {
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}
 	confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 		return
@@ -789,7 +789,7 @@ func (this *EdbClassifyController) ClassifyEdbInfoList() {
 	}
 
 	allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 0, 0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -839,19 +839,19 @@ func (this *EdbClassifyController) ItemsV3() {
 		this.ServeJSON()
 	}()
 	rootList, err := data_manage.GetEdbClassifyByParentId(0, 0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 	rootTwoList, err := data_manage.GetEdbClassifyByParentIdTwo(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 	classifyAll, err := data_manage.GetEdbClassifyAllV2(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -977,7 +977,7 @@ func (this *EdbClassifyController) SimpleList() {
 		sysUserId = this.SysUser.AdminId
 	}
 	rootList, err := data_manage.GetEdbClassifyByParentId(parentId, 0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -990,7 +990,7 @@ func (this *EdbClassifyController) SimpleList() {
 		// 获取当前账号的不可见指标
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1114,7 +1114,7 @@ func (this *EdbClassifyController) ClassifyTree() {
 	}()
 	level, _ := this.GetInt(`Level`)
 	allList, err := data_manage.GetNormalEdbClassifyAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -1289,7 +1289,7 @@ func (this *EdbInfoController) ClassifyEdbInfoList() {
 			pars = append(pars, classifyIdsArr)
 		} else {
 			classifyAll, err := data_manage.GetNormalEdbClassifyAll()
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取数据失败,Err:" + err.Error()
 				return
@@ -1342,7 +1342,7 @@ func (this *EdbInfoController) ClassifyEdbInfoList() {
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}
 	confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 		return
@@ -1357,7 +1357,7 @@ func (this *EdbInfoController) ClassifyEdbInfoList() {
 	}
 
 	count, err := data_manage.GetEdbInfoByConditionCount(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -1365,7 +1365,7 @@ func (this *EdbInfoController) ClassifyEdbInfoList() {
 	page := paging.GetPaging(currentIndex, pageSize, count)
 
 	list, err := data_manage.GetEdbInfoListByCondition(condition, pars, startSize, pageSize, "")
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

File diff suppressed because it is too large
+ 116 - 118
controllers/data_manage/edb_info.go


+ 12 - 7
controllers/data_manage/edb_info_calculate.go

@@ -764,7 +764,7 @@ func (this *ChartInfoController) CalculateBatchEdit() {
 
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "指标已被删除,请刷新页面"
 			br.ErrMsg = "指标已被删除,请刷新页面:Err:" + err.Error()
 			return
@@ -933,7 +933,7 @@ func (this *ChartInfoController) CalculateBatchReset() {
 
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "指标已被删除,请刷新页面"
 			br.ErrMsg = "指标已删除,请刷新页面:Err:" + err.Error()
 			return
@@ -968,7 +968,7 @@ func (this *ChartInfoController) CalculateBatchReset() {
 	//	for _, v := range fromEdbInfoList {
 	//		edbInfo, err := data_manage.GetEdbInfoById(v.FromEdbInfoId)
 	//		if err != nil {
-	//			if err.Error() == utils.ErrNoRow() {
+	//			if utils.IsErrNoRow(err) {
 	//				br.Msg = "重新计算失败"
 	//				br.Msg = "指标 " + strconv.Itoa(v.FromEdbInfoId) + " 不存在"
 	//				return
@@ -1347,7 +1347,7 @@ func (this *ChartInfoController) EditPythonEdb() {
 	//获取指标信息
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "指标已被删除,请刷新页面"
 			br.ErrMsg = "指标已被删除,请刷新页面:Err:" + err.Error()
 			return
@@ -1476,7 +1476,12 @@ func (this *EdbInfoController) QueryEdbDataTable() {
 	if edbInfo.Source == utils.DATA_SOURCE_BUSINESS && utils.UseMongo {
 		templateStr = fmt.Sprintf("# 查询条件\nquery = {\"edb_code\": \"%s\"}\n# 排序\nsort = [(\"data_time\", -1)]  # -1 表示降序排列,对应 SQL 的 DESC\nprojection = {\"data_time\": 1, \"value\": 1, \"_id\": 0}  # 只选择data_time和value字段,忽略_id字段\n# 使用 find() 方法获取数据,然后使用 aggregate() 转换为列表\nraw_data = list(collection.find(query, projection).sort(sort))\n# 将结果转换为 DataFrame\nraw = pd.DataFrame(raw_data)\n# 转换data_time字段为本地时区时间\nraw['data_time'] = raw['data_time'].apply(lambda x: x.replace(tzinfo=utc_tz)).dt.tz_convert(local_tz).dt.strftime('%s')", edbInfo.EdbCode, "%Y-%m-%d")
 	} else {
-		templateStr = fmt.Sprintf("sql1 = f\"\"\"SELECT data_time,`value` FROM %s WHERE edb_code = '%s' ORDER BY data_time DESC;\"\"\"\nraw = pandas_fetch_all(sql1, db)", tableName, edbInfo.EdbCode)
+		switch utils.DbDriverName {
+		case `dm`:
+			templateStr = fmt.Sprintf("sql1 = f\"\"\"SELECT data_time,\"value\" FROM %s WHERE edb_code = '%s' ORDER BY data_time DESC;\"\"\"\nraw = pandas_fetch_all(sql1, db)", tableName, edbInfo.EdbCode)
+		default:
+			templateStr = fmt.Sprintf("sql1 = f\"\"\"SELECT data_time,`value` FROM %s WHERE edb_code = '%s' ORDER BY data_time DESC;\"\"\"\nraw = pandas_fetch_all(sql1, db)", tableName, edbInfo.EdbCode)
+		}
 	}
 	info := data_manage.TableInfoResp{
 		ColumnList:  columnList,
@@ -2252,7 +2257,7 @@ func (this *ChartInfoController) CalculateMultiChoice() {
 	}
 
 	list, err := data_manage.GetEdbInfoByIdList(edbIdArr)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标列表失败"
 		br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
 		return
@@ -2445,7 +2450,7 @@ func (this *ChartInfoController) CalculateMultiSearch() {
 		}
 
 		list, err := data_manage.GetEdbInfoByIdList(edbIdArr)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取指标列表失败"
 			br.ErrMsg = "获取指标列表失败,Err:" + err.Error()
 			return

+ 11 - 11
controllers/data_manage/edb_info_refresh.go

@@ -97,14 +97,14 @@ func (c *EdbInfoController) RefreshClassifyList() {
 	switch source {
 	case utils.DATA_SOURCE_MYSTEEL_CHEMICAL: // 钢联
 		rootList, err := data_manage.GetBaseFromMysteelChemicalClassifyByParentId(0)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
 
 		classifyAll, err := data_manage.GetAllBaseFromMysteelChemicalClassify()
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
@@ -161,14 +161,14 @@ func (c *EdbInfoController) RefreshClassifyList() {
 			Children:     nil,
 		})
 		rootList, err := data_manage.GetBaseFromSmmClassifyByParentId(0)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
 
 		classifyAll, err := data_manage.GetAllBaseFromSmmClassify()
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
@@ -204,7 +204,7 @@ func (c *EdbInfoController) RefreshClassifyList() {
 
 	default:
 		tmpList, err := data_manage.GetAllEdbClassify()
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
@@ -313,7 +313,7 @@ func (c *EdbInfoController) RefreshEdbList() {
 	startSize = utils.StartIndex(currentIndex, pageSize)
 
 	total, list, err := data.GetList(source, subSource, classifyId, terminalCode, sysUserId, frequency, keyword, status, startSize, pageSize, sortParam, sortType)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -490,7 +490,7 @@ func (c *EdbInfoController) SaveEdbRefreshStatus() {
 	if req.IsSelectAll {
 		// 如果是列表全选
 		_, edbList, err := data.GetList(req.Source, req.SubSource, req.ClassifyId, req.TerminalCode, req.SysUserId, req.Frequency, req.Keyword, req.Status, 0, 100000, "", "")
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
@@ -538,7 +538,7 @@ func (c *EdbInfoController) SaveEdbRefreshStatus() {
 	if isStop == 1 {
 		fromEdbIdList := make([]int, 0)
 		edbList, e := data_manage.GetEdbInfoByIdList(edbIdList)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + e.Error()
 			return
@@ -607,7 +607,7 @@ func (c *EdbInfoController) SaveEdbRefreshStatusSingle() {
 	// 查询指标
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "指标不存在"
 			return
 		}
@@ -694,7 +694,7 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 	if req.IsSelectAll {
 		// 如果是列表全选
 		_, edbList, err := data.GetEdbRelationList(req.Source, edbType, req.ClassifyId, req.SysUserId, req.Frequency, req.Keyword, req.Status, 0, 100000, "", "")
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
@@ -727,7 +727,7 @@ func (c *EdbInfoController) SaveRelationEdbRefreshStatus() {
 	}
 	//查询指标信息
 	edbList, e := data_manage.GetEdbInfoByIdList(edbIdList)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + e.Error()
 		return

+ 8 - 8
controllers/data_manage/edb_info_relation.go

@@ -80,7 +80,7 @@ func (c *EdbInfoRelationController) RelationEdbList() {
 	startSize = utils.StartIndex(currentIndex, pageSize)
 
 	total, list, err := data.GetEdbRelationList(source, edbType, classifyId, sysUserId, frequency, keyword, status, startSize, pageSize, sortParam, sortType)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -127,7 +127,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 	startSize = utils.StartIndex(currentIndex, pageSize)
 
 	total, relationList, err := data_manage.GetEdbInfoRelationDetailList(edbInfoId, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -164,7 +164,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 	objectNameMap := make(map[string]string)
 	if len(sandboxIds) > 0 {
 		sandboxList, err := sandbox.GetSandboxNameByIds(sandboxIds)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
@@ -182,7 +182,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, eventInfoIds)
 		eventList, err := matterOb.GetItemsByCondition(cond, pars, []string{}, "")
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取事件日历数据失败,Err:" + err.Error()
 			return
@@ -196,7 +196,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 	// 查询图表
 	if len(chartInfoIds) > 0 {
 		chartList, err := data_manage.GetChartInfoByIdList(chartInfoIds)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表数据失败,Err:" + err.Error()
 			return
@@ -213,7 +213,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 		pars := make([]interface{}, 0)
 		pars = append(pars, tableInfoIds)
 		tableList, err := excel.GetNoContentExcelInfoListByConditionNoPage(cond, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取表格数据失败,Err:" + err.Error()
 			return
@@ -231,7 +231,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 			pars = make([]interface{}, 0)
 			pars = append(pars, parentIds)
 			parentList, err := excel.GetNoContentExcelInfoListByConditionNoPage(cond, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取表格数据失败,Err:" + err.Error()
 				return
@@ -254,7 +254,7 @@ func (c *EdbInfoRelationController) RelationEdbListDetail() {
 	// 查询预测指标名称
 	if len(predictEdbIds) > 0 {
 		predictList, err := data_manage.GetEdbInfoByIdList(predictEdbIds)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取预测指标信息失败,Err:" + err.Error()
 			return

+ 2 - 2
controllers/data_manage/eia_steo.go

@@ -557,7 +557,7 @@ func (c *EdbInfoController) EiaSteoNameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_EIA_STEO, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取钢联已存在信息失败,Err:" + err.Error()
 			return
@@ -815,7 +815,7 @@ func (this *EdbInfoController) EiaSteoAdd() {
 
 	tmpInfo, err := data_manage.GetBaseFromEiaSteoIndexByCode(req.EdbCode)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
 			return

+ 7 - 7
controllers/data_manage/excel/balance_table.go

@@ -506,7 +506,7 @@ func (c *ExcelInfoController) BalanceChartInfoAdd() {
 	adminItem, e := system.GetSysAdminById(sysUser.AdminId)
 	if e != nil {
 		br.Msg = "操作失败"
-		br.ErrMsg = "获取系统用户数据失败,Err:" + err.Error()
+		br.ErrMsg = "获取系统用户数据失败,Err:" + e.Error()
 		return
 	}
 	if utils.BusinessCode == utils.BusinessCodeSandbox && adminItem.DepartmentName == "ETA试用客户" {
@@ -713,7 +713,7 @@ func (c *ExcelInfoController) GetBalanceChartList() {
 	// 查询所有子表
 	excelInfo, err := excel.GetExcelInfoById(excelInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "表格不存在"
 			return
 		}
@@ -811,7 +811,7 @@ func (c *ExcelInfoController) DeleteBalanceChart() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -1596,7 +1596,7 @@ func (this *ExcelInfoController) BalanceChartInfoBaseEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -1619,7 +1619,7 @@ func (this *ExcelInfoController) BalanceChartInfoBaseEdit() {
 		edbInfoId := v.EdbInfoId
 		edbInfo, err := excel.GetExcelChartEdbById(edbInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表不存在!"
 				br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 				return
@@ -1654,7 +1654,7 @@ func (this *ExcelInfoController) BalanceChartInfoBaseEdit() {
 
 			edbExist, err := excel.GetBalanceChartEdbByCondition(edbCondition, edbPars)
 			if err != nil {
-				if err.Error() != utils.ErrNoRow() {
+				if !utils.IsErrNoRow(err) {
 					br.Msg = "判断英文指标名称是否存在失败"
 					br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + err.Error()
 					return
@@ -1686,7 +1686,7 @@ func (this *ExcelInfoController) BalanceChartInfoBaseEdit() {
 
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return

+ 9 - 9
controllers/data_manage/excel/custom_analysis.go

@@ -62,7 +62,7 @@ func (c *CustomAnalysisController) ExcelByName() {
 	// 获取数据详情
 	excelDetail, err := excelModel.GetNoContentExcelInfoByName(excelName, utils.CUSTOM_ANALYSIS_TABLE, sysUser.AdminId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"
@@ -413,7 +413,7 @@ func (c *CustomAnalysisController) BaseExcelDetail() {
 	// 获取数据详情
 	excelDetail, err := excelModel.GetNoContentExcelInfoByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"
@@ -571,7 +571,7 @@ func (c *CustomAnalysisController) ExcelDataList() {
 	// 获取数据详情
 	excelDetail, err := excelModel.GetNoContentExcelInfoByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Ret = 200
 			br.Success = true
 			br.Msg = "获取成功"
@@ -796,7 +796,7 @@ func (c *CustomAnalysisController) ClassifyList() {
 		classifyMap[v.ExcelClassifyId] = v
 	}
 	allExcelInfo, err := excelModel.GetNoContentExcelInfoAll(source, sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
 		return
@@ -959,14 +959,14 @@ func (c *CustomAnalysisController) List() {
 	// 筛选分类
 	if !isShare && excelClassifyId > 0 {
 		_, err := excelModel.GetExcelClassifyById(excelClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取表格信息失败"
 			br.ErrMsg = "获取信息失败,GetExcelClassify,Err:" + err.Error()
 			return
 		}
 
 		childClassify, e, _ := excel2.GetChildClassifyByClassifyId(excelClassifyId, source)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
 			return
@@ -1000,7 +1000,7 @@ func (c *CustomAnalysisController) List() {
 	}
 	startSize = paging.StartIndex(currentIndex, pageSize)
 	list, err := excelModel.GetNoContentExcelListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取表格信息失败"
 		br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
@@ -1013,7 +1013,7 @@ func (c *CustomAnalysisController) List() {
 
 	// 总数据量
 	dataCount, err := excelModel.GetExcelListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取表格列表信息失败"
 		br.ErrMsg = "获取表格列表数据总数失败,Err:" + err.Error()
 		return
@@ -1066,7 +1066,7 @@ func (c *CustomAnalysisController) Share() {
 
 	excelInfo, e := excelModel.GetExcelInfoById(req.ExcelInfoId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "表格不存在, 请刷新页面"
 			return
 		}

+ 1 - 1
controllers/data_manage/excel/custom_analysis_edb.go

@@ -312,7 +312,7 @@ func (c *CustomAnalysisController) EditEdb() {
 
 	edbInfo, err := data_manage.GetEdbInfoById(req.EdbInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "指标已被删除,请刷新页面"
 			br.ErrMsg = "指标已被删除,请刷新页面:Err:" + err.Error()
 			return

+ 15 - 15
controllers/data_manage/excel/excel_classify.go

@@ -87,14 +87,14 @@ func (this *ExcelClassifyController) List() {
 		}
 
 		allExcelInfo, err = excel.GetBalanceNoContentExcelInfoAll(source, excelIds, showUserId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
 			return
 		}
 	} else {
 		allExcelInfo, err = excel.GetNoContentExcelInfoAll(source, showUserId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
 			return
@@ -196,7 +196,7 @@ func AnalysisClassifyList(this *ExcelClassifyController) (br *models.BaseRespons
 	// 获取三级分类
 	// 根据来源获取所有excel表格(无内容)
 	allExcelInfo, err := excel.GetNoContentExcelInfoAll(source, showUserId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
 		return
@@ -432,7 +432,7 @@ func (this *ExcelClassifyController) AddExcelClassify() {
 		var parent *excel.ExcelClassify
 		parent, err = excel.GetExcelClassifyById(req.ParentId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "父级分类不存在"
 				return
 			}
@@ -577,7 +577,7 @@ func (this *ExcelClassifyController) DeleteExcelClassifyCheck() {
 	// 校验是否存在该分类
 	ExcelClassifyInfo, err := excel.GetExcelClassifyById(req.ExcelClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "该分类不存在"
 			br.ErrMsg = "该分类不存在"
 			return
@@ -607,7 +607,7 @@ func (this *ExcelClassifyController) DeleteExcelClassifyCheck() {
 			tipsMsg = "该分类下关联表格不可删除"
 		} else {
 			childClassify, e := excel.GetChildClassifyById(req.ExcelClassifyId)
-			if e != nil && e.Error() != utils.ErrNoRow() {
+			if e != nil && !utils.IsErrNoRow(e) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
 				return
@@ -621,7 +621,7 @@ func (this *ExcelClassifyController) DeleteExcelClassifyCheck() {
 				var pars []interface{}
 				pars = append(pars, classifyIds)
 				childCount, err := excel.GetExcelInfoCountByCondition(condition, pars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "查询分类下表格数量失败,Err:" + err.Error()
 					return
@@ -701,7 +701,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 	if req.ExcelClassifyId > 0 && req.ExcelInfoId == 0 {
 		//判断是否含有指标
 		count, err := excel.GetExcelInfoCountByClassifyId(req.ExcelClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -713,7 +713,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 			return
 		} else {
 			childClassify, e := excel.GetChildClassifyById(req.ExcelClassifyId)
-			if e != nil && e.Error() != utils.ErrNoRow() {
+			if e != nil && !utils.IsErrNoRow(e) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
 				return
@@ -727,7 +727,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 				var pars []interface{}
 				pars = append(pars, classifyIds)
 				childCount, err := excel.GetExcelInfoCountByCondition(condition, pars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "查询分类下表格数量失败,Err:" + err.Error()
 					return
@@ -744,7 +744,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 		if err != nil {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取分类失败,Err:" + err.Error()
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类不存在"
 				br.ErrMsg = "分类不存在"
 			}
@@ -764,7 +764,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 	if req.ExcelInfoId > 0 {
 		excelInfo, err := excel.GetExcelInfoById(req.ExcelInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "表格已删除,请刷新页面"
 				br.ErrMsg = "表格已删除,请刷新页面"
 				return
@@ -808,7 +808,7 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 			pars = append(pars, excelInfo.Sort, excelInfo.Sort, excelInfo.ExcelInfoId)
 
 			nextItem, err = excel.GetNextExcelInfoByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级表格信息失败,Err:" + err.Error()
 				return
@@ -817,14 +817,14 @@ func (this *ExcelClassifyController) DeleteExcelClassify() {
 			// 如果没找到,那么查找下一个分类的第一个表格
 			if nextItem == nil {
 				currClassifyInfo, err := excel.GetExcelClassifyById(excelInfo.ExcelClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取当前表格分类信息失败,Err:" + err.Error()
 					return
 				}
 
 				nextItem, err = excel.GetNextExcelInfo(excelInfo.ExcelClassifyId, currClassifyInfo.Sort, currClassifyInfo.Source)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级表格信息失败,Err:" + err.Error()
 					return

+ 21 - 21
controllers/data_manage/excel/excel_info.go

@@ -91,7 +91,7 @@ func (c *ExcelInfoController) Add() {
 	if req.ExcelClassifyId > 0 {
 		excelClassify, e := excel3.GetExcelClassifyById(req.ExcelClassifyId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "分类不存在"
 				br.ErrMsg = "分类不存在"
 				br.IsSendEmail = false
@@ -112,7 +112,7 @@ func (c *ExcelInfoController) Add() {
 	if req.ParentId > 0 {
 		parentExcelInfo, e := excel3.GetExcelInfoById(req.ParentId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "父级ETA表格被删除,请刷新页面"
 				return
 			}
@@ -436,14 +436,14 @@ func (c *ExcelInfoController) List() {
 	// 筛选分类
 	if excelClassifyId > 0 {
 		_, err := excel3.GetExcelClassifyById(excelClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取表格信息失败"
 			br.ErrMsg = "获取信息失败,GetExcelClassify,Err:" + err.Error()
 			return
 		}
 
 		childClassify, e, _ := excel2.GetChildClassifyByClassifyId(excelClassifyId, source)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
 			return
@@ -521,7 +521,7 @@ func (c *ExcelInfoController) List() {
 
 			//获取表格信息
 			tmpList, e := excel3.GetNoContentExcelListByConditionNoPage(newCondition, newPars)
-			if e != nil && e.Error() != utils.ErrNoRow() {
+			if e != nil && !utils.IsErrNoRow(e) {
 				br.Success = true
 				br.Msg = "获取表格信息失败"
 				br.ErrMsg = "获取表格信息失败,Err:" + e.Error()
@@ -579,7 +579,7 @@ func (c *ExcelInfoController) List() {
 	}
 	//获取表格信息
 	list, err := excel3.GetNoContentExcelListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取表格信息失败"
 		br.ErrMsg = "获取表格信息失败,Err:" + err.Error()
@@ -587,7 +587,7 @@ func (c *ExcelInfoController) List() {
 	}
 
 	lenList := len(list)
-	if list == nil || lenList <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || lenList <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		list = make([]*excel3.MyExcelInfoList, 0)
 	}
 
@@ -648,7 +648,7 @@ func (c *ExcelInfoController) List() {
 
 	// 总数据量
 	dataCount, err := excel3.GetExcelListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取表格列表信息失败"
 		br.ErrMsg = "获取表格列表数据总数失败,Err:" + err.Error()
 		return
@@ -899,7 +899,7 @@ func (c *ExcelInfoController) Edit() {
 	if req.ExcelClassifyId > 0 {
 		excelClassify, e := excel3.GetExcelClassifyById(req.ExcelClassifyId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "分类不存在"
 				br.ErrMsg = "分类不存在"
 				br.IsSendEmail = false
@@ -919,7 +919,7 @@ func (c *ExcelInfoController) Edit() {
 	if excelInfo.ParentId > 0 {
 		parentExcelInfo, e := excel3.GetExcelInfoById(excelInfo.ParentId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "父级ETA表格被删除,请刷新页面"
 				return
 			}
@@ -1211,7 +1211,7 @@ func (c *ExcelInfoController) Move() {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取分类信息失败" + err.Error()
 
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类已被删除,不可移动,请刷新页面"
 				br.ErrMsg = "分类已被删除,不可移动,请刷新页面"
 				br.IsSendEmail = false
@@ -1420,7 +1420,7 @@ func (c *ExcelInfoController) Delete() {
 		condition += " AND sort>=? "
 		pars = append(pars, excelInfo.Sort)
 		nextItem, err = excel3.GetNextExcelInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级表格信息失败,Err:" + err.Error()
 			return
@@ -1429,7 +1429,7 @@ func (c *ExcelInfoController) Delete() {
 		// 如果没找到,那么查找下一个分类的第一个表格
 		if nextItem == nil {
 			currClassifyInfo, err := excel3.GetExcelClassifyById(excelInfo.ExcelClassifyId)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取当前表格分类信息失败,Err:" + err.Error()
 				return
@@ -1458,7 +1458,7 @@ func (c *ExcelInfoController) Delete() {
 			//}
 
 			nextItem, err = excel3.GetNextExcelInfo(excelInfo.ExcelClassifyId, currClassifyInfo.Sort, currClassifyInfo.Source)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级表格信息失败,Err:" + err.Error()
 				return
@@ -1533,7 +1533,7 @@ func (c *ExcelInfoController) AddDraft() {
 
 	excelClassify, err := excel3.GetExcelClassifyById(req.ExcelClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			br.IsSendEmail = false
@@ -1632,7 +1632,7 @@ func (c *ExcelInfoController) GetExcelTableData() {
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取ETA表格信息失败,Err:" + err.Error()
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "ETA表格被删除,请刷新页面"
 			br.ErrMsg = "ETA表格被删除,请刷新页面,Err:" + err.Error()
 			br.IsSendEmail = false
@@ -1752,7 +1752,7 @@ func (c *ExcelInfoController) GetExcelTableData() {
 
 	// 获取表格引用
 	reference, err := excel3.GetReferencedExcelConfig(referencedId, fromScene, uniqueCode, uuid)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取表格引用失败,Err:" + err.Error()
 		return
@@ -2664,7 +2664,7 @@ func (c *ExcelInfoController) Download() {
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取ETA表格信息失败,Err:" + err.Error()
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "ETA表格被删除,请刷新页面"
 			br.ErrMsg = "ETA表格被删除,请刷新页面,Err:" + err.Error()
 			br.IsSendEmail = false
@@ -3098,7 +3098,7 @@ func (c *ExcelInfoController) BatchRefresh() {
 	syncing, e := data.BatchRefreshEdbByEdbIds(edbIds, redisKey, refreshKeys)
 	if e != nil {
 		br.Msg = "刷新失败"
-		br.ErrMsg = "刷新表格关联指标信息失败,Err:" + err.Error()
+		br.ErrMsg = "刷新表格关联指标信息失败,Err:" + e.Error()
 		return
 	}
 
@@ -3734,7 +3734,7 @@ func (c *ExcelInfoController) SaveExcelReference() {
 	addList := make([]*excel3.ReferencedExcelConfig, 0)
 
 	exist, e := excel3.GetReferencedExcelConfig(req.ReferencedId, req.FromScene, req.UniqueCode, req.Uuid)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "查找引用失败"
 		br.ErrMsg = "查找引用失败,Err:" + e.Error()
 		return
@@ -3769,7 +3769,7 @@ func (c *ExcelInfoController) SaveExcelReference() {
 
 	if len(addList) > 0 {
 		err = excel3.AddReferencedExcelConfig(addList)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "添加引用失败"
 			br.ErrMsg = "添加引用失败,Err:" + err.Error()
 			return

+ 2 - 2
controllers/data_manage/factor_edb_series.go

@@ -328,7 +328,7 @@ func (this *FactorEdbSeriesController) Edit() {
 	seriesOb := new(data_manage.FactorEdbSeries)
 	seriesItem, e := seriesOb.GetItemById(req.SeriesId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "该因子指标系列不存在"
 			return
 		}
@@ -460,7 +460,7 @@ func (this *FactorEdbSeriesController) Detail() {
 	seriesOb := new(data_manage.FactorEdbSeries)
 	series, e := seriesOb.GetItemById(seriesId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "该因子指标系列不存在"
 			return
 		}

+ 1 - 1
controllers/data_manage/fenwei_data.go

@@ -944,7 +944,7 @@ func (this *EdbInfoController) FenWeiIndexDataExport() {
 
 			var dataList []*data_manage.BaseFromFenweiData
 			dataList, err = data_manage.GetBaseFromFenWeiDataByIndexCode(v.IndexCode)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.ErrMsg = "GetBaseFromFenWeiDataByIndexCode,Err:" + err.Error()
 				br.Msg = "获取数据失败"
 				return

+ 15 - 0
controllers/data_manage/fix.go

@@ -0,0 +1,15 @@
+package data_manage
+
+func init() {
+
+	// 刷新指标
+	//data.AddOrEditAllEdbInfoToEs()
+
+	// 修复ETA图库
+	//data.AddAllChartInfo()
+
+	// 修复我的图库
+	//data.AddAllMyChartInfo()
+	//
+	//fmt.Println("修复完成")
+}

+ 12 - 12
controllers/data_manage/future_good/future_good_chart_classify.go

@@ -36,7 +36,7 @@ func (this *FutureGoodChartClassifyController) ChartClassifyList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -67,14 +67,14 @@ func (this *FutureGoodChartClassifyController) ChartClassifyList() {
 	}
 
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_FUTURE_GOOD)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoAll([]int{utils.CHART_SOURCE_FUTURE_GOOD, utils.CHART_SOURCE_FUTURE_GOOD_PROFIT})
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -108,13 +108,13 @@ func (this *FutureGoodChartClassifyController) ChartClassifyList() {
 // getChartClassifyListForMe 获取我创建的图表
 func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_FUTURE_GOOD)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_FUTURE_GOOD, utils.CHART_SOURCE_FUTURE_GOOD_PROFIT}, adminInfo.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -307,7 +307,7 @@ func (this *FutureGoodChartClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -369,7 +369,7 @@ func (this *FutureGoodChartClassifyController) DeleteChartClassify() {
 	if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -393,7 +393,7 @@ func (this *FutureGoodChartClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -455,7 +455,7 @@ func (this *FutureGoodChartClassifyController) DeleteChartClassify() {
 		pars = append(pars, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -475,14 +475,14 @@ func (this *FutureGoodChartClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return
@@ -617,7 +617,7 @@ func (this *FutureGoodChartClassifyController) ChartClassifyMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartClassifyByParentId(chartClassifyInfo.ParentId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return

+ 38 - 38
controllers/data_manage/future_good/future_good_chart_info.go

@@ -82,7 +82,7 @@ func (this *FutureGoodChartInfoController) ChartList() {
 
 	if chartClassifyId > 0 {
 		chartClassifyId, err := data_manage.GetChartClassify(chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -123,7 +123,7 @@ func (this *FutureGoodChartInfoController) ChartList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -141,7 +141,7 @@ func (this *FutureGoodChartInfoController) ChartList() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -149,7 +149,7 @@ func (this *FutureGoodChartInfoController) ChartList() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -193,7 +193,7 @@ func (this *FutureGoodChartInfoController) ChartList() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -204,7 +204,7 @@ func (this *FutureGoodChartInfoController) ChartList() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -254,7 +254,7 @@ func (this *FutureGoodChartInfoController) ChartInfoSave() {
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面!"
 			br.ErrMsg = "图表已被删除,请刷新页面,ChartInfoId:" + strconv.Itoa(req.ChartInfoId)
 			return
@@ -363,7 +363,7 @@ func (this *FutureGoodChartInfoController) ChartInfoAdd() {
 
 	chartClassify, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -405,7 +405,7 @@ func (this *FutureGoodChartInfoController) ChartInfoAdd() {
 		if v.Source == utils.CHART_SOURCE_DEFAULT { //ETA指标
 			edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "指标不存在!"
 					br.ErrMsg = "指标不存在,edbInfoId:" + strconv.Itoa(edbInfoId)
 					return
@@ -433,7 +433,7 @@ func (this *FutureGoodChartInfoController) ChartInfoAdd() {
 		} else { // 商品指标
 			edbInfo, err := future_good.GetFutureGoodEdbInfo(edbInfoId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "指标不存在!"
 					br.ErrMsg = "指标不存在,edbInfoId:" + strconv.Itoa(edbInfoId)
 					return
@@ -648,7 +648,7 @@ func (this *FutureGoodChartInfoController) ChartInfoEdit() {
 
 	chartClassify, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -664,7 +664,7 @@ func (this *FutureGoodChartInfoController) ChartInfoEdit() {
 	}
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -726,7 +726,7 @@ func (this *FutureGoodChartInfoController) ChartInfoEdit() {
 		if v.Source == utils.CHART_SOURCE_DEFAULT { //ETA指标
 			edbInfo, err := data_manage.GetEdbInfoById(edbInfoId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "图表不存在!"
 					br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoId)
 					return
@@ -746,7 +746,7 @@ func (this *FutureGoodChartInfoController) ChartInfoEdit() {
 		} else { //商品指标
 			edbInfo, err := future_good.GetFutureGoodEdbInfo(edbInfoId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "指标不存在!"
 					br.ErrMsg = "指标不存在,edbInfoId:" + strconv.Itoa(edbInfoId)
 					return
@@ -862,7 +862,7 @@ func (this *FutureGoodChartInfoController) ChartEnInfoEdit() {
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -896,7 +896,7 @@ func (this *FutureGoodChartInfoController) ChartEnInfoEdit() {
 	//校验指标信息是否存在
 	edbInfo, err := data_manage.GetEdbInfoById(edbInfoMapping.EdbInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表不存在!"
 			br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoMapping.EdbInfoId)
 			return
@@ -926,7 +926,7 @@ func (this *FutureGoodChartInfoController) ChartEnInfoEdit() {
 
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return
@@ -951,7 +951,7 @@ func (this *FutureGoodChartInfoController) ChartEnInfoEdit() {
 			}
 			futureGoodEdbInfo, err := future_good.GetFutureGoodEdbInfo(futureGoodEdbInfoMapping.EdbInfoId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "图表不存在!"
 					br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(edbInfoMapping.EdbInfoId)
 					return
@@ -1040,7 +1040,7 @@ func (this *FutureGoodChartInfoController) ChartInfoNewest() {
 		this.ServeJSON()
 	}()
 	item, err := data_manage.GetChartInfoByNewest(2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取最新图表失败"
 		br.ErrMsg = "获取最新图表失败,Err:" + err.Error()
 		return
@@ -1113,12 +1113,12 @@ func (this *FutureGoodChartInfoController) ChartInfoMove() {
 	if chartInfo.ChartClassifyId != req.ChartClassifyId {
 		//查询需要修改的分类下是否存在同一个图表名称
 		tmpChartInfo, tmpErr := data_manage.GetChartInfoByClassifyIdAndName(req.ChartClassifyId, chartInfo.ChartName)
-		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
 			return
 		}
-		if tmpChartInfo != nil {
+		if tmpChartInfo != nil && tmpChartInfo.ChartInfoId > 0 {
 			br.Msg = "移动失败,同一个分类下图表名称不允许重复"
 			br.ErrMsg = "移动失败,同一个分类下图表名称不允许重复"
 			return
@@ -1172,7 +1172,7 @@ func (this *FutureGoodChartInfoController) ChartInfoMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
@@ -1284,7 +1284,7 @@ func (this *FutureGoodChartInfoController) ChartInfoDetail() {
 	if chartInfoId > 0 {
 		chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图被删除,请刷新页面"
 				br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 				return
@@ -1328,7 +1328,7 @@ func getFutureGoodChartInfo(chartInfo *data_manage.ChartInfoView, chartType, dat
 	}
 	futureGoodEdbInfoMapping, err = data_manage.GetFutureGoodEdbChartEdbMapping(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "期货指标不存在"
 			return
 		}
@@ -1462,7 +1462,7 @@ func getFutureGoodChartInfo(chartInfo *data_manage.ChartInfoView, chartType, dat
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -1535,7 +1535,7 @@ func (this *FutureGoodChartInfoController) ChartInfoDetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -1589,7 +1589,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -1831,7 +1831,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -2173,7 +2173,7 @@ func (this *FutureGoodChartInfoController) BaseChartInfoDetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -2304,7 +2304,7 @@ func (this *FutureGoodChartInfoController) BaseChartInfoDetailFromUniqueCode() {
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -2400,7 +2400,7 @@ func (this *FutureGoodChartInfoController) ChartInfoSearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -2414,7 +2414,7 @@ func (this *FutureGoodChartInfoController) ChartInfoSearchByEs() {
 		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, []int{utils.CHART_SOURCE_FUTURE_GOOD, utils.CHART_SOURCE_FUTURE_GOOD_PROFIT}, noPermissionChartIdList, startSize, pageSize)
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, []int{utils.CHART_SOURCE_FUTURE_GOOD, utils.CHART_SOURCE_FUTURE_GOOD_PROFIT}, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -2513,7 +2513,7 @@ func (this *FutureGoodChartInfoController) ChartInfoRefresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -2893,7 +2893,7 @@ func copyChartInfo(oldChartInfo *data_manage.ChartInfo, chartClassifyId int, cha
 	}
 	chartClassify, err := data_manage.GetChartClassifyById(chartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -3218,7 +3218,7 @@ func (this *FutureGoodChartInfoController) BaseInfoEdit() {
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -3255,7 +3255,7 @@ func (this *FutureGoodChartInfoController) BaseInfoEdit() {
 	//校验指标信息是否存在
 	edbInfoList, err := data_manage.GetEdbInfoByIdList(edbIds)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表不存在!"
 			br.ErrMsg = "图表指标不存在,ChartInfoId:" + strconv.Itoa(req.ChartInfoId)
 			return
@@ -3298,7 +3298,7 @@ func (this *FutureGoodChartInfoController) BaseInfoEdit() {
 
 			edbExist, e := data_manage.GetEdbInfoByCondition(edbCondition, edbPars)
 			if e != nil {
-				if e.Error() != utils.ErrNoRow() {
+				if !utils.IsErrNoRow(e) {
 					br.Msg = "判断英文指标名称是否存在失败"
 					br.ErrMsg = "判断英文指标名称是否存在失败,Err:" + e.Error()
 					return
@@ -3330,7 +3330,7 @@ func (this *FutureGoodChartInfoController) BaseInfoEdit() {
 
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return

+ 6 - 6
controllers/data_manage/future_good/future_good_edb_info.go

@@ -60,7 +60,7 @@ func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoList() {
 	}
 
 	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -141,14 +141,14 @@ func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoDataList() {
 	}
 
 	total, err := future_good2.GetFutureGoodEdbDataListCount(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	list, err := future_good2.GetFutureGoodEdbDataList(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -156,7 +156,7 @@ func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoDataList() {
 
 	// 获取用到的指标信息
 	futureGoodEdbInfoList, err := future_good2.GetAllFutureGoodEdbInfoList()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -219,7 +219,7 @@ func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoGroupList() {
 	}
 
 	list, err := future_good2.GetFutureGoodEdbInfoGroupList(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -320,7 +320,7 @@ func (this *FutureGoodEdbInfoController) FutureGoodEdbExchangeList() {
 	}
 
 	list, err := future_good2.GetFutureGoodEdbExchangeList(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 9 - 9
controllers/data_manage/future_good/future_good_profit_chart_info.go

@@ -73,7 +73,7 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoAdd() {
 
 	chartClassify, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -165,7 +165,7 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoAdd() {
 		edbInfoId := v.EdbInfoId
 		futureGoodEdbInfo, tmpErr := future_good.GetFutureGoodEdbInfo(edbInfoId)
 		if tmpErr != nil {
-			if tmpErr.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(tmpErr) {
 				br.Msg = "期货商品指标不存在!"
 				br.ErrMsg = "期货商品指标不存在,指标id:" + strconv.Itoa(edbInfoId)
 				return
@@ -397,7 +397,7 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoEdit() {
 
 	chartClassify, err := data_manage.GetChartClassifyById(req.ChartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -413,7 +413,7 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoEdit() {
 	}
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -520,7 +520,7 @@ func (this *FutureGoodChartInfoController) ProfitChartInfoEdit() {
 		edbInfoId := v.EdbInfoId
 		futureGoodEdbInfo, tmpErr := future_good.GetFutureGoodEdbInfo(edbInfoId)
 		if tmpErr != nil {
-			if tmpErr.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(tmpErr) {
 				br.Msg = "期货商品指标不存在!"
 				br.ErrMsg = "期货商品指标不存在,指标id:" + strconv.Itoa(edbInfoId)
 				return
@@ -713,7 +713,7 @@ func copyProfitChartInfo(oldChartInfo *data_manage.ChartInfo, chartClassifyId in
 	}
 	chartClassify, err := data_manage.GetChartClassifyById(chartClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			br.ErrMsg = "分类不存在"
 			return
@@ -1124,7 +1124,7 @@ func getFutureGoodProfitChartInfo(chartInfo *data_manage.ChartInfoView, sysUser
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -1188,7 +1188,7 @@ func GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo *data_manage.Cha
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -1387,7 +1387,7 @@ func GetFutureGoodProfitChartInfoDetailFromUniqueCode(chartInfo *data_manage.Cha
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err: " + err.Error()
 				return

+ 7 - 7
controllers/data_manage/gpr_risk_data.go

@@ -44,7 +44,7 @@ func (this *BaseFromGprRiskController) GprRiskClassify() {
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromGprRiskClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -172,8 +172,8 @@ func (this *BaseFromGprRiskController) GprRiskIndexData() {
 			return
 		}
 		if len(dataTimes) > 0 {
-			startDate := dataTimes[len(dataTimes)-1]
-			endDate := dataTimes[0]
+			startDate := utils.GormDateStrToDateStr(dataTimes[len(dataTimes)-1])
+			endDate := utils.GormDateStrToDateStr(dataTimes[0])
 			// 把截止日往后加1天
 			endDateT, _ := time.ParseInLocation(utils.FormatDate, endDate, time.Local)
 			endDate = endDateT.AddDate(0, 0, 1).Format(utils.FormatDate)
@@ -355,7 +355,7 @@ func (this *BaseFromGprRiskController) GprRiskSingleData() {
 		return
 	}
 	edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_GPR_RISK, indexCode)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取数据源失败"
 		br.ErrMsg = "获取数据源失败,Err:" + err.Error()
 		return
@@ -405,7 +405,7 @@ func (this *BaseFromGprRiskController) GprRiskIndexList() {
 	}()
 	classifyId, _ := this.GetInt("ClassifyId", 0)
 	indexList, err := data_manage.GetGprRiskIndexByClassifyId(classifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -489,7 +489,7 @@ func (this *BaseFromGprRiskController) GprRiskNameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_GPR_RISK, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取钢联已存在信息失败,Err:" + err.Error()
 			return
@@ -792,7 +792,7 @@ func (this *BaseFromGprRiskController) ExportGprRiskList() {
 	if classifyId > 0 {
 		classifyInfo, err := data_manage.GetBaseFromGprRiskClassifyById(classifyId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类不存在"
 				return
 			}

+ 12 - 12
controllers/data_manage/line_equation/line_chart_classify.go

@@ -36,7 +36,7 @@ func (this *LineEquationChartClassifyController) ChartClassifyList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -64,14 +64,14 @@ func (this *LineEquationChartClassifyController) ChartClassifyList() {
 	source := utils.CHART_SOURCE_LINE_EQUATION
 
 	rootList, err := data_manage.GetChartClassifyByParentId(0, source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoAll([]int{source})
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -113,14 +113,14 @@ func (this *LineEquationChartClassifyController) ChartClassifyList() {
 func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	// 获取所有的分类
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_LINE_EQUATION)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	// /获取所有的图表
 	allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_LINE_EQUATION}, adminInfo.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -312,7 +312,7 @@ func (this *LineEquationChartClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -374,7 +374,7 @@ func (this *LineEquationChartClassifyController) DeleteChartClassify() {
 	if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -398,7 +398,7 @@ func (this *LineEquationChartClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -461,7 +461,7 @@ func (this *LineEquationChartClassifyController) DeleteChartClassify() {
 		pars = append(pars, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -481,14 +481,14 @@ func (this *LineEquationChartClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return
@@ -623,7 +623,7 @@ func (this *LineEquationChartClassifyController) ChartClassifyMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartClassifyByParentId(chartClassifyInfo.ParentId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return

+ 21 - 21
controllers/data_manage/line_equation/line_chart_info.go

@@ -413,7 +413,7 @@ func (this *LineEquationChartInfoController) Move() {
 	if chartInfo.ChartClassifyId != req.ChartClassifyId {
 		//查询需要修改的分类下是否存在同一个图表名称
 		tmpChartInfo, tmpErr := data_manage.GetChartInfoByClassifyIdAndName(req.ChartClassifyId, chartInfo.ChartName)
-		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
 			return
@@ -472,7 +472,7 @@ func (this *LineEquationChartInfoController) Move() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
@@ -588,7 +588,7 @@ func (this *LineEquationChartInfoController) List() {
 
 	if chartClassifyId > 0 {
 		chartClassifyId, err := data_manage.GetChartClassify(chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -628,7 +628,7 @@ func (this *LineEquationChartInfoController) List() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -646,7 +646,7 @@ func (this *LineEquationChartInfoController) List() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -654,7 +654,7 @@ func (this *LineEquationChartInfoController) List() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -698,7 +698,7 @@ func (this *LineEquationChartInfoController) List() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -709,7 +709,7 @@ func (this *LineEquationChartInfoController) List() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -760,7 +760,7 @@ func (this *LineEquationChartInfoController) Detail() {
 	chartInfo := new(data_manage.ChartInfoView)
 	chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图被删除,请刷新页面"
 			br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 			return
@@ -834,7 +834,7 @@ func (this *LineEquationChartInfoController) Detail() {
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -962,7 +962,7 @@ func (this *LineEquationChartInfoController) DetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -1000,7 +1000,7 @@ func (this *LineEquationChartInfoController) DetailFromUniqueCode() {
 					myCond += ` AND a.chart_info_id=? `
 					myPars = append(myPars, chartInfo.ChartInfoId)
 					myList, err := data_manage.GetMyChartByCondition(myCond, myPars)
-					if err != nil && err.Error() != utils.ErrNoRow() {
+					if err != nil && !utils.IsErrNoRow(err) {
 						br.Msg = "获取失败"
 						br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 						return
@@ -1076,7 +1076,7 @@ func (this *LineEquationChartInfoController) Refresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -1236,7 +1236,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -1400,7 +1400,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -1496,7 +1496,7 @@ func (this *LineEquationChartInfoController) EnInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -1514,7 +1514,7 @@ func (this *LineEquationChartInfoController) EnInfoEdit() {
 		pars = append(pars, req.ChartInfoId, req.ChartNameEn, utils.CHART_SOURCE_LINE_EQUATION)
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return
@@ -1623,7 +1623,7 @@ func (this *LineEquationChartInfoController) SearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1637,7 +1637,7 @@ func (this *LineEquationChartInfoController) SearchByEs() {
 		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -1739,7 +1739,7 @@ func (this *LineEquationChartInfoController) BaseInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -1764,7 +1764,7 @@ func (this *LineEquationChartInfoController) BaseInfoEdit() {
 		pars = append(pars, req.ChartName)
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return

+ 43 - 39
controllers/data_manage/line_feature/chart_info.go

@@ -65,7 +65,7 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSave() {
 	if err != nil {
 		br.Msg = "指标A异常"
 		br.ErrMsg = "指标A异常,err:" + err.Error()
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = `指标A不存在`
 			br.IsSendEmail = false
 		}
@@ -226,7 +226,7 @@ func (this *LineFeaturesChartInfoController) MultipleGraphPreview() {
 	// 标准差图表信息
 	{
 		// 配置了数据才有返回
-		if req.StandardDeviation.CalculateValue > 0 {
+		if req.StandardDeviation.CalculateValue > 1 {
 			tmpChartInfo := *chartInfo
 			tmpChartInfo.ChartName = fmt.Sprintf("%s%d期滚动标准差", edbInfoMapping.EdbName, req.StandardDeviation.CalculateValue)
 
@@ -554,11 +554,15 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveChart() {
 	}
 
 	multipleGraphConfigChartMapping, err := data_manage.GetMultipleGraphConfigChartMappingByIdAndSource(req.MultipleGraphConfigId, req.Source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
 	}
+	// 兼容gorm
+	if multipleGraphConfigChartMapping != nil && multipleGraphConfigChartMapping.Id <= 0 {
+		multipleGraphConfigChartMapping = nil
+	}
 
 	err = nil
 	var isAdd bool
@@ -567,13 +571,13 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveChart() {
 		isAdd = true
 	} else {
 		chartInfo, err := data_manage.GetChartInfoById(multipleGraphConfigChartMapping.ChartInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = `保存失败`
 			br.ErrMsg = "获取图表信息失败,ERR:" + err.Error()
 			return
 		}
 		// 说明图还在,没有被删除
-		if chartInfo != nil {
+		if chartInfo != nil && chartInfo.ChartInfoId > 0 {
 			chartInfoId = multipleGraphConfigChartMapping.ChartInfoId
 			req.ChartName = chartInfo.ChartName
 			req.ClassifyId = chartInfo.ChartClassifyId
@@ -812,7 +816,7 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveChart() {
 			br.ErrMsg = "保存配置与图表的关联关系失败,ERR:" + err.Error()
 			return
 		}
-	} else if multipleGraphConfigChartMapping != nil {
+	} else if multipleGraphConfigChartMapping != nil && multipleGraphConfigChartMapping.MultipleGraphConfigId > 0 {
 		multipleGraphConfigChartMapping.ChartInfoId = chartInfo.ChartInfoId
 		multipleGraphConfigChartMapping.ModifyTime = time.Now()
 		err = multipleGraphConfigChartMapping.Update([]string{"ChartInfoId", "ModifyTime"})
@@ -866,7 +870,7 @@ func CopyMultipleGraphConfigSaveChart(req request.SaveMultipleGraphChartReq, thi
 	}
 
 	multipleGraphConfigChartMapping, err := data_manage.GetMultipleGraphConfigChartMappingByIdAndSource(req.MultipleGraphConfigId, req.Source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
@@ -874,7 +878,7 @@ func CopyMultipleGraphConfigSaveChart(req request.SaveMultipleGraphChartReq, thi
 
 	// 原图
 	oldChartInfo, err := data_manage.GetChartInfoById(multipleGraphConfigChartMapping.ChartInfoId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取图表信息失败,ERR:" + err.Error()
 		return
@@ -1064,7 +1068,7 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveEdb() {
 	}
 
 	multipleGraphConfigEdbMapping, err := data_manage.GetMultipleGraphConfigEdbMappingByIdAndSource(req.MultipleGraphConfigId, req.Source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
@@ -1072,17 +1076,17 @@ func (this *LineFeaturesChartInfoController) MultipleGraphConfigSaveEdb() {
 	err = nil
 	var isAdd bool
 	var edbInfoId int
-	if multipleGraphConfigEdbMapping == nil {
+	if multipleGraphConfigEdbMapping == nil || multipleGraphConfigEdbMapping.MultipleGraphConfigId <= 0 {
 		isAdd = true
 	} else {
 		edbInfo, err := data_manage.GetEdbInfoById(multipleGraphConfigEdbMapping.EdbInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = `保存失败`
 			br.ErrMsg = "获取图表信息失败,ERR:" + err.Error()
 			return
 		}
 		// 说明指标还在,没有被删除
-		if edbInfo != nil && !req.IsSaveAs {
+		if edbInfo != nil && edbInfo.EdbInfoId > 0 && !req.IsSaveAs {
 			edbInfoId = multipleGraphConfigEdbMapping.EdbInfoId
 			req.EdbName = edbInfo.EdbName
 			req.ClassifyId = edbInfo.ClassifyId
@@ -1463,12 +1467,12 @@ func (this *LineFeaturesChartInfoController) Move() {
 	if chartInfo.ChartClassifyId != req.ChartClassifyId {
 		//查询需要修改的分类下是否存在同一个图表名称
 		tmpChartInfo, tmpErr := data_manage.GetChartInfoByClassifyIdAndName(req.ChartClassifyId, chartInfo.ChartName)
-		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
+		if tmpErr != nil && !utils.IsErrNoRow(tmpErr) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "移动失败,Err:" + tmpErr.Error()
 			return
 		}
-		if tmpChartInfo != nil {
+		if tmpChartInfo != nil && tmpChartInfo.ChartInfoId > 0 {
 			br.Msg = "移动失败,同一个分类下图表名称不允许重复"
 			br.ErrMsg = "移动失败,同一个分类下图表名称不允许重复"
 			return
@@ -1522,14 +1526,14 @@ func (this *LineFeaturesChartInfoController) Move() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartInfoByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
 		}
 
 		//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-		if firstClassify != nil && firstClassify.Sort == 0 {
+		if firstClassify != nil && firstClassify.ChartClassifyId > 0 && firstClassify.Sort == 0 {
 			updateSortStr := ` sort + 1 `
 			_ = data_manage.UpdateChartInfoSortByClassifyId(firstClassify.ChartClassifyId, 0, firstClassify.ChartInfoId-1, []int{utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY}, updateSortStr)
 		}
@@ -1633,7 +1637,7 @@ func (this *LineFeaturesChartInfoController) List() {
 
 	if chartClassifyId > 0 {
 		chartClassifyId, err := data_manage.GetChartClassify(chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -1671,7 +1675,7 @@ func (this *LineFeaturesChartInfoController) List() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1689,7 +1693,7 @@ func (this *LineFeaturesChartInfoController) List() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -1697,7 +1701,7 @@ func (this *LineFeaturesChartInfoController) List() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -1741,7 +1745,7 @@ func (this *LineFeaturesChartInfoController) List() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -1752,7 +1756,7 @@ func (this *LineFeaturesChartInfoController) List() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -1795,7 +1799,7 @@ func (this *LineFeaturesChartInfoController) Detail() {
 	chartInfo := new(data_manage.ChartInfoView)
 	chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图被删除,请刷新页面"
 			br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 			return
@@ -1920,7 +1924,7 @@ func (this *LineFeaturesChartInfoController) Detail() {
 	}
 
 	// 判断是否加入我的图库
-	if chartInfoId > 0 && chartInfo != nil {
+	if chartInfoId > 0 && chartInfo != nil && chartInfo.ChartInfoId > 0 {
 		{
 			var myChartCondition string
 			var myChartPars []interface{}
@@ -1930,7 +1934,7 @@ func (this *LineFeaturesChartInfoController) Detail() {
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -2058,7 +2062,7 @@ func (this *LineFeaturesChartInfoController) DetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -2096,7 +2100,7 @@ func (this *LineFeaturesChartInfoController) DetailFromUniqueCode() {
 					myCond += ` AND a.chart_info_id=? `
 					myPars = append(myPars, chartInfo.ChartInfoId)
 					myList, err := data_manage.GetMyChartByCondition(myCond, myPars)
-					if err != nil && err.Error() != utils.ErrNoRow() {
+					if err != nil && !utils.IsErrNoRow(err) {
 						br.Msg = "获取失败"
 						br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 						return
@@ -2172,7 +2176,7 @@ func (this *LineFeaturesChartInfoController) Refresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -2254,7 +2258,7 @@ func (this *LineFeaturesChartInfoController) Copy() {
 	}
 
 	multipleGraphConfigChartMapping, err := data_manage.GetMultipleGraphConfigChartMappingByChartId(oldChartInfo.ChartInfoId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
@@ -2338,7 +2342,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -2414,7 +2418,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		if !isOk {
 			if errMsg != "" {
 				uniqueCode := ""
-				if chartInfo != nil {
+				if chartInfo != nil && chartInfo.ChartInfoId > 0 {
 					uniqueCode = chartInfo.UniqueCode
 				}
 				tmpTip := fmt.Sprintf("查询图表详情失败,line_feature.GetChartInfoDetailFromUniqueCode UniqueCode:%s,err:%s", uniqueCode, errMsg)
@@ -2532,7 +2536,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 		return
 	}
 
-	if chartInfo.ChartInfoId > 0 && chartInfo != nil {
+	if chartInfo != nil && chartInfo.ChartInfoId > 0 {
 		//判断是否加入我的图库
 		{
 			var myChartCondition string
@@ -2543,7 +2547,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -2639,7 +2643,7 @@ func (this *LineFeaturesChartInfoController) EnInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -2657,7 +2661,7 @@ func (this *LineFeaturesChartInfoController) EnInfoEdit() {
 		pars = append(pars, req.ChartInfoId, req.ChartNameEn, utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY)
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return
@@ -2766,7 +2770,7 @@ func (this *LineFeaturesChartInfoController) SearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -2780,7 +2784,7 @@ func (this *LineFeaturesChartInfoController) SearchByEs() {
 		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -2882,7 +2886,7 @@ func (this *LineFeaturesChartInfoController) BaseInfoEdit() {
 	//判断指标名称是否存在
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面"
 			br.ErrMsg = "图表已被删除,请刷新页面"
 			return
@@ -2908,7 +2912,7 @@ func (this *LineFeaturesChartInfoController) BaseInfoEdit() {
 		pars = append(pars, req.ChartName)
 		existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 		if err != nil {
-			if err.Error() != utils.ErrNoRow() {
+			if !utils.IsErrNoRow(err) {
 				br.Msg = "判断英文图表名称是否存在失败"
 				br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 				return

+ 12 - 12
controllers/data_manage/line_feature/classify.go

@@ -36,7 +36,7 @@ func (this *LineFeaturesChartClassifyController) ChartClassifyList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -64,14 +64,14 @@ func (this *LineFeaturesChartClassifyController) ChartClassifyList() {
 	source := utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION
 
 	rootList, err := data_manage.GetChartClassifyByParentId(0, source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoAll([]int{utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY})
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -113,14 +113,14 @@ func (this *LineFeaturesChartClassifyController) ChartClassifyList() {
 func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	// 获取所有的分类
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	// /获取所有的图表
 	allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_LINE_FEATURE_STANDARD_DEVIATION, utils.CHART_SOURCE_LINE_FEATURE_PERCENTILE, utils.CHART_SOURCE_LINE_FEATURE_FREQUENCY}, adminInfo.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -312,7 +312,7 @@ func (this *LineFeaturesChartClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -374,7 +374,7 @@ func (this *LineFeaturesChartClassifyController) DeleteChartClassify() {
 	if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -398,7 +398,7 @@ func (this *LineFeaturesChartClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -461,7 +461,7 @@ func (this *LineFeaturesChartClassifyController) DeleteChartClassify() {
 		pars = append(pars, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -481,14 +481,14 @@ func (this *LineFeaturesChartClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return
@@ -623,7 +623,7 @@ func (this *LineFeaturesChartClassifyController) ChartClassifyMove() {
 
 	} else {
 		firstClassify, err := data_manage.GetFirstChartClassifyByParentId(chartClassifyInfo.ParentId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前父级分类下的排序第一条的分类信息失败,Err:" + err.Error()
 			return

+ 11 - 13
controllers/data_manage/manual.go

@@ -2,13 +2,13 @@ package data_manage
 
 import (
 	"encoding/json"
-	"fmt"
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	"eta/eta_api/models/data_manage"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
+	"fmt"
 	"strconv"
 	"strings"
 	"time"
@@ -224,12 +224,12 @@ func (this *ChartClassifyController) AddManualClassify() {
 	}
 
 	classifyItem, err := data_manage.GetManualClassifyByClassifyName(req.ClassifyName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "判断名称是否已存在失败"
 		br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 		return
 	}
-	if classifyItem != nil {
+	if classifyItem != nil && classifyItem.ClassifyId > 0 {
 		if classifyItem.IsShow == 1 {
 			br.Msg = "分类名称已存在,请重新输入"
 			br.IsSendEmail = false
@@ -243,7 +243,7 @@ func (this *ChartClassifyController) AddManualClassify() {
 				return
 			}
 			parentItem, _ := data_manage.GetManualClassifyById(req.ParentId)
-			if parentItem != nil && parentItem.IsShow == 0 {
+			if parentItem != nil && parentItem.ClassifyId > 0 && parentItem.IsShow == 0 {
 				err = data_manage.ModifyManualClassifyIsShow(1, parentItem.ClassifyId, req.ParentId)
 				if err != nil {
 					br.Msg = "保存失败"
@@ -315,17 +315,15 @@ func (this *ChartClassifyController) ManualClassifyEdit() {
 		return
 	}
 	classifyItem, err := data_manage.GetManualClassifyByClassifyName(req.ClassifyName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "修改失败"
 		br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 		return
 	}
 
-	if classifyItem != nil {
-		if item.ClassifyId != classifyItem.ClassifyId {
-			br.Msg = "名称已存在,请重新输入"
-			return
-		}
+	if classifyItem != nil && classifyItem.ClassifyId > 0 && item.ClassifyId != classifyItem.ClassifyId {
+		br.Msg = "名称已存在,请重新输入"
+		return
 	}
 
 	err = data_manage.ModifyManualClassifyName(req.ClassifyName, req.ClassifyId, req.ParentId)
@@ -364,7 +362,7 @@ func (this *ChartClassifyController) ManualClassifyDel() {
 		return
 	}
 	classifyItem, err := data_manage.GetManualClassifyById(req.ClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "查找分类失败"
 		br.ErrMsg = "查找分类失败,Err:" + err.Error()
 		return
@@ -377,7 +375,7 @@ func (this *ChartClassifyController) ManualClassifyDel() {
 
 	// 获取当前分类下是否存在子分类
 	count, err := data_manage.GetChildManualClassifyCount(req.ClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "删除失败"
 		br.ErrMsg = "根据分类id获取下面存在的子分类数量失败,Err:" + err.Error()
 		return
@@ -391,7 +389,7 @@ func (this *ChartClassifyController) ManualClassifyDel() {
 	if classifyItem.ParentId > 0 {
 		// 获取当前分类下的指标数
 		count, err = data_manage.GetManualEdbInfoCountByClassifyId(req.ClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "根据分类id获取下面存在的指标数量失败,Err:" + err.Error()
 			return

+ 17 - 10
controllers/data_manage/multiple_graph_config.go

@@ -61,7 +61,7 @@ func (this *ChartInfoController) MultipleGraphConfigSave() {
 	if err != nil {
 		br.Msg = "指标A异常"
 		br.ErrMsg = "指标A异常,err:" + err.Error()
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = `指标A不存在`
 			br.IsSendEmail = false
 		}
@@ -81,7 +81,7 @@ func (this *ChartInfoController) MultipleGraphConfigSave() {
 	if err != nil {
 		br.Msg = "指标B异常"
 		br.ErrMsg = "指标B异常,err:" + err.Error()
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = `指标B不存在`
 			br.IsSendEmail = false
 		}
@@ -676,11 +676,14 @@ func (this *ChartInfoController) MultipleGraphConfigSaveChart() {
 	}
 
 	multipleGraphConfigChartMapping, err := data_manage.GetMultipleGraphConfigChartMappingByIdAndSource(req.MultipleGraphConfigId, req.Source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
 	}
+	if multipleGraphConfigChartMapping != nil && multipleGraphConfigChartMapping.Id <= 0 {
+		multipleGraphConfigChartMapping = nil
+	}
 
 	err = nil
 	var isAdd bool
@@ -689,13 +692,13 @@ func (this *ChartInfoController) MultipleGraphConfigSaveChart() {
 		isAdd = true
 	} else {
 		chartInfo, err := data_manage.GetChartInfoById(multipleGraphConfigChartMapping.ChartInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = `保存失败`
 			br.ErrMsg = "获取图表信息失败,ERR:" + err.Error()
 			return
 		}
 		// 说明图还在,没有被删除
-		if chartInfo != nil {
+		if chartInfo != nil && chartInfo.ChartInfoId > 0 {
 			chartInfoId = multipleGraphConfigChartMapping.ChartInfoId
 			req.ChartName = chartInfo.ChartName
 			req.ClassifyId = chartInfo.ChartClassifyId
@@ -1018,7 +1021,7 @@ func CopyMultipleGraphConfigSaveChart(req request.SaveMultipleGraphChartReq, thi
 	}
 
 	multipleGraphConfigChartMapping, err := data_manage.GetMultipleGraphConfigChartMappingByIdAndSource(req.MultipleGraphConfigId, req.Source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
@@ -1026,7 +1029,7 @@ func CopyMultipleGraphConfigSaveChart(req request.SaveMultipleGraphChartReq, thi
 
 	// 原图
 	oldChartInfo, err := data_manage.GetChartInfoById(multipleGraphConfigChartMapping.ChartInfoId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取图表信息失败,ERR:" + err.Error()
 		return
@@ -1275,11 +1278,15 @@ func (this *ChartInfoController) MultipleGraphConfigSaveEdb() {
 	}
 
 	multipleGraphConfigEdbMapping, err := data_manage.GetMultipleGraphConfigEdbMappingByIdAndSource(req.MultipleGraphConfigId, req.Source)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = `保存失败`
 		br.ErrMsg = "获取配置与图表的关联关系失败,ERR:" + err.Error()
 		return
 	}
+	if multipleGraphConfigEdbMapping != nil && multipleGraphConfigEdbMapping.Id <= 0 {
+		multipleGraphConfigEdbMapping = nil
+	}
+
 	err = nil
 	var isAdd bool
 	var edbInfoId int
@@ -1287,13 +1294,13 @@ func (this *ChartInfoController) MultipleGraphConfigSaveEdb() {
 		isAdd = true
 	} else {
 		edbInfo, err := data_manage.GetEdbInfoById(multipleGraphConfigEdbMapping.EdbInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = `保存失败`
 			br.ErrMsg = "获取图表信息失败,ERR:" + err.Error()
 			return
 		}
 		// 说明指标还在,没有被删除
-		if edbInfo != nil && !req.IsSaveAs {
+		if edbInfo != nil && edbInfo.EdbInfoId > 0 && !req.IsSaveAs {
 			edbInfoId = multipleGraphConfigEdbMapping.EdbInfoId
 			req.EdbName = edbInfo.EdbName
 			req.ClassifyId = edbInfo.ClassifyId

+ 41 - 45
controllers/data_manage/my_chart.go

@@ -129,7 +129,7 @@ func (this *MyChartController) ChartList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -147,7 +147,7 @@ func (this *MyChartController) ChartList() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -155,7 +155,7 @@ func (this *MyChartController) ChartList() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -232,7 +232,7 @@ func (this *MyChartController) ChartList() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -243,7 +243,7 @@ func (this *MyChartController) ChartList() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -278,7 +278,7 @@ func (this *MyChartController) ClassifyList() {
 	}
 	//获取图表信息
 	list, err := data_manage.GetMyChartClassifyAll(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取分类信息失败"
 		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
@@ -286,7 +286,7 @@ func (this *MyChartController) ClassifyList() {
 	}
 
 	resp := new(data_manage.MyChartClassifyResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.MyChartClassifyItem, 0)
 		resp.List = items
 		br.Ret = 200
@@ -458,7 +458,7 @@ func (this *MyChartController) ClassifyEdit() {
 		return
 	}
 	item, err := data_manage.GetMyChartClassifyById(sysUser.AdminId, req.MyChartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "保存失败"
 		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
 		return
@@ -546,7 +546,7 @@ func (this *MyChartController) ClassifyMove() {
 	}
 	//查询该分类存不存在
 	item, err := data_manage.GetMyChartClassifyById(sysUser.AdminId, req.MyChartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "移动失败,找不到该分类"
 		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
 		return
@@ -596,14 +596,14 @@ func (this *MyChartController) ClassifyMove() {
 		updateCol = append(updateCol, "Sort", "ModifyTime")
 	} else {
 		firstClassify, err := data_manage.GetFirstMyChartClassifyByAdminId(sysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "移动失败"
 			br.ErrMsg = "获取获取当前账号下的排序第一条的分类信息失败,Err:" + err.Error()
 			return
 		}
 
 		//如果该分类下存在其他分类,且第一个其他分类的排序等于0,那么需要调整排序
-		if firstClassify != nil && firstClassify.Sort == 0 {
+		if firstClassify != nil && firstClassify.MyChartClassifyId > 0 && firstClassify.Sort == 0 {
 			updateSortStr := ` sort + 1 `
 			_ = data_manage.UpdateMyChartClassifySortByClassifyId(sysUser.AdminId, firstClassify.MyChartClassifyId-1, 0, updateSortStr)
 		}
@@ -670,7 +670,7 @@ func (this *MyChartController) ClassifyDelete() {
 	}
 
 	item, err := data_manage.GetMyChartClassifyById(sysUser.AdminId, req.MyChartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "保存失败"
 		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
 		return
@@ -769,7 +769,7 @@ func (this *MyChartController) MyChartAdd() {
 	}
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败!"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -790,14 +790,14 @@ func (this *MyChartController) MyChartAdd() {
 	pars = append(pars, req.ChartInfoId)
 
 	existItem, err := data_manage.GetMyChartDetailByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "保存失败"
 		br.ErrMsg = "保存失败,校验名称是否存在失败,Err:" + err.Error()
 		return
 	}
 	resp := new(data_manage.MyChartAddResp)
 	var myChartClassifyId string
-	if existItem != nil { //修改
+	if existItem != nil && existItem.MyChartId > 0 { //修改
 		fmt.Println("modify")
 		for _, v := range req.MyChartClassifyId {
 			myChartClassifyId += strconv.Itoa(v) + ","
@@ -830,7 +830,7 @@ func (this *MyChartController) MyChartAdd() {
 			var sort float64
 			// 查找最小排序值
 			firstMapItem, _ := data_manage.GetMyChartSort(sysUser.AdminId, v, 0)
-			if firstMapItem != nil {
+			if firstMapItem != nil && firstMapItem.MyChartClassifyMappingId > 0 {
 				sort = firstMapItem.Sort
 			}
 			//获取最大的排序字段
@@ -910,7 +910,7 @@ func (this *MyChartController) MyChartAddToClassify() {
 	}
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败!"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
@@ -931,14 +931,14 @@ func (this *MyChartController) MyChartAddToClassify() {
 	pars = append(pars, req.ChartInfoId)
 
 	existItem, err := data_manage.GetMyChartDetailByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "保存失败"
 		br.ErrMsg = "保存失败,校验名称是否存在失败,Err:" + err.Error()
 		return
 	}
 	resp := new(data_manage.MyChartAddResp)
 	var myChartClassifyId string
-	if existItem != nil { //修改
+	if existItem != nil && existItem.MyChartId > 0 { //修改
 		fmt.Println("modify")
 		for _, v := range req.MyChartClassifyId {
 			myChartClassifyId += strconv.Itoa(v) + ","
@@ -1051,9 +1051,9 @@ func (this *MyChartController) GetMyChartClassifyIdList() {
 	pars = append(pars, sysUser.AdminId, chartInfoId)
 
 	existItem, _ := data_manage.GetMyChartDetailByCondition(condition, pars)
-	if existItem != nil {
+	if existItem != nil && existItem.MyChartId > 0 {
 		myChartClassifyList, err := data_manage.GetMyChartClassifyList(existItem.MyChartId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败!"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -1275,7 +1275,7 @@ func (this *MyChartController) MyChartList() {
 		if isShared {
 			myClassify, e := data_manage.GetMyChartClassifyByClassifyId(myChartClassifyId)
 			if e != nil {
-				if e.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(e) {
 					br.Msg = "分类已被删除, 请刷新页面"
 					return
 				}
@@ -1308,7 +1308,7 @@ func (this *MyChartController) MyChartList() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1326,14 +1326,14 @@ func (this *MyChartController) MyChartList() {
 
 	//获取图表信息
 	list, err := data_manage.GetMyChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 		return
 	}
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -1408,7 +1408,7 @@ func (this *MyChartController) MyChartList() {
 	}
 
 	resp := new(data_manage.MyChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.MyChartList, 0)
 		resp.Paging = page
 		resp.List = items
@@ -1418,7 +1418,7 @@ func (this *MyChartController) MyChartList() {
 		return
 	}
 	total, err = data_manage.GetMyChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取我的图表数据总数失败,Err:" + err.Error()
 		return
@@ -1599,7 +1599,7 @@ func (this *MyChartController) ChartRecommendList() {
 
 	//获取图表信息
 	list, err := data_manage.GetRecommendChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -1607,7 +1607,7 @@ func (this *MyChartController) ChartRecommendList() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -1658,7 +1658,7 @@ func (this *MyChartController) ChartRecommendList() {
 	}
 
 	resp := new(data_manage.ChartRecommendListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.List = items
 		br.Ret = 200
@@ -1707,7 +1707,7 @@ func (this *MyChartController) MyChartSearch() {
 
 	//获取图表信息
 	list, err := data_manage.GetMyChartSearchByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -1802,7 +1802,7 @@ func (this *MyChartController) MyChartSearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1919,7 +1919,7 @@ func (this *MyChartController) PublicClassifyList() {
 	}
 	//获取图表信息
 	list, err := data_manage.GetPublicChartClassifyAllExceptMy(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取公共分类信息失败"
 		br.ErrMsg = "获取公共分类信息失败,Err:" + err.Error()
@@ -1927,7 +1927,7 @@ func (this *MyChartController) PublicClassifyList() {
 	}
 
 	resp := new(data_manage.PublicChartClassifyResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		resp.List = make([]data_manage.PublicChartClassifyList, 0)
 		br.Ret = 200
 		br.Success = true
@@ -1989,11 +1989,11 @@ func (this *MyChartController) PublicClassifyList() {
 	// 指标显示的语言
 	{
 		configDetail, _ := system.GetConfigDetailByCode(this.SysUser.AdminId, system.ChartLanguageVar)
-		if configDetail != nil {
+		if configDetail != nil && configDetail.ConfigId > 0 {
 			language = configDetail.ConfigValue
 		} else {
 			configDetail, _ = system.GetDefaultConfigDetailByCode(system.ChartLanguageVar)
-			if configDetail != nil {
+			if configDetail != nil && configDetail.ConfigId > 0 {
 				language = configDetail.ConfigValue
 			}
 		}
@@ -2036,7 +2036,7 @@ func (this *MyChartController) ModifyClassifyPublicStatus() {
 	}
 	//查询该分类存不存在
 	item, err := data_manage.GetMyChartClassifyById(sysUser.AdminId, req.MyChartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "修改失败,找不到该分类"
 		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
 		return
@@ -2108,7 +2108,7 @@ func (this *MyChartController) CopyClassifyAndChart() {
 	}
 	//查询该公共分类存不存在
 	item, err := data_manage.GetPublicMyChartClassifyById(req.MyChartClassifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "复制失败,找不到该分类"
 		br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
 		return
@@ -2263,7 +2263,7 @@ func (this *MyChartController) CompanyPublicClassifyList() {
 		pars = append(pars, keyword)
 	}
 	list, err := data_manage.GetCompanyPublicClassifyList(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取用户可见分类列表失败"
 		br.ErrMsg = "获取用户可见分类列表失败, Err:" + err.Error()
@@ -2271,7 +2271,7 @@ func (this *MyChartController) CompanyPublicClassifyList() {
 	}
 
 	resp := new(data_manage.MyChartClassifyResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.MyChartClassifyItem, 0)
 		resp.List = items
 		br.Ret = 200
@@ -2293,10 +2293,6 @@ func (this *MyChartController) CompanyPublicClassifyList() {
 	br.Data = resp
 }
 
-//func init() {
-//	data.AddAllMyChartInfo()
-//}
-
 // ClassifyFrameworkNodeList
 // @Title 我的图表分类-关联的框架节点列表
 // @Description 我的图表分类-关联的框架节点列表
@@ -2328,7 +2324,7 @@ func (this *MyChartController) ClassifyFrameworkNodeList() {
 
 	_, e := data_manage.GetMyChartClassifyById(sysUser.AdminId, classifyId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "分类不存在, 请刷新页面"
 			return
 		}

+ 6 - 6
controllers/data_manage/mysteel_chemical_data.go

@@ -44,14 +44,14 @@ func (this *EdbInfoController) MysteelChemicalClassify() {
 	}
 
 	rootList, err := data_manage.GetBaseFromMysteelChemicalClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromMysteelChemicalClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -113,7 +113,7 @@ func (this *EdbInfoController) MysteelChemicalIndexList() {
 		return
 	}
 	allBaseFromMysteelChemicalIndex, err := data_manage.GetMysteelChemicalIndexByClassifyId(classifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -594,7 +594,7 @@ func (this *EdbInfoController) MysteelChemicalData() {
 			dataList = make([]*data_manage.MysteelChemicalData, 0)
 		}
 		edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_MYSTEEL_CHEMICAL, v.IndexCode)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取指标库统计数据失败,Err:" + err.Error()
 			return
@@ -1327,7 +1327,7 @@ func (c *EdbInfoController) NameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取钢联已存在信息失败,Err:" + err.Error()
 			return
@@ -1585,7 +1585,7 @@ func (this *EdbInfoController) Add() {
 
 	tmpInfo, err := data_manage.GetBaseFromMysteelChemicalIndexByCode(req.EdbCode)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
 			return

+ 3 - 3
controllers/data_manage/predict_edb_classify.go

@@ -702,7 +702,7 @@ func (this *PredictEdbClassifyController) SimpleList() {
 	}
 
 	rootList, err := data_manage.GetEdbClassifyByParentId(parentId, 1)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -715,7 +715,7 @@ func (this *PredictEdbClassifyController) SimpleList() {
 		// 获取当前账号的不可见指标
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -845,7 +845,7 @@ func (this *PredictEdbClassifyController) ClassifyTree() {
 	}()
 
 	allList, err := data_manage.GetPredictEdbClassifyAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 16 - 20
controllers/data_manage/predict_edb_info.go

@@ -80,7 +80,7 @@ func (this *PredictEdbInfoController) EdbChartList() {
 	// 筛选分类
 	if classifyId > 0 {
 		childClassify, e, _ := data.GetChildClassifyByClassifyId(classifyId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
 			return
@@ -104,7 +104,7 @@ func (this *PredictEdbInfoController) EdbChartList() {
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}
 	confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 		return
@@ -120,14 +120,14 @@ func (this *PredictEdbInfoController) EdbChartList() {
 	}
 	//获取指标信息
 	dataCount, list, err := data_manage.GetEdbInfoFilterList(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取预测指标列表失败"
 		br.ErrMsg = "获取预测指标列表失败,Err:" + err.Error()
 		return
 	}
 
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		list = make([]*data_manage.EdbInfoList, 0)
 	} else {
 		classifyIdList := make([]int, 0)
@@ -245,14 +245,14 @@ func (this *PredictEdbInfoController) List() {
 	}
 	//获取指标信息
 	edbInfoItem, err := data_manage.GetEdbInfoByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
 	}
 
-	if edbInfoItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if edbInfoItem == nil || (err != nil && utils.IsErrNoRow(err)) {
 		item := new(data_manage.EdbInfoList)
 		resp.Paging = page
 		resp.Item = item
@@ -289,7 +289,7 @@ func (this *PredictEdbInfoController) List() {
 	//获取指标数据(实际已生成)
 	{
 		dataCount, dataList, err := data.GetPageData(edbInfoItem.EdbInfoId, edbInfoItem.Source, edbInfoItem.SubSource, edbInfoItem.LatestDate, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取指标信息失败"
 			br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 			return
@@ -561,7 +561,7 @@ func (this *PredictEdbInfoController) ChartImageSet() {
 		if err != nil {
 			br.Msg = "保存失败"
 			br.ErrMsg = "保存失败,Err:" + err.Error()
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "找不到该指标"
 				br.ErrMsg = "找不到该指标"
 				br.IsSendEmail = false
@@ -926,7 +926,7 @@ func (this *PredictEdbInfoController) Detail() {
 	if edbInfo.EdbType == 1 {
 		// 获取所有的指标预测规则配置
 		tmpPredictEdbConfList, err := data_manage.GetPredictEdbConfListById(edbInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取预测指标配置信息失败,Err:" + err.Error()
 			return
@@ -935,7 +935,7 @@ func (this *PredictEdbInfoController) Detail() {
 			var tmpPredictEdbConfCalculateMappingDetail []*data_manage.PredictEdbConfCalculateMappingDetail
 			if v.RuleType == 9 || v.RuleType == 14 {
 				tmpPredictEdbConfCalculateMappingDetail, err = data_manage.GetPredictEdbConfCalculateMappingDetailListByConfigId(v.PredictEdbInfoId, v.ConfigId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "获取失败"
 					br.ErrMsg = "获取预测指标配置与关联指标信息失败,Err:" + err.Error()
 					return
@@ -1177,7 +1177,7 @@ func (this *PredictEdbInfoController) FilterByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1614,7 +1614,7 @@ func (this *PredictEdbInfoController) ChartDataList() {
 		endNumList := make([]int, 0)
 		for _, v := range req.RuleList {
 			if req.EndDateType == 0 {
-				confEndDate, err := time.Parse(utils.FormatDate, v.EndDate)
+				confEndDate, err := time.ParseInLocation(utils.FormatDate, v.EndDate, time.Local)
 				if err != nil {
 					br.Msg = "配置项中时间异常,请重新选择"
 					br.ErrMsg = "配置项中时间异常,请重新选择,err:" + err.Error()
@@ -1751,7 +1751,7 @@ func (this *PredictEdbInfoController) ChartDataList() {
 	if err != nil {
 		br.Msg = "获取来源指标信息失败"
 		br.ErrMsg = "获取来源指标信息失败"
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.ErrMsg = "获取来源指标信息失败,Err:" + err.Error()
 		}
 		br.Success = true
@@ -2050,10 +2050,6 @@ func (this *PredictEdbInfoController) Modify() {
 //
 //}
 
-//func init() {
-//	data.AddOrEditAllEdbInfoToEs()
-//}
-
 // ClassifyEdbInfoItems
 // @Title 获取分类下指标接口
 // @Description 获取分类下指标接口
@@ -2080,7 +2076,7 @@ func (this *PredictEdbInfoController) ClassifyEdbInfoItems() {
 	// 获取当前账号的不可见指标
 	obj := data_manage.EdbInfoNoPermissionAdmin{}
 	confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 		return
@@ -2097,7 +2093,7 @@ func (this *PredictEdbInfoController) ClassifyEdbInfoItems() {
 	}
 
 	allEdbInfo, err := data_manage.GetEdbInfoByClassifyId(classifyId, 1, sysUserId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -2213,7 +2209,7 @@ func (this *PredictEdbInfoController) ChartImageSetBySvg() {
 	if err != nil {
 		br.Msg = "保存失败"
 		br.ErrMsg = "保存失败,Err:" + err.Error()
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "找不到该指标"
 			br.ErrMsg = "找不到该指标"
 			br.IsSendEmail = false

+ 12 - 12
controllers/data_manage/range_analysis/chart_classify.go

@@ -61,7 +61,7 @@ func (this *RangeChartClassifyController) ChartClassifyList() {
 	nodeAll := make([]*data_manage.ChartClassifyItems, 0)
 	// 查询分类节点
 	rootList, err := data_manage.GetChartClassifyByParentId(parentId, utils.CHART_SOURCE_RANGE_ANALYSIS)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -154,19 +154,19 @@ func (this *RangeChartClassifyController) ChartClassifyList() {
 // getChartClassifyListForMe 获取我创建的图表
 func getChartClassifyListForMe(adminInfo system.Admin, resp *data_manage.ChartClassifyListResp) (errMsg string, err error) {
 	rootList, err := data_manage.GetChartClassifyByParentId(0, utils.CHART_SOURCE_RANGE_ANALYSIS)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	classifyAll, err := data_manage.GetChartClassifyAll(utils.CHART_SOURCE_RANGE_ANALYSIS)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
 
 	allChartInfo, err := data_manage.GetChartInfoByAdminId([]int{utils.CHART_SOURCE_RANGE_ANALYSIS, utils.CHART_SOURCE_RANGE_ANALYSIS}, adminInfo.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		errMsg = "获取失败"
 		return
 	}
@@ -366,7 +366,7 @@ func (this *RangeChartClassifyController) DeleteChartClassifyCheck() {
 
 	if deleteStatus != 1 && req.ChartInfoId == 0 {
 		classifyCount, err := data_manage.GetChartClassifyCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "分类下是否含有图表失败,Err:" + err.Error()
 			return
@@ -428,7 +428,7 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 	if req.ChartClassifyId > 0 && req.ChartInfoId == 0 {
 		//判断是否含有指标
 		count, err := data_manage.GetChartInfoCountByClassifyId(req.ChartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "判断名称是否已存在失败,Err:" + err.Error()
 			return
@@ -452,7 +452,7 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 	if req.ChartInfoId > 0 {
 		chartInfo, err := data_manage.GetChartInfoById(req.ChartInfoId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "图表已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -503,7 +503,7 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 		chartSeriesOb := new(data_manage.FactorEdbSeriesChartMapping)
 		seriesMappingItem, e := chartSeriesOb.GetItemByChartInfoId(chartInfo.ChartInfoId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 			} else {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取图表关联失败, Err: " + e.Error()
@@ -527,7 +527,7 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 		}
 		// 删除配置关联指标数据
 		multiConfig, e := data_manage.GetMultipleGraphConfigChartMappingByChartId(chartInfo.ChartInfoId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取图表关联配置失败, Err: " + e.Error()
 			return
@@ -550,7 +550,7 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 		pars = append(pars, req.ChartInfoId)
 
 		nextItem, err := data_manage.GetChartInfoByCondition(condition, pars)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 			return
@@ -570,14 +570,14 @@ func (this *RangeChartClassifyController) DeleteChartClassify() {
 			pars = append(pars, chartInfo.ChartClassifyId)
 
 			classifyItem, err := data_manage.GetChartClassifyByCondition(condition, pars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "删除失败"
 				br.ErrMsg = "获取下一级图库分类信息失败,Err:" + err.Error()
 				return
 			}
 			if classifyItem != nil {
 				nextItem, err = data_manage.GetNextChartInfo(chartInfo.ChartClassifyId)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					br.Msg = "删除失败"
 					br.ErrMsg = "获取下一级图库信息失败,Err:" + err.Error()
 					return

+ 21 - 21
controllers/data_manage/range_analysis/chart_info.go

@@ -73,7 +73,7 @@ func (this *RangeChartChartInfoController) Preview() {
 	for _, v := range req.ChartEdbInfoList {
 		edbInfoMapping, e := data_manage.GetChartEdbMappingByEdbInfoId(v.EdbInfoId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = v.EdbAliasName + "指标不存在"
 				br.ErrMsg = v.EdbAliasName + "指标不存在"
 				return
@@ -336,7 +336,7 @@ func (this *RangeChartChartInfoController) Detail() {
 	chartInfo := new(data_manage.ChartInfoView)
 	chartInfo, err = data_manage.GetChartInfoViewById(chartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图被删除,请刷新页面"
 			br.ErrMsg = "图被删除,请刷新页面,Err:" + err.Error()
 			return
@@ -415,7 +415,7 @@ func (this *RangeChartChartInfoController) Detail() {
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -564,7 +564,7 @@ func (this *RangeChartChartInfoController) DetailFromUniqueCode() {
 	status := true
 	chartInfo, err := data_manage.GetChartInfoViewByUniqueCode(uniqueCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			status = false
 		} else {
 			br.Msg = "获取失败"
@@ -602,7 +602,7 @@ func (this *RangeChartChartInfoController) DetailFromUniqueCode() {
 					myCond += ` AND a.chart_info_id=? `
 					myPars = append(myPars, chartInfo.ChartInfoId)
 					myList, err := data_manage.GetMyChartByCondition(myCond, myPars)
-					if err != nil && err.Error() != utils.ErrNoRow() {
+					if err != nil && !utils.IsErrNoRow(err) {
 						br.Msg = "获取失败"
 						br.ErrMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 						return
@@ -659,7 +659,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 				myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 				myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-				if err != nil && err.Error() != utils.ErrNoRow() {
+				if err != nil && !utils.IsErrNoRow(err) {
 					msg = "获取失败"
 					errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 					return
@@ -826,7 +826,7 @@ func GetChartInfoDetailFromUniqueCode(chartInfo *data_manage.ChartInfoView, isCa
 			myChartPars = append(myChartPars, chartInfo.ChartInfoId)
 
 			myChartList, err := data_manage.GetMyChartByCondition(myChartCondition, myChartPars)
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				msg = "获取失败"
 				errMsg = "获取我的图表信息失败,GetMyChartByCondition,Err:" + err.Error()
 				return
@@ -937,7 +937,7 @@ func (this *RangeChartChartInfoController) List() {
 
 	if chartClassifyId > 0 {
 		chartClassifyId, err := data_manage.GetChartClassify(chartClassifyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取图表信息失败"
 			br.ErrMsg = "获取信息失败,GetChartClassify,Err:" + err.Error()
 			return
@@ -969,7 +969,7 @@ func (this *RangeChartChartInfoController) List() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -987,7 +987,7 @@ func (this *RangeChartChartInfoController) List() {
 
 	//获取图表信息
 	list, err := data_manage.GetChartListByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
@@ -995,7 +995,7 @@ func (this *RangeChartChartInfoController) List() {
 	}
 
 	myChartList, err := data_manage.GetMyChartListByAdminId(sysUser.AdminId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取图表信息失败"
 		br.ErrMsg = "获取我的图表信息失败,Err:" + err.Error()
 		return
@@ -1039,7 +1039,7 @@ func (this *RangeChartChartInfoController) List() {
 	}
 
 	resp := new(data_manage.ChartListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*data_manage.ChartInfoView, 0)
 		resp.Paging = page
 		resp.List = items
@@ -1050,7 +1050,7 @@ func (this *RangeChartChartInfoController) List() {
 	}
 
 	dataCount, err := data_manage.GetChartListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -1147,7 +1147,7 @@ func (this *RangeChartChartInfoController) Copy() {
 
 		_, e = data_manage.GetChartClassifyById(req.ChartClassifyId)
 		if e != nil {
-			if e.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(e) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -1160,7 +1160,7 @@ func (this *RangeChartChartInfoController) Copy() {
 	// 图表信息
 	originChart, e := data_manage.GetChartInfoById(req.ChartInfoId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "原图表不存在"
 			return
 		}
@@ -1253,7 +1253,7 @@ func (this *RangeChartChartInfoController) Refresh() {
 		chartInfo, err = data_manage.GetChartInfoByUniqueCode(uniqueCode)
 	}
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,无需刷新"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -1827,7 +1827,7 @@ func (this *RangeChartChartInfoController) SearchByEs() {
 	{
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllChartListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -1841,7 +1841,7 @@ func (this *RangeChartChartInfoController) SearchByEs() {
 		searchList, total, err = data.EsSearchChartInfo(keyword, showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
 	} else {
 		total, searchList, err = data_manage.ChartInfoSearchByEmptyKeyWord(showSysId, sourceList, noPermissionChartIdList, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取图表信息失败,Err:" + err.Error()
 			return
@@ -1942,7 +1942,7 @@ func (this *RangeChartChartInfoController) BaseInfoEdit() {
 
 	chartItem, e := data_manage.GetChartInfoById(req.ChartInfoId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "图表已被删除, 请刷新页面"
 			return
 		}
@@ -1970,7 +1970,7 @@ func (this *RangeChartChartInfoController) BaseInfoEdit() {
 	pars = append(pars, req.ChartName)
 	existItem, err := data_manage.GetChartInfoByCondition(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "判断英文图表名称是否存在失败"
 			br.ErrMsg = "判断英文图表名称是否存在失败,Err:" + err.Error()
 			return
@@ -2063,7 +2063,7 @@ func (this *RangeChartChartInfoController) ChartInfoSave() {
 
 	chartItem, err := data_manage.GetChartInfoById(req.ChartInfoId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "图表已被删除,请刷新页面!"
 			br.ErrMsg = "图表已被删除,请刷新页面,ChartInfoId:" + strconv.Itoa(req.ChartInfoId)
 			return

+ 5 - 5
controllers/data_manage/sci_data.go

@@ -36,14 +36,14 @@ func (this *EdbInfoController) SciClassify() {
 	}
 
 	rootList, err := data_manage.GetBaseFromSciClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromSciClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -52,7 +52,7 @@ func (this *EdbInfoController) SciClassify() {
 	baseFromSciIndexMap := make(map[int][]*data_manage.BaseFromSciClassifyItems)
 
 	allBaseFromSciIndex, err := data_manage.GetSciIndexAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -144,14 +144,14 @@ func (this *EdbInfoController) SciClassifyName() {
 	}
 
 	rootList, err := data_manage.GetBaseFromSciClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromSciClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 7 - 7
controllers/data_manage/sci_hq_data.go

@@ -180,7 +180,7 @@ func (this *SciHqDataController) EditClassify() {
 	}
 	classify, err := data_manage.GetSciHqClassifyById(req.ClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}
@@ -295,7 +295,7 @@ func (this *SciHqDataController) IndexList() {
 	}()
 	classifyId, _ := this.GetInt("ClassifyId", 0)
 	indexList, err := data_manage.GetSciHqIndexBaseInfoByClassifyId(classifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -429,7 +429,7 @@ func (this *SciHqDataController) IndexPageList() {
 		}
 		total = tmpTotal
 		tmpIndexList, err := data_manage.GetSciHqIndexByPage(startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -457,7 +457,7 @@ func (this *SciHqDataController) IndexPageList() {
 		}
 		total = tmpTotal
 		tmpIndexList, err := data_manage.GetSciHqIndexByClassifyId(classifyIds, startSize, pageSize)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 			return
@@ -534,7 +534,7 @@ func (this *SciHqDataController) SingleData() {
 		return
 	}
 	edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_SCI_HQ, indexInfo.IndexCode)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标数据失败"
 		br.ErrMsg = "获取指标库数据失败,Err:" + err.Error()
 		return
@@ -736,7 +736,7 @@ func (this *SciHqDataController) AddEdbInfo() {
 
 	_, err = data_manage.GetSciHqIndexByIndexCode(req.EdbCode)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "指标不存在"
 			return
 		}
@@ -947,7 +947,7 @@ func (c *SciHqDataController) NameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_SCI_HQ, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取卓创红期已存在信息失败,Err:" + err.Error()
 			return

+ 4 - 4
controllers/data_manage/smm_data.go

@@ -37,14 +37,14 @@ func (this *EdbInfoController) SmmClassify() {
 	}
 
 	rootList, err := data_manage.GetBaseFromSmmClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromSmmClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -196,14 +196,14 @@ func (this *EdbInfoController) SmmClassifyName() {
 	}
 
 	rootList, err := data_manage.GetBaseFromSmmClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromSmmClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 8 - 8
controllers/data_manage/supply_analysis/variety.go

@@ -76,7 +76,7 @@ func (this *VarietyController) List() {
 		}
 		total, list, err = varietyObj.GetListByPage(condition, pars, startSize, pageSize)
 	}
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -146,12 +146,12 @@ func (this *VarietyController) Add() {
 	}
 	varietyName := utils.TrimStr(req.VarietyName)
 	item, err := supply_analysis.GetVarietyByName(varietyName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "添加失败"
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil {
+	if item != nil && item.VarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -219,12 +219,12 @@ func (this *VarietyController) Edit() {
 	varietyName := utils.TrimStr(req.VarietyName)
 
 	item, err := supply_analysis.GetVarietyByName(varietyName)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "添加失败"
 		br.ErrMsg = "添加失败,Err:" + err.Error()
 		return
 	}
-	if item != nil && item.VarietyId != req.VarietyId {
+	if item != nil && item.VarietyId != req.VarietyId && item.VarietyId > 0 {
 		br.Msg = "添加失败,品种名称不能重复"
 		br.IsSendEmail = false
 		return
@@ -364,7 +364,7 @@ func (this *VarietyController) Delete() {
 
 	varietyInfo, err := supply_analysis.GetVarietyById(req.VarietyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "该品种不存在或已删除"
 			br.IsSendEmail = false
 		} else {
@@ -411,7 +411,7 @@ func (this *VarietyController) Detail() {
 	if err != nil {
 		br.Msg = "查询品种失败"
 		br.ErrMsg = "查询品种失败;ERR:" + err.Error()
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "不存在该品种或该品种已被删除"
 			br.ErrMsg = "不存在该品种或该品种已被删除"
 			br.IsSendEmail = false
@@ -626,7 +626,7 @@ func (this *VarietyController) ModifyProductionDay() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, req.VarietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return

+ 6 - 6
controllers/data_manage/supply_analysis/variety_edb.go

@@ -57,7 +57,7 @@ func (this *VarietyController) EdbList() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, varietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return
@@ -65,7 +65,7 @@ func (this *VarietyController) EdbList() {
 
 	var list []*supply_analysis.VarietyEdbInfoItem
 	list, err = supply_analysis.GetAllVarietyEdbInfoByVarietyId(varietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -206,7 +206,7 @@ func (this *VarietyController) AddToEdb() {
 
 	varietyEdbInfo, err := supply_analysis.GetVarietyEdbInfoByVarietyEdbId(req.VarietyEdbId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "找不到该指标"
 			br.IsSendEmail = false
 		} else {
@@ -219,7 +219,7 @@ func (this *VarietyController) AddToEdb() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, varietyEdbInfo.VarietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return
@@ -232,7 +232,7 @@ func (this *VarietyController) AddToEdb() {
 
 	if varietyEdbInfo.EdbInfoId > 0 {
 		tmpEdbInfo, err := data_manage.GetEdbInfoById(varietyEdbInfo.EdbInfoId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "添加失败"
 			br.ErrMsg = "查询ETA指标失败,ERR:" + err.Error()
 			return
@@ -347,7 +347,7 @@ func (this *VarietyController) EdbDataExport() {
 
 	var list []*supply_analysis.VarietyEdbInfoItem
 	list, err = supply_analysis.GetAllVarietyEdbInfoByVarietyId(varietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return

+ 8 - 8
controllers/data_manage/supply_analysis/variety_plant.go

@@ -50,7 +50,7 @@ func (this *VarietyController) PlantList() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, varietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return
@@ -58,7 +58,7 @@ func (this *VarietyController) PlantList() {
 
 	var list []*supply_analysis.VarietyPlantItem
 	list, err = supply_analysis.GetAllVarietyPlantByVarietyId(varietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -141,7 +141,7 @@ func (this *VarietyController) AddPlant() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, req.VarietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return
@@ -320,7 +320,7 @@ func (this *VarietyController) EditPlant() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, varietyPlantInfo.VarietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return
@@ -443,7 +443,7 @@ func (this *VarietyController) DeletePlant() {
 	}
 
 	varietyPlantInfo, err := supply_analysis.GetVarietyPlantById(req.VarietyPlantId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "删除失败"
 		br.ErrMsg = "查找品种装置失败,Err:" + err.Error()
 		return
@@ -471,7 +471,7 @@ func (this *VarietyController) DeletePlant() {
 	// 是否有装置的操作权限
 	var hasPermission bool
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, varietyPlantInfo.VarietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return
@@ -485,7 +485,7 @@ func (this *VarietyController) DeletePlant() {
 	// 保留一条装置校验
 	{
 		total, err := supply_analysis.GetCountVarietyPlantByVarietyId(varietyInfo.VarietyId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "删除失败"
 			br.ErrMsg = "查找品种装置总数量失败,Err:" + err.Error()
 			return
@@ -542,7 +542,7 @@ func (this *VarietyController) CopyPlant() {
 	var hasPermission bool //是否有操作权限
 	// 是否有装置的操作权限
 	hasPermission, err = supply_analysisServ.HasVarietyPlantPermission(this.SysUser, req.VarietyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "查询是否有装置的操作权限失败;ERR:" + err.Error()
 		return

+ 6 - 6
controllers/data_manage/usda_fas_data.go

@@ -44,7 +44,7 @@ func (this *BaseFromUsdaFasController) UsdaFasClassify() {
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromUsdaFasClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -134,7 +134,7 @@ func (this *BaseFromUsdaFasController) UsdaFasIndexData() {
 	if classifyId >= 0 {
 		classifyInfo, err := data_manage.GetBaseFromUsdaFasClassifyById(classifyId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -371,7 +371,7 @@ func (this *BaseFromUsdaFasController) UsdaFasSingleData() {
 		return
 	}
 	edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_USDA_FAS, indexCode)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取数据源失败"
 		br.ErrMsg = "获取数据源失败,Err:" + err.Error()
 		return
@@ -421,7 +421,7 @@ func (this *BaseFromUsdaFasController) UsdaFasIndexList() {
 	}()
 	classifyId, _ := this.GetInt("ClassifyId", 0)
 	indexList, err := data_manage.GetUsdaFasIndexByClassifyId(classifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -736,7 +736,7 @@ func (this *BaseFromUsdaFasController) UsdaFasNameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_USDA_FAS, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取钢联已存在信息失败,Err:" + err.Error()
 			return
@@ -1039,7 +1039,7 @@ func (this *BaseFromUsdaFasController) ExportUsdaFasList() {
 	if classifyId > 0 {
 		classifyInfo, err := data_manage.GetBaseFromUsdaFasClassifyById(classifyId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类不存在"
 				return
 			}

+ 7 - 7
controllers/data_manage/wind_data.go

@@ -29,7 +29,7 @@ func (this *EdbInfoController) WindClassify() {
 	parentId, _ := this.GetInt("ParentId")
 	// 特殊处理顶级分类
 	rootList, err := data_manage.GetEdbClassifyByParentId(parentId, 0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -38,7 +38,7 @@ func (this *EdbInfoController) WindClassify() {
 	if parentId == 0 {
 		// 查询wind指标的所有一级分类
 		classifyIdList, e := data_manage.GetEdbClassifyIdListBySource(utils.DATA_SOURCE_WIND)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取分类列表失败,Err:" + e.Error()
 			return
@@ -53,7 +53,7 @@ func (this *EdbInfoController) WindClassify() {
 		}
 		// 查询wind指标的所有一级分类下的指标信息
 		rootIds, e := data_manage.GetEdbClassifyRootIdsByClassifyIds(classifyIdList)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取分类列表失败,Err:" + e.Error()
 			return
@@ -70,7 +70,7 @@ func (this *EdbInfoController) WindClassify() {
 		// 获取当前账号的不可见指标
 		obj := data_manage.EdbInfoNoPermissionAdmin{}
 		confList, err := obj.GetAllListByAdminId(this.SysUser.AdminId)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取不可见指标配置数据失败,Err:" + err.Error()
 			return
@@ -218,7 +218,7 @@ func (this *EdbInfoController) WindEdbInfoList() {
 	edbInfoId, _ := this.GetInt("EdbInfoId")
 	if classifyId > 0 {
 		childClassify, e, _ := data.GetChildClassifyByClassifyId(classifyId)
-		if e != nil && e.Error() != utils.ErrNoRow() {
+		if e != nil && !utils.IsErrNoRow(e) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取分类信息失败, GetEdbClassify,Err:" + e.Error()
 			return
@@ -270,7 +270,7 @@ func (this *EdbInfoController) WindEdbInfoList() {
 		if classifyId > 0 { // todo 当没有传入分类ID时,如何处理 同一个分类ID,顶级分类是一样的
 			targetClassify, err := data_manage.GetEdbClassifyById(classifyId)
 			if err != nil {
-				if err.Error() == utils.ErrNoRow() {
+				if utils.IsErrNoRow(err) {
 					br.Msg = "当前分类不存在"
 					return
 				}
@@ -279,7 +279,7 @@ func (this *EdbInfoController) WindEdbInfoList() {
 				return
 			}
 			targetClassifyList, err = data_manage.GetEdbClassifyByRootIdLevel(targetClassify.RootId, targetClassify.ClassifyType, "")
-			if err != nil && err.Error() != utils.ErrNoRow() {
+			if err != nil && !utils.IsErrNoRow(err) {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取分类信息失败,Err:" + err.Error()
 				return

+ 10 - 8
controllers/data_manage/yongyi_data.go

@@ -40,7 +40,7 @@ func (this *EdbInfoController) YongyiClassify() {
 	}
 
 	classifyAll, err := data_manage.GetAllBaseFromYongyiClassify()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -128,7 +128,7 @@ func (this *EdbInfoController) YongyiIndexData() {
 	if classifyId >= 0 {
 		classifyInfo, err := data_manage.GetBaseFromYongyiClassifyById(classifyId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -320,7 +320,7 @@ func (this *EdbInfoController) YongyiSingleData() {
 		return
 	}
 	edbInfo, err := data_manage.GetEdbInfoByEdbCode(utils.DATA_SOURCE_YONYI, indexCode)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取数据源失败"
 		br.ErrMsg = "获取数据源失败,Err:" + err.Error()
 		return
@@ -343,7 +343,7 @@ func (this *EdbInfoController) YongyiSingleData() {
 	ret.Unit = indexInfo.Unit
 	for _, v := range dataTmpList {
 		tmp := &data_manage.YongyiSingleData{
-			Value:    v.Value,
+			Value:    v.Value.String(),
 			DataTime: v.DataTime,
 		}
 		dataList = append(dataList, tmp)
@@ -370,7 +370,7 @@ func (this *EdbInfoController) YongyiIndexList() {
 	}()
 	classifyId, _ := this.GetInt("ClassifyId", 0)
 	indexList, err := data_manage.GetYongyiIndexByClassifyId(classifyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取指标信息失败,Err:" + err.Error()
 		return
@@ -660,7 +660,7 @@ func (this *EdbInfoController) YongyiNameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_YONYI, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取钢联已存在信息失败,Err:" + err.Error()
 			return
@@ -962,7 +962,7 @@ func (this *EdbInfoController) ExportYongyiList() {
 	if classifyId > 0 {
 		classifyInfo, err := data_manage.GetBaseFromYongyiClassifyById(classifyId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "分类不存在"
 				return
 			}
@@ -980,9 +980,11 @@ func (this *EdbInfoController) ExportYongyiList() {
 
 		if len(childClassify) > 0 {
 			condition += `AND classify_id IN (` + utils.GetOrmInReplace(len(childClassify)) + `)`
+			var classifyIdList []int
 			for _, child := range childClassify {
-				pars = append(pars, child.ClassifyId)
+				classifyIdList = append(classifyIdList, child.ClassifyId)
 			}
+			pars = append(pars, classifyIdList)
 		} else {
 			condition += ` AND classify_id=?`
 			pars = append(pars, classifyId)

+ 14 - 1
controllers/data_source/data_source.go

@@ -124,7 +124,7 @@ func (c *DataSourceController) SearchByEs() {
 		var updateEs bool
 		if v.StartDate == "" || v.EndDate == "" || v.LatestValue == "" || v.LatestValue == "0" {
 			minMax, e := dataSourceModel.GetBaseIndexDataMinMax(v.Source, v.SubSource, v.IndexCode)
-			if e != nil && e.Error() != utils.ErrNoRow() {
+			if e != nil && !utils.IsErrNoRow(e) {
 				br.Msg = "获取失败"
 				br.ErrMsg = fmt.Sprintf("获取指标开始结束时间失败, %v", e)
 				return
@@ -260,6 +260,19 @@ func (c *DataSourceController) SearchByEs() {
 	//	}
 	//}
 
+	for _, v := range listMap {
+		classifyId, ok := v[classifyIdKey].(int)
+		if !ok {
+			v["ClassifyUniqueCode"] = ""
+			continue
+		}
+		v["ClassifyUniqueCode"] = strconv.Itoa(classifyId)
+		startDate := v["StartDate"].(string)
+		v["StartDate"] = utils.GormDateStrToDateStr(startDate)
+		endDate := v["EndDate"].(string)
+		v["EndDate"] = utils.GormDateStrToDateStr(endDate)
+	}
+
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := dataSourceModel.SearchDataSourceResp{
 		Paging: page,

+ 7 - 8
controllers/data_source/sci99.go

@@ -103,7 +103,6 @@ func (this *DataSourceController) Sci99Data() {
 		pars = append(pars, "%"+keyword+"%")
 	}
 
-
 	sci99List, err := data_source.GetSci99Index(condition, pars)
 	if err != nil {
 		br.Msg = "获取数据失败"
@@ -121,13 +120,13 @@ func (this *DataSourceController) Sci99Data() {
 		product.Unit = v.Unit
 		product.ModifyTime = v.ModifyTime
 
-		modifyTime, err := data_source.GetSci99IndexLatestDate(v.IndexCode)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取更新时间失败"
-			br.ErrMsg = "获取更新时间失败,Err:" + err.Error()
-			return
-		}
-		product.ModifyTime = modifyTime
+		// modifyTime, err := data_source.GetSci99IndexLatestDate(v.IndexCode)
+		// if err != nil && !utils.IsErrNoRow(err) {
+		// 	br.Msg = "获取更新时间失败"
+		// 	br.ErrMsg = "获取更新时间失败,Err:" + err.Error()
+		// 	return
+		// }
+		// product.ModifyTime = modifyTime
 
 		total, err := data_source.GetSci99IndexDataCount(v.IndexCode)
 		page := paging.GetPaging(currentIndex, pageSize, total)

+ 7 - 6
controllers/data_stat/edb_source_stat.go

@@ -225,7 +225,7 @@ func (this *EdbSourceStatController) EdbDeleteLog() {
 	}
 	total, err := data_stat.GetEdbDeleteLogCount(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取指标删除列表总数失败"
 			br.ErrMsg = "获取指标删除列表总数失败,Err:" + err.Error()
 			return
@@ -378,7 +378,7 @@ func (this *EdbSourceStatController) EdbUpdateLog() {
 	}
 	total, err := data_stat.GetEdbUpdateLogCount(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取指标删除列表总数失败"
 			br.ErrMsg = "获取指标删除列表总数失败,Err:" + err.Error()
 			return
@@ -555,7 +555,7 @@ func (this *EdbSourceStatController) EdbUpdateStat() {
 	}
 	total, err := data_stat.GetEdbUpdateStatCount(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取指标列表总数失败"
 			br.ErrMsg = "获取指标列表总数失败,Err:" + err.Error()
 			return
@@ -727,7 +727,7 @@ func (this *EdbSourceStatController) EdbSourceStat() {
 	}
 	total, err := data_stat.GetEdbSourceStatCount(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取数据源统计列表总数失败"
 			br.ErrMsg = "获取数据源统计列表总数失败,Err:" + err.Error()
 			return
@@ -804,6 +804,7 @@ func (this *EdbSourceStatController) EdbUpdateFailedList() {
 
 	terminalCode := this.GetString("TerminalCode", "")
 	createTime := this.GetString("CreateTime", "")
+
 	condition := " and source = ? and terminal_code = ?"
 	var pars []interface{}
 	pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, terminalCode)
@@ -813,7 +814,7 @@ func (this *EdbSourceStatController) EdbUpdateFailedList() {
 	if terminalCode != "" {
 		terminalInfo, err := data_manage.GetEdbTerminalByTerminalCode(terminalCode)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "终端不存在"
 				return
 			}
@@ -933,7 +934,7 @@ func (this *EdbSourceStatController) EdbUpdateFailedDetailList() {
 
 	total, err := data_stat.GetEdbUpdateStatCount(condition, pars)
 	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(err) {
 			br.Msg = "获取指标列表总数失败"
 			br.ErrMsg = "获取指标列表总数失败,Err:" + err.Error()
 			return

+ 5 - 3
controllers/document_manage/document_manage_controller.go

@@ -156,7 +156,8 @@ func (this *DocumentManageController) DocumentReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	documentReportPage, err := document_manage_service.DocumentReportList(documentType, chartPermissionIdList, classifyIdList, keyword, orderField, orderType, currentIndex, pageSize)
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	documentReportPage, err := document_manage_service.DocumentReportList(documentType, chartPermissionIdList, classifyIdList, keyword, orderField, orderType, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -211,7 +212,8 @@ func (this *DocumentManageController) RuiSiReportList() {
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
-	RuiSiReportPage, err := document_manage_service.RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList, keyword, orderField, orderType, currentIndex, pageSize)
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	RuiSiReportPage, err := document_manage_service.RuiSiReportList(classifyIdFirst, classifyIdSecond, classifyIdThird, chartPermissionIdList, keyword, orderField, orderType, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取报告列表失败"
 		br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -257,7 +259,7 @@ func (this *DocumentManageController) DocumentRuiSiDetail() {
 
 	reportDetail, err := document_manage_service.DocumentRuiSiDetail(reportId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "报告已被删除"
 			return
 		}

+ 14 - 2
controllers/english_report/email.go

@@ -187,7 +187,7 @@ func (this *EnglishReportEmailController) Save() {
 
 	// 英文客户以邮箱为主, 邮箱去重, 手机号非必填, 此处不做手机号去重
 	exist, e := models.GetEnglishReportEmailByEmail(req.Email)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "保存失败"
 		br.ErrMsg = "获取同名邮箱失败, Err:" + e.Error()
 		return
@@ -595,6 +595,18 @@ func (this *EnglishReportEmailController) Send() {
 			noCompanyIdsMap[v] = struct{}{}
 		}
 	}
+
+	// 加个缓存吧,避免重复点击
+	cacheKey := "CACHE_ENGLISH_REPORT_SEND_" + strconv.Itoa(req.ReportId)
+	if !utils.Rc.SetNX(cacheKey, 1, 300*time.Second) {
+		br.Msg = "系统处理中,请稍后重试!"
+		br.ErrMsg = "系统处理中,请稍后重试!" + sysUser.RealName + ";data:" + string(this.Ctx.Input.RequestBody)
+		return
+	}
+	defer func() {
+		_ = utils.Rc.Delete(cacheKey)
+	}()
+
 	// 指定品种的客户
 	sendCompanyIds := make([]int, 0)
 	if len(req.EnPermissions) > 0 {
@@ -933,7 +945,7 @@ func (this *EnglishReportEmailController) ImportListMatch() {
 	}
 	companyItem, e := models.GetEnglishCompanyById(companyId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "客户已被删除, 请刷新页面"
 			return
 		}

+ 5 - 5
controllers/english_report/en_permission.go

@@ -62,7 +62,7 @@ func (this *EnPermissionController) Add() {
 	existPars := make([]interface{}, 0)
 	existPars = append(existPars, req.PermissionName, req.ParentId)
 	exist, e := existOB.GetItemByCondition(existCond, existPars)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "操作失败"
 		br.ErrMsg = "获取重名品种权限失败, Err: " + e.Error()
 		return
@@ -143,7 +143,7 @@ func (this *EnPermissionController) Edit() {
 	existPars := make([]interface{}, 0)
 	existPars = append(existPars, req.PermissionName, req.ParentId, req.PermissionId)
 	exist, e := ob.GetItemByCondition(existCond, existPars)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "操作失败"
 		br.ErrMsg = "获取重名品种权限失败, Err: " + e.Error()
 		return
@@ -155,7 +155,7 @@ func (this *EnPermissionController) Edit() {
 
 	item, e := ob.GetItemById(req.PermissionId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "品种不存在, 请刷新页面"
 			return
 		}
@@ -384,7 +384,7 @@ func (this *EnPermissionController) Remove() {
 	ob := new(models.EnPermission)
 	item, e := ob.GetItemById(req.PermissionId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "品种不存在, 请刷新页面"
 			return
 		}
@@ -522,7 +522,7 @@ func (this *EnPermissionController) SetEnabled() {
 
 	item, e := ob.GetItemById(req.PermissionId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "品种不存在, 请刷新页面"
 			return
 		}

+ 8 - 8
controllers/english_report/english_classify.go

@@ -206,7 +206,7 @@ func (this *EnglishReportController) AddClassify() {
 	if parentId > 0 {
 		parentClassify, err := models.GetEnglishReportClassifyById(parentId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "上级分类不存在"
 				return
 			}
@@ -331,7 +331,7 @@ func (this *EnglishReportController) EditClassify() {
 
 	oldItem, err := models.GetEnglishReportClassifyById(classifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "当前分类不存在"
 			return
 		}
@@ -350,7 +350,7 @@ func (this *EnglishReportController) EditClassify() {
 	if parentId > 0 {
 		parent, err = models.GetEnglishReportClassifyById(parentId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "上级分类不存在"
 				return
 			}
@@ -377,7 +377,7 @@ func (this *EnglishReportController) EditClassify() {
 	//判断是否已存在同个名称的分类
 	existItem, e := models.GetEnglishClassifyByClassifyNameParentId(classifyName, parentId)
 	if e != nil {
-		if e.Error() != utils.ErrNoRow() {
+		if !utils.IsErrNoRow(e) {
 			br.Msg = "查询已存在的分类出错"
 			br.ErrMsg = "查询已存在的分类出错, Err:" + e.Error()
 			return
@@ -482,7 +482,7 @@ func (this *EnglishReportController) DelClassify() {
 
 	classifyInfo, err := models.GetEnglishReportClassifyById(classifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "当前分类不存在"
 			br.ErrMsg = "当前分类不存在"
 			return
@@ -505,7 +505,7 @@ func (this *EnglishReportController) DelClassify() {
 	// 	return
 	// }
 	reportCount, e := models.GetEnglishReportCounts(classifyId, classifyInfo.ParentId)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取失败,Err:" + e.Error()
 		return
@@ -517,7 +517,7 @@ func (this *EnglishReportController) DelClassify() {
 		return
 	}
 	videoCount, e := models.GetEnglishVideoCounts(classifyId, classifyInfo.ParentId)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取失败,Err:" + e.Error()
 		return
@@ -754,7 +754,7 @@ func (this *EnglishReportController) SetEnabled() {
 	}
 	item, err := models.GetEnglishReportClassifyById(req.ClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}

+ 3 - 3
controllers/english_report/english_company.go

@@ -266,7 +266,7 @@ func (this *EnglishCompanyController) Save() {
 
 	// 重名校验
 	exist, e := models.GetEnglishCompanyByName(req.CompanyName)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "保存失败"
 		br.ErrMsg = "获取客户信息失败, Err:" + e.Error()
 		return
@@ -298,7 +298,7 @@ func (this *EnglishCompanyController) Save() {
 			return
 		}
 	} else {
-		if exist != nil && exist.CompanyId != req.CompanyId {
+		if exist != nil && exist.CompanyId != req.CompanyId && exist.CompanyId > 0 {
 			br.Msg = "客户名称已存在"
 			return
 		}
@@ -721,7 +721,7 @@ func (this *EnglishCompanyController) SavePermission() {
 	nowTime := time.Now().Local()
 	item, e := models.GetEnglishCompanyById(req.CompanyId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "客户已被删除, 请刷新页面"
 			return
 		}

+ 2 - 2
controllers/english_report/english_company_todo.go

@@ -2,12 +2,12 @@ package english_report
 
 import (
 	"encoding/json"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	"eta/eta_api/models/system"
 	"eta/eta_api/services"
 	"eta/eta_api/utils"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"html"
 	"time"
 )
@@ -524,7 +524,7 @@ func (this *EnglishCompanyTodoController) LastPublicTodo() {
 	}
 
 	item, e := models.GetLastEnglishCompanyTodoPublic()
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取最新的公共TODO失败, Err: " + e.Error()
 		return

+ 5 - 5
controllers/english_report/english_video.go

@@ -2,12 +2,12 @@ package english_report
 
 import (
 	"encoding/json"
-	"github.com/rdlucklib/rdluck_tools/paging"
 	"eta/eta_api/controllers"
 	"eta/eta_api/models"
 	"eta/eta_api/models/company"
 	"eta/eta_api/services"
 	"eta/eta_api/utils"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"strconv"
 	"strings"
 )
@@ -251,7 +251,7 @@ func (this *EnglishVideoController) Detail() {
 	}
 	item, err := models.GetEnglishVideoById(id)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "路演视频不存在"
 			return
 		}
@@ -408,7 +408,7 @@ func (this *EnglishVideoController) PublishVideo() {
 	}
 	videoInfo, err := models.GetEnglishVideoById(id)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "路演视频不存在"
 			return
 		}
@@ -474,7 +474,7 @@ func (this *EnglishVideoController) PublishCancleVideo() {
 	}
 	videoInfo, err := models.GetEnglishVideoById(req.Id)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "路演视频不存在"
 			return
 		}
@@ -526,7 +526,7 @@ func (this *EnglishVideoController) Delete() {
 	}
 	videoInfo, err := models.GetEnglishVideoById(req.Id)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "路演视频不存在"
 			return
 		}

+ 1 - 1
controllers/english_report/policy_report.go

@@ -39,7 +39,7 @@ func (this *EnglishPolicyReportController) Detail() {
 	}
 	item, err := models.GetEnglishPolicyReportById(reportId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "报告不存在!"
 			return
 		}

+ 10 - 10
controllers/english_report/report.go

@@ -94,7 +94,7 @@ func (this *EnglishReportController) Add() {
 	}
 	reportClassify, e := models.GetEnglishReportClassifyById(req.ClassifyIdFirst)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "报告所在分类异常"
 			return
 		}
@@ -250,7 +250,7 @@ func (this *EnglishReportController) Edit() {
 	var stage int
 	report, e := models.GetEnglishReportById(int(req.ReportId))
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "报告已被删除, 请刷新页面"
 			return
 		}
@@ -337,7 +337,7 @@ func (this *EnglishReportController) Detail() {
 	}
 	item, err := models.GetEnglishReportById(reportId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "报告已被删除"
 			return
 		}
@@ -926,7 +926,7 @@ func (this *EnglishReportController) Delete() {
 	}
 	reportInfo, err := models.GetEnglishReportById(req.ReportIds)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "报告不存在"
 			return
 		}
@@ -1071,7 +1071,7 @@ func (this *EnglishReportController) ClassifyIdDetail() {
 		classifyIdSecond, _ = this.GetInt("ClassifyIdSecond")
 	}
 	item, err := models.GetEnglishReportDetailByClassifyId(classifyIdFirst, classifyIdSecond)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败!"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
@@ -1251,7 +1251,7 @@ func (this *EnglishReportController) EditPolicy() {
 	//查询报告是否存在
 	reportInfo, err := models.GetEnglishReportItemById(int(req.ReportId))
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "报告不存在"
 			return
 		}
@@ -1333,7 +1333,7 @@ func (this *EnglishReportController) SubmitApprove() {
 	reportOb := new(models.EnglishReport)
 	reportItem, e := reportOb.GetItemById(reportId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "报告已被删除, 请刷新页面"
 			return
 		}
@@ -1343,7 +1343,7 @@ func (this *EnglishReportController) SubmitApprove() {
 	}
 	reportClassify, e := models.GetEnglishReportClassifyById(reportItem.ClassifyIdFirst)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "报告所在分类异常"
 			return
 		}
@@ -1434,7 +1434,7 @@ func (this *EnglishReportController) CancelApprove() {
 	reportOb := new(models.EnglishReport)
 	reportItem, e := reportOb.GetItemById(reportId)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "报告已被删除, 请刷新页面"
 			return
 		}
@@ -1444,7 +1444,7 @@ func (this *EnglishReportController) CancelApprove() {
 	}
 	reportClassify, e := models.GetEnglishReportClassifyById(reportItem.ClassifyIdFirst)
 	if e != nil {
-		if e.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(e) {
 			br.Msg = "报告所在分类异常"
 			return
 		}

+ 1 - 1
controllers/eta_trial/questionnaire.go

@@ -56,7 +56,7 @@ func (this *EtaTrialController) QuestionnairePopUp() {
 	}
 
 	fillItem, e := eta_trial.GetQuestionnaireFillRecordCountByMobile(sysUser.Mobile)
-	if e != nil && e.Error() != utils.ErrNoRow() {
+	if e != nil && !utils.IsErrNoRow(e) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败失败,GetQuestionnaireFillRecordCountByMobile Err:" + e.Error()
 		return

+ 12 - 10
controllers/hisugar_data.go

@@ -446,7 +446,7 @@ func (c *TradeCommonController) HisugarNameCheck() {
 			EdbName: v.EdbName,
 		})
 		dataItems, err := data_manage.GetEdbDataAllByEdbCode(v.EdbCode, utils.DATA_SOURCE_HISUGAR, 0, utils.EDB_DATA_LIMIT)
-		if err != nil && err.Error() != utils.ErrNoRow() {
+		if err != nil && !utils.IsErrNoRow(err) {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取泛糖科技已存在信息失败,Err:" + err.Error()
 			return
@@ -675,11 +675,13 @@ func (this *TradeCommonController) HisugarExporthisugarList() {
 	if req.IsSelectedAll {
 		if len(req.IndexCode) > 0 {
 			condition += ` AND index_code NOT IN (` + utils.GetOrmInReplace(len(req.IndexCode)) + `)`
+			//condition += ` AND index_code NOT IN ? `
 			pars = append(pars, req.IndexCode)
 		}
 	} else {
 		if len(req.IndexCode) > 0 {
 			condition += ` AND index_code IN (` + utils.GetOrmInReplace(len(req.IndexCode)) + `)`
+			//condition += ` AND index_code IN ?`
 			pars = append(pars, req.IndexCode)
 		}
 	}
@@ -690,8 +692,10 @@ func (this *TradeCommonController) HisugarExporthisugarList() {
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-		if classifyIds != ""{
-			condition += ` AND classify_id IN (`+ classifyIds +`)`
+		if classifyIds != "" {
+			condition += ` AND classify_id IN (` + classifyIds + `)`
+			//condition += ` AND classify_id IN (?)`
+			//pars = append(pars, classifyIds)
 		}
 	}
 	frequencies, err := data_manage.GetHisugarFrequencyByCondition(condition, pars)
@@ -721,7 +725,7 @@ func (this *TradeCommonController) HisugarExporthisugarList() {
 			return
 		}
 
-		sheetNew, err := xlsxFile.AddSheet(*frequency+frequencyMap[*frequency])
+		sheetNew, err := xlsxFile.AddSheet(*frequency + frequencyMap[*frequency])
 		if err != nil {
 			fmt.Println("新增Sheet失败", err.Error())
 			return
@@ -911,8 +915,8 @@ func (this *TradeCommonController) HisugarIndexData() {
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-		if classifyIds != ""{
-			condition += ` AND classify_id IN (`+ classifyIds +`)`
+		if classifyIds != "" {
+			condition += ` AND classify_id IN (` + classifyIds + `)`
 		}
 	}
 
@@ -1058,7 +1062,6 @@ func (this *TradeCommonController) GetHisugarIndexInfo() {
 	br.Data = indexInfoPage
 }
 
-
 // FrequencyList
 // @Title 指标频度列表
 // @Description 指标频度列表
@@ -1092,12 +1095,11 @@ func (this *TradeCommonController) FrequencyList() {
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-		if classifyIds != ""{
-			condition += ` AND classify_id IN (`+ classifyIds +`)`
+		if classifyIds != "" {
+			condition += ` AND classify_id IN (` + classifyIds + `)`
 		}
 	}
 
-
 	frequencies, err := data_manage.GetHisugarFrequencyByCondition(condition, pars)
 	if err != nil {
 		fmt.Println("GetSciFrequency err:", err.Error())

+ 420 - 0
controllers/llm/abstract.go

@@ -0,0 +1,420 @@
+package llm
+
+import (
+	"encoding/json"
+	"eta/eta_api/cache"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/models/rag"
+	"eta/eta_api/models/rag/request"
+	"eta/eta_api/models/rag/response"
+	"eta/eta_api/services"
+	"eta/eta_api/services/elastic"
+	"eta/eta_api/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+// AbstractController
+// @Description: 摘要管理
+type AbstractController struct {
+	controllers.BaseAuthController
+}
+
+// List
+// @Title 列表
+// @Description 列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} []*rag.QuestionListListResp
+// @router /abstract/list [get]
+func (c *AbstractController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	keyWord := c.GetString("KeyWord")
+	tagId, _ := c.GetInt("TagId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	// 获取列表
+	total, viewList, err := getAbstractList(keyWord, tagId, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := response.AbstractListListResp{
+		List:   viewList,
+		Paging: page,
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+func getAbstractList(keyWord string, tagId int, startSize, pageSize int) (total int, viewList []rag.WechatArticleAbstractView, err error) {
+	if keyWord == `` {
+		var condition string
+		var pars []interface{}
+		condition += fmt.Sprintf(` AND c.%s = ?`, rag.WechatPlatformColumns.Enabled)
+		pars = append(pars, 1)
+
+		if keyWord != "" {
+			condition += fmt.Sprintf(` AND a.%s like ?`, rag.WechatArticleAbstractColumns.Content)
+			pars = append(pars, `%`+keyWord+`%`)
+		}
+
+		if tagId > 0 {
+			condition += fmt.Sprintf(` AND d.%s = ?`, rag.WechatPlatformTagMappingColumns.TagID)
+			pars = append(pars, tagId)
+		}
+
+		obj := new(rag.WechatArticleAbstract)
+		tmpTotal, list, tmpErr := obj.GetPageListByTagAndPlatformCondition(condition, pars, startSize, pageSize)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		total = tmpTotal
+		viewList = obj.WechatArticleAbstractItem(list)
+	} else {
+		sortMap := map[string]string{
+			//"ModifyTime":              "desc",
+			//"WechatArticleAbstractId": "desc",
+		}
+
+		obj := new(rag.WechatPlatform)
+		platformList, tmpErr := obj.GetListByCondition(` AND enabled = 1 `, []interface{}{}, 0, 100000)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		platformIdList := make([]int, 0)
+		for _, v := range platformList {
+			platformIdList = append(platformIdList, v.WechatPlatformId)
+		}
+		tagList := make([]int, 0)
+		if tagId > 0 {
+			tagList = append(tagList, tagId)
+		}
+		tmpTotal, list, tmpErr := elastic.WechatArticleAbstractEsSearch(keyWord, tagList, platformIdList, startSize, pageSize, sortMap)
+		if tmpErr != nil {
+			err = tmpErr
+			return
+		}
+		total = int(tmpTotal)
+		if list != nil && len(list) > 0 {
+			viewList = list[0].ToViewList(list)
+		}
+	}
+
+	return
+}
+
+// Del
+// @Title 删除摘要
+// @Description 删除摘要
+// @Param	request	body request.BeachOpAbstractReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/del [post]
+func (c *AbstractController) Del() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.BeachOpAbstractReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if len(req.WechatArticleAbstractIdList) <= 0 && !req.IsSelectAll {
+		br.Msg = "请选择摘要"
+		br.IsSendEmail = false
+		return
+	}
+
+	vectorKeyList := make([]string, 0)
+	wechatArticleAbstractIdList := make([]int, 0)
+
+	obj := rag.WechatArticleAbstract{}
+
+	if !req.IsSelectAll {
+		list, err := obj.GetByIdList(req.WechatArticleAbstractIdList)
+		if err != nil {
+			br.Msg = "修改失败"
+			br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+			if utils.IsErrNoRow(err) {
+				br.Msg = "问题不存在"
+				br.IsSendEmail = false
+			}
+			return
+		}
+		if len(list) > 0 {
+			for _, v := range list {
+				// 有加入到向量库,那么就加入到待删除的向量库list中
+				if v.VectorKey != `` {
+					vectorKeyList = append(vectorKeyList, v.VectorKey)
+				}
+				wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.WechatArticleAbstractId)
+			}
+		}
+	} else {
+		notIdMap := make(map[int]bool)
+		for _, v := range req.NotWechatArticleAbstractIdList {
+			notIdMap[v] = true
+		}
+
+		_, list, err := getAbstractList(req.KeyWord, req.TagId, 0, 100000)
+		if err != nil {
+			br.Msg = "修改失败"
+			br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+			if utils.IsErrNoRow(err) {
+				br.Msg = "问题不存在"
+				br.IsSendEmail = false
+			}
+			return
+		}
+		if len(list) > 0 {
+			for _, v := range list {
+				if notIdMap[v.WechatArticleAbstractId] {
+					continue
+				}
+				// 有加入到向量库,那么就加入到待删除的向量库list中
+				if v.VectorKey != `` {
+					vectorKeyList = append(vectorKeyList, v.VectorKey)
+				}
+				wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.WechatArticleAbstractId)
+			}
+		}
+	}
+
+	// 删除向量库
+	err = services.DelLlmDoc(vectorKeyList, wechatArticleAbstractIdList)
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除向量库失败,Err:" + err.Error()
+		return
+	}
+
+	// 删除摘要
+	err = obj.DelByIdList(wechatArticleAbstractIdList)
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+
+	// 删除es数据
+	for _, wechatArticleAbstractId := range wechatArticleAbstractIdList {
+		go services.DelEsWechatArticleAbstract(wechatArticleAbstractId)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `删除成功`
+}
+
+// VectorDel
+// @Title 删除摘要向量库
+// @Description 删除摘要向量库
+// @Param	request	body request.BeachOpAbstractReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/vector/del [post]
+func (c *AbstractController) VectorDel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.BeachOpAbstractReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if len(req.WechatArticleAbstractIdList) <= 0 && !req.IsSelectAll {
+		br.Msg = "请选择摘要"
+		br.IsSendEmail = false
+		return
+	}
+
+	vectorKeyList := make([]string, 0)
+	wechatArticleAbstractIdList := make([]int, 0)
+
+	obj := rag.WechatArticleAbstract{}
+
+	if !req.IsSelectAll {
+		list, err := obj.GetByIdList(req.WechatArticleAbstractIdList)
+		if err != nil {
+			br.Msg = "修改失败"
+			br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+			if utils.IsErrNoRow(err) {
+				br.Msg = "问题不存在"
+				br.IsSendEmail = false
+			}
+			return
+		}
+		if len(list) > 0 {
+			for _, v := range list {
+				// 有加入到向量库,那么就加入到待删除的向量库list中
+				if v.VectorKey != `` {
+					vectorKeyList = append(vectorKeyList, v.VectorKey)
+				}
+				wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.WechatArticleAbstractId)
+			}
+		}
+	} else {
+		notIdMap := make(map[int]bool)
+		for _, v := range req.NotWechatArticleAbstractIdList {
+			notIdMap[v] = true
+		}
+		_, list, err := getAbstractList(req.KeyWord, req.TagId, 0, 100000)
+		if err != nil {
+			br.Msg = "修改失败"
+			br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+			if utils.IsErrNoRow(err) {
+				br.Msg = "问题不存在"
+				br.IsSendEmail = false
+			}
+			return
+		}
+		if len(list) > 0 {
+			for _, v := range list {
+				if notIdMap[v.WechatArticleAbstractId] {
+					continue
+				}
+
+				// 有加入到向量库,那么就加入到待删除的向量库list中
+				if v.VectorKey != `` {
+					vectorKeyList = append(vectorKeyList, v.VectorKey)
+				}
+				wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.WechatArticleAbstractId)
+			}
+		}
+	}
+
+	// 删除摘要库
+	err = services.DelLlmDoc(vectorKeyList, wechatArticleAbstractIdList)
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+
+	// 修改ES数据
+	for _, wechatArticleAbstractId := range wechatArticleAbstractIdList {
+		go services.AddOrEditEsWechatArticleAbstract(wechatArticleAbstractId)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `删除成功`
+}
+
+// AddVector
+// @Title 删除摘要向量库
+// @Description 删除摘要向量库
+// @Param	request	body request.BeachOpAbstractReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /abstract/vector/add [post]
+func (c *AbstractController) AddVector() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.BeachOpAbstractReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if len(req.WechatArticleAbstractIdList) <= 0 && !req.IsSelectAll {
+		br.Msg = "请选择摘要"
+		br.IsSendEmail = false
+		return
+	}
+
+	wechatArticleAbstractIdList := make([]int, 0)
+
+	obj := rag.WechatArticleAbstract{}
+
+	if !req.IsSelectAll {
+		list, err := obj.GetByIdList(req.WechatArticleAbstractIdList)
+		if err != nil {
+			br.Msg = "修改失败"
+			br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+			if utils.IsErrNoRow(err) {
+				br.Msg = "问题不存在"
+				br.IsSendEmail = false
+			}
+			return
+		}
+		if len(list) > 0 {
+			for _, v := range list {
+				wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.WechatArticleAbstractId)
+			}
+		}
+	} else {
+		notIdMap := make(map[int]bool)
+		for _, v := range req.NotWechatArticleAbstractIdList {
+			notIdMap[v] = true
+		}
+
+		_, list, err := getAbstractList(req.KeyWord, req.TagId, 0, 100000)
+		if err != nil {
+			br.Msg = "修改失败"
+			br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+			if utils.IsErrNoRow(err) {
+				br.Msg = "问题不存在"
+				br.IsSendEmail = false
+			}
+			return
+		}
+		if len(list) > 0 {
+			for _, v := range list {
+				if notIdMap[v.WechatArticleAbstractId] {
+					continue
+				}
+				wechatArticleAbstractIdList = append(wechatArticleAbstractIdList, v.WechatArticleAbstractId)
+			}
+		}
+	}
+
+	for _, wechatArticleAbstractId := range wechatArticleAbstractIdList {
+		cache.AddWechatArticleLlmOpToCache(wechatArticleAbstractId, ``)
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `添加向量库中,请稍后查看`
+}

+ 186 - 0
controllers/llm/chat_ws_controller.go

@@ -0,0 +1,186 @@
+package llm
+
+import (
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/models/system"
+	"eta/eta_api/services/llm/facade"
+	"eta/eta_api/utils"
+	"eta/eta_api/utils/ws"
+	"fmt"
+	"github.com/gorilla/websocket"
+	"net"
+	"net/http"
+	"strings"
+	"time"
+)
+
+type ChatWsController struct {
+	controllers.BaseAuthController
+}
+
+func (cc *ChatWsController) Prepare() {
+	method := cc.Ctx.Input.Method()
+	uri := cc.Ctx.Input.URI()
+	if method == "GET" {
+		authorization := cc.Ctx.Input.Header("authorization")
+		if authorization == "" {
+			authorization = cc.Ctx.Input.Header("Authorization")
+		}
+		if strings.Contains(authorization, ";") {
+			authorization = strings.Replace(authorization, ";", "$", 1)
+		}
+		if authorization == "" {
+			strArr := strings.Split(uri, "?")
+			for k, v := range strArr {
+				fmt.Println(k, v)
+			}
+			if len(strArr) > 1 {
+				authorization = strArr[1]
+				authorization = strings.Replace(authorization, "Authorization", "authorization", -1)
+			}
+		}
+		if authorization == "" {
+			utils.FileLog.Error("authorization为空,未授权")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusUnauthorized)
+			return
+		}
+		tokenStr := authorization
+		tokenArr := strings.Split(tokenStr, "=")
+		token := tokenArr[1]
+
+		session, err := system.GetSysSessionByToken(token)
+		if err != nil {
+			if utils.IsErrNoRow(err) {
+				utils.FileLog.Error("authorization已过期")
+				cc.Ctx.ResponseWriter.WriteHeader(http.StatusUnauthorized)
+				return
+			}
+			utils.FileLog.Error("authorization查询用户信息失败")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusBadRequest)
+			return
+		}
+		if session == nil {
+			utils.FileLog.Error("会话不存在")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusBadRequest)
+			return
+		}
+		//校验token是否合法
+		// JWT校验Token和Account
+		account := utils.MD5(session.UserName)
+		if !utils.CheckToken(account, token) {
+			utils.FileLog.Error("authorization校验不合法")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusUnauthorized)
+			return
+		}
+		if time.Now().After(session.ExpiredTime) {
+			utils.FileLog.Error("authorization过期法")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusUnauthorized)
+			return
+		}
+		admin, err := system.GetSysUserById(session.SysUserId)
+		if err != nil {
+			if utils.IsErrNoRow(err) {
+				utils.FileLog.Error("权限不够")
+				cc.Ctx.ResponseWriter.WriteHeader(http.StatusForbidden)
+				return
+			}
+			utils.FileLog.Error("获取用户信息失败")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusBadRequest)
+			return
+		}
+		if admin == nil {
+			utils.FileLog.Error("权限不够")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusForbidden)
+			return
+		}
+		//如果不是启用状态
+		if admin.Enabled != 1 {
+			utils.FileLog.Error("用户被禁用")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusForbidden)
+			return
+		}
+
+		//接口权限校验
+		roleId := admin.RoleId
+		list, e := system.GetMenuButtonApisByRoleId(roleId)
+		if e != nil {
+			utils.FileLog.Error("接口权限查询出错", e)
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusForbidden)
+			return
+		}
+		var api string
+		for _, v := range list {
+			if v.Api != "" {
+				api += v.Api + "&"
+			}
+		}
+		api += "&" + models.BusinessConfMap["PublicApi"]
+		//处理uri请求,去除前缀和参数
+		api = strings.TrimRight(api, "&")
+		uri = strings.Replace(uri, "/adminapi", "", 1)
+		uris := strings.Split(uri, "?")
+		uri = uris[0]
+		//fmt.Println("uri:", uri)
+		apis := strings.Split(api, "&")
+		apiMap := make(map[string]bool, 0)
+		for _, s := range apis {
+			apiMap[s] = true
+		}
+		if !apiMap[uri] {
+			utils.FileLog.Error("用户无权访问")
+			cc.Ctx.ResponseWriter.WriteHeader(http.StatusForbidden)
+			return
+		}
+		cc.SysUser = admin
+	} else {
+		utils.FileLog.Error("请求方法类型错误")
+		cc.Ctx.ResponseWriter.WriteHeader(http.StatusBadRequest)
+		return
+	}
+}
+
+// ChatConnect @Title 知识库问答创建对话连接
+// @Description 知识库问答创建对话连接
+// @Success 101 {object} response.ListResp
+// @router /chat/connect [get]
+func (cc *ChatWsController) ChatConnect() {
+	if !ws.Allow(cc.SysUser.AdminId, ws.CONNECT_LIMITER) {
+		utils.FileLog.Error("WebSocket连接太频繁,主动拒绝链接")
+		cc.Ctx.ResponseWriter.WriteHeader(http.StatusTooManyRequests)
+		return
+	}
+	wsCon, err := webSocketHandler(cc.Ctx.ResponseWriter, cc.Ctx.Request)
+	if err != nil {
+		utils.FileLog.Error("WebSocket连接失败:", err)
+		cc.Ctx.ResponseWriter.WriteHeader(http.StatusBadRequest)
+		return
+	}
+	facade.AddSession(cc.SysUser.AdminId, wsCon)
+}
+
+// upGrader 用于将HTTP连接升级为WebSocket连接
+var upGrader = websocket.Upgrader{
+	ReadBufferSize:  1024,
+	WriteBufferSize: 1024,
+	CheckOrigin: func(r *http.Request) bool {
+		return true
+	},
+}
+
+// WebSocketHandler 处理WebSocket连接
+func webSocketHandler(w http.ResponseWriter, r *http.Request) (conn *websocket.Conn, err error) {
+	conn, err = upGrader.Upgrade(w, r, nil)
+	if err != nil {
+		utils.FileLog.Error("升级协议失败:WebSocket:%s", err.Error())
+		return
+	}
+	// 获取底层 TCP 连接并设置保活
+	if tcpConn, ok := conn.NetConn().(*net.TCPConn); ok {
+		_ = tcpConn.SetKeepAlive(true)
+		_ = tcpConn.SetKeepAlivePeriod(ws.TcpTimeout)
+		utils.FileLog.Info("TCP KeepAlive 已启用")
+	}
+	_ = conn.SetReadDeadline(time.Now().Add(ws.ReadTimeout))
+	return
+}

+ 51 - 0
controllers/llm/kb_controller.go

@@ -0,0 +1,51 @@
+package llm
+
+import (
+	"encoding/json"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/services/llm/facade"
+)
+
+type KbController struct {
+	controllers.BaseAuthController
+}
+
+// SearchDocs  @Title 搜索知识库文档
+// @Description 搜索知识库文档
+// @Success 101 {object} response.ListResp
+// @router /knowledge_base/searchDocs [post]
+func (kbctrl *KbController) SearchDocs() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		if br.ErrMsg == "" {
+			br.IsSendEmail = false
+		}
+		kbctrl.Data["json"] = br
+		kbctrl.ServeJSON()
+	}()
+	sysUser := kbctrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req facade.LLMKnowledgeSearch
+	err := json.Unmarshal(kbctrl.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	searchResp, err := facade.LLMKnowledgeBaseSearchDocs(req)
+	if err != nil {
+		br.Msg = "搜索知识库失败"
+		br.ErrMsg = "搜索知识库失败:" + err.Error()
+		return
+	}
+	br.Data = searchResp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+}

+ 20 - 0
controllers/llm/llm_http/request.go

@@ -0,0 +1,20 @@
+package llm_http
+
+type LLMQuestionReq struct {
+	Question      string `description:"提问"`
+	KnowledgeBase string `description:"知识库"`
+	SessionId     string `description:"会话ID"`
+}
+
+type UserChatReq struct {
+	ChatId    int    `json:"ChatId"`
+	ChatTitle string `json:"ChatTitle" description:"会话名称"`
+}
+
+type UserChatRecordReq struct {
+	Id           int    `json:"Id"`
+	ChatId       int    `json:"ChatId"`
+	Content      string `json:"Content" description:"会话名称"`
+	ChatUserType string `json:"ChatUserType" description:"用户类型"`
+	SendTime     string `json:"SendTime" description:"发送时间"`
+}

+ 17 - 0
controllers/llm/llm_http/response.go

@@ -0,0 +1,17 @@
+package llm_http
+
+import "eta/eta_api/models/llm"
+
+type UserChatListResp struct {
+	TodayList     []llm.UserLlmChatListViewItem
+	YesterdayList []llm.UserLlmChatListViewItem
+	WeekList      []llm.UserLlmChatListViewItem
+}
+type UserChatResp struct {
+	ChatId    int
+	ChatTitle string
+	SendTime  string
+}
+type UserChatAddResp struct {
+	SendTime string
+}

+ 233 - 0
controllers/llm/question.go

@@ -0,0 +1,233 @@
+package llm
+
+import (
+	"encoding/json"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/models/rag"
+	"eta/eta_api/models/rag/request"
+	"eta/eta_api/models/rag/response"
+	"eta/eta_api/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"strings"
+	"time"
+)
+
+// QuestionController
+// @Description: 问题库管理
+type QuestionController struct {
+	controllers.BaseAuthController
+}
+
+// List
+// @Title 列表
+// @Description 列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} []*rag.QuestionListListResp
+// @router /question/list [get]
+func (c *QuestionController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	keyWord := c.GetString("KeyWord")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyWord != "" {
+		condition += fmt.Sprintf(` AND %s like ?`, rag.QuestionColumns.QuestionContent)
+		pars = append(pars, `%`+keyWord+`%`)
+	}
+
+	obj := new(rag.Question)
+	total, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	viewList := obj.ListToViewList(list)
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := response.QuestionListListResp{
+		List:   viewList,
+		Paging: page,
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// Add
+// @Title 新增问题
+// @Description 新增问题
+// @Param	request	body request.AddQuestionReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /question/add [post]
+func (c *QuestionController) Add() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.AddQuestionReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	req.Content = strings.TrimSpace(req.Content)
+	if req.Content == "" {
+		br.Msg = "请输入问题"
+		br.IsSendEmail = false
+		return
+	}
+	item := &rag.Question{
+		QuestionId:      0,
+		QuestionContent: req.Content,
+		Sort:            0,
+		ModifyTime:      time.Now(),
+		CreateTime:      time.Now(),
+	}
+	err = item.Create()
+	if err != nil {
+		br.Msg = "添加失败"
+		br.ErrMsg = "添加失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `添加成功`
+}
+
+// Edit
+// @Title 编辑问题
+// @Description 编辑问题
+// @Param	request	body request.EditQuestionReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /question/edit [post]
+func (c *QuestionController) Edit() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.EditQuestionReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.QuestionId <= 0 {
+		br.Msg = "问题id不能为空"
+		br.IsSendEmail = false
+		return
+	}
+	req.Content = strings.TrimSpace(req.Content)
+	if req.Content == "" {
+		br.Msg = "请输入问题"
+		br.IsSendEmail = false
+		return
+	}
+
+	obj := rag.Question{}
+	item, err := obj.GetByID(req.QuestionId)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "问题不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+	item.QuestionContent = req.Content
+	item.ModifyTime = time.Now()
+	err = item.Update([]string{"question_content", "modify_time"})
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `添加成功`
+}
+
+// Del
+// @Title 删除问题
+// @Description 删除问题
+// @Param	request	body request.EditQuestionReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /question/del [post]
+func (c *QuestionController) Del() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.EditQuestionReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.QuestionId <= 0 {
+		br.Msg = "问题id不能为空"
+		br.IsSendEmail = false
+		return
+	}
+
+	obj := rag.Question{}
+	item, err := obj.GetByID(req.QuestionId)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,查找问题失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "问题不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+	err = item.Del()
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `删除成功`
+}

+ 332 - 0
controllers/llm/user_chat_controller.go

@@ -0,0 +1,332 @@
+package llm
+
+import (
+	"encoding/json"
+	"eta/eta_api/controllers"
+	"eta/eta_api/controllers/llm/llm_http"
+	"eta/eta_api/models"
+	"eta/eta_api/models/llm"
+	llmService "eta/eta_api/services/llm"
+	"eta/eta_api/utils"
+	"time"
+)
+
+type UserChatController struct {
+	controllers.BaseAuthController
+}
+
+// NewChat @Title 新建对话框
+// @Description 新建对话框
+// @Success 101 {object} response.ListResp
+// @router /chat/new_chat [post]
+func (ucCtrl *UserChatController) NewChat() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		ucCtrl.Data["json"] = br
+		ucCtrl.ServeJSON()
+	}()
+	var req llm_http.UserChatReq
+	err := json.Unmarshal(ucCtrl.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	sysUser := ucCtrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	if req.ChatTitle == "" {
+		req.ChatTitle = "新会话"
+	}
+	session := llm.UserLlmChat{
+		UserId:      sysUser.AdminId,
+		CreatedTime: time.Now(),
+		ChatTitle:   req.ChatTitle,
+	}
+	var chatResp = new(llm_http.UserChatResp)
+	chatResp.ChatTitle = req.ChatTitle
+	chatResp.ChatId, err = session.CreateChatSession()
+	chatResp.SendTime = time.Now().Format(utils.FormatDateTime)
+	if err != nil {
+		br.Msg = "创建失败"
+		br.ErrMsg = "创建失败,Err:" + err.Error()
+		return
+	}
+	_ = llmService.AddChatRecord(&llm.UserChatRecordRedis{
+		ChatId:       session.Id,
+		ChatUserType: "user",
+		Content:      req.ChatTitle,
+		SendTime:     chatResp.SendTime,
+	})
+	br.Data = chatResp
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "创建成功"
+}
+
+// RenameChat @Title 新建对话框
+// @Description 新建对话框
+// @Success 101 {object} response.ListResp
+// @router /chat/rename_chat [post]
+func (ucCtrl *UserChatController) RenameChat() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		ucCtrl.Data["json"] = br
+		ucCtrl.ServeJSON()
+	}()
+	var req llm_http.UserChatReq
+	err := json.Unmarshal(ucCtrl.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	sysUser := ucCtrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	if req.ChatId <= 0 {
+		br.Msg = "非法的对话框Id"
+		br.ErrMsg = "非法的对话框Id"
+		return
+	}
+	if req.ChatTitle == "" {
+		br.Msg = "重命名不能为空"
+		br.ErrMsg = "重命名不能为空"
+		return
+	}
+	session := llm.UserLlmChat{
+		Id:         req.ChatId,
+		UpdateTime: time.Now(),
+		UserId:     sysUser.AdminId,
+		ChatTitle:  req.ChatTitle,
+	}
+	err = session.RenameChatSession()
+	if err != nil {
+		br.Msg = "重命名失败"
+		br.ErrMsg = "重命名失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "重命名成功"
+}
+
+// DeleteChat @Title 删除对话框
+// @Description 删除对话框
+// @Success 101 {object} response.ListResp
+// @router /chat/delete_chat [post]
+func (ucCtrl *UserChatController) DeleteChat() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		ucCtrl.Data["json"] = br
+		ucCtrl.ServeJSON()
+	}()
+	var req llm_http.UserChatReq
+	err := json.Unmarshal(ucCtrl.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	sysUser := ucCtrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	if req.ChatId <= 0 {
+		br.Msg = "非法的对话框Id"
+		br.ErrMsg = "非法的对话框Id"
+		return
+	}
+
+	session := llm.UserLlmChat{
+		Id:         req.ChatId,
+		UpdateTime: time.Now(),
+		IsDeleted:  1,
+	}
+	err = session.DeleteChatSession()
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "删除成功"
+}
+
+// GetUserChatList @Title 获取用户对话框列表
+// @Description  获取用户对话框列表
+// @Success 101 {object} response.ListResp
+// @router /chat/user_chat_list [get]
+func (ucCtrl *UserChatController) GetUserChatList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		ucCtrl.Data["json"] = br
+		ucCtrl.ServeJSON()
+	}()
+	sysUser := ucCtrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	//周日是0,周六是6
+	weekDay := time.Now().Weekday()
+	offset := int(time.Monday - weekDay)
+	if offset > 0 {
+		offset -= 7
+	}
+	today := time.Now().Format(utils.FormatDate)
+	monDay := time.Now().AddDate(0, 0, offset).Format(utils.FormatDate)
+	yesterday := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
+	chatList, err := llm.GetUserChatList(sysUser.AdminId, monDay, time.Now().Format(utils.FormatDate))
+	if err != nil {
+		br.Msg = "获取用户聊天列表失败"
+		br.ErrMsg = "获取用户聊天列表失败,Err:" + err.Error()
+		return
+	}
+	data := new(llm_http.UserChatListResp)
+	data.WeekList = make([]llm.UserLlmChatListViewItem, 0)
+	data.YesterdayList = make([]llm.UserLlmChatListViewItem, 0)
+	data.TodayList = make([]llm.UserLlmChatListViewItem, 0)
+	for _, v := range chatList {
+		list, _ := llmService.GetChatRecordsFromRedis(v.Id)
+		item := llm.CovertItemToView(v)
+		item.RecordCount = len(list)
+		if v.CreatedTime.Format(utils.FormatDate) == today {
+			data.TodayList = append(data.TodayList, item)
+		} else if v.CreatedTime.Format(utils.FormatDate) == yesterday {
+			data.YesterdayList = append(data.YesterdayList, item)
+		} else {
+			data.WeekList = append(data.WeekList, item)
+		}
+	}
+
+	br.Data = data
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取用户聊天列表成功"
+}
+
+// ChatRecordAdd @Title 保存聊天记录
+// @Description 保存聊天记录
+// @Success 101 {object} response.ListResp
+// @router /chat/chat_record_save [post]
+func (ucCtrl *UserChatController) ChatRecordAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		ucCtrl.Data["json"] = br
+		ucCtrl.ServeJSON()
+	}()
+	var req llm_http.UserChatRecordReq
+	err := json.Unmarshal(ucCtrl.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	sysUser := ucCtrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	if req.ChatId <= 0 {
+		br.Msg = "非法的对话框Id"
+		br.ErrMsg = "非法的对话框Id"
+		return
+	}
+	if req.Content == "" {
+		br.Msg = "聊天记录不能为空"
+		br.ErrMsg = "聊天记录不能为空"
+		return
+	}
+	if req.Id < 0 {
+		br.Msg = "非法的Id"
+		br.ErrMsg = "非法的Id"
+		return
+	}
+	if req.ChatUserType != "user" && req.ChatUserType != "assistant" {
+		br.Msg = "非法的用户类型"
+		br.ErrMsg = "非法的用户类型,用户类型支持:user/assistant"
+		return
+	}
+	if req.SendTime == "" {
+		req.SendTime = time.Now().Format(utils.FormatDateTime)
+	} else {
+		_, err = time.Parse(utils.FormatDateTime, req.SendTime)
+		if err != nil {
+			br.Msg = "非法的发送时间"
+			br.ErrMsg = "非法的发送时间,Err:" + err.Error()
+			return
+		}
+	}
+	record := llm.UserChatRecordRedis{
+		ChatId:       req.ChatId,
+		ChatUserType: req.ChatUserType,
+		Content:      req.Content,
+		SendTime:     req.SendTime,
+	}
+	err = llmService.AddChatRecord(&record)
+	if err != nil {
+		br.Msg = "添加聊天记录失败"
+		br.ErrMsg = "添加聊天记录失败,Err:" + err.Error()
+		return
+	}
+
+	br.Data = llm_http.UserChatAddResp{
+		SendTime: record.SendTime,
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "添加聊天记录成功"
+}
+
+// ChatRecordList @Title 获取聊天记录
+// @Description 获取聊天记录
+// @Success 101 {object} response.ListResp
+// @router /chat/chat_record_list [get]
+func (ucCtrl *UserChatController) ChatRecordList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		ucCtrl.Data["json"] = br
+		ucCtrl.ServeJSON()
+	}()
+	sysUser := ucCtrl.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	chatId, _ := ucCtrl.GetInt("ChatId", 0)
+	if chatId <= 0 {
+		br.Msg = "非法的对话Id"
+		br.ErrMsg = "非法的对话Id"
+		return
+	}
+
+	list, err := llmService.GetChatRecordsFromRedis(chatId)
+	if err != nil {
+		br.Msg = "获取聊天记录失败"
+		br.ErrMsg = "获取聊天记录失败,Err:" + err.Error()
+		return
+	}
+	br.Data = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取聊天记录成功"
+}

+ 777 - 0
controllers/llm/wechat_platform.go

@@ -0,0 +1,777 @@
+package llm
+
+import (
+	"encoding/json"
+	"eta/eta_api/cache"
+	"eta/eta_api/controllers"
+	"eta/eta_api/models"
+	"eta/eta_api/models/rag"
+	"eta/eta_api/models/rag/request"
+	"eta/eta_api/models/rag/response"
+	"eta/eta_api/models/system"
+	"eta/eta_api/services"
+	"eta/eta_api/services/elastic"
+	"eta/eta_api/utils"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"html"
+	"strings"
+	"time"
+)
+
+// WechatPlatformController
+// @Description: 微信公众号管理
+type WechatPlatformController struct {
+	controllers.BaseAuthController
+}
+
+// TagList
+// @Title 获取ppt列表
+// @Description 获取ppt列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} models.TagListResp
+// @router /tag/list [get]
+func (c *WechatPlatformController) TagList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	keyWord := c.GetString("KeyWord")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyWord != "" {
+		condition += fmt.Sprintf(` AND %s like ?`, rag.WechatPlatformColumns.Nickname)
+		pars = append(pars, `%`+keyWord+`%`)
+	}
+
+	obj := new(rag.Tag)
+	total, list, err := obj.GetPageListByCondition(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(response.TagListResp)
+	resp.Paging = page
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// Add
+// @Title 新增公众号
+// @Description 新增公众号
+// @Param	request	body request.AddWechatPlatformReq true "type json string"
+// @Success 200 Ret=200 新增成功
+// @router /wechat_platform/add [post]
+func (c *WechatPlatformController) Add() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+	var req request.AddWechatPlatformReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	req.Name = strings.TrimSpace(req.Name)
+	if req.Name == "" {
+		br.Msg = "请输入公众号名称"
+		br.IsSendEmail = false
+		return
+	}
+	req.Link = strings.TrimSpace(req.Link)
+	if req.Link == "" {
+		br.Msg = "请输入文章链接"
+		br.IsSendEmail = false
+		return
+	}
+
+	// 名称校验
+	{
+		var condition string
+		var pars []interface{}
+		condition += fmt.Sprintf(` AND %s = ?`, rag.WechatPlatformColumns.Nickname)
+		pars = append(pars, req.Name)
+		obj := new(rag.WechatPlatform)
+		item, err := obj.GetByCondition(condition, pars)
+		if err != nil && !utils.IsErrNoRow(err) {
+			br.Msg = "公众号信息获取失败"
+			br.ErrMsg = "公众号信息获取失败,Err:" + err.Error()
+			return
+		}
+
+		if item.WechatPlatformId > 0 {
+			br.Msg = "公众号名称重复"
+			br.IsSendEmail = false
+			return
+		}
+	}
+
+	// 链接校验
+	{
+		var condition string
+		var pars []interface{}
+		condition += fmt.Sprintf(` AND %s = ?`, rag.WechatPlatformColumns.ArticleLink)
+		pars = append(pars, req.Link)
+		obj := new(rag.WechatPlatform)
+		item, err := obj.GetByCondition(condition, pars)
+		if err != nil && !utils.IsErrNoRow(err) {
+			br.Msg = "公众号信息获取失败"
+			br.ErrMsg = "公众号信息获取失败,Err:" + err.Error()
+			return
+		}
+
+		if item.WechatPlatformId > 0 {
+			br.Msg = "公众号链接重复"
+			br.IsSendEmail = false
+			return
+		}
+	}
+
+	item := &rag.WechatPlatform{
+		WechatPlatformId: 0,
+		FakeId:           "",
+		Nickname:         req.Name,
+		Alias:            "",
+		RoundHeadImg:     "",
+		ServiceType:      0,
+		Signature:        "",
+		Verified:         0,
+		ArticleLink:      req.Link,
+		Enabled:          0,
+		SysUserId:        c.SysUser.AdminId,
+		ModifyTime:       time.Now(),
+		CreateTime:       time.Now(),
+	}
+	err = item.Add(req.TagIdList)
+	if err != nil {
+		br.Msg = "添加失败"
+		br.ErrMsg = "添加失败,Err:" + err.Error()
+		return
+	}
+
+	// 异步新增公众号
+	go cache.AddWechatArticleOpToCache(item.WechatPlatformId, `add`)
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = `添加成功`
+}
+
+// FollowList
+// @Title 我关注的接口
+// @Description 我关注的接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} []*rag.WechatPlatform
+// @router /wechat_platform/list/follow [get]
+func (c *WechatPlatformController) FollowList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	keyWord := c.GetString("KeyWord")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyWord != "" {
+		condition += fmt.Sprintf(` AND %s like ?`, rag.WechatPlatformColumns.Nickname)
+		pars = append(pars, `%`+keyWord+`%`)
+	}
+
+	condition += fmt.Sprintf(` AND b.%s = ?`, rag.WechatPlatformUserMappingColumns.SysUserID)
+	pars = append(pars, c.SysUser.AdminId)
+
+	obj := new(rag.WechatPlatformUserMapping)
+	list, err := obj.GetListByCondition(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = list
+}
+
+// PublicList
+// @Title 公共列表
+// @Description 公共列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} models.WechatPlatformListResp
+// @router /wechat_platform/list/public [get]
+func (c *WechatPlatformController) PublicList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	keyWord := c.GetString("KeyWord")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if keyWord != "" {
+		condition += fmt.Sprintf(` AND %s like ?`, rag.WechatPlatformColumns.Nickname)
+		pars = append(pars, `%`+keyWord+`%`)
+	}
+
+	obj := new(rag.WechatPlatformUserMapping)
+	list, err := obj.GetListByCondition(condition, pars, startSize, 100000)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	resp := make([]response.WechatPlatformPublicListResp, 0)
+
+	if list != nil && len(list) > 0 {
+		userIdList := make([]int, 0)
+		uerIdMap := make(map[int]bool)
+		userFollowIndexMap := make(map[int]int)
+		for _, v := range list {
+			if _, ok := uerIdMap[v.FollowUserId]; !ok {
+				userIdList = append(userIdList, v.FollowUserId)
+				uerIdMap[v.FollowUserId] = true
+			}
+
+			index, ok := userFollowIndexMap[v.FollowUserId]
+			if !ok {
+				userFollowIndexMap[v.FollowUserId] = len(resp)
+
+				resp = append(resp, response.WechatPlatformPublicListResp{
+					UserId: v.FollowUserId,
+					List:   []*rag.UserFollowWechatPlatform{v},
+				})
+			} else {
+				resp[index].List = append(resp[index].List, v)
+			}
+		}
+
+		userList, err := system.GetAdminListByIdList(userIdList)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		userNameMap := make(map[int]*system.Admin)
+		for _, v := range userList {
+			userNameMap[v.AdminId] = v
+		}
+
+		for k, v := range resp {
+			userInfo, ok := userNameMap[v.UserId]
+			if !ok {
+				continue
+			}
+			resp[k].Name = userInfo.RealName + `关注`
+		}
+
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// PublicList
+// @Title 公共列表
+// @Description 公共列表
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} models.WechatPlatformListResp
+// @router /wechat_platform/op [post]
+func (c *WechatPlatformController) Op() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+
+	var req request.OpWechatPlatformReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.WechatPlatformId <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+
+	if req.Status < 0 || req.Status > 1 {
+		br.Msg = "参数错误"
+		return
+	}
+	obj := rag.WechatPlatform{}
+	wechatPlatform, err := obj.GetById(req.WechatPlatformId)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "公众号不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+	wechatPlatform.Enabled = req.Status
+	wechatPlatform.ModifyTime = time.Now()
+	err = wechatPlatform.Update([]string{"enabled", `modify_time`})
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,Err:" + err.Error()
+		return
+	}
+
+	// 异步处理公众号下面的文章
+	go services.AddOrEditEsWechatPlatformId(wechatPlatform.WechatPlatformId)
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "修改成功"
+}
+
+// Refresh
+// @Title 公共列表
+// @Description 公共列表
+// @Success 200 {object} models.WechatPlatformListResp
+// @router /wechat_platform/refresh [post]
+func (c *WechatPlatformController) Refresh() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+
+	var req request.RefreshWechatPlatformReq
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.WechatPlatformId <= 0 {
+		br.Msg = "参数错误"
+		return
+	}
+
+	obj := rag.WechatPlatform{}
+	wechatPlatform, err := obj.GetById(req.WechatPlatformId)
+	if err != nil {
+		br.Msg = "修改失败"
+		br.ErrMsg = "修改失败,Err:" + err.Error()
+		if utils.IsErrNoRow(err) {
+			br.Msg = "公众号不存在"
+			br.IsSendEmail = false
+		}
+		return
+	}
+	if wechatPlatform.FakeId != `` {
+		br.Msg = "公众号已添加成功"
+		br.ErrMsg = "公众号已添加成功"
+		br.IsSendEmail = false
+		return
+	}
+
+	go cache.AddWechatArticleOpToCache(wechatPlatform.WechatPlatformId, `add`)
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "刷新成功"
+}
+
+// ArticleList
+// @Title 我关注的接口
+// @Description 我关注的接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   WechatPlatformId   query   int  true       "微信公众号id"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Success 200 {object} []*rag.WechatPlatform
+// @router /wechat_platform/article/list [get]
+func (c *WechatPlatformController) ArticleList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	pageSize, _ := c.GetInt("PageSize")
+	currentIndex, _ := c.GetInt("CurrentIndex")
+	wechatPlatformId, _ := c.GetInt("WechatPlatformId")
+	keyWord := c.GetString("KeyWord")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+
+	//var condition string
+	//var pars []interface{}
+	//
+	//if keyWord != "" {
+	//	condition += fmt.Sprintf(` AND (b.%s like ? or a.%s like ? ) `, rag.WechatPlatformColumns.Nickname, rag.WechatArticleColumns.Title)
+	//	pars = append(pars, `%`+keyWord+`%`, `%`+keyWord+`%`)
+	//}
+	//
+	//if wechatPlatformId > 0 {
+	//	condition += fmt.Sprintf(` AND a.%s = ?`, rag.WechatArticleColumns.WechatPlatformID)
+	//	pars = append(pars, wechatPlatformId)
+	//}
+	//
+	//condition += fmt.Sprintf(` AND b.%s = ? `, rag.WechatPlatformColumns.Enabled)
+	//pars = append(pars, 1)
+
+	var total int
+	viewList := make([]rag.WechatArticleView, 0)
+
+	if keyWord == `` {
+		var condition string
+		var pars []interface{}
+
+		if keyWord != "" {
+			condition += fmt.Sprintf(` AND (b.%s like ? or a.%s like ? ) `, rag.WechatPlatformColumns.Nickname, rag.WechatArticleColumns.Title)
+			pars = append(pars, `%`+keyWord+`%`, `%`+keyWord+`%`)
+		}
+
+		if wechatPlatformId > 0 {
+			condition += fmt.Sprintf(` AND a.%s = ?`, rag.WechatArticleColumns.WechatPlatformID)
+			pars = append(pars, wechatPlatformId)
+		}
+
+		//condition += fmt.Sprintf(` AND b.%s = ? `, rag.WechatPlatformColumns.Enabled)
+		//pars = append(pars, 1)
+
+		obj := new(rag.WechatArticle)
+		tmpTotal, list, err := obj.GetPageListByPlatformCondition(condition, pars, startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		total = tmpTotal
+
+		if list != nil && len(list) > 0 {
+			viewList = obj.ArticleAndPlatformListToViewList(list)
+		}
+	} else {
+		sortMap := map[string]string{
+			//"ArticleCreateTime": "desc",
+			//"WechatArticleId":   "desc",
+		}
+		tmpTotal, list, err := elastic.WechatArticleEsSearch(keyWord, wechatPlatformId, startSize, pageSize, sortMap)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		total = int(tmpTotal)
+		if list != nil && len(list) > 0 {
+			viewList = list[0].ArticleAndPlatformListToViewList(list)
+		}
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := response.WechatArticleListListResp{
+		List:   viewList,
+		Paging: page,
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// ArticleList
+// @Title 我关注的接口
+// @Description 我关注的接口
+// @Param   WechatArticleId   query   int  true       "文章id"
+// @Success 200 {object} []*rag.WechatArticle
+// @router /wechat_platform/article/detail [get]
+func (c *WechatPlatformController) ArticleDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	wechatArticleId, _ := c.GetInt("WechatArticleId")
+	if wechatArticleId <= 0 {
+		br.Msg = "请选择文章"
+		br.IsSendEmail = false
+		return
+	}
+	obj := new(rag.WechatArticle)
+	item, err := obj.GetById(wechatArticleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	if item.IsDeleted == 1 {
+		br.Msg = "文章已删除"
+		br.IsSendEmail = false
+		return
+	}
+	resp := item.ToView()
+	resp.Content = html.UnescapeString(item.Content)
+
+	// 获取摘要信息
+	{
+		abstractObj := rag.WechatArticleAbstract{}
+		abstractItem, err := abstractObj.GetByWechatArticleId(wechatArticleId)
+		if err != nil && !utils.IsErrNoRow(err) {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		resp.Abstract = abstractItem.Content
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// ArticleList
+// @Title 我关注的接口
+// @Description 我关注的接口
+// @Param   WechatArticleId   query   int  true       "文章id"
+// @Success 200 {object} []*rag.WechatPlatform
+// @router /wechat_platform/article/del [get]
+func (c *WechatPlatformController) ArticleDel() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		c.Data["json"] = br
+		c.ServeJSON()
+	}()
+
+	sysUser := c.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	wechatArticleId, _ := c.GetInt("WechatArticleId")
+	if wechatArticleId <= 0 {
+		br.Msg = "请选择文章"
+		br.IsSendEmail = false
+		return
+	}
+	obj := new(rag.WechatArticle)
+	item, err := obj.GetById(wechatArticleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	if item.IsDeleted == 1 {
+		br.Msg = "文章已删除"
+		br.IsSendEmail = false
+		return
+	}
+	item.IsDeleted = 1
+	err = item.Update([]string{"is_deleted"})
+	if err != nil {
+		br.Msg = "删除失败"
+		br.ErrMsg = "删除失败,Err:" + err.Error()
+		return
+	}
+
+	// 修改ES信息
+	services.AddOrEditEsWechatArticle(item.WechatArticleId)
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "删除成功"
+}
+
+//func init() {
+//	//obj := rag.WechatPlatform{}
+//	//item, _ := obj.GetByID(2)
+//	//fmt.Println(llm.BeachAddWechatPlatform(item))
+//
+//	obj := rag.WechatArticle{}
+//	//item, _ := obj.GetById(30)
+//	list, _ := obj.GetListByCondition(``, ` `, []interface{}{}, 0, 1000)
+//	//llm.ArticleToTmpFile(item.TextContent)
+//	for _, item := range list {
+//		//llm.ArticleToKnowledge(item)
+//		llm.GenerateArticleAbstract(item)
+//	}
+//}
+
+//func init() {
+//	//obj := rag.WechatPlatform{}
+//	//item, _ := obj.GetByID(2)
+//	//fmt.Println(llm.BeachAddWechatPlatform(item))
+//
+//	//obj := rag.WechatArticle{}
+//	//list, _ := obj.GetListByCondition(`wechat_article_id,content`, `  `, []interface{}{}, 0, 1)
+//	////obj := rag.WechatPlatform{}
+//	////list, _ := obj.GetListByCondition(` AND wechat_platform_id !=1 `, []interface{}{}, 0, 100)
+//	////llm.ArticleToTmpFile(item.TextContent)
+//	//for _, item := range list {
+//	//	//llm.ArticleToKnowledge(item)
+//	//	services.ReGenerateArticleAbstract(item)
+//	//}
+//
+//	// 重新生成摘要
+//	{
+//		obj := rag.WechatArticle{}
+//		list, _ := obj.GetListByCondition(``, ` AND text_content !='' AND abstract_status = 0`, []interface{}{}, 0, 300)
+//		for _, item := range list {
+//			services.GenerateArticleAbstract(item)
+//		}
+//	}
+//
+//	//// 删除摘要向量库
+//	//{
+//	//	obj := rag.WechatArticleAbstract{}
+//	//	list, _ := obj.GetListByCondition(`vector_key,wechat_article_abstract_id`, ` AND wechat_article_id in (25,27) `, []interface{}{}, 0, 10000)
+//	//	fmt.Println(services.DelDoc(list))
+//	//}
+//
+//	fmt.Println("修复结束")
+//}
+
+//func init() {
+//	//// 微信文章加到es
+//	//{
+//	//	obj := rag.WechatArticle{}
+//	//	list, _ := obj.GetListByCondition(` wechat_article_id `, ` `, []interface{}{}, 0, 10000)
+//	//	total := len(list)
+//	//	for k, item := range list {
+//	//		fmt.Println(k, "/", total)
+//	//		services.AddOrEditEsWechatArticle(item.WechatArticleId)
+//	//	}
+//	//
+//	//	fmt.Println("结束了")
+//	//}
+//
+//	//// 微信文章加到es
+//	{
+//		obj := rag.WechatArticleAbstract{}
+//		list, _ := obj.GetListByCondition(` wechat_article_abstract_id `, ` `, []interface{}{}, 0, 10000)
+//		total := len(list)
+//		for k, item := range list {
+//			fmt.Println(k, "/", total)
+//			services.AddOrEditEsWechatArticleAbstract(item.WechatArticleAbstractId)
+//		}
+//
+//		fmt.Println("结束了")
+//	}
+//
+//}

+ 16 - 16
controllers/material/material.go

@@ -158,7 +158,7 @@ func (this *MaterialController) EditMaterialClassify() {
 	// 只允许修改分类名称
 	item, err := material.GetMaterialClassifyById(req.ClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}
@@ -404,7 +404,7 @@ func (this *MaterialController) DeleteMaterialClassify() {
 	/*if req.MaterialId > 0 {
 		materialInfo, err := material.GetMaterialById(req.MaterialId)
 		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
+			if utils.IsErrNoRow(err) {
 				br.Msg = "素材库已删除,请刷新页面"
 				br.ErrMsg = "指标不存在,Err:" + err.Error()
 				return
@@ -466,7 +466,7 @@ func (this *MaterialController) ClassifyMove() {
 	//判断分类是否存在
 	materialClassifyInfo, err := material.GetMaterialClassifyById(req.ClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在,请刷新页面"
 			br.ErrMsg = "分类不存在,Err:" + err.Error()
 			return
@@ -818,7 +818,7 @@ func (this *MaterialController) List() {
 
 	//获取图表信息
 	list, err := material.GetMaterialListPageByCondition(condition, pars, startSize, pageSize)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Success = true
 		br.Msg = "获取素材库信息失败"
 		br.ErrMsg = "获取素材库信息失败,Err:" + err.Error()
@@ -826,7 +826,7 @@ func (this *MaterialController) List() {
 	}
 
 	resp := new(material.MaterialListResp)
-	if list == nil || len(list) <= 0 || (err != nil && err.Error() == utils.ErrNoRow()) {
+	if list == nil || len(list) <= 0 || (err != nil && utils.IsErrNoRow(err)) {
 		items := make([]*material.MaterialListItems, 0)
 		resp.Paging = page
 		resp.List = items
@@ -838,7 +838,7 @@ func (this *MaterialController) List() {
 	}
 
 	dataCount, err := material.GetMaterialListCountByCondition(condition, pars)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取指标信息失败"
 		br.ErrMsg = "获取指标数据总数失败,Err:" + err.Error()
 		return
@@ -891,7 +891,7 @@ func (this *MaterialController) SaveAsMaterial() {
 		// 判断名称是否重复
 		exist, err = material.GetMaterialByName(req.MaterialName)
 	}
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -1206,14 +1206,14 @@ func (this *MaterialController) MaterialClassifyList() {
 	resp := new(material.MaterialClassifyListResp)
 
 	rootList, err := material.GetMaterialClassifyByParentId(0)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
 
 	classifyAll, err := material.GetMaterialClassifyAll()
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
@@ -1475,7 +1475,7 @@ func (this *MaterialController) BatchChangeClassify() {
 	// 判断新分类是否存在
 	_, err = material.GetMaterialClassifyById(req.NewClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}
@@ -1534,7 +1534,7 @@ func (this *MaterialController) ChangeClassify() {
 	// 判断素材是否存在
 	info, err := material.GetMaterialById(req.MaterialId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "素材不存在"
 			return
 		}
@@ -1551,7 +1551,7 @@ func (this *MaterialController) ChangeClassify() {
 	// 判断新分类是否存在
 	_, err = material.GetMaterialClassifyById(req.NewClassifyId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "分类不存在"
 			return
 		}
@@ -1613,7 +1613,7 @@ func (this *MaterialController) Rename() {
 	// 判断素材是否存在
 	info, err := material.GetMaterialById(req.MaterialId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "素材不存在"
 			return
 		}
@@ -1643,12 +1643,12 @@ func (this *MaterialController) Rename() {
 		info.MaterialName = req.MaterialName
 		updateStr = append(updateStr, "MaterialName")
 	}
-	if err != nil && err.Error() != utils.ErrNoRow() {
+	if err != nil && !utils.IsErrNoRow(err) {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
 		return
 	}
-	if err == nil && exist.MaterialId > 0 {
+	if err == nil && exist != nil && exist.MaterialId > 0 {
 		br.Msg = "图片名称已存在"
 		return
 	}
@@ -1844,7 +1844,7 @@ func (this *MaterialController) Download() {
 	// 判断素材是否存在
 	info, err := material.GetMaterialById(materialId)
 	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
+		if utils.IsErrNoRow(err) {
 			br.Msg = "素材不存在"
 			return
 		}

Some files were not shown because too many files changed in this diff