diff --git a/example/releases/main.go b/example/releases/main.go index 4c8d9d3..49f300e 100644 --- a/example/releases/main.go +++ b/example/releases/main.go @@ -17,23 +17,31 @@ package main import ( - "log" - "github.com/easysoft/go-zentao/v20/zentao" + + "github.com/davecgh/go-spew/spew" ) func main() { zt, err := zentao.NewBasicAuthClient( "admin", "jaege1ugh4ooYip7", - zentao.WithBaseURL("http://172.77.77.12"), + zentao.WithBaseURL("http://127.0.0.1"), zentao.WithDevMode(), zentao.WithDumpAll(), zentao.WithoutProxy(), ) if err != nil { - log.Fatal(err) + panic(err) + } + p1, _, err := zt.Releases.ProjectsList(2) + if err != nil { + panic(err) + } + spew.Dump(p1) + p2, _, err := zt.Releases.ProductsList(1) + if err != nil { + panic(err) } - zt.Releases.ProjectsList(7) - zt.Releases.ProductsList(1) + spew.Dump(p2) } diff --git a/zentao/releases.go b/zentao/releases.go index b13f3e3..ee75a49 100644 --- a/zentao/releases.go +++ b/zentao/releases.go @@ -26,38 +26,78 @@ type ReleasesService struct { client *Client } -type Releases struct { - ID int `json:"id"` - Project int `json:"project"` - Product int `json:"product"` - Branch int `json:"branch"` - Build int `json:"build"` - Name string `json:"name"` - Marker string `json:"marker"` - Date string `json:"date"` - Stories string `json:"stories"` - Bugs string `json:"bugs"` - Leftbugs string `json:"leftBugs"` - Desc string `json:"desc"` - Mailto string `json:"mailto"` - Notify interface{} `json:"notify"` - Status string `json:"status"` - Substatus string `json:"subStatus"` - Deleted bool `json:"deleted"` - Productname string `json:"productName"` - Buildid int `json:"buildID"` - Buildname string `json:"buildName"` - Projectname string `json:"projectName"` +type ReleasesCommon struct { + ID int `json:"id"` + Project string `json:"project"` + Product int `json:"product"` + Branch string `json:"branch"` + Shadow int `json:"shadow"` + Name string `json:"name"` + Marker string `json:"marker"` + Date string `json:"date"` + ReleasedDate string `json:"releasedDate"` + Stories string `json:"stories"` + Bugs string `json:"bugs"` + Leftbugs string `json:"leftBugs"` + Desc string `json:"desc"` + Mailto any `json:"mailto"` + Notify any `json:"notify"` + Status string `json:"status"` + Substatus string `json:"subStatus"` + CreatedBy any `json:"createdBy"` + CreatedDate string `json:"createdDate"` + Deleted bool `json:"deleted"` + ProductName string `json:"productName"` + ProductType string `json:"productType"` } -type ReleasesMsg struct { - Total int `json:"total"` - Releases []Releases `json:"releases"` +type BuildInfo struct { + ID int `json:"id"` + Name string `json:"name"` + Project int `json:"project"` + Execution int `json:"execution"` + ProjectName string `json:"projectName,omitempty"` + Link string `json:"link,omitempty"` + Product int `json:"product,omitempty"` + Branch string `json:"branch,omitempty"` + ScmPath string `json:"scmPath,omitempty"` + FilePath string `json:"filePath,omitempty"` + BranchName string `json:"branchName,omitempty"` +} + +type ProjectRelease struct { + ReleasesCommon + BranchName string `json:"branchName,omitempty"` + BuildInfos map[string]BuildInfo `json:"buildInfos,omitempty"` +} + +type ProjectReleasesMsg struct { + Total int `json:"total"` + Limit int `json:"limit"` + Page int `json:"page"` + Releases []ProjectRelease `json:"releases"` +} + +type ProductRelease struct { + ReleasesCommon + BranchName string `json:"branchName,omitempty"` + ProjectName string `json:"projectName,omitempty"` + Actions []string `json:"actions,omitempty"` + Rowspan int `json:"rowspan,omitempty"` + Build BuildInfo `json:"build,omitempty"` + Builds []BuildInfo `json:"builds,omitempty"` +} + +type ProductReleasesMsg struct { + Total int `json:"total"` + Limit int `json:"limit"` + Page int `json:"page"` + Releases []ProductRelease `json:"releases"` } // ProjectsList 获取项目发布列表 -func (s *ReleasesService) ProjectsList(id int) (*ReleasesMsg, *req.Response, error) { - var u ReleasesMsg +func (s *ReleasesService) ProjectsList(id int) (*ProjectReleasesMsg, *req.Response, error) { + var u ProjectReleasesMsg resp, err := s.client.client.R(). SetHeader("Token", s.client.token). SetSuccessResult(&u). @@ -66,8 +106,8 @@ func (s *ReleasesService) ProjectsList(id int) (*ReleasesMsg, *req.Response, err } // ProductsList 获取产品发布列表 -func (s *ReleasesService) ProductsList(id int) (*ReleasesMsg, *req.Response, error) { - var u ReleasesMsg +func (s *ReleasesService) ProductsList(id int) (*ProductReleasesMsg, *req.Response, error) { + var u ProductReleasesMsg resp, err := s.client.client.R(). SetHeader("Token", s.client.token). SetSuccessResult(&u).