|
|
package unified_user_center
|
|
|
|
|
|
import (
|
|
|
"net/http"
|
|
|
|
|
|
"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 employeeId int64
|
|
|
BeforeEach(func() {
|
|
|
_, err := pG.DB.QueryOne(
|
|
|
pg.Scan(&employeeId),
|
|
|
"INSERT INTO employees (id, company_id, uid, employee_name, employee_account, employee_avatar_url, is_principal, su_money, status, permissions) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
|
|
|
1, 101, 2499036607974745088, "employee_name", "13799999999", "employee_avatar_url", false, 1000.00, 1, pg.Array([]int{1, 3}))
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
})
|
|
|
Describe("同步企业员工回调", func() {
|
|
|
Context("同步添加企业员工", func() {
|
|
|
It("添加成功", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"module": "employee",
|
|
|
"action": "add",
|
|
|
"data": `{
|
|
|
"id": 5040167991950442755,
|
|
|
"company_id": 1000,
|
|
|
"open_id": 0,
|
|
|
"name": "杨洲2",
|
|
|
"sex": 1,
|
|
|
"job_num": 59101419,
|
|
|
"phone": "15659781344",
|
|
|
"private_phone": "18050324007",
|
|
|
"email": "cczhang319@qq.com",
|
|
|
"extension_num": "0591-83845806",
|
|
|
"entry_time": "2020-02-10",
|
|
|
"workspace": "买买买",
|
|
|
"is_business": 1,
|
|
|
"status": 1,
|
|
|
"avatar": "http://suplus-business-admin-dev.fjmaimaimai.com//images/default_avatar.png",
|
|
|
"extra_text": "[]",
|
|
|
"remarks": "无",
|
|
|
"admin_type": 1,
|
|
|
"charge_status": 2,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null,
|
|
|
"user_departments": [
|
|
|
{
|
|
|
"id": 102,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 0,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 103,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 10,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 104,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 11,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 105,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 12,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
}
|
|
|
],
|
|
|
"user_positions": [
|
|
|
{
|
|
|
"id": 28,
|
|
|
"company_id": 1000,
|
|
|
"position_id": 10,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 29,
|
|
|
"company_id": 1000,
|
|
|
"position_id": 11,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 30,
|
|
|
"company_id": 1000,
|
|
|
"position_id": 12,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
}
|
|
|
],
|
|
|
"user_roles": [
|
|
|
{
|
|
|
"id": 32,
|
|
|
"role_id": 6,
|
|
|
"enable_status": 1,
|
|
|
"company_id": 1000,
|
|
|
"user_id": 5040167991950442755
|
|
|
},
|
|
|
{
|
|
|
"id": 33,
|
|
|
"role_id": 7,
|
|
|
"enable_status": 1,
|
|
|
"company_id": 1000,
|
|
|
"user_id": 5040167991950442755
|
|
|
}
|
|
|
]
|
|
|
}`,
|
|
|
}
|
|
|
httpExpect.POST("/api/business/index").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").ValueEqual("data", true)
|
|
|
})
|
|
|
})
|
|
|
Context("同步更新企业员工", func() {
|
|
|
It("更新成功", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"module": "employee",
|
|
|
"action": "edit",
|
|
|
"data": `{
|
|
|
"id": 2499036607974745088,
|
|
|
"company_id": 1000,
|
|
|
"open_id": 0,
|
|
|
"name": "杨洲2",
|
|
|
"sex": 1,
|
|
|
"job_num": 59101419,
|
|
|
"phone": "15659781344",
|
|
|
"private_phone": "18050324007",
|
|
|
"email": "cczhang319@qq.com",
|
|
|
"extension_num": "0591-83845806",
|
|
|
"entry_time": "2020-02-10",
|
|
|
"workspace": "买买买",
|
|
|
"is_business": 1,
|
|
|
"status": 1,
|
|
|
"avatar": "http://suplus-business-admin-dev.fjmaimaimai.com//images/default_avatar.png",
|
|
|
"extra_text": "[]",
|
|
|
"remarks": "无",
|
|
|
"admin_type": 1,
|
|
|
"charge_status": 2,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null,
|
|
|
"user_departments": [
|
|
|
{
|
|
|
"id": 102,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 0,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 103,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 10,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 104,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 11,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 105,
|
|
|
"company_id": 1000,
|
|
|
"department_id": 12,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
}
|
|
|
],
|
|
|
"user_positions": [
|
|
|
{
|
|
|
"id": 28,
|
|
|
"company_id": 1000,
|
|
|
"position_id": 10,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 29,
|
|
|
"company_id": 1000,
|
|
|
"position_id": 11,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
},
|
|
|
{
|
|
|
"id": 30,
|
|
|
"company_id": 1000,
|
|
|
"position_id": 12,
|
|
|
"user_id": 5040167991950442755,
|
|
|
"created_at": "2020-02-14 22:45:32",
|
|
|
"updated_at": "2020-02-14 22:45:32",
|
|
|
"deleted_at": null
|
|
|
}
|
|
|
],
|
|
|
"user_roles": [
|
|
|
{
|
|
|
"id": 32,
|
|
|
"role_id": 6,
|
|
|
"enable_status": 1,
|
|
|
"company_id": 1000,
|
|
|
"user_id": 5040167991950442755
|
|
|
},
|
|
|
{
|
|
|
"id": 33,
|
|
|
"role_id": 7,
|
|
|
"enable_status": 1,
|
|
|
"company_id": 1000,
|
|
|
"user_id": 5040167991950442755
|
|
|
}
|
|
|
]
|
|
|
}`,
|
|
|
}
|
|
|
httpExpect.POST("/api/business/index").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").ValueEqual("data", true)
|
|
|
})
|
|
|
})
|
|
|
Context("同步批量删除企业员工", func() {
|
|
|
It("删除成功", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"module": "employee",
|
|
|
"action": "batchDelete",
|
|
|
"data": ` {
|
|
|
"ids": [
|
|
|
2499036607974745088
|
|
|
]
|
|
|
}`,
|
|
|
}
|
|
|
httpExpect.POST("/api/business/index").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").ValueEqual("data", true)
|
|
|
})
|
|
|
})
|
|
|
Context("同步批量设置企业员工状态", func() {
|
|
|
It("设置成功", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"module": "employee",
|
|
|
"action": "batchForbid",
|
|
|
"data": ` {
|
|
|
"ids": [
|
|
|
2499036607974745088
|
|
|
],
|
|
|
"status": 2
|
|
|
}`,
|
|
|
}
|
|
|
httpExpect.POST("/api/business/index").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").ValueEqual("data", true)
|
|
|
})
|
|
|
})
|
|
|
Context("同步更换管理员", func() {
|
|
|
It("更换成功", func() {
|
|
|
httpExpect := httpexpect.New(GinkgoT(), server.URL)
|
|
|
body := map[string]interface{}{
|
|
|
"module": "company",
|
|
|
"action": "changeAdmin",
|
|
|
"data": ` {
|
|
|
"company_id": 101,
|
|
|
"phone": "13799999999"
|
|
|
}`,
|
|
|
}
|
|
|
httpExpect.POST("/api/business/index").
|
|
|
WithJSON(body).
|
|
|
Expect().
|
|
|
Status(http.StatusOK).
|
|
|
JSON().
|
|
|
Object().
|
|
|
ContainsKey("code").ValueEqual("code", 0).
|
|
|
ContainsKey("msg").ValueEqual("msg", "ok").
|
|
|
ContainsKey("data").ValueEqual("data", true)
|
|
|
})
|
|
|
})
|
|
|
})
|
|
|
AfterEach(func() {
|
|
|
_, err := pG.DB.Exec("DELETE FROM employees WHERE true")
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
})
|
|
|
}) |
...
|
...
|
|