正在显示
1 个修改的文件
包含
3 行增加
和
2 行删除
@@ -102,7 +102,8 @@ func GetUserCompanyBy(id int64, companyId int64) (v *UserCompany, err error) { | @@ -102,7 +102,8 @@ func GetUserCompanyBy(id int64, companyId int64) (v *UserCompany, err error) { | ||
102 | //获取用户第一个有效公司 | 102 | //获取用户第一个有效公司 |
103 | func GetUserCompanysFirst(uid int64) (v *UserCompany, err error) { | 103 | func GetUserCompanysFirst(uid int64) (v *UserCompany, err error) { |
104 | o := orm.NewOrm() | 104 | o := orm.NewOrm() |
105 | - sql := "select * from user_company where user_id=? and enable=1 order by create_at desc limit 1" // | 105 | + 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 |
106 | + order by a.create_at desc limit 1` // | ||
106 | if err = o.Raw(sql, uid).QueryRow(&v); err == nil { | 107 | if err = o.Raw(sql, uid).QueryRow(&v); err == nil { |
107 | return v, nil | 108 | return v, nil |
108 | } | 109 | } |
@@ -122,7 +123,7 @@ func GetUserCompanyIdAll(companyId int) (v []int64, err error) { | @@ -122,7 +123,7 @@ func GetUserCompanyIdAll(companyId int) (v []int64, err error) { | ||
122 | //@uid 表user.id | 123 | //@uid 表user.id |
123 | func GetUserAllCompany(uid int64) (v []*UserCompany, err error) { | 124 | func GetUserAllCompany(uid int64) (v []*UserCompany, err error) { |
124 | o := orm.NewOrm() | 125 | o := orm.NewOrm() |
125 | - sql := "select * from user_company where user_id=? and enable=1" //and enable=1 | 126 | + 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 |
126 | if _, err = o.Raw(sql, uid).QueryRows(&v); err == nil { | 127 | if _, err = o.Raw(sql, uid).QueryRows(&v); err == nil { |
127 | return v, nil | 128 | return v, nil |
128 | } | 129 | } |
-
请 注册 或 登录 后发表评论