package dictionary_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/dictionary_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 get /api/admin/dictionary/list dictionary_admin GetDictionaryListAdmin
//
// Get dictionary list | 获取字典列表
//
// Get dictionary list | 获取字典列表
//
// Responses:
//  200: DictionaryListResp

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

		l := dictionary_admin.NewGetDictionaryListAdminLogic(r, r.Context(), svcCtx)
		resp, err := l.GetDictionaryListAdmin(&req)

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

	}
}
