作者 tangxuhui

添加 消息通知配置

{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627890131470525700}
\ No newline at end of file
{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627895012887669600}
\ No newline at end of file
... ...
... ... @@ -11,7 +11,7 @@ type NoticeSettingUpdateCommand struct {
//操作人
Operator domain.Operator `json:"-"`
// id
NoticeSettingId string `json:"noticeSetting"`
NoticeSettingId string `json:"noticeSettingId"`
// 消息对应的业务模块
Module string `json:"module" valid:"Required"`
// 业务环节
... ...
package query
import (
"fmt"
"github.com/beego/beego/v2/core/validation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
)
type NoticeSettingGetQuery struct {
//操作人
Operator domain.Operator `json:"-"`
NoticeSettingId string `json:"noticeSettingId"`
}
func (noticeSettingProfileQuery *NoticeSettingGetQuery) Valid(validation *validation.Validation) {
}
func (noticeSettingProfileQuery *NoticeSettingGetQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(noticeSettingProfileQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -38,8 +38,11 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingProfile(noticeSet
if err := noticeSettingProfileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
//TODO
return nil, nil
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingProfileQuery.Operator,
)
result, err := creationBasicGateway.NoticeSettingProfile(allied_creation_basic.ReqNoticeSettingProfile{})
return result, err
}
// NoticeSettingUpdate 更新配置
... ... @@ -96,6 +99,25 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingAdd(noticeSetting
return data, nil
}
// NoticeSettingGet 获取配置
func (noticeSettingService *NoticeSettingService) NoticeSettingGet(noticeSettingGetQuery *query.NoticeSettingGetQuery) (interface{}, error) {
if err := noticeSettingGetQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
noticeSettingGetQuery.Operator,
)
noticeSettingID, _ := strconv.Atoi(noticeSettingGetQuery.NoticeSettingId)
result, err := creationBasicGateway.NoticeSettingGet(allied_creation_basic.ReqNoticeSettingGet{
NoticeSettingID: noticeSettingID,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return result, nil
}
func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService {
newNoticeSettingService := &NoticeSettingService{}
return newNoticeSettingService
... ...
... ... @@ -25,5 +25,4 @@ func NewHttplibAlliedCreationBasic(operator domain.Operator) *HttplibAlliedCreat
},
baseUrL: constant.ALLIED_CREATION_USER_HOST,
}
}
... ...
... ... @@ -73,7 +73,7 @@ func (gateway HttplibAlliedCreationBasic) NoticeSettingAdd(param ReqNoticeSettin
// NoticeSettingGet 返回编排消息通知内容
func (gateway HttplibAlliedCreationBasic) NoticeSettingGet(param ReqNoticeSettingGet) (*DataNoticeSettingGet, error) {
url := gateway.baseUrL + "/notice-setting/" + strconv.Itoa(param.SettingId)
url := gateway.baseUrL + "/notice-setting/" + strconv.Itoa(param.NoticeSettingID)
method := "GET"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向基础模块请求数据:返回编排消息通知内容。", map[string]interface{}{
... ... @@ -132,3 +132,34 @@ func (gateway HttplibAlliedCreationBasic) NoticeSettingSearch(param ReqNoticeSet
err = gateway.GetResponseData(result, &data)
return &data, err
}
// NoticeSettingProfile 编排消息通知可选配置列表
func (gateway HttplibAlliedCreationBasic) NoticeSettingProfile(param ReqNoticeSettingProfile) (*DataNoticeSettingProfile, error) {
url := gateway.baseUrL + "/notice-setting/profile/get"
method := "get"
req := gateway.CreateRequest(url, method)
log.Logger.Debug("向基础模块请求数据:编排消息通知可选配置列表。", map[string]interface{}{
"api": method + ":" + url,
"param": param,
})
req, err := req.JSONBody(param)
if err != nil {
return nil, fmt.Errorf("请求返回编排消息通知可选配置列表失败:%w", err)
}
byteResult, err := req.Bytes()
if err != nil {
return nil, fmt.Errorf("获取返回编排消息通知可选配置列表失败:%w", err)
}
log.Logger.Debug("获取基础模块请求数据:返回编排消息通知可选配置列表。", map[string]interface{}{
"result": string(byteResult),
})
var result service_gateway.GatewayResponse
err = json.Unmarshal(byteResult, &result)
if err != nil {
return nil, fmt.Errorf("解析编排消息通知可选配置:%w", err)
}
var data DataNoticeSettingProfile
err = gateway.GetResponseData(result, &data)
return &data, err
}
... ...
... ... @@ -48,7 +48,7 @@ type (
//返回编排消息通知内容
type (
ReqNoticeSettingGet struct {
SettingId int `json:"settingId"`
NoticeSettingID int `json:"noticeSettingId"`
}
DataNoticeSettingGet struct {
... ... @@ -59,7 +59,6 @@ type (
ModuleAction string `json:"moduleAction"`
NoticeSettingID int `json:"noticeSettingId"`
OrganizationID int `json:"organizationId"`
SysCode string `json:"sysCode"`
}
)
... ... @@ -85,3 +84,30 @@ type (
} `json:"noticeSettings"`
}
)
type (
ReqNoticeSettingProfile struct {
}
DataNoticeSettingProfile struct {
Module []struct {
ModuleCode string `json:"Code"`
Name string `json:"name"`
} `json:"module"`
ModuleAction []struct {
ModuleCode string `json:"module_code"`
ActionCode string `json:"action_Code"`
Name string `json:"name"`
} `json:"moduleAction"`
ParamList []struct {
// 变量的代码标识
ParamCode string `json:"paramCode"`
// 变量名称描述
ParamName string `json:"paramName"`
// 业务环节
ModuleAction string `json:"moduleAction"`
// 消息对应的业务模块
Module string `json:"module"`
} `json:"paramList"`
}
)
... ...
... ... @@ -19,19 +19,13 @@ func (controller *NoticeSettingController) NoticeSettingList() {
controller.returnPageListData(cnt, data, err, noticeSettingListQuery.PageNumber)
}
func (controller *NoticeSettingController) NoticeSettingProfile() {
noticeSettingService := service.NewNoticeSettingService(nil)
noticeSettingProfileQuery := &query.NoticeSettingProfileQuery{}
noticeSettingProfileQuery.Operator = controller.GetOperator()
data, err := noticeSettingService.NoticeSettingProfile(noticeSettingProfileQuery)
controller.Response(data, err)
}
func (controller *NoticeSettingController) NoticeSettingUpdate() {
noticeSettingService := service.NewNoticeSettingService(nil)
noticeSettingUpdateCommand := &command.NoticeSettingUpdateCommand{}
settingId := controller.GetString(":settingId")
controller.Unmarshal(noticeSettingUpdateCommand)
noticeSettingUpdateCommand.Operator = controller.GetOperator()
noticeSettingUpdateCommand.NoticeSettingId = settingId
data, err := noticeSettingService.NoticeSettingUpdate(noticeSettingUpdateCommand)
controller.Response(data, err)
}
... ... @@ -44,3 +38,23 @@ func (controller *NoticeSettingController) NoticeSettingAdd() {
data, err := noticeSettingService.NoticeSettingAdd(noticeSettingAddCommand)
controller.Response(data, err)
}
func (controller *NoticeSettingController) NoticeSettingProfile() {
noticeSettingService := service.NewNoticeSettingService(nil)
p := &query.NoticeSettingProfileQuery{
Operator: controller.GetOperator(),
}
data, err := noticeSettingService.NoticeSettingProfile(p)
controller.Response(data, err)
}
func (controller *NoticeSettingController) NoticeSettingGet() {
noticeSettingService := service.NewNoticeSettingService(nil)
queryParm := &query.NoticeSettingGetQuery{
Operator: controller.GetOperator(),
}
settingId := controller.GetString(":settingId")
queryParm.NoticeSettingId = settingId
data, err := noticeSettingService.NoticeSettingGet(queryParm)
controller.Response(data, err)
}
... ...
... ... @@ -7,6 +7,7 @@ import (
func init() {
web.Router("/v1/web/notice-setting/search", &web_client.NoticeSettingController{}, "Post:NoticeSettingList")
web.Router("/v1/web/notice-setting/profile", &web_client.NoticeSettingController{}, "Get:NoticeSettingProfile")
web.Router("/v1/web/notice-setting/", &web_client.NoticeSettingController{}, "Put:NoticeSettingUpdate")
web.Router("/v1/web/notice-setting/profile/get", &web_client.NoticeSettingController{}, "Get:NoticeSettingProfile")
web.Router("/v1/web/notice-setting/:settingId", &web_client.NoticeSettingController{}, "Get:NoticeSettingGet")
web.Router("/v1/web/notice-setting/:settingId", &web_client.NoticeSettingController{}, "Put:NoticeSettingUpdate")
}
... ...