...
|
...
|
@@ -3,7 +3,7 @@ package repository |
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
|
|
|
"github.com/go-pg/pg/v10/orm"
|
|
|
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"github.com/linmadan/egglib-go/utils/snowflake"
|
...
|
...
|
@@ -31,6 +31,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
"feedback_attachment",
|
|
|
"feedback_content",
|
|
|
"cooperation_contract_number",
|
|
|
"cooperation_contract_name",
|
|
|
"contract_undertaker",
|
|
|
"org",
|
|
|
"company",
|
...
|
...
|
@@ -57,6 +58,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
&contractUndertakerFeedback.FeedbackAttachment,
|
|
|
&contractUndertakerFeedback.FeedbackContent,
|
|
|
&contractUndertakerFeedback.CooperationContractNumber,
|
|
|
&contractUndertakerFeedback.CooperationContractName,
|
|
|
&contractUndertakerFeedback.ContractUndertaker,
|
|
|
&contractUndertakerFeedback.Org,
|
|
|
&contractUndertakerFeedback.Company,
|
...
|
...
|
@@ -69,6 +71,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
contractUndertakerFeedback.FeedbackAttachment,
|
|
|
contractUndertakerFeedback.FeedbackContent,
|
|
|
contractUndertakerFeedback.CooperationContractNumber,
|
|
|
contractUndertakerFeedback.CooperationContractName,
|
|
|
contractUndertakerFeedback.ContractUndertaker,
|
|
|
contractUndertakerFeedback.Org,
|
|
|
contractUndertakerFeedback.Company,
|
...
|
...
|
@@ -85,6 +88,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
&contractUndertakerFeedback.FeedbackAttachment,
|
|
|
&contractUndertakerFeedback.FeedbackContent,
|
|
|
&contractUndertakerFeedback.CooperationContractNumber,
|
|
|
&contractUndertakerFeedback.CooperationContractName,
|
|
|
&contractUndertakerFeedback.ContractUndertaker,
|
|
|
&contractUndertakerFeedback.Org,
|
|
|
&contractUndertakerFeedback.Company,
|
...
|
...
|
@@ -97,6 +101,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF |
|
|
contractUndertakerFeedback.FeedbackAttachment,
|
|
|
contractUndertakerFeedback.FeedbackContent,
|
|
|
contractUndertakerFeedback.CooperationContractNumber,
|
|
|
contractUndertakerFeedback.CooperationContractName,
|
|
|
contractUndertakerFeedback.ContractUndertaker,
|
|
|
contractUndertakerFeedback.Org,
|
|
|
contractUndertakerFeedback.Company,
|
...
|
...
|
@@ -136,12 +141,6 @@ 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)
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -151,24 +150,33 @@ func (repository *ContractUndertakerFeedbackRepository) Find(queryOptions map[st |
|
|
var contractUndertakerFeedbackModels []*models.ContractUndertakerFeedback
|
|
|
contractUndertakerFeedbacks := make([]*domain.ContractUndertakerFeedback, 0)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(&contractUndertakerFeedbackModels), queryOptions)
|
|
|
if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" {
|
|
|
query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
|
|
|
}
|
|
|
if undertakerName, ok := queryOptions["undertakerName"]; ok && undertakerName != "" {
|
|
|
query.Where("contract_undertaker->>'userName' like ?", fmt.Sprintf("%%%s%%", undertakerName))
|
|
|
}
|
|
|
// 搜索内容包括项目合约名称、承接人姓名、承接内容关键字
|
|
|
if matchWord, ok := queryOptions["matchWord"]; ok && matchWord != "" {
|
|
|
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
|
|
|
q.WhereOr("cooperation_contract_name like ?",fmt.Sprintf("%%%s%%", matchWord))
|
|
|
q.WhereOr("contract_undertaker->>'userName' like ?", fmt.Sprintf("%%%s%%", matchWord))
|
|
|
q.WhereOr("feedback_content like ?", fmt.Sprintf("%%%s%%", matchWord))
|
|
|
return q, nil
|
|
|
})
|
|
|
}
|
|
|
query.SetOffsetAndLimit(20)
|
|
|
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 {
|
|
|
if contractUndertakerFeedback, err := transform.TransformToContractUndertakerFeedbackDomainModelFromPgModels(contractUndertakerFeedbackModel); err != nil {
|
|
|
return 0, contractUndertakerFeedbacks, err
|
|
|
} else {
|
|
|
contractUndertakerFeedbacks = append(contractUndertakerFeedbacks, contractUndertakerFeedback)
|
|
|
}
|
|
|
}
|
|
|
return int64(count), contractUndertakerFeedbacks, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
|