...
|
...
|
@@ -84,8 +84,11 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe |
|
|
"pageSize": listNoticeSettingQuery.PageSize,
|
|
|
"companyId": listNoticeSettingQuery.CompanyId,
|
|
|
}
|
|
|
if listNoticeSettingQuery.OrgId > 0 {
|
|
|
queryOption["orgId"] = listNoticeSettingQuery.OrgId
|
|
|
if len(listNoticeSettingQuery.OrgIds) > 0 {
|
|
|
queryOption["orgIds"] = listNoticeSettingQuery.OrgIds
|
|
|
}
|
|
|
if len(listNoticeSettingQuery.ModuleActionName) > 0 {
|
|
|
queryOption["moduleActionName"] = "%" + listNoticeSettingQuery.ModuleActionName + "%"
|
|
|
}
|
|
|
if count, noticeSettings, err := noticeSettingRepository.Find(queryOption); err != nil {
|
|
|
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -211,15 +214,25 @@ func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSett |
|
|
if len(noticeSettings) > 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该环节配置已存在")
|
|
|
}
|
|
|
moduleAction, err := domain.GetNoticeModuleAction(addNoticeSettingCommand.Module, addNoticeSettingCommand.ModuleAction)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
module, err := domain.GetNoticeModule(addNoticeSettingCommand.Module)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
noticeSetting = &domain.NoticeSetting{
|
|
|
CompanyId: addNoticeSettingCommand.CompanyId,
|
|
|
Content: addNoticeSettingCommand.Content,
|
|
|
IsPush: addNoticeSettingCommand.IsPush,
|
|
|
Module: addNoticeSettingCommand.Module,
|
|
|
ModuleAction: addNoticeSettingCommand.ModuleAction,
|
|
|
OrgId: addNoticeSettingCommand.OrgId,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
CompanyId: addNoticeSettingCommand.CompanyId,
|
|
|
Content: addNoticeSettingCommand.Content,
|
|
|
IsPush: addNoticeSettingCommand.IsPush,
|
|
|
Module: addNoticeSettingCommand.Module,
|
|
|
ModuleName: module.ModuleName,
|
|
|
ModuleAction: addNoticeSettingCommand.ModuleAction,
|
|
|
ModuleActionName: moduleAction.ActionName,
|
|
|
OrgId: addNoticeSettingCommand.OrgId,
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
|
|
}
|
|
|
if noticeSetting, err := noticeSettingRepository.Save(noticeSetting); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -231,68 +244,6 @@ func (noticeSettingService *NoticeSettingService) AddNoticeSetting(addNoticeSett |
|
|
}
|
|
|
}
|
|
|
|
|
|
// //InitNoticeSetting 为企业初始化消息列表,填充空白的消息模板
|
|
|
// func (noticeSettingService *NoticeSettingService) InitNoticeSetting(initCommand *command.InitNoticeSettingCommand) error {
|
|
|
// if err := initCommand.ValidateCommand(); err != nil {
|
|
|
// return application.ThrowError(application.ARG_ERROR, err.Error())
|
|
|
// }
|
|
|
// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// var noticeSettingRepository domain.NoticeSettingRepository
|
|
|
// if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// } else {
|
|
|
// noticeSettingRepository = value
|
|
|
// }
|
|
|
// _, noticeSets, err := noticeSettingRepository.Find(map[string]interface{}{
|
|
|
// "companyId": initCommand.CompanyId,
|
|
|
// "orgId": initCommand.OrgId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// notticeExist := make(map[string]int)
|
|
|
// for i := range noticeSets {
|
|
|
// notticeExist[noticeSets[i].ModuleAction] = 1
|
|
|
// }
|
|
|
// defaultModuleAction := domain.GetNoticeModuleActionList()
|
|
|
// newEmptySetting := []domain.NoticeSetting{}
|
|
|
// for _, act := range defaultModuleAction {
|
|
|
// if _, ok := notticeExist[act.ActionCode]; !ok {
|
|
|
// newEmptySetting = append(newEmptySetting, domain.NoticeSetting{
|
|
|
// CompanyId: initCommand.CompanyId,
|
|
|
// OrgId: initCommand.OrgId,
|
|
|
// Module: act.ModuleCode,
|
|
|
// ModuleAction: act.ActionCode,
|
|
|
// CreatedAt: time.Now(),
|
|
|
// UpdatedAt: time.Now(),
|
|
|
// Content: "",
|
|
|
// IsPush: domain.NoticeSettingIsNotPush,
|
|
|
// })
|
|
|
// }
|
|
|
// }
|
|
|
// for i := range newEmptySetting {
|
|
|
// _, err = noticeSettingRepository.Save(&newEmptySetting[i])
|
|
|
// if err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// }
|
|
|
// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
// return application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// return nil
|
|
|
// }
|
|
|
|
|
|
func NewNoticeSettingService(options map[string]interface{}) *NoticeSettingService {
|
|
|
newNoticeSettingService := &NoticeSettingService{}
|
|
|
return newNoticeSettingService
|
...
|
...
|
|