new.go 618 B

1234567891011121314151617181920212223242526
  1. package gen
  2. import (
  3. "git.i2edu.net/i2/go-zero/tools/goctl/model/sql/template"
  4. "git.i2edu.net/i2/go-zero/tools/goctl/util"
  5. )
  6. func genNew(table Table, withCache bool) (string, error) {
  7. text, err := util.LoadTemplate(category, modelNewTemplateFile, template.New)
  8. if err != nil {
  9. return "", err
  10. }
  11. output, err := util.With("new").
  12. Parse(text).
  13. Execute(map[string]interface{}{
  14. "table": wrapWithRawString(table.Name.Source()),
  15. "withCache": withCache,
  16. "upperStartCamelObject": table.Name.ToCamel(),
  17. })
  18. if err != nil {
  19. return "", err
  20. }
  21. return output.String(), nil
  22. }