operator_log.go 3.6 KB
package controllers

import (
	"github.com/tiptok/gocomm/pkg/log"
	"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/operatorLog/command"
	"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/operatorLog/query"
	"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/operatorLog/service"
	"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
)

type OperatorLogController struct {
	BaseController
}

// CreateOperatorLog
// CreateOperatorLog execute command  create  OperatorLog
func (controller *OperatorLogController) CreateOperatorLog() {
	var (
		msg     *protocol.ResponseMessage
		svr     = service.NewOperatorLogService(nil)
		request *command.CreateOperatorLogRequest
	)
	defer func() {
		controller.Resp(msg)
	}()
	if err := controller.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, err.Error())
		return
	}
	header := controller.GetRequestHeader(controller.Ctx)
	data, err := svr.CreateOperatorLog(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// UpdateOperatorLog
// UpdateOperatorLog execute command  update  OperatorLog
func (controller *OperatorLogController) UpdateOperatorLog() {
	var (
		msg     *protocol.ResponseMessage
		svr     = service.NewOperatorLogService(nil)
		request *command.UpdateOperatorLogRequest
	)
	defer func() {
		controller.Resp(msg)
	}()
	if err := controller.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, err.Error())
		return
	}
	header := controller.GetRequestHeader(controller.Ctx)
	data, err := svr.UpdateOperatorLog(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// GetOperatorLog
// GetOperatorLog execute query  get  OperatorLog
func (controller *OperatorLogController) GetOperatorLog() {
	var (
		msg     *protocol.ResponseMessage
		svr     = service.NewOperatorLogService(nil)
		request *query.GetOperatorLogRequest
	)
	defer func() {
		controller.Resp(msg)
	}()
	if err := controller.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, err.Error())
		return
	}
	header := controller.GetRequestHeader(controller.Ctx)
	data, err := svr.GetOperatorLog(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// DeleteOperatorLog
// DeleteOperatorLog execute command  delete  OperatorLog
func (controller *OperatorLogController) DeleteOperatorLog() {
	var (
		msg     *protocol.ResponseMessage
		svr     = service.NewOperatorLogService(nil)
		request *command.DeleteOperatorLogRequest
	)
	defer func() {
		controller.Resp(msg)
	}()
	if err := controller.JsonUnmarshal(&request); err != nil {
		msg = protocol.NewResponseMessage(2, err.Error())
		return
	}
	header := controller.GetRequestHeader(controller.Ctx)
	data, err := svr.DeleteOperatorLog(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}

// ListOperatorLog
// ListOperatorLog execute query  list  OperatorLog
func (controller *OperatorLogController) ListOperatorLog() {
	var (
		msg     *protocol.ResponseMessage
		svr     = service.NewOperatorLogService(nil)
		request = &query.ListOperatorLogRequest{}
	)
	defer func() {
		controller.Resp(msg)
	}()
	//if err := controller.JsonUnmarshal(&request); err != nil {
	//	msg = protocol.NewResponseMessage(2,err.Error())
	//	return
	//}
	request.Offset, request.Limit = controller.GetLimitInfo()
	request.ResourceId, _ = controller.GetInt64("resourceId")
	header := controller.GetRequestHeader(controller.Ctx)
	data, err := svr.ListOperatorLog(header, request)
	if err != nil {
		log.Error(err)
	}
	msg = protocol.NewResponseMessageData(data, err)
}