Commit 51d52c07 authored by wuwz's avatar wuwz

旅游路线

parent e300a0bd
package com.xxfc.platform.tour.biz; package com.xxfc.platform.tour.biz;
import com.xxfc.platform.tour.mapper.TourGoodMapper; import com.github.wxiaoqi.security.common.msg.BaseResponse;
import org.springframework.stereotype.Service; import com.github.wxiaoqi.security.common.msg.ListRestResponse;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.tour.entity.TourGood; import com.xxfc.platform.tour.mapper.TourGoodMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 旅游商品表 import com.xxfc.platform.tour.entity.TourGood;
* import com.github.wxiaoqi.security.common.biz.BaseBiz;
* @author zjw import org.springframework.web.bind.annotation.PathVariable;
* @email nishijjo@qq.com
* @date 2019-06-06 11:41:51 import java.util.HashMap;
*/ import java.util.List;
@Service import java.util.Map;
public class TourGoodBiz extends BaseBiz<TourGoodMapper,TourGood> {
/**
* 旅游商品表
*
* @author zjw
* @email nishijjo@qq.com
* @date 2019-06-06 11:41:51
*/
@Service
public class TourGoodBiz extends BaseBiz<TourGoodMapper,TourGood> {
@Autowired
private TourGoodMapper tourGoodMapper;
public PageDataVO<TourGood> getGoodList(int page, int limit , String query , Double latitude, Double longitude, Integer tagId, Double distance){
Map<String,Object> params = new HashMap<String,Object>();
params.put("query",query);
params.put("latitude",latitude);
params.put("longitude",longitude);
params.put("tagId",tagId);
params.put("distance",distance);
List<TourGood> list = tourGoodMapper.getGoodList(params);
return PageDataVO.pageInfo(page,limit,list);
}
} }
\ No newline at end of file
package com.xxfc.platform.tour.mapper; package com.xxfc.platform.tour.mapper;
import com.xxfc.platform.tour.entity.TourGood; import com.xxfc.platform.tour.entity.TourGood;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
import java.util.Map;
/** /**
* 旅游商品表 * 旅游商品表
* *
...@@ -11,5 +16,5 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -11,5 +16,5 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2019-06-06 11:41:51 * @date 2019-06-06 11:41:51
*/ */
public interface TourGoodMapper extends Mapper<TourGood> { public interface TourGoodMapper extends Mapper<TourGood> {
public List<TourGood> getGoodList(@Param("params") Map<String,Object> map);
} }
package com.xxfc.platform.tour.rest; package com.xxfc.platform.tour.rest;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.xxfc.platform.tour.biz.TourGoodBiz; import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.xxfc.platform.tour.entity.TourGood; import com.github.wxiaoqi.security.common.msg.ListRestResponse;
import org.springframework.web.bind.annotation.RequestMapping; import com.github.wxiaoqi.security.common.rest.BaseController;
import org.springframework.web.bind.annotation.RestController; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.tour.biz.TourGoodBiz;
@RestController import com.xxfc.platform.tour.entity.TourGood;
@RequestMapping("tourGood") import io.swagger.annotations.ApiOperation;
public class TourGoodController extends BaseController<TourGoodBiz,TourGood> { import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("tourGood")
public class TourGoodController extends BaseController<TourGoodBiz,TourGood> {
@ApiOperation("订单详情")
@RequestMapping(value = "/app/unauth/getGoodList",method = RequestMethod.GET)
//@GetMapping(value = "/app/unauth/getGoodList")
@IgnoreClientToken
@ResponseBody
public PageDataVO<TourGood> getGoodList(@RequestParam(value = "page", required=true) Integer page, @RequestParam(value = "limit", required=true) Integer limit ,
@RequestParam(value = "query") String query , @RequestParam(value = "latitude", required=false) Double latitude, @RequestParam(value = "longitude", required=false) Double longitude,
@RequestParam(value = "tagId", required=false) Integer tagId, @RequestParam(value = "distance",defaultValue = "10.00") Double distance){
//BaseResponse baseResponse = new BaseResponse();
return baseBiz.getGoodList(page, limit, query, latitude, longitude, tagId, distance);
}
} }
\ No newline at end of file
...@@ -25,4 +25,28 @@ ...@@ -25,4 +25,28 @@
<result property="unit" column="unit"/> <result property="unit" column="unit"/>
</resultMap> </resultMap>
<select id="getGoodList" parameterType="java.util.Map" resultMap="tourGoodMap">
SELECT * from tour_good t
where 1=1
<if test="params.query != null and params.query != ''">
and (t.`name` like CONCAT('%',#{params.query},'%') or t.introduce like CONCAT('%',#{params.query},'%'))
</if>
<if test="params.latitude != null and params.latitude != '' and params.longitude != null and params.longitude != ''">
and t.id in (SELECT s.good_id from (
select good_id,
if(ROUND(( (2 * ASIN( SQRT( POW( SIN((latitude * PI() / 180.0- #{params.latitude}* PI() / 180.0)/2), 2)+COS( latitude * PI() / 180.0)*COS( #{params.longitude} * PI() / 180.0)
*POW(SIN((longitude * PI() / 180.0 - #{params.longitude}* PI() /180.0)/2),2))))*6378.137)*10000)/10000 is null ,0,ROUND(( (2 * ASIN( SQRT( POW( SIN((latitude * PI() / 180.0-22.954205* PI() / 180.0)/2), 2)+COS( latitude * PI() / 180.0)*COS(113.879421 * PI() / 180.0)
*POW(SIN((longitude * PI() / 180.0 - #{params.longitude}* PI() /180.0)/2),2))))*6378.137)*10000)/10000 ) AS distance
FROM tour_good_site
order by distance
) s
where s.distance &lt; #{params.distance})
</if>
<if test="params.tagId != null and params.tagId != '' ">
and t.id in (SELECT tg.good_id from tour_good_tag tg
where tg.tag_id = 1) and t.recommend = 1
ORDER BY t.recommend
</if>
</select>
</mapper> </mapper>
\ No newline at end of file
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