Commit c4645c26 authored by wuwz's avatar wuwz

营地增加标签和距离

parent 7a3aee83
...@@ -48,4 +48,8 @@ public class GoodDataVO{ ...@@ -48,4 +48,8 @@ public class GoodDataVO{
@ApiModelProperty("seo*html标签优化") @ApiModelProperty("seo*html标签优化")
private String imgDesc; private String imgDesc;
private String distance;
private String labels;
} }
...@@ -82,8 +82,27 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> { ...@@ -82,8 +82,27 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
* @param limit * @param limit
* @return * @return
*/ */
public List<GoodDataVO> getAllByHome(Integer page, Integer limit) { public List<GoodDataVO> getAllByHome(Integer page, Integer limit,Double lat ,Double lon) {
return mapper.findAllByHome((page - 1) * limit, limit); //return mapper.findAllByHome((page - 1) * limit, limit);
List<GoodDataVO>list = new ArrayList<GoodDataVO>();
if(lat != null && lat > 0 && lon != null && lon > 0){
list = mapper.findAllAndJlByHome((page - 1) * limit, limit,lat,lon);
}else{
list = mapper.findAllByHome((page - 1) * limit, limit);
}
//增加标签
for(GoodDataVO goodDataVO : list){
List<CampsiteShopTagDTO> listTag= campsiteShopTagBiz.findByCampsiteShopId(goodDataVO.getId());
if(listTag.size() > 0){
String labels = "";
for(CampsiteShopTagDTO campsiteShopTagDTO : listTag){
labels += campsiteShopTagDTO.getName() + ",";
}
labels = labels.substring(0,labels.length()-1);
goodDataVO.setLabels(labels);
}
}
return list;
} }
......
...@@ -33,6 +33,8 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> { ...@@ -33,6 +33,8 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> {
*/ */
List<GoodDataVO> findAllByHome(@Param("start") Integer start, @Param("size") Integer size); List<GoodDataVO> findAllByHome(@Param("start") Integer start, @Param("size") Integer size);
List<GoodDataVO> findAllAndJlByHome(@Param("start") Integer start, @Param("size") Integer size,@Param("lat")Double lat,@Param("lon")Double lon);
List<GoodDataVO> findAll(); List<GoodDataVO> findAll();
/** /**
......
...@@ -68,8 +68,10 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp ...@@ -68,8 +68,10 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp
@ApiOperation("首页营地列表") @ApiOperation("首页营地列表")
@GetMapping(value = "/app/shopList") @GetMapping(value = "/app/shopList")
public List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page, public List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit", defaultValue = "4") Integer limit) { @RequestParam(value = "limit", defaultValue = "4") Integer limit,
return getBaseBiz().getAllByHome(page, limit); @RequestParam(value = "longitude", required = false) Double longitude,
@RequestParam(value = "latitude", required = false) Double latitude) {
return getBaseBiz().getAllByHome(page, limit,longitude,latitude);
} }
@ApiOperation("随机获取营地") @ApiOperation("随机获取营地")
......
...@@ -94,6 +94,19 @@ ...@@ -94,6 +94,19 @@
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER} limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
</select> </select>
<select id="findAllAndJlByHome" resultType="com.github.wxiaoqi.security.common.vo.GoodDataVO">
select cs.id as `id`,cs.name as `name`,cs.logo as `imgUrl`,cs.province_name as `name1`,cs.longitude,cs.latitude,cs.alt,cs.img_title as `imgTitle`,cs.img_keyword as `imgKeyword`,cs.img_desc as `imgDesc`,
ROUND(( (2 * ASIN( SQRT( POW( SIN((latitude * PI() / 180.0
- #{lat} * PI() / 180.0)/2), 2)
+COS( latitude * PI() / 180.0)*COS(#{lat} * PI() / 180.0)
*POW(SIN((longitude * PI() / 180.0 - #{lon} * PI() /
180.0)/2),2))))*6378.137)*10000)/10000 as distance
FROM `campsite_shop` cs
where cs.sale_state=1 and cs.is_del=0
order by cs.hot desc
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
</select>
<select id="findAll" resultType="com.github.wxiaoqi.security.common.vo.GoodDataVO"> <select id="findAll" resultType="com.github.wxiaoqi.security.common.vo.GoodDataVO">
select cs.id as `id`,cs.name as `name`,cs.logo as `imgUrl`,cs.province_name as `name1`,cs.longitude,cs.latitude,cs.alt,cs.img_title as `imgTitle`,cs.img_keyword as `imgKeyword`,cs.img_desc as `imgDesc` select cs.id as `id`,cs.name as `name`,cs.logo as `imgUrl`,cs.province_name as `name1`,cs.longitude,cs.latitude,cs.alt,cs.img_title as `imgTitle`,cs.img_keyword as `imgKeyword`,cs.img_desc as `imgDesc`
FROM `campsite_shop` cs FROM `campsite_shop` cs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment