|
@@ -43,13 +43,15 @@ func IdentityList(userId int64) []*Identity {
|
|
|
}
|
|
|
}
|
|
|
if len(entIds) > 0 {
|
|
|
- ents := entity.Mysql.SelectBySql(`SELECT a.id,a.name,a.ent_id,b.name as ent_name from entniche_user a inner join entniche_info b on (a.phone=? and b.id in (`+strings.Join(entIds, ",")+`) and a.ent_id=b.id) order by b.createtime`, phone)
|
|
|
+ ents := entity.Mysql.SelectBySql(`SELECT a.id,a.name,a.ent_id,a.niche_dis,b.name as ent_name,c.role_id from entniche_user a inner join entniche_info b on (a.phone=? and b.id in (`+strings.Join(entIds, ",")+`) and a.ent_id=b.id) left join entniche_user_role c on (a.id=c.user_id) order by b.createtime`, phone)
|
|
|
if ents != nil {
|
|
|
for _, v := range *ents {
|
|
|
i := m[Int64All(v["ent_id"])]
|
|
|
i.EntUserId = Int64All(v["id"])
|
|
|
i.EntUserName = ObjToString(v["name"])
|
|
|
i.Name = ObjToString(v["ent_name"])
|
|
|
+ i.EntRole = Int64All(v["role_id"])
|
|
|
+ i.EntNicheDis = Int64All(v["niche_dis"])
|
|
|
result = append(result, i)
|
|
|
}
|
|
|
}
|
|
@@ -66,7 +68,7 @@ func IdentityByUserId(userId int64) *Identity {
|
|
|
list := entity.BaseMysql.SelectBySql(`SELECT a.account_id,a.id as position_id,c.person_id,a.person_name,a.type as position_type from base_user d
|
|
|
inner join base_position a on (d.id=? and a.type=0 and d.id=a.user_id)
|
|
|
inner join base_account c on (c.type=0 and a.account_id=c.id) order by a.id desc limit 1`, userId)
|
|
|
- if list != nil && len(*list) == 1 {
|
|
|
+ if list != nil && len(*list) > 0 {
|
|
|
return &Identity{
|
|
|
PersonId: Int64All((*list)[0]["person_id"]),
|
|
|
UserName: ObjToString((*list)[0]["person_name"]),
|
|
@@ -102,7 +104,7 @@ func IdentityByPositionId(positionId int64) *Identity {
|
|
|
phone := ObjToString((*list)[0]["phone"])
|
|
|
if identity.EntId > 0 {
|
|
|
ents := entity.Mysql.SelectBySql(`SELECT a.id,a.name,a.ent_id,a.niche_dis,b.name as ent_name,c.role_id from entniche_user a inner join entniche_info b on (a.phone=? and b.id=? and a.ent_id=b.id) left join entniche_user_role c on (a.id=c.user_id) limit 1`, phone, identity.EntId)
|
|
|
- if ents != nil && len(*ents) == 1 {
|
|
|
+ if ents != nil && len(*ents) > 0 {
|
|
|
identity.EntUserId = Int64All((*ents)[0]["id"])
|
|
|
identity.EntUserName = ObjToString((*ents)[0]["name"])
|
|
|
identity.Name = ObjToString((*ents)[0]["ent_name"])
|
|
@@ -117,7 +119,7 @@ func IdentityByPositionId(positionId int64) *Identity {
|
|
|
|
|
|
//根据企业员工id获取身份信息
|
|
|
func IdentityByEntUserId(entUserId int64) *Identity {
|
|
|
- ents := entity.Mysql.SelectBySql(`SELECT a.id,a.name,a.phone,a.ent_id,b.name as ent_name from entniche_user a inner join entniche_info b on (a.id=? and a.ent_id=b.id) limit 1`, entUserId)
|
|
|
+ ents := entity.Mysql.SelectBySql(`SELECT a.id,a.name,a.phone,a.ent_id,a.niche_dis,b.name as ent_name,c.role_id from entniche_user a inner join entniche_info b on (a.id=? and a.ent_id=b.id) left join entniche_user_role c on (a.id=c.user_id) limit 1`, entUserId)
|
|
|
if ents == nil || len(*ents) == 0 {
|
|
|
return nil
|
|
|
}
|
|
@@ -126,7 +128,7 @@ func IdentityByEntUserId(entUserId int64) *Identity {
|
|
|
inner join base_position a on (d.phone=? and a.ent_id=? and a.type=1 and d.id=a.user_id)
|
|
|
inner join base_account c on (c.ent_id=? and c.type=1 and a.account_id=c.id)
|
|
|
inner join base_account b on (b.type=1 and b.person_id=0 and b.ent_id=?) order by a.id desc limit 1`, ObjToString((*ents)[0]["phone"]), entId, entId, entId)
|
|
|
- if list != nil && len(*list) == 1 {
|
|
|
+ if list != nil && len(*list) > 0 {
|
|
|
identity := &Identity{
|
|
|
PersonId: Int64All((*list)[0]["person_id"]),
|
|
|
UserName: ObjToString((*list)[0]["person_name"]),
|
|
@@ -139,6 +141,8 @@ func IdentityByEntUserId(entUserId int64) *Identity {
|
|
|
EntUserId: Int64All((*ents)[0]["id"]),
|
|
|
EntUserName: ObjToString((*ents)[0]["name"]),
|
|
|
Name: ObjToString((*ents)[0]["ent_name"]),
|
|
|
+ EntRole: Int64All((*ents)[0]["role_id"]),
|
|
|
+ EntNicheDis: Int64All((*ents)[0]["niche_dis"]),
|
|
|
}
|
|
|
return identity
|
|
|
}
|