api_func_template.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package route
  2. import (
  3. "opennamu/route/tool"
  4. )
  5. func Api_func_template(config tool.Config) string {
  6. db := tool.DB_connect()
  7. defer tool.DB_close(db)
  8. other_set := map[string]any{}
  9. json.Unmarshal([]byte(config.Other_set), &other_set)
  10. sub_menu := []any{}
  11. if v, ok := other_set["sub"]; ok {
  12. switch x := v.(type) {
  13. case []any:
  14. sub_menu = x
  15. default:
  16. }
  17. }
  18. menu := [][]any{}
  19. if v, ok := other_set["menu"]; ok {
  20. switch x := v.(type) {
  21. case [][]any:
  22. menu = x
  23. case []any:
  24. for _, row := range x {
  25. if r, ok := row.([]any); ok {
  26. menu = append(menu, r)
  27. }
  28. }
  29. default:
  30. }
  31. }
  32. option := map[string]string{}
  33. if v, ok := other_set["option"]; ok {
  34. for k, v := range v.(map[string]any) {
  35. option[k] = v.(string)
  36. }
  37. }
  38. return tool.Get_template(
  39. db,
  40. config,
  41. other_set["name"].(string),
  42. other_set["data"].(string),
  43. sub_menu,
  44. menu,
  45. option,
  46. )
  47. }