...
|
...
|
@@ -92,6 +92,7 @@ func (cooperationModeService *CooperationModeService) CreateCooperationMode(crea |
|
|
} else {
|
|
|
cooperationModeDao = value
|
|
|
}
|
|
|
|
|
|
// 校验共创模式编码唯一性
|
|
|
numberAvailable, _ := cooperationModeDao.CheckModeNumberAvailable(map[string]interface{}{
|
|
|
"companyId": createCooperationModeCommand.CompanyId,
|
...
|
...
|
@@ -231,6 +232,8 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 共创模式仓储初始化
|
|
|
var cooperationModeRepository domain.CooperationModeRepository
|
|
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -239,6 +242,18 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
|
|
} else {
|
|
|
cooperationModeRepository = value
|
|
|
}
|
|
|
|
|
|
// 共创模式DAO初始化
|
|
|
var cooperationModeDao *dao.CooperationModeDao
|
|
|
if value, err := factory.CreateCooperationModeDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationModeDao = value
|
|
|
}
|
|
|
|
|
|
// 获取共创模式
|
|
|
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeId": removeCooperationModeCommand.CooperationModeId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
|
...
|
...
|
@@ -246,13 +261,25 @@ func (cooperationModeService *CooperationModeService) RemoveCooperationMode(remo |
|
|
if cooperationMode == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeCooperationModeCommand.CooperationModeId, 10)))
|
|
|
}
|
|
|
if cooperationMode, err := cooperationModeRepository.Remove(cooperationMode); err != nil {
|
|
|
|
|
|
// 校验共创模式是否可以删除
|
|
|
deleteAvailable, _ := cooperationModeDao.CheckModeIsDeleteAvailable(map[string]interface{}{
|
|
|
"companyId": removeCooperationModeCommand.CompanyId,
|
|
|
"orgId": removeCooperationModeCommand.OrgId,
|
|
|
"cooperationModeNumber": cooperationMode.CooperationModeNumber,
|
|
|
})
|
|
|
if !deleteAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "当前共创模式存在业务数据,不可删除")
|
|
|
}
|
|
|
|
|
|
// 移除共创模式
|
|
|
if cooperationModeRemoved, err := cooperationModeRepository.Remove(cooperationMode); err != nil {
|
|
|
return 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 cooperationMode, nil
|
|
|
return cooperationModeRemoved, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -271,6 +298,8 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 共创模式仓储初始化
|
|
|
var cooperationModeRepository domain.CooperationModeRepository
|
|
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -279,13 +308,41 @@ func (cooperationModeService *CooperationModeService) BatchRemoveCooperationMode |
|
|
} else {
|
|
|
cooperationModeRepository = value
|
|
|
}
|
|
|
cooperationModeIds, _ := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds)
|
|
|
|
|
|
// 共创模式ID列表类型转换
|
|
|
cooperationModeIds, err := utils.SliceAtoi(batchRemoveCooperationModeCommand.CooperationModeIds)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式类型错误")
|
|
|
}
|
|
|
|
|
|
// 共创模式DAO初始化
|
|
|
var cooperationModeDao *dao.CooperationModeDao
|
|
|
if value, err := factory.CreateCooperationModeDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationModeDao = value
|
|
|
}
|
|
|
|
|
|
// 获取共创模式
|
|
|
if count, cooperationModes, err := cooperationModeRepository.Find(map[string]interface{}{
|
|
|
"cooperationModeIds": cooperationModeIds,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if count > 0 {
|
|
|
for _, cooperationMode := range cooperationModes {
|
|
|
// 校验共创模式是否可以删除
|
|
|
deleteAvailable, _ := cooperationModeDao.CheckModeIsDeleteAvailable(map[string]interface{}{
|
|
|
"companyId": batchRemoveCooperationModeCommand.CompanyId,
|
|
|
"orgId": batchRemoveCooperationModeCommand.OrgId,
|
|
|
"cooperationModeNumber": cooperationMode.CooperationModeNumber,
|
|
|
})
|
|
|
if !deleteAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "所选共创模式存在业务数据,不可删除")
|
|
|
}
|
|
|
}
|
|
|
if cooperationMode, err := cooperationModeRepository.BatchRemove(cooperationModes); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
|