TenantProxyInfoMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.ym.mec.biz.dal.dao.TenantProxyInfoDao">
  4. <resultMap id="BaseResultMap" type="com.ym.mec.biz.dal.entity.TenantProxyInfo">
  5. <id column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="proxy_name_" jdbcType="VARCHAR" property="proxyName"/>
  7. <result column="proxy_user_id_" jdbcType="INTEGER" property="proxyUserId"/>
  8. <result column="state_" jdbcType="INTEGER" property="state"/>
  9. <result column="create_by_" jdbcType="INTEGER" property="createBy"/>
  10. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  11. </resultMap>
  12. <sql id="Base_Column_List">
  13. id_
  14. , proxy_name_, proxy_user_id_, state_, create_by_, create_time_
  15. </sql>
  16. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  17. parameterType="com.ym.mec.biz.dal.entity.TenantProxyInfo">
  18. insert into tenant_proxy_info(proxy_name_, proxy_user_id_, state_, create_by_, create_time_)
  19. values
  20. <foreach collection="entities" item="entity" separator=",">
  21. (#{entity.proxyName}, #{entity.proxyUserId}, #{entity.state}, #{entity.createBy}, #{entity.createTime})
  22. </foreach>
  23. </insert>
  24. <!-- 向数据库增加一条记录 -->
  25. <insert id="insertProxySysUser" parameterType="com.ym.mec.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
  26. keyProperty="id">
  27. INSERT INTO sys_user
  28. (tenant_id_,username_,phone_,password_,create_time_,user_type_,real_name_)
  29. VALUES(#{tenantId},#{username},#{phone},#{password},now(),#{userType},#{realName})
  30. </insert>
  31. <update id="updateProxySysUserLock" parameterType="object">
  32. update sys_user set lock_flag_ = #{lock} where id_ = #{id}
  33. </update>
  34. <update id="updateSysUserPhone" parameterType="object">
  35. update sys_user
  36. set phone_ = #{phone},
  37. username_ = #{name},
  38. real_name_ = #{name}
  39. where id_ = #{id}
  40. </update>
  41. <select id="queryProxyUserStaff" resultType="com.ym.mec.biz.dal.vo.ProxyUserVo">
  42. select
  43. b.id_ as userId,
  44. a.parent_id_ as parentId,
  45. c.id_ as proxyId,
  46. c.proxy_name_ as proxyName,
  47. b.real_name_ as `name`,
  48. b.phone_ as `phone`,
  49. '员工' as `role`,
  50. c.state_ as state
  51. from tenant_proxy_user_relation as a
  52. left join tenant_proxy_info as c on a.parent_id_ = c.proxy_user_id_
  53. left join sys_user as b on a.user_id_ = b.id_
  54. where a.parent_id_ = #{id}
  55. </select>
  56. <select id="queryProxyUser" parameterType="map" resultType="com.ym.mec.biz.dal.vo.ProxyUserVo">
  57. select
  58. b.id_ as userId,
  59. c.id_ as proxyId,
  60. c.proxy_name_ as proxyName,
  61. b.real_name_ as `name`,
  62. b.phone_ as `phone`,
  63. '负责人' as `role`,
  64. c.state_ as state
  65. from tenant_proxy_user_relation as a
  66. left join tenant_proxy_info as c on a.user_id_ = c.proxy_user_id_
  67. left join sys_user as b on a.user_id_ = b.id_
  68. <where>
  69. a.parent_id_ is null
  70. <if test="param.state != null ">
  71. AND c.state_ = #{param.state}
  72. </if>
  73. <if test="param.search != null ">
  74. AND (
  75. c.proxy_name_ LIKE CONCAT('%', #{param.search},'%')
  76. OR b.`real_name_` LIKE CONCAT('%', #{param.search},'%')
  77. OR b.`phone_` LIKE CONCAT('%', #{param.search},'%')
  78. )
  79. </if>
  80. </where>
  81. </select>
  82. <select id="queryUserList" parameterType="map" resultType="com.ym.mec.auth.api.entity.SysUser">
  83. select id_ as id,
  84. real_name_ as realName,
  85. phone_ as phone
  86. from sys_user
  87. where tenant_id_ = -1
  88. <if test="param.id != null ">
  89. AND id_ = #{param.id}
  90. </if>
  91. <if test="param.search != null and param.search != ''">
  92. AND (
  93. `real_name_` LIKE CONCAT('%', #{param.search},'%')
  94. OR `phone_` LIKE CONCAT('%', #{param.search},'%')
  95. )
  96. </if>
  97. </select>
  98. </mapper>