12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package Basic
- import (
- "ERP_storage/logs"
- "git.baozhida.cn/ERP_libs/lib"
- _ "github.com/astaxie/beego/cache/redis"
- "github.com/beego/beego/v2/adapter/orm"
- orm2 "github.com/beego/beego/v2/client/orm"
- _ "github.com/go-sql-driver/mysql"
- )
- // 产品规格
- type ProductSpec struct {
- Id int `orm:"column(ID);size(11);auto;pk"`
- T_name string `orm:"size(256);null"` // 名称
- }
- func (t *ProductSpec) TableName() string {
- return "product_spec" // 数据库名称
- }
- func init() {
- //注册模型
- orm.RegisterModel(new(ProductSpec))
- }
- // 获取列表
- func Read_ProductSpec_List(T_name string) (r_ []ProductSpec) {
- o := orm.NewOrm()
- // 也可以直接使用 Model 结构体作为表名
- qs := o.QueryTable(new(ProductSpec))
- // 过滤
- cond := orm.NewCondition()
- if len(T_name) > 0 {
- cond = cond.And("T_name__icontains", T_name)
- }
- // 查询
- _, err := qs.SetCond((*orm2.Condition)(cond)).OrderBy("-Id").All(&r_)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- return
- }
- return r_
- }
|