作者 yangfu

共创项目列表修改

@@ -19,6 +19,7 @@ require ( @@ -19,6 +19,7 @@ require (
19 github.com/onsi/ginkgo v1.14.2 19 github.com/onsi/ginkgo v1.14.2
20 github.com/onsi/gomega v1.10.3 20 github.com/onsi/gomega v1.10.3
21 github.com/sergi/go-diff v1.2.0 // indirect 21 github.com/sergi/go-diff v1.2.0 // indirect
  22 + github.com/shopspring/decimal v1.2.0
22 github.com/sirupsen/logrus v1.8.1 // indirect 23 github.com/sirupsen/logrus v1.8.1 // indirect
23 github.com/smartystreets/goconvey v1.6.4 // indirect 24 github.com/smartystreets/goconvey v1.6.4 // indirect
24 github.com/valyala/fasthttp v1.28.0 // indirect 25 github.com/valyala/fasthttp v1.28.0 // indirect
@@ -27,5 +28,4 @@ require ( @@ -27,5 +28,4 @@ require (
27 github.com/yudai/gojsondiff v1.0.0 // indirect 28 github.com/yudai/gojsondiff v1.0.0 // indirect
28 github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect 29 github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
29 github.com/yudai/pp v2.0.1+incompatible // indirect 30 github.com/yudai/pp v2.0.1+incompatible // indirect
30 - github.com/shopspring/decimal v1.2.0  
31 ) 31 )
@@ -223,6 +223,8 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= @@ -223,6 +223,8 @@ github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
223 github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 223 github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
224 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= 224 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
225 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= 225 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
  226 +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
  227 +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
226 github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= 228 github.com/siddontang/go v0.0.0-20170517070808-cb568a3e5cc0/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
227 github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s= 229 github.com/siddontang/goredis v0.0.0-20150324035039-760763f78400/go.mod h1:DDcKzU3qCuvj/tPnimWSsZZzvk9qvkvrIL5naVBPh5s=
228 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= 230 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
  1 +package dto
  2 +
  3 +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  4 +
  5 +type CooperationProjectsDto struct {
  6 + *domain.CooperationProject
  7 + CooperationMode *CooperationMode `json:"cooperationMode"`
  8 +}
  9 +
  10 +type CooperationMode struct {
  11 + // 共创模式ID
  12 + CooperationModeId int64 `json:"cooperationModeId,string"`
  13 + // 共创模式编码,唯一确定
  14 + CooperationModeNumber string `json:"cooperationModeNumber"`
  15 + // 模式名称,唯一确定
  16 + CooperationModeName string `json:"cooperationModeName"`
  17 +}
  18 +
  19 +func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode) {
  20 + dto.CooperationProject = project
  21 + dto.CooperationMode = &CooperationMode{
  22 + CooperationModeId: mode.CooperationModeId,
  23 + CooperationModeName: mode.CooperationModeName,
  24 + CooperationModeNumber: mode.CooperationModeNumber,
  25 + }
  26 +}
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ 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"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
@@ -119,13 +120,15 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -119,13 +120,15 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
119 } 120 }
120 121
121 newCooperationProject := &domain.CooperationProject{ 122 newCooperationProject := &domain.CooperationProject{
122 - CooperationProjectNumber: "", 123 + CooperationProjectNumber: createCooperationProjectCommand.CooperationModeNumber,
123 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName, 124 CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
124 CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes, 125 CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes,
125 CooperationProjectSponsor: sponsor, 126 CooperationProjectSponsor: sponsor,
126 CooperationProjectPublisher: publisher, 127 CooperationProjectPublisher: publisher,
127 CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription, 128 CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
  129 + CooperationProjectPublishTime: time.Now(),
128 Company: company, 130 Company: company,
  131 + Department: organization.ToDepartment(),
129 Org: organization, 132 Org: organization,
130 Operator: operator, 133 Operator: operator,
131 OperateTime: time.Now(), 134 OperateTime: time.Now(),
@@ -215,13 +218,40 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -215,13 +218,40 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
215 if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil { 218 if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil {
216 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 219 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
217 } else { 220 } else {
  221 +
  222 + //var cooperationModeRepository domain.CooperationModeRepository
  223 + //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  224 + // "transactionContext": transactionContext,
  225 + //}); err != nil {
  226 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  227 + //} else {
  228 + // cooperationProjectRepository = value
  229 + //}
  230 + //var modeMap = make(map[string]*domain.CooperationMode)
  231 + //if _, cooperationProjects, err := cooperationModeRepository.Find(map[string]interface{}{"companyId":listCooperationProjectQuery.CompanyId,"orgId":listCooperationProjectQuery.OrgId}); err != nil {
  232 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  233 + //}else{
  234 + // for i:=range cooperationProjects{
  235 + // p :=cooperationProjects[i]
  236 + // modeMap[p.CooperationModeNumber]=p
  237 + // }
  238 + //}
  239 + //
  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 +
218 if err := transactionContext.CommitTransaction(); err != nil { 248 if err := transactionContext.CommitTransaction(); err != nil {
219 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 249 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
220 } 250 }
221 return map[string]interface{}{ 251 return map[string]interface{}{
222 //"grid": map[string]interface{}{ 252 //"grid": map[string]interface{}{
223 "total": count, 253 "total": count,
224 - "list": cooperationProjects, 254 + "list": res,
225 //}, 255 //},
226 }, nil 256 }, nil
227 } 257 }
@@ -9,3 +9,10 @@ type Org struct { @@ -9,3 +9,10 @@ type Org struct {
9 // 公司 9 // 公司
10 Company *Company `json:"company"` 10 Company *Company `json:"company"`
11 } 11 }
  12 +
  13 +func (org *Org) ToDepartment() *Department {
  14 + return &Department{
  15 + DepartmentId: org.OrgId,
  16 + DepartmentName: org.OrgName,
  17 + }
  18 +}
@@ -7,15 +7,15 @@ type User struct { @@ -7,15 +7,15 @@ type User struct {
7 // 用户基本id 7 // 用户基本id
8 UserBaseId int64 `json:"userBaseId,string"` 8 UserBaseId int64 `json:"userBaseId,string"`
9 // 用户所属组织机构 9 // 用户所属组织机构
10 - Org *Org `json:"org"` 10 + Org *Org `json:"org,omitempty"`
11 // 用户关联的组织机构 11 // 用户关联的组织机构
12 - Orgs []*Org `json:"orgs"` 12 + Orgs []*Org `json:"orgs,omitempty"`
13 // 用户所属的部门 13 // 用户所属的部门
14 Department *Department `json:"department"` 14 Department *Department `json:"department"`
15 // 用户角色 15 // 用户角色
16 - Roles []*Role `json:"role"` 16 + Roles []*Role `json:"role,omitempty"`
17 // 冗余字段,jsonb格式,不限制存放内容 17 // 冗余字段,jsonb格式,不限制存放内容
18 - UserInfo *UserInfo `json:"userInfo"` 18 + UserInfo *UserInfo `json:"userInfo,omitempty"`
19 // 用户类型 19 // 用户类型
20 UserType int32 `json:"userType"` 20 UserType int32 `json:"userType"`
21 // 用户姓名 21 // 用户姓名
@@ -25,5 +25,5 @@ type User struct { @@ -25,5 +25,5 @@ type User struct {
25 // 状态 25 // 状态
26 Status int32 `json:"status"` 26 Status int32 `json:"status"`
27 // 用户关联公司信息 27 // 用户关联公司信息
28 - Company *Company `json:"company"` 28 + Company *Company `json:"company,omitempty"`
29 } 29 }
@@ -175,12 +175,16 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail) @@ -175,12 +175,16 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail)
175 Orgs: nil, 175 Orgs: nil,
176 Department: nil, 176 Department: nil,
177 Roles: nil, 177 Roles: nil,
178 - UserInfo: nil,  
179 - UserType: 0,  
180 - UserName: user.UserInfo.UserName,  
181 - UserPhone: user.UserInfo.Phone,  
182 - Status: 0,  
183 - Company: nil, 178 + UserInfo: &domain.UserInfo{
  179 + UserName: user.UserInfo.UserName,
  180 + UserPhone: user.UserInfo.Phone,
  181 + UserAvatar: user.UserInfo.Avatar,
  182 + },
  183 + UserType: 0,
  184 + UserName: user.UserInfo.UserName,
  185 + UserPhone: user.UserInfo.Phone,
  186 + Status: 0,
  187 + Company: nil,
184 }, nil 188 }, nil
185 } 189 }
186 190
@@ -192,12 +196,16 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d @@ -192,12 +196,16 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d
192 Orgs: nil, 196 Orgs: nil,
193 Department: nil, 197 Department: nil,
194 Roles: nil, 198 Roles: nil,
195 - UserInfo: nil,  
196 - UserType: 0,  
197 - UserName: user.UserInfo.UserName,  
198 - UserPhone: user.UserInfo.Phone,  
199 - Status: 0,  
200 - Company: nil, 199 + UserInfo: &domain.UserInfo{
  200 + UserName: user.UserInfo.UserName,
  201 + UserPhone: user.UserInfo.Phone,
  202 + UserAvatar: user.UserInfo.Avatar,
  203 + },
  204 + UserType: 0,
  205 + UserName: user.UserInfo.UserName,
  206 + UserPhone: user.UserInfo.Phone,
  207 + Status: 0,
  208 + Company: nil,
201 }, nil 209 }, nil
202 } 210 }
203 211