作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !34
@@ -34,7 +34,7 @@ type CooperationContractRelevant struct { @@ -34,7 +34,7 @@ type CooperationContractRelevant struct {
34 // 更新时间 34 // 更新时间
35 UpdatedAt time.Time `comment:"更新时间"` 35 UpdatedAt time.Time `comment:"更新时间"`
36 // 删除时间 36 // 删除时间
37 - DeletedAt time.Time `comment:"删除时间"` 37 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
38 // 创建时间 38 // 创建时间
39 CreatedAt time.Time `comment:"创建时间"` 39 CreatedAt time.Time `comment:"创建时间"`
40 } 40 }
@@ -44,5 +44,5 @@ type CooperationContractUndertaker struct { @@ -44,5 +44,5 @@ type CooperationContractUndertaker struct {
44 // 更新时间 44 // 更新时间
45 UpdatedAt time.Time `comment:"更新时间"` 45 UpdatedAt time.Time `comment:"更新时间"`
46 // 删除时间 46 // 删除时间
47 - DeletedAt time.Time `comment:"删除时间"` 47 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
48 } 48 }
@@ -143,25 +143,34 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -143,25 +143,34 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
143 // 新增承接人 143 // 新增承接人
144 var undertakersModel []*models.CooperationContractUndertaker 144 var undertakersModel []*models.CooperationContractUndertaker
145 for _, undertaker := range cooperationContract.Undertakers { 145 for _, undertaker := range cooperationContract.Undertakers {
  146 + if undertaker.Identify() == nil {
  147 + undertakerId, err := repository.nextIdentify()
  148 + if err != nil {
  149 + return nil, err
  150 + } else {
  151 + undertaker.UndertakerId = undertakerId
  152 + }
  153 + }
146 undertakersModel = append(undertakersModel, &models.CooperationContractUndertaker{ 154 undertakersModel = append(undertakersModel, &models.CooperationContractUndertaker{
147 - CooperationContractNumber: cooperationContract.CooperationContractNumber,  
148 - CooperationContractId: cooperationContract.CooperationContractId,  
149 - UserId: undertaker.UserId,  
150 - UserBaseId: undertaker.UserBaseId,  
151 - Org: undertaker.Org,  
152 - Orgs: undertaker.Orgs,  
153 - Department: undertaker.Department,  
154 - Roles: undertaker.Roles,  
155 - UserInfo: undertaker.UserInfo,  
156 - UserType: undertaker.UserType,  
157 - Referrer: undertaker.Referrer,  
158 - Salesman: undertaker.Salesman,  
159 - Status: undertaker.Status,  
160 - Company: undertaker.Company,  
161 - ContractAttachment: undertaker.ContractAttachment,  
162 - CreatedAt: time.Now(),  
163 - UpdatedAt: time.Time{},  
164 - DeletedAt: time.Time{}, 155 + CooperationContractUndertakerId: undertaker.UndertakerId,
  156 + CooperationContractNumber: cooperationContract.CooperationContractNumber,
  157 + CooperationContractId: cooperationContract.CooperationContractId,
  158 + UserId: undertaker.UserId,
  159 + UserBaseId: undertaker.UserBaseId,
  160 + Org: undertaker.Org,
  161 + Orgs: undertaker.Orgs,
  162 + Department: undertaker.Department,
  163 + Roles: undertaker.Roles,
  164 + UserInfo: undertaker.UserInfo,
  165 + UserType: undertaker.UserType,
  166 + Referrer: undertaker.Referrer,
  167 + Salesman: undertaker.Salesman,
  168 + Status: undertaker.Status,
  169 + Company: undertaker.Company,
  170 + ContractAttachment: undertaker.ContractAttachment,
  171 + CreatedAt: time.Now(),
  172 + UpdatedAt: time.Time{},
  173 + DeletedAt: time.Time{},
165 }) 174 })
166 } 175 }
167 if len(undertakersModel) > 0 { 176 if len(undertakersModel) > 0 {
@@ -1063,16 +1072,6 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string @@ -1063,16 +1072,6 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
1063 if cooperationContractModel.CooperationContractId == 0 { 1072 if cooperationContractModel.CooperationContractId == 0 {
1064 return nil, nil 1073 return nil, nil
1065 } else { 1074 } else {
1066 - // 获取共创模式  
1067 - //cooperationModeModels := new(models.CooperationMode)  
1068 - //cooperationModeQuery := tx.Model(cooperationModeModels)  
1069 - //if err := cooperationModeQuery.  
1070 - // Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).  
1071 - // Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).  
1072 - // Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).  
1073 - // First(); err != nil {  
1074 - // return nil, fmt.Errorf("共创合约关联的共创模式不存在")  
1075 - //}  
1076 var cooperationModeModels []*models.CooperationMode 1075 var cooperationModeModels []*models.CooperationMode
1077 cooperationModeQuery := tx.Model(&cooperationModeModels) 1076 cooperationModeQuery := tx.Model(&cooperationModeModels)
1078 if countMode, err := cooperationModeQuery. 1077 if countMode, err := cooperationModeQuery.
@@ -1151,7 +1150,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -1151,7 +1150,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
1151 query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName)) 1150 query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
1152 } 1151 }
1153 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" { 1152 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
1154 - query.Where(`(cooperation_contract.department->>'departmentName')::test LIKE ?`, fmt.Sprintf("%%%s%%", departmentName)) 1153 + query.Where(`(cooperation_contract.department->>'departmentName')::text LIKE ?`, fmt.Sprintf("%%%s%%", departmentName))
1155 } 1154 }
1156 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { 1155 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
1157 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) 1156 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))