作者 tangxuhui

列表输出结构调整

@@ -112,16 +112,16 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu @@ -112,16 +112,16 @@ func (dictionaryService *DictionaryService) GetDictionary(getDictionaryQuery *qu
112 } 112 }
113 113
114 // 返回数据字典设置列表 114 // 返回数据字典设置列表
115 -func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *query.ListDictionaryQuery) (interface{}, error) { 115 +func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *query.ListDictionaryQuery) (int64, interface{}, error) {
116 if err := listDictionaryQuery.ValidateQuery(); err != nil { 116 if err := listDictionaryQuery.ValidateQuery(); err != nil {
117 - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 117 + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
118 } 118 }
119 transactionContext, err := factory.CreateTransactionContext(nil) 119 transactionContext, err := factory.CreateTransactionContext(nil)
120 if err != nil { 120 if err != nil {
121 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 121 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
122 } 122 }
123 if err := transactionContext.StartTransaction(); err != nil { 123 if err := transactionContext.StartTransaction(); err != nil {
124 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 124 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
125 } 125 }
126 defer func() { 126 defer func() {
127 transactionContext.RollbackTransaction() 127 transactionContext.RollbackTransaction()
@@ -130,7 +130,7 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery * @@ -130,7 +130,7 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *
130 if value, err := factory.CreateDictionaryRepository(map[string]interface{}{ 130 if value, err := factory.CreateDictionaryRepository(map[string]interface{}{
131 "transactionContext": transactionContext, 131 "transactionContext": transactionContext,
132 }); err != nil { 132 }); err != nil {
133 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 133 + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
134 } else { 134 } else {
135 dictionaryRepository = value 135 dictionaryRepository = value
136 } 136 }
@@ -140,15 +140,14 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery * @@ -140,15 +140,14 @@ func (dictionaryService *DictionaryService) ListDictionary(listDictionaryQuery *
140 "offset": offset, 140 "offset": offset,
141 } 141 }
142 if count, dictionarys, err := dictionaryRepository.Find(queryCondition); err != nil { 142 if count, dictionarys, err := dictionaryRepository.Find(queryCondition); err != nil {
143 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 143 + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
144 } else { 144 } else {
145 if err := transactionContext.CommitTransaction(); err != nil { 145 if err := transactionContext.CommitTransaction(); err != nil {
146 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 146 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
147 } 147 }
148 - return map[string]interface{}{  
149 - "count": count,  
150 - "dictionarys": dictionarys,  
151 - }, nil 148 + return count,
  149 + dictionarys,
  150 + nil
152 } 151 }
153 } 152 }
154 153
@@ -55,16 +55,16 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett @@ -55,16 +55,16 @@ func (noticeSettingService *NoticeSettingService) GetNoticeSetting(getNoticeSett
55 } 55 }
56 56
57 // 返回编排消息通知内容列表 57 // 返回编排消息通知内容列表
58 -func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSettingQuery *query.ListNoticeSettingQuery) (interface{}, error) { 58 +func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSettingQuery *query.ListNoticeSettingQuery) (int64, interface{}, error) {
59 if err := listNoticeSettingQuery.ValidateQuery(); err != nil { 59 if err := listNoticeSettingQuery.ValidateQuery(); err != nil {
60 - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 60 + return 0, nil, application.ThrowError(application.ARG_ERROR, err.Error())
61 } 61 }
62 transactionContext, err := factory.CreateTransactionContext(nil) 62 transactionContext, err := factory.CreateTransactionContext(nil)
63 if err != nil { 63 if err != nil {
64 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 64 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
65 } 65 }
66 if err := transactionContext.StartTransaction(); err != nil { 66 if err := transactionContext.StartTransaction(); err != nil {
67 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 67 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
68 } 68 }
69 defer func() { 69 defer func() {
70 transactionContext.RollbackTransaction() 70 transactionContext.RollbackTransaction()
@@ -73,7 +73,7 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe @@ -73,7 +73,7 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe
73 if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{ 73 if value, err := factory.CreateNoticeSettingRepository(map[string]interface{}{
74 "transactionContext": transactionContext, 74 "transactionContext": transactionContext,
75 }); err != nil { 75 }); err != nil {
76 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 76 + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
77 } else { 77 } else {
78 noticeSettingRepository = value 78 noticeSettingRepository = value
79 } 79 }
@@ -87,15 +87,14 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe @@ -87,15 +87,14 @@ func (noticeSettingService *NoticeSettingService) ListNoticeSetting(listNoticeSe
87 queryOption["orgId"] = listNoticeSettingQuery.OrgId 87 queryOption["orgId"] = listNoticeSettingQuery.OrgId
88 } 88 }
89 if count, noticeSettings, err := noticeSettingRepository.Find(queryOption); err != nil { 89 if count, noticeSettings, err := noticeSettingRepository.Find(queryOption); err != nil {
90 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 90 + return 0, nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
91 } else { 91 } else {
92 if err := transactionContext.CommitTransaction(); err != nil { 92 if err := transactionContext.CommitTransaction(); err != nil {
93 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 93 + return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
94 } 94 }
95 - return map[string]interface{}{  
96 - "count": count,  
97 - "noticeSettings": noticeSettings,  
98 - }, nil 95 + return count,
  96 + noticeSettings,
  97 + nil
99 } 98 }
100 } 99 }
101 100
@@ -11,6 +11,15 @@ type DictionaryController struct { @@ -11,6 +11,15 @@ type DictionaryController struct {
11 beego.BaseController 11 beego.BaseController
12 } 12 }
13 13
  14 +func (controller *DictionaryController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
  15 + dataMap := map[string]interface{}{
  16 + "totalRow": count,
  17 + "pageNumber": pageNumber,
  18 + "list": data,
  19 + }
  20 + controller.Response(dataMap, err)
  21 +}
  22 +
14 func (controller *DictionaryController) CreateDictionary() { 23 func (controller *DictionaryController) CreateDictionary() {
15 dictionaryService := service.NewDictionaryService(nil) 24 dictionaryService := service.NewDictionaryService(nil)
16 createDictionaryCommand := &command.CreateDictionaryCommand{} 25 createDictionaryCommand := &command.CreateDictionaryCommand{}
@@ -42,8 +51,8 @@ func (controller *DictionaryController) ListDictionary() { @@ -42,8 +51,8 @@ func (controller *DictionaryController) ListDictionary() {
42 dictionaryService := service.NewDictionaryService(nil) 51 dictionaryService := service.NewDictionaryService(nil)
43 listDictionaryQuery := &query.ListDictionaryQuery{} 52 listDictionaryQuery := &query.ListDictionaryQuery{}
44 _ = controller.Unmarshal(listDictionaryQuery) 53 _ = controller.Unmarshal(listDictionaryQuery)
45 - data, err := dictionaryService.ListDictionary(listDictionaryQuery)  
46 - controller.Response(data, err) 54 + count, listData, err := dictionaryService.ListDictionary(listDictionaryQuery)
  55 + controller.returnPageListData(count, listData, err, listDictionaryQuery.Pageindex)
47 } 56 }
48 57
49 func (controller *DictionaryController) GetDictionaryByCode() { 58 func (controller *DictionaryController) GetDictionaryByCode() {
@@ -11,6 +11,15 @@ type NoticeSettingController struct { @@ -11,6 +11,15 @@ type NoticeSettingController struct {
11 beego.BaseController 11 beego.BaseController
12 } 12 }
13 13
  14 +func (controller *NoticeSettingController) returnPageListData(count int64, data interface{}, err error, pageNumber int) {
  15 + dataMap := map[string]interface{}{
  16 + "totalRow": count,
  17 + "pageNumber": pageNumber,
  18 + "list": data,
  19 + }
  20 + controller.Response(dataMap, err)
  21 +}
  22 +
14 func (controller *NoticeSettingController) UpdateNoticeSetting() { 23 func (controller *NoticeSettingController) UpdateNoticeSetting() {
15 noticeSettingService := service.NewNoticeSettingService(nil) 24 noticeSettingService := service.NewNoticeSettingService(nil)
16 updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{} 25 updateNoticeSettingCommand := &command.UpdateNoticeSettingCommand{}
@@ -34,8 +43,8 @@ func (controller *NoticeSettingController) ListNoticeSetting() { @@ -34,8 +43,8 @@ func (controller *NoticeSettingController) ListNoticeSetting() {
34 noticeSettingService := service.NewNoticeSettingService(nil) 43 noticeSettingService := service.NewNoticeSettingService(nil)
35 listNoticeSettingQuery := &query.ListNoticeSettingQuery{} 44 listNoticeSettingQuery := &query.ListNoticeSettingQuery{}
36 controller.Unmarshal(listNoticeSettingQuery) 45 controller.Unmarshal(listNoticeSettingQuery)
37 - data, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery)  
38 - controller.Response(data, err) 46 + count, listdata, err := noticeSettingService.ListNoticeSetting(listNoticeSettingQuery)
  47 + controller.returnPageListData(count, listdata, err, listNoticeSettingQuery.PageIndex)
39 } 48 }
40 49
41 func (controller *NoticeSettingController) AddNoticeSetting() { 50 func (controller *NoticeSettingController) AddNoticeSetting() {