作者 tangxuhui

添加 消息通知配置

1 -{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627890131470525700}  
  1 +{"D:\\workspaceGo\\src\\allied-creation-gateway\\pkg\\port\\beego\\routers":1627895012887669600}
@@ -11,7 +11,7 @@ type NoticeSettingUpdateCommand struct { @@ -11,7 +11,7 @@ type NoticeSettingUpdateCommand struct {
11 //操作人 11 //操作人
12 Operator domain.Operator `json:"-"` 12 Operator domain.Operator `json:"-"`
13 // id 13 // id
14 - NoticeSettingId string `json:"noticeSetting"` 14 + NoticeSettingId string `json:"noticeSettingId"`
15 // 消息对应的业务模块 15 // 消息对应的业务模块
16 Module string `json:"module" valid:"Required"` 16 Module string `json:"module" valid:"Required"`
17 // 业务环节 17 // 业务环节
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 +
  6 + "github.com/beego/beego/v2/core/validation"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
  8 +)
  9 +
  10 +type NoticeSettingGetQuery struct {
  11 + //操作人
  12 + Operator domain.Operator `json:"-"`
  13 + NoticeSettingId string `json:"noticeSettingId"`
  14 +}
  15 +
  16 +func (noticeSettingProfileQuery *NoticeSettingGetQuery) Valid(validation *validation.Validation) {
  17 +
  18 +}
  19 +
  20 +func (noticeSettingProfileQuery *NoticeSettingGetQuery) ValidateQuery() error {
  21 + valid := validation.Validation{}
  22 + b, err := valid.Valid(noticeSettingProfileQuery)
  23 + if err != nil {
  24 + return err
  25 + }
  26 + if !b {
  27 + for _, validErr := range valid.Errors {
  28 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  29 + }
  30 + }
  31 + return nil
  32 +}
@@ -38,8 +38,11 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingProfile(noticeSet @@ -38,8 +38,11 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingProfile(noticeSet
38 if err := noticeSettingProfileQuery.ValidateQuery(); err != nil { 38 if err := noticeSettingProfileQuery.ValidateQuery(); err != nil {
39 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 39 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
40 } 40 }
41 - //TODO  
42 - return nil, nil 41 + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
  42 + noticeSettingProfileQuery.Operator,
  43 + )
  44 + result, err := creationBasicGateway.NoticeSettingProfile(allied_creation_basic.ReqNoticeSettingProfile{})
  45 + return result, err
43 } 46 }
44 47
45 // NoticeSettingUpdate 更新配置 48 // NoticeSettingUpdate 更新配置
@@ -96,6 +99,25 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingAdd(noticeSetting @@ -96,6 +99,25 @@ func (noticeSettingService *NoticeSettingService) NoticeSettingAdd(noticeSetting
96 return data, nil 99 return data, nil
97 } 100 }
98 101
  102 +// NoticeSettingGet 获取配置
  103 +func (noticeSettingService *NoticeSettingService) NoticeSettingGet(noticeSettingGetQuery *query.NoticeSettingGetQuery) (interface{}, error) {
  104 + if err := noticeSettingGetQuery.ValidateQuery(); err != nil {
  105 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  106 + }
  107 + creationBasicGateway := allied_creation_basic.NewHttplibAlliedCreationBasic(
  108 + noticeSettingGetQuery.Operator,
  109 + )
  110 +
  111 + noticeSettingID, _ := strconv.Atoi(noticeSettingGetQuery.NoticeSettingId)
  112 + result, err := creationBasicGateway.NoticeSettingGet(allied_creation_basic.ReqNoticeSettingGet{
  113 + NoticeSettingID: noticeSettingID,
  114 + })
  115 + if err != nil {
  116 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  117 + }
  118 + return result, nil
  119 +}
  120 +
99 func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService { 121 func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService {
100 newNoticeSettingService := &NoticeSettingService{} 122 newNoticeSettingService := &NoticeSettingService{}
101 return newNoticeSettingService 123 return newNoticeSettingService
@@ -25,5 +25,4 @@ func NewHttplibAlliedCreationBasic(operator domain.Operator) *HttplibAlliedCreat @@ -25,5 +25,4 @@ func NewHttplibAlliedCreationBasic(operator domain.Operator) *HttplibAlliedCreat
25 }, 25 },
26 baseUrL: constant.ALLIED_CREATION_USER_HOST, 26 baseUrL: constant.ALLIED_CREATION_USER_HOST,
27 } 27 }
28 -  
29 } 28 }
@@ -73,7 +73,7 @@ func (gateway HttplibAlliedCreationBasic) NoticeSettingAdd(param ReqNoticeSettin @@ -73,7 +73,7 @@ func (gateway HttplibAlliedCreationBasic) NoticeSettingAdd(param ReqNoticeSettin
73 73
74 // NoticeSettingGet 返回编排消息通知内容 74 // NoticeSettingGet 返回编排消息通知内容
75 func (gateway HttplibAlliedCreationBasic) NoticeSettingGet(param ReqNoticeSettingGet) (*DataNoticeSettingGet, error) { 75 func (gateway HttplibAlliedCreationBasic) NoticeSettingGet(param ReqNoticeSettingGet) (*DataNoticeSettingGet, error) {
76 - url := gateway.baseUrL + "/notice-setting/" + strconv.Itoa(param.SettingId) 76 + url := gateway.baseUrL + "/notice-setting/" + strconv.Itoa(param.NoticeSettingID)
77 method := "GET" 77 method := "GET"
78 req := gateway.CreateRequest(url, method) 78 req := gateway.CreateRequest(url, method)
79 log.Logger.Debug("向基础模块请求数据:返回编排消息通知内容。", map[string]interface{}{ 79 log.Logger.Debug("向基础模块请求数据:返回编排消息通知内容。", map[string]interface{}{
@@ -132,3 +132,34 @@ func (gateway HttplibAlliedCreationBasic) NoticeSettingSearch(param ReqNoticeSet @@ -132,3 +132,34 @@ func (gateway HttplibAlliedCreationBasic) NoticeSettingSearch(param ReqNoticeSet
132 err = gateway.GetResponseData(result, &data) 132 err = gateway.GetResponseData(result, &data)
133 return &data, err 133 return &data, err
134 } 134 }
  135 +
  136 +// NoticeSettingProfile 编排消息通知可选配置列表
  137 +func (gateway HttplibAlliedCreationBasic) NoticeSettingProfile(param ReqNoticeSettingProfile) (*DataNoticeSettingProfile, error) {
  138 + url := gateway.baseUrL + "/notice-setting/profile/get"
  139 + method := "get"
  140 + req := gateway.CreateRequest(url, method)
  141 + log.Logger.Debug("向基础模块请求数据:编排消息通知可选配置列表。", map[string]interface{}{
  142 + "api": method + ":" + url,
  143 + "param": param,
  144 + })
  145 + req, err := req.JSONBody(param)
  146 + if err != nil {
  147 + return nil, fmt.Errorf("请求返回编排消息通知可选配置列表失败:%w", err)
  148 + }
  149 +
  150 + byteResult, err := req.Bytes()
  151 + if err != nil {
  152 + return nil, fmt.Errorf("获取返回编排消息通知可选配置列表失败:%w", err)
  153 + }
  154 + log.Logger.Debug("获取基础模块请求数据:返回编排消息通知可选配置列表。", map[string]interface{}{
  155 + "result": string(byteResult),
  156 + })
  157 + var result service_gateway.GatewayResponse
  158 + err = json.Unmarshal(byteResult, &result)
  159 + if err != nil {
  160 + return nil, fmt.Errorf("解析编排消息通知可选配置:%w", err)
  161 + }
  162 + var data DataNoticeSettingProfile
  163 + err = gateway.GetResponseData(result, &data)
  164 + return &data, err
  165 +}
@@ -48,7 +48,7 @@ type ( @@ -48,7 +48,7 @@ type (
48 //返回编排消息通知内容 48 //返回编排消息通知内容
49 type ( 49 type (
50 ReqNoticeSettingGet struct { 50 ReqNoticeSettingGet struct {
51 - SettingId int `json:"settingId"` 51 + NoticeSettingID int `json:"noticeSettingId"`
52 } 52 }
53 53
54 DataNoticeSettingGet struct { 54 DataNoticeSettingGet struct {
@@ -59,7 +59,6 @@ type ( @@ -59,7 +59,6 @@ type (
59 ModuleAction string `json:"moduleAction"` 59 ModuleAction string `json:"moduleAction"`
60 NoticeSettingID int `json:"noticeSettingId"` 60 NoticeSettingID int `json:"noticeSettingId"`
61 OrganizationID int `json:"organizationId"` 61 OrganizationID int `json:"organizationId"`
62 - SysCode string `json:"sysCode"`  
63 } 62 }
64 ) 63 )
65 64
@@ -85,3 +84,30 @@ type ( @@ -85,3 +84,30 @@ type (
85 } `json:"noticeSettings"` 84 } `json:"noticeSettings"`
86 } 85 }
87 ) 86 )
  87 +
  88 +type (
  89 + ReqNoticeSettingProfile struct {
  90 + }
  91 +
  92 + DataNoticeSettingProfile struct {
  93 + Module []struct {
  94 + ModuleCode string `json:"Code"`
  95 + Name string `json:"name"`
  96 + } `json:"module"`
  97 + ModuleAction []struct {
  98 + ModuleCode string `json:"module_code"`
  99 + ActionCode string `json:"action_Code"`
  100 + Name string `json:"name"`
  101 + } `json:"moduleAction"`
  102 + ParamList []struct {
  103 + // 变量的代码标识
  104 + ParamCode string `json:"paramCode"`
  105 + // 变量名称描述
  106 + ParamName string `json:"paramName"`
  107 + // 业务环节
  108 + ModuleAction string `json:"moduleAction"`
  109 + // 消息对应的业务模块
  110 + Module string `json:"module"`
  111 + } `json:"paramList"`
  112 + }
  113 +)
@@ -19,19 +19,13 @@ func (controller *NoticeSettingController) NoticeSettingList() { @@ -19,19 +19,13 @@ func (controller *NoticeSettingController) NoticeSettingList() {
19 controller.returnPageListData(cnt, data, err, noticeSettingListQuery.PageNumber) 19 controller.returnPageListData(cnt, data, err, noticeSettingListQuery.PageNumber)
20 } 20 }
21 21
22 -func (controller *NoticeSettingController) NoticeSettingProfile() {  
23 - noticeSettingService := service.NewNoticeSettingService(nil)  
24 - noticeSettingProfileQuery := &query.NoticeSettingProfileQuery{}  
25 - noticeSettingProfileQuery.Operator = controller.GetOperator()  
26 - data, err := noticeSettingService.NoticeSettingProfile(noticeSettingProfileQuery)  
27 - controller.Response(data, err)  
28 -}  
29 -  
30 func (controller *NoticeSettingController) NoticeSettingUpdate() { 22 func (controller *NoticeSettingController) NoticeSettingUpdate() {
31 noticeSettingService := service.NewNoticeSettingService(nil) 23 noticeSettingService := service.NewNoticeSettingService(nil)
32 noticeSettingUpdateCommand := &command.NoticeSettingUpdateCommand{} 24 noticeSettingUpdateCommand := &command.NoticeSettingUpdateCommand{}
  25 + settingId := controller.GetString(":settingId")
33 controller.Unmarshal(noticeSettingUpdateCommand) 26 controller.Unmarshal(noticeSettingUpdateCommand)
34 noticeSettingUpdateCommand.Operator = controller.GetOperator() 27 noticeSettingUpdateCommand.Operator = controller.GetOperator()
  28 + noticeSettingUpdateCommand.NoticeSettingId = settingId
35 data, err := noticeSettingService.NoticeSettingUpdate(noticeSettingUpdateCommand) 29 data, err := noticeSettingService.NoticeSettingUpdate(noticeSettingUpdateCommand)
36 controller.Response(data, err) 30 controller.Response(data, err)
37 } 31 }
@@ -44,3 +38,23 @@ func (controller *NoticeSettingController) NoticeSettingAdd() { @@ -44,3 +38,23 @@ func (controller *NoticeSettingController) NoticeSettingAdd() {
44 data, err := noticeSettingService.NoticeSettingAdd(noticeSettingAddCommand) 38 data, err := noticeSettingService.NoticeSettingAdd(noticeSettingAddCommand)
45 controller.Response(data, err) 39 controller.Response(data, err)
46 } 40 }
  41 +
  42 +func (controller *NoticeSettingController) NoticeSettingProfile() {
  43 + noticeSettingService := service.NewNoticeSettingService(nil)
  44 + p := &query.NoticeSettingProfileQuery{
  45 + Operator: controller.GetOperator(),
  46 + }
  47 + data, err := noticeSettingService.NoticeSettingProfile(p)
  48 + controller.Response(data, err)
  49 +}
  50 +
  51 +func (controller *NoticeSettingController) NoticeSettingGet() {
  52 + noticeSettingService := service.NewNoticeSettingService(nil)
  53 + queryParm := &query.NoticeSettingGetQuery{
  54 + Operator: controller.GetOperator(),
  55 + }
  56 + settingId := controller.GetString(":settingId")
  57 + queryParm.NoticeSettingId = settingId
  58 + data, err := noticeSettingService.NoticeSettingGet(queryParm)
  59 + controller.Response(data, err)
  60 +}
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 7
8 func init() { 8 func init() {
9 web.Router("/v1/web/notice-setting/search", &web_client.NoticeSettingController{}, "Post:NoticeSettingList") 9 web.Router("/v1/web/notice-setting/search", &web_client.NoticeSettingController{}, "Post:NoticeSettingList")
10 - web.Router("/v1/web/notice-setting/profile", &web_client.NoticeSettingController{}, "Get:NoticeSettingProfile")  
11 - web.Router("/v1/web/notice-setting/", &web_client.NoticeSettingController{}, "Put:NoticeSettingUpdate") 10 + web.Router("/v1/web/notice-setting/profile/get", &web_client.NoticeSettingController{}, "Get:NoticeSettingProfile")
  11 + web.Router("/v1/web/notice-setting/:settingId", &web_client.NoticeSettingController{}, "Get:NoticeSettingGet")
  12 + web.Router("/v1/web/notice-setting/:settingId", &web_client.NoticeSettingController{}, "Put:NoticeSettingUpdate")
12 } 13 }