|
...
|
...
|
@@ -11,13 +11,25 @@ import ( |
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("更新", func() {
|
|
|
|
return
|
|
|
|
var userId int64
|
|
|
|
BeforeEach(func() {
|
|
|
|
_, err := pG.DB.QueryOne(
|
|
|
|
var err error
|
|
|
|
_, err = pG.DB.QueryOne(
|
|
|
|
pg.Scan(&userId),
|
|
|
|
"INSERT INTO users (user_id, company_id, user_base_id, user_type, user_code, organization_id, department_id, user_info, user_org, user_role, favorite_menus, cooperation_info, enable_status, ext, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING user_id",
|
|
|
|
"testUserId", "testCompanyId", "testUserBaseId", "testUserType", "testUserCode", "testOrganizationId", "testDepartmentId", "testUserInfo", "testUserOrg", "testUserRole", "testFavoriteMenus", "testCooperationInfo", "testEnableStatus", "testExt", "testCreatedAt", "testUpdatedAt")
|
|
|
|
"INSERT INTO \"users\".\"user_base\"(\"user_base_id\", \"user_info\", \"account\", \"password\", \"im\", \"related_user\", \"status\", \"created_at\", \"updated_at\") VALUES (999, '{\"phone\": \"phone\", \"userName\": \"string\"}', 'phone', 'string', '{\"accid\": \"\", \"imToken\": \"\", \"csAccountId\": \"\"}', '{999}', 1, '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08') RETURNING user_base_id;",
|
|
|
|
)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
_, err = pG.DB.QueryOne(
|
|
|
|
pg.Scan(&userId),
|
|
|
|
"INSERT INTO \"users\".\"user\"(\"user_id\", \"company_id\", \"user_base_id\", \"user_type\", \"user_code\", \"organization_id\", \"department_id\", \"user_org\", \"user_role\", \"favorite_menus\", \"cooperation_info\", \"enable_status\", \"ext\", \"created_at\", \"updated_at\") VALUES (999, 5, 999, 1025, 'ADMIN01', 5, 5, '[{\"orgId\": 5, \"orgName\": \"string1\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"deletedAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[{\"ext\": {\"orgName\": \"string1\"}, \"roleId\": 5, \"roleName\": \"企业管理员\", \"createdAt\": \"0001-01-01T00:00:00Z\", \"updatedAt\": \"0001-01-01T00:00:00Z\"}]', '[]', '{\"cooperationCompany\": \"\", \"cooperationDeadline\": \"0001-01-01T00:00:00Z\"}', 1, '{\"phone\": \"18860183031\", \"depName\": \"string1\", \"orgName\": \"string1\"}', '2021-07-24 10:16:17.680805+08', '2021-07-24 10:16:17.680805+08');\n",
|
|
|
|
)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
|
|
|
|
_, err = pG.DB.QueryOne(
|
|
|
|
pg.Scan(&userId),
|
|
|
|
"INSERT INTO users.org (org_id,company_id,created_at,updated_at,deleted_at,org_code,org_name,ext,org_status,is_org,parent_id,parent_path) VALUES (999,999,'2021-07-26 08:06:29.3101584+00:00:00','2021-07-26 08:06:29.3101584+00:00:00','0001-01-01 00:00:00+00:00:00','ENTERPRISE01','string1','{}',1,1,0,'');",
|
|
|
|
)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
Describe("提交数据更新", func() {
|
|
...
|
...
|
@@ -25,19 +37,19 @@ var _ = Describe("更新", func() { |
|
|
|
It("返回更新后的用户数据", func() {
|
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
|
body := map[string]interface{}{
|
|
|
|
"organizationId": "int64",
|
|
|
|
"departmentId": "int64",
|
|
|
|
"userOrg": "array",
|
|
|
|
"userRole": "array",
|
|
|
|
"cooperationCompany": "string",
|
|
|
|
"cooperationDeadline": "datetime",
|
|
|
|
"enableStatus": "int",
|
|
|
|
"userName": "string",
|
|
|
|
"phone": "string",
|
|
|
|
"avatar": "string",
|
|
|
|
"email": "string",
|
|
|
|
"organizationId": 999,
|
|
|
|
"departmentId": 999,
|
|
|
|
//"userOrg": "array",
|
|
|
|
//"userRole": "array",
|
|
|
|
"cooperationCompany": "string",
|
|
|
|
//"cooperationDeadline": "datetime",
|
|
|
|
"enableStatus": 1,
|
|
|
|
"userName": "string",
|
|
|
|
"phone": "phone",
|
|
|
|
"avatar": "string",
|
|
|
|
"email": "string",
|
|
|
|
}
|
|
|
|
httpExpect.PUT("/user/{userId}").
|
|
|
|
httpExpect.PUT("/user/999").
|
|
|
|
WithJSON(body).
|
|
|
|
Expect().
|
|
|
|
Status(http.StatusOK).
|
|
...
|
...
|
@@ -51,7 +63,11 @@ var _ = Describe("更新", func() { |
|
|
|
})
|
|
|
|
})
|
|
|
|
AfterEach(func() {
|
|
|
|
_, err := pG.DB.Exec("DELETE FROM users WHERE true")
|
|
|
|
_, err := pG.DB.Exec("DELETE FROM users.user_base WHERE user_base_id = 999")
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
_, err = pG.DB.Exec(`DELETE FROM users."user" WHERE user_id = 999`)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
_, err = pG.DB.Exec(`DELETE FROM users."org" WHERE org_id = 999`)
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
}) |
...
|
...
|
|