作者 陈志颖

feat:添加分红预算接口

@@ -9,6 +9,8 @@ import ( @@ -9,6 +9,8 @@ import (
9 ) 9 )
10 10
11 type CancelDividendsEstimateCommand struct { 11 type CancelDividendsEstimateCommand struct {
  12 + // 承接人分红预算记录ID
  13 + DividendsEstimateId string `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"`
12 // 公司ID,通过集成REST上下文获取 14 // 公司ID,通过集成REST上下文获取
13 CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"` 15 CompanyId int64 `cname:"公司ID,通过集成REST上下文获取" json:"companyId,string" valid:"Required"`
14 // 组织机构ID 16 // 组织机构ID
  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/dividendsEstimate/command"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/service"
  8 +)
  9 +
  10 +type DividendsEstimateController struct {
  11 + beego.BaseController
  12 +}
  13 +
  14 +func (controller *DividendsEstimateController) CreateDividendsEstimate() {
  15 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  16 + createDividendsEstimateCommand := &command.CreateDividendsEstimateCommand{}
  17 + controller.Unmarshal(createDividendsEstimateCommand)
  18 + data, err := dividendsEstimateService.CreateDividendsEstimate(createDividendsEstimateCommand)
  19 + controller.Response(data, err)
  20 +}
  21 +
  22 +func (controller *DividendsEstimateController) UpdateDividendsEstimate() {
  23 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  24 + updateDividendsEstimateCommand := &command.UpdateDividendsEstimateCommand{}
  25 + controller.Unmarshal(updateDividendsEstimateCommand)
  26 + dividendsEstimateId, _ := controller.GetInt64(":dividendsEstimateId")
  27 + updateDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId
  28 + data, err := dividendsEstimateService.UpdateDividendsEstimate(updateDividendsEstimateCommand)
  29 + controller.Response(data, err)
  30 +}
  31 +
  32 +func (controller *DividendsEstimateController) GetDividendsEstimate() {
  33 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  34 + getDividendsEstimateQuery := &query.GetDividendsEstimateQuery{}
  35 + dividendsEstimateId, _ := controller.GetInt64(":dividendsEstimateId")
  36 + getDividendsEstimateQuery.DividendsEstimateId = dividendsEstimateId
  37 + data, err := dividendsEstimateService.GetDividendsEstimate(getDividendsEstimateQuery)
  38 + controller.Response(data, err)
  39 +}
  40 +
  41 +func (controller *DividendsEstimateController) RemoveDividendsEstimate() {
  42 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  43 + removeDividendsEstimateCommand := &command.RemoveDividendsEstimateCommand{}
  44 + controller.Unmarshal(removeDividendsEstimateCommand)
  45 + dividendsEstimateId, _ := controller.GetInt64(":dividendsEstimateId")
  46 + removeDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId
  47 + data, err := dividendsEstimateService.RemoveDividendsEstimate(removeDividendsEstimateCommand)
  48 + controller.Response(data, err)
  49 +}
  50 +
  51 +func (controller *DividendsEstimateController) CancelDividendsEstimate() {
  52 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  53 + cancelDividendsEstimateCommand := &command.CancelDividendsEstimateCommand{}
  54 + controller.Unmarshal(cancelDividendsEstimateCommand)
  55 + dividendsEstimateId := controller.GetString(":dividendsEstimateId")
  56 + cancelDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId
  57 + data, err := dividendsEstimateService.CancelDividendsEstimate(cancelDividendsEstimateCommand)
  58 + controller.Response(data, err)
  59 +}
  60 +
  61 +func (controller *DividendsEstimateController) SearchDividendsEstimate() {
  62 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  63 + searchDividendsEstimateQuery := &query.SearchDividendsEstimateQuery{}
  64 + data, err := dividendsEstimateService.SearchDividendsEstimate(searchDividendsEstimateQuery)
  65 + controller.Response(data, err)
  66 +}
  67 +
  68 +func (controller *DividendsEstimateController) EstimateDividendsIncentives() {
  69 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  70 + estimateDividendsIncentivesCommand := &command.EstimateDividendsIncentivesCommand{}
  71 + controller.Unmarshal(estimateDividendsIncentivesCommand)
  72 + data, err := dividendsEstimateService.EstimateDividendsIncentives(estimateDividendsIncentivesCommand)
  73 + controller.Response(data, err)
  74 +}
  75 +
  76 +func (controller *DividendsEstimateController) EstimateMoneyIncentives() {
  77 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  78 + estimateMoneyIncentivesCommand := &command.EstimateMoneyIncentivesCommand{}
  79 + controller.Unmarshal(estimateMoneyIncentivesCommand)
  80 + data, err := dividendsEstimateService.EstimateMoneyIncentives(estimateMoneyIncentivesCommand)
  81 + controller.Response(data, err)
  82 +}
  83 +
  84 +func (controller *DividendsEstimateController) ListMoneyIncentives() {
  85 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  86 + listMoneyIncentivesQuery := &query.ListMoneyIncentivesQuery{}
  87 + data, err := dividendsEstimateService.ListMoneyIncentives(listMoneyIncentivesQuery)
  88 + controller.Response(data, err)
  89 +}
  90 +
  91 +func (controller *DividendsEstimateController) SearchMoneyIncentives() {
  92 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  93 + searchMoneyIncentivesQuery := &query.SearchMoneyIncentivesQuery{}
  94 + data, err := dividendsEstimateService.SearchMoneyIncentives(searchMoneyIncentivesQuery)
  95 + controller.Response(data, err)
  96 +}
  97 +
  98 +func (controller *DividendsEstimateController) ListDividendsIncentives() {
  99 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  100 + listDividendsIncentivesQuery := &query.ListDividendsIncentivesQuery{}
  101 + data, err := dividendsEstimateService.ListDividendsIncentives(listDividendsIncentivesQuery)
  102 + controller.Response(data, err)
  103 +}
  104 +
  105 +func (controller *DividendsEstimateController) SearchDividendsIncentives() {
  106 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  107 + searchDividendsIncentivesQuery := &query.SearchDividendsIncentivesQuery{}
  108 + data, err := dividendsEstimateService.SearchDividendsIncentives(searchDividendsIncentivesQuery)
  109 + controller.Response(data, err)
  110 +}
  111 +
  112 +func (controller *DividendsEstimateController) ListDividendsEstimate() {
  113 + dividendsEstimateService := service.NewDividendsEstimateService(nil)
  114 + listDividendsEstimateQuery := &query.ListDividendsEstimateQuery{}
  115 + offset, _ := controller.GetInt("offset")
  116 + listDividendsEstimateQuery.Offset = offset
  117 + limit, _ := controller.GetInt("limit")
  118 + listDividendsEstimateQuery.Limit = limit
  119 + data, err := dividendsEstimateService.ListDividendsEstimate(listDividendsEstimateQuery)
  120 + controller.Response(data, err)
  121 +}
  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("/dividends-estimates/", &controllers.DividendsEstimateController{}, "Post:CreateDividendsEstimate")
  10 + web.Router("/dividends-estimates/:dividendsEstimateId", &controllers.DividendsEstimateController{}, "Put:UpdateDividendsEstimate")
  11 + web.Router("/dividends-estimates/:dividendsEstimateId", &controllers.DividendsEstimateController{}, "Get:GetDividendsEstimate")
  12 + web.Router("/dividends-estimates/:dividendsEstimateId", &controllers.DividendsEstimateController{}, "Delete:RemoveDividendsEstimate")
  13 + web.Router("/dividends-estimates/:dividendsEstimateId/cancel", &controllers.DividendsEstimateController{}, "Post:CancelDividendsEstimate")
  14 + web.Router("/dividends-estimates/search", &controllers.DividendsEstimateController{}, "Post:SearchDividendsEstimate")
  15 + web.Router("/dividends-estimates/estimate-dividends-incentives", &controllers.DividendsEstimateController{}, "Post:EstimateDividendsIncentives")
  16 + web.Router("/dividends-estimates/estimate-money-incentives", &controllers.DividendsEstimateController{}, "Post:EstimateMoneyIncentives")
  17 + web.Router("/dividends-estimates/list-money-incentives", &controllers.DividendsEstimateController{}, "Get:ListMoneyIncentives")
  18 + web.Router("/dividends-estimates/search-money-incentives", &controllers.DividendsEstimateController{}, "Post:SearchMoneyIncentives")
  19 + web.Router("/dividends-estimates/list-dividends-incentives", &controllers.DividendsEstimateController{}, "Get:ListDividendsIncentives")
  20 + web.Router("/dividends-estimates/search-dividends-incentives", &controllers.DividendsEstimateController{}, "Post:SearchDividendsIncentives")
  21 + web.Router("/dividends-estimates/", &controllers.DividendsEstimateController{}, "Get:ListDividendsEstimate")
  22 +}
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("取消分红预算", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "companyId": "int64",
  27 + "orgId": "int64",
  28 + "userId": "int64",
  29 + }
  30 + httpExpect.POST("/dividends-estimates/{dividendsEstimateId}/cancel").
  31 + WithJSON(body).
  32 + Expect().
  33 + Status(http.StatusOK).
  34 + JSON().
  35 + Object().
  36 + ContainsKey("code").ValueEqual("code", 0).
  37 + ContainsKey("msg").ValueEqual("msg", "ok").
  38 + ContainsKey("data").Value("data").Object()
  39 + })
  40 + })
  41 + })
  42 + AfterEach(func() {
  43 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  44 + Expect(err).NotTo(HaveOccurred())
  45 + })
  46 +})
  1 +package dividends_estimate
  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 + "companyId": "int64",
  19 + "orgId": "int64",
  20 + "userId": "int64",
  21 + }
  22 + httpExpect.POST("/dividends-estimates/").
  23 + WithJSON(body).
  24 + Expect().
  25 + Status(http.StatusOK).
  26 + JSON().
  27 + Object().
  28 + ContainsKey("code").ValueEqual("code", 0).
  29 + ContainsKey("msg").ValueEqual("msg", "ok").
  30 + ContainsKey("data").Value("data").Object().
  31 + ContainsKey("dividendsEstimateId").ValueNotEqual("dividendsEstimateId", BeZero())
  32 + })
  33 + })
  34 + })
  35 + AfterEach(func() {
  36 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  37 + Expect(err).NotTo(HaveOccurred())
  38 + })
  39 +})
  1 +package dividends_estimate
  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 TestDividendsEstimate(t *testing.T) {
  17 + RegisterFailHandler(Fail)
  18 + RunSpecs(t, "Beego Port DividendsEstimate 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 dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("确定预算分红激励", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "orderOrReturnedOrderNum": "string",
  27 + "cooperationContractNumber": "string",
  28 + "companyId": "int64",
  29 + "orgId": "int64",
  30 + "userId": "int64",
  31 + }
  32 + httpExpect.POST("/dividends-estimates/estimate-dividends-incentives").
  33 + WithJSON(body).
  34 + Expect().
  35 + Status(http.StatusOK).
  36 + JSON().
  37 + Object().
  38 + ContainsKey("code").ValueEqual("code", 0).
  39 + ContainsKey("msg").ValueEqual("msg", "ok").
  40 + ContainsKey("data").Value("data").Object()
  41 + })
  42 + })
  43 + })
  44 + AfterEach(func() {
  45 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  46 + Expect(err).NotTo(HaveOccurred())
  47 + })
  48 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("确定预算金额激励分红", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationContractNumber": "string",
  27 + "dividendsIncentivesStage": "int64",
  28 + "undertakerUid": "string",
  29 + "companyId": "int64",
  30 + "orgId": "int64",
  31 + "userId": "int64",
  32 + }
  33 + httpExpect.POST("/dividends-estimates/estimate-money-incentives").
  34 + WithJSON(body).
  35 + Expect().
  36 + Status(http.StatusOK).
  37 + JSON().
  38 + Object().
  39 + ContainsKey("code").ValueEqual("code", 0).
  40 + ContainsKey("msg").ValueEqual("msg", "ok").
  41 + ContainsKey("data").Value("data").Object()
  42 + })
  43 + })
  44 + })
  45 + AfterEach(func() {
  46 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  47 + Expect(err).NotTo(HaveOccurred())
  48 + })
  49 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("根据dividendsEstimateId参数返回分红预算实体", func() {
  22 + Context("传入有效的dividendsEstimateId", func() {
  23 + It("返回分红预算实体数据", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.GET("/dividends-estimates/{dividendsEstimateId}").
  26 + Expect().
  27 + Status(http.StatusOK).
  28 + JSON().
  29 + Object().
  30 + ContainsKey("code").ValueEqual("code", 0).
  31 + ContainsKey("msg").ValueEqual("msg", "ok").
  32 + ContainsKey("data").Value("data").Object()
  33 + })
  34 + })
  35 + })
  36 + AfterEach(func() {
  37 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  38 + Expect(err).NotTo(HaveOccurred())
  39 + })
  40 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("根据参数返回分红预算实体列表", func() {
  22 + Context("传入有效的参数", func() {
  23 + It("返回分红预算实体数据列表", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.GET("/dividends-estimates/").
  26 + WithQuery("offset", "int").
  27 + WithQuery("limit", "int").
  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("count").ValueEqual("count", 1).
  36 + ContainsKey("dividendsEstimates").Value("dividendsEstimates").Array()
  37 + })
  38 + })
  39 + })
  40 + AfterEach(func() {
  41 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  42 + Expect(err).NotTo(HaveOccurred())
  43 + })
  44 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("返回业绩激励分红", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.GET("/dividends-estimates/list-dividends-incentives").
  26 + Expect().
  27 + Status(http.StatusOK).
  28 + JSON().
  29 + Object().
  30 + ContainsKey("code").ValueEqual("code", 0).
  31 + ContainsKey("msg").ValueEqual("msg", "ok").
  32 + ContainsKey("data").Value("data").Object()
  33 + })
  34 + })
  35 + })
  36 + AfterEach(func() {
  37 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  38 + Expect(err).NotTo(HaveOccurred())
  39 + })
  40 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("返回金额激励分红", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.GET("/dividends-estimates/list-money-incentives").
  26 + Expect().
  27 + Status(http.StatusOK).
  28 + JSON().
  29 + Object().
  30 + ContainsKey("code").ValueEqual("code", 0).
  31 + ContainsKey("msg").ValueEqual("msg", "ok").
  32 + ContainsKey("data").Value("data").Object()
  33 + })
  34 + })
  35 + })
  36 + AfterEach(func() {
  37 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  38 + Expect(err).NotTo(HaveOccurred())
  39 + })
  40 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("根据参数移除分红预算服务", func() {
  22 + Context("传入有效的dividendsEstimateId", func() {
  23 + It("返回被移除分红预算实体的数据", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + httpExpect.DELETE("/dividends-estimates/{dividendsEstimateId}").
  26 + Expect().
  27 + Status(http.StatusOK).
  28 + JSON().
  29 + Object().
  30 + ContainsKey("code").ValueEqual("code", 0).
  31 + ContainsKey("msg").ValueEqual("msg", "ok").
  32 + ContainsKey("data").Value("data").Object()
  33 + })
  34 + })
  35 + })
  36 + AfterEach(func() {
  37 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  38 + Expect(err).NotTo(HaveOccurred())
  39 + })
  40 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("查询分红预算单", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "dividendsEstimateOrderNumber": "string",
  27 + "dividendsType": "int32",
  28 + "companyId": "int64",
  29 + "orgId": "int64",
  30 + "userId": "int64",
  31 + }
  32 + httpExpect.POST("/dividends-estimates/search").
  33 + WithJSON(body).
  34 + Expect().
  35 + Status(http.StatusOK).
  36 + JSON().
  37 + Object().
  38 + ContainsKey("code").ValueEqual("code", 0).
  39 + ContainsKey("msg").ValueEqual("msg", "ok").
  40 + ContainsKey("data").Value("data").Object()
  41 + })
  42 + })
  43 + })
  44 + AfterEach(func() {
  45 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  46 + Expect(err).NotTo(HaveOccurred())
  47 + })
  48 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("查询业绩分红", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationContractNumber": "string",
  27 + "orderOrReturnedOrderNum": "string",
  28 + "companyId": "int64",
  29 + "orgId": "int64",
  30 + "userId": "int64",
  31 + }
  32 + httpExpect.POST("/dividends-estimates/search-dividends-incentives").
  33 + WithJSON(body).
  34 + Expect().
  35 + Status(http.StatusOK).
  36 + JSON().
  37 + Object().
  38 + ContainsKey("code").ValueEqual("code", 0).
  39 + ContainsKey("msg").ValueEqual("msg", "ok").
  40 + ContainsKey("data").Value("data").Object()
  41 + })
  42 + })
  43 + })
  44 + AfterEach(func() {
  45 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  46 + Expect(err).NotTo(HaveOccurred())
  47 + })
  48 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("查询金额激励分红", func() {
  22 + Context("", func() {
  23 + It("", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "cooperationContractName": "string",
  27 + "departmentName": "string",
  28 + "companyId": "int64",
  29 + "orgId": "int64",
  30 + "userId": "int64",
  31 + }
  32 + httpExpect.POST("/dividends-estimates/search-money-incentives").
  33 + WithJSON(body).
  34 + Expect().
  35 + Status(http.StatusOK).
  36 + JSON().
  37 + Object().
  38 + ContainsKey("code").ValueEqual("code", 0).
  39 + ContainsKey("msg").ValueEqual("msg", "ok").
  40 + ContainsKey("data").Value("data").Object()
  41 + })
  42 + })
  43 + })
  44 + AfterEach(func() {
  45 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  46 + Expect(err).NotTo(HaveOccurred())
  47 + })
  48 +})
  1 +package dividends_estimate
  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 + var dividendsEstimateId int64
  14 + BeforeEach(func() {
  15 + _, err := pG.DB.QueryOne(
  16 + pg.Scan(&dividendsEstimateId),
  17 + "INSERT INTO dividends_estimates (dividends_estimate_id, dividends_account_status, dividends_amount, dividends_estimate_order_number, dividends_estimate_time, dividends_participate_type, dividends_type, order_or_returned_order_num, cooperation_project_number, dividends_user, org, company, operator, operate_time, created_at, deleted_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING dividends_estimate_id",
  18 + "testDividendsEstimateId", "testDividendsAccountStatus", "testDividendsAmount", "testDividendsEstimateOrderNumber", "testDividendsEstimateTime", "testDividendsParticipateType", "testDividendsType", "testOrderOrReturnedOrderNum", "testCooperationProjectNumber", "testDividendsUser", "testOrg", "testCompany", "testOperator", "testOperateTime", "testCreatedAt", "testDeletedAt", "testUpdatedAt")
  19 + Expect(err).NotTo(HaveOccurred())
  20 + })
  21 + Describe("提交数据更新分红预算服务", func() {
  22 + Context("提交正确的分红预算实体数据", func() {
  23 + It("返回更新后的分红预算实体数据", func() {
  24 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  25 + body := map[string]interface{}{
  26 + "companyId": "int64",
  27 + "orgId": "int64",
  28 + "userId": "int64",
  29 + }
  30 + httpExpect.PUT("/dividends-estimates/{dividendsEstimateId}").
  31 + WithJSON(body).
  32 + Expect().
  33 + Status(http.StatusOK).
  34 + JSON().
  35 + Object().
  36 + ContainsKey("code").ValueEqual("code", 0).
  37 + ContainsKey("msg").ValueEqual("msg", "ok").
  38 + ContainsKey("data").Value("data").Object().
  39 + ContainsKey("dividendsEstimateId").ValueEqual("dividendsEstimateId", dividendsEstimateId)
  40 + })
  41 + })
  42 + })
  43 + AfterEach(func() {
  44 + _, err := pG.DB.Exec("DELETE FROM dividends_estimates WHERE true")
  45 + Expect(err).NotTo(HaveOccurred())
  46 + })
  47 +})