|
|
@@ -11,10 +11,11 @@
|
|
|
<result property="superId" column="super_id" jdbcType="INTEGER"/>
|
|
|
<result property="status" column="status" jdbcType="INTEGER"/>
|
|
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
|
+ <result property="ancestors" column="ancestors" jdbcType="VARCHAR"/>
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="SalesTeamAllSql">
|
|
|
- id, name, aid, lvl, dep_id, super_id, status, create_time
|
|
|
+ id, name, aid, lvl, dep_id, super_id, status, create_time, ancestors
|
|
|
</sql>
|
|
|
|
|
|
<!--查询单个-->
|
|
|
@@ -26,23 +27,38 @@
|
|
|
</select>
|
|
|
|
|
|
<!--查询指定行数据-->
|
|
|
- <select id="findSalesTeamList" resultType="com.goafanti.admin.bo.SalesTeamBo">
|
|
|
- select a.id, a.name, a.aid, a.lvl, a.dep_id depId, a.super_id superId, a.status, a.create_time createTime,
|
|
|
- b.name adminName,c.name depName,d.name superName
|
|
|
- from sales_team a left join admin b on a.aid=b.id left join department c on a.dep_id=c.id
|
|
|
- left join sales_team d on a.super_id=d.id
|
|
|
+ <select id="findSalesTeamList" resultMap="SalesTeamMap">
|
|
|
+ select
|
|
|
+ <include refid="SalesTeamAllSql"/>
|
|
|
+
|
|
|
+ from sales_team
|
|
|
<where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ and name = #{name}
|
|
|
+ </if>
|
|
|
<if test="aid != null and aid != ''">
|
|
|
- and a.aid = #{aid}
|
|
|
+ and aid = #{aid}
|
|
|
+ </if>
|
|
|
+ <if test="lvl != null">
|
|
|
+ and lvl = #{lvl}
|
|
|
</if>
|
|
|
<if test="depId != null and depId != ''">
|
|
|
- and a.dep_id = #{depId}
|
|
|
+ and dep_id = #{depId}
|
|
|
+ </if>
|
|
|
+ <if test="superId != null">
|
|
|
+ and super_id = #{superId}
|
|
|
</if>
|
|
|
<if test="status != null">
|
|
|
- and a.status = #{status}
|
|
|
+ and status = #{status}
|
|
|
</if>
|
|
|
- <if test="lvl!= null">
|
|
|
- and a.lvl = #{lvl}
|
|
|
+ <if test="createTime != null">
|
|
|
+ and create_time = #{createTime}
|
|
|
+ </if>
|
|
|
+ <if test="ancestors != null and ancestors != ''">
|
|
|
+ and ancestors = #{ancestors}
|
|
|
</if>
|
|
|
</where>
|
|
|
<if test="page_sql != null">
|
|
|
@@ -53,45 +69,59 @@
|
|
|
<!--统计总行数-->
|
|
|
<select id="findSalesTeamCount" resultType="java.lang.Integer">
|
|
|
select count(1)
|
|
|
- from sales_team a
|
|
|
+ from sales_team
|
|
|
<where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="name != null and name != ''">
|
|
|
+ and name = #{name}
|
|
|
+ </if>
|
|
|
<if test="aid != null and aid != ''">
|
|
|
- and a.aid = #{aid}
|
|
|
+ and aid = #{aid}
|
|
|
+ </if>
|
|
|
+ <if test="lvl != null">
|
|
|
+ and lvl = #{lvl}
|
|
|
</if>
|
|
|
<if test="depId != null and depId != ''">
|
|
|
- and a.dep_id = #{depId}
|
|
|
+ and dep_id = #{depId}
|
|
|
+ </if>
|
|
|
+ <if test="superId != null">
|
|
|
+ and super_id = #{superId}
|
|
|
</if>
|
|
|
<if test="status != null">
|
|
|
- and a.status = #{status}
|
|
|
+ and status = #{status}
|
|
|
</if>
|
|
|
- <if test="lvl!= null">
|
|
|
- and a.lvl = #{lvl}
|
|
|
+ <if test="createTime != null">
|
|
|
+ and create_time = #{createTime}
|
|
|
+ </if>
|
|
|
+ <if test="ancestors != null and ancestors != ''">
|
|
|
+ and ancestors = #{ancestors}
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
-
|
|
|
<!--新增所有列-->
|
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
- insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time)
|
|
|
- values (#{name}, #{aid}, #{lvl}, #{depId}, #{superId}, #{status}, #{createTime})
|
|
|
+ insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time, ancestors)
|
|
|
+ values (#{name}, #{aid}, #{lvl}, #{depId}, #{superId}, #{status}, #{createTime}, #{ancestors})
|
|
|
</insert>
|
|
|
|
|
|
<insert id="insertBatch">
|
|
|
- insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time)
|
|
|
+ insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time, ancestors)
|
|
|
values
|
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
|
(#{entity.name}, #{entity.aid}, #{entity.lvl}, #{entity.depId}, #{entity.superId}, #{entity.status},
|
|
|
- #{entity.createTime})
|
|
|
+ #{entity.createTime}, #{entity.ancestors})
|
|
|
</foreach>
|
|
|
</insert>
|
|
|
|
|
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
- insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time)
|
|
|
+ insert into sales_team(name, aid, lvl, dep_id, super_id, status, create_time, ancestors)
|
|
|
values
|
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
|
(#{entity.name}, #{entity.aid}, #{entity.lvl}, #{entity.depId}, #{entity.superId}, #{entity.status},
|
|
|
- #{entity.createTime})
|
|
|
+ #{entity.createTime}, #{entity.ancestors})
|
|
|
</foreach>
|
|
|
on duplicate key update
|
|
|
name = values(name),
|
|
|
@@ -100,7 +130,8 @@
|
|
|
dep_id = values(dep_id),
|
|
|
super_id = values(super_id),
|
|
|
status = values(status),
|
|
|
- create_time = values(create_time)
|
|
|
+ create_time = values(create_time),
|
|
|
+ ancestors = values(ancestors)
|
|
|
</insert>
|
|
|
|
|
|
<!--通过主键修改数据-->
|
|
|
@@ -128,6 +159,9 @@
|
|
|
<if test="createTime != null">
|
|
|
create_time = #{createTime},
|
|
|
</if>
|
|
|
+ <if test="ancestors != null and ancestors != ''">
|
|
|
+ ancestors = #{ancestors},
|
|
|
+ </if>
|
|
|
</set>
|
|
|
where id = #{id}
|
|
|
</update>
|
|
|
@@ -180,6 +214,7 @@
|
|
|
<select id="queryByAncestors" resultType="java.lang.Integer">
|
|
|
select id
|
|
|
from sales_team
|
|
|
+ where find_in_set(#{id},ancestors)
|
|
|
</select>
|
|
|
</mapper>
|
|
|
|