Skip to content

Commit

Permalink
* [release] imp release 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 3fee7fc commit dab0819
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 35 deletions.
20 changes: 14 additions & 6 deletions example/releases/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
98 changes: 69 additions & 29 deletions zentao/releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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).
Expand Down

0 comments on commit dab0819

Please sign in to comment.