access.go 3.0 KB
package controllers

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

type AccessController struct {
	BaseController
}

// CreateAccess
// CreateAccess execute command  create  Access
func (this *AccessController) CreateAccess() {
	var (
		msg     *protocol.ResponseMessage
		svr     = access.NewAccessService(nil)
		request *protocolx.CreateAccessRequest
	)
	defer func() {
		this.Resp(msg)
	}()
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, "")
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := svr.CreateAccess(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// UpdateAccess
// UpdateAccess execute command  update  Access
func (this *AccessController) UpdateAccess() {
	var (
		msg     *protocol.ResponseMessage
		svr     = access.NewAccessService(nil)
		request *protocolx.UpdateAccessRequest
	)
	defer func() {
		this.Resp(msg)
	}()
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, "")
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := svr.UpdateAccess(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// GetAccess
// GetAccess execute query  get  Access
func (this *AccessController) GetAccess() {
	var (
		msg     *protocol.ResponseMessage
		svr     = access.NewAccessService(nil)
		request *protocolx.GetAccessRequest
	)
	defer func() {
		this.Resp(msg)
	}()
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, "")
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := svr.GetAccess(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// DeleteAccess
// DeleteAccess execute command  delete  Access
func (this *AccessController) DeleteAccess() {
	var (
		msg     *protocol.ResponseMessage
		svr     = access.NewAccessService(nil)
		request *protocolx.DeleteAccessRequest
	)
	defer func() {
		this.Resp(msg)
	}()
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, "")
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := svr.DeleteAccess(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// ListAccess
// ListAccess execute query  list  Access
func (this *AccessController) ListAccess() {
	var (
		msg     *protocol.ResponseMessage
		svr     = access.NewAccessService(nil)
		request *protocolx.ListAccessRequest
	)
	defer func() {
		this.Resp(msg)
	}()
	if err := this.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, "")
		return
	}
	header := this.GetRequestHeader(this.Ctx)
	data, err := svr.ListAccess(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}