create issue endpoint
This commit is contained in:
@ -12,13 +12,52 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func PostIssue(c *gin.Context) {
|
||||
var issueProxy model.PostCreateIssueProxy
|
||||
if err := c.BindJSON(&issueProxy); err != nil {
|
||||
c.AsciiJSON(http.StatusBadRequest, gin.H{
|
||||
"message": "CREATE_ISSUE_ERROR",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
giteaIssue, err := issueProxy.TransformToGiteaCreateIssueOption()
|
||||
if err != nil {
|
||||
c.AsciiJSON(http.StatusBadRequest, gin.H{
|
||||
"message": "CREATE_ISSUE_ERROR",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
response, err := giteaClient.CreateIssue(giteaIssue)
|
||||
if err != nil {
|
||||
c.AsciiJSON(http.StatusBadRequest, gin.H{
|
||||
"message": "CREATE_ISSUE_ERROR",
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.AsciiJSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
func PostIssueSwagger() (*swagger.Endpoint){
|
||||
return endpoint.New("post", "/issues", "Create issue",
|
||||
endpoint.Handler(PostIssue),
|
||||
endpoint.Description("Post new issue"),
|
||||
endpoint.Body(model.PostCreateIssueProxy{}, "Issue object", true),
|
||||
endpoint.Tags("issues"),
|
||||
endpoint.Response(http.StatusOK, gitea.Issue{}, "Gitea Issue list"),
|
||||
)
|
||||
}
|
||||
|
||||
func GetIssues(c *gin.Context) {
|
||||
giteaIssues, err := giteaClient.GetIssues();
|
||||
|
||||
proxyIssues := []model.GetCreateIssueProxy{}
|
||||
|
||||
for _, issue := range giteaIssues {
|
||||
proxyIssues = append(proxyIssues, model.TransformFromGitea(issue))
|
||||
proxyIssues = append(proxyIssues, model.IssueTransformFromGitea(issue))
|
||||
}
|
||||
|
||||
if(err != nil){
|
||||
|
Reference in New Issue
Block a user