package contact_field_template import ( "context" "errors" "github.com/suyuan32/simple-admin-common/msg/errormsg" "wechat-api/ent/contactfieldtemplate" "wechat-api/internal/utils/dberrorhandler" "wechat-api/internal/svc" "wechat-api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type DeleteContactFieldTemplateLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewDeleteContactFieldTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteContactFieldTemplateLogic { return &DeleteContactFieldTemplateLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} } func (l *DeleteContactFieldTemplateLogic) DeleteContactFieldTemplate(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { organizationId := l.ctx.Value("organizationId").(uint64) if len(req.Ids) == 0 { return nil, errors.New("ids参数不能为空") } _, err = l.svcCtx.DB.ContactFieldTemplate.Delete().Where(contactfieldtemplate.IDIn(req.Ids...), contactfieldtemplate.OrganizationID(organizationId)).Exec(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil }