|
@@ -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)
|