作者 tangxuhui

更新

package domain
// 登录系统的操作人员 可以从头部中获取数据
type Operator struct {
UserId int64 `json:"userId"`
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserBaseId int64 `json:"userBaseId"`
}
... ...
package controllers
import (
"strconv"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain"
)
type baseController struct {
beego.BaseController
}
func (controller *baseController) GetUserId() int64 {
str := controller.Ctx.Input.Header("userId")
userId, _ := strconv.Atoi(str)
return int64(userId)
}
func (controller *baseController) GetCompanyId() int64 {
str := controller.Ctx.Input.Header("companyId")
companyId, _ := strconv.Atoi(str)
return int64(companyId)
}
func (controller *baseController) GetUserBaseId() int64 {
str := controller.Ctx.Input.Header("userBaseId")
userBaseId, _ := strconv.Atoi(str)
return int64(userBaseId)
}
func (controller *baseController) GetOrgId() int64 {
str := controller.Ctx.Input.Header("orgId")
orgId, _ := strconv.Atoi(str)
return int64(orgId)
}
func (controller *baseController) GetOperator() domain.Operator {
return domain.Operator{
UserId: controller.GetUserId(),
CompanyId: controller.GetCompanyId(),
OrgId: controller.GetOrgId(),
UserBaseId: controller.GetUserBaseId(),
}
}
... ...
... ... @@ -5,21 +5,13 @@ 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"
)
type NoticeSettingController struct {
beego.BaseController
}
func (controller *NoticeSettingController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
dataMap := map[string]interface{}{
"totalRow": count,
"pageNumber": pageNumber,
"list": data,
}
controller.Response(dataMap, err)
}
func (controller *NoticeSettingController) UpdateNoticeSetting() {
noticeSettingService := service.NewNoticeSettingService(nil)
updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{}
... ... @@ -44,7 +36,11 @@ func (controller *NoticeSettingController) ListNoticeSetting() {
listNoticeSettingQuery := &query.ListNoticeSettingQuery{}
controller.Unmarshal(listNoticeSettingQuery)
count, listdata, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery)
controller.returnPageListData(count, listdata, err, listNoticeSettingQuery.PageIndex)
data := map[string]interface{}{
"noticeSettings": listdata,
"count": count,
}
controller.Response(data, err)
}
func (controller *NoticeSettingController) AddNoticeSetting() {
... ... @@ -54,3 +50,12 @@ func (controller *NoticeSettingController) AddNoticeSetting() {
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)
}
... ...
... ... @@ -10,4 +10,5 @@ func init() {
web.Router("/notice-setting/:settingId", &controllers.NoticeSettingController{}, "Get:GetNoticeSetting")
web.Router("/notice-setting/search", &controllers.NoticeSettingController{}, "POST:ListNoticeSetting")
web.Router("/notice-setting", &controllers.NoticeSettingController{}, "Post:UpdateNoticeSetting")
web.Router("/notice-setting/profile/get", &controllers.NoticeSettingController{}, "Get:NoticeSettingProfile")
}
... ...