UserInfoMapper.xml 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.abi.qms.platform.dao.mapper.UserInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.abi.qms.platform.dao.entity.UserInfo">
  6. <id column="ID" property="id"/>
  7. <result column="USER_NAME" property="userName"/>
  8. <result column="EMPLOYEE_NO" property="employeeNo"/>
  9. <result column="PHONE" property="phone"/>
  10. <result column="EMAIL" property="email"/>
  11. <result column="LOGIN_NAME" property="loginName"/>
  12. <result column="PASSWORD" property="password"/>
  13. <result column="is_abi" property="isAbi"/>
  14. <result column="factory_id" property="factoryId"/>
  15. <result column="factory_type" property="factoryType"/>
  16. <result column="is_enable" property="isEnable"/>
  17. <result column="role_code" property="roleCode"/>
  18. <result column="link_flag" property="linkFlag"/>
  19. <result column="CREATE_TIME" property="createTime"/>
  20. <result column="CREATE_BY" property="createBy"/>
  21. <result column="UPDATE_TIME" property="updateTime"/>
  22. <result column="IS_DELETE" property="isDelete"/>
  23. </resultMap>
  24. <!-- 通用查询结果列 -->
  25. <sql id="Base_Column_List">
  26. id, user_name, employee_no, phone, email, login_name, password, is_abi, factory_id, factory_type, role_code, is_enable, create_time, create_by, update_time, is_delete
  27. </sql>
  28. <!--列表查询列-->
  29. <sql id="Base_Column_List_Page">
  30. u.ID, u.USER_NAME, u.EMPLOYEE_NO, u.PHONE, u.EMAIL, f.factory_name, r.role_name, u.is_enable, u.update_time
  31. </sql>
  32. <select id="selectUserInfoPage" resultType="com.abi.qms.platform.dto.res.entity.UserInfoResp">
  33. SELECT
  34. <include refid="Base_Column_List_Page"/>
  35. from user_info u
  36. LEFT JOIN base_factory f ON u.factory_id = f.id
  37. LEFT JOIN user_role r ON u.role_code = r.role_code
  38. WHERE 1=1
  39. <if test="req.linkFlag != null and req.linkFlag != ''">
  40. AND u.link_flag LIKE CONCAT('%',#{req.linkFlag},'%')
  41. </if>
  42. <if test="req.userName != null and req.userName != ''">
  43. AND u.USER_NAME LIKE CONCAT('%',#{req.userName},'%')
  44. </if>
  45. <if test="req.employeeNo != null and req.employeeNo != ''">
  46. AND u.EMPLOYEE_NO LIKE CONCAT('%',#{req.employeeNo},'%')
  47. </if>
  48. <if test="req.roleCode != null and req.roleCode != ''">
  49. AND r.role_code = #{req.roleCode}
  50. </if>
  51. <if test="req.isEnable != null">
  52. AND u.is_enable = #{req.isEnable}
  53. </if>
  54. and u.is_delete = 0
  55. order by u.UPDATE_TIME desc
  56. </select>
  57. <!--批量启用/停用用户-->
  58. <update id="batchEnableUser">
  59. update user_info
  60. set is_enable =#{isEnable}
  61. where id in
  62. <foreach collection="ids" open="(" close=")" separator="," item="id">
  63. #{id}
  64. </foreach>
  65. and is_delete = 0
  66. </update>
  67. <!--根据rolecode查询该角色下启用中的用户-->
  68. <select id="selectUserInfoByRoleCodeEnable" resultMap="BaseResultMap">
  69. SELECT
  70. <include refid="Base_Column_List"/>
  71. from user_info
  72. WHERE role_code = #{roleCode} AND is_enable = 1 and is_delete = 0
  73. </select>
  74. </mapper>