package fronted

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

// 分页查询
func (e MemberBalanceLog) GetPage(c *gin.Context) {
	s := appservice.MemberBalanceLog{}
	req := dto.MemberBalanceLogPageAppReq{}
	err := e.MakeContext(c).
		MakeOrm().
		Bind(&req).
		MakeService(&s.Service).
		Errors
	if err != nil {
		e.Logger.Error(err)
		e.Error(500, err, "server error")
		return
	}
	req.UserId = common.GetUserId(c)
	data := make([]dto.MemberBalanceLogAppResp, 0)
	var count int64
	code := s.GetPage(&req, &data, &count)

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

	e.PageOK(data, int(count), req.PageIndex, req.PageSize, "success")
}
