common_controller.go 1.7 KB
package controllers

import (
	"io/ioutil"

	//"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service"
)

type CommonController struct {
	BaseController
}

func (controller *CommonController) GetDictionaryByCode() {
	commonService := service.NewCommonService(nil)
	queryParam := &query.GetDictionaryByCodeQuery{}
	_ = controller.Unmarshal(queryParam)
	data, err := commonService.GetDictionaryByCode(queryParam)
	controller.Response(data, err)
}

func (controller *CommonController) LatestVersionInfo() {
	commonService := service.NewCommonService(nil)
	queryParam := &query.GetLatestVersionQuery{}
	_ = controller.Unmarshal(queryParam)
	queryParam.Request = controller.Ctx.Request
	queryParam.DeviceType = controller.GetDeviceType()
	data, err := commonService.LatestVersionInfo(queryParam)
	controller.Response(data, err)
}

func (controller *CommonController) AdvancedSetting() {
	commonService := service.NewCommonService(nil)
	queryParam := &query.GetAdvancedSettingQuery{}
	_ = controller.Unmarshal(queryParam)
	data, err := commonService.AdvancedSetting(queryParam)
	controller.Response(data, err)
}

func (controller *CommonController) AppSharing() {
	commonService := service.NewCommonService(nil)
	queryParam := &query.GetLatestVersionQuery{}
	_ = controller.Unmarshal(queryParam)
	queryParam.Request = controller.Ctx.Request
	queryParam.DeviceType = controller.GetDeviceType()
	data, err := commonService.AppSharing(queryParam)
	controller.Response(data, err)
}

func (controller *CommonController) LogData() {
	bytes, _ := ioutil.ReadFile("./app.log")
	controller.Ctx.WriteString(string(bytes))
}