company.go 2.3 KB
package controllers

import (
	"github.com/tiptok/gocomm/pkg/log"
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/company"
	"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
	protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
)

type CompanyController struct {
	BaseController
}

// Property
// 测试
func (this *CompanyController) Property() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocolx.PropertyRequest
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := company.Property(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewReturnResponse(data, err)
}

// Partners
// 测试
func (this *CompanyController) Partners() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocolx.PartnersRequest
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := company.Partners(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewReturnResponse(data, err)
}

// Partners
// 测试
func (this *CompanyController) PartnersV2() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocolx.PartnersRequest
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := company.PartnersV2(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewReturnResponse(data, err)
}

// Statistics
// 测试
func (this *CompanyController) Statistics() {
	var msg *protocol.ResponseMessage
	defer func() {
		this.Resp(msg)
	}()
	var request *protocolx.StatisticsRequest
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.BadRequestParam(1)
		return
	}
	if b, m := this.Valid(request); !b {
		msg = m
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := company.Statistics(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewReturnResponse(data, err)
}