作者 唐旭辉

bug 修复

@@ -6,7 +6,6 @@ import ( @@ -6,7 +6,6 @@ import (
6 "oppmg/models" 6 "oppmg/models"
7 "oppmg/protocol" 7 "oppmg/protocol"
8 "oppmg/utils" 8 "oppmg/utils"
9 - "strings"  
10 "time" 9 "time"
11 ) 10 )
12 11
@@ -334,21 +333,16 @@ func GetRoleHasRole(roleid int64, companyid int64) ([]protocol.RoleHasUser, erro @@ -334,21 +333,16 @@ func GetRoleHasRole(roleid int64, companyid int64) ([]protocol.RoleHasUser, erro
334 return roleuserlist, protocol.NewErrWithMessage("1") 333 return roleuserlist, protocol.NewErrWithMessage("1")
335 } 334 }
336 var ( 335 var (
337 - ucid []string  
338 - datasql string = `SELECT user_company_id FROM user_role  
339 - WHERE company_id=? AND role_id =? AND enable_status = 1`  
340 - datasql2 string = `SELECT a.nick_name,b.id AS user_company_id FROM user AS a,user_company AS b  
341 - WHERE a.id= b.user_id AND b.id IN(%s)` 336 + datasql2 string = `SELECT a.nick_name,b.id AS user_company_id
  337 + FROM user AS a
  338 + JOIN user_company AS b ON a.id=b.user_id
  339 + JOIN user_role AS c ON b.id= c.user_company_id
  340 + WHERE c.company_id=?
  341 + AND c.role_id =?
  342 + AND c.enable_status = 1
  343 + AND b.enable = 1 AND b.delete_at = 0 `
342 ) 344 )
343 - err = utils.ExecuteQueryAll(&ucid, datasql, companyid, roleid)  
344 - if err != nil {  
345 - log.Error("获取用户id失败:%s", err)  
346 - return roleuserlist, protocol.NewErrWithMessage("1")  
347 - }  
348 - if len(ucid) == 0 {  
349 - return roleuserlist, nil  
350 - }  
351 - err = utils.ExecuteQueryAll(&roleuserlist, fmt.Sprintf(datasql2, strings.Join(ucid, ","))) 345 + err = utils.ExecuteQueryAll(&roleuserlist, datasql2, companyid, roleid)
352 if err != nil { 346 if err != nil {
353 log.Error("获取用户数据失败;%s", err) 347 log.Error("获取用户数据失败;%s", err)
354 } 348 }