LAPP 打印服务 支持条码打印和表单打印 通过Socket或windows打印方式
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.

55 lines
1.6 KiB

  1. package config
  2. import (
  3. "gopkg.in/yaml.v2"
  4. "os"
  5. )
  6. type EnvConfig struct {
  7. DbType string `yaml:"dbtype"`
  8. Server string `yaml:"server"`
  9. Ip string `yaml:"ip"`
  10. User string `yaml:"user"`
  11. Password string `yaml:"password"`
  12. DbName string `yaml:"dbname"`
  13. Port int `yaml:"port"`
  14. SalveDbType string `yaml:"salvedbtype"`
  15. SalveServer string `yaml:"salveserver"`
  16. SalveIp string `yaml:"salveip"`
  17. SalveUser string `yaml:"salveuser"`
  18. SalvePassword string `yaml:"salvepassword"`
  19. SalveDbName string `yaml:"salvedbname"`
  20. SalvePort int `yaml:"salveport"`
  21. PlantNr int `yaml:"plantnr"`
  22. Filefolder string `yaml:"filefolder"`
  23. Crontime string `yaml:"crontime"`
  24. TemplatePath string `yaml:"templatepath"`
  25. ReadTaskInterval int `yaml:"readtaskinterval"`
  26. PrinterType string `yaml:"printertype"`
  27. Printers string `yaml:"printers"`
  28. Inbox string `yaml:"inbox"`
  29. Outbox string `yaml:"outbox"`
  30. Day int `yaml:"day"`
  31. Num int `yaml:"num"`
  32. Printobjtype string `yaml:"printobjtype"`
  33. Begtime string `yaml:"begtime"`
  34. Endtime string `yaml:"endtime"`
  35. Shiptog bool `yaml:"shiptog"`
  36. Packtog bool `yaml:"packtog"`
  37. }
  38. //read yaml config
  39. //注:path为yaml或yml文件的路径
  40. func ReadYamlConfig(path string) (*EnvConfig, error) {
  41. conf := &EnvConfig{}
  42. f, err := os.Open(path)
  43. if err != nil {
  44. return nil, err
  45. } else {
  46. yaml.NewDecoder(f).Decode(conf)
  47. }
  48. defer f.Close()
  49. return conf, nil
  50. }