| | |
| | | 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; |
| | |
| | | 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); |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | IPage<MallShop> findShopListInPage(MallShop mallShop, QueryRequest request); |
| | | |
| | | List<ShopListVo> findShopList(ApiShopDto apiShopDto); |
| | | List<ApiShopVo> findShopList(ApiShopDto apiShopDto); |
| | | } |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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); |
| | | } |
| | | } |
| | |
| | | </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> |