作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !11
正在显示 89 个修改的文件 包含 861 行增加29 行删除
@@ -159,6 +159,39 @@ @@ -159,6 +159,39 @@
159 ### 分离领域 159 ### 分离领域
160 ![avatar](http://gitlab.fjmaimaimai.com/chenzhiying/img-folder/raw/master/dispatch.png) 160 ![avatar](http://gitlab.fjmaimaimai.com/chenzhiying/img-folder/raw/master/dispatch.png)
161 161
  162 +## 标准产品组工具使用
  163 +- 设置全局变量(替换YOUR-USER-PATH为你真实的项目路径)
  164 +
  165 + 1.生成路径(项目生成路径):/YOUR-USER-PATH/GolandProjects/
  166 +
  167 + 2.eggs根目录路径(领域描述语言DSL文档路径生成或引用路径):/YOUR-USER-PATH/GolandProjects/mmm-worth/document/
  168 +
  169 + 3.egg名称(通常为项目名称,同样是DSL文件夹名称):mmm-worth
  170 +
  171 +- 应用描述语言生成
  172 +
  173 + 1.应用描述语言egg脚手架生成
  174 +
  175 + 2.生成属性(Attribute)
  176 +
  177 + 3.生成模式(Schema)
  178 +
  179 + 4.生成服务(Service)
  180 +
  181 + 5.生成接口(Api)
  182 +
  183 +- 具体工程生成
  184 +
  185 + 1.生成接口文档(OpenApi)
  186 +
  187 + 2.生成项目代码脚手架
  188 +
  189 + 3.生成领域模型
  190 +
  191 + 4.生成应用服务
  192 +
  193 + 5.生成Http协议接口
  194 +
162 ## 安装与使用 195 ## 安装与使用
163 [价值系统代码仓库地址](http://gitlab.fjmaimaimai.com/linmadan/mmm-worth) 196 [价值系统代码仓库地址](http://gitlab.fjmaimaimai.com/linmadan/mmm-worth)
164 ### 新建开发分支,如:xxx-dev,下载相应分支代码 197 ### 新建开发分支,如:xxx-dev,下载相应分支代码
@@ -68,7 +68,7 @@ spec: @@ -68,7 +68,7 @@ spec:
68 - name: ABILITY_SERVICE_HOST 68 - name: ABILITY_SERVICE_HOST
69 value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" 69 value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
70 - name: MMM_OPEN_API_SERVICE_HOST 70 - name: MMM_OPEN_API_SERVICE_HOST
71 - value: "http://mmm-open-api-dev.fjmaimaimai.com" 71 + value: "https://mmm-open-api-dev.fjmaimaimai.com"
72 - name: LOG_PREFIX 72 - name: LOG_PREFIX
73 value: "[mmm-worth_dev]" 73 value: "[mmm-worth_dev]"
74 volumes: 74 volumes:
@@ -68,7 +68,7 @@ spec: @@ -68,7 +68,7 @@ spec:
68 - name: ABILITY_SERVICE_HOST 68 - name: ABILITY_SERVICE_HOST
69 value: "https://suplus-worth-app-gateway-test.fjmaimaimai.com" 69 value: "https://suplus-worth-app-gateway-test.fjmaimaimai.com"
70 - name: MMM_OPEN_API_SERVICE_HOST 70 - name: MMM_OPEN_API_SERVICE_HOST
71 - value: "http://mmm-open-api-test.fjmaimaimai.com" 71 + value: "https://mmm-open-api-test.fjmaimaimai.com"
72 - name: LOG_PREFIX 72 - name: LOG_PREFIX
73 value: "[mmm-worth_test]" 73 value: "[mmm-worth_test]"
74 volumes: 74 volumes:
@@ -1218,7 +1218,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1218,7 +1218,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1218 activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney 1218 activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
1219 activityFoundExchangedCash := activityFound.ExchangedCash 1219 activityFoundExchangedCash := activityFound.ExchangedCash
1220 1220
1221 - // 判断当前员工是否有效 1221 + // TODO 更改:根据uid和companyId,判断当前员工是否有效
1222 getEmployee := map[string]interface{}{ 1222 getEmployee := map[string]interface{}{
1223 "account": personFound.EmployeeInfo.EmployeeAccount, 1223 "account": personFound.EmployeeInfo.EmployeeAccount,
1224 "companyId": activityFound.CompanyId, 1224 "companyId": activityFound.CompanyId,
@@ -1535,7 +1535,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1535,7 +1535,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1535 cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金 1535 cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
1536 cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金 1536 cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
1537 1537
1538 - // 判断当前员工是否有效 1538 + // TODO 更改:根据uid和companyId,判断当前员工是否有效
1539 getEmployee := map[string]interface{}{ 1539 getEmployee := map[string]interface{}{
1540 "account": createExchangeCashPersonCommand.PersonAccount, 1540 "account": createExchangeCashPersonCommand.PersonAccount,
1541 "companyId": activityFound.CompanyId, 1541 "companyId": activityFound.CompanyId,
@@ -1563,7 +1563,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1563,7 +1563,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1563 } 1563 }
1564 employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值 1564 employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
1565 1565
1566 - // 判断当前员工是否已经在素币兑换清单中 1566 + // TODO 更改:根据uid和activityId判断当前员工是否已经在素币兑换清单中,
1567 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{ 1567 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
1568 "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount, 1568 "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
1569 "activityId": activityFound.ActivityId, 1569 "activityId": activityFound.ActivityId,
@@ -5,7 +5,7 @@ import "os" @@ -5,7 +5,7 @@ import "os"
5 const SERVICE_NAME = "mmm-worth" 5 const SERVICE_NAME = "mmm-worth"
6 6
7 var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" 7 var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
8 -var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com" 8 +var MMM_OPEN_API_SERVICE_HOST = "https://mmm-open-api-dev.fjmaimaimai.com"
9 9
10 var LOG_LEVEL = "debug" 10 var LOG_LEVEL = "debug"
11 var LOG_File = "logs/app.log" 11 var LOG_File = "logs/app.log"
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package service
  8 +
  9 +import (
  10 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  11 +)
  12 +
  13 +type MutationCashPoolService interface {
  14 + coreDomain.DomainEventPublisher
  15 + Mutation() error
  16 +}
1 package cash_pool 1 package cash_pool
2 2
3 import ( 3 import (
  4 + "github.com/go-pg/pg"
4 "net/http" 5 "net/http"
  6 + "time"
5 7
6 "github.com/gavv/httpexpect" 8 "github.com/gavv/httpexpect"
7 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/ginkgo"
@@ -10,14 +12,46 @@ import ( @@ -10,14 +12,46 @@ import (
10 ) 12 )
11 13
12 var _ = Describe("投入现金", func() { 14 var _ = Describe("投入现金", func() {
13 - Describe("投入现金并更新现金池数据", func() {  
14 - Context("提交正确的现金值(>=已兑换的现金)", func() {  
15 - It("返回现金池数据", func() { 15 + var (
  16 + cashPoolId int64
  17 + cash float64
  18 + )
  19 + BeforeEach(func() {
  20 + _, err := pG.DB.QueryOne(
  21 + pg.Scan( &cashPoolId, &cash),
  22 + "INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time",
  23 + 100, 312, 100, 10001, 0, 0, 0, 0, time.Now)
  24 + Expect(err).NotTo(HaveOccurred())
  25 + })
  26 + Describe("投入现金到现金池", func() {
  27 + Context("投入错误的金额", func() {
  28 + It("返回现金池错误数据", func() {
16 httpExpect := httpexpect.New(GinkgoT(), server.URL) 29 httpExpect := httpexpect.New(GinkgoT(), server.URL)
17 body := map[string]interface{}{ 30 body := map[string]interface{}{
18 - "cashAmount": 100, 31 + "cash": 99,
  32 + "companyId": 312,
  33 + }
  34 + httpExpect.POST("/cash-pool/input").
  35 + WithJSON(body).
  36 + Expect().
  37 + Status(http.StatusOK).
  38 + JSON().
  39 + Object().
  40 + ContainsKey("code").ValueEqual("code", 501).
  41 + ContainsKey("msg").ValueEqual("msg", "投入的现金值必须大于当前已兑换现金值").
  42 + NotContainsKey("data").Value("data").Object()
  43 + })
  44 + })
  45 + })
  46 + Describe("投入现金到现金池", func() {
  47 + Context("投入正确的金额", func() {
  48 + It("返回正确现金池数据", func() {
  49 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  50 + body := map[string]interface{} {
  51 + "cash": 100,
  52 + "companyId": 312,
19 } 53 }
20 - httpExpect.POST("/cash_pool/input"). 54 + httpExpect.POST("/cash-pool/input").
21 WithJSON(body). 55 WithJSON(body).
22 Expect(). 56 Expect().
23 Status(http.StatusOK). 57 Status(http.StatusOK).
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package cash_pool
  8 +
  9 +import (
  10 + "github.com/go-pg/pg"
  11 + "net/http"
  12 + "time"
  13 +
  14 + "github.com/gavv/httpexpect"
  15 + . "github.com/onsi/ginkgo"
  16 + . "github.com/onsi/gomega"
  17 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  18 +)
  19 +
  20 +var _ = Describe("返回现金池数据", func() {
  21 + var (
  22 + cashPoolId int64
  23 + cash float64
  24 + )
  25 + BeforeEach(func() {
  26 + _, err := pG.DB.QueryOne(
  27 + pg.Scan(&cashPoolId, &cash),
  28 + "INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate, last_rate, create_time",
  29 + 100, 312, 100, 10001, 0, 0, 0, 0, time.Now)
  30 + Expect(err).NotTo(HaveOccurred())
  31 + })
  32 + Describe("根据公司id返回现金池数据", func() {
  33 + Context("传入有效的公司id", func() {
  34 + It("返回现金池数据", func() {
  35 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  36 + httpExpect.GET("/cash-pool/cash-pool?companyId=312").
  37 + Expect().
  38 + Status(http.StatusOK).
  39 + JSON().
  40 + Object().
  41 + ContainsKey("code").ValueNotEqual("code", 0).
  42 + ContainsKey("msg").ValueNotEqual("msg", "ok").
  43 + ContainsKey("data").Value("data").Object()
  44 + })
  45 + })
  46 + })
  47 + AfterEach(func() {
  48 + _, err := pG.DB.Exec("DELETE FROM cash_pools WHERE true")
  49 + Expect(err).NotTo(HaveOccurred())
  50 + })
  51 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_activities
  8 +
  9 +import (
  10 + "net/http"
  11 +
  12 + "github.com/gavv/httpexpect"
  13 + . "github.com/onsi/ginkgo"
  14 + . "github.com/onsi/gomega"
  15 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  16 +)
  17 +
  18 +var _ = Describe("创建素币兑换活动", func() {
  19 + Describe("提交数据创建素币兑换活动", func() {
  20 + Context("提交正确的新活动数据", func() {
  21 + It("返回素币兑换活动数据", func() {
  22 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  23 + body := map[string]interface{}{
  24 + "companyId": 311,
  25 + "exchangeActivityName": "测试兑换活动",
  26 + "deadline": "2021-01-07T16:00:00.000Z",
  27 + "exchangeRate": 5.1,
  28 + }
  29 + httpExpect.POST("/cash-pool/activity").
  30 + WithJSON(body).
  31 + Expect().
  32 + Status(http.StatusOK).
  33 + JSON().
  34 + Object().
  35 + ContainsKey("code").ValueEqual("code", 0).
  36 + ContainsKey("msg").ValueEqual("msg", "ok").
  37 + ContainsKey("data").Value("data").Object()
  38 + })
  39 + })
  40 + })
  41 + AfterEach(func(){
  42 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_activities WHERE true")
  43 + Expect(err).NotTo(HaveOccurred())
  44 + })
  45 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_activities
  8 +
  9 +import (
  10 + "github.com/onsi/ginkgo"
  11 + "github.com/onsi/gomega"
  12 + "net/http"
  13 + "net/http/httptest"
  14 + "testing"
  15 +
  16 + "github.com/astaxie/beego"
  17 + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port Exchange Activities Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_activities
  8 +
  9 +import (
  10 + "net/http"
  11 + "strconv"
  12 + "time"
  13 +
  14 + "github.com/gavv/httpexpect"
  15 + "github.com/go-pg/pg"
  16 + . "github.com/onsi/ginkgo"
  17 + . "github.com/onsi/gomega"
  18 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  19 +)
  20 +
  21 +var _ = Describe("返回素币兑换活动", func() {
  22 + var (
  23 + exchangeCashActivityId int64
  24 + )
  25 + BeforeEach(func() {
  26 + _, err := pG.DB.QueryOne(
  27 + pg.Scan(&exchangeCashActivityId),
  28 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  29 + 311, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  30 + Expect(err).NotTo(HaveOccurred())
  31 + })
  32 + Describe("根据activityId返回活动", func(){
  33 + Context("传入有效的activityId", func() {
  34 + It("返回活动数据", func() {
  35 + activityIdStr := strconv.FormatInt(exchangeCashActivityId, 10)
  36 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  37 + httpExpect.GET("/cash-pool/activity/" + activityIdStr).
  38 + Expect().
  39 + Status(http.StatusOK).
  40 + JSON().
  41 + Object().
  42 + ContainsKey("code").ValueEqual("code", 0).
  43 + ContainsKey("msg").ValueEqual("msg", "ok").
  44 + ContainsKey("data").Value("data").Object()
  45 + })
  46 + })
  47 + })
  48 + AfterEach(func() {
  49 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_activities WHERE true")
  50 + Expect(err).NotTo(HaveOccurred())
  51 + })
  52 +})
  1 +package exchange_activities
  2 +
  3 +import (
  4 + "net/http"
  5 + "time"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + "github.com/go-pg/pg"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  12 +)
  13 +
  14 +var _ = Describe("返回兑换活动列表", func() {
  15 + var (
  16 + exchangeCashActivityId int64
  17 + )
  18 + BeforeEach(func() {
  19 + _, err := pG.DB.QueryOne(
  20 + pg.Scan(&exchangeCashActivityId),
  21 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  22 + 311, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  23 + Expect(err).NotTo(HaveOccurred())
  24 + })
  25 + Describe("根据参数返回素币兑换活动列表", func() {
  26 + Context("传入有效的参数", func() {
  27 + It("返回素币兑换清单列表", func() {
  28 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  29 + httpExpect.GET("/cash-pool/activity/?companyId=311&offset=0&limit=20").
  30 + WithQuery("companyId", 311).
  31 + WithQuery("offset", 0).
  32 + WithQuery("limit", 1).
  33 + Expect().
  34 + Status(http.StatusOK).
  35 + JSON().
  36 + Object().
  37 + ContainsKey("code").ValueEqual("code", 0).
  38 + ContainsKey("msg").ValueEqual("msg", "ok").
  39 + ContainsKey("data").Value("data").Object().
  40 + ContainsKey("count").ValueEqual("count", 1)
  41 + })
  42 + })
  43 + })
  44 + AfterEach(func() {
  45 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_activities WHERE true")
  46 + Expect(err).NotTo(HaveOccurred())
  47 + })
  48 +})
  1 +package exchange_activities
  2 +
  3 +import (
  4 + "net/http"
  5 + "strconv"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("移除素币兑换活动", func() {
  16 + var (
  17 + activityId int64
  18 + )
  19 + BeforeEach(func() {
  20 + _, err := pG.DB.QueryOne(
  21 + pg.Scan(&activityId),
  22 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  23 + 311, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  24 + Expect(err).NotTo(HaveOccurred())
  25 + })
  26 + Describe("根据参数移除素币兑换活动", func() {
  27 + Context("传入有效的活动id", func() {
  28 + It("返回被删除的素币兑换活动数据", func() {
  29 + activityIdStr := strconv.FormatInt(activityId, 10)
  30 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  31 + httpExpect.DELETE("/cash-pool/activity/" + activityIdStr).
  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 exchange_cash_activities WHERE true")
  44 + Expect(err).NotTo(HaveOccurred())
  45 + })
  46 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_activities
  8 +
  9 +import (
  10 + "net/http"
  11 + "time"
  12 +
  13 + "github.com/gavv/httpexpect"
  14 + "github.com/go-pg/pg"
  15 + . "github.com/onsi/ginkgo"
  16 + . "github.com/onsi/gomega"
  17 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  18 +)
  19 +
  20 +var _ = Describe("搜索素币兑换活动", func() {
  21 + var activityId int64
  22 + BeforeEach(func() {
  23 + _, err := pG.DB.QueryOne(
  24 + pg.Scan(&activityId),
  25 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  26 + 312, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  27 + Expect(err).NotTo(HaveOccurred())
  28 + })
  29 + Describe("搜索素币兑换活动", func() {
  30 + Context("指定搜索条件", func() {
  31 + It("返回搜索结果", func() {
  32 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  33 + body := map[string]interface{} {
  34 + "companyId": 312,
  35 + "deadline": "",
  36 + "activityNameMatch": "测试活动",
  37 + "offset": 0,
  38 + "limit": 20,
  39 + }
  40 + httpExpect.POST("/cash-pool/activity/search-activity").
  41 + WithJSON(body).
  42 + Expect().
  43 + Status(http.StatusOK).
  44 + JSON().
  45 + Object().
  46 + ContainsKey("code").ValueEqual("code", 0).
  47 + ContainsKey("msg").ValueEqual("msg", "ok").
  48 + ContainsKey("data").Value("data").Object()
  49 + })
  50 + })
  51 + })
  52 + AfterEach(func() {
  53 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_activities WHERE true")
  54 + Expect(err).NotTo(HaveOccurred())
  55 + })
  56 +})
  1 +package exchange_activities
  2 +
  3 +
  4 +import (
  5 + "net/http"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("更新素币兑换活动", func() {
  16 + var activityId int64
  17 + BeforeEach(func() {
  18 + _, err := pG.DB.QueryOne(
  19 + pg.Scan(&activityId),
  20 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  21 + 311, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  22 + Expect(err).NotTo(HaveOccurred())
  23 + })
  24 + Describe("提交数据更新素币兑换活动", func() {
  25 + Context("提交正确的素币兑换活动数据", func() {
  26 + It("返回更新后的素币兑换活动数据", func() {
  27 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  28 + body := map[string]interface{} {
  29 + "exchangeActivityName": "这是更新后的公司311的兑换活动,哈哈哈",
  30 + "deadline": "2020-12-14T23:59:59+08:00",
  31 + "exchangeRate": 1.2,
  32 + }
  33 + httpExpect.PUT("/cash-pool/activity/").
  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 + ContainsKey("id").ValueEqual("id", activityId)
  43 + })
  44 + })
  45 + })
  46 + AfterEach(func() {
  47 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_activities WHERE true")
  48 + Expect(err).NotTo(HaveOccurred())
  49 + })
  50 +})
  1 +package exchange_list
  2 +
  3 +import (
  4 + "github.com/go-pg/pg"
  5 + "net/http"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  12 +)
  13 +
  14 +var _ = Describe("创建素币兑换清单", func() {
  15 + var activityId int64
  16 + BeforeEach(func() {
  17 + _, err1 := pG.DB.QueryOne(
  18 + pg.Scan(),
  19 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  20 + 1, 101, 2499036607974745088, "testEmployeeName", "testEmployeeAccount", 100.00)
  21 + Expect(err1).NotTo(HaveOccurred())
  22 + _, err2 := pG.DB.QueryOne(
  23 + pg.Scan(),
  24 + "INSERT INTO employees (id, company_id, uid, employee_name, employee_account, su_money) VALUES (?, ?, ?, ?, ?, ?)",
  25 + 2, 101, 2499036607974745099, "testEmployeeName", "testEmployeeAccount", 0)
  26 + Expect(err2).NotTo(HaveOccurred())
  27 + _, err3 := pG.DB.QueryOne(
  28 + pg.Scan(&activityId),
  29 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  30 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  31 + Expect(err3).NotTo(HaveOccurred())
  32 + })
  33 + Describe("提交数据创建素币兑换清单", func() {
  34 + Context("提交正确的新建素币兑换清单数据", func() {
  35 + It("返回素币兑换清单数据", func() {
  36 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  37 + body := map[string]interface{} {
  38 + "uid": 2499036607974745088,
  39 + "exchangeCashActivityId": activityId,
  40 + "exchangedSuMoney": 1.13,
  41 + "operator": 2499036607974745099,
  42 + }
  43 + httpExpect.POST("/cash-pool/activity/exchange-list").
  44 + WithJSON(body).
  45 + Expect().
  46 + Status(http.StatusOK).
  47 + JSON().
  48 + Object().
  49 + ContainsKey("code").ValueEqual("code", 0).
  50 + ContainsKey("msg").ValueEqual("msg", "ok").
  51 + ContainsKey("data").Value("data").Object()
  52 + })
  53 + })
  54 + })
  55 + AfterEach(func() {
  56 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  57 + Expect(err).NotTo(HaveOccurred())
  58 + })
  59 +})
1 /** 1 /**
2 @author: stevechan 2 @author: stevechan
3 - @date: 2020/12/10 3 + @date: 2021/2/25
4 @note: 4 @note:
5 **/ 5 **/
6 6
7 -package su_money 7 +package exchange_list
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/23
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_list
  8 +
  9 +import (
  10 + "github.com/onsi/ginkgo"
  11 + "github.com/onsi/gomega"
  12 + "net/http"
  13 + "net/http/httptest"
  14 + "testing"
  15 +
  16 + "github.com/astaxie/beego"
  17 + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/port/beego"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port Exchange List Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/25
  4 + @note:
  5 +**/
  6 +
  7 +package exchange_list
  8 +
  9 +import (
  10 + "net/http"
  11 + "strconv"
  12 + "time"
  13 +
  14 + "github.com/gavv/httpexpect"
  15 + "github.com/go-pg/pg"
  16 + . "github.com/onsi/ginkgo"
  17 + . "github.com/onsi/gomega"
  18 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  19 +)
  20 +
  21 +var _ = Describe("获取素币兑换人员清单", func() {
  22 + var (
  23 + listId int64
  24 + )
  25 + BeforeEach(func() {
  26 + var (
  27 + activityId int64
  28 + )
  29 + _, err1 := pG.DB.QueryOne(
  30 + pg.Scan(&activityId),
  31 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  32 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  33 + Expect(err1).NotTo(HaveOccurred())
  34 + _, err2 := pG.DB.QueryOne(
  35 + pg.Scan(&listId),
  36 + "INSERT INTO exchange_cash_person_lists (activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash) VALUES (100, 3242227175192320, '卞信华3', '18900000000', 1.13, 5.76,3) RETURNING id, activity_id, uid, employee_name, employee_acco, exchanged_su_money, exchanged_cash",
  37 + activityId, 3242227175192320, "卞信华3", "18900000000", 1.13, 5.76, 3)
  38 + Expect(err2).NotTo(HaveOccurred())
  39 + })
  40 + Describe("根据listId返回素币兑换清单", func() {
  41 + Context("传入有效的listId", func() {
  42 + It("返回素币兑换清单", func() {
  43 + listIdStr := strconv.FormatInt(listId, 10)
  44 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  45 + httpExpect.GET("/cash-pool/activity/exchange-list/"+listIdStr).
  46 + Expect().
  47 + Status(http.StatusOK).
  48 + JSON().
  49 + Object().
  50 + ContainsKey("code").ValueEqual("code", 0).
  51 + ContainsKey("msg").ValueEqual("msg", "ok").
  52 + ContainsKey("data").Value("data").Object()
  53 + })
  54 + })
  55 + })
  56 + AfterEach(func() {
  57 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  58 + Expect(err).NotTo(HaveOccurred())
  59 + })
  60 +})
  1 +package exchange_list
  2 +
  3 +import (
  4 + "net/http"
  5 + "os"
  6 + "strconv"
  7 + "time"
  8 +
  9 + "github.com/gavv/httpexpect"
  10 + "github.com/go-pg/pg"
  11 + . "github.com/onsi/ginkgo"
  12 + . "github.com/onsi/gomega"
  13 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  14 +)
  15 +
  16 +var _ = Describe("导入素币兑换清单", func() {
  17 + var (
  18 + activityId int64
  19 + )
  20 + BeforeEach(func() {
  21 +
  22 + _, err1 := pG.DB.QueryOne(
  23 + pg.Scan(&activityId),
  24 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  25 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  26 + Expect(err1).NotTo(HaveOccurred())
  27 + })
  28 + Describe("通过excel文件导入素币兑换清单", func() {
  29 + Context("传入有效的素币兑换清单文件", func() {
  30 + It("返回素币兑换清单导入结果", func() {
  31 + activityIdStr := strconv.FormatInt(activityId, 10)
  32 + fh, _ := os.Open("./files/素币兑换清单模板.xlsx")
  33 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  34 + httpExpect.POST("/cash-pool/activity/exchange-list/import").
  35 + WithFormField("where", "{\"activityId\": \""+activityIdStr+"\", \"uid\": 3289819024952064}").
  36 + WithFile("file", "素币兑换清单模板.xlsx", fh).
  37 + Expect().
  38 + Status(http.StatusOK).
  39 + JSON().
  40 + Object().
  41 + ContainsKey("code").ValueEqual("code", 0).
  42 + ContainsKey("msg").ValueEqual("msg", "ok").
  43 + ContainsKey("data").Value("data").Object()
  44 +
  45 + _ = fh.Close()
  46 + })
  47 + })
  48 + })
  49 + AfterEach(func() {
  50 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  51 + Expect(err).NotTo(HaveOccurred())
  52 + })
  53 +})
  1 +package exchange_list
  2 +
  3 +import (
  4 + "net/http"
  5 + "time"
  6 +
  7 + "github.com/gavv/httpexpect"
  8 + "github.com/go-pg/pg"
  9 + . "github.com/onsi/ginkgo"
  10 + . "github.com/onsi/gomega"
  11 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  12 +)
  13 +
  14 +var _ = Describe("获取素币兑换人员清单列表", func() {
  15 + var (
  16 + listId int64
  17 + )
  18 + BeforeEach(func() {
  19 + var (
  20 + activityId int64
  21 + )
  22 + _, err1 := pG.DB.QueryOne(
  23 + pg.Scan(&activityId),
  24 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  25 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  26 + Expect(err1).NotTo(HaveOccurred())
  27 + _, err2 := pG.DB.QueryOne(
  28 + pg.Scan(&listId),
  29 + "INSERT INTO exchange_cash_person_lists (activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash) VALUES (100, 3242227175192320, '卞信华3', '18900000000', 1.13, 5.76,3) RETURNING id, activity_id, uid, employee_name, employee_acco, exchanged_su_money, exchanged_cash",
  30 + activityId, 3242227175192320, "卞信华3", "18900000000", 1.13, 5.76, 3)
  31 + Expect(err2).NotTo(HaveOccurred())
  32 + })
  33 + Describe("返回素币兑换清单列表", func() {
  34 + Context("传入有效的参数", func() {
  35 + It("返回素币兑换清单列表", func() {
  36 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  37 + httpExpect.GET("/cash-pool/activity/exchange-list").
  38 + WithQuery("companyId", 101).
  39 + WithQuery("offset", 0).
  40 + WithQuery("limit", 1).
  41 + Expect().
  42 + Status(http.StatusOK).
  43 + JSON().
  44 + Object().
  45 + ContainsKey("code").ValueEqual("code", 0).
  46 + ContainsKey("msg").ValueEqual("msg", "ok").
  47 + ContainsKey("data").Value("data").Object().
  48 + ContainsKey("count").ValueEqual("count", 1).
  49 + ContainsKey("people").Value("people").Array()
  50 + })
  51 + })
  52 + })
  53 + AfterEach(func() {
  54 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  55 + Expect(err).NotTo(HaveOccurred())
  56 + })
  57 +})
  1 +package exchange_list
  2 +
  3 +import (
  4 + "net/http"
  5 + "strconv"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("删除素币兑换清单", func() {
  16 + var (
  17 + listId int64
  18 + )
  19 + BeforeEach(func() {
  20 + var (
  21 + activityId int64
  22 + )
  23 + _, err1 := pG.DB.QueryOne(
  24 + pg.Scan(&activityId),
  25 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  26 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  27 + Expect(err1).NotTo(HaveOccurred())
  28 + _, err2 := pG.DB.QueryOne(
  29 + pg.Scan(&listId),
  30 + "INSERT INTO exchange_cash_person_lists (activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash) VALUES (100, 3242227175192320, '卞信华3', '18900000000', 1.13, 5.76,3) RETURNING id, activity_id, uid, employee_name, employee_acco, exchanged_su_money, exchanged_cash",
  31 + activityId, 3242227175192320, "卞信华3", "18900000000", 1.13, 5.76, 3)
  32 + Expect(err2).NotTo(HaveOccurred())
  33 + })
  34 + Describe("根据listId删除素币兑换清单", func() {
  35 + Context("传入有效的listId", func() {
  36 + It("返回已删除的素币兑换清单", func() {
  37 + listIdStr := strconv.FormatInt(listId, 10)
  38 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  39 + httpExpect.DELETE("/cash-pool/activity/exchange-list/"+listIdStr).
  40 + WithQuery("operator", 3242227175192320).
  41 + Expect().
  42 + Status(http.StatusOK).
  43 + JSON().
  44 + Object().
  45 + ContainsKey("code").ValueEqual("code", 0).
  46 + ContainsKey("msg").ValueEqual("msg", "ok").
  47 + ContainsKey("data").Value("data").Object()
  48 + })
  49 + })
  50 + })
  51 + AfterEach(func() {
  52 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  53 + Expect(err).NotTo(HaveOccurred())
  54 + })
  55 +})
  1 +package exchange_list
  2 +
  3 +import (
  4 + "net/http"
  5 + "strconv"
  6 + "time"
  7 +
  8 + "github.com/gavv/httpexpect"
  9 + "github.com/go-pg/pg"
  10 + . "github.com/onsi/ginkgo"
  11 + . "github.com/onsi/gomega"
  12 + pG "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg"
  13 +)
  14 +
  15 +var _ = Describe("更新素币兑换人员清单", func() {
  16 + var (
  17 + listId int64
  18 + )
  19 + BeforeEach(func() {
  20 + var (
  21 + activityId int64
  22 + )
  23 + _, err1 := pG.DB.QueryOne(
  24 + pg.Scan(&activityId),
  25 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate, create_time",
  26 + 101, "测试活动", "2021-02-08 15:59:59+00:00:00", 0, 0, 0, 5.1, time.Now())
  27 + Expect(err1).NotTo(HaveOccurred())
  28 + _, err2 := pG.DB.QueryOne(
  29 + pg.Scan(&listId),
  30 + "INSERT INTO exchange_cash_person_lists (activity_id, uid, employee_name, employee_account, exchanged_su_money, exchanged_cash) VALUES (100, 3242227175192320, '卞信华3', '18900000000', 1.13, 5.76,3) RETURNING id, activity_id, uid, employee_name, employee_acco, exchanged_su_money, exchanged_cash",
  31 + activityId, 3242227175192320, "卞信华3", "18900000000", 1.13, 5.76, 3)
  32 + Expect(err2).NotTo(HaveOccurred())
  33 + })
  34 + Describe("根据listId更新素币兑换清单", func() {
  35 + Context("传入有效的listId", func() {
  36 + It("返回已更新的素币兑换清单", func() {
  37 + listIdStr := strconv.FormatInt(listId, 10)
  38 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  39 + body := map[string]interface{}{
  40 + "exchangedSuMoney": 13,
  41 + "operator": 3242227175192320,
  42 + }
  43 + httpExpect.PUT("/cash-pool/activity/exchange-list/"+listIdStr).
  44 + WithJSON(body).
  45 + Expect().
  46 + Status(http.StatusOK).
  47 + JSON().
  48 + Object().
  49 + ContainsKey("code").ValueEqual("code", 0).
  50 + ContainsKey("msg").ValueEqual("msg", "ok").
  51 + ContainsKey("data").Value("data").Object().
  52 + ContainsKey("listId").ValueEqual("listId", listId)
  53 + })
  54 + })
  55 + })
  56 + AfterEach(func() {
  57 + _, err := pG.DB.Exec("DELETE FROM exchange_cash_person_lists WHERE true")
  58 + Expect(err).NotTo(HaveOccurred())
  59 + })
  60 +})
1 -/**  
2 - @author: stevechan  
3 - @date: 2020/12/10  
4 - @note:  
5 -**/  
6 -  
7 -package su_money