作者 yangfu

异常处理

1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "github.com/linmadan/egglib-go/core/application"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/blur" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/blur"
9 "strconv" 13 "strconv"
10 "strings" 14 "strings"
11 -  
12 - "github.com/linmadan/egglib-go/core/application"  
13 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"  
14 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"  
15 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"  
16 ) 15 )
17 16
18 // CooperationProjectService 共创项目服务 17 // CooperationProjectService 共创项目服务
@@ -245,17 +244,20 @@ func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfoAtta @@ -245,17 +244,20 @@ func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfoAtta
245 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 244 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
246 } 245 }
247 // 不是本人查看需要做模糊处理 246 // 不是本人查看需要做模糊处理
248 - if response.UserBaseId != projectQuery.Operator.UserBaseId {  
249 - file, err := blur.FileBlur(response.Attachment.Url, true)  
250 - if err != nil { // || len(file)==0  
251 - log.Logger.Error(err.Error())  
252 - return nil, application.ThrowError(application.BUSINESS_ERROR, "文件加载错误,请重试")  
253 - }  
254 - if !(strings.HasPrefix(file, "http") || strings.HasPrefix(file, "https")) {  
255 - file = constant.ALLIED_CREATION_GATEWAY_HOST + "/" + file 247 + if response.Attachment != nil {
  248 + if response.UserBaseId != projectQuery.Operator.UserBaseId {
  249 + file, err := blur.FileBlur(response.Attachment.Url, true)
  250 + if err != nil { // || len(file)==0
  251 + log.Logger.Error(err.Error())
  252 + return nil, application.ThrowError(application.BUSINESS_ERROR, "文件加载错误,请重试")
  253 + }
  254 + if !(strings.HasPrefix(file, "http") || strings.HasPrefix(file, "https")) {
  255 + file = constant.ALLIED_CREATION_GATEWAY_HOST + "/" + file
  256 + }
  257 + response.Attachment.Url = file
256 } 258 }
257 - response.Attachment.Url = file  
258 } 259 }
  260 +
259 return map[string]interface{}{ 261 return map[string]interface{}{
260 "attachment": response.Attachment, 262 "attachment": response.Attachment,
261 }, nil 263 }, nil
@@ -120,7 +120,7 @@ func PDFBlur(pdfPath string) (string, error) { @@ -120,7 +120,7 @@ func PDFBlur(pdfPath string) (string, error) {
120 cmd := exec.Command(cmdPath, pdfPath, tmpImagePath+"/") 120 cmd := exec.Command(cmdPath, pdfPath, tmpImagePath+"/")
121 err = cmd.Run() 121 err = cmd.Run()
122 if err != nil { 122 if err != nil {
123 - panic(err) 123 + return "", err
124 } 124 }
125 125
126 var blurFiles = make([]string, 0) 126 var blurFiles = make([]string, 0)