12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package whatsapp
- import (
- "context"
- "wechat-api/hook/aliyun"
- "wechat-api/internal/svc"
- "wechat-api/internal/types"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type GetBusinessInfoLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
- func NewGetBusinessInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetBusinessInfoLogic {
- return &GetBusinessInfoLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx}
- }
- func (l *GetBusinessInfoLogic) GetBusinessInfo(req *types.GetBusinessReq) (*types.GetBusinessResp, error) {
- resp := types.GetBusinessResp{}
- result, err := aliyun.GetCamsBusiness(*req.Phone, *req.WaId)
- l.Logger.Infof("result=%v err=%v \n", result, err)
- if err != nil {
- resp.Code = 1
- resp.Msg = err.Error()
- } else {
- if result.Body.Data != nil {
- if result.Body.Data.About != nil {
- resp.Data.About = *result.Body.Data.About
- }
- if result.Body.Data.Address != nil {
- resp.Data.Address = *result.Body.Data.Address
- }
- if result.Body.Data.Description != nil {
- resp.Data.Description = *result.Body.Data.Description
- }
- if result.Body.Data.Email != nil {
- resp.Data.Email = *result.Body.Data.Email
- }
- if result.Body.Data.Vertical != nil {
- resp.Data.Vertical = *result.Body.Data.Vertical
- }
- if result.Body.Data.ProfilePictureUrl != nil {
- resp.Data.ProfilePictureUrl = *result.Body.Data.ProfilePictureUrl
- }
- if result.Body.Data.Websites != nil {
- websites := make([]string, 0)
- for _, v := range result.Body.Data.Websites {
- websites = append(websites, *v)
- }
- resp.Data.Websites = websites
- }
- }
- }
- return &resp, nil
- }
|