正在显示
12 个修改的文件
包含
301 行增加
和
30 行删除
@@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
7 | ) | 7 | ) |
8 | 8 | ||
9 | type ListDictionaryQuery struct { | 9 | type ListDictionaryQuery struct { |
10 | - // 查询偏离量 | 10 | + // 查询页码 |
11 | Pageindex int `json:"pageIndex"` | 11 | Pageindex int `json:"pageIndex"` |
12 | // 查询限制 | 12 | // 查询限制 |
13 | PageSize int `json:"pageSize" valid:"Required"` | 13 | PageSize int `json:"pageSize" valid:"Required"` |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/beego/beego/v2/core/validation" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain" | ||
8 | +) | ||
9 | + | ||
10 | +type AddNoticeSettingCommand struct { | ||
11 | + // 公司id | ||
12 | + CompanyId int64 `json:"companyId"` | ||
13 | + // 内容模板 | ||
14 | + Content string `json:"content"` | ||
15 | + // 是否推送 【是:1】【否:2】 | ||
16 | + IsPush int `json:"isPush"` | ||
17 | + // 消息对应的业务模块 | ||
18 | + Module string `json:"module"` | ||
19 | + // 业务环节 | ||
20 | + ModuleAction string `json:"moduleAction"` | ||
21 | + // 组织id | ||
22 | + OrgId int64 `json:"orgId"` | ||
23 | + // 消息对应的编码 | ||
24 | + SysCode string `json:"sysCode"` | ||
25 | +} | ||
26 | + | ||
27 | +func (addNoticeSettingCommand *AddNoticeSettingCommand) Valid(v *validation.Validation) { | ||
28 | + ok := domain.ValidNoticeModule(addNoticeSettingCommand.Module) | ||
29 | + if ok { | ||
30 | + v.SetError("Module", "不是规定的值") | ||
31 | + } | ||
32 | + //检查消息编码 | ||
33 | + ok = domain.ValidNoticeModuleAction(addNoticeSettingCommand.Module, addNoticeSettingCommand.ModuleAction) | ||
34 | + if !ok { | ||
35 | + v.SetError("ModuleAction", "不是规定的值") | ||
36 | + } | ||
37 | +} | ||
38 | + | ||
39 | +func (addNoticeSettingCommand *AddNoticeSettingCommand) ValidateCommand() error { | ||
40 | + valid := validation.Validation{} | ||
41 | + b, err := valid.Valid(addNoticeSettingCommand) | ||
42 | + if err != nil { | ||
43 | + return err | ||
44 | + } | ||
45 | + if !b { | ||
46 | + for _, validErr := range valid.Errors { | ||
47 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
48 | + } | ||
49 | + } | ||
50 | + return nil | ||
51 | +} |
@@ -4,9 +4,11 @@ import ( | @@ -4,9 +4,11 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | 5 | ||
6 | "github.com/beego/beego/v2/core/validation" | 6 | "github.com/beego/beego/v2/core/validation" |
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/domain" | ||
7 | ) | 8 | ) |
8 | 9 | ||
9 | type UpdateNoticeSettingCommand struct { | 10 | type UpdateNoticeSettingCommand struct { |
11 | + //id | ||
10 | NoticeSettingId int64 `json:"noticeSettingId"` | 12 | NoticeSettingId int64 `json:"noticeSettingId"` |
11 | // 公司id | 13 | // 公司id |
12 | CompanyId int64 `json:"companyId"` | 14 | CompanyId int64 `json:"companyId"` |
@@ -19,13 +21,22 @@ type UpdateNoticeSettingCommand struct { | @@ -19,13 +21,22 @@ type UpdateNoticeSettingCommand struct { | ||
19 | // 业务环节 | 21 | // 业务环节 |
20 | ModuleAction string `json:"moduleAction"` | 22 | ModuleAction string `json:"moduleAction"` |
21 | // 组织id | 23 | // 组织id |
22 | - OrganizationId int64 `json:"organizationId"` | 24 | + OrgId int64 `json:"orgId"` |
23 | // 消息对应的编码 | 25 | // 消息对应的编码 |
24 | SysCode string `json:"sysCode"` | 26 | SysCode string `json:"sysCode"` |
25 | } | 27 | } |
26 | 28 | ||
27 | -func (updateNoticeSettingCommand *UpdateNoticeSettingCommand) Valid(validation *validation.Validation) { | ||
28 | - validation.SetError("CustomValid", "未实现的自定义认证") | 29 | +func (updateNoticeSettingCommand *UpdateNoticeSettingCommand) Valid(v *validation.Validation) { |
30 | + ok := domain.ValidNoticeModule(updateNoticeSettingCommand.Module) | ||
31 | + if ok { | ||
32 | + v.SetError("Module", "不是规定的值") | ||
33 | + } | ||
34 | + //检查消息编码 | ||
35 | + ok = domain.ValidNoticeModuleAction(updateNoticeSettingCommand.Module, updateNoticeSettingCommand.ModuleAction) | ||
36 | + if !ok { | ||
37 | + v.SetError("ModuleAction", "不是规定的值") | ||
38 | + } | ||
39 | + | ||
29 | } | 40 | } |
30 | 41 | ||
31 | func (updateNoticeSettingCommand *UpdateNoticeSettingCommand) ValidateCommand() error { | 42 | func (updateNoticeSettingCommand *UpdateNoticeSettingCommand) ValidateCommand() error { |
@@ -8,13 +8,15 @@ import ( | @@ -8,13 +8,15 @@ import ( | ||
8 | 8 | ||
9 | type ListNoticeSettingQuery struct { | 9 | type ListNoticeSettingQuery struct { |
10 | // 查询偏离量 | 10 | // 查询偏离量 |
11 | - Offset int `json:"offset" valid:"Required"` | 11 | + PageIndex int `json:"offset" valid:"Required"` |
12 | // 查询限制 | 12 | // 查询限制 |
13 | - Limit int `json:"limit" valid:"Required"` | 13 | + PageSize int `json:"limit" valid:"Required"` |
14 | + CompanyId int64 `json:"companyId" valid:"Required"` | ||
15 | + OrgId int64 `json:"orgId"` | ||
14 | } | 16 | } |
15 | 17 | ||
16 | func (listNoticeSettingQuery *ListNoticeSettingQuery) Valid(validation *validation.Validation) { | 18 | func (listNoticeSettingQuery *ListNoticeSettingQuery) Valid(validation *validation.Validation) { |
17 | - validation.SetError("CustomValid", "未实现的自定义认证") | 19 | + |
18 | } | 20 | } |
19 | 21 | ||
20 | func (listNoticeSettingQuery *ListNoticeSettingQuery) ValidateQuery() error { | 22 | func (listNoticeSettingQuery *ListNoticeSettingQuery) ValidateQuery() error { |
@@ -2,6 +2,7 @@ package service | @@ -2,6 +2,7 @@ package service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "time" | ||
5 | 6 | ||
6 | "github.com/linmadan/egglib-go/core/application" | 7 | "github.com/linmadan/egglib-go/core/application" |
7 | "github.com/linmadan/egglib-go/utils/tool_funs" | 8 | "github.com/linmadan/egglib-go/utils/tool_funs" |
@@ -38,12 +39,14 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett | @@ -38,12 +39,14 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett | ||
38 | } else { | 39 | } else { |
39 | noticeSettingRepository = value | 40 | noticeSettingRepository = value |
40 | } | 41 | } |
41 | - noticeSetting, err := noticeSettingRepository.FindOne(map[string]interface{}{"noticeSettingId": getNoticeSettingQuery.NoticeSettingId}) | 42 | + noticeSetting, err := noticeSettingRepository.FindOne(map[string]interface{}{ |
43 | + "noticeSettingId": getNoticeSettingQuery.NoticeSettingId, | ||
44 | + }) | ||
42 | if err != nil { | 45 | if err != nil { |
43 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 46 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
44 | } | 47 | } |
45 | if noticeSetting == nil { | 48 | if noticeSetting == nil { |
46 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getNoticeSettingQuery.NoticeSettingId))) | 49 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%d", getNoticeSettingQuery.NoticeSettingId)) |
47 | } else { | 50 | } else { |
48 | if err := transactionContext.CommitTransaction(); err != nil { | 51 | if err := transactionContext.CommitTransaction(); err != nil { |
49 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 52 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -53,6 +56,7 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett | @@ -53,6 +56,7 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett | ||
53 | } | 56 | } |
54 | 57 | ||
55 | // 返回编排消息通知内容列表 | 58 | // 返回编排消息通知内容列表 |
59 | +// 检查初始化消息列表 | ||
56 | func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSettingQuery *query.ListNoticeSettingQuery) (interface{}, error) { | 60 | func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSettingQuery *query.ListNoticeSettingQuery) (interface{}, error) { |
57 | if err := listNoticeSettingQuery.ValidateQuery(); err != nil { | 61 | if err := listNoticeSettingQuery.ValidateQuery(); err != nil { |
58 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 62 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -111,15 +115,42 @@ func (noticeSettingService *NoticeSettingService) UpdateNoticeSetting(updateNoti | @@ -111,15 +115,42 @@ func (noticeSettingService *NoticeSettingService) UpdateNoticeSetting(updateNoti | ||
111 | } else { | 115 | } else { |
112 | noticeSettingRepository = value | 116 | noticeSettingRepository = value |
113 | } | 117 | } |
114 | - | ||
115 | - noticeSetting, err := noticeSettingRepository.FindOne(map[string]interface{}{"noticeSettingId": updateNoticeSettingCommand.NoticeSettingId}) | 118 | + var ( |
119 | + noticeSettings []*domain.NoticeSetting | ||
120 | + noticeSetting *domain.NoticeSetting | ||
121 | + ) | ||
122 | + _, noticeSettings, err = noticeSettingRepository.Find(map[string]interface{}{ | ||
123 | + "companyId": updateNoticeSettingCommand.CompanyId, | ||
124 | + "orgId": updateNoticeSettingCommand.OrgId, | ||
125 | + "moduleAction": updateNoticeSettingCommand.ModuleAction, | ||
126 | + }) | ||
116 | if err != nil { | 127 | if err != nil { |
117 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 128 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
118 | } | 129 | } |
119 | - if noticeSetting == nil { | ||
120 | - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateNoticeSettingCommand.NoticeSettingId))) | 130 | + if len(noticeSettings) > 1 { |
131 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "配置信息重复") | ||
132 | + } | ||
133 | + if len(noticeSettings) > 0 { | ||
134 | + //存在旧的数据 | ||
135 | + noticeSetting = noticeSettings[0] | ||
136 | + if noticeSetting.NoticeSettingId != updateNoticeSettingCommand.NoticeSettingId { | ||
137 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "配置信息已存在") | ||
138 | + } | ||
139 | + } | ||
140 | + noticeSetting, err = noticeSettingRepository.FindOne(map[string]interface{}{ | ||
141 | + "noticeSettingId": updateNoticeSettingCommand.NoticeSettingId, | ||
142 | + }) | ||
143 | + if err != nil { | ||
144 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
121 | } | 145 | } |
122 | - if err := noticeSetting.Update(tool_funs.SimpleStructToMap(updateNoticeSettingCommand)); err != nil { | 146 | + err = noticeSetting.Update(map[string]interface{}{ |
147 | + "content": updateNoticeSettingCommand.Content, | ||
148 | + "isPush": updateNoticeSettingCommand.IsPush, | ||
149 | + "module": updateNoticeSettingCommand.Module, | ||
150 | + "moduleAction": updateNoticeSettingCommand.ModuleAction, | ||
151 | + "updatedAt": time.Now(), | ||
152 | + }) | ||
153 | + if err != nil { | ||
123 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 154 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
124 | } | 155 | } |
125 | if noticeSetting, err := noticeSettingRepository.Save(noticeSetting); err != nil { | 156 | if noticeSetting, err := noticeSettingRepository.Save(noticeSetting); err != nil { |
@@ -132,6 +163,126 @@ func (noticeSettingService *NoticeSettingService) UpdateNoticeSetting(updateNoti | @@ -132,6 +163,126 @@ func (noticeSettingService *NoticeSettingService) UpdateNoticeSetting(updateNoti | ||
132 | } | 163 | } |
133 | } | 164 | } |
134 | 165 | ||
166 | +// 更新编排消息通知内容 | ||
167 | +func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSettingCommand *command.AddNoticeSettingCommand) (interface{}, error) { | ||
168 | + if err := addNoticeSettingCommand.ValidateCommand(); err != nil { | ||
169 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
170 | + } | ||
171 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
172 | + if err != nil { | ||
173 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
174 | + } | ||
175 | + if err := transactionContext.StartTransaction(); err != nil { | ||
176 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
177 | + } | ||
178 | + defer func() { | ||
179 | + transactionContext.RollbackTransaction() | ||
180 | + }() | ||
181 | + var noticeSettingRepository domain.NoticeSettingRepository | ||
182 | + if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{ | ||
183 | + "transactionContext": transactionContext, | ||
184 | + }); err != nil { | ||
185 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
186 | + } else { | ||
187 | + noticeSettingRepository = value | ||
188 | + } | ||
189 | + var ( | ||
190 | + noticeSettings []*domain.NoticeSetting | ||
191 | + noticeSetting *domain.NoticeSetting | ||
192 | + ) | ||
193 | + _, noticeSettings, err = noticeSettingRepository.Find(map[string]interface{}{ | ||
194 | + "companyId": addNoticeSettingCommand.CompanyId, | ||
195 | + "orgId": addNoticeSettingCommand.OrgId, | ||
196 | + "moduleAction": addNoticeSettingCommand.ModuleAction, | ||
197 | + }) | ||
198 | + if err != nil { | ||
199 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
200 | + } | ||
201 | + if len(noticeSettings) > 0 { | ||
202 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该环节配置已存在") | ||
203 | + } | ||
204 | + noticeSetting = &domain.NoticeSetting{ | ||
205 | + CompanyId: addNoticeSettingCommand.CompanyId, | ||
206 | + Content: addNoticeSettingCommand.Content, | ||
207 | + IsPush: addNoticeSettingCommand.IsPush, | ||
208 | + Module: addNoticeSettingCommand.Module, | ||
209 | + ModuleAction: addNoticeSettingCommand.ModuleAction, | ||
210 | + OrgId: addNoticeSettingCommand.OrgId, | ||
211 | + CreatedAt: time.Now(), | ||
212 | + UpdatedAt: time.Now(), | ||
213 | + } | ||
214 | + if noticeSetting, err := noticeSettingRepository.Save(noticeSetting); err != nil { | ||
215 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
216 | + } else { | ||
217 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
218 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
219 | + } | ||
220 | + return noticeSetting, nil | ||
221 | + } | ||
222 | +} | ||
223 | + | ||
224 | +// //InitNoticeSetting 为企业初始化消息列表,填充空白的消息模板 | ||
225 | +// func (noticeSettingService *NoticeSettingService) InitNoticeSetting(initCommand *command.InitNoticeSettingCommand) error { | ||
226 | +// if err := initCommand.ValidateCommand(); err != nil { | ||
227 | +// return application.ThrowError(application.ARG_ERROR, err.Error()) | ||
228 | +// } | ||
229 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
230 | +// if err != nil { | ||
231 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
232 | +// } | ||
233 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
234 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
235 | +// } | ||
236 | +// defer func() { | ||
237 | +// transactionContext.RollbackTransaction() | ||
238 | +// }() | ||
239 | +// var noticeSettingRepository domain.NoticeSettingRepository | ||
240 | +// if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{ | ||
241 | +// "transactionContext": transactionContext, | ||
242 | +// }); err != nil { | ||
243 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
244 | +// } else { | ||
245 | +// noticeSettingRepository = value | ||
246 | +// } | ||
247 | +// _, noticeSets, err := noticeSettingRepository.Find(map[string]interface{}{ | ||
248 | +// "companyId": initCommand.CompanyId, | ||
249 | +// "orgId": initCommand.OrgId, | ||
250 | +// }) | ||
251 | +// if err != nil { | ||
252 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
253 | +// } | ||
254 | +// notticeExist := make(map[string]int) | ||
255 | +// for i := range noticeSets { | ||
256 | +// notticeExist[noticeSets[i].ModuleAction] = 1 | ||
257 | +// } | ||
258 | +// defaultModuleAction := domain.GetNoticeModuleActionList() | ||
259 | +// newEmptySetting := []domain.NoticeSetting{} | ||
260 | +// for _, act := range defaultModuleAction { | ||
261 | +// if _, ok := notticeExist[act.ActionCode]; !ok { | ||
262 | +// newEmptySetting = append(newEmptySetting, domain.NoticeSetting{ | ||
263 | +// CompanyId: initCommand.CompanyId, | ||
264 | +// OrgId: initCommand.OrgId, | ||
265 | +// Module: act.ModuleCode, | ||
266 | +// ModuleAction: act.ActionCode, | ||
267 | +// CreatedAt: time.Now(), | ||
268 | +// UpdatedAt: time.Now(), | ||
269 | +// Content: "", | ||
270 | +// IsPush: domain.NoticeSettingIsNotPush, | ||
271 | +// }) | ||
272 | +// } | ||
273 | +// } | ||
274 | +// for i := range newEmptySetting { | ||
275 | +// _, err = noticeSettingRepository.Save(&newEmptySetting[i]) | ||
276 | +// if err != nil { | ||
277 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
278 | +// } | ||
279 | +// } | ||
280 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
281 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
282 | +// } | ||
283 | +// return nil | ||
284 | +// } | ||
285 | + | ||
135 | func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService { | 286 | func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService { |
136 | newNoticeSettingService := &NoticeSettingService{} | 287 | newNoticeSettingService := &NoticeSettingService{} |
137 | return newNoticeSettingService | 288 | return newNoticeSettingService |
@@ -17,7 +17,7 @@ type NoticeEmpty struct { | @@ -17,7 +17,7 @@ type NoticeEmpty struct { | ||
17 | } | 17 | } |
18 | 18 | ||
19 | type NoticeEmptyRepository interface { | 19 | type NoticeEmptyRepository interface { |
20 | - // Save(noticeEmpty *NoticeEmpty) (*NoticeEmpty, error) //用不到 | 20 | + Save(noticeEmpty *NoticeEmpty) (*NoticeEmpty, error) //用不到 |
21 | // Remove(noticeEmpty *NoticeEmpty) (*NoticeEmpty, error)//用户不到 | 21 | // Remove(noticeEmpty *NoticeEmpty) (*NoticeEmpty, error)//用户不到 |
22 | // FindOne(queryOptions map[string]interface{}) (*NoticeEmpty, error) //用不到 | 22 | // FindOne(queryOptions map[string]interface{}) (*NoticeEmpty, error) //用不到 |
23 | Find(queryOptions map[string]interface{}) (int64, []*NoticeEmpty, error) | 23 | Find(queryOptions map[string]interface{}) (int64, []*NoticeEmpty, error) |
@@ -2,6 +2,12 @@ package domain | @@ -2,6 +2,12 @@ package domain | ||
2 | 2 | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | +// 是否推送 【是:1】【否:2】 | ||
6 | +const ( | ||
7 | + NoticeSettingIsPush = 1 | ||
8 | + NoticeSettingIsNotPush = 2 | ||
9 | +) | ||
10 | + | ||
5 | // 编排消息通知内容 | 11 | // 编排消息通知内容 |
6 | type NoticeSetting struct { | 12 | type NoticeSetting struct { |
7 | // 消息id | 13 | // 消息id |
@@ -18,8 +24,6 @@ type NoticeSetting struct { | @@ -18,8 +24,6 @@ type NoticeSetting struct { | ||
18 | ModuleAction string `json:"moduleAction"` | 24 | ModuleAction string `json:"moduleAction"` |
19 | // 组织id | 25 | // 组织id |
20 | OrgId int64 `json:"orgId"` | 26 | OrgId int64 `json:"orgId"` |
21 | - // 消息对应的编码 | ||
22 | - SysCode string `json:"sysCode"` | ||
23 | // 创建时间 | 27 | // 创建时间 |
24 | CreatedAt time.Time `json:"createdAt"` | 28 | CreatedAt time.Time `json:"createdAt"` |
25 | // 删除时间 | 29 | // 删除时间 |
@@ -28,6 +32,8 @@ type NoticeSetting struct { | @@ -28,6 +32,8 @@ type NoticeSetting struct { | ||
28 | UpdatedAt time.Time `json:"updatedAt"` | 32 | UpdatedAt time.Time `json:"updatedAt"` |
29 | } | 33 | } |
30 | 34 | ||
35 | +//OrgId+ModuleAction 做唯一索引 | ||
36 | + | ||
31 | type NoticeSettingRepository interface { | 37 | type NoticeSettingRepository interface { |
32 | Save(noticeSetting *NoticeSetting) (*NoticeSetting, error) | 38 | Save(noticeSetting *NoticeSetting) (*NoticeSetting, error) |
33 | Remove(noticeSetting *NoticeSetting) (*NoticeSetting, error) | 39 | Remove(noticeSetting *NoticeSetting) (*NoticeSetting, error) |
@@ -64,9 +70,6 @@ func (noticeSetting *NoticeSetting) Update(data map[string]interface{}) error { | @@ -64,9 +70,6 @@ func (noticeSetting *NoticeSetting) Update(data map[string]interface{}) error { | ||
64 | if organizationId, ok := data["orgId"]; ok { | 70 | if organizationId, ok := data["orgId"]; ok { |
65 | noticeSetting.OrgId = organizationId.(int64) | 71 | noticeSetting.OrgId = organizationId.(int64) |
66 | } | 72 | } |
67 | - if sysCode, ok := data["sysCode"]; ok { | ||
68 | - noticeSetting.SysCode = sysCode.(string) | ||
69 | - } | ||
70 | if createdAt, ok := data["createdAt"]; ok { | 73 | if createdAt, ok := data["createdAt"]; ok { |
71 | noticeSetting.CreatedAt = createdAt.(time.Time) | 74 | noticeSetting.CreatedAt = createdAt.(time.Time) |
72 | } | 75 | } |
@@ -18,8 +18,6 @@ type NoticeSetting struct { | @@ -18,8 +18,6 @@ type NoticeSetting struct { | ||
18 | NoticeSettingId int64 | 18 | NoticeSettingId int64 |
19 | // 组织id | 19 | // 组织id |
20 | OrgId int64 | 20 | OrgId int64 |
21 | - // 消息对应的编码 | ||
22 | - SysCode string | ||
23 | // 创建时间 | 21 | // 创建时间 |
24 | CreatedAt time.Time | 22 | CreatedAt time.Time |
25 | // 删除时间 | 23 | // 删除时间 |
@@ -13,8 +13,7 @@ func TransformToNoticeSettingDomainModelFromPgModels(noticeSettingModel *models. | @@ -13,8 +13,7 @@ func TransformToNoticeSettingDomainModelFromPgModels(noticeSettingModel *models. | ||
13 | Module: noticeSettingModel.Module, | 13 | Module: noticeSettingModel.Module, |
14 | ModuleAction: noticeSettingModel.ModuleAction, | 14 | ModuleAction: noticeSettingModel.ModuleAction, |
15 | NoticeSettingId: noticeSettingModel.NoticeSettingId, | 15 | NoticeSettingId: noticeSettingModel.NoticeSettingId, |
16 | - OrganizationId: noticeSettingModel.OrganizationId, | ||
17 | - SysCode: noticeSettingModel.SysCode, | 16 | + OrgId: noticeSettingModel.OrgId, |
18 | CreatedAt: noticeSettingModel.CreatedAt, | 17 | CreatedAt: noticeSettingModel.CreatedAt, |
19 | DeletedAt: noticeSettingModel.DeletedAt, | 18 | DeletedAt: noticeSettingModel.DeletedAt, |
20 | UpdatedAt: noticeSettingModel.UpdatedAt, | 19 | UpdatedAt: noticeSettingModel.UpdatedAt, |
@@ -27,8 +27,7 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -27,8 +27,7 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
27 | "module", | 27 | "module", |
28 | "module_action", | 28 | "module_action", |
29 | "notice_setting_id", | 29 | "notice_setting_id", |
30 | - "organization_id", | ||
31 | - "sys_code", | 30 | + "org_id", |
32 | "created_at", | 31 | "created_at", |
33 | "deleted_at", | 32 | "deleted_at", |
34 | "updated_at", | 33 | "updated_at", |
@@ -55,7 +54,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -55,7 +54,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
55 | ¬iceSetting.ModuleAction, | 54 | ¬iceSetting.ModuleAction, |
56 | ¬iceSetting.NoticeSettingId, | 55 | ¬iceSetting.NoticeSettingId, |
57 | ¬iceSetting.OrgId, | 56 | ¬iceSetting.OrgId, |
58 | - ¬iceSetting.SysCode, | ||
59 | ¬iceSetting.CreatedAt, | 57 | ¬iceSetting.CreatedAt, |
60 | ¬iceSetting.DeletedAt, | 58 | ¬iceSetting.DeletedAt, |
61 | ¬iceSetting.UpdatedAt, | 59 | ¬iceSetting.UpdatedAt, |
@@ -68,7 +66,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -68,7 +66,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
68 | noticeSetting.ModuleAction, | 66 | noticeSetting.ModuleAction, |
69 | noticeSetting.NoticeSettingId, | 67 | noticeSetting.NoticeSettingId, |
70 | noticeSetting.OrgId, | 68 | noticeSetting.OrgId, |
71 | - noticeSetting.SysCode, | ||
72 | noticeSetting.CreatedAt, | 69 | noticeSetting.CreatedAt, |
73 | noticeSetting.DeletedAt, | 70 | noticeSetting.DeletedAt, |
74 | noticeSetting.UpdatedAt, | 71 | noticeSetting.UpdatedAt, |
@@ -85,7 +82,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -85,7 +82,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
85 | ¬iceSetting.ModuleAction, | 82 | ¬iceSetting.ModuleAction, |
86 | ¬iceSetting.NoticeSettingId, | 83 | ¬iceSetting.NoticeSettingId, |
87 | ¬iceSetting.OrgId, | 84 | ¬iceSetting.OrgId, |
88 | - ¬iceSetting.SysCode, | ||
89 | ¬iceSetting.CreatedAt, | 85 | ¬iceSetting.CreatedAt, |
90 | ¬iceSetting.DeletedAt, | 86 | ¬iceSetting.DeletedAt, |
91 | ¬iceSetting.UpdatedAt, | 87 | ¬iceSetting.UpdatedAt, |
@@ -98,7 +94,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -98,7 +94,6 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
98 | noticeSetting.ModuleAction, | 94 | noticeSetting.ModuleAction, |
99 | noticeSetting.NoticeSettingId, | 95 | noticeSetting.NoticeSettingId, |
100 | noticeSetting.OrgId, | 96 | noticeSetting.OrgId, |
101 | - noticeSetting.SysCode, | ||
102 | noticeSetting.CreatedAt, | 97 | noticeSetting.CreatedAt, |
103 | noticeSetting.DeletedAt, | 98 | noticeSetting.DeletedAt, |
104 | noticeSetting.UpdatedAt, | 99 | noticeSetting.UpdatedAt, |
@@ -109,6 +104,7 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -109,6 +104,7 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
109 | } | 104 | } |
110 | return noticeSetting, nil | 105 | return noticeSetting, nil |
111 | } | 106 | } |
107 | + | ||
112 | func (repository *NoticeSettingRepository) Remove(noticeSetting *domain.NoticeSetting) (*domain.NoticeSetting, error) { | 108 | func (repository *NoticeSettingRepository) Remove(noticeSetting *domain.NoticeSetting) (*domain.NoticeSetting, error) { |
113 | tx := repository.transactionContext.PgTx | 109 | tx := repository.transactionContext.PgTx |
114 | noticeSettingModel := new(models.NoticeSetting) | 110 | noticeSettingModel := new(models.NoticeSetting) |
@@ -118,6 +114,7 @@ func (repository *NoticeSettingRepository) Remove(noticeSetting *domain.NoticeSe | @@ -118,6 +114,7 @@ func (repository *NoticeSettingRepository) Remove(noticeSetting *domain.NoticeSe | ||
118 | } | 114 | } |
119 | return noticeSetting, nil | 115 | return noticeSetting, nil |
120 | } | 116 | } |
117 | + | ||
121 | func (repository *NoticeSettingRepository) FindOne(queryOptions map[string]interface{}) (*domain.NoticeSetting, error) { | 118 | func (repository *NoticeSettingRepository) FindOne(queryOptions map[string]interface{}) (*domain.NoticeSetting, error) { |
122 | tx := repository.transactionContext.PgTx | 119 | tx := repository.transactionContext.PgTx |
123 | noticeSettingModel := new(models.NoticeSetting) | 120 | noticeSettingModel := new(models.NoticeSetting) |
1 | +package controllers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/linmadan/egglib-go/web/beego" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticeSetting/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticeSetting/query" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/application/noticeSetting/service" | ||
8 | +) | ||
9 | + | ||
10 | +type NoticeSettingController struct { | ||
11 | + beego.BaseController | ||
12 | +} | ||
13 | + | ||
14 | +func (controller *NoticeSettingController) UpdateNoticeSetting() { | ||
15 | + noticeSettingService := service.NewNoticeSettingService(nil) | ||
16 | + updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{} | ||
17 | + controller.Unmarshal(updateNoticeSettingCommand) | ||
18 | + Id, _ := controller.GetInt64(":settingId") | ||
19 | + updateNoticeSettingCommand.NoticeSettingId = Id | ||
20 | + data, err := noticeSettingService.UpdateNoticeSetting(updateNoticeSettingCommand) | ||
21 | + controller.Response(data, err) | ||
22 | +} | ||
23 | + | ||
24 | +func (controller *NoticeSettingController) GetNoticeSetting() { | ||
25 | + noticeSettingService := service.NewNoticeSettingService(nil) | ||
26 | + getNoticeSettingQuery := &query.GetNoticeSettingQuery{} | ||
27 | + Id, _ := controller.GetInt64(":settingId") | ||
28 | + getNoticeSettingQuery.NoticeSettingId = Id | ||
29 | + data, err := noticeSettingService.GetNoticeSetting(getNoticeSettingQuery) | ||
30 | + controller.Response(data, err) | ||
31 | +} | ||
32 | + | ||
33 | +func (controller *NoticeSettingController) ListNoticeSetting() { | ||
34 | + noticeSettingService := service.NewNoticeSettingService(nil) | ||
35 | + listNoticeSettingQuery := &query.ListNoticeSettingQuery{} | ||
36 | + data, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery) | ||
37 | + controller.Response(data, err) | ||
38 | +} | ||
39 | + | ||
40 | +func (controller *NoticeSettingController) AddNoticeSetting() { | ||
41 | + noticeSettingService := service.NewNoticeSettingService(nil) | ||
42 | + addNoticeSettingCommand := &command.AddNoticeSettingCommand{} | ||
43 | + controller.Unmarshal(addNoticeSettingCommand) | ||
44 | + data, err := noticeSettingService.AddNoticeSetting(addNoticeSettingCommand) | ||
45 | + controller.Response(data, err) | ||
46 | +} |
1 | +package routers | ||
2 | + | ||
3 | +import ( | ||
4 | + "github.com/beego/beego/v2/server/web" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-basic/pkg/port/beego/controllers" | ||
6 | +) | ||
7 | + | ||
8 | +func init() { | ||
9 | + web.Router("/notice-setting/:settingId", &controllers.NoticeSettingController{}, "Put:UpdateNoticeSetting") | ||
10 | + web.Router("/notice-setting/:settingId", &controllers.NoticeSettingController{}, "Get:GetNoticeSetting") | ||
11 | + web.Router("/notice-setting/", &controllers.NoticeSettingController{}, "Get:ListNoticeSetting") | ||
12 | + web.Router("/notice-setting", &controllers.NoticeSettingController{}, "Post:UpdateNoticeSetting") | ||
13 | +} |
-
请 注册 或 登录 后发表评论