正在显示
5 个修改的文件
包含
70 行增加
和
16 行删除
| @@ -5,7 +5,6 @@ import ( | @@ -5,7 +5,6 @@ import ( | ||
| 5 | "github.com/linmadan/egglib-go/core/application" | 5 | "github.com/linmadan/egglib-go/core/application" |
| 6 | "github.com/linmadan/egglib-go/utils/tool_funs" | 6 | "github.com/linmadan/egglib-go/utils/tool_funs" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/command" |
| 8 | - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/dto" | ||
| 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| @@ -119,11 +118,28 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -119,11 +118,28 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 119 | organization = data | 118 | organization = data |
| 120 | } | 119 | } |
| 121 | 120 | ||
| 121 | + // 查找共创模式 | ||
| 122 | + var cooperationModeRepository domain.CooperationModeRepository | ||
| 123 | + if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ | ||
| 124 | + "transactionContext": transactionContext, | ||
| 125 | + }); err != nil { | ||
| 126 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 127 | + } else { | ||
| 128 | + cooperationModeRepository = value | ||
| 129 | + } | ||
| 130 | + cooperationMode, err := cooperationModeRepository.FindOne(map[string]interface{}{"cooperationModeNumber": createCooperationProjectCommand.CooperationModeNumber}) | ||
| 131 | + if err != nil { | ||
| 132 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 133 | + } | ||
| 134 | + if cooperationMode == nil { | ||
| 135 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationProjectCommand.CooperationModeNumber)) | ||
| 136 | + } else { | ||
| 122 | newCooperationProject := &domain.CooperationProject{ | 137 | newCooperationProject := &domain.CooperationProject{ |
| 123 | CooperationProjectNumber: createCooperationProjectCommand.CooperationModeNumber, | 138 | CooperationProjectNumber: createCooperationProjectCommand.CooperationModeNumber, |
| 124 | CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, | 139 | CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, |
| 125 | CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes, | 140 | CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes, |
| 126 | CooperationProjectSponsor: sponsor, | 141 | CooperationProjectSponsor: sponsor, |
| 142 | + CooperationMode: cooperationMode, | ||
| 127 | CooperationProjectPublisher: publisher, | 143 | CooperationProjectPublisher: publisher, |
| 128 | CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription, | 144 | CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription, |
| 129 | CooperationProjectPublishTime: time.Now(), | 145 | CooperationProjectPublishTime: time.Now(), |
| @@ -153,6 +169,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -153,6 +169,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 153 | } | 169 | } |
| 154 | return cooperationProject, nil | 170 | return cooperationProject, nil |
| 155 | } | 171 | } |
| 172 | + } | ||
| 156 | } | 173 | } |
| 157 | 174 | ||
| 158 | // GetCooperationProject 返回共创项目服务 | 175 | // GetCooperationProject 返回共创项目服务 |
| @@ -192,7 +209,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -192,7 +209,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 192 | } | 209 | } |
| 193 | } | 210 | } |
| 194 | 211 | ||
| 195 | -// ListCooperationProject 返回共创项目服务列表 | 212 | +// ListCooperationProject 返回共创项目列表 |
| 196 | func (cooperationProjectService *CooperationProjectService) ListCooperationProject(listCooperationProjectQuery *query.ListCooperationProjectQuery) (interface{}, error) { | 213 | func (cooperationProjectService *CooperationProjectService) ListCooperationProject(listCooperationProjectQuery *query.ListCooperationProjectQuery) (interface{}, error) { |
| 197 | if err := listCooperationProjectQuery.ValidateQuery(); err != nil { | 214 | if err := listCooperationProjectQuery.ValidateQuery(); err != nil { |
| 198 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 215 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
| @@ -218,7 +235,6 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje | @@ -218,7 +235,6 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje | ||
| 218 | if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil { | 235 | if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil { |
| 219 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 236 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 220 | } else { | 237 | } else { |
| 221 | - | ||
| 222 | //var cooperationModeRepository domain.CooperationModeRepository | 238 | //var cooperationModeRepository domain.CooperationModeRepository |
| 223 | //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | 239 | //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ |
| 224 | // "transactionContext": transactionContext, | 240 | // "transactionContext": transactionContext, |
| @@ -237,22 +253,23 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje | @@ -237,22 +253,23 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje | ||
| 237 | // } | 253 | // } |
| 238 | //} | 254 | //} |
| 239 | // | 255 | // |
| 240 | - var res []*dto.CooperationProjectsDto | ||
| 241 | - for i := range cooperationProjects { | ||
| 242 | - p := cooperationProjects[i] | ||
| 243 | - tp := &dto.CooperationProjectsDto{} | ||
| 244 | - tp.LoadDto(p, &domain.CooperationMode{}) | ||
| 245 | - res = append(res, tp) | ||
| 246 | - } | ||
| 247 | - | 256 | + //var res []*dto.CooperationProjectsDto |
| 257 | + //for i := range cooperationProjects { | ||
| 258 | + // p := cooperationProjects[i] | ||
| 259 | + // tp := &dto.CooperationProjectsDto{} | ||
| 260 | + // tp.LoadDto(p, &domain.CooperationMode{}) | ||
| 261 | + // res = append(res, tp) | ||
| 262 | + //} | ||
| 248 | if err := transactionContext.CommitTransaction(); err != nil { | 263 | if err := transactionContext.CommitTransaction(); err != nil { |
| 249 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 264 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 250 | } | 265 | } |
| 251 | return map[string]interface{}{ | 266 | return map[string]interface{}{ |
| 252 | //"grid": map[string]interface{}{ | 267 | //"grid": map[string]interface{}{ |
| 253 | - "total": count, | ||
| 254 | - "list": res, | 268 | + //"total": count, |
| 269 | + //"list": res, | ||
| 255 | //}, | 270 | //}, |
| 271 | + "list": cooperationProjects, | ||
| 272 | + "total": count, | ||
| 256 | }, nil | 273 | }, nil |
| 257 | } | 274 | } |
| 258 | } | 275 | } |
| @@ -18,6 +18,8 @@ type CooperationProject struct { | @@ -18,6 +18,8 @@ type CooperationProject struct { | ||
| 18 | CooperationProjectPublisher *User `json:"cooperationProjectPublisher"` | 18 | CooperationProjectPublisher *User `json:"cooperationProjectPublisher"` |
| 19 | // 共创项目发起人 | 19 | // 共创项目发起人 |
| 20 | CooperationProjectSponsor *User `json:"cooperationProjectSponsor"` | 20 | CooperationProjectSponsor *User `json:"cooperationProjectSponsor"` |
| 21 | + // 共创模式 | ||
| 22 | + CooperationMode *CooperationMode `json:"cooperationMode"` | ||
| 21 | // 共创项目发起部门 | 23 | // 共创项目发起部门 |
| 22 | Department *Department `json:"department"` | 24 | Department *Department `json:"department"` |
| 23 | // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 | 25 | // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 |
| @@ -21,6 +21,8 @@ type CooperationProject struct { | @@ -21,6 +21,8 @@ type CooperationProject struct { | ||
| 21 | CooperationProjectPublisher *domain.User `comment:"共创项目发布人"` | 21 | CooperationProjectPublisher *domain.User `comment:"共创项目发布人"` |
| 22 | // 共创项目发起人 | 22 | // 共创项目发起人 |
| 23 | CooperationProjectSponsor *domain.User `comment:"共创项目发起人"` | 23 | CooperationProjectSponsor *domain.User `comment:"共创项目发起人"` |
| 24 | + // 共创模式编码 | ||
| 25 | + CooperationModeNumber string `comment:"共创模式编号"` | ||
| 24 | // 共创项目发起部门 | 26 | // 共创项目发起部门 |
| 25 | Department *domain.Department `comment:"共创项目发起部门"` | 27 | Department *domain.Department `comment:"共创项目发起部门"` |
| 26 | // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 | 28 | // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 |
| @@ -5,7 +5,9 @@ import ( | @@ -5,7 +5,9 @@ import ( | ||
| 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | 5 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" |
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | -func TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel *models.CooperationProject) (*domain.CooperationProject, error) { | 8 | +func TransformToCooperationProjectDomainModelFromPgModels( |
| 9 | + cooperationProjectModel *models.CooperationProject, | ||
| 10 | + cooperationMode *models.CooperationMode) (*domain.CooperationProject, error) { | ||
| 9 | return &domain.CooperationProject{ | 11 | return &domain.CooperationProject{ |
| 10 | CooperationProjectId: cooperationProjectModel.CooperationProjectId, | 12 | CooperationProjectId: cooperationProjectModel.CooperationProjectId, |
| 11 | CooperationProjectNumber: cooperationProjectModel.CooperationProjectNumber, | 13 | CooperationProjectNumber: cooperationProjectModel.CooperationProjectNumber, |
| @@ -14,6 +16,20 @@ func TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectMode | @@ -14,6 +16,20 @@ func TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectMode | ||
| 14 | CooperationProjectPublishTime: cooperationProjectModel.CooperationProjectPublishTime, | 16 | CooperationProjectPublishTime: cooperationProjectModel.CooperationProjectPublishTime, |
| 15 | CooperationProjectPublisher: cooperationProjectModel.CooperationProjectPublisher, | 17 | CooperationProjectPublisher: cooperationProjectModel.CooperationProjectPublisher, |
| 16 | CooperationProjectSponsor: cooperationProjectModel.CooperationProjectSponsor, | 18 | CooperationProjectSponsor: cooperationProjectModel.CooperationProjectSponsor, |
| 19 | + CooperationMode: &domain.CooperationMode{ | ||
| 20 | + CooperationModeId: cooperationMode.CooperationModeId, | ||
| 21 | + CooperationModeNumber: cooperationMode.CooperationModeNumber, | ||
| 22 | + CooperationModeName: cooperationMode.CooperationModeName, | ||
| 23 | + Status: cooperationMode.Status, | ||
| 24 | + Org: cooperationMode.Org, | ||
| 25 | + Company: cooperationMode.Company, | ||
| 26 | + Remarks: cooperationMode.Remarks, | ||
| 27 | + Operator: cooperationMode.Operator, | ||
| 28 | + OperateTime: cooperationMode.OperateTime, | ||
| 29 | + UpdatedAt: cooperationMode.UpdatedAt, | ||
| 30 | + DeletedAt: cooperationMode.DeletedAt, | ||
| 31 | + CreatedAt: cooperationMode.CreatedAt, | ||
| 32 | + }, | ||
| 17 | Department: cooperationProjectModel.Department, | 33 | Department: cooperationProjectModel.Department, |
| 18 | CooperationProjectUndertakerTypes: cooperationProjectModel.CooperationProjectUndertakerTypes, | 34 | CooperationProjectUndertakerTypes: cooperationProjectModel.CooperationProjectUndertakerTypes, |
| 19 | Org: cooperationProjectModel.Org, | 35 | Org: cooperationProjectModel.Org, |
| @@ -34,6 +34,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -34,6 +34,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 34 | "cooperation_project_publish_time", | 34 | "cooperation_project_publish_time", |
| 35 | "cooperation_project_publisher", | 35 | "cooperation_project_publisher", |
| 36 | "cooperation_project_sponsor", | 36 | "cooperation_project_sponsor", |
| 37 | + "cooperation_mode_number", | ||
| 37 | "department", | 38 | "department", |
| 38 | "cooperation_project_undertaker_types", | 39 | "cooperation_project_undertaker_types", |
| 39 | "org", | 40 | "org", |
| @@ -67,6 +68,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -67,6 +68,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 67 | &cooperationProject.CooperationProjectPublishTime, | 68 | &cooperationProject.CooperationProjectPublishTime, |
| 68 | &cooperationProject.CooperationProjectPublisher, | 69 | &cooperationProject.CooperationProjectPublisher, |
| 69 | &cooperationProject.CooperationProjectSponsor, | 70 | &cooperationProject.CooperationProjectSponsor, |
| 71 | + &cooperationProject.CooperationMode.CooperationModeNumber, | ||
| 70 | &cooperationProject.Department, | 72 | &cooperationProject.Department, |
| 71 | pg.Array(&cooperationProject.CooperationProjectUndertakerTypes), | 73 | pg.Array(&cooperationProject.CooperationProjectUndertakerTypes), |
| 72 | &cooperationProject.Org, | 74 | &cooperationProject.Org, |
| @@ -86,6 +88,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -86,6 +88,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 86 | cooperationProject.CooperationProjectPublishTime, | 88 | cooperationProject.CooperationProjectPublishTime, |
| 87 | cooperationProject.CooperationProjectPublisher, | 89 | cooperationProject.CooperationProjectPublisher, |
| 88 | cooperationProject.CooperationProjectSponsor, | 90 | cooperationProject.CooperationProjectSponsor, |
| 91 | + cooperationProject.CooperationMode.CooperationModeNumber, | ||
| 89 | cooperationProject.Department, | 92 | cooperationProject.Department, |
| 90 | pg.Array(cooperationProject.CooperationProjectUndertakerTypes), | 93 | pg.Array(cooperationProject.CooperationProjectUndertakerTypes), |
| 91 | cooperationProject.Org, | 94 | cooperationProject.Org, |
| @@ -109,6 +112,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -109,6 +112,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 109 | &cooperationProject.CooperationProjectPublishTime, | 112 | &cooperationProject.CooperationProjectPublishTime, |
| 110 | &cooperationProject.CooperationProjectPublisher, | 113 | &cooperationProject.CooperationProjectPublisher, |
| 111 | &cooperationProject.CooperationProjectSponsor, | 114 | &cooperationProject.CooperationProjectSponsor, |
| 115 | + &cooperationProject.CooperationMode.CooperationModeNumber, | ||
| 112 | &cooperationProject.Department, | 116 | &cooperationProject.Department, |
| 113 | pg.Array(&cooperationProject.CooperationProjectUndertakerTypes), | 117 | pg.Array(&cooperationProject.CooperationProjectUndertakerTypes), |
| 114 | &cooperationProject.Org, | 118 | &cooperationProject.Org, |
| @@ -128,6 +132,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | @@ -128,6 +132,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain. | ||
| 128 | cooperationProject.CooperationProjectPublishTime, | 132 | cooperationProject.CooperationProjectPublishTime, |
| 129 | cooperationProject.CooperationProjectPublisher, | 133 | cooperationProject.CooperationProjectPublisher, |
| 130 | cooperationProject.CooperationProjectSponsor, | 134 | cooperationProject.CooperationProjectSponsor, |
| 135 | + cooperationProject.CooperationMode.CooperationModeNumber, | ||
| 131 | cooperationProject.Department, | 136 | cooperationProject.Department, |
| 132 | pg.Array(cooperationProject.CooperationProjectUndertakerTypes), | 137 | pg.Array(cooperationProject.CooperationProjectUndertakerTypes), |
| 133 | cooperationProject.Org, | 138 | cooperationProject.Org, |
| @@ -171,7 +176,13 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | @@ -171,7 +176,13 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | ||
| 171 | if cooperationProjectModel.CooperationProjectId == 0 { | 176 | if cooperationProjectModel.CooperationProjectId == 0 { |
| 172 | return nil, nil | 177 | return nil, nil |
| 173 | } else { | 178 | } else { |
| 174 | - return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel) | 179 | + // 获取共创模式 |
| 180 | + cooperationModeModel := new(models.CooperationMode) | ||
| 181 | + cooperationModeQuery := tx.Model(cooperationModeModel) | ||
| 182 | + if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | ||
| 183 | + return nil, err | ||
| 184 | + } | ||
| 185 | + return transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel) | ||
| 175 | } | 186 | } |
| 176 | } | 187 | } |
| 177 | 188 | ||
| @@ -186,7 +197,13 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | @@ -186,7 +197,13 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int | ||
| 186 | return 0, cooperationProjects, err | 197 | return 0, cooperationProjects, err |
| 187 | } else { | 198 | } else { |
| 188 | for _, cooperationProjectModel := range cooperationProjectModels { | 199 | for _, cooperationProjectModel := range cooperationProjectModels { |
| 189 | - if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel); err != nil { | 200 | + // 获取共创模式 |
| 201 | + cooperationModeModel := new(models.CooperationMode) | ||
| 202 | + cooperationModeQuery := tx.Model(cooperationModeModel) | ||
| 203 | + if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationProjectModel.CooperationModeNumber).First(); err != nil { | ||
| 204 | + return 0, nil, err | ||
| 205 | + } | ||
| 206 | + if cooperationProject, err := transform.TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel, cooperationModeModel); err != nil { | ||
| 190 | return 0, cooperationProjects, err | 207 | return 0, cooperationProjects, err |
| 191 | } else { | 208 | } else { |
| 192 | cooperationProjects = append(cooperationProjects, cooperationProject) | 209 | cooperationProjects = append(cooperationProjects, cooperationProject) |
-
请 注册 或 登录 后发表评论