作者 yangfu

异常处理

package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/util/blur"
"strconv"
"strings"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
// CooperationProjectService 共创项目服务
... ... @@ -245,17 +244,20 @@ func (srv CooperationProjectService) PersonSearchCooperationProjectShareInfoAtta
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
// 不是本人查看需要做模糊处理
if response.UserBaseId != projectQuery.Operator.UserBaseId {
file, err := blur.FileBlur(response.Attachment.Url, true)
if err != nil { // || len(file)==0
log.Logger.Error(err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, "文件加载错误,请重试")
}
if !(strings.HasPrefix(file, "http") || strings.HasPrefix(file, "https")) {
file = constant.ALLIED_CREATION_GATEWAY_HOST + "/" + file
if response.Attachment != nil {
if response.UserBaseId != projectQuery.Operator.UserBaseId {
file, err := blur.FileBlur(response.Attachment.Url, true)
if err != nil { // || len(file)==0
log.Logger.Error(err.Error())
return nil, application.ThrowError(application.BUSINESS_ERROR, "文件加载错误,请重试")
}
if !(strings.HasPrefix(file, "http") || strings.HasPrefix(file, "https")) {
file = constant.ALLIED_CREATION_GATEWAY_HOST + "/" + file
}
response.Attachment.Url = file
}
response.Attachment.Url = file
}
return map[string]interface{}{
"attachment": response.Attachment,
}, nil
... ...
... ... @@ -120,7 +120,7 @@ func PDFBlur(pdfPath string) (string, error) {
cmd := exec.Command(cmdPath, pdfPath, tmpImagePath+"/")
err = cmd.Run()
if err != nil {
panic(err)
return "", err
}
var blurFiles = make([]string, 0)
... ...