正在显示
13 个修改的文件
包含
152 行增加
和
103 行删除
| 1 | +package command | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "github.com/beego/beego/v2/core/validation" | ||
| 6 | + "reflect" | ||
| 7 | + "strings" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type CancelCooperationApplicationCommand struct { | ||
| 11 | + // 共创申请ID | ||
| 12 | + CooperationApplicationId int64 `cname:"共创申请ID" json:"cooperationApplicationId,string" valid:"Required"` | ||
| 13 | + // 公司ID,通过集成REST上下文获取 | ||
| 14 | + CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` | ||
| 15 | + // 组织机构id | ||
| 16 | + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` | ||
| 17 | + // 菜单编码,APP端必须 | ||
| 18 | + Code string `cname:"菜单编码" json:"code" valid:"Required"` | ||
| 19 | + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 | ||
| 20 | + UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` | ||
| 21 | + // 用户基础数据id | ||
| 22 | + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"` | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +func (cancelCooperationApplicationCommand *CancelCooperationApplicationCommand) Valid(validation *validation.Validation) { | ||
| 26 | + //validation.SetError("CustomValid", "未实现的自定义认证") | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (cancelCooperationApplicationCommand *CancelCooperationApplicationCommand) ValidateCommand() error { | ||
| 30 | + valid := validation.Validation{} | ||
| 31 | + b, err := valid.Valid(cancelCooperationApplicationCommand) | ||
| 32 | + if err != nil { | ||
| 33 | + return err | ||
| 34 | + } | ||
| 35 | + if !b { | ||
| 36 | + elem := reflect.TypeOf(cancelCooperationApplicationCommand).Elem() | ||
| 37 | + for _, validErr := range valid.Errors { | ||
| 38 | + field, isExist := elem.FieldByName(validErr.Field) | ||
| 39 | + if isExist { | ||
| 40 | + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1)) | ||
| 41 | + } else { | ||
| 42 | + return fmt.Errorf(validErr.Message) | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + return nil | ||
| 47 | +} |
| @@ -473,6 +473,53 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper | @@ -473,6 +473,53 @@ func (cooperationApplicationService *CooperationApplicationService) UpdateCooper | ||
| 473 | } | 473 | } |
| 474 | } | 474 | } |
| 475 | 475 | ||
| 476 | +// CancelCooperationApplication 取消共创申请 | ||
| 477 | +func (cooperationApplicationService *CooperationApplicationService) CancelCooperationApplication(cancelCooperationApplicationCommand *command.CancelCooperationApplicationCommand) (interface{}, error) { | ||
| 478 | + if err := cancelCooperationApplicationCommand.ValidateCommand(); err != nil { | ||
| 479 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
| 480 | + } | ||
| 481 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
| 482 | + if err != nil { | ||
| 483 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 484 | + } | ||
| 485 | + if err := transactionContext.StartTransaction(); err != nil { | ||
| 486 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 487 | + } | ||
| 488 | + defer func() { | ||
| 489 | + _ = transactionContext.RollbackTransaction() | ||
| 490 | + }() | ||
| 491 | + //TODO 校验用户菜单模块权限 | ||
| 492 | + | ||
| 493 | + var cooperationApplicationRepository domain.CooperationApplicationRepository | ||
| 494 | + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ | ||
| 495 | + "transactionContext": transactionContext, | ||
| 496 | + }); err != nil { | ||
| 497 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 498 | + } else { | ||
| 499 | + cooperationApplicationRepository = value | ||
| 500 | + } | ||
| 501 | + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": cancelCooperationApplicationCommand.CooperationApplicationId}) | ||
| 502 | + if err != nil { | ||
| 503 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 504 | + } | ||
| 505 | + if cooperationApplication == nil { | ||
| 506 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelCooperationApplicationCommand.CooperationApplicationId, 10))) | ||
| 507 | + } | ||
| 508 | + if err := cooperationApplication.Update(map[string]interface{}{ | ||
| 509 | + "isCanceled": true, | ||
| 510 | + }); err != nil { | ||
| 511 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
| 512 | + } | ||
| 513 | + if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil { | ||
| 514 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 515 | + } else { | ||
| 516 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
| 517 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 518 | + } | ||
| 519 | + return cooperationApplication, nil | ||
| 520 | + } | ||
| 521 | +} | ||
| 522 | + | ||
| 476 | func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { | 523 | func NewCooperationApplicationService(options map[string]interface{}) *CooperationApplicationService { |
| 477 | newCooperationApplicationService := &CooperationApplicationService{} | 524 | newCooperationApplicationService := &CooperationApplicationService{} |
| 478 | return newCooperationApplicationService | 525 | return newCooperationApplicationService |
| @@ -13,9 +13,7 @@ type UpdateCooperationContractCommand struct { | @@ -13,9 +13,7 @@ type UpdateCooperationContractCommand struct { | ||
| 13 | CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"` | 13 | CooperationContractId string `cname:"共创合约id" json:"cooperationContractId" valid:"Required"` |
| 14 | // 共创合约描述 | 14 | // 共创合约描述 |
| 15 | CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` | 15 | CooperationContractDescription string `cname:"共创合约描述" json:"cooperationContractDescription" valid:"Required"` |
| 16 | - // 共创合约编号 | ||
| 17 | - CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"` | ||
| 18 | - // 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001 | 16 | + // 共创项目编号 |
| 19 | CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"` | 17 | CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber" valid:"Required"` |
| 20 | // 部门编码 | 18 | // 部门编码 |
| 21 | DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"` | 19 | DepartmentId string `cname:"部门ID" json:"departmentId" valid:"Required"` |
| 1 | +package dto | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
| 4 | + | ||
| 5 | +type CooperationContractDto struct { | ||
| 6 | + *domain.CooperationContract | ||
| 7 | + // 可以去除勾选的共创项目承接对象列表 | ||
| 8 | + UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"` | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +func (dto *CooperationContractDto) LoadDto(contract *domain.CooperationContract, undertakerTypesUncheckedAvailable []int32) error { | ||
| 12 | + dto.CooperationContract = contract | ||
| 13 | + dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable | ||
| 14 | + return nil | ||
| 15 | +} |
| @@ -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/cooperationContract/command" | 7 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/dto" | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/query" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/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" |
| @@ -319,10 +320,31 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont | @@ -319,10 +320,31 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont | ||
| 319 | if cooperationContract == nil { | 320 | if cooperationContract == nil { |
| 320 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractQuery.CooperationContractId, 10))) | 321 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(getCooperationContractQuery.CooperationContractId, 10))) |
| 321 | } else { | 322 | } else { |
| 323 | + // 共创合约DAO初始化 | ||
| 324 | + var cooperationContractDao *dao.CooperationContractDao | ||
| 325 | + if value, err := factory.CreateCooperationContractDao(map[string]interface{}{ | ||
| 326 | + "transactionContext": transactionContext, | ||
| 327 | + }); err != nil { | ||
| 328 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 329 | + } else { | ||
| 330 | + cooperationContractDao = value | ||
| 331 | + } | ||
| 332 | + //TODO 获取可删除的承接对象类型 | ||
| 333 | + undertakerTypesUncheckedAvailable, err := cooperationContractDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ | ||
| 334 | + "cooperationContractNumber": cooperationContract.CooperationContractNumber, | ||
| 335 | + "cooperationContractUndertakerTypes": cooperationContract.CooperationContractUndertakerTypes, | ||
| 336 | + }) | ||
| 337 | + if err != nil { | ||
| 338 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
| 339 | + } | ||
| 340 | + cooperationContractDto := &dto.CooperationContractDto{} | ||
| 341 | + if err := cooperationContractDto.LoadDto(cooperationContract, undertakerTypesUncheckedAvailable); err != nil { | ||
| 342 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 343 | + } | ||
| 322 | if err := transactionContext.CommitTransaction(); err != nil { | 344 | if err := transactionContext.CommitTransaction(); err != nil { |
| 323 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 345 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 324 | } | 346 | } |
| 325 | - return cooperationContract, nil | 347 | + return cooperationContractDto, nil |
| 326 | } | 348 | } |
| 327 | } | 349 | } |
| 328 | 350 |
| @@ -16,7 +16,7 @@ type UpdateCooperationProjectCommand struct { | @@ -16,7 +16,7 @@ type UpdateCooperationProjectCommand struct { | ||
| 16 | // 共创模式编码 | 16 | // 共创模式编码 |
| 17 | CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"` | 17 | CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"` |
| 18 | // 承接对象,1员工,2共创用户,3公开,可以多选 | 18 | // 承接对象,1员工,2共创用户,3公开,可以多选 |
| 19 | - CooperationProjectUndertakerType []int32 `cname:"承接对象" json:"cooperationProjectUndertakerType" valid:"Required"` | 19 | + CooperationProjectUndertakerTypes []int32 `cname:"承接对象" json:"cooperationProjectUndertakerTypes" valid:"Required"` |
| 20 | // 共创项目发起人uid | 20 | // 共创项目发起人uid |
| 21 | SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"` | 21 | SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"` |
| 22 | // 共创项目发布人uid | 22 | // 共创项目发布人uid |
| @@ -237,7 +237,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -237,7 +237,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 237 | } else { | 237 | } else { |
| 238 | cooperationProjectDao = value | 238 | cooperationProjectDao = value |
| 239 | } | 239 | } |
| 240 | - //TODO 获取可删除的承接对象类型 | 240 | + // 获取可删除的承接对象类型 |
| 241 | undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ | 241 | undertakerTypesUncheckedAvailable, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ |
| 242 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, | 242 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, |
| 243 | "cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes, | 243 | "cooperationProjectUndertakerTypes": cooperationProject.CooperationProjectUndertakerTypes, |
| @@ -252,7 +252,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -252,7 +252,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 252 | if err := transactionContext.CommitTransaction(); err != nil { | 252 | if err := transactionContext.CommitTransaction(); err != nil { |
| 253 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 253 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| 254 | } | 254 | } |
| 255 | - return cooperationProject, nil | 255 | + return cooperationProjectDto, nil |
| 256 | } | 256 | } |
| 257 | } | 257 | } |
| 258 | 258 |
| @@ -53,17 +53,8 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} { | @@ -53,17 +53,8 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} { | ||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error { | 55 | func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error { |
| 56 | - if userId, ok := data["userId"]; ok { | ||
| 57 | - cooperationApplication.CooperationApplicationApplicant.UserId = userId.(int64) | ||
| 58 | - } | ||
| 59 | - if userBaseId, ok := data["userBaseId"]; ok { | ||
| 60 | - cooperationApplication.CooperationApplicationApplicant.UserBaseId = userBaseId.(int64) | ||
| 61 | - } | ||
| 62 | - if orgs, ok := data["orgs"]; ok { | ||
| 63 | - cooperationApplication.CooperationApplicationApplicant.Orgs = orgs.([]*Org) | ||
| 64 | - } | ||
| 65 | - if status, ok := data["status"]; ok { | ||
| 66 | - cooperationApplication.CooperationApplicationApplicant.Status = status.(int32) | 56 | + if isCanceled, ok := data["isCanceled"]; ok { |
| 57 | + cooperationApplication.IsCanceled = isCanceled.(bool) | ||
| 67 | } | 58 | } |
| 68 | if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok { | 59 | if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok { |
| 69 | cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment) | 60 | cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment) |
| @@ -71,90 +71,9 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{} | @@ -71,90 +71,9 @@ func (cooperationProject *CooperationProject) Update(data map[string]interface{} | ||
| 71 | if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok { | 71 | if cooperationProjectPublishTime, ok := data["cooperationProjectPublishTime"]; ok { |
| 72 | cooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time) | 72 | cooperationProject.CooperationProjectPublishTime = cooperationProjectPublishTime.(time.Time) |
| 73 | } | 73 | } |
| 74 | - //if userId, ok := data["userId"]; ok { | ||
| 75 | - // cooperationProject.CooperationProjectPublisher.UserId = userId.(int64) | ||
| 76 | - //} | ||
| 77 | - //if userBaseId, ok := data["userBaseId"]; ok { | ||
| 78 | - // cooperationProject.CooperationProjectPublisher.UserBaseId = userBaseId.(int64) | ||
| 79 | - //} | ||
| 80 | - //if orgId, ok := data["orgId"]; ok { | ||
| 81 | - // cooperationProject.CooperationProjectPublisher.Org.OrgId = orgId.(int64) | ||
| 82 | - //} | ||
| 83 | - //if orgName, ok := data["orgName"]; ok { | ||
| 84 | - // cooperationProject.CooperationProjectPublisher.Org.OrgName = orgName.(string) | ||
| 85 | - //} | ||
| 86 | - //if companyId, ok := data["companyId"]; ok { | ||
| 87 | - // cooperationProject.CooperationProjectPublisher.Org.Company.CompanyId = companyId.(int64) | ||
| 88 | - //} | ||
| 89 | - //if companyLogo, ok := data["companyLogo"]; ok { | ||
| 90 | - // cooperationProject.CooperationProjectPublisher.Org.Company.CompanyLogo = companyLogo.(string) | ||
| 91 | - //} | ||
| 92 | - //if companyName, ok := data["companyName"]; ok { | ||
| 93 | - // cooperationProject.CooperationProjectPublisher.Org.Company.CompanyName = companyName.(string) | ||
| 94 | - //} | ||
| 95 | - //if orgs, ok := data["orgs"]; ok { | ||
| 96 | - // cooperationProject.CooperationProjectPublisher.Orgs = orgs.([]*Org) | ||
| 97 | - //} | ||
| 98 | - //if departmentId, ok := data["departmentId"]; ok { | ||
| 99 | - // cooperationProject.CooperationProjectPublisher.Department.DepartmentId = departmentId.(int64) | ||
| 100 | - //} | ||
| 101 | - //if departmentName, ok := data["departmentName"]; ok { | ||
| 102 | - // cooperationProject.CooperationProjectPublisher.Department.DepartmentName = departmentName.(string) | ||
| 103 | - //} | ||
| 104 | - //if departmentNumber, ok := data["departmentNumber"]; ok { | ||
| 105 | - // cooperationProject.CooperationProjectPublisher.Department.DepartmentNumber = departmentNumber.(string) | ||
| 106 | - //} | ||
| 107 | - //if isOrganization, ok := data["isOrganization"]; ok { | ||
| 108 | - // cooperationProject.CooperationProjectPublisher.Department.IsOrganization = isOrganization.(bool) | ||
| 109 | - //} | ||
| 110 | - //if userAvatar, ok := data["userAvatar"]; ok { | ||
| 111 | - // cooperationProject.CooperationProjectPublisher.UserInfo.UserAvatar = userAvatar.(string) | ||
| 112 | - //} | ||
| 113 | - //if userEmail, ok := data["userEmail"]; ok { | ||
| 114 | - // cooperationProject.CooperationProjectPublisher.UserInfo.UserEmail = userEmail.(string) | ||
| 115 | - //} | ||
| 116 | - //if userName, ok := data["userName"]; ok { | ||
| 117 | - // cooperationProject.CooperationProjectPublisher.UserInfo.UserName = userName.(string) | ||
| 118 | - //} | ||
| 119 | - //if userPhone, ok := data["userPhone"]; ok { | ||
| 120 | - // cooperationProject.CooperationProjectPublisher.UserInfo.UserPhone = userPhone.(string) | ||
| 121 | - //} | ||
| 122 | - //if userAccount, ok := data["userAccount"]; ok { | ||
| 123 | - // cooperationProject.CooperationProjectPublisher.UserInfo.UserAccount = userAccount.(string) | ||
| 124 | - //} | ||
| 125 | - //if userType, ok := data["userType"]; ok { | ||
| 126 | - // cooperationProject.CooperationProjectPublisher.UserType = userType.(int32) | ||
| 127 | - //} | ||
| 128 | - //if status, ok := data["status"]; ok { | ||
| 129 | - // cooperationProject.CooperationProjectPublisher.Status = status.(int32) | ||
| 130 | - //} | ||
| 131 | - //if companyId, ok := data["companyId"]; ok { | ||
| 132 | - // cooperationProject.CooperationProjectPublisher.Company.CompanyId = companyId.(int64) | ||
| 133 | - //} | ||
| 134 | - //if companyLogo, ok := data["companyLogo"]; ok { | ||
| 135 | - // cooperationProject.CooperationProjectPublisher.Company.CompanyLogo = companyLogo.(string) | ||
| 136 | - //} | ||
| 137 | - //if companyName, ok := data["companyName"]; ok { | ||
| 138 | - // cooperationProject.CooperationProjectPublisher.Company.CompanyName = companyName.(string) | ||
| 139 | - //} | ||
| 140 | - //if userId, ok := data["userId"]; ok { | ||
| 141 | - // cooperationProject.CooperationProjectSponsor.UserId = userId.(int64) | ||
| 142 | - //} | ||
| 143 | - //if userBaseId, ok := data["userBaseId"]; ok { | ||
| 144 | - // cooperationProject.CooperationProjectSponsor.UserBaseId = userBaseId.(int64) | ||
| 145 | - //} | ||
| 146 | - //if orgId, ok := data["orgId"]; ok { | ||
| 147 | - // cooperationProject.CooperationProjectSponsor.Org.OrgId = orgId.(int64) | ||
| 148 | - //} | ||
| 149 | - //if orgName, ok := data["orgName"]; ok { | ||
| 150 | - // cooperationProject.CooperationProjectSponsor.Org.OrgName = orgName.(string) | ||
| 151 | - //} | ||
| 152 | - //if companyId, ok := data["companyId"]; ok { | ||
| 153 | - // cooperationProject.CooperationProjectSponsor.Company.CompanyId = companyId.(int64) | ||
| 154 | - //} | ||
| 155 | - //if cooperationProjectUndertakerType, ok := data["cooperationProjectUndertakerType"]; ok { | ||
| 156 | - // cooperationProject.CooperationProjectUndertakerTypes = cooperationProjectUndertakerType.([]int32) | ||
| 157 | - //} | 74 | + if cooperationProjectUndertakerTypes, ok := data["cooperationProjectUndertakerTypes"]; ok { |
| 75 | + cooperationProject.CooperationProjectUndertakerTypes = cooperationProjectUndertakerTypes.([]int32) | ||
| 76 | + } | ||
| 158 | if operateTime, ok := data["operateTime"]; ok { | 77 | if operateTime, ok := data["operateTime"]; ok { |
| 159 | cooperationProject.OperateTime = operateTime.(time.Time) | 78 | cooperationProject.OperateTime = operateTime.(time.Time) |
| 160 | } | 79 | } |
| @@ -35,6 +35,12 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) { | @@ -35,6 +35,12 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) { | ||
| 35 | } | 35 | } |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | +// CheckUndertakerTypesUncheckedAvailable TODO 校验合约承接对象是否可以删除 | ||
| 39 | +func (dao *CooperationContractDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) { | ||
| 40 | + | ||
| 41 | + return []int32{}, nil | ||
| 42 | +} | ||
| 43 | + | ||
| 38 | // CheckContractNumberAvailable 检验合约编号唯一性 | 44 | // CheckContractNumberAvailable 检验合约编号唯一性 |
| 39 | func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map[string]interface{}) (bool, error) { | 45 | func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map[string]interface{}) (bool, error) { |
| 40 | tx := dao.transactionContext.PgTx | 46 | tx := dao.transactionContext.PgTx |
| @@ -37,6 +37,7 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { | @@ -37,6 +37,7 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { | ||
| 37 | 37 | ||
| 38 | // CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除 | 38 | // CheckUndertakerTypesUncheckedAvailable TODO 校验项目承接对象是否可以删除 |
| 39 | func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) { | 39 | func (dao *CooperationProjectDao) CheckUndertakerTypesUncheckedAvailable(queryOptions map[string]interface{}) ([]int32, error) { |
| 40 | + | ||
| 40 | return []int32{}, nil | 41 | return []int32{}, nil |
| 41 | } | 42 | } |
| 42 | 43 |
| @@ -166,6 +166,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -166,6 +166,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
| 166 | if _, err := tx.Model(÷ndsIncentivesRulesModel).Insert(); err != nil { | 166 | if _, err := tx.Model(÷ndsIncentivesRulesModel).Insert(); err != nil { |
| 167 | return nil, err | 167 | return nil, err |
| 168 | } | 168 | } |
| 169 | + | ||
| 169 | // 新增金额激励规则 | 170 | // 新增金额激励规则 |
| 170 | var moneyIncentivesRulesModel []*models.MoneyIncentivesRule | 171 | var moneyIncentivesRulesModel []*models.MoneyIncentivesRule |
| 171 | for _, rule := range cooperationContract.MoneyIncentivesRules { | 172 | for _, rule := range cooperationContract.MoneyIncentivesRules { |
| @@ -685,7 +686,6 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -685,7 +686,6 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 685 | query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) | 686 | query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) |
| 686 | } | 687 | } |
| 687 | if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { | 688 | if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { |
| 688 | - //query.Where(`cooperation_contract.cooperation_contract_sponsor->'userName' LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) | ||
| 689 | query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) | 689 | query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) |
| 690 | } | 690 | } |
| 691 | query.SetOffsetAndLimit(20) | 691 | query.SetOffsetAndLimit(20) |
| @@ -170,6 +170,9 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | @@ -170,6 +170,9 @@ func (repository *CooperationProjectRepository) FindOne(queryOptions map[string] | ||
| 170 | tx := repository.transactionContext.PgTx | 170 | tx := repository.transactionContext.PgTx |
| 171 | cooperationProjectModel := new(models.CooperationProject) | 171 | cooperationProjectModel := new(models.CooperationProject) |
| 172 | query := sqlbuilder.BuildQuery(tx.Model(cooperationProjectModel), queryOptions) | 172 | query := sqlbuilder.BuildQuery(tx.Model(cooperationProjectModel), queryOptions) |
| 173 | + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { | ||
| 174 | + query.Where("cooperation_project_number = ?", cooperationProjectNumber) | ||
| 175 | + } | ||
| 173 | query.SetWhereByQueryOption("cooperation_project.cooperation_project_id = ?", "cooperationProjectId") | 176 | query.SetWhereByQueryOption("cooperation_project.cooperation_project_id = ?", "cooperationProjectId") |
| 174 | if err := query.First(); err != nil { | 177 | if err := query.First(); err != nil { |
| 175 | if err.Error() == "pg: no rows in result set" { | 178 | if err.Error() == "pg: no rows in result set" { |
-
请 注册 或 登录 后发表评论