UserDao.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. package com.nokia.dao;
  2. import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  3. import com.nokia.pojo.UserEntity;
  4. import com.nokia.vo.FlowRoleVo;
  5. import com.nokia.vo.FlowUserVo;
  6. import org.apache.ibatis.annotations.*;
  7. import java.util.List;
  8. @Mapper
  9. public interface UserDao extends BaseMapper<UserEntity> {
  10. /**
  11. * 支持username模糊查询
  12. */
  13. @Select("select distinct r.role_id, r.role_name from sqmdb_rpt.acl_user u, sqmdb_rpt.acl_role r, sqmdb_rpt.acl_user_role ur where u.user_id = ur.user_id and r.role_id = ur.role_id and u.user_name like concat('%',#{username},'%')")
  14. List<FlowRoleVo> findRoleList(String username);
  15. /**
  16. * 查询全部
  17. */
  18. @Select("select role_id, role_name from sqmdb_rpt.acl_role")
  19. List<FlowRoleVo> findRoleList2();
  20. /**
  21. * 查询全部用户(流程所需),未分页
  22. */
  23. @Results({
  24. @Result(column = "org_id", property = "org.orgId"),
  25. @Result(column = "org_name", property = "org.orgName"),
  26. })
  27. @Select("select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
  28. + " a.city_id as org_id, c.city_name_zh as org_name, a.district"
  29. + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c"
  30. + " where a.city_id = c.city_id")
  31. List<FlowUserVo> findToPage();
  32. /**
  33. * 查询登录用户信息
  34. */
  35. // @Select("select user_id as user_id,login_name as login_id,user_name as
  36. // user_name ,phone as mobile,email as email, city_id as org_id from
  37. // sqmdb_rpt.acl_user where login_name=#{loginId} ")
  38. // @Results({
  39. // @Result(column = "city_id", property = "org", one = @One(select =
  40. // "com.nokia.dao.CityDao.findOrgByCityId"))
  41. // })
  42. @Results({
  43. @Result(column = "org_id", property = "org.orgId"),
  44. @Result(column = "org_name", property = "org.orgName"),
  45. })
  46. @Select("select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
  47. + " a.city_id as org_id, c.city_name_zh as org_name, a.district"
  48. + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c"
  49. + " where a.city_id = c.city_id and login_name=#{loginId}")
  50. FlowUserVo getFlowUserVoByLoginId(String loginId);
  51. /**
  52. * 根据用户ID获取用户接口
  53. */
  54. @Results({
  55. @Result(column = "org_id", property = "org.orgId"),
  56. @Result(column = "org_name", property = "org.orgName"),
  57. })
  58. @Select("select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
  59. + " a.city_id as org_id, c.city_name_zh as org_name, a.district"
  60. + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c"
  61. + " where a.city_id = c.city_id and user_id=#{userId}")
  62. FlowUserVo getFlowUserVoByUserId(Integer userId);
  63. @Select("select r.role_id from sqmdb_rpt.acl_role r, sqmdb_rpt.acl_user_role ur where r.role_id = ur.role_id and ur.user_id=#{userId}")
  64. List<Integer> findRoleIdByUserId(Integer userId);
  65. @Select("select u.user_id from sqmdb_rpt.acl_user u, sqmdb_rpt.acl_user_role ur where u.user_id = ur.user_id and ur.role_id=#{roleId}")
  66. List<Integer> findUserIdByRoleId(Integer roleId);
  67. /**
  68. *
  69. */
  70. @Results({
  71. @Result(column = "org_id", property = "org.orgId"),
  72. @Result(column = "org_name", property = "org.orgName"),
  73. })
  74. @Select("<script>"
  75. + "select a.user_id as user_id, a.login_name as login_id, a.user_name as user_name, a.phone as mobile, a.email as email,"
  76. + " a.city_id as org_id, c.city_name_zh as org_name, a.district"
  77. + " from sqmdb_rpt.acl_user a, sqmdb_rpt.acl_city c, sqmdb_rpt.acl_user_role ur "
  78. + " where a.user_id = ur.user_id and a.city_id = c.city_id"
  79. + "<if test=\"loginId != null and loginId !=''\">"
  80. + " and a.login_name=#{loginId} "
  81. + "</if>"
  82. + "<if test=\"roleId != null\">"
  83. + " and ur.role_id=#{roleId} "
  84. + "</if>"
  85. + "<if test=\"userName != null and userName !=''\">"
  86. + " and a.user_name like concat('%',#{userName},'%') "
  87. + "</if>"
  88. + "</script>")
  89. List<FlowUserVo> findAuthorizedUser(String loginId, Integer roleId, String userName);
  90. @Select("select * from sqmdb_rpt.acl_user where login_name=#{loginName} ")
  91. @Results({
  92. @Result(column = "city_id", property = "cityId"),
  93. @Result(column = "city_id", property = "city", one = @One(select = "com.nokia.dao.CityDao.findByCityId"))
  94. })
  95. UserEntity getByLoinName(String loginName);
  96. }