作者 yangfu
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -11,29 +8,11 @@ type NoticeSettingAddCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// 消息对应的业务模块
Module string `json:"module" valid:"Required"`
Module string `json:"module"`
// 业务环节
ModuleAction string `json:"moduleAction" valid:"Required"`
ModuleAction string `json:"moduleAction"`
// 是否推送 【是:1】【否:2】
IsPush int `json:"isPush" valid:"Required"`
IsPush int `json:"isPush" `
// 内容模板
Content string `json:"content" valid:"Required"`
}
func (noticeSettingUpdateQuery *NoticeSettingAddCommand) Valid(validation *validation.Validation) {
}
func (noticeSettingUpdateQuery *NoticeSettingAddCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(noticeSettingUpdateQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
Content string `json:"content"`
}
... ...
package command
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
... ... @@ -13,29 +10,11 @@ type NoticeSettingUpdateCommand struct {
// id
NoticeSettingId string `json:"noticeSettingId"`
// 消息对应的业务模块
Module string `json:"module" valid:"Required"`
Module string `json:"module"`
// 业务环节
ModuleAction string `json:"moduleAction" valid:"Required"`
ModuleAction string `json:"moduleAction"`
// 是否推送 【是:1】【否:2】
IsPush int `json:"isPush" valid:"Required"`
IsPush int `json:"isPush"`
// 内容模板
Content string `json:"content" valid:"Required"`
}
func (noticeSettingUpdateQuery *NoticeSettingUpdateCommand) Valid(validation *validation.Validation) {
}
func (noticeSettingUpdateQuery *NoticeSettingUpdateCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(noticeSettingUpdateQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
Content string `json:"content"`
}
... ...
... ... @@ -30,7 +30,7 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingList(noticeSettin
Offset: 1,
Limit: 20,
CompanyId: int(noticeSettingListQuery.Operator.CompanyId),
IsOrg: 1,
IsOrg: 0,
MatchOrgName: noticeSettingListQuery.OrgName,
})
if err != nil {
... ... @@ -94,9 +94,6 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingProfile(noticeSet
// NoticeSettingUpdate 更新配置
func (noticeSettingService *NoticeSettingService) NoticeSettingUpdate(noticeSettingUpdateCommand *command.NoticeSettingUpdateCommand) (interface{}, error) {
if err := noticeSettingUpdateCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingUpdateCommand.Operator,
)
... ...