cooperation_application_dto.go 5.2 KB
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"`
}

// 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"`
	//	共创模式
	CooperationMode *domain.CooperationMode `json:"cooperationMode"`
}

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.CooperationApplicationVerifyDescription
	data.CooperationApplicationVerifyTime = a.CooperationApplicationVerifyTime.Unix() * 1000
	data.CooperationApplyTime = a.CooperationApplyTime.Unix() * 1000
	data.CooperationProject = data.LoadCooperationProject(a.CooperationProject)
	data.Org = data.LoadOrg(a.Org)
	if a.IsCanceled == 1 {
		data.IsCanceled = false
	} else {
		data.IsCanceled = true
	}
	data.Company = data.LoadCompany(a.Company)
}

func (data *CooperationApplicationDto) LoadUser(v *domain.User) *User {
	if v == nil {
		return &User{}
	}
	result := User{
		UserId:   v.UserId,
		UserInfo: v.UserInfo,
	}
	if v.Department != nil {
		result.Department = &Department{
			DepartmentId:   v.Department.DepartmentId,
			DepartmentName: v.Department.DepartmentName,
		}
	}

	return &result
}

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,
		CooperationMode:               v.CooperationMode,
	}
}