作者 陈志颖

feat:承接信息反馈查询接口调整

... ... @@ -80,33 +80,51 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Crea
organization = data
}
newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{
FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment,
FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent,
CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber,
ContractUndertaker: undertaker,
Company: company,
Org: organization,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
// 获取项目合约信息
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
contractUndertakerFeedbackRepository = value
cooperationContractRepository = value
}
if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Save(newContractUndertakerFeedback); err != nil {
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractNumber": createContractUndertakerFeedbackCommand.CooperationContractNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", createContractUndertakerFeedbackCommand.CooperationContractNumber))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{
FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment,
FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent,
CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber,
CooperationContractName: cooperationContract.CooperationContractName,
ContractUndertaker: undertaker,
Company: company,
Org: organization,
UpdatedAt: time.Time{},
DeletedAt: time.Time{},
CreatedAt: time.Now(),
}
var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
contractUndertakerFeedbackRepository = value
}
if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Save(newContractUndertakerFeedback); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return contractUndertakerFeedback, nil
}
return contractUndertakerFeedback, nil
}
}
... ...
... ... @@ -3,7 +3,7 @@ package domain
// Company 公司值对象
type Company struct {
// 公司ID,通过集成REST上下文获取
CompanyId int64 `json:"companyId"`
CompanyId int64 `json:"companyId,string"`
// 公司logo
CompanyLogo string `json:"companyLogo"`
// 公司名称
... ...
... ... @@ -12,6 +12,8 @@ type ContractUndertakerFeedback struct {
FeedbackContent string `json:"feedbackContent"`
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 项目合约名称
CooperationContractName string `json:"cooperationContractName"`
// 共创合约承接人
ContractUndertaker *Undertaker `json:"contractUndertaker"`
// 数据所属组织机构
... ...
... ... @@ -3,7 +3,7 @@ package domain
// Department 部门值对象
type Department struct {
// 部门ID,通过REST集成上下文获取
DepartmentId int64 `json:"departmentId"`
DepartmentId int64 `json:"departmentId,string"`
// 部门名称
DepartmentName string `json:"departmentName"`
// 部门编码
... ...
... ... @@ -3,7 +3,7 @@ package domain
// Org 组织机构值对象
type Org struct {
// 组织机构ID
OrgId int64 `json:"orgId"`
OrgId int64 `json:"orgId,string"`
// 组织名称
OrgName string `json:"orgName"`
// 公司
... ...
... ... @@ -3,9 +3,9 @@ package domain
// Participator 共创参与人
type Participator struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId"`
UserBaseId int64 `json:"userBaseId,string"`
// 用户所属的组织机构
Org *Org `json:"org"`
// 用户关联的组织机构
... ...
... ... @@ -3,9 +3,9 @@ package domain
// Referrer 推荐人值对象
type Referrer struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId"`
UserBaseId int64 `json:"userBaseId,string"`
// 用户角色
Roles []*Role `json:"role"`
// 用户关联的组织机构
... ...
... ... @@ -3,13 +3,13 @@ package domain
// Relevant 共创合约相关人值对象
type Relevant struct {
// 相关人id
RelevantId int64 `json:"relevantId"`
RelevantId int64 `json:"relevantId,string"`
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId"`
UserBaseId int64 `json:"userBaseId,string"`
// 用户所属的组织机构
Org *Org `json:"org"`
// 用户关联的组织机构
... ...
... ... @@ -3,9 +3,9 @@ package domain
// Salesman 业务员值对象
type Salesman struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId"`
UserBaseId int64 `json:"userBaseId,string"`
// 用户角色
Roles []*Role `json:"role"`
// 用户关联的组织机构
... ...
... ... @@ -3,11 +3,11 @@ package domain
// Undertaker 共创合约承接方值对象
type Undertaker struct {
// 承接人id
UndertakerId int64 `json:"relevantId"`
UndertakerId int64 `json:"relevantId,string"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId"`
UserBaseId int64 `json:"userBaseId,string"`
// 共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 用户所属组织机构
... ...
... ... @@ -3,9 +3,9 @@ package domain
// User 用户第三方服务防腐模型
type User struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `json:"userId"`
UserId int64 `json:"userId,string"`
// 用户基本id
UserBaseId int64 `json:"userBaseId"`
UserBaseId int64 `json:"userBaseId,string"`
// 用户所属组织机构
Org *Org `json:"org"`
// 用户关联的组织机构
... ...
... ... @@ -27,9 +27,6 @@ func (service *UserService) UserFrom(companyId int64, orgId int64, userId int64)
if err1 != nil {
return nil, err
}
log.Logger.Debug("普通用户", map[string]interface{}{
"user json": userJson,
})
err2 := json.Unmarshal(userJson, &returnData)
if err2 != nil {
return nil, err2
... ... @@ -57,9 +54,6 @@ func (service *UserService) ReferrerFrom(companyId int64, orgId int64, userId in
if err1 != nil {
return nil, err
}
log.Logger.Debug("推荐人", map[string]interface{}{
"referrer json": referrerJson,
})
err2 := json.Unmarshal(referrerJson, &returnData)
if err2 != nil {
return nil, err2
... ... @@ -87,9 +81,6 @@ func (service *UserService) UndertakerFrom(companyId int64, orgId int64, userId
if err1 != nil {
return nil, err
}
log.Logger.Debug("承接人", map[string]interface{}{
"undertaker json": undertakerJson,
})
err2 := json.Unmarshal(undertakerJson, &returnData)
if err2 != nil {
return nil, err2
... ... @@ -117,9 +108,6 @@ func (service *UserService) RelevantFrom(companyId int64, orgId int64, userId in
if err1 != nil {
return nil, err
}
log.Logger.Debug("相关人", map[string]interface{}{
"relevant json": relevantJson,
})
err2 := json.Unmarshal(relevantJson, &returnData)
if err2 != nil {
return nil, err2
... ... @@ -147,9 +135,6 @@ func (service *UserService) SalesmanFrom(companyId int64, orgId int64, userId in
if err1 != nil {
return nil, err
}
log.Logger.Debug("业务员", map[string]interface{}{
"salesman json": salesmanJson,
})
err2 := json.Unmarshal(salesmanJson, &returnData)
if err2 != nil {
return nil, err2
... ... @@ -177,9 +162,6 @@ func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId in
if err1 != nil {
return nil, err
}
log.Logger.Debug("操作人", map[string]interface{}{
"operator json": operatorJson,
})
err2 := json.Unmarshal(operatorJson, &returnData)
if err2 != nil {
return nil, err2
... ...
... ... @@ -15,6 +15,8 @@ type ContractUndertakerFeedback struct {
FeedbackContent string `comment:"合约承接方反馈内容"`
// 共创合约编号
CooperationContractNumber string `comment:"共创合约编号"`
// 项目合约名称
CooperationContractName string `comment:"项目合约名称"`
// 共创合约承接人
ContractUndertaker *domain.Undertaker `comment:"共创合约承接人"`
// 数据所属组织机构
... ...
... ... @@ -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,
... ... @@ -151,6 +156,15 @@ func (repository *ContractUndertakerFeedbackRepository) Find(queryOptions map[st
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 {
... ...
... ... @@ -625,6 +625,7 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
cooperationContractModel := new(models.CooperationContract)
query := sqlbuilder.BuildQuery(tx.Model(cooperationContractModel), queryOptions)
query.SetWhereByQueryOption("cooperation_contract.cooperation_contract_id = ?", "cooperationContractId")
query.SetWhereByQueryOption("cooperation_contract.cooperation_contract_number = ?", "cooperationContractNumber")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
... ...