作者 yangfu

适配数据

@@ -11,7 +11,7 @@ import ( @@ -11,7 +11,7 @@ import (
11 11
12 type CreateContractUndertakerFeedbackCommand struct { 12 type CreateContractUndertakerFeedbackCommand struct {
13 // 合约承接方反馈内容附件 13 // 合约承接方反馈内容附件
14 - FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment" valid:"Required"` 14 + FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment"`
15 // 合约承接方反馈内容 15 // 合约承接方反馈内容
16 FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"` 16 FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
17 // 共创合约编号 17 // 共创合约编号
  1 +package dto
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  5 +)
  6 +
  7 +type CooperationApplicationDto struct {
  8 + // 共创申请ID
  9 + CooperationApplicationId int64 `json:"cooperationApplicationId,string"`
  10 + // 共创申请人
  11 + CooperationApplicationApplicant *User `json:"cooperationApplicationApplicant"`
  12 + // 共创申请描述附件
  13 + CooperationApplicationAttachment []*domain.Attachment `json:"cooperationApplicationAttachment"`
  14 + // 共创申请描述
  15 + CooperationApplicationDescription string `json:"cooperationApplicationDescription"`
  16 + // 共创申请审核状态,1待审核,2已同意,3已拒绝
  17 + CooperationApplicationStatus int32 `json:"cooperationApplicationStatus"`
  18 + // 共创申请审核人
  19 + CooperationApplicationVerifier *User `json:"cooperationApplicationVerifier"`
  20 + // 共创申请审核描述
  21 + CooperationApplicationVerifyDescription string `json:"cooperationApplicationVerifyDescription"`
  22 + // 共创申请审核时间
  23 + CooperationApplicationVerifyTime int64 `json:"cooperationApplicationVerifyTime"`
  24 + // 共创申请时间
  25 + CooperationApplyTime int64 `json:"cooperationApplyTime"`
  26 + // 共创项目
  27 + CooperationProject *CooperationProject `json:"cooperationProject"`
  28 + // 数据所属组织机构
  29 + Org *Org `json:"org"`
  30 + // 是否被取消标志位
  31 + IsCanceled bool `json:"isCanceled"`
  32 + // 公司
  33 + Company *Company `json:"company"`
  34 + // 创建时间
  35 + //CreatedAt time.Time `json:"createdAt"`
  36 + // 删除时间
  37 + //DeletedAt time.Time `json:"deletedAt"`
  38 + // 更新时间
  39 + //UpdatedAt time.Time `json:"updatedAt"`
  40 +}
  41 +
  42 +// User 用户第三方服务防腐模型
  43 +type User struct {
  44 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  45 + UserId int64 `json:"userId"`
  46 + // 冗余字段,jsonb格式,不限制存放内容
  47 + UserInfo *domain.UserInfo `json:"userInfo,omitempty"`
  48 + // 用户所属的部门
  49 + Department *Department `json:"department"`
  50 +}
  51 +
  52 +type Company struct {
  53 + // 公司ID,通过集成REST上下文获取
  54 + CompanyId int64 `json:"companyId"`
  55 + // 公司logo
  56 + CompanyLogo string `json:"companyLogo"`
  57 + // 公司名称
  58 + CompanyName string `json:"companyName"`
  59 +}
  60 +
  61 +// Org 组织机构值对象
  62 +type Org struct {
  63 + // 组织机构ID
  64 + OrgId int64 `json:"orgId"`
  65 + // 组织名称
  66 + OrgName string `json:"orgName"`
  67 + // 公司
  68 + //Company *Company `json:"company"`
  69 +}
  70 +
  71 +// Department 部门值对象
  72 +type Department struct {
  73 + // 部门ID,通过REST集成上下文获取
  74 + DepartmentId int64 `json:"departmentId"`
  75 + // 部门名称
  76 + DepartmentName string `json:"departmentName"`
  77 +}
  78 +
  79 +// CooperationProject 共创项目实体
  80 +type CooperationProject struct {
  81 + // 共创项目ID
  82 + CooperationProjectId int64 `json:"cooperationProjectId"`
  83 + // 共创项目编号
  84 + CooperationProjectNumber string `json:"cooperationProjectNumber"`
  85 + // 共创项目描述
  86 + CooperationProjectDescription string `json:"cooperationProjectDescription"`
  87 + // 共创项目名称
  88 + CooperationProjectName string `json:"cooperationProjectName"`
  89 + // 图片附件
  90 + Attachment []*domain.Attachment `json:"attachment"`
  91 +}
  92 +
  93 +func (data *CooperationApplicationDto) LoadDto(a *domain.CooperationApplication) {
  94 + data.CooperationApplicationId = a.CooperationApplicationId
  95 + data.CooperationApplicationApplicant = data.LoadUser(a.CooperationApplicationApplicant)
  96 + data.CooperationApplicationAttachment = a.CooperationApplicationAttachment
  97 + data.CooperationApplicationDescription = a.CooperationApplicationDescription
  98 + data.CooperationApplicationStatus = a.CooperationApplicationStatus
  99 + data.CooperationApplicationVerifier = data.LoadUser(a.CooperationApplicationVerifier)
  100 + data.CooperationApplicationVerifyDescription = a.CooperationApplicationDescription
  101 + data.CooperationApplicationVerifyTime = a.CooperationApplicationVerifyTime.Unix() * 1000
  102 + data.CooperationApplyTime = a.CooperationApplyTime.Unix() * 1000
  103 + data.CooperationProject = data.LoadCooperationProject(a.CooperationProject)
  104 + data.Org = data.LoadOrg(a.Org)
  105 + data.IsCanceled = a.IsCanceled
  106 + data.Company = data.LoadCompany(a.Company)
  107 +}
  108 +
  109 +func (data *CooperationApplicationDto) LoadUser(v *domain.User) *User {
  110 + if v == nil {
  111 + return &User{}
  112 + }
  113 + return &User{
  114 + UserId: v.UserId,
  115 + UserInfo: v.UserInfo,
  116 + }
  117 +}
  118 +
  119 +func (data *CooperationApplicationDto) LoadCompany(v *domain.Company) *Company {
  120 + return &Company{
  121 + CompanyId: v.CompanyId,
  122 + CompanyName: v.CompanyName,
  123 + }
  124 +}
  125 +
  126 +func (data *CooperationApplicationDto) LoadOrg(v *domain.Org) *Org {
  127 + return &Org{
  128 + OrgId: v.OrgId,
  129 + OrgName: v.OrgName,
  130 + }
  131 +}
  132 +
  133 +func (data *CooperationApplicationDto) LoadDepartment(v *domain.Org) *Department {
  134 + return &Department{
  135 + DepartmentId: v.OrgId,
  136 + DepartmentName: v.OrgName,
  137 + }
  138 +}
  139 +
  140 +func (data *CooperationApplicationDto) LoadCooperationProject(v *domain.CooperationProject) *CooperationProject {
  141 + return &CooperationProject{
  142 + CooperationProjectId: v.CooperationProjectId,
  143 + CooperationProjectNumber: v.CooperationProjectNumber,
  144 + CooperationProjectDescription: v.CooperationProjectDescription,
  145 + CooperationProjectName: v.CooperationProjectName,
  146 + Attachment: v.Attachment,
  147 + }
  148 +}
@@ -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/cooperationApplication/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/dto"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/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"
@@ -327,7 +328,9 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati @@ -327,7 +328,9 @@ func (cooperationApplicationService *CooperationApplicationService) GetCooperati
327 if err := transactionContext.CommitTransaction(); err != nil { 328 if err := transactionContext.CommitTransaction(); err != nil {
328 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 329 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
329 } 330 }
330 - return cooperationApplication, nil 331 + coProjectDto := &dto.CooperationApplicationDto{}
  332 + coProjectDto.LoadDto(cooperationApplication)
  333 + return coProjectDto, nil
331 } 334 }
332 } 335 }
333 336
@@ -424,10 +427,34 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper @@ -424,10 +427,34 @@ func (cooperationApplicationService *CooperationApplicationService) SearchCooper
424 defer func() { 427 defer func() {
425 _ = transactionContext.RollbackTransaction() 428 _ = transactionContext.RollbackTransaction()
426 }() 429 }()
427 - if err := transactionContext.CommitTransaction(); err != nil {  
428 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 430 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  431 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  432 + "transactionContext": transactionContext,
  433 + }); err != nil {
  434 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  435 + } else {
  436 + cooperationApplicationRepository = value
  437 + }
  438 + if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(searchCooperationApplicationQuery)); err != nil {
  439 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  440 + } else {
  441 + if err := transactionContext.CommitTransaction(); err != nil {
  442 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  443 + }
  444 + var coProjectDtos []*dto.CooperationApplicationDto
  445 + for i := range cooperationApplications {
  446 + var coProjectDto = &dto.CooperationApplicationDto{}
  447 + coProjectDto.LoadDto(cooperationApplications[i])
  448 + coProjectDtos = append(coProjectDtos, coProjectDto)
  449 + }
  450 +
  451 + return map[string]interface{}{
  452 + "grid": map[string]interface{}{
  453 + "total": count,
  454 + "list": coProjectDtos,
  455 + },
  456 + }, nil
429 } 457 }
430 - return nil, nil  
431 } 458 }
432 459
433 // UpdateCooperationApplication 更新共创申请服务 460 // UpdateCooperationApplication 更新共创申请服务