作者 tangxuhui

更新 数据结构调整适配

package dto
//CooperationMode 共创模式
// type CooperationMode struct {
// CooperationModeID int `json:"cooperationModeId,string,"`
// CooperationModeName string `json:"cooperationModeName"`
// CooperationModeNumber string `json:"cooperationModeNumber"`
// }
//Department 部门
// type Department struct {
// DepartmentId int `json:"departmentId,string"`
// DepartmentName string `json:"departmentName"`
// DepartmentNumber string `json:"departmentNumber"`
// }
//UserBase 嵌套的用户数据
// type UserBase struct {
// UsersId int `json:"usersId"`
// UserInfo struct {
// UsersName string `json:"usersName"`
// UsersCode string `json:"usersCode"`
// Phone string `json:"phone"`
// UsersId int `json:"userId,string"`
// } `json:"cooperationProjectSpons"` //共创发起人
// }
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)
//CooperationProjectItem 返回共创项目列表项
// type CooperationProjectItem struct {
// CooperationMode CooperationMode `json:"cooperationMode"` //共创模式
// CooperationProjectID int `json:"cooperationProjectId,string,"` //id
// CooperationProjectName string `json:"cooperationProjectName"` //共创项目名称
// CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
// CooperationProjectPublishTime string `json:"cooperationProjectPublishTime"` //共创项目发布时间
// Department Department `json:"department"` //项目发起部门
// Status int `json:"status"` //项目状态
// CooperationProjectSpons UserBase `json:"cooperationProjectSpons"`
// }
type CooperationProjectItem struct {
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //项目模式
CooperationProjectID int `json:"cooperationProjectId,string,"` //id
CooperationProjectName string `json:"cooperationProjectName"` //共创项目名称
CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //承接对象
Department struct {
DepartmentNumber string `json:"departmentNumber"`
DepartmentId int `json:"departmentId,string,"`
DepartmentName string `json:"departmentName"`
} `json:"department"` //项目发起部门
Status int `json:"status"` //项目状态
CooperationProjectPublishTime int `json:"cooperationProjectPublishTime"`
CooperationProjectSponsor struct {
UsersId int `json:"usersId"`
UserInfo struct {
UsersName string `json:"usersName"`
Phone string `json:"phone"`
UsersId int `json:"userId,string"`
} `json:"UserInfo"`
} `json:"cooperationProjectSponsor"` //共创发起人
}
func ToCooperationProjectItem(projecetParam *allied_creation_cooperation.CooperationProject) *CooperationProjectItem {
data := CooperationProjectItem{
CooperationMode: projecetParam.CooperationMode,
CooperationProjectID: projecetParam.CooperationProjectId,
CooperationProjectName: projecetParam.CooperationProjectName,
CooperationProjectNumber: projecetParam.CooperationProjectNumber,
CooperationProjectUndertakerType: projecetParam.CooperationProjectUndertakerType,
Department: projecetParam.Department,
Status: projecetParam.Status,
CooperationProjectPublishTime: int(projecetParam.CooperationProjectPublishTime.Unix()),
}
data.CooperationProjectSponsor.UsersId = projecetParam.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo.UsersId = projecetParam.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo.Phone = projecetParam.CooperationProjectSponsor.UserInfo.Phone
data.CooperationProjectSponsor.UserInfo.UsersName = projecetParam.CooperationProjectSponsor.UserInfo.UsersName
return &data
}
//CooperationProjectInfo 返回共创项目详情
// type CooperationProjectInfo struct {
// CooperationMode CooperationMode `json:"cooperationMode"` //共创模式
// CooperationProjectID int `json:"cooperationProjectId,string,"` //id
// CooperationProjectName string `json:"cooperationProjectName"` //共创项目名称
// CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
// CooperationProjectPublishTime string `json:"cooperationProjectPublishTime"` //共创项目发布时间
// Department Department `json:"department"` //项目发起部门
// Status int `json:"status"` //项目状态
// CooperationProjectSpons UserBase `json:"cooperationProjectSpons"` // 项目发起人
// }
type CooperationProjectInfo struct {
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //共创模式
CooperationProjectID int `json:"cooperationProjectId,string,"` //id
CooperationProjectName string `json:"cooperationProjectName"` //共创项目名称
CooperationProjectNumber string `json:"cooperationProjectNumber"` //项目编号
CooperationProjectPublishTime int `json:"cooperationProjectPublishTime"` //共创项目发布时间
CooperationProjectUndertakerType []int `json:"cooperationProjectUndertakerType"` //承接对象
CooperationProjectDescription string `json:"cooperationProjectDescription"` //共创描述
Department struct {
DepartmentNumber string `json:"departmentNumber"`
DepartmentId int `json:"departmentId,string,"`
DepartmentName string `json:"departmentName"`
} `json:"department"` //项目发起部门
Status int `json:"status"` //项目状态
CooperationProjectSponsor struct {
UsersId int `json:"usersId"`
UserInfo struct {
UsersName string `json:"usersName"`
Phone string `json:"phone"`
UsersId int `json:"userId,string"`
} `json:"UserInfo"`
} `json:"cooperationProjectSponsor"` //共创发起人
Attachment []allied_creation_cooperation.ProjectAttachment `json:"attachment"` //图片附件
}
func ToCooperationProjectInfo(projecetParam *allied_creation_cooperation.CooperationProject) *CooperationProjectInfo {
data := CooperationProjectInfo{
CooperationMode: projecetParam.CooperationMode,
CooperationProjectID: projecetParam.CooperationProjectId,
CooperationProjectName: projecetParam.CooperationProjectName,
CooperationProjectNumber: projecetParam.CooperationProjectNumber,
CooperationProjectUndertakerType: projecetParam.CooperationProjectUndertakerType,
Department: projecetParam.Department,
Status: projecetParam.Status,
CooperationProjectPublishTime: int(projecetParam.CooperationProjectPublishTime.Unix()),
Attachment: projecetParam.Attachment,
CooperationProjectDescription: projecetParam.CooperationProjectDescription,
}
data.CooperationProjectSponsor.UsersId = projecetParam.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo.UsersId = projecetParam.CooperationProjectSponsor.UsersId
data.CooperationProjectSponsor.UserInfo.Phone = projecetParam.CooperationProjectSponsor.UserInfo.Phone
data.CooperationProjectSponsor.UserInfo.UsersName = projecetParam.CooperationProjectSponsor.UserInfo.UsersName
return &data
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/mobile/cooperation/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
)
... ... @@ -13,7 +14,7 @@ import (
type CooperationProjectService struct {
}
// CreateCooperationProject TODO:创建共创项目
// CreateCooperationProject 创建共创项目
func (srv CooperationProjectService) CreateCooperationProject(createCooperationProjectCommand *command.CreateCooperationProjectCommand) (interface{}, error) {
if err := createCooperationProjectCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -41,22 +42,22 @@ func (srv CooperationProjectService) CreateCooperationProject(createCooperationP
return data, nil
}
// GetCooperationProject TODO:返回共创项目明细
func (srv CooperationProjectService) GetCooperationProject(userMenusCommand *command.GetCooperationProjectQuery) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
resultMenu, err := creationUserGateway.UserAccessMenus(allied_creation_user.ReqUserAccessMenus{
UserId: int(userMenusCommand.Operator.UserId),
// GetCooperationProject 返回共创项目明细
func (srv CooperationProjectService) GetCooperationProject(projectQuery *command.GetCooperationProjectQuery) (interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
result, err := creationCooperationGateway.CooperationProjectGet(allied_creation_cooperation.ReqCooperationProjectGet{
CooperationProjectId: projectQuery.CooperationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
return map[string]interface{}{
"accessMenus": resultMenu.Menus,
}, nil
return dto.ToCooperationProjectInfo(&result.CooperationProject), nil
}
// UpdateCooperationProject TODO:企业更新共创项目
// UpdateCooperationProject
//TODO 企业更新共创项目
func (srv CooperationProjectService) UpdateCooperationProject(userMenusCommand *command.UpdateCooperationProjectCommand) (interface{}, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(
userMenusCommand.Operator)
... ... @@ -86,7 +87,7 @@ func (srv CooperationProjectService) EndCooperationProject(userMenusCommand *com
}, nil
}
// SearchCooperationProject TODO:获取共创项目列表
// SearchCooperationProject 企业获取共创项目列表
func (srv CooperationProjectService) SearchCooperationProject(projectQuery *command.ListCooperationProjectQuery) (int, interface{}, error) {
creationCooperationGateway := allied_creation_cooperation.NewHttplibAlliedCreationCooperation(
projectQuery.Operator)
... ... @@ -98,7 +99,10 @@ func (srv CooperationProjectService) SearchCooperationProject(projectQuery *comm
if err != nil {
return 0, nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// var dataList []dto.CooperationProjectItem
//TODO 数据填充
return int(result.Total), result.List, nil
var dataList []dto.CooperationProjectItem
for i := range result.List {
item := dto.ToCooperationProjectItem(&result.List[i])
dataList = append(dataList, *item)
}
return int(result.Total), dataList, nil
}
... ...
... ... @@ -63,11 +63,10 @@ type CooperationApplicationInfo struct {
CooperationProjectName string `json:"cooperationProjectName"` //共创名称
CooperationProjectNumber string `json:"cooperationProjectNumber"` //共创编号
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string,"`
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //项目模式
}
CooperationApplicationApplicant struct {
UserName string `json:"userName"` //申请人名字
... ... @@ -107,7 +106,9 @@ func ToCooperationApplicationInfo(applicationParam *allied_creation_cooperation.
data.CooperationProject.CooperationProjectID = objectParam.CooperationProjectId
data.CooperationProject.CooperationProjectName = objectParam.CooperationProjectName
data.CooperationProject.CooperationProjectNumber = objectParam.CooperationProjectNumber
data.CooperationProject.CooperationMode = objectParam.CooperationMode
data.CooperationProject.CooperationMode.CooperationModeId = objectParam.CooperationMode.CooperationModeId
data.CooperationProject.CooperationMode.CooperationModeName = objectParam.CooperationMode.CooperationModeName
data.CooperationProject.CooperationMode.CooperationModeNumber = objectParam.CooperationMode.CooperationModeNumber
data.CooperationApplicationApplicant.UserName = applicationParam.CooperationApplicationApplicant.UserInfo.UserName
data.CooperationApplicationApplicant.Phone = applicationParam.CooperationApplicationApplicant.UserInfo.UserPhone
data.CooperationApplicationApplicant.UserCode = applicationParam.CooperationApplicationApplicant.UserInfo.UserPhone
... ...
... ... @@ -17,17 +17,12 @@ type CooperationProjectInfo struct {
OrgName string `json:"orgName"`
} `json:"org"` //项目创建时的组织
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string,"`
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //项目模式
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Attachment []struct {
FileType string `json:"fileType"`
Name string `json:"name"`
Url string `json:"url"`
FileSize int `json:"fileSize"`
} `json:"attachment"` //图片附件
Attachment []allied_creation_cooperation.ProjectAttachment `json:"attachment"` //图片附件
CooperationProjectId int `json:"cooperationProjectId,string,"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectNumber string `json:"cooperationProjectNumber"`
... ... @@ -60,7 +55,6 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj
Org: param.Org,
CooperationMode: param.CooperationMode,
CooperationProjectDescription: param.CooperationProjectDescription,
Attachment: param.Attachment,
CooperationProjectId: param.CooperationProjectId,
CooperationProjectName: param.CooperationProjectName,
CooperationProjectNumber: param.CooperationProjectNumber,
... ... @@ -69,7 +63,9 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj
CooperationProjectUndertakerType: param.CooperationProjectUndertakerType,
Department: param.Department,
Status: param.Status,
Attachment: param.Attachment,
}
data.CooperationProjectSponsor.UsersCode = param.CooperationProjectSponsor.UserInfo.UsersCode
data.CooperationProjectSponsor.UsersName = param.CooperationProjectSponsor.UserInfo.UsersName
data.CooperationProjectSponsor.UsersId = param.CooperationProjectSponsor.UsersId
... ... @@ -77,7 +73,7 @@ func ToCooperationProjectInfo(param *allied_creation_cooperation.CooperationProj
return &data
}
type CooperationApplication struct {
type CooperationApplicationItem struct {
CooperationApplicationApplicant struct {
Company struct {
CompanyID int `json:"companyId"`
... ... @@ -116,8 +112,8 @@ type CooperationApplication struct {
} `json:"cooperationApplicationAttachment"` //附件
}
func ToCooperationApplication(param *allied_creation_cooperation.CooperationApplication) *CooperationApplication {
data := CooperationApplication{
func ToCooperationApplicationItem(param *allied_creation_cooperation.CooperationApplication) *CooperationApplicationItem {
data := CooperationApplicationItem{
CooperationApplicationApplicant: param.CooperationApplicationApplicant,
CooperationApplicationDescription: param.CooperationApplicationDescription,
CooperationApplicationID: param.CooperationApplicationID,
... ...
... ... @@ -73,10 +73,10 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var (
applications []dto.CooperationApplication
applications []dto.CooperationApplicationItem
)
for i := range resultApplication.Gride.List {
item := dto.ToCooperationApplication(&resultApplication.Gride.List[i])
item := dto.ToCooperationApplicationItem(&resultApplication.Gride.List[i])
applications = append(applications, *item)
}
data := map[string]interface{}{
... ...
... ... @@ -2,6 +2,12 @@ package allied_creation_cooperation
import "time"
type ProjectAttachment struct {
FileType string `json:"fileType"`
Name string `json:"name"`
Url string `json:"url"`
FileSize int `json:"fileSize"`
} //图片附件
type CooperationProject struct {
Company struct {
CompanyId int `json:"companyId,string,"`
... ... @@ -13,17 +19,12 @@ type CooperationProject struct {
OrgName string `json:"orgName"`
} `json:"org"` //项目创建时的组织
CooperationMode struct {
CooperationModeId int `json:"cooperationModeId,string,"`
CooperationModeId int `json:"cooperationModeId,string"`
CooperationModeName string `json:"cooperationModeName"`
CooperationModeNumber string `json:"cooperationModeNumber"`
} `json:"cooperationMode"` //项目模式
CooperationProjectDescription string `json:"cooperationProjectDescription"`
Attachment []struct {
FileType string `json:"fileType"`
Name string `json:"name"`
Url string `json:"url"`
FileSize int `json:"fileSize"`
} `json:"attachment"` //图片附件
Attachment []ProjectAttachment `json:"attachment"`
CooperationProjectId int `json:"cooperationProjectId,string,"`
CooperationProjectName string `json:"cooperationProjectName"`
CooperationProjectNumber string `json:"cooperationProjectNumber"`
... ...