|
@@ -0,0 +1,75 @@
|
|
|
+package future_good
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// ChartInfoFutureGoodProfit 商品利润图表-扩展信息
|
|
|
+type ChartInfoFutureGoodProfit struct {
|
|
|
+ ChartInfoId int `orm:"column(chart_info_id);pk" description:"商品利润图表ID(chart_info表source=5的)"`
|
|
|
+ ProfitName string `description:"利润名称"`
|
|
|
+ ProfitNameEn string `description:"利润英文名称"`
|
|
|
+ XValue string `description:"X轴数据值"`
|
|
|
+ YValue string `description:"Y轴数据值"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+ ModifyTime time.Time `description:"更新时间"`
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) TableName() string {
|
|
|
+ return "chart_info_future_good_profit"
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) Create() (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ _, err = o.Insert(m)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //m.CorrelationChartInfoId = int(id)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) Update(cols []string) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ _, err = o.Update(m, cols...)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) Delete() (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := fmt.Sprintf(`DELETE FROM %s WHERE chart_info_id = ? LIMIT 1`, m.TableName())
|
|
|
+ _, err = o.Raw(sql, m.ChartInfoId).Exec()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) GetItemById(id int) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := fmt.Sprintf(`SELECT * FROM %s WHERE chart_info_id = ? LIMIT 1`, m.TableName())
|
|
|
+ err = o.Raw(sql, id).QueryRow(&m)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) GetItemByCondition(condition string, pars []interface{}) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := fmt.Sprintf(`SELECT * FROM %s WHERE 1=1 %s LIMIT 1`, m.TableName(), condition)
|
|
|
+ err = o.Raw(sql, pars).QueryRow(&m)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (m *ChartInfoFutureGoodProfit) GetItemsByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*ChartInfoFutureGoodProfit, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ fields := strings.Join(fieldArr, ",")
|
|
|
+ if len(fieldArr) == 0 {
|
|
|
+ fields = `*`
|
|
|
+ }
|
|
|
+ order := ``
|
|
|
+ if orderRule != "" {
|
|
|
+ order = ` ORDER BY ` + orderRule
|
|
|
+ }
|
|
|
+ sql := fmt.Sprintf(`SELECT %s FROM %s WHERE 1=1 %s %s`, fields, m.TableName(), condition, order)
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|