正在显示
9 个修改的文件
包含
49 行增加
和
66 行删除
| @@ -12,7 +12,8 @@ type ListNoticeSettingQuery struct { | @@ -12,7 +12,8 @@ type ListNoticeSettingQuery struct { | ||
| 12 | // 查询限制 | 12 | // 查询限制 |
| 13 | PageSize int `json:"pageSize" valid:"Required"` | 13 | PageSize int `json:"pageSize" valid:"Required"` |
| 14 | CompanyId int64 `json:"companyId" valid:"Required"` | 14 | CompanyId int64 `json:"companyId" valid:"Required"` |
| 15 | - OrgId int64 `json:"orgId"` | 15 | + OrgIds []int64 `json:"orgIds"` |
| 16 | + ModuleActionName string `json:"moduleActionName"` //消息环节名称 | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | func (listNoticeSettingQuery *ListNoticeSettingQuery) Valid(validation *validation.Validation) { | 19 | func (listNoticeSettingQuery *ListNoticeSettingQuery) Valid(validation *validation.Validation) { |
| @@ -84,8 +84,11 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe | @@ -84,8 +84,11 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe | ||
| 84 | "pageSize": listNoticeSettingQuery.PageSize, | 84 | "pageSize": listNoticeSettingQuery.PageSize, |
| 85 | "companyId": listNoticeSettingQuery.CompanyId, | 85 | "companyId": listNoticeSettingQuery.CompanyId, |
| 86 | } | 86 | } |
| 87 | - if listNoticeSettingQuery.OrgId > 0 { | ||
| 88 | - queryOption["orgId"] = listNoticeSettingQuery.OrgId | 87 | + if len(listNoticeSettingQuery.OrgIds) > 0 { |
| 88 | + queryOption["orgIds"] = listNoticeSettingQuery.OrgIds | ||
| 89 | + } | ||
| 90 | + if len(listNoticeSettingQuery.ModuleActionName) > 0 { | ||
| 91 | + queryOption["moduleActionName"] = "%" + listNoticeSettingQuery.ModuleActionName + "%" | ||
| 89 | } | 92 | } |
| 90 | if count, noticeSettings, err := noticeSettingRepository.Find(queryOption); err != nil { | 93 | if count, noticeSettings, err := noticeSettingRepository.Find(queryOption); err != nil { |
| 91 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 94 | return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -211,12 +214,22 @@ func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSett | @@ -211,12 +214,22 @@ func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSett | ||
| 211 | if len(noticeSettings) > 0 { | 214 | if len(noticeSettings) > 0 { |
| 212 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该环节配置已存在") | 215 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该环节配置已存在") |
| 213 | } | 216 | } |
| 217 | + moduleAction, err := domain.GetNoticeModuleAction(addNoticeSettingCommand.Module, addNoticeSettingCommand.ModuleAction) | ||
| 218 | + if err != nil { | ||
| 219 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 220 | + } | ||
| 221 | + module, err := domain.GetNoticeModule(addNoticeSettingCommand.Module) | ||
| 222 | + if err != nil { | ||
| 223 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 224 | + } | ||
| 214 | noticeSetting = &domain.NoticeSetting{ | 225 | noticeSetting = &domain.NoticeSetting{ |
| 215 | CompanyId: addNoticeSettingCommand.CompanyId, | 226 | CompanyId: addNoticeSettingCommand.CompanyId, |
| 216 | Content: addNoticeSettingCommand.Content, | 227 | Content: addNoticeSettingCommand.Content, |
| 217 | IsPush: addNoticeSettingCommand.IsPush, | 228 | IsPush: addNoticeSettingCommand.IsPush, |
| 218 | Module: addNoticeSettingCommand.Module, | 229 | Module: addNoticeSettingCommand.Module, |
| 230 | + ModuleName: module.ModuleName, | ||
| 219 | ModuleAction: addNoticeSettingCommand.ModuleAction, | 231 | ModuleAction: addNoticeSettingCommand.ModuleAction, |
| 232 | + ModuleActionName: moduleAction.ActionName, | ||
| 220 | OrgId: addNoticeSettingCommand.OrgId, | 233 | OrgId: addNoticeSettingCommand.OrgId, |
| 221 | CreatedAt: time.Now(), | 234 | CreatedAt: time.Now(), |
| 222 | UpdatedAt: time.Now(), | 235 | UpdatedAt: time.Now(), |
| @@ -231,68 +244,6 @@ func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSett | @@ -231,68 +244,6 @@ func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSett | ||
| 231 | } | 244 | } |
| 232 | } | 245 | } |
| 233 | 246 | ||
| 234 | -// //InitNoticeSetting 为企业初始化消息列表,填充空白的消息模板 | ||
| 235 | -// func (noticeSettingService *NoticeSettingService) InitNoticeSetting(initCommand *command.InitNoticeSettingCommand) error { | ||
| 236 | -// if err := initCommand.ValidateCommand(); err != nil { | ||
| 237 | -// return application.ThrowError(application.ARG_ERROR, err.Error()) | ||
| 238 | -// } | ||
| 239 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 240 | -// if err != nil { | ||
| 241 | -// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 242 | -// } | ||
| 243 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
| 244 | -// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 245 | -// } | ||
| 246 | -// defer func() { | ||
| 247 | -// transactionContext.RollbackTransaction() | ||
| 248 | -// }() | ||
| 249 | -// var noticeSettingRepository domain.NoticeSettingRepository | ||
| 250 | -// if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{ | ||
| 251 | -// "transactionContext": transactionContext, | ||
| 252 | -// }); err != nil { | ||
| 253 | -// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 254 | -// } else { | ||
| 255 | -// noticeSettingRepository = value | ||
| 256 | -// } | ||
| 257 | -// _, noticeSets, err := noticeSettingRepository.Find(map[string]interface{}{ | ||
| 258 | -// "companyId": initCommand.CompanyId, | ||
| 259 | -// "orgId": initCommand.OrgId, | ||
| 260 | -// }) | ||
| 261 | -// if err != nil { | ||
| 262 | -// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 263 | -// } | ||
| 264 | -// notticeExist := make(map[string]int) | ||
| 265 | -// for i := range noticeSets { | ||
| 266 | -// notticeExist[noticeSets[i].ModuleAction] = 1 | ||
| 267 | -// } | ||
| 268 | -// defaultModuleAction := domain.GetNoticeModuleActionList() | ||
| 269 | -// newEmptySetting := []domain.NoticeSetting{} | ||
| 270 | -// for _, act := range defaultModuleAction { | ||
| 271 | -// if _, ok := notticeExist[act.ActionCode]; !ok { | ||
| 272 | -// newEmptySetting = append(newEmptySetting, domain.NoticeSetting{ | ||
| 273 | -// CompanyId: initCommand.CompanyId, | ||
| 274 | -// OrgId: initCommand.OrgId, | ||
| 275 | -// Module: act.ModuleCode, | ||
| 276 | -// ModuleAction: act.ActionCode, | ||
| 277 | -// CreatedAt: time.Now(), | ||
| 278 | -// UpdatedAt: time.Now(), | ||
| 279 | -// Content: "", | ||
| 280 | -// IsPush: domain.NoticeSettingIsNotPush, | ||
| 281 | -// }) | ||
| 282 | -// } | ||
| 283 | -// } | ||
| 284 | -// for i := range newEmptySetting { | ||
| 285 | -// _, err = noticeSettingRepository.Save(&newEmptySetting[i]) | ||
| 286 | -// if err != nil { | ||
| 287 | -// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 288 | -// } | ||
| 289 | -// } | ||
| 290 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
| 291 | -// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 292 | -// } | ||
| 293 | -// return nil | ||
| 294 | -// } | ||
| 295 | - | ||
| 296 | func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService { | 247 | func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService { |
| 297 | newNoticeSettingService := &NoticeSettingService{} | 248 | newNoticeSettingService := &NoticeSettingService{} |
| 298 | return newNoticeSettingService | 249 | return newNoticeSettingService |
| @@ -20,8 +20,10 @@ type NoticeSetting struct { | @@ -20,8 +20,10 @@ type NoticeSetting struct { | ||
| 20 | IsPush int `json:"isPush"` | 20 | IsPush int `json:"isPush"` |
| 21 | // 消息对应的业务模块 | 21 | // 消息对应的业务模块 |
| 22 | Module string `json:"module"` | 22 | Module string `json:"module"` |
| 23 | + ModuleName string `json:"moduleName"` | ||
| 23 | // 业务环节 | 24 | // 业务环节 |
| 24 | ModuleAction string `json:"moduleAction"` | 25 | ModuleAction string `json:"moduleAction"` |
| 26 | + ModuleActionName string `json:"moduleActionName"` | ||
| 25 | // 组织id | 27 | // 组织id |
| 26 | OrgId int64 `json:"orgId"` | 28 | OrgId int64 `json:"orgId"` |
| 27 | // 创建时间 | 29 | // 创建时间 |
| @@ -82,6 +82,15 @@ func GetNoticeModuleAction(moduleCode string, actioncode string) (NoticeModuleAc | @@ -82,6 +82,15 @@ func GetNoticeModuleAction(moduleCode string, actioncode string) (NoticeModuleAc | ||
| 82 | return NoticeModuleAction{}, errors.New("未找到对应的消息动作") | 82 | return NoticeModuleAction{}, errors.New("未找到对应的消息动作") |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | +func GetNoticeModule(moduleCode string) (NoticeModule, error) { | ||
| 86 | + for i := range noticeModuleList { | ||
| 87 | + if noticeModuleList[i].ModuleCode == moduleCode { | ||
| 88 | + return noticeModuleList[i], nil | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + return NoticeModule{}, errors.New("未找到对应的消息模块") | ||
| 92 | +} | ||
| 93 | + | ||
| 85 | //业务模块 | 94 | //业务模块 |
| 86 | const ( | 95 | const ( |
| 87 | Module00 = "module00" // 系统消息 | 96 | Module00 = "module00" // 系统消息 |
| @@ -12,8 +12,10 @@ type NoticeSetting struct { | @@ -12,8 +12,10 @@ type NoticeSetting struct { | ||
| 12 | IsPush int | 12 | IsPush int |
| 13 | // 消息对应的业务模块 | 13 | // 消息对应的业务模块 |
| 14 | Module string | 14 | Module string |
| 15 | + ModuleName string | ||
| 15 | // 业务环节 | 16 | // 业务环节 |
| 16 | ModuleAction string | 17 | ModuleAction string |
| 18 | + ModuleActionName string | ||
| 17 | // 消息id | 19 | // 消息id |
| 18 | NoticeSettingId int64 `pg:",pk"` | 20 | NoticeSettingId int64 `pg:",pk"` |
| 19 | // 组织id | 21 | // 组织id |
| @@ -11,7 +11,9 @@ func TransformToNoticeSettingDomainModelFromPgModels(noticeSettingModel *models. | @@ -11,7 +11,9 @@ func TransformToNoticeSettingDomainModelFromPgModels(noticeSettingModel *models. | ||
| 11 | Content: noticeSettingModel.Content, | 11 | Content: noticeSettingModel.Content, |
| 12 | IsPush: noticeSettingModel.IsPush, | 12 | IsPush: noticeSettingModel.IsPush, |
| 13 | Module: noticeSettingModel.Module, | 13 | Module: noticeSettingModel.Module, |
| 14 | + ModuleName: noticeSettingModel.ModuleName, | ||
| 14 | ModuleAction: noticeSettingModel.ModuleAction, | 15 | ModuleAction: noticeSettingModel.ModuleAction, |
| 16 | + ModuleActionName: noticeSettingModel.ModuleName, | ||
| 15 | NoticeSettingId: noticeSettingModel.NoticeSettingId, | 17 | NoticeSettingId: noticeSettingModel.NoticeSettingId, |
| 16 | OrgId: noticeSettingModel.OrgId, | 18 | OrgId: noticeSettingModel.OrgId, |
| 17 | CreatedAt: noticeSettingModel.CreatedAt, | 19 | CreatedAt: noticeSettingModel.CreatedAt, |
| @@ -25,7 +25,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -25,7 +25,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
| 25 | "content", | 25 | "content", |
| 26 | "is_push", | 26 | "is_push", |
| 27 | "module", | 27 | "module", |
| 28 | + "module_name", | ||
| 28 | "module_action", | 29 | "module_action", |
| 30 | + "module_action_name", | ||
| 29 | "notice_setting_id", | 31 | "notice_setting_id", |
| 30 | "org_id", | 32 | "org_id", |
| 31 | "created_at", | 33 | "created_at", |
| @@ -51,7 +53,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -51,7 +53,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
| 51 | ¬iceSetting.Content, | 53 | ¬iceSetting.Content, |
| 52 | ¬iceSetting.IsPush, | 54 | ¬iceSetting.IsPush, |
| 53 | ¬iceSetting.Module, | 55 | ¬iceSetting.Module, |
| 56 | + ¬iceSetting.ModuleName, | ||
| 54 | ¬iceSetting.ModuleAction, | 57 | ¬iceSetting.ModuleAction, |
| 58 | + ¬iceSetting.ModuleActionName, | ||
| 55 | ¬iceSetting.NoticeSettingId, | 59 | ¬iceSetting.NoticeSettingId, |
| 56 | ¬iceSetting.OrgId, | 60 | ¬iceSetting.OrgId, |
| 57 | ¬iceSetting.CreatedAt, | 61 | ¬iceSetting.CreatedAt, |
| @@ -63,7 +67,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -63,7 +67,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
| 63 | noticeSetting.Content, | 67 | noticeSetting.Content, |
| 64 | noticeSetting.IsPush, | 68 | noticeSetting.IsPush, |
| 65 | noticeSetting.Module, | 69 | noticeSetting.Module, |
| 70 | + noticeSetting.ModuleName, | ||
| 66 | noticeSetting.ModuleAction, | 71 | noticeSetting.ModuleAction, |
| 72 | + noticeSetting.ModuleActionName, | ||
| 67 | noticeSetting.NoticeSettingId, | 73 | noticeSetting.NoticeSettingId, |
| 68 | noticeSetting.OrgId, | 74 | noticeSetting.OrgId, |
| 69 | noticeSetting.CreatedAt, | 75 | noticeSetting.CreatedAt, |
| @@ -79,7 +85,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -79,7 +85,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
| 79 | ¬iceSetting.Content, | 85 | ¬iceSetting.Content, |
| 80 | ¬iceSetting.IsPush, | 86 | ¬iceSetting.IsPush, |
| 81 | ¬iceSetting.Module, | 87 | ¬iceSetting.Module, |
| 88 | + ¬iceSetting.ModuleName, | ||
| 82 | ¬iceSetting.ModuleAction, | 89 | ¬iceSetting.ModuleAction, |
| 90 | + ¬iceSetting.ModuleActionName, | ||
| 83 | ¬iceSetting.NoticeSettingId, | 91 | ¬iceSetting.NoticeSettingId, |
| 84 | ¬iceSetting.OrgId, | 92 | ¬iceSetting.OrgId, |
| 85 | ¬iceSetting.CreatedAt, | 93 | ¬iceSetting.CreatedAt, |
| @@ -91,7 +99,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | @@ -91,7 +99,9 @@ func (repository *NoticeSettingRepository) Save(noticeSetting *domain.NoticeSett | ||
| 91 | noticeSetting.Content, | 99 | noticeSetting.Content, |
| 92 | noticeSetting.IsPush, | 100 | noticeSetting.IsPush, |
| 93 | noticeSetting.Module, | 101 | noticeSetting.Module, |
| 102 | + noticeSetting.ModuleName, | ||
| 94 | noticeSetting.ModuleAction, | 103 | noticeSetting.ModuleAction, |
| 104 | + noticeSetting.ModuleActionName, | ||
| 95 | noticeSetting.NoticeSettingId, | 105 | noticeSetting.NoticeSettingId, |
| 96 | noticeSetting.OrgId, | 106 | noticeSetting.OrgId, |
| 97 | noticeSetting.CreatedAt, | 107 | noticeSetting.CreatedAt, |
| @@ -144,6 +154,11 @@ func (repository *NoticeSettingRepository) Find(queryOptions map[string]interfac | @@ -144,6 +154,11 @@ func (repository *NoticeSettingRepository) Find(queryOptions map[string]interfac | ||
| 144 | query.SetWhereByQueryOption("notice_setting.module_action=?", "moduleAction") | 154 | query.SetWhereByQueryOption("notice_setting.module_action=?", "moduleAction") |
| 145 | query.SetWhereByQueryOption("notice_setting.org_id=?", "orgId") | 155 | query.SetWhereByQueryOption("notice_setting.org_id=?", "orgId") |
| 146 | query.SetWhereByQueryOption("notice_setting.company_id=?", "companyId") | 156 | query.SetWhereByQueryOption("notice_setting.company_id=?", "companyId") |
| 157 | + query.SetWhereByQueryOption("notice_setting.module_action_name like ?", "moduleActionName") | ||
| 158 | + if v, ok := queryOptions["orgIds"]; ok { | ||
| 159 | + query.WhereIn("notice_setting.orgId in (?)", v) | ||
| 160 | + } | ||
| 161 | + | ||
| 147 | if count, err := query.SelectAndCount(); err != nil { | 162 | if count, err := query.SelectAndCount(); err != nil { |
| 148 | return 0, noticeSettings, err | 163 | return 0, noticeSettings, err |
| 149 | } else { | 164 | } else { |
| @@ -132,6 +132,7 @@ func (repository *SystemSettingRepository) Find(queryOptions map[string]interfac | @@ -132,6 +132,7 @@ func (repository *SystemSettingRepository) Find(queryOptions map[string]interfac | ||
| 132 | query.SetOrderDirect("system_setting_id", "DESC") | 132 | query.SetOrderDirect("system_setting_id", "DESC") |
| 133 | query.SetWhereByQueryOption("system_setting.setting_code=?", "settingCode") | 133 | query.SetWhereByQueryOption("system_setting.setting_code=?", "settingCode") |
| 134 | query.SetWhereByQueryOption("system_setting.company_id=?", "companyId") | 134 | query.SetWhereByQueryOption("system_setting.company_id=?", "companyId") |
| 135 | + | ||
| 135 | if count, err := query.SelectAndCount(); err != nil { | 136 | if count, err := query.SelectAndCount(); err != nil { |
| 136 | return 0, systemSettings, err | 137 | return 0, systemSettings, err |
| 137 | } else { | 138 | } else { |
-
请 注册 或 登录 后发表评论