获取当前的用户信息:
public class HrUtils {
public static Hr
getCurrentHr() {
return (Hr
) SecurityContextHolder
.getContext().getAuthentication().getPrincipal();
}
}
使用的时候,可以根据上面那段代码中获取到的Hr实体类信息,然后通过get获取Hr中的某个属性:
public List
<Hr> getAllHrExceptAdmin() {
return hrMapper
.getAllHr(HrUtils
.getCurrentHr().getId());
}
顺便把相关的都放出来: Mapper接口中存放:
List
<Hr> getAllHr(@Param("currentId") Long currentId
);
mapper.xml
<select id
="getAllHr" resultType
="com.zto.hrms.model.Hr">
select
* from hr
<if test
="currentId!=null">
WHERE id
!=#
{currentId
}
</if>
</select
>
如果感兴趣可以关注本人的微信公众号,微信搜索"IT微资源",或者扫下面的二维码