|
@@ -138,6 +138,26 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
|
@@ -138,6 +138,26 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
138
|
department = data
|
138
|
department = data
|
139
|
}
|
139
|
}
|
140
|
|
140
|
|
|
|
141
|
+ // 共创项目仓储初始化
|
|
|
142
|
+ var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
143
|
+ if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
144
|
+ "transactionContext": transactionContext,
|
|
|
145
|
+ }); err != nil {
|
|
|
146
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
147
|
+ } else {
|
|
|
148
|
+ cooperationProjectRepository = value
|
|
|
149
|
+ }
|
|
|
150
|
+
|
|
|
151
|
+ // 共创项目DAO初始化
|
|
|
152
|
+ var cooperationProjectDao *dao.CooperationProjectDao
|
|
|
153
|
+ if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{
|
|
|
154
|
+ "transactionContext": transactionContext,
|
|
|
155
|
+ }); err != nil {
|
|
|
156
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
157
|
+ } else {
|
|
|
158
|
+ cooperationProjectDao = value
|
|
|
159
|
+ }
|
|
|
160
|
+
|
141
|
// 查找共创模式
|
161
|
// 查找共创模式
|
142
|
var cooperationModeRepository domain.CooperationModeRepository
|
162
|
var cooperationModeRepository domain.CooperationModeRepository
|
143
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
163
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
|
@@ -147,22 +167,17 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
|
@@ -147,22 +167,17 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
147
|
} else {
|
167
|
} else {
|
148
|
cooperationModeRepository = value
|
168
|
cooperationModeRepository = value
|
149
|
}
|
169
|
}
|
150
|
- cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber})
|
170
|
+ cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{
|
|
|
171
|
+ "companyId": createCooperationProjectCommand.CompanyId,
|
|
|
172
|
+ "orgId": createCooperationProjectCommand.OrgId,
|
|
|
173
|
+ "cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber,
|
|
|
174
|
+ })
|
151
|
if err != nil {
|
175
|
if err != nil {
|
152
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
|
176
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创模式不存在")
|
153
|
}
|
177
|
}
|
154
|
if cooperationMode == nil {
|
178
|
if cooperationMode == nil {
|
155
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber))
|
179
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber))
|
156
|
} else {
|
180
|
} else {
|
157
|
- // 共创项目DAO初始化
|
|
|
158
|
- var cooperationProjectDao *dao.CooperationProjectDao
|
|
|
159
|
- if value, err := factory.CreateCooperationProjectDao(map[string]interface{}{
|
|
|
160
|
- "transactionContext": transactionContext,
|
|
|
161
|
- }); err != nil {
|
|
|
162
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
163
|
- } else {
|
|
|
164
|
- cooperationProjectDao = value
|
|
|
165
|
- }
|
|
|
166
|
// 生成共创项目编号
|
181
|
// 生成共创项目编号
|
167
|
projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{
|
182
|
projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{
|
168
|
"companyId": createCooperationProjectCommand.CompanyId,
|
183
|
"companyId": createCooperationProjectCommand.CompanyId,
|
|
@@ -172,21 +187,27 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
|
@@ -172,21 +187,27 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
172
|
}
|
187
|
}
|
173
|
|
188
|
|
174
|
// 校验共创项目编号是否唯一
|
189
|
// 校验共创项目编号是否唯一
|
175
|
- numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{
|
190
|
+ numberAvailable, err := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{
|
176
|
"companyId": createCooperationProjectCommand.CompanyId,
|
191
|
"companyId": createCooperationProjectCommand.CompanyId,
|
177
|
"orgId": createCooperationProjectCommand.OrgId,
|
192
|
"orgId": createCooperationProjectCommand.OrgId,
|
178
|
"cooperationProjectNumber": projectNumber,
|
193
|
"cooperationProjectNumber": projectNumber,
|
179
|
})
|
194
|
})
|
|
|
195
|
+ if err != nil {
|
|
|
196
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
197
|
+ }
|
180
|
if !numberAvailable {
|
198
|
if !numberAvailable {
|
181
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常")
|
199
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创项目异常")
|
182
|
}
|
200
|
}
|
183
|
|
201
|
|
184
|
// 校验共创项目名称是否唯一
|
202
|
// 校验共创项目名称是否唯一
|
185
|
- nameAvailable, _ := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{
|
203
|
+ nameAvailable, err := cooperationProjectDao.CheckProjectNameAvailable(map[string]interface{}{
|
186
|
"companyId": createCooperationProjectCommand.CompanyId,
|
204
|
"companyId": createCooperationProjectCommand.CompanyId,
|
187
|
"orgId": createCooperationProjectCommand.OrgId,
|
205
|
"orgId": createCooperationProjectCommand.OrgId,
|
188
|
"cooperationProjectName": createCooperationProjectCommand.CooperationProjectName,
|
206
|
"cooperationProjectName": createCooperationProjectCommand.CooperationProjectName,
|
189
|
})
|
207
|
})
|
|
|
208
|
+ if err != nil {
|
|
|
209
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
210
|
+ }
|
190
|
if !nameAvailable {
|
211
|
if !nameAvailable {
|
191
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复")
|
212
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "共创项目名称重复")
|
192
|
}
|
213
|
}
|
|
@@ -212,14 +233,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
|
@@ -212,14 +233,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
212
|
CreatedAt: time.Now(),
|
233
|
CreatedAt: time.Now(),
|
213
|
ApplicantCount: 0,
|
234
|
ApplicantCount: 0,
|
214
|
}
|
235
|
}
|
215
|
- var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
216
|
- if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
217
|
- "transactionContext": transactionContext,
|
|
|
218
|
- }); err != nil {
|
|
|
219
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
220
|
- } else {
|
|
|
221
|
- cooperationProjectRepository = value
|
|
|
222
|
- }
|
236
|
+
|
223
|
if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil {
|
237
|
if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil {
|
224
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
238
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
225
|
} else {
|
239
|
} else {
|