package company_contract_permission import ( "github.com/beego/beego/v2/client/orm" "time" ) type CompanyContractPermission struct { Id int `orm:"column(id);pk" description:"客户合同id"` CompanyId int `description:"客户id"` CompanyContractId int `description:"合同id"` ChartPermissionId int `description:"权限id"` IsUpgrade int `description:"是否升级,1是,0否"` ExpensiveYx int `description:"权益研选: 0-3w; 1-5w"` StartDate string `description:"开始日期"` EndDate string `description:"结束日期"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` ContractType string `description:"签约合同时,当前行业类型:枚举值:'行业新签','行业续约'"` PermissionName string `description:"权限名称"` Points float64 `description:"研选扣点包点数"` } // 获取合同对应的权限列表 func GetCompanyContractPermissionList(condition string, pars []interface{}) (items []*CompanyContractPermission, err error) { o := orm.NewOrm() sql := `SELECT * FROM company_contract_permission WHERE 1 = 1 ` if condition != "" { sql += condition } _, err = o.Raw(sql, pars).QueryRows(&items) return } // UpdateCompanyContractPermissionMulti 批量修改 func UpdateCompanyContractPermissionMulti(items []*CompanyContractPermission) (err error) { o, err := orm.NewOrm().Begin() if err != nil { return } defer func() { if err == nil { o.Commit() } else { o.Rollback() } }() //批量修改公司 p, err := o.Raw("UPDATE company_contract_permission SET permission_name = ? ,contract_type = ? WHERE id = ?").Prepare() if err != nil { return } defer func() { _ = p.Close() // 别忘记关闭 statement }() for _, v := range items { _, err = p.Exec(v.PermissionName, v.ContractType, v.Id) if err != nil { return } } return }