|
|
@@ -12,12 +12,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<result property="extensionPass" column="extension_pass" />
|
|
|
<result property="extId" column="ext_id" />
|
|
|
<result property="userCode" column="user_code" />
|
|
|
+ <result property="status" column="status" />
|
|
|
+ <result property="isDel" column="is_del" />
|
|
|
<result property="createTime" column="create_time" />
|
|
|
<result property="createBy" column="create_by" />
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectCompanyExtensionBindVo">
|
|
|
- select id, company_id, company_user_id, extension_num, extension_pass, ext_id, user_code, create_time, create_by from company_extension_bind
|
|
|
+ select id, company_id, company_user_id, extension_num, extension_pass, ext_id, user_code, status, is_del, create_time, create_by, update_time from company_extension_bind
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectCompanyExtensionBindList" parameterType="CompanyExtensionBind" resultMap="CompanyExtensionBindResult">
|
|
|
@@ -29,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="extensionPass != null and extensionPass != ''"> and extension_pass = #{extensionPass}</if>
|
|
|
<if test="extId != null "> and ext_id = #{extId}</if>
|
|
|
<if test="userCode != null and userCode != ''"> and user_code = #{userCode}</if>
|
|
|
+ and (is_del = 0 or is_del is null)
|
|
|
</where>
|
|
|
</select>
|
|
|
|
|
|
@@ -46,6 +50,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="extensionPass != null">extension_pass,</if>
|
|
|
<if test="extId != null">ext_id,</if>
|
|
|
<if test="userCode != null">user_code,</if>
|
|
|
+ <if test="status != null">status,</if>
|
|
|
+ <if test="isDel != null">is_del,</if>
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
</trim>
|
|
|
@@ -56,6 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<if test="extensionPass != null">#{extensionPass},</if>
|
|
|
<if test="extId != null">#{extId},</if>
|
|
|
<if test="userCode != null">#{userCode},</if>
|
|
|
+ <if test="status != null">#{status},</if>
|
|
|
+ <if test="isDel != null">#{isDel},</if>
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
</trim>
|
|
|
@@ -88,21 +96,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</delete>
|
|
|
|
|
|
<insert id="batchInsertCompanyExtensionBind" parameterType="java.util.List">
|
|
|
- insert into company_extension_bind (company_id, company_user_id, extension_num, extension_pass, ext_id, user_code, create_time)
|
|
|
+ insert into company_extension_bind (company_id, company_user_id, extension_num, extension_pass, ext_id, user_code, status, is_del, create_time, create_by)
|
|
|
values
|
|
|
<foreach item="item" collection="list" separator=",">
|
|
|
- (#{item.companyId}, #{item.companyUserId}, #{item.extensionNum}, #{item.extensionPass}, #{item.extId}, #{item.userCode}, #{item.createTime})
|
|
|
+ (#{item.companyId}, #{item.companyUserId}, #{item.extensionNum}, #{item.extensionPass}, #{item.extId}, #{item.userCode}, #{item.status}, #{item.isDel}, #{item.createTime}, #{item.createBy})
|
|
|
</foreach>
|
|
|
</insert>
|
|
|
|
|
|
<select id="selectUnBindByCompanyId" resultMap="CompanyExtensionBindResult">
|
|
|
<include refid="selectCompanyExtensionBindVo"/>
|
|
|
where company_id = #{companyId} and (company_user_id is null or company_user_id = 0)
|
|
|
+ and status = 1 and (is_del = 0 or is_del is null)
|
|
|
</select>
|
|
|
|
|
|
<select id="selectUnBindAndSelfByCompanyId" resultMap="CompanyExtensionBindResult">
|
|
|
<include refid="selectCompanyExtensionBindVo"/>
|
|
|
where company_id = #{companyId} and (company_user_id is null or company_user_id =#{companyUserId})
|
|
|
+ and status = 1 and (is_del = 0 or is_del is null)
|
|
|
</select>
|
|
|
|
|
|
<update id="updateBindByExtId">
|
|
|
@@ -113,7 +123,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
|
<select id="selectByExtNumAndCompanyId" resultMap="CompanyExtensionBindResult">
|
|
|
<include refid="selectCompanyExtensionBindVo"/>
|
|
|
- where extension_num = #{extensionNum} and company_id = #{companyId}
|
|
|
+ where extension_num = #{extensionNum}
|
|
|
+ and company_id = #{companyId}
|
|
|
+ and company_id > 0
|
|
|
+ and status = 1
|
|
|
+ and (is_del = 0 or is_del is null)
|
|
|
</select>
|
|
|
|
|
|
<update id="clearBindByExtNum">
|
|
|
@@ -140,5 +154,148 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
left join company_user t2 on t1.company_user_id = t2.user_id
|
|
|
WHERE
|
|
|
t1.company_id = #{companyId}
|
|
|
+ and t1.status = 1 and (t1.is_del = 0 or t1.is_del is null)
|
|
|
</select>
|
|
|
+
|
|
|
+ <update id="updateStatusByExtId">
|
|
|
+ update company_extension_bind
|
|
|
+ set status = #{status}, update_time = now()
|
|
|
+ where ext_id = #{extId} and (is_del = 0 or is_del is null)
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="batchUpdateStatusByExtIds">
|
|
|
+ update company_extension_bind
|
|
|
+ set status = #{status}, update_time = now()
|
|
|
+ where (is_del = 0 or is_del is null) and ext_id in
|
|
|
+ <foreach collection="extIds" item="extId" open="(" separator="," close=")">
|
|
|
+ #{extId}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="logicDeleteByExtId">
|
|
|
+ update company_extension_bind
|
|
|
+ set is_del = 1, update_time = now()
|
|
|
+ where ext_id = #{extId} and (is_del = 0 or is_del is null)
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="batchLogicDeleteByExtIds">
|
|
|
+ update company_extension_bind
|
|
|
+ set is_del = 1, update_time = now()
|
|
|
+ where (is_del = 0 or is_del is null) and ext_id in
|
|
|
+ <foreach collection="extIds" item="extId" open="(" separator="," close=")">
|
|
|
+ #{extId}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <sql id="saasVoiceSeatWhere">
|
|
|
+ and (t.is_del = 0 or t.is_del is null)
|
|
|
+ <if test="extensionNum != null and extensionNum != ''">
|
|
|
+ and t.extension_num like concat('%', #{extensionNum}, '%')
|
|
|
+ </if>
|
|
|
+ <if test="status != null">
|
|
|
+ and t.status = #{status}
|
|
|
+ </if>
|
|
|
+ <if test="companyId != null">
|
|
|
+ and t.company_id = #{companyId}
|
|
|
+ </if>
|
|
|
+ <if test="assignStatus != null and assignStatus == 0">
|
|
|
+ and t.company_id = 0
|
|
|
+ </if>
|
|
|
+ <if test="assignStatus != null and assignStatus == 1">
|
|
|
+ and t.company_id > 0
|
|
|
+ </if>
|
|
|
+ <if test="companyName != null and companyName != ''">
|
|
|
+ and (
|
|
|
+ (t.company_id = 0 and '租户分机池' like concat('%', #{companyName}, '%'))
|
|
|
+ or c.company_name like concat('%', #{companyName}, '%')
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectSaasVoiceSeatList" resultType="com.fs.company.vo.SaasVoiceSeatVO">
|
|
|
+ select
|
|
|
+ t.id,
|
|
|
+ t.company_id as companyId,
|
|
|
+ case when t.company_id = 0 then '租户分机池' else c.company_name end as companyName,
|
|
|
+ t.company_user_id as companyUserId,
|
|
|
+ cu.nick_name as companyUserName,
|
|
|
+ t.extension_num as extensionNum,
|
|
|
+ t.extension_pass as extensionPass,
|
|
|
+ t.ext_id as extId,
|
|
|
+ t.user_code as userCode,
|
|
|
+ t.status,
|
|
|
+ t.create_time as createTime,
|
|
|
+ t.update_time as updateTime
|
|
|
+ from company_extension_bind t
|
|
|
+ left join company c on t.company_id = c.company_id and t.company_id > 0
|
|
|
+ left join company_user cu on t.company_user_id = cu.user_id
|
|
|
+ <where>
|
|
|
+ 1 = 1
|
|
|
+ <include refid="saasVoiceSeatWhere"/>
|
|
|
+ </where>
|
|
|
+ order by t.id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSaasVoiceSeatById" resultType="com.fs.company.vo.SaasVoiceSeatVO">
|
|
|
+ select
|
|
|
+ t.id,
|
|
|
+ t.company_id as companyId,
|
|
|
+ case when t.company_id = 0 then '租户分机池' else c.company_name end as companyName,
|
|
|
+ t.company_user_id as companyUserId,
|
|
|
+ cu.nick_name as companyUserName,
|
|
|
+ t.extension_num as extensionNum,
|
|
|
+ t.extension_pass as extensionPass,
|
|
|
+ t.ext_id as extId,
|
|
|
+ t.user_code as userCode,
|
|
|
+ t.status,
|
|
|
+ t.create_time as createTime,
|
|
|
+ t.update_time as updateTime
|
|
|
+ from company_extension_bind t
|
|
|
+ left join company c on t.company_id = c.company_id and t.company_id > 0
|
|
|
+ left join company_user cu on t.company_user_id = cu.user_id
|
|
|
+ where t.id = #{id} and (t.is_del = 0 or t.is_del is null)
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <update id="assignExtensionToCompany">
|
|
|
+ update company_extension_bind
|
|
|
+ set company_id = #{companyId},
|
|
|
+ update_time = #{updateTime}
|
|
|
+ where company_id = 0
|
|
|
+ and status = 1
|
|
|
+ and (is_del = 0 or is_del is null)
|
|
|
+ and (company_user_id is null or company_user_id = 0)
|
|
|
+ and id in
|
|
|
+ <foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="recycleExtensionToPool">
|
|
|
+ update company_extension_bind
|
|
|
+ set company_id = #{poolCompanyId},
|
|
|
+ company_user_id = null,
|
|
|
+ update_time = #{updateTime}
|
|
|
+ where company_id > 0
|
|
|
+ and (is_del = 0 or is_del is null)
|
|
|
+ and (company_user_id is null or company_user_id = 0)
|
|
|
+ and id in
|
|
|
+ <foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="updateStatusById">
|
|
|
+ update company_extension_bind
|
|
|
+ set status = #{status}, update_time = now()
|
|
|
+ where id = #{id} and (is_del = 0 or is_del is null)
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="batchUpdateStatusByIds">
|
|
|
+ update company_extension_bind
|
|
|
+ set status = #{status}, update_time = now()
|
|
|
+ where (is_del = 0 or is_del is null) and id in
|
|
|
+ <foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
</mapper>
|