Explorar el Código

Merge branch 'pool_2463_notReleaseReport'

# Conflicts:
#	controller/report/report.go
ziwen hace 2 años
padre
commit
ac8b87cff6
Se han modificado 2 ficheros con 19 adiciones y 2 borrados
  1. 8 2
      controller/report/report.go
  2. 11 0
      controller/response/base.go

+ 8 - 2
controller/report/report.go

@@ -28,9 +28,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
 }

+ 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)
 }