From 208ad71314820e8680cf9b202c1a48d0aaf5ef92 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Thu, 27 Aug 2020 17:42:34 +0800
Subject: [PATCH] 更新O3保良值
---
src/main/resources/mapper/AccountMapper.xml | 457 +++++++++++++++++++++------------------------------------
1 files changed, 169 insertions(+), 288 deletions(-)
diff --git a/src/main/resources/mapper/AccountMapper.xml b/src/main/resources/mapper/AccountMapper.xml
index 6279878..f981613 100644
--- a/src/main/resources/mapper/AccountMapper.xml
+++ b/src/main/resources/mapper/AccountMapper.xml
@@ -1,295 +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">
+<?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" />
- </resultMap>
- <sql id="Example_Where_Clause">
- <where>
- <foreach collection="oredCriteria" item="criteria" separator="or">
- <if test="criteria.valid">
- <trim prefix="(" prefixOverrides="and" suffix=")">
- <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </when>
- </choose>
- </foreach>
- </trim>
- </if>
- </foreach>
- </where>
- </sql>
- <sql id="Update_By_Example_Where_Clause">
- <where>
- <foreach collection="example.oredCriteria" item="criteria" separator="or">
- <if test="criteria.valid">
- <trim prefix="(" prefixOverrides="and" suffix=")">
- <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </when>
- </choose>
- </foreach>
- </trim>
- </if>
- </foreach>
- </where>
- </sql>
- <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
+ expire_time, user_name
</sql>
- <select id="selectByExample" parameterType="com.moral.entity.AccountExample" resultMap="BaseResultMap">
- select
- <if test="distinct">
- distinct
- </if>
- <include refid="Base_Column_List" />
- from account
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
- </select>
- <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+ <select id="getByAccountName" parameterType="java.lang.String" resultMap="BaseResultMap">
select
- <include refid="Base_Column_List" />
- from account
- where id = #{id,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from account
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <delete id="deleteByExample" parameterType="com.moral.entity.AccountExample">
- delete from account
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </delete>
- <insert id="insert" parameterType="com.moral.entity.Account">
- insert into account (id, account_name, password,
- organization_id, email, mobile,
- weixin, is_delete, create_time,
- expire_time)
- values (#{id,jdbcType=INTEGER}, #{accountName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
- #{organizationId,jdbcType=INTEGER}, #{email,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
- #{weixin,jdbcType=VARCHAR}, #{isDelete,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP},
- #{expireTime,jdbcType=TIMESTAMP})
- </insert>
- <insert id="insertSelective" parameterType="com.moral.entity.Account">
- insert into account
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="accountName != null">
- account_name,
- </if>
- <if test="password != null">
- password,
- </if>
- <if test="organizationId != null">
- organization_id,
- </if>
- <if test="email != null">
- email,
- </if>
- <if test="mobile != null">
- mobile,
- </if>
- <if test="weixin != null">
- weixin,
- </if>
- <if test="isDelete != null">
- is_delete,
- </if>
- <if test="createTime != null">
- create_time,
- </if>
- <if test="expireTime != null">
- expire_time,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=INTEGER},
- </if>
- <if test="accountName != null">
- #{accountName,jdbcType=VARCHAR},
- </if>
- <if test="password != null">
- #{password,jdbcType=VARCHAR},
- </if>
- <if test="organizationId != null">
- #{organizationId,jdbcType=INTEGER},
- </if>
- <if test="email != null">
- #{email,jdbcType=VARCHAR},
- </if>
- <if test="mobile != null">
- #{mobile,jdbcType=VARCHAR},
- </if>
- <if test="weixin != null">
- #{weixin,jdbcType=VARCHAR},
- </if>
- <if test="isDelete != null">
- #{isDelete,jdbcType=CHAR},
- </if>
- <if test="createTime != null">
- #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="expireTime != null">
- #{expireTime,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <select id="countByExample" parameterType="com.moral.entity.AccountExample" resultType="java.lang.Integer">
- select count(*) from account
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </select>
- <update id="updateByExampleSelective" parameterType="map">
- update account
- <set>
- <if test="record.id != null">
- id = #{record.id,jdbcType=INTEGER},
- </if>
- <if test="record.accountName != null">
- account_name = #{record.accountName,jdbcType=VARCHAR},
- </if>
- <if test="record.password != null">
- password = #{record.password,jdbcType=VARCHAR},
- </if>
- <if test="record.organizationId != null">
- organization_id = #{record.organizationId,jdbcType=INTEGER},
- </if>
- <if test="record.email != null">
- email = #{record.email,jdbcType=VARCHAR},
- </if>
- <if test="record.mobile != null">
- mobile = #{record.mobile,jdbcType=VARCHAR},
- </if>
- <if test="record.weixin != null">
- weixin = #{record.weixin,jdbcType=VARCHAR},
- </if>
- <if test="record.isDelete != null">
- is_delete = #{record.isDelete,jdbcType=CHAR},
- </if>
- <if test="record.createTime != null">
- create_time = #{record.createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="record.expireTime != null">
- expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
- </if>
- </set>
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByExample" parameterType="map">
- update account
- set id = #{record.id,jdbcType=INTEGER},
- account_name = #{record.accountName,jdbcType=VARCHAR},
- password = #{record.password,jdbcType=VARCHAR},
- organization_id = #{record.organizationId,jdbcType=INTEGER},
- email = #{record.email,jdbcType=VARCHAR},
- mobile = #{record.mobile,jdbcType=VARCHAR},
- weixin = #{record.weixin,jdbcType=VARCHAR},
- is_delete = #{record.isDelete,jdbcType=CHAR},
- create_time = #{record.createTime,jdbcType=TIMESTAMP},
- expire_time = #{record.expireTime,jdbcType=TIMESTAMP}
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByPrimaryKeySelective" parameterType="com.moral.entity.Account">
- update account
- <set>
- <if test="accountName != null">
- account_name = #{accountName,jdbcType=VARCHAR},
- </if>
- <if test="password != null">
- password = #{password,jdbcType=VARCHAR},
- </if>
- <if test="organizationId != null">
- organization_id = #{organizationId,jdbcType=INTEGER},
- </if>
- <if test="email != null">
- email = #{email,jdbcType=VARCHAR},
- </if>
- <if test="mobile != null">
- mobile = #{mobile,jdbcType=VARCHAR},
- </if>
- <if test="weixin != null">
- weixin = #{weixin,jdbcType=VARCHAR},
- </if>
- <if test="isDelete != null">
- is_delete = #{isDelete,jdbcType=CHAR},
- </if>
- <if test="createTime != null">
- create_time = #{createTime,jdbcType=TIMESTAMP},
- </if>
- <if test="expireTime != null">
- expire_time = #{expireTime,jdbcType=TIMESTAMP},
- </if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.moral.entity.Account">
- update account
- set account_name = #{accountName,jdbcType=VARCHAR},
- password = #{password,jdbcType=VARCHAR},
- organization_id = #{organizationId,jdbcType=INTEGER},
- email = #{email,jdbcType=VARCHAR},
- mobile = #{mobile,jdbcType=VARCHAR},
- weixin = #{weixin,jdbcType=VARCHAR},
- is_delete = #{isDelete,jdbcType=CHAR},
- create_time = #{createTime,jdbcType=TIMESTAMP},
- expire_time = #{expireTime,jdbcType=TIMESTAMP}
- where id = #{id,jdbcType=INTEGER}
- </update>
-
- <select id="getRoleNameByAccountId" resultType="map">
+ 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
@@ -299,4 +60,124 @@
ar.role_id = r.id
AND ar.account_id = #{accountId}
</select>
+
+ <select id="getOrganizationIdByAccountId" resultType="java.util.Map">
+ SELECT organization_id
+ FROM account
+ WHERE id=#{id}
+ </select>
+
+ <select id="getAccountList" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List"/>
+ from account
+ where is_delete=0 and expire_time > now()
+ <if test="accountName != 'null'">
+ 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="getScreenRoleByAccountName" resultType="int">
+ SELECT channel_id
+ from
+ (select DISTINCT channel_id FROM role_menu
+ WHERE 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.id is not null)) s
+ where s.channel_id=1;
+ </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 and m.is_delete=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} and m.is_delete=0
+ order by m.menu_order
+ </select>
+
+ <select id="getEmailByAccountName" resultType="java.lang.String">
+ select
+ email
+ from account
+ where account_name = #{accountName}
+ </select>
+
+ <select id="getScreenMenuListsByAccountName" 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=1
+ 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 and m.is_delete=0
+ order by m.menu_order
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0