notice_setting_controller.go 2.4 KB
package controllers

import (
	"github.com/linmadan/egglib-go/web/beego"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticeSetting/command"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticeSetting/query"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticeSetting/service"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain"
)

type NoticeSettingController struct {
	beego.BaseController
}

func (controller *NoticeSettingController) UpdateNoticeSetting() {
	noticeSettingService := service.NewNoticeSettingService(nil)
	updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{}
	controller.Unmarshal(updateNoticeSettingCommand)
	Id, _ := controller.GetInt64(":settingId")
	updateNoticeSettingCommand.NoticeSettingId = Id
	data, err := noticeSettingService.UpdateNoticeSetting(updateNoticeSettingCommand)
	controller.Response(data, err)
}

func (controller *NoticeSettingController) GetNoticeSetting() {
	noticeSettingService := service.NewNoticeSettingService(nil)
	getNoticeSettingQuery := &query.GetNoticeSettingQuery{}
	Id, _ := controller.GetInt64(":settingId")
	getNoticeSettingQuery.NoticeSettingId = Id
	data, err := noticeSettingService.GetNoticeSetting(getNoticeSettingQuery)
	controller.Response(data, err)
}

func (controller *NoticeSettingController) ListNoticeSetting() {
	noticeSettingService := service.NewNoticeSettingService(nil)
	listNoticeSettingQuery := &query.ListNoticeSettingQuery{}
	controller.Unmarshal(listNoticeSettingQuery)
	count, listdata, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery)
	data := map[string]interface{}{
		"noticeSettings": listdata,
		"count":          count,
	}
	controller.Response(data, err)
}

func (controller *NoticeSettingController) AddNoticeSetting() {
	noticeSettingService := service.NewNoticeSettingService(nil)
	addNoticeSettingCommand := &command.AddNoticeSettingCommand{}
	controller.Unmarshal(addNoticeSettingCommand)
	data, err := noticeSettingService.AddNoticeSetting(addNoticeSettingCommand)
	controller.Response(data, err)
}

func (controller *NoticeSettingController) NoticeSettingProfile() {
	data := map[string]interface{}{
		"module":       domain.GetNoticeModuleList(),
		"moduleAction": domain.GetNoticeModuleActionList(),
		"paramList":    domain.GetNoticeSettingParamList(""),
	}
	controller.Response(data, nil)
}