作者 yangfu

适配数据

... ... @@ -11,7 +11,7 @@ import (
type CreateContractUndertakerFeedbackCommand struct {
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment" valid:"Required"`
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment"`
// 合约承接方反馈内容
FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
// 共创合约编号
... ...
package dto
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
)
type CooperationApplicationDto struct {
// 共创申请ID
CooperationApplicationId int64 `json:"cooperationApplicationId,string"`
// 共创申请人
CooperationApplicationApplicant *User `json:"cooperationApplicationApplicant"`
// 共创申请描述附件
CooperationApplicationAttachment []*domain.Attachment `json:"cooperationApplicationAttachment"`
// 共创申请描述
CooperationApplicationDescription string `json:"cooperationApplicationDescription"`
// 共创申请审核状态,1待审核,2已同意,3已拒绝
CooperationApplicationStatus int32 `json:"cooperationApplicationStatus"`
// 共创申请审核人
CooperationApplicationVerifier *User `json:"cooperationApplicationVerifier"`
// 共创申请审核描述
CooperationApplicationVerifyDescription string `json:"cooperationApplicationVerifyDescription"`
// 共创申请审核时间
CooperationApplicationVerifyTime int64 `json:"cooperationApplicationVerifyTime"`
// 共创申请时间
CooperationApplyTime int64 `json:"cooperationApplyTime"`
// 共创项目
CooperationProject *CooperationProject `json:"cooperationProject"`
// 数据所属组织机构
Org *Org `json:"org"`
// 是否被取消标志位
IsCanceled bool `json:"isCanceled"`
// 公司
Company *Company `json:"company"`
// 创建时间
//CreatedAt time.Time `json:"createdAt"`
// 删除时间
//DeletedAt time.Time `json:"deletedAt"`
// 更新时间
//UpdatedAt time.Time `json:"updatedAt"`
}
// User 用户第三方服务防腐模型
type User struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
// 冗余字段,jsonb格式,不限制存放内容
UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
// 用户所属的部门
Department *Department `json:"department"`
}
type Company struct {
// 公司ID,通过集成REST上下文获取
CompanyId int64 `json:"companyId"`
// 公司logo
CompanyLogo string `json:"companyLogo"`
// 公司名称
CompanyName string `json:"companyName"`
}
// Org 组织机构值对象
type Org struct {
// 组织机构ID
OrgId int64 `json:"orgId"`
// 组织名称
OrgName string `json:"orgName"`
// 公司
//Company *Company `json:"company"`
}
// Department 部门值对象
type Department struct {
// 部门ID,通过REST集成上下文获取
DepartmentId int64 `json:"departmentId"`
// 部门名称
DepartmentName string `json:"departmentName"`
}
// CooperationProject 共创项目实体
type CooperationProject struct {
// 共创项目ID
CooperationProjectId int64 `json:"cooperationProjectId"`
// 共创项目编号
CooperationProjectNumber string `json:"cooperationProjectNumber"`
// 共创项目描述
CooperationProjectDescription string `json:"cooperationProjectDescription"`
// 共创项目名称
CooperationProjectName string `json:"cooperationProjectName"`
// 图片附件
Attachment []*domain.Attachment `json:"attachment"`
}
func (data *CooperationApplicationDto) LoadDto(a *domain.CooperationApplication) {
data.CooperationApplicationId = a.CooperationApplicationId
data.CooperationApplicationApplicant = data.LoadUser(a.CooperationApplicationApplicant)
data.CooperationApplicationAttachment = a.CooperationApplicationAttachment
data.CooperationApplicationDescription = a.CooperationApplicationDescription
data.CooperationApplicationStatus = a.CooperationApplicationStatus
data.CooperationApplicationVerifier = data.LoadUser(a.CooperationApplicationVerifier)
data.CooperationApplicationVerifyDescription = a.CooperationApplicationDescription
data.CooperationApplicationVerifyTime = a.CooperationApplicationVerifyTime.Unix() * 1000
data.CooperationApplyTime = a.CooperationApplyTime.Unix() * 1000
data.CooperationProject = data.LoadCooperationProject(a.CooperationProject)
data.Org = data.LoadOrg(a.Org)
data.IsCanceled = a.IsCanceled
data.Company = data.LoadCompany(a.Company)
}
func (data *CooperationApplicationDto) LoadUser(v *domain.User) *User {
if v == nil {
return &User{}
}
return &User{
UserId: v.UserId,
UserInfo: v.UserInfo,
}
}
func (data *CooperationApplicationDto) LoadCompany(v *domain.Company) *Company {
return &Company{
CompanyId: v.CompanyId,
CompanyName: v.CompanyName,
}
}
func (data *CooperationApplicationDto) LoadOrg(v *domain.Org) *Org {
return &Org{
OrgId: v.OrgId,
OrgName: v.OrgName,
}
}
func (data *CooperationApplicationDto) LoadDepartment(v *domain.Org) *Department {
return &Department{
DepartmentId: v.OrgId,
DepartmentName: v.OrgName,
}
}
func (data *CooperationApplicationDto) LoadCooperationProject(v *domain.CooperationProject) *CooperationProject {
return &CooperationProject{
CooperationProjectId: v.CooperationProjectId,
CooperationProjectNumber: v.CooperationProjectNumber,
CooperationProjectDescription: v.CooperationProjectDescription,
CooperationProjectName: v.CooperationProjectName,
Attachment: v.Attachment,
}
}
... ...
... ... @@ -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/cooperationApplication/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/dto"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
... ... @@ -327,7 +328,9 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return cooperationApplication, nil
coProjectDto := &dto.CooperationApplicationDto{}
coProjectDto.LoadDto(cooperationApplication)
return coProjectDto, nil
}
}
... ... @@ -424,10 +427,34 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(searchCooperationApplicationQuery)); 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())
}
var coProjectDtos []*dto.CooperationApplicationDto
for i := range cooperationApplications {
var coProjectDto = &dto.CooperationApplicationDto{}
coProjectDto.LoadDto(cooperationApplications[i])
coProjectDtos = append(coProjectDtos, coProjectDto)
}
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": coProjectDtos,
},
}, nil
}
return nil, nil
}
// UpdateCooperationApplication 更新共创申请服务
... ...