...
|
...
|
@@ -24,6 +24,7 @@ func (repository *ContractUndertakerFeedbackRepository) nextIdentify() (int64, e |
|
|
id, err := IdWorker.NextId()
|
|
|
return id, err
|
|
|
}
|
|
|
|
|
|
func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerFeedback *domain.ContractUndertakerFeedback) (*domain.ContractUndertakerFeedback, error) {
|
|
|
sqlBuildFields := []string{
|
|
|
"feedback_id",
|
...
|
...
|
@@ -31,7 +32,6 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
"feedback_content",
|
|
|
"cooperation_contract_number",
|
|
|
"contract_undertaker",
|
|
|
"cooperation_mode",
|
|
|
"org",
|
|
|
"company",
|
|
|
"updated_at",
|
...
|
...
|
@@ -58,7 +58,6 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
&contractUndertakerFeedback.FeedbackContent,
|
|
|
&contractUndertakerFeedback.CooperationContractNumber,
|
|
|
&contractUndertakerFeedback.ContractUndertaker,
|
|
|
&contractUndertakerFeedback.CooperationMode,
|
|
|
&contractUndertakerFeedback.Org,
|
|
|
&contractUndertakerFeedback.Company,
|
|
|
&contractUndertakerFeedback.UpdatedAt,
|
...
|
...
|
@@ -71,11 +70,10 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
contractUndertakerFeedback.FeedbackContent,
|
|
|
contractUndertakerFeedback.CooperationContractNumber,
|
|
|
contractUndertakerFeedback.ContractUndertaker,
|
|
|
contractUndertakerFeedback.CooperationMode,
|
|
|
contractUndertakerFeedback.Org,
|
|
|
contractUndertakerFeedback.Company,
|
|
|
contractUndertakerFeedback.UpdatedAt,
|
|
|
contractUndertakerFeedback.DeletedAt,
|
|
|
nil,
|
|
|
contractUndertakerFeedback.CreatedAt,
|
|
|
); err != nil {
|
|
|
return contractUndertakerFeedback, err
|
...
|
...
|
@@ -88,7 +86,6 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
&contractUndertakerFeedback.FeedbackContent,
|
|
|
&contractUndertakerFeedback.CooperationContractNumber,
|
|
|
&contractUndertakerFeedback.ContractUndertaker,
|
|
|
&contractUndertakerFeedback.CooperationMode,
|
|
|
&contractUndertakerFeedback.Org,
|
|
|
&contractUndertakerFeedback.Company,
|
|
|
&contractUndertakerFeedback.UpdatedAt,
|
...
|
...
|
@@ -101,11 +98,10 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
contractUndertakerFeedback.FeedbackContent,
|
|
|
contractUndertakerFeedback.CooperationContractNumber,
|
|
|
contractUndertakerFeedback.ContractUndertaker,
|
|
|
contractUndertakerFeedback.CooperationMode,
|
|
|
contractUndertakerFeedback.Org,
|
|
|
contractUndertakerFeedback.Company,
|
|
|
contractUndertakerFeedback.UpdatedAt,
|
|
|
contractUndertakerFeedback.DeletedAt,
|
|
|
nil,
|
|
|
contractUndertakerFeedback.CreatedAt,
|
|
|
contractUndertakerFeedback.Identify(),
|
|
|
); err != nil {
|
...
|
...
|
@@ -114,6 +110,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
}
|
|
|
return contractUndertakerFeedback, nil
|
|
|
}
|
|
|
|
|
|
func (repository *ContractUndertakerFeedbackRepository) Remove(contractUndertakerFeedback *domain.ContractUndertakerFeedback) (*domain.ContractUndertakerFeedback, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
contractUndertakerFeedbackModel := new(models.ContractUndertakerFeedback)
|
...
|
...
|
@@ -123,11 +120,12 @@ func (repository *ContractUndertakerFeedbackRepository) Remove(contractUndertake |
|
|
}
|
|
|
return contractUndertakerFeedback, nil
|
|
|
}
|
|
|
|
|
|
func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map[string]interface{}) (*domain.ContractUndertakerFeedback, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
contractUndertakerFeedbackModel := new(models.ContractUndertakerFeedback)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(contractUndertakerFeedbackModel), queryOptions)
|
|
|
query.SetWhereByQueryOption("contract_undertaker_feedback.contract_undertaker_feedback_id = ?", "contractUndertakerFeedbackId")
|
|
|
query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId")
|
|
|
if err := query.First(); err != nil {
|
|
|
if err.Error() == "pg: no rows in result set" {
|
|
|
return nil, fmt.Errorf("没有此资源")
|
...
|
...
|
@@ -138,41 +136,43 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map |
|
|
if contractUndertakerFeedbackModel.FeedbackId == 0 {
|
|
|
return nil, nil
|
|
|
} else {
|
|
|
// 获取共创模式
|
|
|
cooperationModeModel := new(models.CooperationMode)
|
|
|
cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", contractUndertakerFeedbackModel.CooperationModeNumber).First(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
return transform.TransformToContractUndertakerFeedbackDomainModelFromPgModels(contractUndertakerFeedbackModel, cooperationModeModel)
|
|
|
//// 获取共创模式
|
|
|
//cooperationModeModel := new(models.CooperationMode)
|
|
|
//cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
//if err := cooperationModeQuery.Where("cooperation_mode_number = ?", contractUndertakerFeedbackModel.CooperationModeNumber).First(); err != nil {
|
|
|
// return nil, err
|
|
|
//}
|
|
|
return transform.TransformToContractUndertakerFeedbackDomainModelFromPgModels(contractUndertakerFeedbackModel)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (repository *ContractUndertakerFeedbackRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ContractUndertakerFeedback, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
var contractUndertakerFeedbackModels []*models.ContractUndertakerFeedback
|
|
|
contractUndertakerFeedbacks := make([]*domain.ContractUndertakerFeedback, 0)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(&contractUndertakerFeedbackModels), queryOptions)
|
|
|
query.SetOffsetAndLimit(20)
|
|
|
query.SetOrderDirect("contract_undertaker_feedback_id", "DESC")
|
|
|
query.SetOrderDirect("feedback_id", "DESC")
|
|
|
if count, err := query.SelectAndCount(); err != nil {
|
|
|
return 0, contractUndertakerFeedbacks, err
|
|
|
} else {
|
|
|
for _, contractUndertakerFeedbackModel := range contractUndertakerFeedbackModels {
|
|
|
// 获取共创模式
|
|
|
cooperationModeModel := new(models.CooperationMode)
|
|
|
cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", contractUndertakerFeedbackModel.CooperationModeNumber).First(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
if contractUndertakerFeedback, err := transform.TransformToContractUndertakerFeedbackDomainModelFromPgModels(contractUndertakerFeedbackModel, cooperationModeModel); err != nil {
|
|
|
return 0, contractUndertakerFeedbacks, err
|
|
|
} else {
|
|
|
contractUndertakerFeedbacks = append(contractUndertakerFeedbacks, contractUndertakerFeedback)
|
|
|
}
|
|
|
}
|
|
|
//for _, contractUndertakerFeedbackModel := range contractUndertakerFeedbackModels {
|
|
|
// // 获取共创模式
|
|
|
// cooperationModeModel := new(models.CooperationMode)
|
|
|
// cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
// if err := cooperationModeQuery.Where("cooperation_mode_number = ?", contractUndertakerFeedbackModel.CooperationModeNumber).First(); err != nil {
|
|
|
// return 0, nil, err
|
|
|
// }
|
|
|
// if contractUndertakerFeedback, err := transform.TransformToContractUndertakerFeedbackDomainModelFromPgModels(contractUndertakerFeedbackModel, cooperationModeModel); err != nil {
|
|
|
// return 0, contractUndertakerFeedbacks, err
|
|
|
// } else {
|
|
|
// contractUndertakerFeedbacks = append(contractUndertakerFeedbacks, contractUndertakerFeedback)
|
|
|
// }
|
|
|
//}
|
|
|
return int64(count), contractUndertakerFeedbacks, nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func NewContractUndertakerFeedbackRepository(transactionContext *pgTransaction.TransactionContext) (*ContractUndertakerFeedbackRepository, error) {
|
|
|
if transactionContext == nil {
|
|
|
return nil, fmt.Errorf("transactionContext参数不能为nil")
|
...
|
...
|
|