作者 陈志颖

feat:新增共创合约变更记录接口

... ... @@ -11,7 +11,7 @@ import (
type CreateContractUndertakerFeedbackCommand struct {
// 合约承接方反馈内容附件
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment"`
FeedbackAttachment []*domain.Attachment `cname:"合约承接方反馈内容附件" json:"feedbackAttachment,omitempty"`
// 合约承接方反馈内容
FeedbackContent string `cname:"合约承接方反馈内容" json:"feedbackContent" valid:"Required"`
// 共创合约编号
... ...
... ... @@ -10,7 +10,7 @@ import (
type UpdateCooperationContractChangeLogCommand struct {
// 共创合约修改记录id
CooperationContractChangeLogId string `cname:"共创合约修改记录ID" json:"cooperationContractChangeLogId" valid:"Required"`
CooperationContractChangeLogId int64 `cname:"共创合约修改记录ID" json:"cooperationContractChangeLogId" valid:"Required"`
// 激励规则
IncentivesRule string `cname:"激励规则" json:"incentivesRule" valid:"Required"`
// 激励规则明细
... ...
package controllers
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContractChangeLog/service"
)
type CooperationContractChangeLogController struct {
BaseController
}
func (controller *CooperationContractChangeLogController) CreateCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
createCooperationContractChangeLogCommand := &command.CreateCooperationContractChangeLogCommand{}
_ = controller.Unmarshal(createCooperationContractChangeLogCommand)
header := controller.GetRequestHeader(controller.Ctx)
createCooperationContractChangeLogCommand.CompanyId = header.CompanyId
createCooperationContractChangeLogCommand.OrgId = header.OrgId
createCooperationContractChangeLogCommand.UserId = header.UserId
createCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId
data, err := cooperationContractChangeLogService.CreateCooperationContractChangeLog(createCooperationContractChangeLogCommand)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) UpdateCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
updateCooperationContractChangeLogCommand := &command.UpdateCooperationContractChangeLogCommand{}
_ = controller.Unmarshal(updateCooperationContractChangeLogCommand)
header := controller.GetRequestHeader(controller.Ctx)
updateCooperationContractChangeLogCommand.CompanyId = header.CompanyId
updateCooperationContractChangeLogCommand.OrgId = header.OrgId
updateCooperationContractChangeLogCommand.UserId = header.UserId
updateCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId
cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId")
updateCooperationContractChangeLogCommand.CooperationContractChangeLogId = cooperationContractChangeLogId
data, err := cooperationContractChangeLogService.UpdateCooperationContractChangeLog(updateCooperationContractChangeLogCommand)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) GetCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
getCooperationContractChangeLogQuery := &query.GetCooperationContractChangeLogQuery{}
header := controller.GetRequestHeader(controller.Ctx)
getCooperationContractChangeLogQuery.CompanyId = header.CompanyId
getCooperationContractChangeLogQuery.OrgId = header.OrgId
getCooperationContractChangeLogQuery.UserId = header.UserId
getCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId
cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId")
getCooperationContractChangeLogQuery.CooperationContractChangeLogId = cooperationContractChangeLogId
data, err := cooperationContractChangeLogService.GetCooperationContractChangeLog(getCooperationContractChangeLogQuery)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) RemoveCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
removeCooperationContractChangeLogCommand := &command.RemoveCooperationContractChangeLogCommand{}
_ = controller.Unmarshal(removeCooperationContractChangeLogCommand)
header := controller.GetRequestHeader(controller.Ctx)
removeCooperationContractChangeLogCommand.CompanyId = header.CompanyId
removeCooperationContractChangeLogCommand.OrgId = header.OrgId
removeCooperationContractChangeLogCommand.UserId = header.UserId
removeCooperationContractChangeLogCommand.UserBaseId = header.UserBaseId
cooperationContractChangeLogId, _ := controller.GetInt64(":cooperationContractChangeLogId")
removeCooperationContractChangeLogCommand.CooperationContractChangeLogId = cooperationContractChangeLogId
data, err := cooperationContractChangeLogService.RemoveCooperationContractChangeLog(removeCooperationContractChangeLogCommand)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) ListCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
listCooperationContractChangeLogQuery := &query.ListCooperationContractChangeLogQuery{}
header := controller.GetRequestHeader(controller.Ctx)
listCooperationContractChangeLogQuery.CompanyId = header.CompanyId
listCooperationContractChangeLogQuery.OrgId = header.OrgId
listCooperationContractChangeLogQuery.UserId = header.UserId
listCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
listCooperationContractChangeLogQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
listCooperationContractChangeLogQuery.PageNumber = pageNumber
data, err := cooperationContractChangeLogService.ListCooperationContractChangeLog(listCooperationContractChangeLogQuery)
controller.Response(data, err)
}
func (controller *CooperationContractChangeLogController) SearchCooperationContractChangeLog() {
cooperationContractChangeLogService := service.NewCooperationContractChangeLogService(nil)
searchCooperationContractChangeLogQuery := &query.SearchCooperationContractChangeLogQuery{}
_ = controller.Unmarshal(searchCooperationContractChangeLogQuery)
header := controller.GetRequestHeader(controller.Ctx)
searchCooperationContractChangeLogQuery.CompanyId = header.CompanyId
searchCooperationContractChangeLogQuery.OrgId = header.OrgId
searchCooperationContractChangeLogQuery.UserId = header.UserId
searchCooperationContractChangeLogQuery.UserBaseId = header.UserBaseId
data, err := cooperationContractChangeLogService.SearchCooperationContractChangeLog(searchCooperationContractChangeLogQuery)
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("/cooperation-contract-change-logs/", &controllers.CooperationContractChangeLogController{}, "Post:CreateCooperationContractChangeLog") // 新增共创合约变更记录(预留)
web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Put:UpdateCooperationContractChangeLog") // 编辑共创合约变更记录(预留)
web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Get:GetCooperationContractChangeLog") // 获取共创合约变更记录详情(预留)
web.Router("/cooperation-contract-change-logs/:cooperationContractChangeLogId", &controllers.CooperationContractChangeLogController{}, "Delete:RemoveCooperationContractChangeLog") // 移除共创合约变更记录(预留)
web.Router("/cooperation-contract-change-logs/", &controllers.CooperationContractChangeLogController{}, "Get:ListCooperationContractChangeLog") // 返回共创合约变更记录列表
web.Router("/cooperation-contract-change-logs/search", &controllers.CooperationContractChangeLogController{}, "Post:SearchCooperationContractChangeLog") // 查询共创合约变更记录
}
... ...
package cooperation_contract_change_log
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 TestCooperationContractChangeLog(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Beego Port CooperationContractChangeLog 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 cooperation_contract_change_log
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{}{
"incentivesRule": "string",
"incentivesRuleDetail": "string",
"operationType": "int32",
"undertakers": "string",
"cooperationContractNumber": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.POST("/cooperation-contract-change-logs/").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("cooperationContractChangeLogId").ValueNotEqual("cooperationContractChangeLogId", BeZero())
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
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() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据cooperationContractChangeLogId参数返回共创合约变更日志", func() {
Context("传入有效的cooperationContractChangeLogId", func() {
It("返回共创合约变更日志数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/cooperation-contract-change-logs/{cooperationContractChangeLogId}").
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 cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
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() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数返回共创合约变更日志列表", func() {
Context("传入有效的参数", func() {
It("返回共创合约变更日志数据列表", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.GET("/cooperation-contract-change-logs/").
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("cooperationContractChangeLogs").Value("cooperationContractChangeLogs").Array()
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
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() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("根据参数移除共创合约变更日志", func() {
Context("传入有效的cooperationContractChangeLogId", func() {
It("返回被移除共创合约变更日志的数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
httpExpect.DELETE("/cooperation-contract-change-logs/{cooperationContractChangeLogId}").
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 cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
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() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("共创合约变更记录搜索", func() {
Context("", func() {
It("", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"operationType": "int32",
"cooperationContractNumber": "string",
"pageSize": "int32",
"pageNumber": "int32",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.POST("/cooperation-contract-change-logs/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 cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...
package cooperation_contract_change_log
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() {
var cooperationContractChangeLogId int64
BeforeEach(func() {
_, err := pG.DB.QueryOne(
pg.Scan(&cooperationContractChangeLogId),
"INSERT INTO cooperation_contract_change_logs (cooperation_contract_change_log_id, incentives_rule, incentives_rule_detail, operation_type, cooperation_contract_number, undertakers, company, operator, updated_at, deleted_at, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING cooperation_contract_change_log_id",
"testCooperationContractChangeLogId", "testIncentivesRule", "testIncentivesRuleDetail", "testOperationType", "testCooperationContractNumber", "testUndertakers", "testCompany", "testOperator", "testUpdatedAt", "testDeletedAt", "testCreatedAt")
Expect(err).NotTo(HaveOccurred())
})
Describe("提交数据更新共创合约变更日志", func() {
Context("提交正确的共创合约变更日志数据", func() {
It("返回更新后的共创合约变更日志数据", func() {
httpExpect := httpexpect.New(GinkgoT(), server.URL)
body := map[string]interface{}{
"incentivesRule": "string",
"incentivesRuleDetail": "string",
"operationType": "int32",
"undertakers": "string",
"cooperationContractNumber": "string",
"companyId": "int64",
"orgId": "int64",
"userId": "int64",
}
httpExpect.PUT("/cooperation-contract-change-logs/{cooperationContractChangeLogId}").
WithJSON(body).
Expect().
Status(http.StatusOK).
JSON().
Object().
ContainsKey("code").ValueEqual("code", 0).
ContainsKey("msg").ValueEqual("msg", "ok").
ContainsKey("data").Value("data").Object().
ContainsKey("cooperationContractChangeLogId").ValueEqual("cooperationContractChangeLogId", cooperationContractChangeLogId)
})
})
})
AfterEach(func() {
_, err := pG.DB.Exec("DELETE FROM cooperation_contract_change_logs WHERE true")
Expect(err).NotTo(HaveOccurred())
})
})
... ...