UserDao.xml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.zglc.kg.dao.UserDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.zglc.kg.entity.UserEntity" id="userMap">
  6. <result property="id" column="id"/>
  7. <result property="userName" column="user_name"/>
  8. <result property="realName" column="real_name"/>
  9. <result property="password" column="password"/>
  10. <result property="departmentId" column="department_id"/>
  11. <result property="departmentName" column="department_name"/>
  12. <result property="roleId" column="role_id"/>
  13. <result property="roleName" column="role_name"/>
  14. <result property="sex" column="sex"/>
  15. <result property="birth" column="birth"/>
  16. <result property="img" column="img"/>
  17. <result property="isEnable" column="is_enable"/>
  18. <result property="remark" column="remark"/>
  19. </resultMap>
  20. <select id="listAll" resultMap="userMap">
  21. select id,user_name,real_name,password,department_id,department_name,role_id,role_name,sex,birth,img,is_enable,
  22. remark
  23. from t_user
  24. where id > 1
  25. </select>
  26. <select id="getCount" resultType="java.lang.Integer">
  27. select count(1)
  28. from t_user
  29. where id > 1
  30. </select>
  31. <select id="findByName" parameterType="String" resultMap="userMap">
  32. select id,user_name,real_name,password,department_id,department_name,role_id,role_name,sex,birth,img,is_enable,remark
  33. from t_user where user_name like #{name}
  34. and id > 1
  35. </select>
  36. <select id="findByUser" parameterType="com.zglc.kg.entity.UserEntity" resultMap="userMap">
  37. select id,user_name,real_name,password,department_id,department_name,role_id,role_name,sex,birth,img,is_enable,
  38. remark from t_user where 1=1
  39. <if test="userName != null">
  40. and user_name like (CONCAT(CONCAT('%',#{userName}),'%'))
  41. </if>
  42. <if test="departmentName != null">
  43. and department_name = #{departmentName}
  44. </if>
  45. <if test="roleName != null">
  46. and role_name = #{roleName}
  47. </if>
  48. <if test="sex != null">
  49. and sex = #{sex}
  50. </if>
  51. </select>
  52. </mapper>