boweniac преди 3 седмици
родител
ревизия
e705110f1a
променени са 1 файла, в които са добавени 12 реда и са изтрити 4 реда
  1. 12 4
      internal/logic/contact_field_template/get_contact_field_template_by_id_logic.go

+ 12 - 4
internal/logic/contact_field_template/get_contact_field_template_by_id_logic.go

@@ -6,10 +6,9 @@ import (
 	"wechat-api/ent"
 	"wechat-api/ent/contactfieldtemplate"
 	"wechat-api/ent/custom_types"
-	"wechat-api/internal/utils/dberrorhandler"
-
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -30,8 +29,17 @@ func NewGetContactFieldTemplateByIdLogic(ctx context.Context, svcCtx *svc.Servic
 func (l *GetContactFieldTemplateByIdLogic) GetContactFieldTemplateById() (resp *types.ContactFieldTemplateInfoResp, err error) {
 	organizationId := l.ctx.Value("organizationId").(uint64)
 	data, err := l.svcCtx.DB.ContactFieldTemplate.Query().Where(contactfieldtemplate.OrganizationID(organizationId)).First(l.ctx)
-	if err != nil && !ent.IsNotFound(err) {
-		return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
+	if err != nil {
+		if ent.IsNotFound(err) {
+			return &types.ContactFieldTemplateInfoResp{
+				BaseDataInfo: types.BaseDataInfo{
+					Code: 0,
+					Msg:  errormsg.Success,
+				},
+			}, nil
+		} else {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)
+		}
 	}
 
 	template := ConvertCustomToInternal(data.Template)