作者 tangxuhui

列表输出结构调整

... ... @@ -112,16 +112,16 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu
}
// 返回数据字典设置列表
func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *query.ListDictionaryQuery) (interface{}, error) {
func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *query.ListDictionaryQuery) (int64, interface{}, error) {
if err := listDictionaryQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
... ... @@ -130,7 +130,7 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *
if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dictionaryRepository = value
}
... ... @@ -140,15 +140,14 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *
"offset": offset,
}
if count, dictionarys, err := dictionaryRepository.Find(queryCondition); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"dictionarys": dictionarys,
}, nil
return count,
dictionarys,
nil
}
}
... ...
... ... @@ -55,16 +55,16 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett
}
// 返回编排消息通知内容列表
func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSettingQuery *query.ListNoticeSettingQuery) (interface{}, error) {
func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSettingQuery *query.ListNoticeSettingQuery) (int64, interface{}, error) {
if err := listNoticeSettingQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
... ... @@ -73,7 +73,7 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe
if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
noticeSettingRepository = value
}
... ... @@ -87,15 +87,14 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe
queryOption["orgId"] = listNoticeSettingQuery.OrgId
}
if count, noticeSettings, err := noticeSettingRepository.Find(queryOption); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"noticeSettings": noticeSettings,
}, nil
return count,
noticeSettings,
nil
}
}
... ...
... ... @@ -11,6 +11,15 @@ type DictionaryController struct {
beego.BaseController
}
func (controller *DictionaryController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
dataMap := map[string]interface{}{
"totalRow": count,
"pageNumber": pageNumber,
"list": data,
}
controller.Response(dataMap, err)
}
func (controller *DictionaryController) CreateDictionary() {
dictionaryService := service.NewDictionaryService(nil)
createDictionaryCommand := &command.CreateDictionaryCommand{}
... ... @@ -42,8 +51,8 @@ func (controller *DictionaryController) ListDictionary() {
dictionaryService := service.NewDictionaryService(nil)
listDictionaryQuery := &query.ListDictionaryQuery{}
_ = controller.Unmarshal(listDictionaryQuery)
data, err := dictionaryService.ListDictionary(listDictionaryQuery)
controller.Response(data, err)
count, listData, err := dictionaryService.ListDictionary(listDictionaryQuery)
controller.returnPageListData(count, listData, err, listDictionaryQuery.Pageindex)
}
func (controller *DictionaryController) GetDictionaryByCode() {
... ...
... ... @@ -11,6 +11,15 @@ type NoticeSettingController struct {
beego.BaseController
}
func (controller *NoticeSettingController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
dataMap := map[string]interface{}{
"totalRow": count,
"pageNumber": pageNumber,
"list": data,
}
controller.Response(dataMap, err)
}
func (controller *NoticeSettingController) UpdateNoticeSetting() {
noticeSettingService := service.NewNoticeSettingService(nil)
updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{}
... ... @@ -34,8 +43,8 @@ func (controller *NoticeSettingController) ListNoticeSetting() {
noticeSettingService := service.NewNoticeSettingService(nil)
listNoticeSettingQuery := &query.ListNoticeSettingQuery{}
controller.Unmarshal(listNoticeSettingQuery)
data, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery)
controller.Response(data, err)
count, listdata, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery)
controller.returnPageListData(count, listdata, err, listNoticeSettingQuery.PageIndex)
}
func (controller *NoticeSettingController) AddNoticeSetting() {
... ...