AccountMapperEx.xml 5.0 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.boco.nbd.wios.manage.mapper.def.AccountMapperEx" >
  <resultMap id="BaseResultMap" type="com.boco.nbd.wios.manage.entity.bo.Account" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon May 18 18:39:09 CST 2020.
    -->
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="account" property="account" jdbcType="VARCHAR" />
    <result column="password" property="password" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="job_number" property="jobNumber" jdbcType="VARCHAR" />
    <result column="email" property="email" jdbcType="VARCHAR" />
    <result column="user_id" property="userId" jdbcType="VARCHAR" />
    <result column="status" property="status" jdbcType="INTEGER" />
    <result column="virtual_balance" property="virtualBalance" jdbcType="DECIMAL" />
    <result column="power" property="power" jdbcType="DECIMAL" />
    <result column="charge_electric" property="chargeElectric" jdbcType="DECIMAL" />
    <result column="last_login_time" property="lastLoginTime" jdbcType="TIMESTAMP" />
    <result column="create_account_id" property="createAccountId" jdbcType="INTEGER" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Mon May 18 18:39:09 CST 2020.
    -->
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    id, account, password, name, phone, job_number, email, user_id , status, virtual_balance, power,
    charge_electric, last_login_time, create_account_id, create_time, update_time
  </sql>
  <select id="selectByPrimaryKeyForUpdate" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from wb_account
    where id = #{id,jdbcType=INTEGER}
    for update
  </select>

  <select id="getListForOem" parameterType="com.boco.nbd.wios.manage.entity.bo.AccountBo"
        resultType="com.boco.nbd.wios.manage.entity.bo.AccountVo">
   select t.*,o.name as oemName,o.id as oemId from wb_account t
   inner join t_oem o on t.id=o.wb_account_id
   <where>
	    <if test="phone != null and account !=''">
	        and t.phone = #{phone}
	    </if>
	    <if test="oemId != null">
	        and o.id = #{oemId}
	    </if>
	    <if test="type != null">
	        and o.type = #{type}
	    </if>
   </where>
	</select>

	<select id="selectByIds"
        resultType="com.boco.nbd.wios.manage.entity.bo.Account">
	   select t.* from wb_account t
	   where t.id in
	  <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
		#{item}
	  </foreach>
	</select>

	<select id="selectByParentIds"
        resultType="com.boco.nbd.wios.manage.entity.bo.AccountVo">
	   select t.*,war.role_id as roleId,wr.name as roleName from wb_account t
	   left join wb_account_role war on war.account_id = t.id
	   left join wb_role wr on wr.id = war.role_id
	   where (
	      t.parent_id in
		  <foreach collection="parentIds" item="item" index="index" open="(" close=")" separator=",">
			#{item}
		  </foreach>
		  or
		  t.id in
		  <foreach collection="parentIds" item="item" index="index" open="(" close=")" separator=",">
			#{item}
		  </foreach>
		)
	    <if test="account != null and account !=''">
	        and t.account = #{account}
	    </if>
	    <if test="name != null and name != ''">
	        <bind name="nameLike" value="'%' + name + '%'"/>
	        and t.name like #{nameLike}
	    </if>
	</select>

</mapper>