1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- 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 UpdateWhatsappLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewUpdateWhatsappLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateWhatsappLogic {
- return &UpdateWhatsappLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *UpdateWhatsappLogic) UpdateWhatsapp(req *types.WhatsappInfo) (*types.BaseMsgResp, error) {
- err := l.svcCtx.DB.Whatsapp.UpdateOneID(*req.Id).
- 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).
- Exec(l.ctx)
- if err != nil {
- return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
- }
- return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
- }
|