作者 陈志颖

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

... ... @@ -14,15 +14,15 @@ type ListContractUndertakerFeedbackQuery struct {
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 承接人uid
UnderTakerUid string `cname:"承接人UID" json:"underTakerUid" valid:"Required"`
UnderTakerUid string `cname:"承接人UID" json:"underTakerUid,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据is" json:"userBaseId,string" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
}
func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -240,10 +240,27 @@ func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) Sear
defer func() {
_ = transactionContext.RollbackTransaction()
}()
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 count, contractUndertakerFeedbacks, err := contractUndertakerFeedbackRepository.Find(tool_funs.SimpleStructToMap(searchContractUndertakerFeedbackQuery)); 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 nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": contractUndertakerFeedbacks,
},
}, nil
}
}
// UpdateContractUndertakerFeedback 更新共创合约反馈服务
... ...
... ... @@ -14,8 +14,6 @@ type ContractUndertakerFeedback struct {
CooperationContractNumber string `json:"cooperationContractNumber"`
// 共创合约承接人
ContractUndertaker *Undertaker `json:"contractUndertaker"`
// 共创模式
CooperationMode *CooperationMode `json:"cooperationMode"`
// 数据所属组织机构
Org *Org `json:"org"`
// 公司
... ... @@ -52,11 +50,5 @@ func (contractUndertakerFeedback *ContractUndertakerFeedback) Update(data map[st
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
contractUndertakerFeedback.CooperationContractNumber = cooperationContractNumber.(string)
}
if status, ok := data["status"]; ok {
contractUndertakerFeedback.CooperationMode.Status = status.(int32)
}
if remarks, ok := data["remarks"]; ok {
contractUndertakerFeedback.CooperationMode.Remarks = remarks.(string)
}
return nil
}
... ...
... ... @@ -17,8 +17,6 @@ type ContractUndertakerFeedback struct {
CooperationContractNumber string `comment:"共创合约编号"`
// 共创合约承接人
ContractUndertaker *domain.Undertaker `comment:"共创合约承接人"`
// 共创模式编号
CooperationModeNumber string `comment:"共创模式编号"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 公司
... ...
... ... @@ -6,28 +6,27 @@ import (
)
func TransformToContractUndertakerFeedbackDomainModelFromPgModels(
contractUndertakerFeedbackModel *models.ContractUndertakerFeedback,
cooperationMode *models.CooperationMode) (*domain.ContractUndertakerFeedback, error) {
contractUndertakerFeedbackModel *models.ContractUndertakerFeedback) (*domain.ContractUndertakerFeedback, error) {
return &domain.ContractUndertakerFeedback{
FeedbackId: contractUndertakerFeedbackModel.FeedbackId,
FeedbackAttachment: contractUndertakerFeedbackModel.FeedbackAttachment,
FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent,
CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber,
ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker,
CooperationMode: &domain.CooperationMode{
CooperationModeId: cooperationMode.CooperationModeId,
CooperationModeNumber: cooperationMode.CooperationModeNumber,
CooperationModeName: cooperationMode.CooperationModeName,
Status: cooperationMode.Status,
Org: cooperationMode.Org,
Company: cooperationMode.Company,
Remarks: cooperationMode.Remarks,
Operator: cooperationMode.Operator,
OperateTime: cooperationMode.OperateTime,
UpdatedAt: cooperationMode.UpdatedAt,
DeletedAt: cooperationMode.DeletedAt,
CreatedAt: cooperationMode.CreatedAt,
},
//CooperationMode: &domain.CooperationMode{
// CooperationModeId: cooperationMode.CooperationModeId,
// CooperationModeNumber: cooperationMode.CooperationModeNumber,
// CooperationModeName: cooperationMode.CooperationModeName,
// Status: cooperationMode.Status,
// Org: cooperationMode.Org,
// Company: cooperationMode.Company,
// Remarks: cooperationMode.Remarks,
// Operator: cooperationMode.Operator,
// OperateTime: cooperationMode.OperateTime,
// UpdatedAt: cooperationMode.UpdatedAt,
// DeletedAt: cooperationMode.DeletedAt,
// CreatedAt: cooperationMode.CreatedAt,
//},
Org: contractUndertakerFeedbackModel.Org,
Company: contractUndertakerFeedbackModel.Company,
UpdatedAt: contractUndertakerFeedbackModel.UpdatedAt,
... ...
... ... @@ -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")
... ...
... ... @@ -14,7 +14,6 @@ func (controller *ContractUndertakerFeedbackController) CreateContractUndertaker
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
createContractUndertakerFeedbackCommand := &command.CreateContractUndertakerFeedbackCommand{}
_ = controller.Unmarshal(createContractUndertakerFeedbackCommand)
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
createContractUndertakerFeedbackCommand.CompanyId = header.CompanyId
createContractUndertakerFeedbackCommand.OrgId = header.OrgId
... ... @@ -28,13 +27,11 @@ func (controller *ContractUndertakerFeedbackController) UpdateContractUndertaker
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
updateContractUndertakerFeedbackCommand := &command.UpdateContractUndertakerFeedbackCommand{}
_ = controller.Unmarshal(updateContractUndertakerFeedbackCommand)
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
updateContractUndertakerFeedbackCommand.CompanyId = header.CompanyId
updateContractUndertakerFeedbackCommand.OrgId = header.OrgId
updateContractUndertakerFeedbackCommand.UserId = header.UserId
updateContractUndertakerFeedbackCommand.UserBaseId = header.UserBaseId
// 解析路径参数
contractUndertakerFeedbackId := controller.GetString(":contractUndertakerFeedbackId")
updateContractUndertakerFeedbackCommand.FeedbackId = contractUndertakerFeedbackId
data, err := contractUndertakerFeedbackService.UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand)
... ... @@ -44,13 +41,11 @@ func (controller *ContractUndertakerFeedbackController) UpdateContractUndertaker
func (controller *ContractUndertakerFeedbackController) GetContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
getContractUndertakerFeedbackQuery := &query.GetContractUndertakerFeedbackQuery{}
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
getContractUndertakerFeedbackQuery.CompanyId = header.CompanyId
getContractUndertakerFeedbackQuery.OrgId = header.OrgId
getContractUndertakerFeedbackQuery.UserId = header.UserId
getContractUndertakerFeedbackQuery.UserBaseId = header.UserBaseId
// 解析路径参数
contractUndertakerFeedbackId := controller.GetString(":contractUndertakerFeedbackId")
getContractUndertakerFeedbackQuery.FeedbackId = contractUndertakerFeedbackId
data, err := contractUndertakerFeedbackService.GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery)
... ... @@ -88,17 +83,17 @@ func (controller *ContractUndertakerFeedbackController) SearchContractUndertaker
func (controller *ContractUndertakerFeedbackController) ListContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
listContractUndertakerFeedbackQuery := &query.ListContractUndertakerFeedbackQuery{}
// 解析头部信息
header := controller.GetRequestHeader(controller.Ctx)
listContractUndertakerFeedbackQuery.CompanyId = header.CompanyId
listContractUndertakerFeedbackQuery.OrgId = header.OrgId
listContractUndertakerFeedbackQuery.UserId = header.UserId
listContractUndertakerFeedbackQuery.UserBaseId = header.UserBaseId
// 获取路径参数
pageSize, _ := controller.GetInt64("pageSize")
listContractUndertakerFeedbackQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
listContractUndertakerFeedbackQuery.PageNumber = pageNumber
underTakerUid := controller.GetString(":underTakerUid")
listContractUndertakerFeedbackQuery.UnderTakerUid = underTakerUid
data, err := contractUndertakerFeedbackService.ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery)
controller.Response(data, err)
}
... ...