package fronted

import (
	"go-admin/app/admin/service"
	"go-admin/app/admin/service/dto"
	"go-admin/common/service/sysservice/sysstatuscode"
	statuscode "go-admin/common/status_code"

	"github.com/gin-gonic/gin"
	"github.com/go-admin-team/go-admin-core/sdk/api"
)

type SysDict struct {
	api.Api
}

// 获取详情
func (e SysDict) Get(c *gin.Context) {

}

// 获取字典数据列表
func (e SysDict) GetChild(c *gin.Context) {
	req := dto.SysDictChildAppReq{}
	s := service.SysDictType{}
	err := e.MakeContext(c).
		MakeOrm().
		Bind(&req).
		MakeService(&s.Service).
		Errors

	if err != nil {
		e.Error(500, nil, err.Error())
	}

	list := make([]dto.SysDictDataResp, 0)

	code := s.GetChild(&req, &list)

	if code != statuscode.OK {
		e.Error(code, nil, sysstatuscode.GetStatusCodeDescription(c, code))
	}

	e.OK(list, "success")
}
