|
|
@@ -7,14 +7,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<resultMap type="CompanyVoiceApiTenant" id="CompanyVoiceApiTenantResult">
|
|
|
<result property="id" column="id" />
|
|
|
<result property="apiId" column="api_id" />
|
|
|
- <result property="companyId" column="company_id" />
|
|
|
- <result property="price" column="price" />
|
|
|
+ <result property="tenantId" column="tenant_id" />
|
|
|
+ <result property="salePrice" column="sale_price" />
|
|
|
<result property="priority" column="priority" />
|
|
|
<result property="isPrimary" column="is_primary" />
|
|
|
- <result property="allowManual" column="allow_manual"/>
|
|
|
+ <result property="selectable" column="selectable" />
|
|
|
<result property="status" column="status" />
|
|
|
<result property="createTime" column="create_time" />
|
|
|
- <result property="companyName" column="company_name"/>
|
|
|
+ <result property="tenantName" column="tenant_name" />
|
|
|
+ <result property="tenantCode" column="tenant_code" />
|
|
|
<result property="apiName" column="api_name" />
|
|
|
<result property="costPrice" column="cost_price" />
|
|
|
<result property="apiType" column="api_type" />
|
|
|
@@ -22,8 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</resultMap>
|
|
|
|
|
|
<sql id="selectCompanyVoiceApiTenantVo">
|
|
|
- select t.id, t.api_id, t.company_id, t.price, t.priority, t.is_primary, t.allow_manual, t.status, t.create_time
|
|
|
+ select t.id, t.api_id, t.tenant_id, t.tenant_code, t.tenant_name,
|
|
|
+ t.sale_price, t.priority, t.is_primary, t.selectable, t.status, t.create_time,
|
|
|
+ a.api_name, a.cost_price, a.provider, a.api_type
|
|
|
from company_voice_api_tenant t
|
|
|
+ left join company_voice_api a on a.api_id = t.api_id and (a.is_del = 0 or a.is_del is null)
|
|
|
</sql>
|
|
|
|
|
|
<select id="selectCompanyVoiceApiTenantById" resultMap="CompanyVoiceApiTenantResult">
|
|
|
@@ -31,41 +35,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
where t.id = #{id}
|
|
|
</select>
|
|
|
|
|
|
- <select id="selectByApiAndCompany" resultMap="CompanyVoiceApiTenantResult">
|
|
|
+ <select id="selectByApiAndTenant" resultMap="CompanyVoiceApiTenantResult">
|
|
|
<include refid="selectCompanyVoiceApiTenantVo"/>
|
|
|
- where t.api_id = #{apiId} and t.company_id = #{companyId}
|
|
|
+ where t.api_id = #{apiId} and t.tenant_id = #{tenantId}
|
|
|
</select>
|
|
|
|
|
|
<!-- 查询接口已分配的租户列表(含租户名、定价信息) -->
|
|
|
<select id="selectTenantsByApiId" resultMap="CompanyVoiceApiTenantResult">
|
|
|
- select t.id, t.api_id, t.company_id, t.price, t.priority, t.is_primary, t.allow_manual, t.status, t.create_time,
|
|
|
- c.company_name, a.cost_price, a.provider, a.api_type
|
|
|
+ select t.id, t.api_id, t.tenant_id, t.sale_price, t.priority, t.is_primary, t.selectable, t.status, t.create_time,
|
|
|
+ a.api_name,
|
|
|
+ coalesce(t.tenant_name, ti.tenant_name) as tenant_name,
|
|
|
+ coalesce(t.tenant_code, ti.tenant_code) as tenant_code,
|
|
|
+ a.cost_price, a.provider, a.api_type
|
|
|
from company_voice_api_tenant t
|
|
|
- left join company c on c.company_id = t.company_id
|
|
|
- left join company_voice_api a on a.api_id = t.api_id
|
|
|
+ left join tenant_info ti on ti.id = t.tenant_id
|
|
|
+ left join company_voice_api a on a.api_id = t.api_id and (a.is_del = 0 or a.is_del is null)
|
|
|
where t.api_id = #{apiId}
|
|
|
order by t.priority asc, t.id desc
|
|
|
</select>
|
|
|
|
|
|
<!-- 查询租户已分配的接口列表(含接口名、成本价、服务商) -->
|
|
|
- <select id="selectApisByCompanyId" resultMap="CompanyVoiceApiTenantResult">
|
|
|
- select t.id, t.api_id, t.company_id, t.price, t.priority, t.is_primary, t.allow_manual, t.status, t.create_time,
|
|
|
- a.api_name, a.cost_price, a.provider, a.api_type
|
|
|
+ <select id="selectApisByTenantId" resultMap="CompanyVoiceApiTenantResult">
|
|
|
+ select t.id, t.api_id, t.tenant_id, t.sale_price, t.priority, t.is_primary, t.selectable, t.status, t.create_time,
|
|
|
+ a.api_name,
|
|
|
+ coalesce(t.tenant_name, ti.tenant_name) as tenant_name,
|
|
|
+ coalesce(t.tenant_code, ti.tenant_code) as tenant_code,
|
|
|
+ a.cost_price, a.provider, a.api_type
|
|
|
+ from company_voice_api_tenant t
|
|
|
+ left join tenant_info ti on ti.id = t.tenant_id
|
|
|
+ left join company_voice_api a on a.api_id = t.api_id and (a.is_del = 0 or a.is_del is null)
|
|
|
+ where t.tenant_id = #{tenantId}
|
|
|
+ order by t.priority asc, t.id desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询租户已分配且启用的接口列表 -->
|
|
|
+ <select id="selectEnabledApisByTenantId" resultMap="CompanyVoiceApiTenantResult">
|
|
|
+ select t.id, t.api_id, t.tenant_id, t.sale_price, t.priority, t.is_primary, t.selectable, t.status, t.create_time,
|
|
|
+ a.api_name,
|
|
|
+ coalesce(t.tenant_name, ti.tenant_name) as tenant_name,
|
|
|
+ coalesce(t.tenant_code, ti.tenant_code) as tenant_code,
|
|
|
+ a.cost_price, a.provider, a.api_type
|
|
|
from company_voice_api_tenant t
|
|
|
- left join company_voice_api a on a.api_id = t.api_id
|
|
|
- where t.company_id = #{companyId}
|
|
|
+ left join tenant_info ti on ti.id = t.tenant_id
|
|
|
+ left join company_voice_api a on a.api_id = t.api_id and (a.is_del = 0 or a.is_del is null)
|
|
|
+ where t.tenant_id = #{tenantId} and t.status = 1
|
|
|
order by t.priority asc, t.id desc
|
|
|
</select>
|
|
|
|
|
|
<select id="selectCompanyVoiceApiTenantList" resultMap="CompanyVoiceApiTenantResult">
|
|
|
- select t.id, t.api_id, t.company_id, t.price, t.priority, t.is_primary, t.allow_manual, t.status, t.create_time,
|
|
|
- c.company_name, a.api_name, a.cost_price, a.provider, a.api_type
|
|
|
+ select t.id, t.api_id, t.tenant_id, t.sale_price, t.priority, t.is_primary, t.selectable, t.status, t.create_time,
|
|
|
+ a.api_name,
|
|
|
+ coalesce(t.tenant_name, ti.tenant_name) as tenant_name,
|
|
|
+ coalesce(t.tenant_code, ti.tenant_code) as tenant_code,
|
|
|
+ a.cost_price, a.provider, a.api_type
|
|
|
from company_voice_api_tenant t
|
|
|
- left join company c on c.company_id = t.company_id
|
|
|
- left join company_voice_api a on a.api_id = t.api_id
|
|
|
+ left join tenant_info ti on ti.id = t.tenant_id
|
|
|
+ left join company_voice_api a on a.api_id = t.api_id and (a.is_del = 0 or a.is_del is null)
|
|
|
<where>
|
|
|
<if test="apiId != null"> and t.api_id = #{apiId}</if>
|
|
|
- <if test="companyId != null"> and t.company_id = #{companyId}</if>
|
|
|
+ <if test="tenantId != null"> and t.tenant_id = #{tenantId}</if>
|
|
|
<if test="status != null"> and t.status = #{status}</if>
|
|
|
</where>
|
|
|
order by t.priority asc, t.id desc
|
|
|
@@ -75,31 +103,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
insert into company_voice_api_tenant
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
<if test="apiId != null">api_id,</if>
|
|
|
- <if test="companyId != null">company_id,</if>
|
|
|
- <if test="price != null">price,</if>
|
|
|
+ <if test="tenantId != null">tenant_id,</if>
|
|
|
+ <if test="tenantCode != null">tenant_code,</if>
|
|
|
+ <if test="tenantName != null">tenant_name,</if>
|
|
|
+ <if test="salePrice != null">sale_price,</if>
|
|
|
<if test="priority != null">priority,</if>
|
|
|
<if test="isPrimary != null">is_primary,</if>
|
|
|
- <if test="allowManual != null">allow_manual,</if>
|
|
|
+ <if test="selectable != null">selectable,</if>
|
|
|
<if test="status != null">status,</if>
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
</trim>
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
<if test="apiId != null">#{apiId},</if>
|
|
|
- <if test="companyId != null">#{companyId},</if>
|
|
|
- <if test="price != null">#{price},</if>
|
|
|
+ <if test="tenantId != null">#{tenantId},</if>
|
|
|
+ <if test="tenantCode != null">#{tenantCode},</if>
|
|
|
+ <if test="tenantName != null">#{tenantName},</if>
|
|
|
+ <if test="salePrice != null">#{salePrice},</if>
|
|
|
<if test="priority != null">#{priority},</if>
|
|
|
<if test="isPrimary != null">#{isPrimary},</if>
|
|
|
- <if test="allowManual != null">#{allowManual},</if>
|
|
|
+ <if test="selectable != null">#{selectable},</if>
|
|
|
<if test="status != null">#{status},</if>
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
</trim>
|
|
|
</insert>
|
|
|
|
|
|
<insert id="batchInsertCompanyVoiceApiTenant">
|
|
|
- insert into company_voice_api_tenant (api_id, company_id, price, priority, is_primary, allow_manual, status, create_time)
|
|
|
+ insert into company_voice_api_tenant (api_id, tenant_id, tenant_code, tenant_name, sale_price, priority, is_primary, selectable, status, create_time)
|
|
|
values
|
|
|
<foreach item="item" collection="list" separator=",">
|
|
|
- (#{item.apiId}, #{item.companyId}, #{item.price}, #{item.priority}, #{item.isPrimary}, #{item.allowManual}, #{item.status}, NOW())
|
|
|
+ (#{item.apiId}, #{item.tenantId}, #{item.tenantCode}, #{item.tenantName}, #{item.salePrice}, #{item.priority}, #{item.isPrimary}, #{item.selectable}, #{item.status}, NOW())
|
|
|
</foreach>
|
|
|
</insert>
|
|
|
|
|
|
@@ -107,11 +139,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
update company_voice_api_tenant
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
|
<if test="apiId != null">api_id = #{apiId},</if>
|
|
|
- <if test="companyId != null">company_id = #{companyId},</if>
|
|
|
- <if test="price != null">price = #{price},</if>
|
|
|
+ <if test="tenantId != null">tenant_id = #{tenantId},</if>
|
|
|
+ <if test="tenantCode != null">tenant_code = #{tenantCode},</if>
|
|
|
+ <if test="tenantName != null">tenant_name = #{tenantName},</if>
|
|
|
+ <if test="salePrice != null">sale_price = #{salePrice},</if>
|
|
|
<if test="priority != null">priority = #{priority},</if>
|
|
|
<if test="isPrimary != null">is_primary = #{isPrimary},</if>
|
|
|
- <if test="allowManual != null">allow_manual = #{allowManual},</if>
|
|
|
+ <if test="selectable != null">selectable = #{selectable},</if>
|
|
|
<if test="status != null">status = #{status},</if>
|
|
|
</trim>
|
|
|
where id = #{id}
|
|
|
@@ -121,12 +155,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
delete from company_voice_api_tenant where id = #{id}
|
|
|
</delete>
|
|
|
|
|
|
- <delete id="deleteByApiAndCompany">
|
|
|
- delete from company_voice_api_tenant where api_id = #{apiId} and company_id = #{companyId}
|
|
|
+ <delete id="deleteByApiAndTenant">
|
|
|
+ delete from company_voice_api_tenant where api_id = #{apiId} and tenant_id = #{tenantId}
|
|
|
</delete>
|
|
|
|
|
|
<delete id="deleteByApiId">
|
|
|
delete from company_voice_api_tenant where api_id = #{apiId}
|
|
|
</delete>
|
|
|
|
|
|
+ <update id="disableByApiId">
|
|
|
+ update company_voice_api_tenant set status = 0 where api_id = #{apiId} and status = 1
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="disableByApiIds">
|
|
|
+ update company_voice_api_tenant set status = 0 where status = 1 and api_id in
|
|
|
+ <foreach item="apiId" collection="apiIds" open="(" separator="," close=")">
|
|
|
+ #{apiId}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="batchUpdatePricing">
|
|
|
+ update company_voice_api_tenant
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="data.salePrice != null">sale_price = #{data.salePrice},</if>
|
|
|
+ <if test="data.priority != null">priority = #{data.priority},</if>
|
|
|
+ <if test="data.isPrimary != null">is_primary = #{data.isPrimary},</if>
|
|
|
+ <if test="data.selectable != null">selectable = #{data.selectable},</if>
|
|
|
+ </trim>
|
|
|
+ where id in
|
|
|
+ <foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <update id="batchUpdateStatus">
|
|
|
+ update company_voice_api_tenant set status = #{status}
|
|
|
+ where id in
|
|
|
+ <foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+
|
|
|
</mapper>
|