作者 陈志颖

feat:共创申请参数调整

... ... @@ -8,7 +8,9 @@ import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"strconv"
"time"
)
// CooperationApplicationService 共创申请服务
... ... @@ -93,15 +95,92 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
var cooperationProjectRepository domain.CooperationProjectRepository
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
}
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectNumber": createCooperationApplicationCommand.CooperationProjectNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createCooperationApplicationCommand.CooperationProjectNumber))
} else {
}
//TODO 获取申请人
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取申请人
var applicant *domain.User
if data, err := userService.UserFrom(createCooperationApplicationCommand.CompanyId, createCooperationApplicationCommand.OrgId, createCooperationApplicationCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
applicant = data
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(createCooperationApplicationCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(createCooperationApplicationCommand.CompanyId, createCooperationApplicationCommand.OrgId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organization = data
}
newCooperationApplication := &domain.CooperationApplication{
//ApplicantUid: createCooperationApplicationCommand.ApplicantUid,
CooperationApplicationDescription: createCooperationApplicationCommand.CooperationApplicationDescription,
CooperationApplicationAttachment: createCooperationApplicationCommand.CooperationApplicationAttachment,
//CooperationProjectNumber: createCooperationApplicationCommand.CooperationProjectNumber,
//CompanyId: createCooperationApplicationCommand.CompanyId,
//OrgId: createCooperationApplicationCommand.OrgId,
//UserId: createCooperationApplicationCommand.UserId,
CooperationApplicationApplicant: applicant,
CooperationApplicationAttachment: createCooperationApplicationCommand.CooperationApplicationAttachment,
CooperationApplicationDescription: createCooperationApplicationCommand.CooperationApplicationDescription,
CooperationApplicationStatus: 1,
CooperationApplicationVerifier: nil,
CooperationApplicationVerifyDescription: "",
CooperationApplicationVerifyTime: time.Time{},
CooperationApplyTime: time.Now(),
CooperationProject: cooperationProject,
Org: organization,
IsCanceled: false,
Company: company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
}
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -16,25 +16,25 @@ type UpdateCooperationContractCommand struct {
// 共创合约编号
CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
// 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
CooperationProjectNumber string `cname:"共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001" json:"cooperationProjectNumber" valid:"Required"`
CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"`
// 部门编码
DepartmentNumber string `cname:"部门编码" json:"departmentNumber" valid:"Required"`
DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"`
// 共创合约承接对象,1员工,2共创用户,3公开
CooperationContractUndertakerType []int32 `cname:"共创合约承接对象,1员工,2共创用户,3公开" json:"cooperationContractUndertakerType" valid:"Required"`
CooperationContractUndertakerTypes []int32 `cname:"共创合约承接对象" json:"cooperationContractUndertakerTypes" valid:"Required"`
// 共创合约名称
CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
// 共创模式编码,手动输入,唯一确定
CooperationModeNumber string `cname:"共创模式编码,手动输入,唯一确定" json:"cooperationModeNumber" valid:"Required"`
CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`
// 共创合约发起人uid
SponsorUid string `cname:"共创合约发起人uid" json:"sponsorUid,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据is" json:"userBaseId,string" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
}
func (updateCooperationContractCommand *UpdateCooperationContractCommand) Valid(validation *validation.Validation) {
... ...
... ... @@ -12,11 +12,11 @@ type CreateCooperationProjectCommand struct {
// 共创项目名称
CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName" valid:"Required"`
// 承接对象,1员工,2共创用户,3公开,可以多选
CooperationProjectUndertakerType []int32 `cname:"承接对象,1员工,2共创用户,3公开,可以多选" json:"cooperationProjectUndertakerType" valid:"Required"`
CooperationProjectUndertakerTypes []int32 `cname:"承接对象" json:"cooperationProjectUndertakerTypes" valid:"Required"`
// 共创项目发起人uid
SponsorUid string `cname:"共创项目发起人uid" json:"sponsorUid" valid:"Required"`
SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"`
// 共创项目发布人uid
PublisherUid string `cname:"共创项目发布人uid" json:"publisherUid" valid:"Required"`
PublisherUid string `cname:"共创项目发布人UID" json:"publisherUid" valid:"Required"`
// 共创项目描述
CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription,omitempty"`
// 公司ID,通过集成REST上下文获取
... ...
... ... @@ -119,20 +119,20 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
}
newCooperationProject := &domain.CooperationProject{
CooperationProjectNumber: "",
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
CooperationProjectUndertakerType: createCooperationProjectCommand.CooperationProjectUndertakerType,
CooperationProjectSponsor: sponsor,
CooperationProjectPublisher: publisher,
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
Company: company,
Org: organization,
Operator: operator,
OperateTime: time.Now(),
Status: 0,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
CooperationProjectNumber: "",
CooperationProjectName: createCooperationProjectCommand.CooperationProjectName,
CooperationProjectUndertakerTypes: createCooperationProjectCommand.CooperationProjectUndertakerTypes,
CooperationProjectSponsor: sponsor,
CooperationProjectPublisher: publisher,
CooperationProjectDescription: createCooperationProjectCommand.CooperationProjectDescription,
Company: company,
Org: organization,
Operator: operator,
OperateTime: time.Now(),
Status: 0,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
... ...
... ... @@ -22,7 +22,7 @@ type CooperationApplication struct {
CooperationApplicationVerifyTime time.Time `json:"cooperationApplicationVerifyTime"`
// 共创申请时间
CooperationApplyTime time.Time `json:"cooperationApplyTime"`
// 共创项目编号
// 共创项目
CooperationProject *CooperationProject `json:"cooperationProject"`
// 数据所属组织机构
Org *Org `json:"org"`
... ... @@ -83,26 +83,5 @@ func (cooperationApplication *CooperationApplication) Update(data map[string]int
if cooperationApplyTime, ok := data["cooperationApplyTime"]; ok {
cooperationApplication.CooperationApplyTime = cooperationApplyTime.(time.Time)
}
if cooperationProjectId, ok := data["cooperationProjectId"]; ok {
cooperationApplication.CooperationProject.CooperationProjectId = cooperationProjectId.(int64)
}
if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
cooperationApplication.CooperationProject.CooperationProjectNumber = cooperationProjectNumber.(string)
}
if cooperationProjectDescription, ok := data["cooperationProjectDescription"]; ok {
cooperationApplication.CooperationProject.CooperationProjectDescription = cooperationProjectDescription.(string)
}
if cooperationProjectName, ok := data["cooperationProjectName"]; ok {
cooperationApplication.CooperationProject.CooperationProjectName = cooperationProjectName.(string)
}
if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok {
cooperationApplication.CooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time)
}
if operateTime, ok := data["operateTime"]; ok {
cooperationApplication.CooperationProject.OperateTime = operateTime.(time.Time)
}
if status, ok := data["status"]; ok {
cooperationApplication.CooperationProject.Status = status.(int32)
}
return nil
}
... ...
... ... @@ -21,11 +21,11 @@ type CooperationProject struct {
// 共创项目发起部门
Department *Department `json:"department"`
// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
CooperationProjectUndertakerType []int32 `json:"cooperationProjectUndertakerType"`
CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
// 数据所属组织机构
Org *Org `json:"org"`
// 图片附件
Attachment *Attachment `json:"attachment"`
Attachment []*Attachment `json:"attachment"`
// 公司
Company *Company `json:"company"`
// 操作人
... ... @@ -151,7 +151,7 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{}
cooperationProject.CooperationProjectSponsor.Company.CompanyId = companyId.(int64)
}
if cooperationProjectUndertakerType, ok := data["cooperationProjectUndertakerType"]; ok {
cooperationProject.CooperationProjectUndertakerType = cooperationProjectUndertakerType.([]int32)
cooperationProject.CooperationProjectUndertakerTypes = cooperationProjectUndertakerType.([]int32)
}
if operateTime, ok := data["operateTime"]; ok {
cooperationProject.OperateTime = operateTime.(time.Time)
... ...
... ... @@ -24,7 +24,9 @@ type CooperationProject struct {
// 共创项目发起部门
Department *domain.Department `comment:"共创项目发起部门"`
// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
CooperationProjectUndertakerType []int32 `comment:"共创项目承接对象,1员工,2共创用户,3公开,可以多选" pg:",array"`
CooperationProjectUndertakerTypes []int32 `comment:"共创项目承接对象,1员工,2共创用户,3公开,可以多选" pg:",array"`
// 附件
Attachment []*domain.Attachment `comment:"附件"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 公司
... ...
... ... @@ -19,22 +19,23 @@ func TransformToCooperationApplicationDomainModelFromPgModels(
CooperationApplicationVerifyTime: cooperationApplicationModel.CooperationApplicationVerifyTime,
CooperationApplyTime: cooperationApplicationModel.CooperationApplyTime,
CooperationProject: &domain.CooperationProject{
CooperationProjectId: cooperationProject.CooperationProjectId,
CooperationProjectNumber: cooperationProject.CooperationProjectNumber,
CooperationProjectDescription: cooperationProject.CooperationProjectDescription,
CooperationProjectName: cooperationProject.CooperationProjectName,
CooperationProjectPublishTime: cooperationProject.CooperationProjectPublishTime,
CooperationProjectPublisher: cooperationProject.CooperationProjectPublisher,
CooperationProjectSponsor: cooperationProject.CooperationProjectSponsor,
CooperationProjectUndertakerType: cooperationProject.CooperationProjectUndertakerType,
Org: cooperationProject.Org,
Company: cooperationProject.Company,
Operator: cooperationProject.Operator,
OperateTime: cooperationProject.OperateTime,
Status: cooperationProject.Status,
UpdatedAt: cooperationProject.UpdatedAt,
DeletedAt: cooperationProject.DeletedAt,
CreatedAt: cooperationProject.CreatedAt,
CooperationProjectNumber: cooperationProject.CooperationProjectNumber,
CooperationProjectDescription: cooperationProject.CooperationProjectDescription,
CooperationProjectName: cooperationProject.CooperationProjectName,
CooperationProjectPublishTime: cooperationProject.CooperationProjectPublishTime,
CooperationProjectPublisher: cooperationProject.CooperationProjectPublisher,
CooperationProjectSponsor: cooperationProject.CooperationProjectSponsor,
Department: cooperationProject.Department,
CooperationProjectUndertakerTypes: cooperationProject.CooperationProjectUndertakerTypes,
Org: cooperationProject.Org,
Attachment: cooperationProject.Attachment,
Company: cooperationProject.Company,
Operator: cooperationProject.Operator,
OperateTime: cooperationProject.OperateTime,
Status: cooperationProject.Status,
UpdatedAt: cooperationProject.UpdatedAt,
DeletedAt: cooperationProject.DeletedAt,
CreatedAt: cooperationProject.CreatedAt,
},
Org: cooperationApplicationModel.Org,
IsCanceled: cooperationApplicationModel.IsCanceled,
... ...
... ... @@ -7,22 +7,22 @@ import (
func TransformToCooperationProjectDomainModelFromPgModels(cooperationProjectModel *models.CooperationProject) (*domain.CooperationProject, error) {
return &domain.CooperationProject{
CooperationProjectId: cooperationProjectModel.CooperationProjectId,
CooperationProjectNumber: cooperationProjectModel.CooperationProjectNumber,
CooperationProjectDescription: cooperationProjectModel.CooperationProjectDescription,
CooperationProjectName: cooperationProjectModel.CooperationProjectName,
CooperationProjectPublishTime: cooperationProjectModel.CooperationProjectPublishTime,
CooperationProjectPublisher: cooperationProjectModel.CooperationProjectPublisher,
CooperationProjectSponsor: cooperationProjectModel.CooperationProjectSponsor,
Department: cooperationProjectModel.Department,
CooperationProjectUndertakerType: cooperationProjectModel.CooperationProjectUndertakerType,
Org: cooperationProjectModel.Org,
Company: cooperationProjectModel.Company,
Operator: cooperationProjectModel.Operator,
OperateTime: cooperationProjectModel.OperateTime,
Status: cooperationProjectModel.Status,
UpdatedAt: cooperationProjectModel.UpdatedAt,
DeletedAt: cooperationProjectModel.DeletedAt,
CreatedAt: cooperationProjectModel.CreatedAt,
CooperationProjectId: cooperationProjectModel.CooperationProjectId,
CooperationProjectNumber: cooperationProjectModel.CooperationProjectNumber,
CooperationProjectDescription: cooperationProjectModel.CooperationProjectDescription,
CooperationProjectName: cooperationProjectModel.CooperationProjectName,
CooperationProjectPublishTime: cooperationProjectModel.CooperationProjectPublishTime,
CooperationProjectPublisher: cooperationProjectModel.CooperationProjectPublisher,
CooperationProjectSponsor: cooperationProjectModel.CooperationProjectSponsor,
Department: cooperationProjectModel.Department,
CooperationProjectUndertakerTypes: cooperationProjectModel.CooperationProjectUndertakerTypes,
Org: cooperationProjectModel.Org,
Company: cooperationProjectModel.Company,
Operator: cooperationProjectModel.Operator,
OperateTime: cooperationProjectModel.OperateTime,
Status: cooperationProjectModel.Status,
UpdatedAt: cooperationProjectModel.UpdatedAt,
DeletedAt: cooperationProjectModel.DeletedAt,
CreatedAt: cooperationProjectModel.CreatedAt,
}, nil
}
... ...
... ... @@ -35,9 +35,9 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
"cooperation_application_verify_description",
"cooperation_application_verify_time",
"cooperation_apply_time",
"cooperation_project",
"cooperation_project_number",
"org",
"isCanceled",
"is_canceled",
"company",
"created_at",
"deleted_at",
... ... @@ -60,7 +60,7 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
pg.Scan(
&cooperationApplication.CooperationApplicationId,
&cooperationApplication.CooperationApplicationApplicant,
pg.Array(&cooperationApplication.CooperationApplicationAttachment),
&cooperationApplication.CooperationApplicationAttachment,
&cooperationApplication.CooperationApplicationDescription,
&cooperationApplication.CooperationApplicationStatus,
&cooperationApplication.CooperationApplicationVerifier,
... ...
... ... @@ -35,7 +35,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
"cooperation_project_publisher",
"cooperation_project_sponsor",
"department",
"cooperation_project_undertaker_type",
"cooperation_project_undertaker_types",
"org",
"company",
"operator",
... ... @@ -68,7 +68,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
&cooperationProject.CooperationProjectPublisher,
&cooperationProject.CooperationProjectSponsor,
&cooperationProject.Department,
pg.Array(&cooperationProject.CooperationProjectUndertakerType),
pg.Array(&cooperationProject.CooperationProjectUndertakerTypes),
&cooperationProject.Org,
&cooperationProject.Company,
&cooperationProject.Operator,
... ... @@ -87,7 +87,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
cooperationProject.CooperationProjectPublisher,
cooperationProject.CooperationProjectSponsor,
cooperationProject.Department,
pg.Array(cooperationProject.CooperationProjectUndertakerType),
pg.Array(cooperationProject.CooperationProjectUndertakerTypes),
cooperationProject.Org,
cooperationProject.Company,
cooperationProject.Operator,
... ... @@ -110,7 +110,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
&cooperationProject.CooperationProjectPublisher,
&cooperationProject.CooperationProjectSponsor,
&cooperationProject.Department,
pg.Array(&cooperationProject.CooperationProjectUndertakerType),
pg.Array(&cooperationProject.CooperationProjectUndertakerTypes),
&cooperationProject.Org,
&cooperationProject.Company,
&cooperationProject.Operator,
... ... @@ -129,7 +129,7 @@ func (repository *CooperationProjectRepository) Save(cooperationProject *domain.
cooperationProject.CooperationProjectPublisher,
cooperationProject.CooperationProjectSponsor,
cooperationProject.Department,
pg.Array(cooperationProject.CooperationProjectUndertakerType),
pg.Array(cooperationProject.CooperationProjectUndertakerTypes),
cooperationProject.Org,
cooperationProject.Company,
cooperationProject.Operator,
... ...
... ... @@ -14,7 +14,6 @@ func (controller *CooperationContractController) CreateCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
createCooperationContractCommand := &command.CreateCooperationContractCommand{}
_ = controller.Unmarshal(createCooperationContractCommand)
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
createCooperationContractCommand.CompanyId = header.CompanyId
createCooperationContractCommand.OrgId = header.OrgId
... ... @@ -28,7 +27,6 @@ func (controller *CooperationContractController) UpdateCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
updateCooperationContractCommand := &command.UpdateCooperationContractCommand{}
_ = controller.Unmarshal(updateCooperationContractCommand)
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
updateCooperationContractCommand.CompanyId = header.CompanyId
updateCooperationContractCommand.OrgId = header.OrgId
... ... @@ -43,7 +41,6 @@ func (controller *CooperationContractController) UpdateCooperationContract() {
func (controller *CooperationContractController) GetCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
getCooperationContractQuery := &query.GetCooperationContractQuery{}
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
getCooperationContractQuery.CompanyId = header.CompanyId
getCooperationContractQuery.OrgId = header.OrgId
... ... @@ -86,7 +83,6 @@ func (controller *CooperationContractController) SearchCooperationContract() {
func (controller *CooperationContractController) SearchCooperationContractByUndertaker() {
cooperationContractService := service.NewCooperationContractService(nil)
searchCooperationContractByUndertakerQuery := &query.SearchCooperationContractByUndertakerQuery{}
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
searchCooperationContractByUndertakerQuery.CompanyId = header.CompanyId
searchCooperationContractByUndertakerQuery.OrgId = header.OrgId
... ... @@ -103,7 +99,6 @@ func (controller *CooperationContractController) SearchCooperationContractByUnde
func (controller *CooperationContractController) ListCooperationContract() {
cooperationContractService := service.NewCooperationContractService(nil)
listCooperationContractQuery := &query.ListCooperationContractQuery{}
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
listCooperationContractQuery.CompanyId = header.CompanyId
listCooperationContractQuery.OrgId = header.OrgId
... ...