作者 陈志颖

feat:添加工创信息反馈功能

正在显示 28 个修改的文件 包含 1003 行增加19 行删除
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type CreateContractUndertakerFeedbackCommand struct {
  13 + // 合约承接方反馈内容附件
  14 + FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment" valid:"Required"`
  15 + // 合约承接方反馈内容
  16 + FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
  17 + // 共创合约编号
  18 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  19 + // 承接人uid
  20 + UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
  21 + // 公司ID,通过集成REST上下文获取
  22 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  23 + // 组织机构ID
  24 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  25 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  26 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  27 +}
  28 +
  29 +func (createContractUndertakerFeedbackCommand *CreateContractUndertakerFeedbackCommand) Valid(validation *validation.Validation) {
  30 + validation.SetError("CustomValid", "未实现的自定义认证")
  31 +}
  32 +
  33 +func (createContractUndertakerFeedbackCommand *CreateContractUndertakerFeedbackCommand) ValidateCommand() error {
  34 + valid := validation.Validation{}
  35 + b, err := valid.Valid(createContractUndertakerFeedbackCommand)
  36 + if err != nil {
  37 + return err
  38 + }
  39 + if !b {
  40 + elem := reflect.TypeOf(createContractUndertakerFeedbackCommand).Elem()
  41 + for _, validErr := range valid.Errors {
  42 + field, isExist := elem.FieldByName(validErr.Field)
  43 + if isExist {
  44 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  45 + } else {
  46 + return fmt.Errorf(validErr.Message)
  47 + }
  48 + }
  49 + }
  50 + return nil
  51 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type RemoveContractUndertakerFeedbackCommand struct {
  12 + // 合约承接方反馈记录ID
  13 + FeedbackId int64 `cname:"合约承接方反馈记录ID" json:"feedbackId,string" valid:"Required"`
  14 + // 承接人uid
  15 + UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (removeContractUndertakerFeedbackCommand *RemoveContractUndertakerFeedbackCommand) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (removeContractUndertakerFeedbackCommand *RemoveContractUndertakerFeedbackCommand) ValidateCommand() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(removeContractUndertakerFeedbackCommand)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(removeContractUndertakerFeedbackCommand).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package command
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  6 + "reflect"
  7 + "strings"
  8 +
  9 + "github.com/beego/beego/v2/core/validation"
  10 +)
  11 +
  12 +type UpdateContractUndertakerFeedbackCommand struct {
  13 + // 合约承接方信息反馈id
  14 + FeedbackId string `cname:"合约承接方反馈信息id" json:"feedbackId" valid:"Required"`
  15 + // 合约承接方反馈内容附件
  16 + FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment" valid:"Required"`
  17 + // 合约承接方反馈内容
  18 + FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
  19 + // 共创合约编号
  20 + CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
  21 + // 承接人用户uid
  22 + UnderTakerUid string `cname:"承接人用户uid" json:"underTakerUid,omitempty"`
  23 + // 公司ID,通过集成REST上下文获取
  24 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  25 + // 组织机构ID
  26 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  27 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  28 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  29 +}
  30 +
  31 +func (updateContractUndertakerFeedbackCommand *UpdateContractUndertakerFeedbackCommand) Valid(validation *validation.Validation) {
  32 + validation.SetError("CustomValid", "未实现的自定义认证")
  33 +}
  34 +
  35 +func (updateContractUndertakerFeedbackCommand *UpdateContractUndertakerFeedbackCommand) ValidateCommand() error {
  36 + valid := validation.Validation{}
  37 + b, err := valid.Valid(updateContractUndertakerFeedbackCommand)
  38 + if err != nil {
  39 + return err
  40 + }
  41 + if !b {
  42 + elem := reflect.TypeOf(updateContractUndertakerFeedbackCommand).Elem()
  43 + for _, validErr := range valid.Errors {
  44 + field, isExist := elem.FieldByName(validErr.Field)
  45 + if isExist {
  46 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  47 + } else {
  48 + return fmt.Errorf(validErr.Message)
  49 + }
  50 + }
  51 + }
  52 + return nil
  53 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type GetContractUndertakerFeedbackQuery struct {
  12 + // 合约承接方反馈记录ID
  13 + FeedbackId int64 `cname:"合约承接方反馈记录ID" json:"feedbackId,string" valid:"Required"`
  14 + // 承接人uid
  15 + UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
  16 + // 公司ID,通过集成REST上下文获取
  17 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  18 + // 组织机构ID
  19 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  20 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  21 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  22 +}
  23 +
  24 +func (getContractUndertakerFeedbackQuery *GetContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
  25 + validation.SetError("CustomValid", "未实现的自定义认证")
  26 +}
  27 +
  28 +func (getContractUndertakerFeedbackQuery *GetContractUndertakerFeedbackQuery) ValidateQuery() error {
  29 + valid := validation.Validation{}
  30 + b, err := valid.Valid(getContractUndertakerFeedbackQuery)
  31 + if err != nil {
  32 + return err
  33 + }
  34 + if !b {
  35 + elem := reflect.TypeOf(getContractUndertakerFeedbackQuery).Elem()
  36 + for _, validErr := range valid.Errors {
  37 + field, isExist := elem.FieldByName(validErr.Field)
  38 + if isExist {
  39 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  40 + } else {
  41 + return fmt.Errorf(validErr.Message)
  42 + }
  43 + }
  44 + }
  45 + return nil
  46 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type ListContractUndertakerFeedbackQuery struct {
  12 + // 查询偏离量
  13 + Offset int `cname:"查询偏离量" json:"offset,omitempty"`
  14 + // 查询限制
  15 + Limit int `cname:"查询限制" json:"limit,omitempty"`
  16 + // 承接人uid
  17 + UnderTakerUid string `cname:"承接人uid" json:"underTakerUid" valid:"Required"`
  18 + // 公司ID,通过集成REST上下文获取
  19 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  20 + // 组织机构ID
  21 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  22 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  23 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  24 +}
  25 +
  26 +func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
  27 + validation.SetError("CustomValid", "未实现的自定义认证")
  28 +}
  29 +
  30 +func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) ValidateQuery() error {
  31 + valid := validation.Validation{}
  32 + b, err := valid.Valid(listContractUndertakerFeedbackQuery)
  33 + if err != nil {
  34 + return err
  35 + }
  36 + if !b {
  37 + elem := reflect.TypeOf(listContractUndertakerFeedbackQuery).Elem()
  38 + for _, validErr := range valid.Errors {
  39 + field, isExist := elem.FieldByName(validErr.Field)
  40 + if isExist {
  41 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  42 + } else {
  43 + return fmt.Errorf(validErr.Message)
  44 + }
  45 + }
  46 + }
  47 + return nil
  48 +}
  1 +package query
  2 +
  3 +import (
  4 + "fmt"
  5 + "reflect"
  6 + "strings"
  7 +
  8 + "github.com/beego/beego/v2/core/validation"
  9 +)
  10 +
  11 +type SearchContractUndertakerFeedbackQuery struct {
  12 + // 页面大小
  13 + PageNumber int32 `cname:"页面大小" json:"pageNumber" valid:"Required"`
  14 + // 页面大小
  15 + PageSize int32 `cname:"页面大小" json:"pageSize" valid:"Required"`
  16 + // 共创合约名称
  17 + CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
  18 + // 承接人姓名
  19 + UndertakerName string `cname:"承接人姓名" json:"undertakerName,omitempty"`
  20 + // 公司ID,通过集成REST上下文获取
  21 + CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
  22 + // 组织机构ID
  23 + OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
  24 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
  25 + UserId int64 `cname:"用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员" json:"userId,string" valid:"Required"`
  26 + // 查询关键词
  27 + MatchWord string `cname:"查询关键词" json:"matchWord,omitempty"`
  28 +}
  29 +
  30 +func (searchContractUndertakerFeedbackQuery *SearchContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
  31 + validation.SetError("CustomValid", "未实现的自定义认证")
  32 +}
  33 +
  34 +func (searchContractUndertakerFeedbackQuery *SearchContractUndertakerFeedbackQuery) ValidateQuery() error {
  35 + valid := validation.Validation{}
  36 + b, err := valid.Valid(searchContractUndertakerFeedbackQuery)
  37 + if err != nil {
  38 + return err
  39 + }
  40 + if !b {
  41 + elem := reflect.TypeOf(searchContractUndertakerFeedbackQuery).Elem()
  42 + for _, validErr := range valid.Errors {
  43 + field, isExist := elem.FieldByName(validErr.Field)
  44 + if isExist {
  45 + return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
  46 + } else {
  47 + return fmt.Errorf(validErr.Message)
  48 + }
  49 + }
  50 + }
  51 + return nil
  52 +}
  1 +package service
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/application"
  6 + "github.com/linmadan/egglib-go/utils/tool_funs"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query"
  9 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  11 +)
  12 +
  13 +// 共创合约反馈服务
  14 +type ContractUndertakerFeedbackService struct {
  15 +}
  16 +
  17 +// 创建共创合约反馈服务
  18 +func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand *command.CreateContractUndertakerFeedbackCommand) (interface{}, error) {
  19 + if err := createContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
  20 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  21 + }
  22 + transactionContext, err := factory.CreateTransactionContext(nil)
  23 + if err != nil {
  24 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  25 + }
  26 + if err := transactionContext.StartTransaction(); err != nil {
  27 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  28 + }
  29 + defer func() {
  30 + transactionContext.RollbackTransaction()
  31 + }()
  32 + newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{
  33 + FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment,
  34 + FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent,
  35 + CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber,
  36 + //UnderTakerUid: createContractUndertakerFeedbackCommand.UnderTakerUid,
  37 + //CompanyId: createContractUndertakerFeedbackCommand.CompanyId,
  38 + //OrgId: createContractUndertakerFeedbackCommand.OrgId,
  39 + //UserId: createContractUndertakerFeedbackCommand.UserId,
  40 + }
  41 + var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
  42 + if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
  43 + "transactionContext": transactionContext,
  44 + }); err != nil {
  45 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  46 + } else {
  47 + contractUndertakerFeedbackRepository = value
  48 + }
  49 + if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Save(newContractUndertakerFeedback); err != nil {
  50 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  51 + } else {
  52 + if err := transactionContext.CommitTransaction(); err != nil {
  53 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  54 + }
  55 + return contractUndertakerFeedback, nil
  56 + }
  57 +}
  58 +
  59 +// 返回共创合约反馈服务
  60 +func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery *query.GetContractUndertakerFeedbackQuery) (interface{}, error) {
  61 + if err := getContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
  62 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  63 + }
  64 + transactionContext, err := factory.CreateTransactionContext(nil)
  65 + if err != nil {
  66 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  67 + }
  68 + if err := transactionContext.StartTransaction(); err != nil {
  69 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  70 + }
  71 + defer func() {
  72 + transactionContext.RollbackTransaction()
  73 + }()
  74 + var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
  75 + if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
  76 + "transactionContext": transactionContext,
  77 + }); err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + } else {
  80 + contractUndertakerFeedbackRepository = value
  81 + }
  82 + contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": getContractUndertakerFeedbackQuery.FeedbackId})
  83 + if err != nil {
  84 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  85 + }
  86 + if contractUndertakerFeedback == nil {
  87 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getContractUndertakerFeedbackQuery.FeedbackId)))
  88 + } else {
  89 + if err := transactionContext.CommitTransaction(); err != nil {
  90 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  91 + }
  92 + return contractUndertakerFeedback, nil
  93 + }
  94 +}
  95 +
  96 +// 返回共创合约反馈服务列表
  97 +func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery *query.ListContractUndertakerFeedbackQuery) (interface{}, error) {
  98 + if err := listContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
  99 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  100 + }
  101 + transactionContext, err := factory.CreateTransactionContext(nil)
  102 + if err != nil {
  103 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  104 + }
  105 + if err := transactionContext.StartTransaction(); err != nil {
  106 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  107 + }
  108 + defer func() {
  109 + transactionContext.RollbackTransaction()
  110 + }()
  111 + var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
  112 + if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
  113 + "transactionContext": transactionContext,
  114 + }); err != nil {
  115 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  116 + } else {
  117 + contractUndertakerFeedbackRepository = value
  118 + }
  119 + if count, contractUndertakerFeedbacks, err := contractUndertakerFeedbackRepository.Find(tool_funs.SimpleStructToMap(listContractUndertakerFeedbackQuery)); err != nil {
  120 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  121 + } else {
  122 + if err := transactionContext.CommitTransaction(); err != nil {
  123 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  124 + }
  125 + return map[string]interface{}{
  126 + "count": count,
  127 + "contractUndertakerFeedbacks": contractUndertakerFeedbacks,
  128 + }, nil
  129 + }
  130 +}
  131 +
  132 +// 移除共创合约反馈服务
  133 +func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand *command.RemoveContractUndertakerFeedbackCommand) (interface{}, error) {
  134 + if err := removeContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
  135 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  136 + }
  137 + transactionContext, err := factory.CreateTransactionContext(nil)
  138 + if err != nil {
  139 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  140 + }
  141 + if err := transactionContext.StartTransaction(); err != nil {
  142 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  143 + }
  144 + defer func() {
  145 + transactionContext.RollbackTransaction()
  146 + }()
  147 + var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
  148 + if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
  149 + "transactionContext": transactionContext,
  150 + }); err != nil {
  151 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  152 + } else {
  153 + contractUndertakerFeedbackRepository = value
  154 + }
  155 + contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": removeContractUndertakerFeedbackCommand.FeedbackId})
  156 + if err != nil {
  157 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  158 + }
  159 + if contractUndertakerFeedback == nil {
  160 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeContractUndertakerFeedbackCommand.FeedbackId)))
  161 + }
  162 + if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Remove(contractUndertakerFeedback); err != nil {
  163 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  164 + } else {
  165 + if err := transactionContext.CommitTransaction(); err != nil {
  166 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  167 + }
  168 + return contractUndertakerFeedback, nil
  169 + }
  170 +}
  171 +
  172 +// 查询共创承接方反馈信息
  173 +func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery *query.SearchContractUndertakerFeedbackQuery) (interface{}, error) {
  174 + if err := searchContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
  175 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  176 + }
  177 + transactionContext, err := factory.CreateTransactionContext(nil)
  178 + if err != nil {
  179 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  180 + }
  181 + if err := transactionContext.StartTransaction(); err != nil {
  182 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  183 + }
  184 + defer func() {
  185 + transactionContext.RollbackTransaction()
  186 + }()
  187 + if err := transactionContext.CommitTransaction(); err != nil {
  188 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  189 + }
  190 + return nil, nil
  191 +}
  192 +
  193 +// 更新共创合约反馈服务
  194 +func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand *command.UpdateContractUndertakerFeedbackCommand) (interface{}, error) {
  195 + if err := updateContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
  196 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  197 + }
  198 + transactionContext, err := factory.CreateTransactionContext(nil)
  199 + if err != nil {
  200 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  201 + }
  202 + if err := transactionContext.StartTransaction(); err != nil {
  203 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  204 + }
  205 + defer func() {
  206 + transactionContext.RollbackTransaction()
  207 + }()
  208 + var contractUndertakerFeedbackRepository domain.ContractUndertakerFeedbackRepository
  209 + if value, err := factory.CreateContractUndertakerFeedbackRepository(map[string]interface{}{
  210 + "transactionContext": transactionContext,
  211 + }); err != nil {
  212 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  213 + } else {
  214 + contractUndertakerFeedbackRepository = value
  215 + }
  216 + contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": updateContractUndertakerFeedbackCommand.FeedbackId})
  217 + if err != nil {
  218 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  219 + }
  220 + if contractUndertakerFeedback == nil {
  221 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateContractUndertakerFeedbackCommand.FeedbackId)))
  222 + }
  223 + if err := contractUndertakerFeedback.Update(tool_funs.SimpleStructToMap(updateContractUndertakerFeedbackCommand)); err != nil {
  224 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  225 + }
  226 + if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Save(contractUndertakerFeedback); err != nil {
  227 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  228 + } else {
  229 + if err := transactionContext.CommitTransaction(); err != nil {
  230 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  231 + }
  232 + return contractUndertakerFeedback, nil
  233 + }
  234 +}
  235 +
  236 +func NewContractUndertakerFeedbackService(options map[string]interface{}) *ContractUndertakerFeedbackService {
  237 + newContractUndertakerFeedbackService := &ContractUndertakerFeedbackService{}
  238 + return newContractUndertakerFeedbackService
  239 +}
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type ContractUndertakerFeedback struct { 8 type ContractUndertakerFeedback struct {
9 tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"` 9 tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"`
10 // 合约承接方反馈记录ID 10 // 合约承接方反馈记录ID
11 - FeedbackId int64 `comment:"合约承接方反馈记录ID"` 11 + FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk"`
12 // 合约承接方反馈内容附件 12 // 合约承接方反馈内容附件
13 FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"` 13 FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"`
14 // 合约承接方反馈内容 14 // 合约承接方反馈内容
@@ -18,7 +18,7 @@ type ContractUndertakerFeedback struct { @@ -18,7 +18,7 @@ type ContractUndertakerFeedback struct {
18 // 共创合约承接人 18 // 共创合约承接人
19 ContractUndertaker *domain.User `comment:"共创合约承接人"` 19 ContractUndertaker *domain.User `comment:"共创合约承接人"`
20 // 共创模式 20 // 共创模式
21 - CooperationMode *CooperationMode `comment:"共创模式"` 21 + CooperationMode *domain.CooperationMode `comment:"共创模式"`
22 // 数据所属组织机构 22 // 数据所属组织机构
23 Org *domain.Org `comment:"数据所属组织机构"` 23 Org *domain.Org `comment:"数据所属组织机构"`
24 // 公司 24 // 公司
@@ -26,7 +26,7 @@ type ContractUndertakerFeedback struct { @@ -26,7 +26,7 @@ type ContractUndertakerFeedback struct {
26 // 更新时间 26 // 更新时间
27 UpdatedAt time.Time `comment:"更新时间"` 27 UpdatedAt time.Time `comment:"更新时间"`
28 // 删除时间 28 // 删除时间
29 - DeletedAt time.Time `comment:"删除时间"` 29 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
30 // 反馈创建时间,同时也作为反馈时间 30 // 反馈创建时间,同时也作为反馈时间
31 CreatedAt time.Time `comment:"反馈创建时间,同时也作为反馈时间"` 31 CreatedAt time.Time `comment:"反馈创建时间,同时也作为反馈时间"`
32 } 32 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationApplication struct { 8 type CooperationApplication struct {
9 tableName string `comment:"共创申请实体" pg:"cooperation_applications,alias:cooperation_application"` 9 tableName string `comment:"共创申请实体" pg:"cooperation_applications,alias:cooperation_application"`
10 // 共创申请ID 10 // 共创申请ID
11 - CooperationApplicationId int64 `comment:"共创申请ID" pg:"pk:cooperation_application_id"` 11 + CooperationApplicationId int64 `comment:"共创申请ID" pg:",pk:cooperation_application_id"`
12 // 共创申请人 12 // 共创申请人
13 CooperationApplicationApplicant *domain.User `comment:"共创申请人"` 13 CooperationApplicationApplicant *domain.User `comment:"共创申请人"`
14 // 共创申请描述附件 14 // 共创申请描述附件
@@ -26,7 +26,7 @@ type CooperationApplication struct { @@ -26,7 +26,7 @@ type CooperationApplication struct {
26 // 共创申请时间 26 // 共创申请时间
27 CooperationApplyTime time.Time `comment:"共创申请时间"` 27 CooperationApplyTime time.Time `comment:"共创申请时间"`
28 // 共创项目编号 28 // 共创项目编号
29 - CooperationProject *CooperationProject `comment:"共创项目编号"` 29 + CooperationProject *domain.CooperationProject `comment:"共创项目编号"`
30 // 数据所属组织机构 30 // 数据所属组织机构
31 Org *domain.Org `comment:"数据所属组织机构"` 31 Org *domain.Org `comment:"数据所属组织机构"`
32 // 公司 32 // 公司
@@ -34,7 +34,7 @@ type CooperationApplication struct { @@ -34,7 +34,7 @@ type CooperationApplication struct {
34 // 创建时间 34 // 创建时间
35 CreatedAt time.Time `comment:"创建时间"` 35 CreatedAt time.Time `comment:"创建时间"`
36 // 删除时间 36 // 删除时间
37 - DeletedAt time.Time `comment:"删除时间"` 37 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
38 // 更新时间 38 // 更新时间
39 UpdatedAt time.Time `comment:"更新时间"` 39 UpdatedAt time.Time `comment:"更新时间"`
40 } 40 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationContract struct { 8 type CooperationContract struct {
9 tableName string `comment:"共创项目合约实体" pg:"cooperation_contracts,alias:cooperation_contract"` 9 tableName string `comment:"共创项目合约实体" pg:"cooperation_contracts,alias:cooperation_contract"`
10 // 共创合约ID 10 // 共创合约ID
11 - CooperationContractId int64 `comment:"共创合约ID" pg:"pk:cooperation_contract_id"` 11 + CooperationContractId int64 `comment:"共创合约ID" pg:",pk:cooperation_contract_id"`
12 // 共创合约描述 12 // 共创合约描述
13 CooperationContractDescription string `comment:"共创合约描述"` 13 CooperationContractDescription string `comment:"共创合约描述"`
14 // 共创合约名称 14 // 共创合约名称
@@ -24,7 +24,7 @@ type CooperationContract struct { @@ -24,7 +24,7 @@ type CooperationContract struct {
24 // 共创合约发起人 24 // 共创合约发起人
25 CooperationContractSponsor *domain.User `comment:"共创合约发起人"` 25 CooperationContractSponsor *domain.User `comment:"共创合约发起人"`
26 // 共创模式或者合伙模式 26 // 共创模式或者合伙模式
27 - CooperationMode *CooperationMode `comment:"共创模式或者合伙模式"` 27 + CooperationMode *domain.CooperationMode `comment:"共创模式或者合伙模式"`
28 // 合约状态,1启用,2禁用 28 // 合约状态,1启用,2禁用
29 Status int32 `comment:"合约状态,1启用,2禁用"` 29 Status int32 `comment:"合约状态,1启用,2禁用"`
30 // 数据所属组织机构 30 // 数据所属组织机构
@@ -38,7 +38,7 @@ type CooperationContract struct { @@ -38,7 +38,7 @@ type CooperationContract struct {
38 // 创建时间 38 // 创建时间
39 CreatedAt time.Time `comment:"创建时间"` 39 CreatedAt time.Time `comment:"创建时间"`
40 // 删除时间 40 // 删除时间
41 - DeletedAt time.Time `comment:"删除时间"` 41 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
42 // 更新时间 42 // 更新时间
43 UpdatedAt time.Time `comment:"更新时间"` 43 UpdatedAt time.Time `comment:"更新时间"`
44 } 44 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationMode struct { 8 type CooperationMode struct {
9 tableName string `comment:"共创模式实体" pg:"cooperation_modes,alias:cooperation_mode"` 9 tableName string `comment:"共创模式实体" pg:"cooperation_modes,alias:cooperation_mode"`
10 // 共创模式ID 10 // 共创模式ID
11 - CooperationModeId int64 `comment:"共创模式ID" pg:"pk:cooperation_mode_id"` 11 + CooperationModeId int64 `comment:"共创模式ID" pg:",pk:cooperation_mode_id"`
12 // 共创模式编码,唯一确定 12 // 共创模式编码,唯一确定
13 CooperationModeNumber string `comment:"共创模式编码,唯一确定"` 13 CooperationModeNumber string `comment:"共创模式编码,唯一确定"`
14 // 模式名称,唯一确定 14 // 模式名称,唯一确定
@@ -28,7 +28,7 @@ type CooperationMode struct { @@ -28,7 +28,7 @@ type CooperationMode struct {
28 // 更新时间 28 // 更新时间
29 UpdatedAt time.Time `comment:"更新时间"` 29 UpdatedAt time.Time `comment:"更新时间"`
30 // 删除时间 30 // 删除时间
31 - DeletedAt time.Time `comment:"删除时间"` 31 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
32 // 创建时间 32 // 创建时间
33 CreatedAt time.Time `comment:"创建时间"` 33 CreatedAt time.Time `comment:"创建时间"`
34 } 34 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type CooperationProject struct { 8 type CooperationProject struct {
9 tableName string `comment:"共创项目实体" pg:"cooperation_projects,alias:cooperation_project"` 9 tableName string `comment:"共创项目实体" pg:"cooperation_projects,alias:cooperation_project"`
10 // 共创项目ID 10 // 共创项目ID
11 - CooperationProjectId int64 `comment:"共创项目ID" pg:"pk:cooperation_project_id"` 11 + CooperationProjectId int64 `comment:"共创项目ID" pg:",pk:cooperation_project_id"`
12 // 共创项目编号 12 // 共创项目编号
13 CooperationProjectNumber string `comment:"共创项目编号"` 13 CooperationProjectNumber string `comment:"共创项目编号"`
14 // 共创项目描述 14 // 共创项目描述
@@ -36,7 +36,7 @@ type CooperationProject struct { @@ -36,7 +36,7 @@ type CooperationProject struct {
36 // 更新时间 36 // 更新时间
37 UpdatedAt time.Time `comment:"更新时间"` 37 UpdatedAt time.Time `comment:"更新时间"`
38 // 删除时间 38 // 删除时间
39 - DeletedAt time.Time `comment:"删除时间"` 39 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
40 // 创建时间 40 // 创建时间
41 CreatedAt time.Time `comment:"创建时间"` 41 CreatedAt time.Time `comment:"创建时间"`
42 } 42 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type DividendsEstimate struct { 8 type DividendsEstimate struct {
9 tableName string `comment:"分红预算实体" pg:"dividends_estimates,alias:dividends_estimate"` 9 tableName string `comment:"分红预算实体" pg:"dividends_estimates,alias:dividends_estimate"`
10 // 承接人分红预算记录ID 10 // 承接人分红预算记录ID
11 - DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:"pk:dividends_estimate_id"` 11 + DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:",pk:dividends_estimate_id"`
12 // 分红结算状态 12 // 分红结算状态
13 DividendsAccountStatus int32 `comment:"分红结算状态"` 13 DividendsAccountStatus int32 `comment:"分红结算状态"`
14 // 分红金额 14 // 分红金额
@@ -38,7 +38,7 @@ type DividendsEstimate struct { @@ -38,7 +38,7 @@ type DividendsEstimate struct {
38 // 创建时间 38 // 创建时间
39 CreatedAt time.Time `comment:"创建时间"` 39 CreatedAt time.Time `comment:"创建时间"`
40 // 删除时间 40 // 删除时间
41 - DeletedAt time.Time `comment:"删除时间"` 41 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
42 // 更新时间 42 // 更新时间
43 UpdatedAt time.Time `comment:"更新时间"` 43 UpdatedAt time.Time `comment:"更新时间"`
44 } 44 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type DividendsIncentivesRule struct { 8 type DividendsIncentivesRule struct {
9 tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"` 9 tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"`
10 // 分红规则ID 10 // 分红规则ID
11 - DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:"pk:dividends_incentives_rule_id"` 11 + DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk:dividends_incentives_rule_id"`
12 // 关联的项目合约编号 12 // 关联的项目合约编号
13 CooperationContractNumber string `comment:"关联的项目合约编号"` 13 CooperationContractNumber string `comment:"关联的项目合约编号"`
14 // 推荐人抽成比例 14 // 推荐人抽成比例
@@ -30,7 +30,7 @@ type DividendsIncentivesRule struct { @@ -30,7 +30,7 @@ type DividendsIncentivesRule struct {
30 // 更新时间 30 // 更新时间
31 UpdatedAt time.Time `comment:"更新时间"` 31 UpdatedAt time.Time `comment:"更新时间"`
32 // 删除时间 32 // 删除时间
33 - DeletedAt time.Time `comment:"删除时间"` 33 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
34 // 创建时间 34 // 创建时间
35 CreatedAt time.Time `comment:"创建时间"` 35 CreatedAt time.Time `comment:"创建时间"`
36 } 36 }
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 type MoneyIncentivesRule struct { 8 type MoneyIncentivesRule struct {
9 tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"` 9 tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"`
10 // 金额激励规则ID 10 // 金额激励规则ID
11 - MoneyIncentivesRuleId int64 `comment:"金额激励规则ID"` 11 + MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"`
12 // 关联的共创合约编号 12 // 关联的共创合约编号
13 CooperationContractNumber string `comment:"关联的共创合约编号"` 13 CooperationContractNumber string `comment:"关联的共创合约编号"`
14 // 激励金额 14 // 激励金额
@@ -32,7 +32,7 @@ type MoneyIncentivesRule struct { @@ -32,7 +32,7 @@ type MoneyIncentivesRule struct {
32 // 更新时间 32 // 更新时间
33 UpdatedAt time.Time `comment:"更新时间"` 33 UpdatedAt time.Time `comment:"更新时间"`
34 // 删除时间 34 // 删除时间
35 - DeletedAt time.Time `comment:"删除时间"` 35 + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
36 // 创建时间 36 // 创建时间
37 CreatedAt time.Time `comment:"创建时间"` 37 CreatedAt time.Time `comment:"创建时间"`
38 } 38 }
  1 +package service_gateway
  2 +
  3 +import (
  4 + "encoding/json"
  5 + "fmt"
  6 + "github.com/beego/beego/v2/client/httplib"
  7 + "strconv"
  8 + "strings"
  9 + "time"
  10 +)
  11 +
  12 +type httplibBaseServiceGateway struct {
  13 + baseURL string
  14 + connectTimeout time.Duration
  15 + readWriteTimeout time.Duration
  16 +}
  17 +
  18 +func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, method string) *httplib.BeegoHTTPRequest {
  19 + var request *httplib.BeegoHTTPRequest
  20 + switch method {
  21 + case "get":
  22 + request = httplib.Get(url)
  23 + break
  24 + case "post":
  25 + request = httplib.Post(url)
  26 + break
  27 + case "put":
  28 + request = httplib.Put(url)
  29 + break
  30 + case "delete":
  31 + request = httplib.Delete(url)
  32 + break
  33 + case "head":
  34 + request = httplib.Head(url)
  35 + break
  36 + default:
  37 + request = httplib.Get(url)
  38 + }
  39 + return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout)
  40 +}
  41 +
  42 +func (serviceGateway *httplibBaseServiceGateway) responseHandle(response map[string]interface{}) (map[string]interface{}, error) {
  43 + data := make(map[string]interface{})
  44 + var err error
  45 + if code, ok := response["code"]; ok {
  46 + code := code.(float64)
  47 + if code == 0 {
  48 + data = response["data"].(map[string]interface{})
  49 + } else {
  50 + msg := response["msg"].(string)
  51 + err = fmt.Errorf(strings.Join([]string{strconv.FormatFloat(code, 'f', -1, 64), msg}, " "))
  52 + }
  53 + } else {
  54 + jsonBytes, marshalErr := json.Marshal(response)
  55 + if marshalErr != nil {
  56 + err = marshalErr
  57 + }
  58 + err = fmt.Errorf("无法解析的网关服务数据返回格式:%s", string(jsonBytes))
  59 + }
  60 + return data, err
  61 +}
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/linmadan/egglib-go/web/beego"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/service"
  8 +)
  9 +
  10 +type ContractUndertakerFeedbackController struct {
  11 + beego.BaseController
  12 +}
  13 +
  14 +func (controller *ContractUndertakerFeedbackController) CreateContractUndertakerFeedback() {
  15 + contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
  16 + createContractUndertakerFeedbackCommand := &command.CreateContractUndertakerFeedbackCommand{}
  17 + controller.Unmarshal(createContractUndertakerFeedbackCommand)
  18 + data, err := contractUndertakerFeedbackService.CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand)
  19 + controller.Response(data, err)
  20 +}
  21 +
  22 +func (controller *ContractUndertakerFeedbackController) UpdateContractUndertakerFeedback() {
  23 + contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
  24 + updateContractUndertakerFeedbackCommand := &command.UpdateContractUndertakerFeedbackCommand{}
  25 + controller.Unmarshal(updateContractUndertakerFeedbackCommand)
  26 + contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")
  27 + updateContractUndertakerFeedbackCommand.ContractUndertakerFeedbackId = contractUndertakerFeedbackId
  28 + data, err := contractUndertakerFeedbackService.UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand)
  29 + controller.Response(data, err)
  30 +}
  31 +
  32 +func (controller *ContractUndertakerFeedbackController) GetContractUndertakerFeedback() {
  33 + contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
  34 + getContractUndertakerFeedbackQuery := &query.GetContractUndertakerFeedbackQuery{}
  35 + contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")
  36 + getContractUndertakerFeedbackQuery.ContractUndertakerFeedbackId = contractUndertakerFeedbackId
  37 + data, err := contractUndertakerFeedbackService.GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery)
  38 + controller.Response(data, err)
  39 +}
  40 +
  41 +func (controller *ContractUndertakerFeedbackController) RemoveContractUndertakerFeedback() {
  42 + contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
  43 + removeContractUndertakerFeedbackCommand := &command.RemoveContractUndertakerFeedbackCommand{}
  44 + controller.Unmarshal(removeContractUndertakerFeedbackCommand)
  45 + contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")
  46 + removeContractUndertakerFeedbackCommand.ContractUndertakerFeedbackId = contractUndertakerFeedbackId
  47 + data, err := contractUndertakerFeedbackService.RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand)
  48 + controller.Response(data, err)
  49 +}
  50 +
  51 +func (controller *ContractUndertakerFeedbackController) SearchContractUndertakerFeedback() {
  52 + contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
  53 + searchContractUndertakerFeedbackQuery := &query.SearchContractUndertakerFeedbackQuery{}
  54 + data, err := contractUndertakerFeedbackService.SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery)
  55 + controller.Response(data, err)
  56 +}
  57 +
  58 +func (controller *ContractUndertakerFeedbackController) ListContractUndertakerFeedback() {
  59 + contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
  60 + listContractUndertakerFeedbackQuery := &query.ListContractUndertakerFeedbackQuery{}
  61 + offset, _ := controller.GetInt("offset")
  62 + listContractUndertakerFeedbackQuery.Offset = offset
  63 + limit, _ := controller.GetInt("limit")
  64 + listContractUndertakerFeedbackQuery.Limit = limit
  65 + data, err := contractUndertakerFeedbackService.ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery)
  66 + controller.Response(data, err)
  67 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + web.Router("/contract-undertaker-feedbacks/", &controllers.ContractUndertakerFeedbackController{}, "Post:CreateContractUndertakerFeedback")
  10 + web.Router("/contract-undertaker-feedbacks/:contractUndertakerFeedbackId", &controllers.ContractUndertakerFeedbackController{}, "Put:UpdateContractUndertakerFeedback")
  11 + web.Router("/contract-undertaker-feedbacks/:contractUndertakerFeedbackId", &controllers.ContractUndertakerFeedbackController{}, "Get:GetContractUndertakerFeedback")
  12 + web.Router("/contract-undertaker-feedbacks/:contractUndertakerFeedbackId", &controllers.ContractUndertakerFeedbackController{}, "Delete:RemoveContractUndertakerFeedback")
  13 + web.Router("/contract-undertaker-feedbacks/search", &controllers.ContractUndertakerFeedbackController{}, "Post:SearchContractUndertakerFeedback")
  14 + web.Router("/contract-undertaker-feedbacks/", &controllers.ContractUndertakerFeedbackController{}, "Get:ListContractUndertakerFeedback")
  15 +}
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "net/http"
  5 + "net/http/httptest"
  6 + "testing"
  7 +
  8 + "github.com/beego/beego/v2/server/web"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application"
  12 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  13 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
  14 +)
  15 +
  16 +func TestContractUndertakerFeedback(t *testing.T) {
  17 + RegisterFailHandler(Fail)
  18 + RunSpecs(t, "Beego Port ContractUndertakerFeedback Correlations Test Case Suite")
  19 +}
  20 +
  21 +var handler http.Handler
  22 +var server *httptest.Server
  23 +
  24 +var _ = BeforeSuite(func() {
  25 + handler = web.BeeApp.Handlers
  26 + server = httptest.NewServer(handler)
  27 +})
  28 +
  29 +var _ = AfterSuite(func() {
  30 + server.Close()
  31 +})
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/gavv/httpexpect"
  7 + . "github.com/onsi/ginkgo"
  8 + . "github.com/onsi/gomega"
  9 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  10 +)
  11 +
  12 +var _ = Describe("创建共创合约反馈服务", func() {
  13 + Describe("提交数据创建共创合约反馈服务", func() {
  14 + Context("提交正确的新承接人反馈信息数据", func() {
  15 + It("返回承接人反馈信息数据", func() {
  16 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  17 + body := map[string]interface{}{
  18 + "feedbackAttachment": "array",
  19 + "feedbackContent": "string",
  20 + "cooperationContractNumber": "string",
  21 + "underTakerUid": "string",
  22 + "companyId": "int64",
  23 + "orgId": "int64",
  24 + "userId": "int64",
  25 + }
  26 + httpExpect.POST("/contract-undertaker-feedbacks/").
  27 + WithJSON(body).
  28 + Expect().
  29 + Status(http.StatusOK).
  30 + JSON().
  31 + Object().
  32 + ContainsKey("code").ValueEqual("code", 0).
  33 + ContainsKey("msg").ValueEqual("msg", "ok").
  34 + ContainsKey("data").Value("data").Object().
  35 + ContainsKey("contractUndertakerFeedbackId").ValueNotEqual("contractUndertakerFeedbackId", BeZero())
  36 + })
  37 + })
  38 + })
  39 + AfterEach(func() {
  40 + _, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
  41 + Expect(err).NotTo(HaveOccurred())
  42 + })
  43 +})
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回共创合约反馈服务", func() {
  14 + var contractUndertakerFeedbackId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&contractUndertakerFeedbackId),
  18 + "INSERT INTO contract_undertaker_feedbacks (feedback_id, feedback_attachment, feedback_content, cooperation_contract_number, contract_undertaker, cooperation_mode, org, company, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING contract_undertaker_feedback_id",
  19 + "testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据contractUndertakerFeedbackId参数返回承接人反馈信息", func() {
  23 + Context("传入有效的contractUndertakerFeedbackId", func() {
  24 + It("返回承接人反馈信息数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/contract-undertaker-feedbacks/{contractUndertakerFeedbackId}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("返回共创合约反馈服务列表", func() {
  14 + var contractUndertakerFeedbackId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&contractUndertakerFeedbackId),
  18 + "INSERT INTO contract_undertaker_feedbacks (feedback_id, feedback_attachment, feedback_content, cooperation_contract_number, contract_undertaker, cooperation_mode, org, company, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING contract_undertaker_feedback_id",
  19 + "testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数返回承接人反馈信息列表", func() {
  23 + Context("传入有效的参数", func() {
  24 + It("返回承接人反馈信息数据列表", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.GET("/contract-undertaker-feedbacks/").
  27 + WithQuery("offset", "int").
  28 + WithQuery("limit", "int").
  29 + Expect().
  30 + Status(http.StatusOK).
  31 + JSON().
  32 + Object().
  33 + ContainsKey("code").ValueEqual("code", 0).
  34 + ContainsKey("msg").ValueEqual("msg", "ok").
  35 + ContainsKey("data").Value("data").Object().
  36 + ContainsKey("count").ValueEqual("count", 1).
  37 + ContainsKey("contractUndertakerFeedbacks").Value("contractUndertakerFeedbacks").Array()
  38 + })
  39 + })
  40 + })
  41 + AfterEach(func() {
  42 + _, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
  43 + Expect(err).NotTo(HaveOccurred())
  44 + })
  45 +})
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("移除共创合约反馈服务", func() {
  14 + var contractUndertakerFeedbackId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&contractUndertakerFeedbackId),
  18 + "INSERT INTO contract_undertaker_feedbacks (feedback_id, feedback_attachment, feedback_content, cooperation_contract_number, contract_undertaker, cooperation_mode, org, company, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING contract_undertaker_feedback_id",
  19 + "testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("根据参数移除共创合约反馈服务", func() {
  23 + Context("传入有效的contractUndertakerFeedbackId", func() {
  24 + It("返回被移除承接人反馈信息的数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + httpExpect.DELETE("/contract-undertaker-feedbacks/{contractUndertakerFeedbackId}").
  27 + Expect().
  28 + Status(http.StatusOK).
  29 + JSON().
  30 + Object().
  31 + ContainsKey("code").ValueEqual("code", 0).
  32 + ContainsKey("msg").ValueEqual("msg", "ok").
  33 + ContainsKey("data").Value("data").Object()
  34 + })
  35 + })
  36 + })
  37 + AfterEach(func() {
  38 + _, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
  39 + Expect(err).NotTo(HaveOccurred())
  40 + })
  41 +})
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("查询共创承接方反馈信息", func() {
  14 + var contractUndertakerFeedbackId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&contractUndertakerFeedbackId),
  18 + "INSERT INTO contract_undertaker_feedbacks (feedback_id, feedback_attachment, feedback_content, cooperation_contract_number, contract_undertaker, cooperation_mode, org, company, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING contract_undertaker_feedback_id",
  19 + "testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("查询共创承接方反馈信息", func() {
  23 + Context("", func() {
  24 + It("", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "pageNumber": "int32",
  28 + "pageSize": "int32",
  29 + "cooperationContractName": "string",
  30 + "undertakerName": "string",
  31 + "companyId": "int64",
  32 + "orgId": "int64",
  33 + "userId": "int64",
  34 + "matchWord": "string",
  35 + }
  36 + httpExpect.POST("/contract-undertaker-feedbacks/search").
  37 + WithJSON(body).
  38 + Expect().
  39 + Status(http.StatusOK).
  40 + JSON().
  41 + Object().
  42 + ContainsKey("code").ValueEqual("code", 0).
  43 + ContainsKey("msg").ValueEqual("msg", "ok").
  44 + ContainsKey("data").Value("data").Object()
  45 + })
  46 + })
  47 + })
  48 + AfterEach(func() {
  49 + _, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
  50 + Expect(err).NotTo(HaveOccurred())
  51 + })
  52 +})
  1 +package contract_undertaker_feedback
  2 +
  3 +import (
  4 + "github.com/go-pg/pg/v10"
  5 + "net/http"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + . "github.com/onsi/ginkgo"
  9 + . "github.com/onsi/gomega"
  10 + pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  11 +)
  12 +
  13 +var _ = Describe("更新共创合约反馈服务", func() {
  14 + var contractUndertakerFeedbackId int64
  15 + BeforeEach(func() {
  16 + _, err := pG.DB.QueryOne(
  17 + pg.Scan(&contractUndertakerFeedbackId),
  18 + "INSERT INTO contract_undertaker_feedbacks (feedback_id, feedback_attachment, feedback_content, cooperation_contract_number, contract_undertaker, cooperation_mode, org, company, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING contract_undertaker_feedback_id",
  19 + "testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
  20 + Expect(err).NotTo(HaveOccurred())
  21 + })
  22 + Describe("提交数据更新共创合约反馈服务", func() {
  23 + Context("提交正确的承接人反馈信息数据", func() {
  24 + It("返回更新后的承接人反馈信息数据", func() {
  25 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  26 + body := map[string]interface{}{
  27 + "feedbackAttachment": "array",
  28 + "feedbackContent": "string",
  29 + "cooperationContractNumber": "string",
  30 + "underTakerUid": "string",
  31 + "companyId": "int64",
  32 + "orgId": "int64",
  33 + "userId": "int64",
  34 + }
  35 + httpExpect.PUT("/contract-undertaker-feedbacks/{contractUndertakerFeedbackId}").
  36 + WithJSON(body).
  37 + Expect().
  38 + Status(http.StatusOK).
  39 + JSON().
  40 + Object().
  41 + ContainsKey("code").ValueEqual("code", 0).
  42 + ContainsKey("msg").ValueEqual("msg", "ok").
  43 + ContainsKey("data").Value("data").Object().
  44 + ContainsKey("contractUndertakerFeedbackId").ValueEqual("contractUndertakerFeedbackId", contractUndertakerFeedbackId)
  45 + })
  46 + })
  47 + })
  48 + AfterEach(func() {
  49 + _, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
  50 + Expect(err).NotTo(HaveOccurred())
  51 + })
  52 +})