package token_admin

import (
	"net/http"

	"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"
	"github.com/zeromicro/go-zero/rest/httpx"

	"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/token_admin"
	"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
	"git.noahlan.cn/n-admin/n-admin-server/api/internal/types"
)

// swagger:route post /api/admin/token/disable token_admin DisableTokenAdmin
//
// Disable token | 禁用凭证（强制下线）
//
// Disable token | 禁用凭证（强制下线）
//
// Parameters:
//  + name: body
//    require: true
//    in: body
//    type: BaseID
//

func DisableTokenAdminHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		const transErr = true
		var req types.BaseID
		if err := httpx.Parse(r, &req); err != nil {
			statusz.ResponseHandler(r, w, transErr, nil, err)
			return
		}

		l := token_admin.NewDisableTokenAdminLogic(r, r.Context(), svcCtx)
		err := l.DisableTokenAdmin(&req)

		statusz.ResponseHandler(r, w, transErr, nil, err)

	}
}
