package fronted

import (
	"go-admin/app/admin/service/appservice"
	"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 Common struct {
	api.Api
}

// 获取默认设置
func (e Common) GetDefaultSet(c *gin.Context) {
	s := appservice.Common{}
	err := e.MakeContext(c).
		MakeOrm().
		MakeService(&s.Service).
		Errors
	if err != nil {
		e.Logger.Error(err)
		e.Error(statuscode.ServerError, nil, sysstatuscode.GetStatusCodeDescription(c, statuscode.ServerError))
		return
	}

	data, code := s.GetDefaultSet()

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

	e.OK(data, "success")
}
