package company import ( "github.com/beego/beego/v2/client/orm" "time" ) type CompanyAscribe struct { CompanyAscribeId int `orm:"column(company_ascribe_id);pk" description:"归因ID"` AscribeContent string `description:"归因说明"` AdminId int `description:"管理员ID"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"更新时间"` } type CompanyAscribeResp struct { CompanyAscribeId int `orm:"column(company_ascribe_id);pk" description:"归因ID"` AscribeContent string `description:"归因说明"` AdminId int `description:"管理员ID"` CreateTime string `description:"创建时间"` } type CompanyAscribeDetailResp struct { Detail *CompanyAscribeResp } type CompanyAscribeListResp struct { List []*CompanyAscribeResp } type CompanyAscribeAddReq struct { AscribeContent string `description:"归因说明"` } // 添加 func AddCompanyAscribe(item *CompanyAscribe) (newId int64, err error) { o := orm.NewOrm() newId, err = o.Insert(item) return } // 获取数量 func GetCompanyAscribeCount(condition string, pars []interface{}) (count int, err error) { sqlCount := ` SELECT COUNT(1) AS count FROM company_ascribe as a WHERE 1= 1 ` if condition != "" { sqlCount += condition } o := orm.NewOrm() err = o.Raw(sqlCount, pars).QueryRow(&count) return } // 列表 func GetCompanyAscribeList(condition string, pars []interface{}, startSize, pageSize int) (items []*CompanyAscribeResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM company_ascribe as a WHERE 1= 1 ` if condition != "" { sql += condition } if startSize+pageSize > 0 { sql += ` LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) } _, err = o.Raw(sql, pars).QueryRows(&items) return } // 通过ID获取详情 func GetCompanyAscribeDetail(companyAscribeId int) (item *CompanyAscribeResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM company_ascribe WHERE company_ascribe_id=? ` err = o.Raw(sql, companyAscribeId).QueryRow(&item) return }