lizijie
2019-08-08 a6ff89dd8eed9ea4e6162ff5491d4583e4ef621a
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
<?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.moral.mapper.AccountMapper">
  <resultMap id="BaseResultMap" type="com.moral.entity.Account">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="account_name" jdbcType="VARCHAR" property="accountName" />
    <result column="password" jdbcType="VARCHAR" property="password" />
    <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    <result column="weixin" jdbcType="VARCHAR" property="weixin" />
    <result column="is_delete" jdbcType="CHAR" property="isDelete" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
      <association property="jwtTokenVersion" javaType="com.moral.entity.JwtTokenVersion">
          <result column="jwt_token_version_id" property="id" jdbcType="INTEGER" />
          <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
      </association>
  </resultMap>
  <sql id="Base_Column_List">
    id, account_name, password, organization_id, email, mobile, weixin, is_delete, create_time, 
    expire_time, user_name
  </sql>
  <select id="getByAccountName" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
      acc.*,jtv.id as jwt_token_version_id,jtv.update_time as update_time
    from account acc
    left join jwt_token_version jtv on acc.account_name = jtv.account_name
    where acc.account_name = #{name,jdbcType=VARCHAR}
   </select>
    <select id="getRoleNameByAccountId" resultType="java.util.Map">
        SELECT
            r.role_name
        FROM
            role r,
            account_role ar
        WHERE
            ar.role_id = r.id
        AND ar.account_id = #{accountId}
    </select>
</mapper>