1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package v1
- import (
- "git.getensh.com/common/gopkgs/logger"
- "git.getensh.com/common/gopkgs/tasker/httptasker"
- "git.getensh.com/common/gopkgs/util"
- "github.com/gin-gonic/gin"
- "go.uber.org/zap"
- "net/http"
- "property-management-gateway/errors"
- param_v1 "property-management-gateway/param/v1"
- "property-management-gateway/pb"
- "property-management-gateway/pb/v1"
- )
- //
- // @Summary 公众号添加小程序入口
- // @Description 公众号添加小程序入口
- // @Tags 微信相关
- // @Accept json
- // @Produce json
- // @Param token header string true " "
- // @Param body body v1.WxPublicAddMiniBody true " "
- // @Success 200 {object} v1.WxPublicAddMiniResponse
- // @Failure 500 {object} base.HTTPError
- // @Router /api/v1/wx/public/mini [post]
- func (c *Controller) WxPublicAddMini(ctx *gin.Context) {
- // 解析参数
- req := ¶m_v1.WxPublicAddMiniRequest{}
- parseParamTask := func() error {
- err := util.ShouldBind(ctx, &req.Header, nil, nil, &req.WxPublicAddMiniBody)
- if err != nil {
- logger.Error("func",
- zap.String("call", "util.ShouldBind"),
- zap.String("error", err.Error()))
- return errors.ParamsError
- }
- return nil
- }
- // 业务处理
- handleServiceTask := func() error {
- resp := param_v1.WxPublicAddMiniResponse{}
- rpcReq := &v1.WxPublicAddMiniRequest{
- MiniPagepath:req.MiniPagepath,
- MiniUrl:req.MiniUrl,
- }
- _, err := pb.Thirdparty.WxPublicAddMini(ctx, rpcReq)
- if err != nil {
- s, _ := json.MarshalToString(req)
- logger.Error("func",
- zap.String("call", "Thirdparty.WxPublicAddMini"),
- zap.String("params", s),
- zap.String("error", err.Error()))
- return errors.ErrorTransForm(err)
- }
- ctx.JSON(http.StatusOK, resp)
- return nil
- }
- // 执行任务
- httptasker.Exec(ctx, parseParamTask, handleServiceTask)
- }
|