package whatsapp import ( "context" "wechat-api/internal/svc" "wechat-api/internal/types" "wechat-api/internal/utils/dberrorhandler" "github.com/suyuan32/simple-admin-common/msg/errormsg" "github.com/zeromicro/go-zero/core/logx" ) type CreateWhatsappLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewCreateWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWhatsappLogic { return &CreateWhatsappLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *CreateWhatsappLogic) CreateWhatsapp(req *types.WhatsappInfo) (*types.BaseMsgResp, error) { var stringSlice []string _, err := l.svcCtx.DB.Whatsapp.Create(). SetNotNilStatus(req.Status). SetNotNilAk(req.Ak). SetNotNilSk(req.Sk). SetNotNilCallback(req.Callback). SetNotNilAccount(req.Account). SetNotNilNickname(req.Nickname). SetNotNilPhone(req.Phone). SetNotNilOrganizationID(req.OrganizationId). SetNotNilAgentID(req.AgentId). SetNotNilAPIBase(req.ApiBase). SetNotNilAPIKey(req.ApiKey). SetNotNilAllowList(stringSlice). SetNotNilGroupAllowList(stringSlice). SetNotNilBlockList(stringSlice). SetNotNilGroupBlockList(stringSlice). Save(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil }