partner_info.go 2.1 KB
package controllers

import (
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/command"
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/query"
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/partnerInfo/service"
)

type PartnerInfoController struct {
	BaseController
}

//CreatePartnerInfo 创建合伙人
func (controller *PartnerInfoController) CreatePartnerInfo() {
	var (
		service = service.NewPartnerInfoService(nil)
		command = &command.CreatePartnerInfoCommand{}
	)
	controller.JsonUnmarshal(command)
	controller.HandlerResponse(service.CreatePartnerInfo(command))
}

//UpdatePartnerInfo 更新合伙人
func (controller *PartnerInfoController) UpdatePartnerInfo() {
	var (
		service = service.NewPartnerInfoService(nil)
		command = &command.UpdatePartnerInfoCommand{}
	)
	controller.JsonUnmarshal(command)
	id, _ := controller.GetInt(":id")
	command.Id = id
	controller.HandlerResponse(service.UpdatePartnerInfo(command))
}

//GetPartnerInfo 获取合伙人
func (controller *PartnerInfoController) GetPartnerInfo() {
	var (
		service = service.NewPartnerInfoService(nil)
		command = &query.GetPartnerInfoQuery{}
	)
	uid, _ := controller.GetInt(":id")
	command.Id = uid
	controller.HandlerResponse(service.GetPartnerInfo(command))
}

//GetPartnerInfo 移除合伙人
func (controller *PartnerInfoController) RemovePartnerInfo() {
	var (
		service = service.NewPartnerInfoService(nil)
		command = &command.RemovePartnerInfoCommand{}
	)
	uid, _ := controller.GetInt(":id")
	command.Id = uid
	controller.HandlerResponse(service.RemovePartnerInfo(command))
}

//ListPartnerInfo 合伙人列表
func (controller *PartnerInfoController) ListPartnerInfo() {
	var (
		service = service.NewPartnerInfoService(nil)
		command = &query.ListPartnerInfoQuery{}
	)
	command.PartnerCategory, _ = controller.GetInt("partnerCategory")
	command.Status, _ = controller.GetInt("status")
	command.SortByCreateTime = controller.GetString("sortByCreateTime")
	command.SortByUpdateTime = controller.GetString("sortByUpdateTime")
	command.Offset, command.Limit = controller.GetLimitInfo()
	controller.HandlerResponse(service.ListPartnerInfo(command))
}