Skip to content

Commit

Permalink
feat(user): Added CreateUser/UpdateUser/UpdateUserPosition/`Del…
Browse files Browse the repository at this point in the history
…eteUser`/`BatchDeleteUser` (#33)

* 增加发送弹窗消息

* add 用户创建,更新,职务更新,删除,批量删除功能

* optimize: user

---------

Co-authored-by: val1nna <[email protected]>
  • Loading branch information
vaL1nna and val1nna committed Dec 29, 2023
1 parent c5e5bdc commit 57564c8
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 5 deletions.
10 changes: 5 additions & 5 deletions feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@

### 用户管理

- [ ] 创建用户
- [ ] 更新用户
- [ ] 更新用户部门职务信息
- [ ] 删除用户
- [ ] 批量删除用户
- [x] 创建用户 `user.go@CreateUser`
- [x] 更新用户 `user.go@UpdateUser`
- [x] 更新用户部门职务信息 `user.go@UpdateUserPosition`
- [x] 删除用户 `user.go@DeleteUser`
- [x] 批量删除用户 `user.go@BatchDeleteUser`
- [x] 获取用户信息 `user.go@GetUser`
- [x] 获取部门用户详细信息 `user.go@GetDeptUserList`
- [x] 获取部门用户 `user.go@GetDeptUserSimpleList`
Expand Down
110 changes: 110 additions & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@ import (
"strconv"
)

type CreateUserRequest struct {
UserId string `json:"userId"`
Name string `json:"name"`
Gender int `json:"gender"`
Mobile string `json:"mobile"`
Phone string `json:"phone"`
Email string `json:"email"`
Dept []int `json:"dept"`
EnableState EnableState `json:"enableState"`
ShortCode string `json:"shortCode"`
}

type UpdateUserRequest struct {
UserId string `json:"userId"`
Name string `json:"name"`
Gender int `json:"gender"`
Mobile string `json:"mobile"`
Phone string `json:"phone"`
Email string `json:"email"`
Dept []int `json:"dept"`
ShortCode string `json:"shortCode"`
}

type UpdateUserPositionRequest struct {
UserId string `json:"userId"`
DeptId int `json:"deptId"`
Position string `json:"position"`
Weight int `json:"weight"`
SortId int `json:"sortId"`
}

type BatchDeleteUserRequest struct {
DelList []string `json:"delList"`
}

type DeptDetail struct {
DeptId int `json:"deptId"`
Position string `json:"position"`
Expand Down Expand Up @@ -48,6 +83,81 @@ type UpdateUserEnableStateRequest struct {
EnableState EnableState `json:"enableState"`
}

func (c *Client) CreateUser(ctx context.Context, request CreateUserRequest) (response Response, err error) {
req, err := c.newRequest(ctx, http.MethodPost, "/cgi/user/create",
withRequestAccessToken(),
withRequestEncrypt(),
withRequestBody(request),
)

if err != nil {
return
}

err = c.sendRequest(req, &response)
return
}

func (c *Client) UpdateUser(ctx context.Context, request UpdateUserRequest) (response Response, err error) {
req, err := c.newRequest(ctx, http.MethodPost, "/cgi/user/update",
withRequestAccessToken(),
withRequestEncrypt(),
withRequestBody(request),
)

if err != nil {
return
}

err = c.sendRequest(req, &response)
return
}

func (c *Client) UpdateUserPosition(ctx context.Context, request UpdateUserPositionRequest) (response Response, err error) {
req, err := c.newRequest(ctx, http.MethodPost, "/cgi/user/positionupdate",
withRequestAccessToken(),
withRequestEncrypt(),
withRequestBody(request),
)

if err != nil {
return
}

err = c.sendRequest(req, &response)
return
}

func (c *Client) DeleteUser(ctx context.Context, userId string) (response Response, err error) {
req, err := c.newRequest(ctx, http.MethodPost, "/cgi/user/delete",
withRequestAccessToken(),
withRequestEncrypt(),
withRequestParamsKV("userId", userId),
)

if err != nil {
return
}

err = c.sendRequest(req, &response)
return
}

func (c *Client) BatchDeleteUser(ctx context.Context, request BatchDeleteUserRequest) (response Response, err error) {
req, err := c.newRequest(ctx, http.MethodPost, "/cgi/user/batchdelete",
withRequestAccessToken(),
withRequestEncrypt(),
withRequestBody(request),
)

if err != nil {
return
}

err = c.sendRequest(req, &response)
return
}

func (c *Client) GetUser(ctx context.Context, userId string) (response UserResponse, err error) {
req, err := c.newRequest(ctx, http.MethodGet, "/cgi/user/get",
withRequestAccessToken(),
Expand Down

0 comments on commit 57564c8

Please sign in to comment.