credit_account_controller.go 2.5 KB
package web_client

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/creditAccount/service"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
)

type CreditAccountController struct {
	baseController
}

//ListCreditAccount返回账期结算列表
func (controller *CreditAccountController) ListCreditAccount() {
	creditAccountService := service.NewCreditAccountService(nil)
	listQuery := &query.ListCreditAccountQuery{}
	err := controller.Unmarshal(listQuery)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	listQuery.Operator = controller.GetOperator()
	cnt, data, err := creditAccountService.ListCreditAccount(listQuery)
	controller.ReturnPageListData(cnt, data, err, listQuery.PageNumber)
}

//GetCreditAccount 返回账期结算详情
func (controller *CreditAccountController) GetCreditAccount() {
	creditAccountService := service.NewCreditAccountService(nil)
	creditAccountID, err := controller.GetInt(":creditAccountId")
	getQuery := &query.GetCreditAccountQuery{
		CreditAccountId: creditAccountID,
		Operator:        controller.GetOperator(),
	}
	data, err := creditAccountService.GetCreditAccount(getQuery)
	controller.Response(data, err)
}

//PayCreditAccount 支付账期结算
func (controller *CreditAccountController) PayCreditAccount() {
	creditAccountService := service.NewCreditAccountService(nil)
	payCreditAccountCommand := &command.PayCreditAccountCommand{}
	err := controller.Unmarshal(payCreditAccountCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	payCreditAccountCommand.Operator = controller.GetOperator()
	data, err := creditAccountService.PayCreditAccount(payCreditAccountCommand)
	controller.Response(data, err)
}

//RemoveCreditAccount 删除账期结算
func (controller *CreditAccountController) RemoveCreditAccount() {
	creditAccountService := service.NewCreditAccountService(nil)
	removeCreditAccountCommand := &command.RemoveCreditAccountCommand{}
	err := controller.Unmarshal(removeCreditAccountCommand)
	if err != nil {
		log.Logger.Debug("json err:" + err.Error())
	}
	removeCreditAccountCommand.Operator = controller.GetOperator()
	data, err := creditAccountService.RemoveCreditAccount(removeCreditAccountCommand)
	controller.Response(data, err)
}