Skip to content

Commit

Permalink
* [product] update product api
Browse files Browse the repository at this point in the history
Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Sep 19, 2024
1 parent b006b93 commit d68a094
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
41 changes: 21 additions & 20 deletions example/products/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package main
import (
"fmt"
"log"
"time"

"github.com/easysoft/go-zentao/v20/zentao"

Expand All @@ -36,33 +35,35 @@ func main() {
zentao.WithoutProxy(),
)
if err != nil {
log.Fatal(err)
panic(err)
}
pl, _, err := zt.Products.List()
if err != nil {
log.Fatal(err)
panic(err)
}
log.Printf("Products count: %v", len(pl.Products))
cp, _, err := zt.Products.Create(zentao.ProductsMeta{
Name: fmt.Sprintf("gosdk_%d%d", time.Now().Minute(), time.Now().Second()),
Code: fmt.Sprintf("gosdk_%d%d", time.Now().Minute(), time.Now().Second()),
p1, _, err := zt.Products.Create(zentao.ProductsMeta{
Name: "gosdk_2",
Code: "gosdk_2",
})
if err != nil {
log.Fatal(err)
panic(err)
}
log.Printf("program id: %v", cp.ID)
getmsg, _, err := zt.Products.GetByID(cp.ID)
log.Printf("product id: %v", p1.ID)
p2, _, err := zt.Products.GetByID(p1.ID)
if err != nil {
log.Fatal(err)
panic(err)
}
spew.Dump(p2)
p3, _, err := zt.Products.UpdateByID(p1.ID, zentao.ProductsMeta{
Name: fmt.Sprintf("gosdk_22"),
})
if err != nil {
panic(err)
}
spew.Dump(p3)
_, _, err = zt.Products.DeleteByID(p1.ID)
if err != nil {
panic(err)
}
spew.Dump(getmsg)
// _, _, err = zt.Products.DeleteByID(cp.ID)
// _, _, err = zt.ProductPlans.Create(cp.ID, zentao.ProductPlanMeta{
// Title: fmt.Sprintf("abc%d%d", time.Now().Minute(), time.Now().Second()),
// })
// if err != nil {
// log.Fatal(err)
// }
// zt.ProductPlans.List(cp.ID)
// zt.ProductPlans.GetByID(5)
}
52 changes: 26 additions & 26 deletions zentao/products.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type ProductsListBody struct {
Linename string `json:"lineName"`
Programname string `json:"programName"`
Stories ProductsStories `json:"stories"`
Requirements ProductsStories `json:"requirements"`
Requirements ProductsStories `json:"requirements,omitempty"`
Plans int `json:"plans"`
Releases int `json:"releases"`
Bugs int `json:"bugs"`
Expand All @@ -54,28 +54,28 @@ type ProductsList struct {
}

type ProductsMeta struct {
Name string `json:"name"`
Code string `json:"code"`
Name string `json:"name,omitempty"`
Code string `json:"code,omitempty"`
Type string `json:"type,omitempty"`
Line int `json:"line,omitempty"`
Program int `json:"program,omitempty"`
Status string `json:"status,omitempty"`
Desc string `json:"desc,omitempty"`
}

type ProductsBody struct {
ID int `json:"id"`
Program int `json:"program"`
Bind string `json:"bind"`
Line int `json:"line"`
Type string `json:"type"`
Status string `json:"status"`
Substatus string `json:"subStatus"`
Desc string `json:"desc"`
Po UserMeta `json:"PO"`
Qd UserMeta `json:"QD"`
Rd UserMeta `json:"RD"`
ACL string `json:"acl"`
Substatus string `json:"subStatus,omitempty"`
Po UserMeta `json:"PO,omitempty"`
Qd UserMeta `json:"QD,omitempty"`
Rd UserMeta `json:"RD,omitempty"`
ACL ACL `json:"acl"`
Whitelist []UserMeta `json:"whitelist"`
Reviewer string `json:"reviewer"`
Reviewer string `json:"reviewer,omitempty"`
Createdby UserMeta `json:"createdBy"`
Createddate time.Time `json:"createdDate"`
Createdversion string `json:"createdVersion"`
Createdversion string `json:"createdVersion,omitempty"`
Order int `json:"order"`
Deleted string `json:"deleted"`
}
Expand All @@ -92,7 +92,7 @@ type ProductsGetMsg struct {
Feedback string `json:"feedback,omitempty"`
Vision string `json:"vision,omitempty"`

Stories ProductsStories `json:"stories"`
Stories ProductsStories `json:"stories,omitempty"`
ProductsExtMsg
}

Expand All @@ -105,16 +105,16 @@ type ProductsUpdateMsg struct {
}

type ProductsExtMsg struct {
Plans int `json:"plans"`
Releases int `json:"releases"`
Builds int `json:"builds"`
Cases int `json:"cases"`
Projects int `json:"projects"`
Executions int `json:"executions"`
Bugs int `json:"bugs"`
Docs int `json:"docs"`
Progress int `json:"progress"`
Casereview bool `json:"caseReview"`
Plans int `json:"plans,omitempty"`
Releases int `json:"releases,omitempty"`
Builds int `json:"builds,omitempty"`
Cases int `json:"cases,omitempty"`
Projects int `json:"projects,omitempty"`
Executions int `json:"executions,omitempty"`
Bugs int `json:"bugs,omitempty"`
Docs int `json:"docs,omitempty"`
Progress int `json:"progress,omitempty"`
Casereview bool `json:"caseReview,omitempty"`
}

type ProductsStories struct {
Expand Down

0 comments on commit d68a094

Please sign in to comment.