Commit 595289ee by 阳浪

登录优化

parent 48a40242
......@@ -31,6 +31,7 @@ import com.yizhi.site.application.vo.site.MyItemConfigVO;
import com.yizhi.system.application.constant.SecurityError;
import com.yizhi.system.application.controller.manage.AccountController;
import com.yizhi.system.application.domain.Account;
import com.yizhi.system.application.domain.Site;
import com.yizhi.system.application.enums.SecurityReturnCode;
import com.yizhi.system.application.exception.AuthNoManagementException;
import com.yizhi.system.application.exception.AuthNotManageException;
......@@ -223,6 +224,7 @@ public class AuthController {
user.setPassword("");
retMap.put("userInfo", user);
retMap.put("siteId", context.getSiteId().toString());
retMap.put("siteCode", context.getSiteCode());
}
/**
......@@ -293,6 +295,14 @@ public class AuthController {
}
context.setAccountId(user.getId());
context.setOrgId(user.getOrgId());
Long siteId = accountService.findSiteId(user.getId());
if(siteId!=null) {
context.setSiteId(siteId);
Site site = siteService.findById(siteId);
if(site!=null){
context.setSiteCode(site.getCode());
}
}
String token = createToken(user, context);
// 生成token(不是首次登陆)
if (!firstLoginFlg) {
......
......@@ -2636,4 +2636,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
return wrapper;
}
@Override
public Long findSiteId(Long accountId){
return this.accountMapper.findSiteId(accountId);
}
}
......@@ -997,5 +997,16 @@
where 1=1 and id in(<foreach collection="idList" index="index" item="item" separator=",">#{item}</foreach>) and
deleted=0
</select>
<select id="findSiteId" resultType="java.lang.Long">
select
distinct ar.site_id
from
authz_account_role aar
left join authz_role ar on
aar.role_id = ar.id
where
account_id = #{accountId}
limit 1
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment