wangchuanjin 2 роки тому
батько
коміт
1a6ad71784
1 змінених файлів з 3 додано та 3 видалено
  1. 3 3
      service/identity.go

+ 3 - 3
service/identity.go

@@ -15,7 +15,7 @@ func IdentityList(userId int64) []*Identity {
 	list := entity.BaseMysql.SelectBySql(`SELECT DISTINCT a.id as position_id,c.person_id,a.person_name,a.account_id,a.type as position_type,a.ent_id,b.id as ent_account_id,d.phone from base_user d
 		inner join base_position a on (d.id=? and d.id=a.user_id)
 		inner join base_account c on (a.account_id=c.id)
-    	left join base_account b on (b.type=1 and b.person_id=0 and b.ent_id<>0 and c.ent_id=b.ent_id)`, userId)
+    	left join base_account b on (b.type=1 and b.person_id=0 and b.ent_id<>0 and c.ent_id=b.ent_id) order by a.id desc`, userId)
 	if list != nil {
 		m := map[int64]*Identity{}
 		entIds := []string{}
@@ -65,7 +65,7 @@ func IdentityList(userId int64) []*Identity {
 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) limit 1`, userId)
+		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 {
 		return &Identity{
 			PersonId:     Int64All((*list)[0]["person_id"]),
@@ -123,7 +123,7 @@ func IdentityByEntUserId(entUserId int64) *Identity {
 		list := entity.BaseMysql.SelectBySql(`SELECT a.id as position_id,c.person_id,a.person_name,a.account_id,a.type as position_type,d.id as user_id,b.id as ent_account_id from base_user d
 		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=?) limit 1`, ObjToString((*ents)[0]["phone"]), entId, entId, entId)
+		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 {
 			identity := &Identity{
 				PersonId:     Int64All((*list)[0]["person_id"]),