浏览代码

[20250517]授权

lin-jim-leon 2 月之前
父节点
当前提交
af4155fc74
共有 3 个文件被更改,包括 65 次插入0 次删除
  1. 46 0
      handler/refreshauthkuaishou.go
  2. 18 0
      model/http_model/refreshauthorizationrequest.go
  3. 1 0
      route/init.go

+ 46 - 0
handler/refreshauthkuaishou.go

@@ -0,0 +1,46 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+)
+
+func WrapRefreshAuthorizationHandler(ctx *gin.Context) {
+	handler := newRefreshAuthorizationHandler(ctx)
+	BaseRun(handler)
+}
+
+type RefreshAuthorizationHandler struct {
+	ctx  *gin.Context
+	req  *http_model.RefreshAuthorizationRequest
+	resp *http_model.CommonResponse
+}
+
+func (c RefreshAuthorizationHandler) getContext() *gin.Context { return c.ctx }
+func (c RefreshAuthorizationHandler) getResponse() interface{} { return c.resp }
+func (c RefreshAuthorizationHandler) getRequest() interface{} {
+	return c.req
+}
+func (c RefreshAuthorizationHandler) run() {
+	data := http_model.RefreshAuthorizationRequest{}
+	data = *c.req
+	res := http_model.RefreshAuthkuaishouResponse{
+		Url: "https://open.kuaishou.com/oauth2/connect?app_id=ks651333097154138217&redirect_uri=https://younggee.com/kuaishouauth&scope=merchant_distribution,merchant_refund,merchant_item,merchant_order,user_info,merchant_servicemarket,merchant_user,merchant_logistics&response_type=code&state=" + data.PhoneNumber,
+	}
+	c.resp.Message = "已返回授权码"
+	c.resp.Status = consts.ErrorSuccess
+	c.resp.Data = res
+
+}
+func (c RefreshAuthorizationHandler) checkParam() error {
+	return nil
+}
+
+func newRefreshAuthorizationHandler(ctx *gin.Context) *RefreshAuthorizationHandler {
+	return &RefreshAuthorizationHandler{
+		ctx:  ctx,
+		req:  http_model.NewRefreshAuthorizationRequest(),
+		resp: http_model.NewRefreshAuthorizationResponse(),
+	}
+}

+ 18 - 0
model/http_model/refreshauthorizationrequest.go

@@ -0,0 +1,18 @@
+package http_model
+
+type RefreshAuthorizationRequest struct {
+	PhoneNumber string `json:"phone_number"` //绑定手机号
+}
+
+type RefreshAuthkuaishouResponse struct {
+	Url string `json:"url"`
+}
+
+func NewRefreshAuthorizationRequest() *RefreshAuthorizationRequest {
+	return new(RefreshAuthorizationRequest)
+}
+func NewRefreshAuthorizationResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(RefreshAuthkuaishouResponse)
+	return resp
+}

+ 1 - 0
route/init.go

@@ -440,6 +440,7 @@ func InitRoute(r *gin.Engine) {
 		n.POST("/jobshow", handler.WrapJobShowHandler)                           //岗位详情
 		n.POST("/addauthorization", handler.WrapAuthkuaishouHandler)             //新增快手授权
 		n.POST("/KSauthorizationlist", handler.WrapGetAuthorizationListHandler)  //查询授权结果
+		n.POST("/refreshauthorization", handler.WrapRefreshAuthorizationHandler) //刷新授权
 		n.POST("/deleteksauthorization", handler.WrapDeleteauthorizationHandler) //删除授权
 		n.POST("/serveratio", handler.WrapSetServeratioHandler)                  //设置服务费率
 		n.POST("/getserveratio", handler.WrapGetServeratioHandler)               //获取服务费率