tapd.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package http
  2. import (
  3. "go-common/library/log"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func saveFiles(c *bm.Context) {
  7. c.JSON(nil, srv.SaveFiles(c))
  8. }
  9. func downloadStoryFile(c *bm.Context) {
  10. var (
  11. err error
  12. data []byte
  13. code int
  14. )
  15. if data, err = srv.DownloadStoryFile(c); err != nil {
  16. log.Error("Download story file failed, error:%v", err)
  17. code = -1
  18. }
  19. contentType := " text/plain;charset:utf-8;"
  20. c.Writer.Header().Set("content-disposition", `attachment; filename=story.txt`)
  21. c.Bytes(code, contentType, data)
  22. }
  23. func downloadChangeFile(c *bm.Context) {
  24. var (
  25. err error
  26. data []byte
  27. code int
  28. )
  29. if data, err = srv.DownloadChangeFile(c); err != nil {
  30. log.Error("Download change file failed, error:%v", err)
  31. code = -1
  32. }
  33. contentType := " text/plain;charset:utf-8;"
  34. c.Writer.Header().Set("content-disposition", `attachment; filename=change.txt`)
  35. c.Bytes(code, contentType, data)
  36. }
  37. func downloadIterationFile(c *bm.Context) {
  38. var (
  39. err error
  40. data []byte
  41. code int
  42. )
  43. if data, err = srv.DownloadIterationFile(c); err != nil {
  44. log.Error("Download iteration file failed, error:%v", err)
  45. code = -1
  46. }
  47. contentType := " text/plain;charset:utf-8;"
  48. c.Writer.Header().Set("content-disposition", `attachment; filename=iteration.txt`)
  49. c.Bytes(code, contentType, data)
  50. }
  51. func downloadBugFile(c *bm.Context) {
  52. var (
  53. err error
  54. data []byte
  55. code int
  56. )
  57. if data, err = srv.DownBugFile(c); err != nil {
  58. log.Error("Download bug file failed, error:%v", err)
  59. code = -1
  60. }
  61. contentType := " text/plain;charset:utf-8;"
  62. c.Writer.Header().Set("content-disposition", `attachment; filename=bug.txt`)
  63. c.Bytes(code, contentType, data)
  64. }