Skip to content

Commit bfd3704

Browse files
committed
feat: refactor user management
1 parent 20aad98 commit bfd3704

File tree

20 files changed

+991
-1849
lines changed

20 files changed

+991
-1849
lines changed

.github/workflows/api.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ jobs:
3434
run: |
3535
echo "install task"
3636
go install github.com/go-task/task/v3/cmd/task@latest
37-
- name: build api
38-
run: |
39-
task swag
40-
- name: Build and push docs api
41-
uses: docker/build-push-action@v6
42-
with:
43-
platforms: linux/amd64,linux/arm64
44-
pull: true
45-
push: true
46-
tags: ttl.sh/easysoft/zentaoapi
47-
context: docs
37+
# - name: build api
38+
# run: |
39+
# task swag
40+
# - name: Build and push docs api
41+
# uses: docker/build-push-action@v6
42+
# with:
43+
# platforms: linux/amd64,linux/arm64
44+
# pull: true
45+
# push: true
46+
# tags: ttl.sh/easysoft/zentaoapi
47+
# context: docs

Taskfile.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ tasks:
1212
- go install github.com/google/addlicense@latest
1313
- ./gencopyright.sh
1414

15-
tools:
16-
run: once
17-
cmds:
18-
- go install github.com/go-swagger/go-swagger/cmd/swagger@latest
19-
- go install github.com/swaggo/swag/cmd/swag@latest
20-
2115
gomod:
2216
desc: update go mod
2317
cmds:
@@ -32,7 +26,7 @@ tasks:
3226
golint:
3327
desc: lint package
3428
cmds:
35-
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
29+
- command -v golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0
3630
- golangci-lint run -v ./...
3731

3832
coverage:
@@ -66,13 +60,6 @@ tasks:
6660
cmds:
6761
- docker compose -f hack/docker-compose.yml up -d
6862

69-
swag:
70-
desc: generate swagger
71-
run: once
72-
cmds:
73-
- task: tools
74-
- swag init -d zentao -g zentao.go --packageName main
75-
7663
clean:
7764
desc: clean
7865
cmds:
@@ -88,7 +75,6 @@ tasks:
8875

8976
fmt:
9077
cmds:
91-
- task: swag
9278
- task: gencopyright
9379
- task: lint
9480

buildin/README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
11
# buildin
22

3-
> Deprecated: please use zentao.NewBasicAuthClient instead
3+
## New Feature: User API
4+
5+
The buildin package now supports fetching user tasks, bugs, and stories.
6+
7+
### Quick Start
8+
9+
```go
10+
import "github.com/easysoft/go-zentao/v21/buildin"
11+
12+
// Create client with username and password
13+
client, err := buildin.NewBasicAuthClient(
14+
"your_username",
15+
"your_password",
16+
buildin.WithBaseURL("https://your-zentao-url.com"),
17+
)
18+
if err != nil {
19+
log.Fatal(err)
20+
}
21+
22+
// Get all user data (tasks + bugs + stories)
23+
result, _, err := client.GetUserTasksBugsStories()
24+
if err != nil {
25+
log.Fatal(err)
26+
}
27+
28+
// Display user info
29+
fmt.Printf("User: %s (%s)\n", result.Profile.Realname, result.Profile.Account)
30+
31+
// Get counts
32+
taskCount, bugCount, storyCount := result.GetItemCounts()
33+
fmt.Printf("Tasks: %d, Bugs: %d, Stories: %d\n", taskCount, bugCount, storyCount)
34+
35+
// Get only specific types
36+
tasks, _, err := client.GetUserTasks() // Tasks only
37+
bugs, _, err := client.GetUserBugs() // Bugs only
38+
stories, _, err := client.GetUserStories() // Stories only
39+
```
40+
41+
### Features
42+
43+
- ✅ Get user's tasks, bugs, and stories
44+
- ✅ Support for fetching individual types
45+
- ✅ Built-in filtering methods (by status)
46+
- ✅ Statistics and analysis methods
47+
- ✅ Today's completed items query
48+
49+
See example at `./example/buildin-user/main.go`
450

551
## Usage
652

buildin/login.go

Lines changed: 52 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -47,52 +47,52 @@ type LoginRespData struct {
4747
}
4848

4949
type LoginUserData struct {
50-
ID string `json:"id"`
51-
Company string `json:"company"`
52-
Type string `json:"type"`
53-
Dept string `json:"dept"`
54-
Account string `json:"account"`
55-
Role string `json:"role"`
56-
Realname string `json:"realname"`
57-
Pinyin string `json:"pinyin"`
58-
Nickname string `json:"nickname"`
59-
Commiter string `json:"commiter"`
60-
Avatar string `json:"avatar"`
61-
Birthday string `json:"birthday"`
62-
Gender string `json:"gender"`
63-
Email string `json:"email"`
64-
Skype string `json:"skype"`
65-
Qq string `json:"qq"`
66-
Mobile string `json:"mobile"`
67-
Phone string `json:"phone"`
68-
Weixin string `json:"weixin"`
69-
Dingding string `json:"dingding"`
70-
Slack string `json:"slack"`
71-
Whatsapp string `json:"whatsapp"`
72-
Address string `json:"address"`
73-
Zipcode string `json:"zipcode"`
74-
Nature string `json:"nature"`
75-
Analysis string `json:"analysis"`
76-
Strategy string `json:"strategy"`
77-
Join string `json:"join"`
78-
Visits string `json:"visits"`
79-
Visions string `json:"visions"`
80-
IP string `json:"ip"`
81-
Last string `json:"last"`
82-
Fails string `json:"fails"`
83-
Locked string `json:"locked"`
84-
Feedback string `json:"feedback"`
85-
Ranzhi string `json:"ranzhi"`
86-
Ldap string `json:"ldap"`
87-
Score string `json:"score"`
88-
ScoreLevel string `json:"scoreLevel"`
89-
ResetToken string `json:"resetToken"`
90-
ClientStatus string `json:"clientStatus"`
91-
ClientLang string `json:"clientLang"`
92-
LastTime string `json:"lastTime"`
93-
Admin bool `json:"admin"`
94-
ModifyPassword bool `json:"modifyPassword"`
95-
Rights LoginUserRights `json:"rights"`
50+
ID int `json:"id"`
51+
Company string `json:"company"`
52+
Type string `json:"type"`
53+
Dept int `json:"dept"`
54+
Account string `json:"account"`
55+
Role string `json:"role"`
56+
Realname string `json:"realname"`
57+
Pinyin string `json:"pinyin"`
58+
Nickname string `json:"nickname"`
59+
Commiter string `json:"commiter"`
60+
Avatar string `json:"avatar"`
61+
Birthday string `json:"birthday"`
62+
Gender string `json:"gender"`
63+
Email string `json:"email"`
64+
Skype string `json:"skype"`
65+
Qq string `json:"qq"`
66+
Mobile string `json:"mobile"`
67+
Phone string `json:"phone"`
68+
Weixin string `json:"weixin"`
69+
Dingding string `json:"dingding"`
70+
Slack string `json:"slack"`
71+
Whatsapp string `json:"whatsapp"`
72+
Address string `json:"address"`
73+
Zipcode string `json:"zipcode"`
74+
Nature string `json:"nature"`
75+
Analysis string `json:"analysis"`
76+
Strategy string `json:"strategy"`
77+
Join string `json:"join"`
78+
Visits int `json:"visits"`
79+
Visions string `json:"visions"`
80+
IP string `json:"ip"`
81+
Last string `json:"last"`
82+
Fails int `json:"fails"`
83+
Locked string `json:"locked"`
84+
Feedback string `json:"feedback"`
85+
Ranzhi string `json:"ranzhi"`
86+
Ldap string `json:"ldap"`
87+
Score int `json:"score"`
88+
ScoreLevel int `json:"scoreLevel"`
89+
ResetToken string `json:"resetToken"`
90+
ClientStatus string `json:"clientStatus"`
91+
ClientLang string `json:"clientLang"`
92+
LastTime int `json:"lastTime"`
93+
Admin bool `json:"admin"`
94+
ModifyPassword bool `json:"modifyPassword"`
95+
Rights interface{} `json:"rights"`
9696
Groups struct {
9797
Num13 string `json:"13"`
9898
} `json:"groups"`
@@ -195,7 +195,12 @@ func (s *LoginService) Login() (bool, *LoginRespData, *req.Response, error) {
195195
} else {
196196
resp, err = s.client.client.R().
197197
SetSuccessResult(&data).
198-
Get(s.client.RequestURLFmt("/user-login.json?account=%s&password=%s&zentaosid=%s", s.client.username, s.client.password, s.client.zentaosid))
198+
SetQueryParams(map[string]string{
199+
"account": s.client.username,
200+
"password": s.client.password,
201+
"zentaosid": s.client.zentaosid,
202+
}).
203+
Get(s.client.RequestURL("/user-login.json"))
199204
}
200205
if err != nil {
201206
return false, &data, resp, err

0 commit comments

Comments
 (0)