...
|
...
|
@@ -5,7 +5,6 @@ import ( |
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"github.com/linmadan/egglib-go/utils/tool_funs"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
...
|
...
|
@@ -119,39 +118,57 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro |
|
|
organization = data
|
|
|
}
|
|
|
|
|
|
newCooperationProject := &domain.CooperationProject{
|
|
|
CooperationProjectNumber: createCooperationProjectCommand.CooperationModeNumber,
|
|
|
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
|
|
|
CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes,
|
|
|
CooperationProjectSponsor: sponsor,
|
|
|
CooperationProjectPublisher: publisher,
|
|
|
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
|
|
|
CooperationProjectPublishTime: time.Now(),
|
|
|
Company: company,
|
|
|
Department: organization.ToDepartment(),
|
|
|
Org: organization,
|
|
|
Operator: operator,
|
|
|
OperateTime: time.Now(),
|
|
|
Status: 0,
|
|
|
UpdatedAt: time.Time{},
|
|
|
DeletedAt: time.Time{},
|
|
|
CreatedAt: time.Now(),
|
|
|
}
|
|
|
var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
// 查找共创模式
|
|
|
var cooperationModeRepository domain.CooperationModeRepository
|
|
|
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationProjectRepository = value
|
|
|
cooperationModeRepository = value
|
|
|
}
|
|
|
if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); err != nil {
|
|
|
cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if cooperationMode == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber))
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
newCooperationProject := &domain.CooperationProject{
|
|
|
CooperationProjectNumber: createCooperationProjectCommand.CooperationModeNumber,
|
|
|
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
|
|
|
CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes,
|
|
|
CooperationProjectSponsor: sponsor,
|
|
|
CooperationMode: cooperationMode,
|
|
|
CooperationProjectPublisher: publisher,
|
|
|
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
|
|
|
CooperationProjectPublishTime: time.Now(),
|
|
|
Company: company,
|
|
|
Department: organization.ToDepartment(),
|
|
|
Org: organization,
|
|
|
Operator: operator,
|
|
|
OperateTime: time.Now(),
|
|
|
Status: 0,
|
|
|
UpdatedAt: time.Time{},
|
|
|
DeletedAt: time.Time{},
|
|
|
CreatedAt: time.Now(),
|
|
|
}
|
|
|
var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationProjectRepository = value
|
|
|
}
|
|
|
if cooperationProject, err := cooperationProjectRepository.Save(newCooperationProject); 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 cooperationProject, nil
|
|
|
}
|
|
|
return cooperationProject, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -192,7 +209,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec |
|
|
}
|
|
|
}
|
|
|
|
|
|
// ListCooperationProject 返回共创项目服务列表
|
|
|
// ListCooperationProject 返回共创项目列表
|
|
|
func (cooperationProjectService *CooperationProjectService) ListCooperationProject(listCooperationProjectQuery *query.ListCooperationProjectQuery) (interface{}, error) {
|
|
|
if err := listCooperationProjectQuery.ValidateQuery(); err != nil {
|
|
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
...
|
...
|
@@ -218,7 +235,6 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje |
|
|
if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
|
|
|
//var cooperationModeRepository domain.CooperationModeRepository
|
|
|
//if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
...
|
...
|
@@ -237,22 +253,23 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje |
|
|
// }
|
|
|
//}
|
|
|
//
|
|
|
var res []*dto.CooperationProjectsDto
|
|
|
for i := range cooperationProjects {
|
|
|
p := cooperationProjects[i]
|
|
|
tp := &dto.CooperationProjectsDto{}
|
|
|
tp.LoadDto(p, &domain.CooperationMode{})
|
|
|
res = append(res, tp)
|
|
|
}
|
|
|
|
|
|
//var res []*dto.CooperationProjectsDto
|
|
|
//for i := range cooperationProjects {
|
|
|
// p := cooperationProjects[i]
|
|
|
// tp := &dto.CooperationProjectsDto{}
|
|
|
// tp.LoadDto(p, &domain.CooperationMode{})
|
|
|
// res = append(res, tp)
|
|
|
//}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return map[string]interface{}{
|
|
|
//"grid": map[string]interface{}{
|
|
|
"total": count,
|
|
|
"list": res,
|
|
|
//"total": count,
|
|
|
//"list": res,
|
|
|
//},
|
|
|
"list": cooperationProjects,
|
|
|
"total": count,
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
|