admin.go 836 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package controllers
  2. import (
  3. "eta/eta_data_init/models"
  4. "eta/eta_data_init/services"
  5. "fmt"
  6. beego "github.com/beego/beego/v2/server/web"
  7. )
  8. // DataInitController
  9. // Operations about Users
  10. type AdminInitController struct {
  11. beego.Controller
  12. }
  13. // Base
  14. // @Title 初始化系统用户
  15. // @Description 初始化系统用户
  16. // @Param FileName query string true "文件名称"
  17. // @Success Ret=200
  18. // @router /base [get]
  19. func (this *AdminInitController) Base() {
  20. br := new(models.BaseResponse).Init()
  21. defer func() {
  22. this.Data["json"] = br
  23. this.ServeJSON()
  24. }()
  25. fileName := this.GetString("FileName")
  26. if fileName == "" {
  27. br.Msg = "文件名称不能为空"
  28. return
  29. }
  30. filePath := "/docs/" + fileName
  31. fmt.Println("filePath:" + filePath)
  32. services.InitAdmin(filePath)
  33. br.Ret = 200
  34. br.Msg = "初始化成功"
  35. }