edb_source.go 929 B

12345678910111213141516171819202122232425262728293031
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "strings"
  6. )
  7. // EdbSource 指标来源表
  8. type EdbSource struct {
  9. EdbSourceId int `orm:"column(edb_source_id);pk"`
  10. SourceName string `description:"指标来源名称"`
  11. TableName string `description:"数据表名"`
  12. IsBase int `description:"是否为基础指标: 0-否; 1-是"`
  13. }
  14. // GetEdbSourceItemsByCondition 获取指标来源
  15. func GetEdbSourceItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*EdbSource, err error) {
  16. o := orm.NewOrmUsingDB("data")
  17. fields := strings.Join(fieldArr, ",")
  18. if len(fieldArr) == 0 {
  19. fields = `*`
  20. }
  21. order := `ORDER BY edb_source_id ASC`
  22. if orderRule != "" {
  23. order = ` ORDER BY ` + orderRule
  24. }
  25. sql := fmt.Sprintf(`SELECT %s FROM edb_source WHERE 1=1 %s %s`, fields, condition, order)
  26. _, err = o.Raw(sql, pars).QueryRows(&items)
  27. return
  28. }