作者 陈志颖

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev-chenzhiying
package dto
import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
type CooperationProjectsDto struct {
*domain.CooperationProject
CooperationMode *CooperationMode `json:"cooperationMode"`
}
type CooperationMode struct {
// 共创模式ID
CooperationModeId int64 `json:"cooperationModeId,string"`
// 共创模式编码,唯一确定
CooperationModeNumber string `json:"cooperationModeNumber"`
// 模式名称,唯一确定
CooperationModeName string `json:"cooperationModeName"`
}
func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode) {
dto.CooperationProject = project
dto.CooperationMode = &CooperationMode{
CooperationModeId: mode.CooperationModeId,
CooperationModeName: mode.CooperationModeName,
CooperationModeNumber: mode.CooperationModeNumber,
}
}
... ...
... ... @@ -5,6 +5,7 @@ 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,13 +120,15 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
}
newCooperationProject := &domain.CooperationProject{
CooperationProjectNumber: "",
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(),
... ... @@ -215,13 +218,40 @@ 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,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// cooperationProjectRepository = value
//}
//var modeMap = make(map[string]*domain.CooperationMode)
//if _, cooperationProjects, err := cooperationModeRepository.Find(map[string]interface{}{"companyId":listCooperationProjectQuery.CompanyId,"orgId":listCooperationProjectQuery.OrgId}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//}else{
// for i:=range cooperationProjects{
// p :=cooperationProjects[i]
// modeMap[p.CooperationModeNumber]=p
// }
//}
//
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": cooperationProjects,
"list": res,
//},
}, nil
}
... ...
... ... @@ -9,3 +9,10 @@ type Org struct {
// 公司
Company *Company `json:"company"`
}
func (org *Org) ToDepartment() *Department {
return &Department{
DepartmentId: org.OrgId,
DepartmentName: org.OrgName,
}
}
... ...
... ... @@ -7,15 +7,15 @@ type User struct {
// 用户基本id
UserBaseId int64 `json:"userBaseId,string"`
// 用户所属组织机构
Org *Org `json:"org"`
Org *Org `json:"org,omitempty"`
// 用户关联的组织机构
Orgs []*Org `json:"orgs"`
Orgs []*Org `json:"orgs,omitempty"`
// 用户所属的部门
Department *Department `json:"department"`
// 用户角色
Roles []*Role `json:"role"`
Roles []*Role `json:"role,omitempty"`
// 冗余字段,jsonb格式,不限制存放内容
UserInfo *UserInfo `json:"userInfo"`
UserInfo *UserInfo `json:"userInfo,omitempty"`
// 用户类型
UserType int32 `json:"userType"`
// 用户姓名
... ... @@ -25,5 +25,5 @@ type User struct {
// 状态
Status int32 `json:"status"`
// 用户关联公司信息
Company *Company `json:"company"`
Company *Company `json:"company,omitempty"`
}
... ...
... ... @@ -175,12 +175,16 @@ func (translator *UserTranslator) ToOperatorFromRepresentation(user *UserDetail)
Orgs: nil,
Department: nil,
Roles: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
UserInfo: &domain.UserInfo{
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
UserAvatar: user.UserInfo.Avatar,
},
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
}, nil
}
... ... @@ -192,12 +196,16 @@ func (translator *UserTranslator) ToUserFromRepresentation(user *UserDetail) (*d
Orgs: nil,
Department: nil,
Roles: nil,
UserInfo: nil,
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
UserInfo: &domain.UserInfo{
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
UserAvatar: user.UserInfo.Avatar,
},
UserType: 0,
UserName: user.UserInfo.UserName,
UserPhone: user.UserInfo.Phone,
Status: 0,
Company: nil,
}, nil
}
... ...