From b284d078f196af80a105dc3bcb610d8ed37d9251 Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Fri, 08 Nov 2019 11:49:29 +0800 Subject: [PATCH] update --- src/main/resources/mapper/AccountMapper.xml | 132 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 110 insertions(+), 22 deletions(-) diff --git a/src/main/resources/mapper/AccountMapper.xml b/src/main/resources/mapper/AccountMapper.xml index c7c2903..a7e353d 100644 --- a/src/main/resources/mapper/AccountMapper.xml +++ b/src/main/resources/mapper/AccountMapper.xml @@ -1,35 +1,56 @@ <?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"> + <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> + + <resultMap id="RoleResultMap" type="com.moral.entity.Role"> + <id column="id" property="id" jdbcType="INTEGER"/> + <result column="role_code" property="roleCode" jdbcType="VARCHAR"/> + <result column="role_name" property="roleName" jdbcType="VARCHAR"/> + <result column="is_delete" property="isDelete" jdbcType="CHAR"/> + <result column="role_remark" property="roleRemark" jdbcType="VARCHAR"/> + <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> + <result column="create_user" property="createUser" jdbcType="VARCHAR"/> + <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> + <result column="update_user" property="updateUser" jdbcType="VARCHAR"/> + </resultMap> + + <resultMap id="MenuResultMap" type="com.moral.entity.Menu"> + <id column="id" property="id" jdbcType="INTEGER"/> + <result column="menu_name" property="menuName" jdbcType="VARCHAR"/> + <result column="menu_icon" property="menuIcon" jdbcType="VARCHAR"/> + <result column="menu_url" property="menuUrl" jdbcType="VARCHAR"/> + <result column="menu_parent_id" property="menuParentId" jdbcType="INTEGER"/> + </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 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 id="getRoleNameByAccountId" resultType="java.util.Map"> SELECT r.role_name FROM @@ -39,8 +60,8 @@ ar.role_id = r.id AND ar.account_id = #{accountId} </select> - - <select id="getOrganizationIdByAccountId" resultType="java.util.Map"> + + <select id="getOrganizationIdByAccountId" resultType="java.util.Map"> SELECT organization_id FROM account WHERE id=#{id} @@ -55,4 +76,71 @@ and account_name like concat('%',#{accountName},'%') </if> </select> + + <select id="getRolesByAccountName" resultMap="RoleResultMap" parameterType="java.lang.String"> + select + r.* + from + role r + right join account_role ar on ar.role_id = r.id + right join account a on a.id = ar.account_id + where + a.account_name = #{accountName} and r.id is not null + </select> + + <select id="getParentMenuListsByAccountName" resultMap="MenuResultMap" parameterType="java.lang.String"> + select + DISTINCT + m.id,m.menu_name,m.menu_icon,m.menu_url,m.menu_order,m.menu_parent_id + from + menu m + right join role_menu rm on rm.channel_id = m.channel_id and rm.menu_id=m.id and m.channel_id=2 + right join role on rm.role_id in + ( + select + r.id + from + role r + right join + account_role ar on ar.role_id = r.id + right join + account a on a.id = ar.account_id + where + a.account_name = #{accountName} and r.is_delete=0 and r.id is not null + ) + where m.menu_parent_id=0 + order by m.menu_order + </select> + + <select id="getChildMenuIdsByAccountName" resultMap="MenuResultMap"> + select + DISTINCT + m.id,m.menu_name,m.menu_icon,m.menu_url,m.menu_order,m.menu_parent_id + from + menu m + right join role_menu rm on rm.channel_id = m.channel_id and rm.menu_id=m.id and m.channel_id=2 + right join role on rm.role_id in + ( + select + r.id + from + role r + right join + account_role ar on ar.role_id = r.id + right join + account a on a.id = ar.account_id + where + a.account_name = #{accountName} and r.is_delete=0 and r.id is not null + ) + where m.menu_parent_id = #{id} + order by m.menu_order + </select> + + <select id="getEmailByAccountName" resultType="java.lang.String"> + select + email + from account + where account_name = #{accountName} + </select> + </mapper> \ No newline at end of file -- Gitblit v1.8.0