作者 陈志颖

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

正在显示 28 个修改的文件 包含 1003 行增加19 行删除
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type CreateContractUndertakerFeedbackCommand struct {
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment" valid:"Required"`
// 合约承接方反馈内容
FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
// 共创合约编号
CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
// 承接人uid
UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" 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"`
}
func (createContractUndertakerFeedbackCommand *CreateContractUndertakerFeedbackCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createContractUndertakerFeedbackCommand *CreateContractUndertakerFeedbackCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createContractUndertakerFeedbackCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(createContractUndertakerFeedbackCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type RemoveContractUndertakerFeedbackCommand struct {
// 合约承接方反馈记录ID
FeedbackId int64 `cname:"合约承接方反馈记录ID" json:"feedbackId,string" valid:"Required"`
// 承接人uid
UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" 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"`
}
func (removeContractUndertakerFeedbackCommand *RemoveContractUndertakerFeedbackCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeContractUndertakerFeedbackCommand *RemoveContractUndertakerFeedbackCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeContractUndertakerFeedbackCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeContractUndertakerFeedbackCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateContractUndertakerFeedbackCommand struct {
// 合约承接方信息反馈id
FeedbackId string `cname:"合约承接方反馈信息id" json:"feedbackId" valid:"Required"`
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment" valid:"Required"`
// 合约承接方反馈内容
FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
// 共创合约编号
CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber" valid:"Required"`
// 承接人用户uid
UnderTakerUid string `cname:"承接人用户uid" json:"underTakerUid,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" 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"`
}
func (updateContractUndertakerFeedbackCommand *UpdateContractUndertakerFeedbackCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateContractUndertakerFeedbackCommand *UpdateContractUndertakerFeedbackCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateContractUndertakerFeedbackCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateContractUndertakerFeedbackCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type GetContractUndertakerFeedbackQuery struct {
// 合约承接方反馈记录ID
FeedbackId int64 `cname:"合约承接方反馈记录ID" json:"feedbackId,string" valid:"Required"`
// 承接人uid
UnderTakerUid string `cname:"承接人uid" json:"underTakerUid,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" 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"`
}
func (getContractUndertakerFeedbackQuery *GetContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getContractUndertakerFeedbackQuery *GetContractUndertakerFeedbackQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getContractUndertakerFeedbackQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(getContractUndertakerFeedbackQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListContractUndertakerFeedbackQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset,omitempty"`
// 查询限制
Limit int `cname:"查询限制" json:"limit,omitempty"`
// 承接人uid
UnderTakerUid string `cname:"承接人uid" json:"underTakerUid" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" 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"`
}
func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listContractUndertakerFeedbackQuery *ListContractUndertakerFeedbackQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listContractUndertakerFeedbackQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listContractUndertakerFeedbackQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type SearchContractUndertakerFeedbackQuery struct {
// 页面大小
PageNumber int32 `cname:"页面大小" json:"pageNumber" valid:"Required"`
// 页面大小
PageSize int32 `cname:"页面大小" json:"pageSize" valid:"Required"`
// 共创合约名称
CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName" valid:"Required"`
// 承接人姓名
UndertakerName string `cname:"承接人姓名" json:"undertakerName,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" 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"`
// 查询关键词
MatchWord string `cname:"查询关键词" json:"matchWord,omitempty"`
}
func (searchContractUndertakerFeedbackQuery *SearchContractUndertakerFeedbackQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (searchContractUndertakerFeedbackQuery *SearchContractUndertakerFeedbackQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(searchContractUndertakerFeedbackQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(searchContractUndertakerFeedbackQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
)
// 共创合约反馈服务
type ContractUndertakerFeedbackService struct {
}
// 创建共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand *command.CreateContractUndertakerFeedbackCommand) (interface{}, error) {
if err := createContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
newContractUndertakerFeedback := &domain.ContractUndertakerFeedback{
FeedbackAttachment: createContractUndertakerFeedbackCommand.FeedbackAttachment,
FeedbackContent: createContractUndertakerFeedbackCommand.FeedbackContent,
CooperationContractNumber: createContractUndertakerFeedbackCommand.CooperationContractNumber,
//UnderTakerUid: createContractUndertakerFeedbackCommand.UnderTakerUid,
//CompanyId: createContractUndertakerFeedbackCommand.CompanyId,
//OrgId: createContractUndertakerFeedbackCommand.OrgId,
//UserId: createContractUndertakerFeedbackCommand.UserId,
}
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
}
}
// 返回共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery *query.GetContractUndertakerFeedbackQuery) (interface{}, error) {
if err := getContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
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
}
contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": getContractUndertakerFeedbackQuery.FeedbackId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if contractUndertakerFeedback == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getContractUndertakerFeedbackQuery.FeedbackId)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return contractUndertakerFeedback, nil
}
}
// 返回共创合约反馈服务列表
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery *query.ListContractUndertakerFeedbackQuery) (interface{}, error) {
if err := listContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
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(listContractUndertakerFeedbackQuery)); 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 map[string]interface{}{
"count": count,
"contractUndertakerFeedbacks": contractUndertakerFeedbacks,
}, nil
}
}
// 移除共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand *command.RemoveContractUndertakerFeedbackCommand) (interface{}, error) {
if err := removeContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
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
}
contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": removeContractUndertakerFeedbackCommand.FeedbackId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if contractUndertakerFeedback == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeContractUndertakerFeedbackCommand.FeedbackId)))
}
if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Remove(contractUndertakerFeedback); 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
}
}
// 查询共创承接方反馈信息
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery *query.SearchContractUndertakerFeedbackQuery) (interface{}, error) {
if err := searchContractUndertakerFeedbackQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 更新共创合约反馈服务
func (contractUndertakerFeedbackService *ContractUndertakerFeedbackService) UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand *command.UpdateContractUndertakerFeedbackCommand) (interface{}, error) {
if err := updateContractUndertakerFeedbackCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
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
}
contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.FindOne(map[string]interface{}{"contractUndertakerFeedbackId": updateContractUndertakerFeedbackCommand.FeedbackId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if contractUndertakerFeedback == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateContractUndertakerFeedbackCommand.FeedbackId)))
}
if err := contractUndertakerFeedback.Update(tool_funs.SimpleStructToMap(updateContractUndertakerFeedbackCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if contractUndertakerFeedback, err := contractUndertakerFeedbackRepository.Save(contractUndertakerFeedback); 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
}
}
func NewContractUndertakerFeedbackService(options map[string]interface{}) *ContractUndertakerFeedbackService {
newContractUndertakerFeedbackService := &ContractUndertakerFeedbackService{}
return newContractUndertakerFeedbackService
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type ContractUndertakerFeedback struct {
tableName string `comment:"承接人反馈信息" pg:"contract_undertaker_feedbacks,alias:contract_undertaker_feedback"`
// 合约承接方反馈记录ID
FeedbackId int64 `comment:"合约承接方反馈记录ID"`
FeedbackId int64 `comment:"合约承接方反馈记录ID" pg:",pk"`
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `comment:"合约承接方反馈内容附件"`
// 合约承接方反馈内容
... ... @@ -18,7 +18,7 @@ type ContractUndertakerFeedback struct {
// 共创合约承接人
ContractUndertaker *domain.User `comment:"共创合约承接人"`
// 共创模式
CooperationMode *CooperationMode `comment:"共创模式"`
CooperationMode *domain.CooperationMode `comment:"共创模式"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 公司
... ... @@ -26,7 +26,7 @@ type ContractUndertakerFeedback struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 反馈创建时间,同时也作为反馈时间
CreatedAt time.Time `comment:"反馈创建时间,同时也作为反馈时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationApplication struct {
tableName string `comment:"共创申请实体" pg:"cooperation_applications,alias:cooperation_application"`
// 共创申请ID
CooperationApplicationId int64 `comment:"共创申请ID" pg:"pk:cooperation_application_id"`
CooperationApplicationId int64 `comment:"共创申请ID" pg:",pk:cooperation_application_id"`
// 共创申请人
CooperationApplicationApplicant *domain.User `comment:"共创申请人"`
// 共创申请描述附件
... ... @@ -26,7 +26,7 @@ type CooperationApplication struct {
// 共创申请时间
CooperationApplyTime time.Time `comment:"共创申请时间"`
// 共创项目编号
CooperationProject *CooperationProject `comment:"共创项目编号"`
CooperationProject *domain.CooperationProject `comment:"共创项目编号"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 公司
... ... @@ -34,7 +34,7 @@ type CooperationApplication struct {
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationContract struct {
tableName string `comment:"共创项目合约实体" pg:"cooperation_contracts,alias:cooperation_contract"`
// 共创合约ID
CooperationContractId int64 `comment:"共创合约ID" pg:"pk:cooperation_contract_id"`
CooperationContractId int64 `comment:"共创合约ID" pg:",pk:cooperation_contract_id"`
// 共创合约描述
CooperationContractDescription string `comment:"共创合约描述"`
// 共创合约名称
... ... @@ -24,7 +24,7 @@ type CooperationContract struct {
// 共创合约发起人
CooperationContractSponsor *domain.User `comment:"共创合约发起人"`
// 共创模式或者合伙模式
CooperationMode *CooperationMode `comment:"共创模式或者合伙模式"`
CooperationMode *domain.CooperationMode `comment:"共创模式或者合伙模式"`
// 合约状态,1启用,2禁用
Status int32 `comment:"合约状态,1启用,2禁用"`
// 数据所属组织机构
... ... @@ -38,7 +38,7 @@ type CooperationContract struct {
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationMode struct {
tableName string `comment:"共创模式实体" pg:"cooperation_modes,alias:cooperation_mode"`
// 共创模式ID
CooperationModeId int64 `comment:"共创模式ID" pg:"pk:cooperation_mode_id"`
CooperationModeId int64 `comment:"共创模式ID" pg:",pk:cooperation_mode_id"`
// 共创模式编码,唯一确定
CooperationModeNumber string `comment:"共创模式编码,唯一确定"`
// 模式名称,唯一确定
... ... @@ -28,7 +28,7 @@ type CooperationMode struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type CooperationProject struct {
tableName string `comment:"共创项目实体" pg:"cooperation_projects,alias:cooperation_project"`
// 共创项目ID
CooperationProjectId int64 `comment:"共创项目ID" pg:"pk:cooperation_project_id"`
CooperationProjectId int64 `comment:"共创项目ID" pg:",pk:cooperation_project_id"`
// 共创项目编号
CooperationProjectNumber string `comment:"共创项目编号"`
// 共创项目描述
... ... @@ -36,7 +36,7 @@ type CooperationProject struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsEstimate struct {
tableName string `comment:"分红预算实体" pg:"dividends_estimates,alias:dividends_estimate"`
// 承接人分红预算记录ID
DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:"pk:dividends_estimate_id"`
DividendsEstimateId int64 `comment:"承接人分红预算记录ID" pg:",pk:dividends_estimate_id"`
// 分红结算状态
DividendsAccountStatus int32 `comment:"分红结算状态"`
// 分红金额
... ... @@ -38,7 +38,7 @@ type DividendsEstimate struct {
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type DividendsIncentivesRule struct {
tableName string `comment:"金额激励规则实体" pg:"dividends_incentives_rules,alias:dividends_incentives_rule"`
// 分红规则ID
DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:"pk:dividends_incentives_rule_id"`
DividendsIncentivesRuleId int64 `comment:"分红规则ID" pg:",pk:dividends_incentives_rule_id"`
// 关联的项目合约编号
CooperationContractNumber string `comment:"关联的项目合约编号"`
// 推荐人抽成比例
... ... @@ -30,7 +30,7 @@ type DividendsIncentivesRule struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
... ... @@ -8,7 +8,7 @@ import (
type MoneyIncentivesRule struct {
tableName string `comment:"金额激励规则实体" pg:"money_incentives_rules,alias:money_incentives_rule"`
// 金额激励规则ID
MoneyIncentivesRuleId int64 `comment:"金额激励规则ID"`
MoneyIncentivesRuleId int64 `comment:"金额激励规则ID" pg:",pk"`
// 关联的共创合约编号
CooperationContractNumber string `comment:"关联的共创合约编号"`
// 激励金额
... ... @@ -32,7 +32,7 @@ type MoneyIncentivesRule struct {
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
package service_gateway
import (
"encoding/json"
"fmt"
"github.com/beego/beego/v2/client/httplib"
"strconv"
"strings"
"time"
)
type httplibBaseServiceGateway struct {
baseURL string
connectTimeout time.Duration
readWriteTimeout time.Duration
}
func (serviceGateway *httplibBaseServiceGateway) createRequest(url string, method string) *httplib.BeegoHTTPRequest {
var request *httplib.BeegoHTTPRequest
switch method {
case "get":
request = httplib.Get(url)
break
case "post":
request = httplib.Post(url)
break
case "put":
request = httplib.Put(url)
break
case "delete":
request = httplib.Delete(url)
break
case "head":
request = httplib.Head(url)
break
default:
request = httplib.Get(url)
}
return request.SetTimeout(serviceGateway.connectTimeout, serviceGateway.readWriteTimeout)
}
func (serviceGateway *httplibBaseServiceGateway) responseHandle(response map[string]interface{}) (map[string]interface{}, error) {
data := make(map[string]interface{})
var err error
if code, ok := response["code"]; ok {
code := code.(float64)
if code == 0 {
data = response["data"].(map[string]interface{})
} else {
msg := response["msg"].(string)
err = fmt.Errorf(strings.Join([]string{strconv.FormatFloat(code, 'f', -1, 64), msg}, " "))
}
} else {
jsonBytes, marshalErr := json.Marshal(response)
if marshalErr != nil {
err = marshalErr
}
err = fmt.Errorf("无法解析的网关服务数据返回格式:%s", string(jsonBytes))
}
return data, err
}
... ...
package controllers
import (
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/contractUndertakerFeedback/service"
)
type ContractUndertakerFeedbackController struct {
beego.BaseController
}
func (controller *ContractUndertakerFeedbackController) CreateContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
createContractUndertakerFeedbackCommand := &command.CreateContractUndertakerFeedbackCommand{}
controller.Unmarshal(createContractUndertakerFeedbackCommand)
data, err := contractUndertakerFeedbackService.CreateContractUndertakerFeedback(createContractUndertakerFeedbackCommand)
controller.Response(data, err)
}
func (controller *ContractUndertakerFeedbackController) UpdateContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
updateContractUndertakerFeedbackCommand := &command.UpdateContractUndertakerFeedbackCommand{}
controller.Unmarshal(updateContractUndertakerFeedbackCommand)
contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")
updateContractUndertakerFeedbackCommand.ContractUndertakerFeedbackId = contractUndertakerFeedbackId
data, err := contractUndertakerFeedbackService.UpdateContractUndertakerFeedback(updateContractUndertakerFeedbackCommand)
controller.Response(data, err)
}
func (controller *ContractUndertakerFeedbackController) GetContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
getContractUndertakerFeedbackQuery := &query.GetContractUndertakerFeedbackQuery{}
contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")
getContractUndertakerFeedbackQuery.ContractUndertakerFeedbackId = contractUndertakerFeedbackId
data, err := contractUndertakerFeedbackService.GetContractUndertakerFeedback(getContractUndertakerFeedbackQuery)
controller.Response(data, err)
}
func (controller *ContractUndertakerFeedbackController) RemoveContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
removeContractUndertakerFeedbackCommand := &command.RemoveContractUndertakerFeedbackCommand{}
controller.Unmarshal(removeContractUndertakerFeedbackCommand)
contractUndertakerFeedbackId, _ := controller.GetString(":contractUndertakerFeedbackId")
removeContractUndertakerFeedbackCommand.ContractUndertakerFeedbackId = contractUndertakerFeedbackId
data, err := contractUndertakerFeedbackService.RemoveContractUndertakerFeedback(removeContractUndertakerFeedbackCommand)
controller.Response(data, err)
}
func (controller *ContractUndertakerFeedbackController) SearchContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
searchContractUndertakerFeedbackQuery := &query.SearchContractUndertakerFeedbackQuery{}
data, err := contractUndertakerFeedbackService.SearchContractUndertakerFeedback(searchContractUndertakerFeedbackQuery)
controller.Response(data, err)
}
func (controller *ContractUndertakerFeedbackController) ListContractUndertakerFeedback() {
contractUndertakerFeedbackService := service.NewContractUndertakerFeedbackService(nil)
listContractUndertakerFeedbackQuery := &query.ListContractUndertakerFeedbackQuery{}
offset, _ := controller.GetInt("offset")
listContractUndertakerFeedbackQuery.Offset = offset
limit, _ := controller.GetInt("limit")
listContractUndertakerFeedbackQuery.Limit = limit
data, err := contractUndertakerFeedbackService.ListContractUndertakerFeedback(listContractUndertakerFeedbackQuery)
controller.Response(data, err)
}
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego/controllers"
)
func init() {
web.Router("/contract-undertaker-feedbacks/", &controllers.ContractUndertakerFeedbackController{}, "Post:CreateContractUndertakerFeedback")
web.Router("/contract-undertaker-feedbacks/:contractUndertakerFeedbackId", &controllers.ContractUndertakerFeedbackController{}, "Put:UpdateContractUndertakerFeedback")
web.Router("/contract-undertaker-feedbacks/:contractUndertakerFeedbackId", &controllers.ContractUndertakerFeedbackController{}, "Get:GetContractUndertakerFeedback")
web.Router("/contract-undertaker-feedbacks/:contractUndertakerFeedbackId", &controllers.ContractUndertakerFeedbackController{}, "Delete:RemoveContractUndertakerFeedback")
web.Router("/contract-undertaker-feedbacks/search", &controllers.ContractUndertakerFeedbackController{}, "Post:SearchContractUndertakerFeedback")
web.Router("/contract-undertaker-feedbacks/", &controllers.ContractUndertakerFeedbackController{}, "Get:ListContractUndertakerFeedback")
}
... ...
package contract_undertaker_feedback
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/beego/beego/v2/server/web"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
)
func TestContractUndertakerFeedback(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port ContractUndertakerFeedback Correlations Test Case Suite")
}
var handler http.Handler
var server *httptest.Server
var _ = BeforeSuite(func() {
handler = web.BeeApp.Handlers
server = httptest.NewServer(handler)
})
var _ = AfterSuite(func() {
server.Close()
})
... ...
package contract_undertaker_feedback
import (
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("创建共创合约反馈服务", func() {
Describe("提交数据创建共创合约反馈服务", func() {
Context("提交正确的新承接人反馈信息数据", func() {
It("返回承接人反馈信息数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"feedbackAttachment": "array",
"feedbackContent": "string",
"cooperationContractNumber": "string",
"underTakerUid": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.POST("/contract-undertaker-feedbacks/").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("contractUndertakerFeedbackId").ValueNotEqual("contractUndertakerFeedbackId", BeZero())
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package contract_undertaker_feedback
import (
"github.com/go-pg/pg/v10"
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("返回共创合约反馈服务", func() {
var contractUndertakerFeedbackId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&contractUndertakerFeedbackId),
"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",
"testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据contractUndertakerFeedbackId参数返回承接人反馈信息", func() {
Context("传入有效的contractUndertakerFeedbackId", func() {
It("返回承接人反馈信息数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/contract-undertaker-feedbacks/{contractUndertakerFeedbackId}").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package contract_undertaker_feedback
import (
"github.com/go-pg/pg/v10"
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("返回共创合约反馈服务列表", func() {
var contractUndertakerFeedbackId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&contractUndertakerFeedbackId),
"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",
"testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数返回承接人反馈信息列表", func() {
Context("传入有效的参数", func() {
It("返回承接人反馈信息数据列表", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/contract-undertaker-feedbacks/").
WithQuery("offset", "int").
WithQuery("limit", "int").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("count").ValueEqual("count", 1).
ContainsKey("contractUndertakerFeedbacks").Value("contractUndertakerFeedbacks").Array()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package contract_undertaker_feedback
import (
"github.com/go-pg/pg/v10"
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("移除共创合约反馈服务", func() {
var contractUndertakerFeedbackId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&contractUndertakerFeedbackId),
"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",
"testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数移除共创合约反馈服务", func() {
Context("传入有效的contractUndertakerFeedbackId", func() {
It("返回被移除承接人反馈信息的数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.DELETE("/contract-undertaker-feedbacks/{contractUndertakerFeedbackId}").
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package contract_undertaker_feedback
import (
"github.com/go-pg/pg/v10"
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("查询共创承接方反馈信息", func() {
var contractUndertakerFeedbackId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&contractUndertakerFeedbackId),
"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",
"testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("查询共创承接方反馈信息", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"pageNumber": "int32",
"pageSize": "int32",
"cooperationContractName": "string",
"undertakerName": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
"matchWord": "string",
}
httpExpect.POST("/contract-undertaker-feedbacks/search").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package contract_undertaker_feedback
import (
"github.com/go-pg/pg/v10"
"net/http"
"github.com/gavv/httpexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
)
var _ = Describe("更新共创合约反馈服务", func() {
var contractUndertakerFeedbackId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&contractUndertakerFeedbackId),
"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",
"testFeedbackId", "testFeedbackAttachment", "testFeedbackContent", "testCooperationContractNumber", "testContractUndertaker", "testCooperationMode", "testOrg", "testCompany", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("提交数据更新共创合约反馈服务", func() {
Context("提交正确的承接人反馈信息数据", func() {
It("返回更新后的承接人反馈信息数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"feedbackAttachment": "array",
"feedbackContent": "string",
"cooperationContractNumber": "string",
"underTakerUid": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.PUT("/contract-undertaker-feedbacks/{contractUndertakerFeedbackId}").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("contractUndertakerFeedbackId").ValueEqual("contractUndertakerFeedbackId", contractUndertakerFeedbackId)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM contract_undertaker_feedbacks WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...