You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
1.1 KiB

package service
import (
"net/http"
repository "sig-pub/internal/admin/repoitory"
"sig-pub/pkg/resp"
"github.com/gin-gonic/gin"
)
type MarketService struct {
repo *repository.MarketRepository
}
func NewMarketService(repo *repository.MarketRepository) *MarketService {
return &MarketService{
repo: repo,
}
}
func (svc *MarketService) Route(group *gin.RouterGroup) {
group.GET("listInstanceId", svc.ListInstanceId) // 所有交易产品ID
group.GET("listInstance", svc.ListInstance) // 所有交易产品信息
}
func (svc *MarketService) ListInstanceId(ctx *gin.Context) {
instIds, err := svc.repo.ListAllInstanceId()
if err != nil {
ctx.JSON(http.StatusInternalServerError, resp.Error(err.Error()))
return
}
ctx.JSON(http.StatusOK, resp.Success(instIds))
}
func (svc *MarketService) ListInstance(ctx *gin.Context) {
insts, err := svc.repo.ListAllInstance()
if err != nil {
ctx.JSON(http.StatusInternalServerError, resp.Error(err.Error()))
return
}
ctx.JSON(http.StatusOK, resp.Success(resp.H{
"total": len(insts),
"insts": insts,
}))
}