su_money_controller.go 4.9 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/suMoney/command"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
	"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
)

type SuMoneyController struct {
	beego.Controller
}

func (controller *SuMoneyController) OperationSuMoney() {
	suMoneyService := service.NewSuMoneyService(nil)
	operationSuMoneyCommand := &command.OperationSuMoneyCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), operationSuMoneyCommand)
	data, err := suMoneyService.OperationSuMoney(operationSuMoneyCommand)
	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 *SuMoneyController) GetSuMoneyTransactionRecord() {
	suMoneyService := service.NewSuMoneyService(nil)
	getSuMoneyTransactionRecordQuery := &query.GetSuMoneyTransactionRecordQuery{}
	suMoneyTransactionRecordId, _ := controller.GetInt64(":suMoneyTransactionRecordId")
	getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId = suMoneyTransactionRecordId
	data, err := suMoneyService.GetSuMoneyTransactionRecord(getSuMoneyTransactionRecordQuery)
	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 *SuMoneyController) ExchangeSuMoney() {
	suMoneyService := service.NewSuMoneyService(nil)
	exchangeSuMoneyCommand := &command.ExchangeSuMoneyCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), exchangeSuMoneyCommand)
	data, err := suMoneyService.ExchangeSuMoney(exchangeSuMoneyCommand)
	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 *SuMoneyController) SearchSuMoneyTransactionRecord() {
	suMoneyService := service.NewSuMoneyService(nil)
	searchSuMoneyTransactionRecordCommand := &command.SearchSuMoneyTransactionRecordCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), searchSuMoneyTransactionRecordCommand)
	data, err := suMoneyService.SearchSuMoneyTransactionRecord(searchSuMoneyTransactionRecordCommand)
	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 *SuMoneyController) SuMoneyTransactionRecordStatistics() {
	suMoneyService := service.NewSuMoneyService(nil)
	suMoneyTransactionRecordStatisticsCommand := &command.SuMoneyTransactionRecordStatisticsCommand{}
	json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), suMoneyTransactionRecordStatisticsCommand)
	data, err := suMoneyService.SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand)
	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 *SuMoneyController) CashInput() {

}

/**
 * 返回兑换活动列表
 */
func (controller *SuMoneyController) ListExchangeActivities () {

}

/**
 * 更新兑换活动信息
 */
func (controller *SuMoneyController) UpdateExchangeActivities () {

}

/**
 * 新增兑换活动
 */
func (controller *SuMoneyController) CreateExchangeActivities ()  {

}

/**
 * 删除兑换活动
 */
func (controller *SuMoneyController) RemoveExchangeActivities () {

}

/**
 * 搜索兑换素币活动
 */
func (controller *SuMoneyController) searchExchangeActivities () {

}

/**
 * 兑换活动数据统计
 */
func (controller *SuMoneyController) exchangeActivitiesStatistics () {

}

/**
 * 获取素币兑换清单
 */
func (controller *SuMoneyController) ListExchangeList () {

}

/**
 * 新增素币兑换清单
 */
func (controller *SuMoneyController) CreateExchangeList () {

}

/**
 * 更新素币兑换清单
 */
func (controller *SuMoneyController) UpdateExchangeList ()  {

}

/**
 * 删除素币兑换清单
 */
func (controller *SuMoneyController) RemoveExchangeList () {

}

/**
 * 搜索素币兑换清单
 */
func (controller *SuMoneyController) searchExchangeList () {

}

/**
 * 导出素币兑换清单
 */
func (controller *SuMoneyController) ExportExchangeList () {

}

/**
 * 导入素币兑换清单
 */
func (controller *SuMoneyController) ImportExchangeList () {

}