123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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().
- 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
- }
|