|
@@ -92,6 +92,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea |
|
@@ -92,6 +92,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea |
92
|
} else {
|
92
|
} else {
|
93
|
cooperationModeDao = value
|
93
|
cooperationModeDao = value
|
94
|
}
|
94
|
}
|
|
|
95
|
+
|
95
|
// 校验共创模式编码唯一性
|
96
|
// 校验共创模式编码唯一性
|
96
|
numberAvailable, _ := cooperationModeDao.CheckModeNumberAvailable(map[string]interface{}{
|
97
|
numberAvailable, _ := cooperationModeDao.CheckModeNumberAvailable(map[string]interface{}{
|
97
|
"companyId": createCooperationModeCommand.CompanyId,
|
98
|
"companyId": createCooperationModeCommand.CompanyId,
|
|
@@ -231,6 +232,8 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
|
@@ -231,6 +232,8 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
231
|
defer func() {
|
232
|
defer func() {
|
232
|
_ = transactionContext.RollbackTransaction()
|
233
|
_ = transactionContext.RollbackTransaction()
|
233
|
}()
|
234
|
}()
|
|
|
235
|
+
|
|
|
236
|
+ // 共创模式仓储初始化
|
234
|
var cooperationModeRepository domain.CooperationModeRepository
|
237
|
var cooperationModeRepository domain.CooperationModeRepository
|
235
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
238
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
236
|
"transactionContext": transactionContext,
|
239
|
"transactionContext": transactionContext,
|
|
@@ -239,6 +242,18 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
|
@@ -239,6 +242,18 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
239
|
} else {
|
242
|
} else {
|
240
|
cooperationModeRepository = value
|
243
|
cooperationModeRepository = value
|
241
|
}
|
244
|
}
|
|
|
245
|
+
|
|
|
246
|
+ // 共创模式DAO初始化
|
|
|
247
|
+ var cooperationModeDao *dao.CooperationModeDao
|
|
|
248
|
+ if value, err := factory.CreateCooperationModeDao(map[string]interface{}{
|
|
|
249
|
+ "transactionContext": transactionContext,
|
|
|
250
|
+ }); err != nil {
|
|
|
251
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
252
|
+ } else {
|
|
|
253
|
+ cooperationModeDao = value
|
|
|
254
|
+ }
|
|
|
255
|
+
|
|
|
256
|
+ // 获取共创模式
|
242
|
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": removeCooperationModeCommand.CooperationModeId})
|
257
|
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": removeCooperationModeCommand.CooperationModeId})
|
243
|
if err != nil {
|
258
|
if err != nil {
|
244
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
|
259
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
|
|
@@ -246,13 +261,25 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
|
@@ -246,13 +261,25 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
246
|
if cooperationMode == nil {
|
261
|
if cooperationMode == nil {
|
247
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10)))
|
262
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10)))
|
248
|
}
|
263
|
}
|
249
|
- if cooperationMode, err := cooperationModeRepository.Remove(cooperationMode); err != nil {
|
264
|
+
|
|
|
265
|
+ // 校验共创模式是否可以删除
|
|
|
266
|
+ deleteAvailable, _ := cooperationModeDao.CheckModeIsDeleteAvailable(map[string]interface{}{
|
|
|
267
|
+ "companyId": removeCooperationModeCommand.CompanyId,
|
|
|
268
|
+ "orgId": removeCooperationModeCommand.OrgId,
|
|
|
269
|
+ "cooperationModeNumber": cooperationMode.CooperationModeNumber,
|
|
|
270
|
+ })
|
|
|
271
|
+ if !deleteAvailable {
|
|
|
272
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "当前共创模式存在业务数据,不可删除")
|
|
|
273
|
+ }
|
|
|
274
|
+
|
|
|
275
|
+ // 移除共创模式
|
|
|
276
|
+ if cooperationModeRemoved, err := cooperationModeRepository.Remove(cooperationMode); err != nil {
|
250
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
277
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
251
|
} else {
|
278
|
} else {
|
252
|
if err := transactionContext.CommitTransaction(); err != nil {
|
279
|
if err := transactionContext.CommitTransaction(); err != nil {
|
253
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
280
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
254
|
}
|
281
|
}
|
255
|
- return cooperationMode, nil
|
282
|
+ return cooperationModeRemoved, nil
|
256
|
}
|
283
|
}
|
257
|
}
|
284
|
}
|
258
|
|
285
|
|
|
@@ -271,6 +298,8 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode |
|
@@ -271,6 +298,8 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode |
271
|
defer func() {
|
298
|
defer func() {
|
272
|
_ = transactionContext.RollbackTransaction()
|
299
|
_ = transactionContext.RollbackTransaction()
|
273
|
}()
|
300
|
}()
|
|
|
301
|
+
|
|
|
302
|
+ // 共创模式仓储初始化
|
274
|
var cooperationModeRepository domain.CooperationModeRepository
|
303
|
var cooperationModeRepository domain.CooperationModeRepository
|
275
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
304
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
276
|
"transactionContext": transactionContext,
|
305
|
"transactionContext": transactionContext,
|
|
@@ -279,13 +308,41 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode |
|
@@ -279,13 +308,41 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode |
279
|
} else {
|
308
|
} else {
|
280
|
cooperationModeRepository = value
|
309
|
cooperationModeRepository = value
|
281
|
}
|
310
|
}
|
282
|
- cooperationModeIds, _ := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds)
|
311
|
+
|
|
|
312
|
+ // 共创模式ID列表类型转换
|
|
|
313
|
+ cooperationModeIds, err := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds)
|
|
|
314
|
+ if err != nil {
|
|
|
315
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式类型错误")
|
|
|
316
|
+ }
|
|
|
317
|
+
|
|
|
318
|
+ // 共创模式DAO初始化
|
|
|
319
|
+ var cooperationModeDao *dao.CooperationModeDao
|
|
|
320
|
+ if value, err := factory.CreateCooperationModeDao(map[string]interface{}{
|
|
|
321
|
+ "transactionContext": transactionContext,
|
|
|
322
|
+ }); err != nil {
|
|
|
323
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
324
|
+ } else {
|
|
|
325
|
+ cooperationModeDao = value
|
|
|
326
|
+ }
|
|
|
327
|
+
|
|
|
328
|
+ // 获取共创模式
|
283
|
if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{
|
329
|
if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{
|
284
|
"cooperationModeIds": cooperationModeIds,
|
330
|
"cooperationModeIds": cooperationModeIds,
|
285
|
}); err != nil {
|
331
|
}); err != nil {
|
286
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
332
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
287
|
} else {
|
333
|
} else {
|
288
|
if count > 0 {
|
334
|
if count > 0 {
|
|
|
335
|
+ for _, cooperationMode := range cooperationModes {
|
|
|
336
|
+ // 校验共创模式是否可以删除
|
|
|
337
|
+ deleteAvailable, _ := cooperationModeDao.CheckModeIsDeleteAvailable(map[string]interface{}{
|
|
|
338
|
+ "companyId": batchRemoveCooperationModeCommand.CompanyId,
|
|
|
339
|
+ "orgId": batchRemoveCooperationModeCommand.OrgId,
|
|
|
340
|
+ "cooperationModeNumber": cooperationMode.CooperationModeNumber,
|
|
|
341
|
+ })
|
|
|
342
|
+ if !deleteAvailable {
|
|
|
343
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, "所选共创模式存在业务数据,不可删除")
|
|
|
344
|
+ }
|
|
|
345
|
+ }
|
289
|
if cooperationMode, err := cooperationModeRepository.BatchRemove(cooperationModes); err != nil {
|
346
|
if cooperationMode, err := cooperationModeRepository.BatchRemove(cooperationModes); err != nil {
|
290
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
347
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
291
|
} else {
|
348
|
} else {
|