fix
Hentua
2023-04-23 fc093b0724b0c8979c0896f2bdc4cf8c4af27a1f
fix
4 files modified
44 ■■■■ changed files
src/main/java/cc/mrbird/febs/mall/mapper/MallShopMapper.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/IMallShopService.java 3 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/MallShopServiceImpl.java 13 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/MallShopMapper.xml 23 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/mapper/MallShopMapper.java
@@ -1,5 +1,6 @@
package cc.mrbird.febs.mall.mapper;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.mall.entity.MallShop;
import cc.mrbird.febs.mall.vo.AdminMallNewsInfoVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -7,7 +8,11 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface MallShopMapper extends BaseMapper<MallShop> {
    IPage<MallShop> selectShopListInPage(@Param("record") MallShop mallShop, Page<MallShop> page);
    List<MallShop> selectShopDistanceList(@Param("record") MallShop mallShop, @Param("page") QueryRequest queryRequest);
}
src/main/java/cc/mrbird/febs/mall/service/IMallShopService.java
@@ -3,6 +3,7 @@
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.mall.dto.ApiShopDto;
import cc.mrbird.febs.mall.entity.MallShop;
import cc.mrbird.febs.mall.vo.ApiShopVo;
import cc.mrbird.febs.mall.vo.ShopListVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -13,5 +14,5 @@
    IPage<MallShop> findShopListInPage(MallShop mallShop, QueryRequest request);
    List<ShopListVo> findShopList(ApiShopDto apiShopDto);
    List<ApiShopVo> findShopList(ApiShopDto apiShopDto);
}
src/main/java/cc/mrbird/febs/mall/service/impl/MallShopServiceImpl.java
@@ -5,6 +5,7 @@
import cc.mrbird.febs.mall.entity.MallShop;
import cc.mrbird.febs.mall.mapper.MallShopMapper;
import cc.mrbird.febs.mall.service.IMallShopService;
import cc.mrbird.febs.mall.vo.ApiShopVo;
import cc.mrbird.febs.mall.vo.ShopListVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
@@ -28,11 +29,13 @@
    }
    @Override
    public List<ShopListVo> findShopList(ApiShopDto apiShopDto) {
        Page<MallShop> page = new Page<>(apiShopDto.getPageNum(), apiShopDto.getPageSize());
    public List<ApiShopVo> findShopList(ApiShopDto apiShopDto) {
        QueryRequest page = new QueryRequest();
        page.setPageNum(apiShopDto.getPageNum() - 1);
        page.setPageSize(apiShopDto.getPageSize());
        MallShop mallShop = BeanUtil.copyProperties(apiShopDto, MallShop.class);
        IPage<MallShop> list = this.baseMapper.selectShopListInPage(mallShop, page);
        return BeanUtil.copyToList(list.getRecords(), ShopListVo.class);
        List<MallShop> list = this.baseMapper.selectShopDistanceList(mallShop, page);
        return BeanUtil.copyToList(list, ApiShopVo.class);
    }
}
src/main/resources/mapper/modules/MallShopMapper.xml
@@ -18,11 +18,28 @@
                </if>
            </if>
        </where>
    </select>
    <select id="selectShopDistanceList" resultType="cc.mrbird.febs.mall.entity.MallShop">
        select
        a.*,
        lat_lng_distance(#{record.latitude}, #{record.longitude}, a.latitude, a.longitude) distance
        from mall_shop a
        <where>
            1=1
            <if test="record != null">
                <if test="record.shopName != null and record.shopName != ''">
                    and shop_name like concat('%', concat(#{record.shopName}, '%'))
                </if>
                <if test="record.state != null">
                    and state = #{record.state}
                </if>
            </if>
        </where>
        <if test="record.longitude != null and record.latitude != null">
            order by lat_lng_distance(#{record.latitude}, #{record.longitude}, a.latitude, a.longitude) desc
        </if>
        <if test="record.longitude == null or record.latitude == null">
            order by id desc
        </if>
        limit #{page.pageNum},#{page.pageSize}
    </select>
</mapper>