正在显示
10 个修改的文件
包含
415 行增加
和
2 行删除
| 1 | +package controllers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "encoding/json" | ||
| 5 | + | ||
| 6 | + "github.com/astaxie/beego" | ||
| 7 | + "github.com/linmadan/egglib-go/web/beego/utils" | ||
| 8 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/command" | ||
| 9 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/query" | ||
| 10 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/columnSetting/service" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type ColumnSettingController struct { | ||
| 14 | + beego.Controller | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +func (controller *ColumnSettingController) CreateColumnSetting() { | ||
| 18 | + columnSettingService := service.NewColumnSettingService(nil) | ||
| 19 | + createColumnSettingCommand := &command.CreateColumnSettingCommand{} | ||
| 20 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createColumnSettingCommand) | ||
| 21 | + data, err := columnSettingService.CreateColumnSetting(createColumnSettingCommand) | ||
| 22 | + var response utils.JsonResponse | ||
| 23 | + if err != nil { | ||
| 24 | + response = utils.ResponseError(controller.Ctx, err) | ||
| 25 | + } else { | ||
| 26 | + response = utils.ResponseData(controller.Ctx, data) | ||
| 27 | + } | ||
| 28 | + controller.Data["json"] = response | ||
| 29 | + controller.ServeJSON() | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +func (controller *ColumnSettingController) UpdateColumnSetting() { | ||
| 33 | + columnSettingService := service.NewColumnSettingService(nil) | ||
| 34 | + updateColumnSettingCommand := &command.UpdateColumnSettingCommand{} | ||
| 35 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), updateColumnSettingCommand) | ||
| 36 | + columnSettingId, _ := controller.GetInt64(":columnSettingId") | ||
| 37 | + updateColumnSettingCommand.ColumnSettingId = columnSettingId | ||
| 38 | + data, err := columnSettingService.UpdateColumnSetting(updateColumnSettingCommand) | ||
| 39 | + var response utils.JsonResponse | ||
| 40 | + if err != nil { | ||
| 41 | + response = utils.ResponseError(controller.Ctx, err) | ||
| 42 | + } else { | ||
| 43 | + response = utils.ResponseData(controller.Ctx, data) | ||
| 44 | + } | ||
| 45 | + controller.Data["json"] = response | ||
| 46 | + controller.ServeJSON() | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +func (controller *ColumnSettingController) GetColumnSetting() { | ||
| 50 | + columnSettingService := service.NewColumnSettingService(nil) | ||
| 51 | + getColumnSettingQuery := &query.GetColumnSettingQuery{} | ||
| 52 | + columnSettingId, _ := controller.GetInt64(":columnSettingId") | ||
| 53 | + getColumnSettingQuery.ColumnSettingId = columnSettingId | ||
| 54 | + data, err := columnSettingService.GetColumnSetting(getColumnSettingQuery) | ||
| 55 | + var response utils.JsonResponse | ||
| 56 | + if err != nil { | ||
| 57 | + response = utils.ResponseError(controller.Ctx, err) | ||
| 58 | + } else { | ||
| 59 | + response = utils.ResponseData(controller.Ctx, data) | ||
| 60 | + } | ||
| 61 | + controller.Data["json"] = response | ||
| 62 | + controller.ServeJSON() | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +func (controller *ColumnSettingController) RemoveColumnSetting() { | ||
| 66 | + columnSettingService := service.NewColumnSettingService(nil) | ||
| 67 | + removeColumnSettingCommand := &command.RemoveColumnSettingCommand{} | ||
| 68 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), removeColumnSettingCommand) | ||
| 69 | + columnSettingId, _ := controller.GetInt64(":columnSettingId") | ||
| 70 | + removeColumnSettingCommand.ColumnSettingId = columnSettingId | ||
| 71 | + data, err := columnSettingService.RemoveColumnSetting(removeColumnSettingCommand) | ||
| 72 | + var response utils.JsonResponse | ||
| 73 | + if err != nil { | ||
| 74 | + response = utils.ResponseError(controller.Ctx, err) | ||
| 75 | + } else { | ||
| 76 | + response = utils.ResponseData(controller.Ctx, data) | ||
| 77 | + } | ||
| 78 | + controller.Data["json"] = response | ||
| 79 | + controller.ServeJSON() | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +func (controller *ColumnSettingController) ResetColumn() { | ||
| 83 | + columnSettingService := service.NewColumnSettingService(nil) | ||
| 84 | + resetColumnCommand := &command.ResetColumnCommand{} | ||
| 85 | + json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), resetColumnCommand) | ||
| 86 | + data, err := columnSettingService.ResetColumn(resetColumnCommand) | ||
| 87 | + var response utils.JsonResponse | ||
| 88 | + if err != nil { | ||
| 89 | + response = utils.ResponseError(controller.Ctx, err) | ||
| 90 | + } else { | ||
| 91 | + response = utils.ResponseData(controller.Ctx, data) | ||
| 92 | + } | ||
| 93 | + controller.Data["json"] = response | ||
| 94 | + controller.ServeJSON() | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +func (controller *ColumnSettingController) ListColumnSetting() { | ||
| 98 | + columnSettingService := service.NewColumnSettingService(nil) | ||
| 99 | + listColumnSettingQuery := &query.ListColumnSettingQuery{} | ||
| 100 | + offset, _ := controller.GetInt("offset") | ||
| 101 | + listColumnSettingQuery.Offset = offset | ||
| 102 | + limit, _ := controller.GetInt("limit") | ||
| 103 | + listColumnSettingQuery.Limit = limit | ||
| 104 | + data, err := columnSettingService.ListColumnSetting(listColumnSettingQuery) | ||
| 105 | + var response utils.JsonResponse | ||
| 106 | + if err != nil { | ||
| 107 | + response = utils.ResponseError(controller.Ctx, err) | ||
| 108 | + } else { | ||
| 109 | + response = utils.ResponseData(controller.Ctx, data) | ||
| 110 | + } | ||
| 111 | + controller.Data["json"] = response | ||
| 112 | + controller.ServeJSON() | ||
| 113 | +} |
| 1 | +package routers | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/beego/controllers" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +func init() { | ||
| 9 | + beego.Router("/column-settings/", &controllers.ColumnSettingController{}, "Post:CreateColumnSetting") | ||
| 10 | + beego.Router("/column-settings/:columnSettingId", &controllers.ColumnSettingController{}, "Put:UpdateColumnSetting") | ||
| 11 | + beego.Router("/column-settings/:columnSettingId", &controllers.ColumnSettingController{}, "Get:GetColumnSetting") | ||
| 12 | + beego.Router("/column-settings/:columnSettingId", &controllers.ColumnSettingController{}, "Delete:RemoveColumnSetting") | ||
| 13 | + beego.Router("/column-settings/", &controllers.ColumnSettingController{}, "Post:ResetColumn") | ||
| 14 | + beego.Router("/column-settings/", &controllers.ColumnSettingController{}, "Get:ListColumnSetting") | ||
| 15 | +} |
| @@ -41,8 +41,11 @@ func init() { | @@ -41,8 +41,11 @@ func init() { | ||
| 41 | beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), // 删除实际订单 | 41 | beego.NSRouter("/actual/del", &controllers.OrderInfoController{}, "POST:RemoveOrderReal"), // 删除实际订单 |
| 42 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), // 新增实际订单 | 42 | beego.NSRouter("/actual/update", &controllers.OrderInfoController{}, "POST:UpdateOrderReal"), // 新增实际订单 |
| 43 | beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), | 43 | beego.NSRouter("/actual/close", &controllers.OrderInfoController{}, "POST:OrderDisable"), |
| 44 | - beego.NSRouter("/fileImportTemplate", &controllers.OrderInfoController{}, "POST:DownloadTemplate"), // 下载导入模板 | ||
| 45 | - beego.NSRouter("/fileImport", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel"), // 导入订单数据 | 44 | + beego.NSRouter("/fileImportTemplate", &controllers.OrderInfoController{}, "POST:DownloadTemplate"), // 下载导入模板 |
| 45 | + beego.NSRouter("/fileImport", &controllers.OrderInfoController{}, "POST:ImportOrderFromExcel"), // 导入订单数据 | ||
| 46 | + beego.NSRouter("/actual/listColumn", &controllers.ColumnSettingController{}, "POST:ListColumnSetting"), // 返回栏目设置列表 | ||
| 47 | + beego.NSRouter("/actual/updateColumn", &controllers.ColumnSettingController{}, "POST:UpdateColumnSetting"), // 更新栏目设置 | ||
| 48 | + beego.NSRouter("/actual/resetColumn", &controllers.ColumnSettingController{}, "Post:ResetColumn"), // 重置栏目设置 | ||
| 46 | ), | 49 | ), |
| 47 | beego.NSNamespace("/common", | 50 | beego.NSNamespace("/common", |
| 48 | beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"), | 51 | beego.NSRouter("/partner", &controllers.CommonController{}, "POST:GetPartnerList"), |
| 1 | +package column_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + "net/http/httptest" | ||
| 6 | + "testing" | ||
| 7 | + | ||
| 8 | + "github.com/astaxie/beego" | ||
| 9 | + . "github.com/onsi/ginkgo" | ||
| 10 | + . "github.com/onsi/gomega" | ||
| 11 | + _ "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg" | ||
| 12 | + _ "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/beego" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +func TestColumnSetting(t *testing.T) { | ||
| 16 | + RegisterFailHandler(Fail) | ||
| 17 | + RunSpecs(t, "Beego Port ColumnSetting Correlations Test Case Suite") | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +var handler http.Handler | ||
| 21 | +var server *httptest.Server | ||
| 22 | + | ||
| 23 | +var _ = BeforeSuite(func() { | ||
| 24 | + handler = beego.BeeApp.Handlers | ||
| 25 | + server = httptest.NewServer(handler) | ||
| 26 | +}) | ||
| 27 | + | ||
| 28 | +var _ = AfterSuite(func() { | ||
| 29 | + server.Close() | ||
| 30 | +}) |
| 1 | +package column_setting | ||
| 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/mmm-go/partnermg/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 | + "description": "string", | ||
| 19 | + "userName": "string", | ||
| 20 | + } | ||
| 21 | + httpExpect.POST("/column-settings/"). | ||
| 22 | + WithJSON(body). | ||
| 23 | + Expect(). | ||
| 24 | + Status(http.StatusOK). | ||
| 25 | + JSON(). | ||
| 26 | + Object(). | ||
| 27 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 28 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 29 | + ContainsKey("data").Value("data").Object(). | ||
| 30 | + ContainsKey("id").ValueNotEqual("id", BeZero()) | ||
| 31 | + }) | ||
| 32 | + }) | ||
| 33 | + }) | ||
| 34 | + AfterEach(func() { | ||
| 35 | + _, err := pG.DB.Exec("DELETE FROM column_settings WHERE true") | ||
| 36 | + Expect(err).NotTo(HaveOccurred()) | ||
| 37 | + }) | ||
| 38 | +}) |
| 1 | +package column_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + "github.com/go-pg/pg" | ||
| 8 | + . "github.com/onsi/ginkgo" | ||
| 9 | + . "github.com/onsi/gomega" | ||
| 10 | + pG "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +var _ = Describe("返回栏目设置增删改查", func() { | ||
| 14 | + var column_settingId int64 | ||
| 15 | + BeforeEach(func() { | ||
| 16 | + _, err := pG.DB.QueryOne( | ||
| 17 | + pg.Scan(&column_settingId), | ||
| 18 | + "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id", | ||
| 19 | + "testColumnSettingId", "testCompanyId", "testCreatedAt", "testDescription", "testKey", "testUid", "testUpdatedAt", "testUserName", "testValue") | ||
| 20 | + Expect(err).NotTo(HaveOccurred()) | ||
| 21 | + }) | ||
| 22 | + Describe("根据column_settingId参数返回栏目设置", func() { | ||
| 23 | + Context("传入有效的column_settingId", func() { | ||
| 24 | + It("返回栏目设置数据", func() { | ||
| 25 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 26 | + httpExpect.GET("/column-settings/{columnSettingId}"). | ||
| 27 | + Expect(). | ||
| 28 | + Status(http.StatusOK). | ||
| 29 | + JSON(). | ||
| 30 | + Object(). | ||
| 31 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 32 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 33 | + ContainsKey("data").Value("data").Object() | ||
| 34 | + }) | ||
| 35 | + }) | ||
| 36 | + }) | ||
| 37 | + AfterEach(func() { | ||
| 38 | + _, err := pG.DB.Exec("DELETE FROM column_settings WHERE true") | ||
| 39 | + Expect(err).NotTo(HaveOccurred()) | ||
| 40 | + }) | ||
| 41 | +}) |
| 1 | +package column_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + "github.com/go-pg/pg" | ||
| 8 | + . "github.com/onsi/ginkgo" | ||
| 9 | + . "github.com/onsi/gomega" | ||
| 10 | + pG "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +var _ = Describe("返回栏目设置增删改查列表", func() { | ||
| 14 | + var column_settingId int64 | ||
| 15 | + BeforeEach(func() { | ||
| 16 | + _, err := pG.DB.QueryOne( | ||
| 17 | + pg.Scan(&column_settingId), | ||
| 18 | + "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id", | ||
| 19 | + "testColumnSettingId", "testCompanyId", "testCreatedAt", "testDescription", "testKey", "testUid", "testUpdatedAt", "testUserName", "testValue") | ||
| 20 | + Expect(err).NotTo(HaveOccurred()) | ||
| 21 | + }) | ||
| 22 | + Describe("根据参数返回栏目设置列表", func() { | ||
| 23 | + Context("传入有效的参数", func() { | ||
| 24 | + It("返回栏目设置数据列表", func() { | ||
| 25 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 26 | + httpExpect.GET("/column-settings/"). | ||
| 27 | + WithQuery("offset", "int"). | ||
| 28 | + WithQuery("limit", "int"). | ||
| 29 | + Expect(). | ||
| 30 | + Status(http.StatusOK). | ||
| 31 | + JSON(). | ||
| 32 | + Object(). | ||
| 33 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 34 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 35 | + ContainsKey("data").Value("data").Object(). | ||
| 36 | + ContainsKey("count").ValueEqual("count", 1). | ||
| 37 | + ContainsKey("column_settings").Value("column_settings").Array() | ||
| 38 | + }) | ||
| 39 | + }) | ||
| 40 | + }) | ||
| 41 | + AfterEach(func() { | ||
| 42 | + _, err := pG.DB.Exec("DELETE FROM column_settings WHERE true") | ||
| 43 | + Expect(err).NotTo(HaveOccurred()) | ||
| 44 | + }) | ||
| 45 | +}) |
| 1 | +package column_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + "github.com/go-pg/pg" | ||
| 8 | + . "github.com/onsi/ginkgo" | ||
| 9 | + . "github.com/onsi/gomega" | ||
| 10 | + pG "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +var _ = Describe("移除栏目设置增删改查", func() { | ||
| 14 | + var column_settingId int64 | ||
| 15 | + BeforeEach(func() { | ||
| 16 | + _, err := pG.DB.QueryOne( | ||
| 17 | + pg.Scan(&column_settingId), | ||
| 18 | + "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id", | ||
| 19 | + "testColumnSettingId", "testCompanyId", "testCreatedAt", "testDescription", "testKey", "testUid", "testUpdatedAt", "testUserName", "testValue") | ||
| 20 | + Expect(err).NotTo(HaveOccurred()) | ||
| 21 | + }) | ||
| 22 | + Describe("根据参数移除栏目设置增删改查", func() { | ||
| 23 | + Context("传入有效的column_settingId", func() { | ||
| 24 | + It("返回被移除栏目设置的数据", func() { | ||
| 25 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 26 | + httpExpect.DELETE("/column-settings/{columnSettingId}"). | ||
| 27 | + Expect(). | ||
| 28 | + Status(http.StatusOK). | ||
| 29 | + JSON(). | ||
| 30 | + Object(). | ||
| 31 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 32 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 33 | + ContainsKey("data").Value("data").Object() | ||
| 34 | + }) | ||
| 35 | + }) | ||
| 36 | + }) | ||
| 37 | + AfterEach(func() { | ||
| 38 | + _, err := pG.DB.Exec("DELETE FROM column_settings WHERE true") | ||
| 39 | + Expect(err).NotTo(HaveOccurred()) | ||
| 40 | + }) | ||
| 41 | +}) |
| 1 | +package column_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + "github.com/go-pg/pg" | ||
| 8 | + . "github.com/onsi/ginkgo" | ||
| 9 | + . "github.com/onsi/gomega" | ||
| 10 | + pG "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +var _ = Describe("重置栏目设置", func() { | ||
| 14 | + var column_settingId int64 | ||
| 15 | + BeforeEach(func() { | ||
| 16 | + _, err := pG.DB.QueryOne( | ||
| 17 | + pg.Scan(&column_settingId), | ||
| 18 | + "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id", | ||
| 19 | + "testColumnSettingId", "testCompanyId", "testCreatedAt", "testDescription", "testKey", "testUid", "testUpdatedAt", "testUserName", "testValue") | ||
| 20 | + Expect(err).NotTo(HaveOccurred()) | ||
| 21 | + }) | ||
| 22 | + Describe("重置栏目设置", func() { | ||
| 23 | + Context("", func() { | ||
| 24 | + It("", func() { | ||
| 25 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 26 | + body := map[string]interface{}{} | ||
| 27 | + httpExpect.POST("/column-settings/"). | ||
| 28 | + WithJSON(body). | ||
| 29 | + Expect(). | ||
| 30 | + Status(http.StatusOK). | ||
| 31 | + JSON(). | ||
| 32 | + Object(). | ||
| 33 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 34 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 35 | + ContainsKey("data").Value("data").Object() | ||
| 36 | + }) | ||
| 37 | + }) | ||
| 38 | + }) | ||
| 39 | + AfterEach(func() { | ||
| 40 | + _, err := pG.DB.Exec("DELETE FROM column_settings WHERE true") | ||
| 41 | + Expect(err).NotTo(HaveOccurred()) | ||
| 42 | + }) | ||
| 43 | +}) |
| 1 | +package column_setting | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/gavv/httpexpect" | ||
| 7 | + "github.com/go-pg/pg" | ||
| 8 | + . "github.com/onsi/ginkgo" | ||
| 9 | + . "github.com/onsi/gomega" | ||
| 10 | + pG "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +var _ = Describe("更新栏目设置增删改查", func() { | ||
| 14 | + var column_settingId int64 | ||
| 15 | + BeforeEach(func() { | ||
| 16 | + _, err := pG.DB.QueryOne( | ||
| 17 | + pg.Scan(&column_settingId), | ||
| 18 | + "INSERT INTO column_settings (column_setting_id, company_id, created_at, description, key, uid, updated_at, user_name, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id", | ||
| 19 | + "testColumnSettingId", "testCompanyId", "testCreatedAt", "testDescription", "testKey", "testUid", "testUpdatedAt", "testUserName", "testValue") | ||
| 20 | + Expect(err).NotTo(HaveOccurred()) | ||
| 21 | + }) | ||
| 22 | + Describe("提交数据更新栏目设置增删改查", func() { | ||
| 23 | + Context("提交正确的栏目设置数据", func() { | ||
| 24 | + It("返回更新后的栏目设置数据", func() { | ||
| 25 | + httpExpect := httpexpect.New(GinkgoT(), server.URL) | ||
| 26 | + body := map[string]interface{}{} | ||
| 27 | + httpExpect.PUT("/column-settings/{columnSettingId}"). | ||
| 28 | + WithJSON(body). | ||
| 29 | + Expect(). | ||
| 30 | + Status(http.StatusOK). | ||
| 31 | + JSON(). | ||
| 32 | + Object(). | ||
| 33 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 34 | + ContainsKey("msg").ValueEqual("msg", "ok"). | ||
| 35 | + ContainsKey("data").Value("data").Object(). | ||
| 36 | + ContainsKey("id").ValueEqual("id", column_settingId) | ||
| 37 | + }) | ||
| 38 | + }) | ||
| 39 | + }) | ||
| 40 | + AfterEach(func() { | ||
| 41 | + _, err := pG.DB.Exec("DELETE FROM column_settings WHERE true") | ||
| 42 | + Expect(err).NotTo(HaveOccurred()) | ||
| 43 | + }) | ||
| 44 | +}) |
-
请 注册 或 登录 后发表评论