package fastgpt

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"

	"wechat-api/internal/logic/fastgpt"
	"wechat-api/internal/svc"
)

// swagger:route get /api/fastgpt/set_token fastgpt SetToken
//

//

//
// Responses:
//  200: BaseMsgResp

func SetTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		username := r.URL.Query().Get("username")
		l := fastgpt.NewSetTokenLogic(r.Context(), svcCtx, w)
		resp, err := l.SetToken(username)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, err)
		} else {
			httpx.OkJsonCtx(r.Context(), w, resp)
		}
	}
}
