package com.talentcard.server.mapper;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.talentcard.server.entity.MerchantDisplayPolicyMerchant;
|
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Select;
|
|
@Mapper
|
public interface DisplayServiceMapper extends BaseMapper<MerchantDisplayPolicyMerchant> {
|
|
@Select("""
|
<script>
|
select m.id as merchantId,
|
m.merchant_name as merchantName,
|
m.merchant_type_code as category,
|
m.merchant_type as merchantType,
|
m.contact_name as contactName,
|
m.contact_mobile as contactMobile,
|
m.logo_url as logoUrl,
|
m.cover_url as coverUrl,
|
m.address,
|
m.business_status as businessStatus,
|
m.longitude,
|
m.latitude,
|
m.usage_instructions as handlingInstructions,
|
m.rights_text as rightsText,
|
m.service_label as serviceLabel,
|
m.is_recommend as recommend,
|
m.sort_no as sortNo,
|
m.status,
|
(select count(*) from merchant_card_benefit b where b.merchant_id = m.id) as policyCount,
|
m.created_at as createdAt,
|
m.updated_at as updatedAt
|
from merchant m
|
where m.deleted = 0
|
and m.merchant_type_code in ('parking', 'medical', 'apartment', 'housing', 'car', 'appliance')
|
<if test="category != null and category != ''">
|
and m.merchant_type_code = #{category}
|
</if>
|
<if test="status != null">and m.status = #{status}</if>
|
<if test="keyword != null and keyword != ''">
|
and (m.merchant_name like concat('%', #{keyword}, '%')
|
or m.contact_mobile like concat('%', #{keyword}, '%')
|
or m.address like concat('%', #{keyword}, '%'))
|
</if>
|
order by m.sort_no desc, m.id desc
|
limit #{size} offset #{offset}
|
</script>
|
""")
|
List<Map<String, Object>> selectAdminPage(@Param("category") String category,
|
@Param("keyword") String keyword,
|
@Param("status") Integer status,
|
@Param("size") int size,
|
@Param("offset") int offset);
|
|
@Select("""
|
<script>
|
select count(*)
|
from merchant m
|
where m.deleted = 0
|
and m.merchant_type_code in ('parking', 'medical', 'apartment', 'housing', 'car', 'appliance')
|
<if test="category != null and category != ''">
|
and m.merchant_type_code = #{category}
|
</if>
|
<if test="status != null">and m.status = #{status}</if>
|
<if test="keyword != null and keyword != ''">
|
and (m.merchant_name like concat('%', #{keyword}, '%')
|
or m.contact_mobile like concat('%', #{keyword}, '%')
|
or m.address like concat('%', #{keyword}, '%'))
|
</if>
|
</script>
|
""")
|
Long countAdminPage(@Param("category") String category,
|
@Param("keyword") String keyword,
|
@Param("status") Integer status);
|
|
@Select("""
|
<script>
|
select m.id as merchantId,
|
m.merchant_name as merchantName,
|
m.merchant_type_code as category,
|
m.merchant_type as merchantType,
|
m.contact_name as contactName,
|
m.contact_mobile as contactMobile,
|
m.logo_url as logoUrl,
|
m.cover_url as coverUrl,
|
m.address,
|
m.business_status as businessStatus,
|
m.longitude,
|
m.latitude,
|
m.usage_instructions as handlingInstructions,
|
m.rights_text as rightsText,
|
m.service_label as serviceLabel,
|
m.is_recommend as recommend,
|
m.sort_no as sortNo,
|
m.status,
|
(select count(*) from merchant_card_benefit b where b.merchant_id = m.id) as policyCount,
|
m.created_at as createdAt,
|
m.updated_at as updatedAt
|
from merchant m
|
where m.deleted = 0
|
and m.id = #{serviceId}
|
and m.merchant_type_code in ('parking', 'medical', 'apartment', 'housing', 'car', 'appliance')
|
limit 1
|
</script>
|
""")
|
Map<String, Object> selectAdminDetail(@Param("serviceId") Long serviceId);
|
}
|