作者 yangfu

用户信息修改

... ... @@ -102,7 +102,8 @@ func GetUserCompanyBy(id int64, companyId int64) (v *UserCompany, err error) {
//获取用户第一个有效公司
func GetUserCompanysFirst(uid int64) (v *UserCompany, err error) {
o := orm.NewOrm()
sql := "select * from user_company where user_id=? and enable=1 order by create_at desc limit 1" //
sql := `select a.* from user_company a inner join company b on a.company_id=b.id where a.user_id=? and a.enable=1 and b.enable=1
order by a.create_at desc limit 1` //
if err = o.Raw(sql, uid).QueryRow(&v); err == nil {
return v, nil
}
... ... @@ -122,7 +123,7 @@ func GetUserCompanyIdAll(companyId int) (v []int64, err error) {
//@uid 表user.id
func GetUserAllCompany(uid int64) (v []*UserCompany, err error) {
o := orm.NewOrm()
sql := "select * from user_company where user_id=? and enable=1" //and enable=1
sql := "select * from user_company a inner join company b on a.company_id=b.id where a.user_id=? and a.enable=1 and b.enable=1" //and enable=1
if _, err = o.Raw(sql, uid).QueryRows(&v); err == nil {
return v, nil
}
... ...