statistics_controller.go 3.0 KB
package controllers

import (
	"encoding/json"

	"github.com/astaxie/beego"
	"github.com/linmadan/egglib-go/web/beego/utils"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/command"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/service"
)

type StatisticsController struct {
	beego.Controller
}

func (controller *StatisticsController) SystemTaskStatistics() {
	statisticsService := service.NewStatisticsService(nil)
	systemTaskStatisticsCommand := &command.SystemTaskStatisticsCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), systemTaskStatisticsCommand)
	data, err := statisticsService.SystemTaskStatistics(systemTaskStatisticsCommand)
	var response utils.JsonResponse
	if err != nil {
		response = utils.ResponseError(controller.Ctx, err)
	} else {
		response = utils.ResponseData(controller.Ctx, data)
	}
	controller.Data["json"] = response
	controller.ServeJSON()
}

func (controller *StatisticsController) PersonTaskStatistics() {
	statisticsService := service.NewStatisticsService(nil)
	personTaskStatisticsCommand := &command.PersonTaskStatisticsCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), personTaskStatisticsCommand)
	data, err := statisticsService.PersonTaskStatistics(personTaskStatisticsCommand)
	var response utils.JsonResponse
	if err != nil {
		response = utils.ResponseError(controller.Ctx, err)
	} else {
		response = utils.ResponseData(controller.Ctx, data)
	}
	controller.Data["json"] = response
	controller.ServeJSON()
}

func (controller *StatisticsController) PersonSuMoneyStatistics() {
	statisticsService := service.NewStatisticsService(nil)
	personSuMoneyStatisticsCommand := &command.PersonSuMoneyStatisticsCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), personSuMoneyStatisticsCommand)
	data, err := statisticsService.PersonSuMoneyStatistics(personSuMoneyStatisticsCommand)
	var response utils.JsonResponse
	if err != nil {
		response = utils.ResponseError(controller.Ctx, err)
	} else {
		response = utils.ResponseData(controller.Ctx, data)
	}
	controller.Data["json"] = response
	controller.ServeJSON()
}

func (controller *StatisticsController) PersonNotificationStatistics() {
	statisticsService := service.NewStatisticsService(nil)
	personNotificationStatisticsCommand := &command.PersonNotificationStatisticsCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), personNotificationStatisticsCommand)
	data, err := statisticsService.PersonNotificationStatistics(personNotificationStatisticsCommand)
	var response utils.JsonResponse
	if err != nil {
		response = utils.ResponseError(controller.Ctx, err)
	} else {
		response = utils.ResponseData(controller.Ctx, data)
	}
	controller.Data["json"] = response
	controller.ServeJSON()
}

// TODO 系统素币统计
func (controller *StatisticsController) SystemSuMoneyStatistics() {

}

// TODO 系统现金统计
func (controller *StatisticsController) SystemCashStatistics() {

}