sys_auto_history.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package request
  2. import (
  3. common "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
  4. model "github.com/flipped-aurora/gin-vue-admin/server/model/system"
  5. )
  6. type SysAutoHistoryCreate struct {
  7. Table string // 表名
  8. Package string // 模块名/插件名
  9. Request string // 前端传入的结构化信息
  10. StructName string // 结构体名称
  11. BusinessDB string // 业务库
  12. Description string // Struct中文名称
  13. Injections map[string]string // 注入路径
  14. Templates map[string]string // 模板信息
  15. ApiIDs []uint // api表注册内容
  16. MenuID uint // 菜单ID
  17. ExportTemplateID uint // 导出模板ID
  18. }
  19. func (r *SysAutoHistoryCreate) Create() model.SysAutoCodeHistory {
  20. entity := model.SysAutoCodeHistory{
  21. Package: r.Package,
  22. Request: r.Request,
  23. Table: r.Table,
  24. StructName: r.StructName,
  25. Abbreviation: r.StructName,
  26. BusinessDB: r.BusinessDB,
  27. Description: r.Description,
  28. Injections: r.Injections,
  29. Templates: r.Templates,
  30. ApiIDs: r.ApiIDs,
  31. MenuID: r.MenuID,
  32. ExportTemplateID: r.ExportTemplateID,
  33. }
  34. if entity.Table == "" {
  35. entity.Table = r.StructName
  36. }
  37. return entity
  38. }
  39. type SysAutoHistoryRollBack struct {
  40. common.GetById
  41. DeleteApi bool `json:"deleteApi" form:"deleteApi"` // 是否删除接口
  42. DeleteMenu bool `json:"deleteMenu" form:"deleteMenu"` // 是否删除菜单
  43. DeleteTable bool `json:"deleteTable" form:"deleteTable"` // 是否删除表
  44. }
  45. func (r *SysAutoHistoryRollBack) ApiIds(entity model.SysAutoCodeHistory) common.IdsReq {
  46. length := len(entity.ApiIDs)
  47. ids := make([]int, 0)
  48. for i := 0; i < length; i++ {
  49. ids = append(ids, int(entity.ApiIDs[i]))
  50. }
  51. return common.IdsReq{Ids: ids}
  52. }