作者 陈志颖

fix:批量删除共创合约

... ... @@ -34,7 +34,7 @@ type CooperationContractRelevant struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
... ... @@ -44,5 +44,5 @@ type CooperationContractUndertaker struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
}
... ...
... ... @@ -143,7 +143,16 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
// 新增承接人
var undertakersModel []*models.CooperationContractUndertaker
for _, undertaker := range cooperationContract.Undertakers {
if undertaker.Identify() == nil {
undertakerId, err := repository.nextIdentify()
if err != nil {
return nil, err
} else {
undertaker.UndertakerId = undertakerId
}
}
undertakersModel = append(undertakersModel, &models.CooperationContractUndertaker{
CooperationContractUndertakerId: undertaker.UndertakerId,
CooperationContractNumber: cooperationContract.CooperationContractNumber,
CooperationContractId: cooperationContract.CooperationContractId,
UserId: undertaker.UserId,
... ... @@ -1063,16 +1072,6 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
if cooperationContractModel.CooperationContractId == 0 {
return nil, nil
} else {
// 获取共创模式
//cooperationModeModels := new(models.CooperationMode)
//cooperationModeQuery := tx.Model(cooperationModeModels)
//if err := cooperationModeQuery.
// Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
// Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
// Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).
// First(); err != nil {
// return nil, fmt.Errorf("共创合约关联的共创模式不存在")
//}
var cooperationModeModels []*models.CooperationMode
cooperationModeQuery := tx.Model(&cooperationModeModels)
if countMode, err := cooperationModeQuery.
... ...