You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.0 KiB

  1. package v1
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global/response"
  5. "gin-vue-admin/model"
  6. "gin-vue-admin/service"
  7. "github.com/gin-gonic/gin"
  8. "os"
  9. )
  10. // @Tags SysApi
  11. // @Summary 自动代码模板
  12. // @Security ApiKeyAuth
  13. // @accept application/json
  14. // @Produce application/json
  15. // @Param data body model.AutoCodeStruct true "创建自动代码"
  16. // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
  17. // @Router /autoCode/createTemp [post]
  18. func CreateTemp(c *gin.Context) {
  19. var a model.AutoCodeStruct
  20. _ = c.ShouldBindJSON(&a)
  21. err := service.CreateTemp(a)
  22. if err != nil {
  23. response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
  24. os.Remove("./ginvueadmin.zip")
  25. } else {
  26. c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) //fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
  27. c.Writer.Header().Add("Content-Type", "application/json")
  28. c.Writer.Header().Add("success", "true")
  29. c.File("./ginvueadmin.zip")
  30. os.Remove("./ginvueadmin.zip")
  31. }
  32. }