|
|
@@ -25,11 +25,12 @@
|
|
|
<result column="type" jdbcType="INTEGER" property="type" />
|
|
|
<result column="reviewer" jdbcType="VARCHAR" property="reviewer" />
|
|
|
<result column="amb_id" jdbcType="VARCHAR" property="ambId" />
|
|
|
+ <result column="amb_role" jdbcType="VARCHAR" property="ambRole" />
|
|
|
</resultMap>
|
|
|
<sql id="Base_Column_List">
|
|
|
id, mobile, `name`, `password`, email, create_time, `number`, province, `position`,
|
|
|
superior_id, city, department_id, `status`, user_no, duty, district, head_portrait_url,
|
|
|
- contact_mobile, last_login_time, open_id, `type`, reviewer, amb_id
|
|
|
+ contact_mobile, last_login_time, open_id, `type`, reviewer, amb_id, amb_role
|
|
|
</sql>
|
|
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
|
|
|
select
|
|
|
@@ -49,7 +50,7 @@
|
|
|
user_no, duty, district,
|
|
|
head_portrait_url, contact_mobile, last_login_time,
|
|
|
open_id, `type`, reviewer,
|
|
|
- amb_id)
|
|
|
+ amb_id, amb_role)
|
|
|
values (#{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
|
|
|
#{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{number,jdbcType=INTEGER},
|
|
|
#{province,jdbcType=VARCHAR}, #{position,jdbcType=VARCHAR}, #{superiorId,jdbcType=VARCHAR},
|
|
|
@@ -57,7 +58,7 @@
|
|
|
#{userNo,jdbcType=VARCHAR}, #{duty,jdbcType=VARCHAR}, #{district,jdbcType=VARCHAR},
|
|
|
#{headPortraitUrl,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR}, #{lastLoginTime,jdbcType=TIMESTAMP},
|
|
|
#{openId,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{reviewer,jdbcType=VARCHAR},
|
|
|
- #{ambId,jdbcType=VARCHAR})
|
|
|
+ #{ambId,jdbcType=VARCHAR}, #{ambRole,jdbcType=VARCHAR})
|
|
|
</insert>
|
|
|
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.Admin" useGeneratedKeys="true">
|
|
|
insert into admin
|
|
|
@@ -128,6 +129,9 @@
|
|
|
<if test="ambId != null">
|
|
|
amb_id,
|
|
|
</if>
|
|
|
+ <if test="ambRole != null">
|
|
|
+ amb_role,
|
|
|
+ </if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="mobile != null">
|
|
|
@@ -196,6 +200,9 @@
|
|
|
<if test="ambId != null">
|
|
|
#{ambId,jdbcType=VARCHAR},
|
|
|
</if>
|
|
|
+ <if test="ambRole != null">
|
|
|
+ #{ambRole,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
</trim>
|
|
|
</insert>
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Admin">
|
|
|
@@ -267,6 +274,9 @@
|
|
|
<if test="ambId != null">
|
|
|
amb_id = #{ambId,jdbcType=VARCHAR},
|
|
|
</if>
|
|
|
+ <if test="ambRole != null">
|
|
|
+ amb_role = #{ambRole,jdbcType=VARCHAR},
|
|
|
+ </if>
|
|
|
</set>
|
|
|
where id = #{id,jdbcType=VARCHAR}
|
|
|
</update>
|
|
|
@@ -293,7 +303,8 @@
|
|
|
open_id = #{openId,jdbcType=VARCHAR},
|
|
|
`type` = #{type,jdbcType=INTEGER},
|
|
|
reviewer = #{reviewer,jdbcType=VARCHAR},
|
|
|
- amb_id = #{ambId,jdbcType=VARCHAR}
|
|
|
+ amb_id = #{ambId,jdbcType=VARCHAR},
|
|
|
+ amb_role = #{ambRole,jdbcType=VARCHAR}
|
|
|
where id = #{id,jdbcType=VARCHAR}
|
|
|
</update>
|
|
|
|
|
|
@@ -522,38 +533,35 @@
|
|
|
|
|
|
<!--*************************************************************************-->
|
|
|
<select id="selectAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo">
|
|
|
- select x.*,y.name as departmentName from(select
|
|
|
- <!-- a.user_no as userNo, -->
|
|
|
- a.mobile, a.name,
|
|
|
- a.position, a.email, a.id,
|
|
|
- a.province,
|
|
|
- a.city,
|
|
|
- a.create_time as createTime,
|
|
|
- aa.name as superior,
|
|
|
- a.superior_id as superiorId,
|
|
|
- a.department_id as departmentId,
|
|
|
- a.last_login_time as lastLoginTime,
|
|
|
- a.contact_mobile as contactMobile,
|
|
|
- a.duty,a.status,
|
|
|
- a.type
|
|
|
+ select a.id, a.mobile, a.name, a.position, a.email, a.province, a.city, a.create_time as createTime, aa.name as superior,dep.name departmentName,
|
|
|
+ a.superior_id as superiorId, a.department_id as departmentId, a.last_login_time as lastLoginTime, a.contact_mobile as contactMobile,
|
|
|
+ a.duty,a.status, a.type, ambs.id ambId,ambs.name ambName,ambs.ancestors_names ancestorsNames ,a.amb_role ambRole
|
|
|
from admin a
|
|
|
left join admin_location al on a.id = al.admin_id
|
|
|
left join admin aa on aa.id = a.superior_id
|
|
|
- left join user_role ur on a.id=ur.uid
|
|
|
- left join `role` y on ur.rid=y.id
|
|
|
- where a.id <![CDATA[ <> ]]> '1'
|
|
|
+ left join amb_system ambs on a.amb_id=ambs.id
|
|
|
+ left join department dep on a.department_id = dep.id
|
|
|
+ <if test="rid != null">
|
|
|
+ RIGHT join (select uid from user_role where rid=#{rid,jdbcType=VARCHAR}) ur on a.id=ur.uid
|
|
|
+ </if>
|
|
|
<if test="roleName != null">
|
|
|
- and y.role_name= #{roleName,jdbcType=VARCHAR}
|
|
|
+ left join user_role ur on a.id=ur.uid
|
|
|
+ RIGHT join (select id from role where role_name =#{roleName,jdbcType=VARCHAR}) y on ur.rid=y.id
|
|
|
+ </if>
|
|
|
+ <if test="ambManage ==0">
|
|
|
+ RIGHT join (select id from admin where(find_in_set( 5 ,amb_role) or find_in_set( 6 ,amb_role)))am on a.id !=am.id
|
|
|
</if>
|
|
|
+ <if test="ambManage ==1">
|
|
|
+ RIGHT join (select id from admin where(find_in_set( 5 ,amb_role) or find_in_set( 6 ,amb_role)))am on a.id =am.id
|
|
|
+ </if>
|
|
|
+ where a.status in (0,1)
|
|
|
<if test="name != null">
|
|
|
and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
|
|
|
</if>
|
|
|
<if test="departmentId != null">
|
|
|
and a.department_id = #{departmentId,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
- <if test="rid != null">
|
|
|
- and ur.rid = #{rid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
+
|
|
|
<if test="duty != null">
|
|
|
and a.duty = #{duty,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
@@ -569,30 +577,38 @@
|
|
|
<if test="superiorId != null">
|
|
|
and a.superior_id = #{superiorId,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
- group by a.id
|
|
|
- order by a.last_login_time,a.number )x left join department y on x.departmentId = y.id
|
|
|
+ <if test="ambId != null">
|
|
|
+ and a.amb_id = #{ambId}
|
|
|
+ </if>
|
|
|
+ <if test="ancestors != null">
|
|
|
+ and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
|
|
|
+ </if>
|
|
|
+ order by a.last_login_time desc
|
|
|
<if test="page_sql!=null">
|
|
|
${page_sql}
|
|
|
</if>
|
|
|
</select>
|
|
|
<select id="selectAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
|
|
|
- select count(t.counts)
|
|
|
- from(select a.id counts from (select a.id from admin a
|
|
|
- left join user_role ur on a.id=ur.uid
|
|
|
- left join `role` y on ur.rid=y.id
|
|
|
- where a.id <![CDATA[ <> ]]> '1'
|
|
|
+ select count(*)
|
|
|
+ from admin a
|
|
|
+ left join admin_location al on a.id = al.admin_id
|
|
|
+ left join admin aa on aa.id = a.superior_id
|
|
|
+ left join amb_system ambs on a.amb_id=ambs.id
|
|
|
+ left join department dep on a.department_id = dep.id
|
|
|
+ <if test="rid != null">
|
|
|
+ RIGHT join (select * from user_role where rid=#{rid,jdbcType=VARCHAR}) ur on a.id=ur.uid
|
|
|
+ </if>
|
|
|
<if test="roleName != null">
|
|
|
- and y.role_name= #{roleName,jdbcType=VARCHAR}
|
|
|
+ left join user_role ur on a.id=ur.uid
|
|
|
+ RIGHT join (select * from role where role_name =#{roleName,jdbcType=VARCHAR}) y on ur.rid=y.id
|
|
|
</if>
|
|
|
+ where a.status in (0,1)
|
|
|
<if test="name != null">
|
|
|
and a.name like concat('%',#{name,jdbcType=VARCHAR},'%')
|
|
|
</if>
|
|
|
<if test="departmentId != null">
|
|
|
and a.department_id = #{departmentId,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
- <if test="rid != null">
|
|
|
- and ur.rid = #{rid,jdbcType=VARCHAR}
|
|
|
- </if>
|
|
|
<if test="duty != null">
|
|
|
and a.duty = #{duty,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
@@ -608,8 +624,12 @@
|
|
|
<if test="superiorId != null">
|
|
|
and a.superior_id = #{superiorId,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
- )a
|
|
|
- group by a.id)t
|
|
|
+ <if test="ambId != null">
|
|
|
+ and a.amb_id = #{ambId}
|
|
|
+ </if>
|
|
|
+ <if test="ancestors != null">
|
|
|
+ and (ambs.id=#{ancestors} or find_in_set( #{ancestors} ,ambs.ancestors))
|
|
|
+ </if>
|
|
|
</select>
|
|
|
<insert id="insertn" parameterType="com.goafanti.common.model.Admin">
|
|
|
insert into admin (id, mobile, name,
|
|
|
@@ -659,21 +679,15 @@
|
|
|
where
|
|
|
id=#{id,jdbcType=VARCHAR}
|
|
|
</select>
|
|
|
- <select id="selectRolesByUid" parameterType="java.lang.String" resultType="java.lang.String">
|
|
|
+ <select id="selectRolesByUid" parameterType="com.goafanti.common.model.Role" resultType="com.goafanti.common.model.Role">
|
|
|
select
|
|
|
- r.role_name as roles
|
|
|
+ r.id,r.role_name as roleName
|
|
|
from user_role ur
|
|
|
left join role r on r.id = ur.rid
|
|
|
where
|
|
|
uid=#{id,jdbcType=VARCHAR}
|
|
|
</select>
|
|
|
- <select id="selectRolesIdByUid" parameterType="java.lang.String" resultType="java.lang.String">
|
|
|
- select
|
|
|
- rid as rolesId
|
|
|
- from user_role
|
|
|
- where
|
|
|
- uid=#{id,jdbcType=VARCHAR}
|
|
|
- </select>
|
|
|
+
|
|
|
<select id="selectStatusByMobile" parameterType="java.lang.String" resultType="java.lang.String">
|
|
|
select
|
|
|
status
|