Skip to content

Commit

Permalink
add BatchBindThirdMember
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanJey committed Sep 19, 2024
1 parent 6f4fbf7 commit cc3c023
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
8 changes: 8 additions & 0 deletions pkg/api_req/user_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,11 @@ type BatchEnableThirdMembersReq struct {
type ChangeMemberDeptWeightReq struct {
Weight int `json:"weight"`
}
type BatchBindThirdMemberReq struct {
Itmes []BatchBindThirdMemberItem `json:"itmes"`
PlatformId string `json:"platform_id"`
}
type BatchBindThirdMemberItem struct {
AccountId string `json:"account_id"`
UnionId string `json:"union_id"`
}
3 changes: 3 additions & 0 deletions pkg/consts/api_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const (

// GetCompanyMembersByStatusPath 根据状态获取企业成员列表
GetCompanyMembersByStatusPath = "/org/dev/v1/companies/%s/members/dept?status=%s&offset=%s&limit=%s"

///org/dev/v1/batch/companies/{company_id}/bind/thirdusers
BatchBindThirdMemberPath = "/org/dev/v1/batch/companies/%s/bind/thirdusers"
)

const (
Expand Down
26 changes: 19 additions & 7 deletions user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,36 @@ type ApiUser interface {
// ChangeCompanyMembersDept 调整企业账户的归属部门
ChangeCompanyMembersDept(operationID string, req api_req.ChangeCompanyMembersDeptReq) (*api_resp.CommonResp, error)
// GetDepartmentMembersPath 获取部门成员列表
GetDepartmentMembersPath(operationID string, deptId, offset, limit string) (*api_resp.GetDepartmentMembersResp, error)
GetDepartmentMembers(operationID string, deptId, offset, limit string) (*api_resp.GetDepartmentMembersResp, error)
// BatchDeleteCompanyMembersPath 批量删除用户
BatchDeleteCompanyMembers(operationID string, accounts []string) (*api_resp.CommonResp, error)
//BatchDisableThirdMembers
BatchDisableThirdMembers(operationID string, req api_req.BatchDisableThirdMembersReq) (*api_resp.CommonResp, error)
//BatchEnableThirdMembers
BatchEnableThirdMembers(operationID string, req api_req.BatchEnableThirdMembersReq) (*api_resp.CommonResp, error)
//ChangeMemberDeptWeightPath
ChangeMemberDeptWeightPath(operationID, deptId, accountId string, req api_req.ChangeMemberDeptWeightReq) (*api_resp.CommonResp, error)
GetCompanyMembersByStatusPath(operationID string, status, offset, limit string) (*api_resp.BatchGetCompanyMembersResp, error)
ChangeMemberDeptWeight(operationID, deptId, accountId string, req api_req.ChangeMemberDeptWeightReq) (*api_resp.CommonResp, error)
GetCompanyMembersByStatus(operationID string, status, offset, limit string) (*api_resp.BatchGetCompanyMembersResp, error)
//BatchBindThirdMemberPath
BatchBindThirdMember(operationID string, req api_req.BatchBindThirdMemberReq) (*api_resp.CommonResp, error)
}
type User struct {
addr string
sign *sign.Sign
companyId string
}

func (u *User) GetCompanyMembersByStatusPath(operationID string, status, offset, limit string) (*api_resp.BatchGetCompanyMembersResp, error) {
func (u *User) BatchBindThirdMember(operationID string, req api_req.BatchBindThirdMemberReq) (*api_resp.CommonResp, error) {
resp := api_resp.CommonResp{}
err := http_client.Post(operationID, fmt.Sprintf(u.addr+consts.BatchBindThirdMemberPath, u.companyId), req, &resp, *u.sign)
if err != nil {
log.Error(operationID, "BatchBindThirdMemberPath err ", err.Error())
return nil, err
}
return &resp, nil
}

func (u *User) GetCompanyMembersByStatus(operationID string, status, offset, limit string) (*api_resp.BatchGetCompanyMembersResp, error) {
resp := api_resp.BatchGetCompanyMembersResp{}
err := http_client.Get(operationID, fmt.Sprintf(u.addr+consts.GetCompanyMembersByStatusPath, u.companyId, status, offset, limit), nil, &resp, *u.sign)
if err != nil {
Expand All @@ -66,7 +78,7 @@ func (u *User) GetCompanyMembersByStatusPath(operationID string, status, offset,
return &resp, nil
}

func (u *User) ChangeMemberDeptWeightPath(operationID, deptId, accountId string, req api_req.ChangeMemberDeptWeightReq) (*api_resp.CommonResp, error) {
func (u *User) ChangeMemberDeptWeight(operationID, deptId, accountId string, req api_req.ChangeMemberDeptWeightReq) (*api_resp.CommonResp, error) {
resp := api_resp.CommonResp{}
err := http_client.Post(operationID, fmt.Sprintf(u.addr+consts.ChangeMemberDeptWeightPath, u.companyId, deptId, accountId), req, &resp, *u.sign)
if err != nil {
Expand All @@ -76,7 +88,7 @@ func (u *User) ChangeMemberDeptWeightPath(operationID, deptId, accountId string,
return &resp, nil
}

func (u *User) GetDepartmentMembersPath(operationID string, deptId, offset, limit string) (*api_resp.GetDepartmentMembersResp, error) {
func (u *User) GetDepartmentMembers(operationID string, deptId, offset, limit string) (*api_resp.GetDepartmentMembersResp, error) {
getMembersResp := api_resp.GetDepartmentMembersResp{}
err := http_client.Get(operationID, fmt.Sprintf(u.addr+consts.GetDepartmentMembersPath, u.companyId, deptId, offset, limit), nil, &getMembersResp, *u.sign)
if err != nil {
Expand Down Expand Up @@ -271,7 +283,7 @@ func (u *User) getDeptUsers(operationID string, deptId string) ([]api_resp.Membe
size := 1000
for {
offset := (page - 1) * size
list, err := u.GetDepartmentMembersPath(operationID, deptId, strconv.Itoa(offset), strconv.Itoa(size))
list, err := u.GetDepartmentMembers(operationID, deptId, strconv.Itoa(offset), strconv.Itoa(size))
if err != nil {
return deptList, err
}
Expand Down

0 comments on commit cc3c023

Please sign in to comment.