作者 陈志颖

合并分支 'test' 到 'master'

Test



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