ziwen 2 rokov pred
rodič
commit
1f17d97309
2 zmenil súbory, kde vykonal 20 pridanie a 3 odobranie
  1. 9 3
      controller/report/report.go
  2. 11 0
      controller/response/base.go

+ 9 - 3
controller/report/report.go

@@ -27,9 +27,15 @@ func Detail(c *gin.Context) {
 
 	reportDetail, err := report.GetReportDetail(userinfo, reportId)
 	if err != nil {
-		response.FailMsg("查看报告详情出错", err.Error(), c)
-		return
+		if err.Error() == "报告未发布" {
+			response.NotReleaseMsg("您查看的报告不存在,请试试其他报告吧", err.Error(), c)
+			return
+		} else {
+			response.FailMsg(err.Error(), err.Error(), c)
+			return
+		}
 	}
+
 	response.OkData("查询成功", reportDetail, c)
 	return
 }
@@ -276,4 +282,4 @@ func VarietyReportList(c *gin.Context) {
 
 	response.OkData("查询成功", list, c)
 	return
-}
+}

+ 11 - 0
controller/response/base.go

@@ -15,6 +15,7 @@ var (
 	TOKEN_ERROR_CODE   = 401  //toke异常
 	NO_AUTH            = 403  //没有权限
 	SPECIFIC_FAIL_CODE = 4001 // 业务指定错误
+	REPORT_NOT_RELEASE_CODE = 4002 // 报告未发布错误
 )
 
 type ResultData struct {
@@ -162,4 +163,14 @@ type BaseResponse struct {
 	Success     bool `description:"true 执行成功,false 执行失败"`
 	IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
 	IsAddLog    bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
+}
+
+// NotReleaseMsg 报告未发布错误
+func NotReleaseMsg(msg, errMsg string, c *gin.Context) {
+	resultData := ResultData{
+		Code:   REPORT_NOT_RELEASE_CODE,
+		Msg:    msg,
+		ErrMsg: errMsg,
+	}
+	result(200, resultData, c)
 }