Browse Source

fix:增加whatsapp 模板接口

jimmyyem 1 month ago
parent
commit
6263da98ee

+ 139 - 0
desc/wechat/whatsapp.api

@@ -274,6 +274,125 @@ type (
         // 群黑名单
         GroupBlockList *string `json:"groupBlockList,optional"`
     }
+
+	TemplateInfo {
+		Category string `json:"category,optional"`
+		TemplateCode string `json:"templateCode,optional"`
+		Name string `json:"name,optional"`
+		Language string `json:"language,optional"`
+		TemplateType string `json:"templateType,optional"`
+		AuditStatus string `json:"auditStatus,optional"`
+		Components []TemplateComponent `json:"components,optional"`
+		QualityScore string `json:"qualityScore,optional"`
+		MessageSendTtlSeconds int `json:"messageSendTtlSeconds,optional"`
+		Reason string `json:"reason,optional"`
+	}
+	TemplateSingleInfo {
+		Category string `json:"category,optional"`
+		TemplateCode string `json:"templateCode,optional"`
+		Name string `json:"name,optional"`
+		Language string `json:"language,optional"`
+		TemplateType string `json:"templateType,optional"`
+		AuditStatus string `json:"auditStatus,optional"`
+	}
+	TemplateComponent {
+		Type string `json:"type,optional"`
+		Url string `json:"url,optional"`
+		Text string `json:"text,optional"`
+		Caption string `json:"caption,optional"`
+		FileName string `json:"fileName,optional"`
+		Format string `json:"format,optional"`
+		Buttons []TemplateButton `json:"buttons,optional"`
+		ThumbUrl string `json:"thumbUrl,optional"`
+		Duration int `json:"duration,optional"`
+		FileType string `json:"fileType,optional"`
+		Latitude string `json:"latitude,optional"`
+		Longitude string `json:"longitude,optional"`
+		LocationName string `json:"locationName,optional"`
+		LocationAddress string `json:"locationAddress,optional"`
+		AddSecretRecommendation bool `json:"addSecretRecommendation,optional"`
+		CodeExpirationMinutes int `json:"codeExpirationMinutes,optional"`
+		HasExpiration bool `json:"hasExpiration,optional"`
+		OfferExpirationTimeMs string `json:"offerExpirationTimeMs,optional"`
+	}
+	TemplateButton {
+		Type string `json:"type,optional"`
+		Text string `json:"text,optional"`
+		PhoneNumber string `json:"phoneNumber,optional"`
+		Url string `json:"url,optional"`
+		UrlType string `json:"urlType,optional"`
+		SignatureHash string `json:"signatureHash,optional"`
+		PackageName string `json:"packageName,optional"`
+		AutofillText string `json:"autofillText,optional"`
+		IsOptOut bool `json:"isOptOut,optional"`
+		ExtendAttrs []TemplateExtendAttr `json:"extendAttrs,optional"`
+		CouponCode string `json:"couponCode,optional"`
+		FlowId string `json:"flowId,optional"`
+		FlowAction string `json:"flowAction,optional"`
+		NavigateScreen string `json:"navigateScreen,optional"`
+		SupportedApps []TemplateSupportedApp `json:"supportedApps,optional"`
+	}
+	TemplateSupportedApp {
+		SignatureHash string `json:"signatureHash,optional"`
+		PackageName string `json:"packageName,optional"`
+	}
+	TemplateExtendAttr {
+		NextTemplateCode string `json:"nextTemplateCode,optional"`
+		NextTemplateName string `json:"nextTemplateName,optional"`
+		NextLanguageCode string `json:"nextLanguageCode,optional"`
+		Action string `json:"action,optional"`
+		IntentCode string `json:"intentCode,optional"`
+	}
+	createTemplateReq {
+		Category string `json:"category"`
+		TemplateCode string `json:"templateCode"`
+		Name string `json:"name"`
+		Language string `json:"language"`
+		TemplateType string `json:"templateType,optional"`
+		AllowCategoryChange bool `json:"allowCategoryChange,optional"`
+		MessageSendTtlSeconds int `json:"messageSendTtlSeconds,optional"`
+	}
+	listTemplateReq {
+		Page int32 `json:"page"`
+		pageSize int32 `json:"pageSize"`
+		Name string `json:"name,optional"`
+		Language string `json:"language,optional"`
+		AuditStatus string `json:"auditStatus,optional"`
+		TemplateType string `json:"templateType,optional"`
+		Code string `json:"code,optional"`
+	}
+	listTemplateResp {
+		Code int    `json:"code"`
+		Msg  string `json:"msg"`
+		Data []TemplateSingleInfo `json:"data,omitempty"`
+	}
+	removeTemplateReq {
+		TemplateCode string `json:"templateCode,optional"`
+		TemplateName string `json:"templateName,optional"`
+		Language string `json:"language"`
+		TemplateType string `json:"templateType,optional"`
+	}
+	editTemplateReq {
+		Components []TemplateComponent `json:"components,optional"`
+		Language string `json:"language,optional"`
+		TemplateCode string `json:"templateCode,optional"`
+		Category string `json:"category,optional"`
+		TemplateType string `json:"templateType,optional"`
+		MessageSendTtlSeconds int `json:"messageSendTtlSeconds,optional"`
+		TemplateName string `json:"templateName,optional"`
+	}
+
+	getTemplateReq {
+		TemplateCode string `json:"templateCode,optional"`
+		Language string `json:"language"`
+		TemplateType string `json:"templateType,optional"`
+		TemplateName string `json:"templateName,optional"`
+	}
+	getTemplateResp {
+		Code int    `json:"code"`
+		Msg  string `json:"msg"`
+		Data TemplateSingleInfo `json:"data,omitempty"`
+	}
 )
 
 @server(
@@ -362,4 +481,24 @@ service Wechat {
     // Update whatsapp information | 更新黑白名单
     @handler updateAllowAndBlockList
     post /whatsapp/updateAllowAndBlockList (UpdateAllowAndBlockListReq) returns (BaseMsgResp)
+
+	// 创建模板
+	@handler createWhatsappTemplate
+	post /whatsapp/createTemplate (createTemplateReq) returns (BaseDataInfo)
+
+	// 创建模板
+	@handler listWhatsappTemplate
+	post /whatsapp/listTemplate (listTemplateReq) returns (listTemplateResp)
+
+	// 删除模板
+	@handler removeWhatsappTemplate
+	post /whatsapp/removeTemplate (removeTemplateReq) returns (BaseDataInfo)
+
+	// 编辑模板
+	@handler editWhatsappTemplate
+	post /whatsapp/editTemplate (editTemplateReq) returns (BaseDataInfo)
+
+	// 模板详情
+	@handler getWhatsappTemplate
+	post /whatsapp/getTemplate (getTemplateReq) returns (getTemplateResp)
 }

+ 0 - 4
go.sum

@@ -447,7 +447,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
 github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
-github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
@@ -481,7 +480,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
 github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
 github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
-github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
@@ -580,8 +578,6 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
 github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
-github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
-github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=

+ 71 - 0
hook/aliyun/whatsapp.go

@@ -440,3 +440,74 @@ func UpdatePhoneWebhook(phone, custSpaceId, callback string) (*cams20200606.Upda
 
 	return response, nil
 }
+
+// ListChatappTemplate 获取模板列表
+func ListChatappTemplate(name, language, auditStatus, templateType, code string, page, size int32) (*cams20200606.ListChatappTemplateResponse, error) {
+	client, _err := CreateCamsClient()
+	if _err != nil {
+		return nil, _err
+	}
+
+	request := &cams20200606.ListChatappTemplateRequest{
+		Name:        tea.String(name),
+		Language:    tea.String(language),
+		AuditStatus: tea.String(auditStatus),
+		Page: &cams20200606.ListChatappTemplateRequestPage{
+			Index: tea.Int32(page),
+			Size:  tea.Int32(size),
+		},
+		TemplateType: tea.String(templateType),
+		Code:         tea.String(code),
+	}
+
+	response, _err := client.ListChatappTemplate(request)
+	if _err != nil {
+		return nil, _err
+	}
+
+	return response, nil
+}
+
+// GetChatappTemplateInfo 获取模板详情
+func GetChatappTemplateInfo(name, language, templateType, templateCode string) (*cams20200606.GetChatappTemplateDetailResponse, error) {
+	client, _err := CreateCamsClient()
+	if _err != nil {
+		return nil, _err
+	}
+
+	request := &cams20200606.GetChatappTemplateDetailRequest{
+		TemplateName: tea.String(name),
+		Language:     tea.String(language),
+		TemplateType: tea.String(templateType),
+		TemplateCode: tea.String(templateCode),
+	}
+
+	response, _err := client.GetChatappTemplateDetail(request)
+	if _err != nil {
+		return nil, _err
+	}
+
+	return response, nil
+}
+
+// DeleteChatappTemplate 模板删除
+func DeleteChatappTemplate(name, language, templateType, templateCode string) (*cams20200606.DeleteChatappTemplateResponse, error) {
+	client, _err := CreateCamsClient()
+	if _err != nil {
+		return nil, _err
+	}
+
+	request := &cams20200606.DeleteChatappTemplateRequest{
+		TemplateName: tea.String(name),
+		Language:     tea.String(language),
+		TemplateType: tea.String(templateType),
+		TemplateCode: tea.String(templateCode),
+	}
+
+	response, _err := client.DeleteChatappTemplate(request)
+	if _err != nil {
+		return nil, _err
+	}
+
+	return response, nil
+}

+ 25 - 0
internal/handler/routes.go

@@ -1879,6 +1879,31 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/whatsapp/updateAllowAndBlockList",
 					Handler: whatsapp.UpdateAllowAndBlockListHandler(serverCtx),
 				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/createTemplate",
+					Handler: whatsapp.CreateWhatsappTemplateHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/listTemplate",
+					Handler: whatsapp.ListWhatsappTemplateHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/removeTemplate",
+					Handler: whatsapp.RemoveWhatsappTemplateHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/editTemplate",
+					Handler: whatsapp.EditWhatsappTemplateHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/whatsapp/getTemplate",
+					Handler: whatsapp.GetWhatsappTemplateHandler(serverCtx),
+				},
 			}...,
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),

+ 44 - 0
internal/handler/whatsapp/create_whatsapp_template_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/createTemplate whatsapp CreateWhatsappTemplate
+//
+// 创建模板
+//
+// 创建模板
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: createTemplateReq
+//
+// Responses:
+//  200: BaseDataInfo
+
+func CreateWhatsappTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.CreateTemplateReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewCreateWhatsappTemplateLogic(r.Context(), svcCtx)
+		resp, err := l.CreateWhatsappTemplate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/edit_whatsapp_template_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/editTemplate whatsapp EditWhatsappTemplate
+//
+// 编辑模板
+//
+// 编辑模板
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: editTemplateReq
+//
+// Responses:
+//  200: BaseDataInfo
+
+func EditWhatsappTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.EditTemplateReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewEditWhatsappTemplateLogic(r.Context(), svcCtx)
+		resp, err := l.EditWhatsappTemplate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/get_whatsapp_template_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/getTemplate whatsapp GetWhatsappTemplate
+//
+// 模板详情
+//
+// 模板详情
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: getTemplateReq
+//
+// Responses:
+//  200: getTemplateResp
+
+func GetWhatsappTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.GetTemplateReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewGetWhatsappTemplateLogic(r.Context(), svcCtx)
+		resp, err := l.GetWhatsappTemplate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/list_whatsapp_template_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/listTemplate whatsapp ListWhatsappTemplate
+//
+// 创建模板
+//
+// 创建模板
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: listTemplateReq
+//
+// Responses:
+//  200: listTemplateResp
+
+func ListWhatsappTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ListTemplateReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewListWhatsappTemplateLogic(r.Context(), svcCtx)
+		resp, err := l.ListWhatsappTemplate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/whatsapp/remove_whatsapp_template_handler.go

@@ -0,0 +1,44 @@
+package whatsapp
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/whatsapp"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /whatsapp/removeTemplate whatsapp RemoveWhatsappTemplate
+//
+// 删除模板
+//
+// 删除模板
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: removeTemplateReq
+//
+// Responses:
+//  200: BaseDataInfo
+
+func RemoveWhatsappTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.RemoveTemplateReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := whatsapp.NewRemoveWhatsappTemplateLogic(r.Context(), svcCtx)
+		resp, err := l.RemoveWhatsappTemplate(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 29 - 0
internal/logic/whatsapp/create_whatsapp_template_logic.go

@@ -0,0 +1,29 @@
+package whatsapp
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CreateWhatsappTemplateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewCreateWhatsappTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWhatsappTemplateLogic {
+	return &CreateWhatsappTemplateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *CreateWhatsappTemplateLogic) CreateWhatsappTemplate(req *types.CreateTemplateReq) (resp *types.BaseDataInfo, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 29 - 0
internal/logic/whatsapp/edit_whatsapp_template_logic.go

@@ -0,0 +1,29 @@
+package whatsapp
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type EditWhatsappTemplateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewEditWhatsappTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditWhatsappTemplateLogic {
+	return &EditWhatsappTemplateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *EditWhatsappTemplateLogic) EditWhatsappTemplate(req *types.EditTemplateReq) (resp *types.BaseDataInfo, err error) {
+	// todo: add your logic here and delete this line
+
+	return
+}

+ 54 - 0
internal/logic/whatsapp/get_whatsapp_template_logic.go

@@ -0,0 +1,54 @@
+package whatsapp
+
+import (
+	"context"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"wechat-api/hook/aliyun"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWhatsappTemplateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetWhatsappTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhatsappTemplateLogic {
+	return &GetWhatsappTemplateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *GetWhatsappTemplateLogic) GetWhatsappTemplate(req *types.GetTemplateReq) (*types.GetTemplateResp, error) {
+	resp := types.GetTemplateResp{}
+
+	if req.Language == "" {
+		return nil, errorx.NewInvalidArgumentError("language参数错误")
+	}
+
+	result, err := aliyun.GetChatappTemplateInfo(req.TemplateName, req.Language, req.TemplateType, req.TemplateCode)
+	l.Logger.Infof("result=%v err=%v\n", result, err)
+
+	if err != nil {
+		resp.Msg = err.Error()
+		resp.Code = 1
+	} else {
+		if *result.Body.Code == "OK" && result.Body.Data != nil {
+			resp.Data = types.TemplateSingleInfo{
+				AuditStatus:  *result.Body.Data.AuditStatus,
+				Category:     *result.Body.Data.Category,
+				Language:     *result.Body.Data.Language,
+				Name:         *result.Body.Data.Name,
+				TemplateCode: *result.Body.Data.TemplateCode,
+				TemplateType: *result.Body.Data.TemplateType,
+			}
+		}
+	}
+
+	return &resp, nil
+}

+ 51 - 0
internal/logic/whatsapp/list_whatsapp_template_logic.go

@@ -0,0 +1,51 @@
+package whatsapp
+
+import (
+	"context"
+	"wechat-api/hook/aliyun"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ListWhatsappTemplateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewListWhatsappTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListWhatsappTemplateLogic {
+	return &ListWhatsappTemplateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *ListWhatsappTemplateLogic) ListWhatsappTemplate(req *types.ListTemplateReq) (*types.ListTemplateResp, error) {
+	resp := types.ListTemplateResp{}
+	result, err := aliyun.ListChatappTemplate(req.Name, req.Language, req.AuditStatus, req.TemplateType, req.Code, req.Page, req.PageSize)
+	l.Logger.Infof("result=%v err=%v\n", result, err)
+
+	if err != nil {
+		resp.Msg = err.Error()
+		resp.Code = 1
+	} else {
+		resp.Code = 0
+		if len(result.Body.ListTemplate) > 0 && *result.Body.Code == "OK" {
+			for _, val := range result.Body.ListTemplate {
+				resp.Data = append(resp.Data, types.TemplateSingleInfo{
+					AuditStatus:  *val.AuditStatus,
+					Category:     *val.Category,
+					Language:     *val.Language,
+					TemplateCode: *val.TemplateCode,
+					Name:         *val.TemplateName,
+					TemplateType: *val.TemplateType,
+				})
+			}
+		}
+	}
+
+	return &resp, nil
+}

+ 45 - 0
internal/logic/whatsapp/remove_whatsapp_template_logic.go

@@ -0,0 +1,45 @@
+package whatsapp
+
+import (
+	"context"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"wechat-api/hook/aliyun"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type RemoveWhatsappTemplateLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewRemoveWhatsappTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RemoveWhatsappTemplateLogic {
+	return &RemoveWhatsappTemplateLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *RemoveWhatsappTemplateLogic) RemoveWhatsappTemplate(req *types.RemoveTemplateReq) (*types.BaseDataInfo, error) {
+	resp := types.BaseDataInfo{}
+
+	if req.TemplateType == "" && req.TemplateCode == "" && req.TemplateName == "" && req.Language == "" {
+		return nil, errorx.NewInvalidArgumentError("参数错误")
+	}
+
+	result, err := aliyun.DeleteChatappTemplate(req.TemplateName, req.Language, req.TemplateType, req.TemplateCode)
+	l.Logger.Infof("result=%v err=%v\n", result, err)
+
+	if err != nil {
+		resp.Msg = err.Error()
+		resp.Code = 1
+	} else if *result.Body.Code == "OK" {
+		resp.Data = "success"
+	}
+
+	return &resp, nil
+}

+ 139 - 0
internal/types/types.go

@@ -3685,6 +3685,145 @@ type UpdateAllowAndBlockListReq struct {
 	GroupBlockList *string `json:"groupBlockList,optional"`
 }
 
+// swagger:model TemplateInfo
+type TemplateInfo struct {
+	Category              string              `json:"category,optional"`
+	TemplateCode          string              `json:"templateCode,optional"`
+	Name                  string              `json:"name,optional"`
+	Language              string              `json:"language,optional"`
+	TemplateType          string              `json:"templateType,optional"`
+	AuditStatus           string              `json:"auditStatus,optional"`
+	Components            []TemplateComponent `json:"components,optional"`
+	QualityScore          string              `json:"qualityScore,optional"`
+	MessageSendTtlSeconds int                 `json:"messageSendTtlSeconds,optional"`
+	Reason                string              `json:"reason,optional"`
+}
+
+// swagger:model TemplateSingleInfo
+type TemplateSingleInfo struct {
+	Category     string `json:"category,optional"`
+	TemplateCode string `json:"templateCode,optional"`
+	Name         string `json:"name,optional"`
+	Language     string `json:"language,optional"`
+	TemplateType string `json:"templateType,optional"`
+	AuditStatus  string `json:"auditStatus,optional"`
+}
+
+type TemplateComponent struct {
+	Type                    string           `json:"type,optional"`
+	Url                     string           `json:"url,optional"`
+	Text                    string           `json:"text,optional"`
+	Caption                 string           `json:"caption,optional"`
+	FileName                string           `json:"fileName,optional"`
+	Format                  string           `json:"format,optional"`
+	Buttons                 []TemplateButton `json:"buttons,optional"`
+	ThumbUrl                string           `json:"thumbUrl,optional"`
+	Duration                int              `json:"duration,optional"`
+	FileType                string           `json:"fileType,optional"`
+	Latitude                string           `json:"latitude,optional"`
+	Longitude               string           `json:"longitude,optional"`
+	LocationName            string           `json:"locationName,optional"`
+	LocationAddress         string           `json:"locationAddress,optional"`
+	AddSecretRecommendation bool             `json:"addSecretRecommendation,optional"`
+	CodeExpirationMinutes   int              `json:"codeExpirationMinutes,optional"`
+	HasExpiration           bool             `json:"hasExpiration,optional"`
+	OfferExpirationTimeMs   string           `json:"offerExpirationTimeMs,optional"`
+}
+
+type TemplateButton struct {
+	Type           string                 `json:"type,optional"`
+	Text           string                 `json:"text,optional"`
+	PhoneNumber    string                 `json:"phoneNumber,optional"`
+	Url            string                 `json:"url,optional"`
+	UrlType        string                 `json:"urlType,optional"`
+	SignatureHash  string                 `json:"signatureHash,optional"`
+	PackageName    string                 `json:"packageName,optional"`
+	AutofillText   string                 `json:"autofillText,optional"`
+	IsOptOut       bool                   `json:"isOptOut,optional"`
+	ExtendAttrs    []TemplateExtendAttr   `json:"extendAttrs,optional"`
+	CouponCode     string                 `json:"couponCode,optional"`
+	FlowId         string                 `json:"flowId,optional"`
+	FlowAction     string                 `json:"flowAction,optional"`
+	NavigateScreen string                 `json:"navigateScreen,optional"`
+	SupportedApps  []TemplateSupportedApp `json:"supportedApps,optional"`
+}
+
+type TemplateSupportedApp struct {
+	SignatureHash string `json:"signatureHash,optional"`
+	PackageName   string `json:"packageName,optional"`
+}
+
+type TemplateExtendAttr struct {
+	NextTemplateCode string `json:"nextTemplateCode,optional"`
+	NextTemplateName string `json:"nextTemplateName,optional"`
+	NextLanguageCode string `json:"nextLanguageCode,optional"`
+	Action           string `json:"action,optional"`
+	IntentCode       string `json:"intentCode,optional"`
+}
+
+// swagger:model createTemplateReq
+type CreateTemplateReq struct {
+	Category              string `json:"category"`
+	TemplateCode          string `json:"templateCode"`
+	Name                  string `json:"name"`
+	Language              string `json:"language"`
+	TemplateType          string `json:"templateType,optional"`
+	AllowCategoryChange   bool   `json:"allowCategoryChange,optional"`
+	MessageSendTtlSeconds int    `json:"messageSendTtlSeconds,optional"`
+}
+
+// swagger:model listTemplateReq
+type ListTemplateReq struct {
+	Page         int32  `json:"page"`
+	PageSize     int32  `json:"pageSize"`
+	Name         string `json:"name,optional"`
+	Language     string `json:"language,optional"`
+	AuditStatus  string `json:"auditStatus,optional"`
+	TemplateType string `json:"templateType,optional"`
+	Code         string `json:"code,optional"`
+}
+
+// swagger:model listTemplateResp
+type ListTemplateResp struct {
+	Code int                  `json:"code"`
+	Msg  string               `json:"msg"`
+	Data []TemplateSingleInfo `json:"data,omitempty"`
+}
+
+// swagger:model removeTemplateReq
+type RemoveTemplateReq struct {
+	TemplateCode string `json:"templateCode,optional"`
+	TemplateName string `json:"templateName,optional"`
+	Language     string `json:"language"`
+	TemplateType string `json:"templateType,optional"`
+}
+
+// swagger:model editTemplateReq
+type EditTemplateReq struct {
+	Components            []TemplateComponent `json:"components,optional"`
+	Language              string              `json:"language,optional"`
+	TemplateCode          string              `json:"templateCode,optional"`
+	Category              string              `json:"category,optional"`
+	TemplateType          string              `json:"templateType,optional"`
+	MessageSendTtlSeconds int                 `json:"messageSendTtlSeconds,optional"`
+	TemplateName          string              `json:"templateName,optional"`
+}
+
+// swagger:model getTemplateReq
+type GetTemplateReq struct {
+	TemplateCode string `json:"templateCode,optional"`
+	Language     string `json:"language"`
+	TemplateType string `json:"templateType,optional"`
+	TemplateName string `json:"templateName,optional"`
+}
+
+// swagger:model getTemplateResp
+type GetTemplateResp struct {
+	Code int                `json:"code"`
+	Msg  string             `json:"msg"`
+	Data TemplateSingleInfo `json:"data,omitempty"`
+}
+
 // The data of whatsapp channel information | WhatsappChannel信息
 // swagger:model WhatsappChannelInfo
 type WhatsappChannelInfo struct {