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 LineCoinnetwork struct {
	api.Api
}

// 获取区块链网络列表
func (e LineCoinnetwork) GetList(c *gin.Context) {
	s := service.LineCoinnetwork{}
	err := e.MakeContext(c).
		MakeOrm().
		MakeService(&s.Service).
		Errors
	if err != nil {
		e.Logger.Error(err)
		e.Error(500, err, err.Error())
		return
	}

	data := make([]dto.LineCoinnetworkAppResp, 0)
	code := s.GetOpenList(&data)

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

	e.OK(data, "success")
}
