notice_setting_controller.go 2.7 KB
package controllers

import (
	"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"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/log"
)

type NoticeSettingController struct {
	baseController
}

func (controller *NoticeSettingController) UpdateNoticeSetting() {
	noticeSettingService := service.NewNoticeSettingService(nil)
	updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{}
	err := controller.Unmarshal(updateNoticeSettingCommand)
	if err != nil {
		log.Logger.Debug(err.Error())
	}
	Id, _ := controller.GetInt64(":settingId")
	updateNoticeSettingCommand.NoticeSettingId = Id
	// updateNoticeSettingCommand.CompanyId = controller.GetCompanyId()
	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{}
	err := controller.Unmarshal(listNoticeSettingQuery)
	if err != nil {
		log.Logger.Debug(err.Error())
	}
	// listNoticeSettingQuery.CompanyId = controller.GetCompanyId()
	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{}
	err := controller.Unmarshal(addNoticeSettingCommand)
	if err != nil {
		log.Logger.Debug(err.Error())
	}
	data, err := noticeSettingService.AddNoticeSetting(addNoticeSettingCommand)
	controller.Response(data, err)
}

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