cooperation-mode_controller.go 3.1 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationMode/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationMode/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationMode/service"
)

type CooperationModeController struct {
	beego.BaseController
}

func (controller *CooperationModeController) CreateCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	createCooperationModeCommand := &command.CreateCooperationModeCommand{}
	controller.Unmarshal(createCooperationModeCommand)
	data, err := cooperationModeService.CreateCooperationMode(createCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) UpdateCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	updateCooperationModeCommand := &command.UpdateCooperationModeCommand{}
	controller.Unmarshal(updateCooperationModeCommand)
	cooperationModeId := controller.GetString(":cooperationModeId")
	updateCooperationModeCommand.CooperationModeId = cooperationModeId
	data, err := cooperationModeService.UpdateCooperationMode(updateCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) GetCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	getCooperationModeQuery := &query.GetCooperationModeQuery{}
	cooperationModeId, _ := controller.GetInt64(":cooperationModeId")
	getCooperationModeQuery.CooperationModeId = cooperationModeId
	data, err := cooperationModeService.GetCooperationMode(getCooperationModeQuery)
	controller.Response(data, err)
}

func (controller *CooperationModeController) RemoveCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	removeCooperationModeCommand := &command.RemoveCooperationModeCommand{}
	controller.Unmarshal(removeCooperationModeCommand)
	cooperationModeId, _ := controller.GetInt64(":cooperationModeId")
	removeCooperationModeCommand.CooperationModeId = cooperationModeId
	data, err := cooperationModeService.RemoveCooperationMode(removeCooperationModeCommand)
	controller.Response(data, err)
}

func (controller *CooperationModeController) SearchCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	searchCooperationModeQuery := &query.SearchCooperationModeQuery{}
	data, err := cooperationModeService.SearchCooperationMode(searchCooperationModeQuery)
	controller.Response(data, err)
}

func (controller *CooperationModeController) ListCooperationMode() {
	cooperationModeService := service.NewCooperationModeService(nil)
	listCooperationModeQuery := &query.ListCooperationModeQuery{}
	offset, _ := controller.GetInt("offset")
	listCooperationModeQuery.Offset = offset
	limit, _ := controller.GetInt("limit")
	listCooperationModeQuery.Limit = limit
	data, err := cooperationModeService.ListCooperationMode(listCooperationModeQuery)
	controller.Response(data, err)
}