| | |
| | | import com.dsh.account.feignclient.competition.model.PurchaseRecordVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.*; |
| | | import com.dsh.account.model.vo.commentDetail.StuCommentsVo; |
| | | import com.dsh.account.model.vo.medalDetail.StuMedalVo; |
| | | import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo; |
| | | import com.dsh.account.model.vo.sourceDetail.CourseDetailsOfContinuationResp; |
| | | import com.dsh.account.model.vo.sourceDetail.RecordTimeRequest; |
| | |
| | | |
| | | |
| | | /** |
| | | * 课时详情-续课 |
| | | * 课时详情-续课课包详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/startCource/renewal") |
| | |
| | | |
| | | |
| | | /** |
| | | * 课时详情-续课 |
| | | * 课时详情-选择优惠券 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/startCource/conponList") |
| | |
| | | |
| | | |
| | | /** |
| | | * 课时详情-续课 |
| | | * 课时详情-支付 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/startCource/payment") |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 学员勋章 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/startCource/stuMedal") |
| | | @ApiOperation(value = "学员勋章", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<StuMedalVo> queryStuMedal(@RequestParam("stuId") Integer stuId, HttpServletRequest request){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(request); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.controller; |
| | | |
| | | |
| | | import com.dsh.account.feignclient.other.model.SysNotice; |
| | | import com.dsh.account.model.vo.exploreDetail.ExploreDatasVo; |
| | | import com.dsh.account.model.vo.exploreDetail.LonLatRequest; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionDetailsVo; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionIns; |
| | | import com.dsh.account.service.TStudentService; |
| | | import com.dsh.account.util.ResultUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 探索玩湃 控制器 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class ExploreWPController { |
| | | |
| | | |
| | | @Autowired |
| | | private TStudentService tsService; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/exploreWP/noticeList") |
| | | @ApiOperation(value = "联系客服-探索首页", tags = {"APP-探索玩湃"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<ExploreDatasVo> indexOfExploreDetail(@RequestBody LonLatRequest llrequest){ |
| | | try { |
| | | return ResultUtil.success(tsService.queryIndexOfExplores(llrequest)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/exploreWP/noticeList") |
| | | @ApiOperation(value = "联系客服-公告列表", tags = {"APP-探索玩湃"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<SysNotice>> queryNoticeListDatas(){ |
| | | try { |
| | | return ResultUtil.success(tsService.querySystemNoticeDetails()); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/exploreWP/noticeList") |
| | | @ApiOperation(value = "联系客服-公告详情", tags = {"APP-探索玩湃"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<SysNotice> queryNotice(@RequestBody Integer noId){ |
| | | try { |
| | | return ResultUtil.success(tsService.queryNoticeData(noId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/exploreWP/noticeList") |
| | | @ApiOperation(value = "联系客服-常见问题列表", tags = {"APP-探索玩湃"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<QuestionDetailsVo> queryFrequentlyAskedQuestionDetails(){ |
| | | try { |
| | | return ResultUtil.success(tsService.queryQuestionData()); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/exploreWP/noticeList") |
| | | @ApiOperation(value = "联系客服-常见问题详情", tags = {"APP-探索玩湃"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<QuestionIns> queryQuestionData(@RequestBody Integer quesId){ |
| | | try { |
| | | return ResultUtil.success(tsService.queryQuestionDataInfo(quesId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/exploreWP/noticeList") |
| | | @ApiOperation(value = "联系客服-客服电话列表", tags = {"APP-探索玩湃"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil<List<String>> queryCustomerData(){ |
| | | try { |
| | | return ResultUtil.success(tsService.queryCustomerDetails()); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * 支付回调控制器 |
| | | */ |
| | | |
| | | |
| | | @RestController |
| | | @RequestMapping("/payment/callback") |
| | | public class PaymentCallbackController { |
| | | |
| | | |
| | | /** |
| | | * 支付宝支付回调接口 |
| | | */ |
| | | @PostMapping("/v1") |
| | | public void alipayCallback(){ |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 微信支付回调接口 |
| | | */ |
| | | @PostMapping("/v2") |
| | | public void weChatCallback(){ |
| | | |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.feignclient.other; |
| | | |
| | | import com.dsh.account.feignclient.other.model.SysNotice; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface NoticeClient { |
| | | |
| | | |
| | | @PostMapping("/base/notice/queryNoticeDetails") |
| | | List<SysNotice> getSysNoticeDetails(); |
| | | |
| | | @PostMapping("/base/notice/queryNotice") |
| | | SysNotice getSysNoticeBuId(@RequestBody Integer noticeId); |
| | | |
| | | @PostMapping("/base/notice/sysTell") |
| | | List<String> queryCustomerTel(); |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.feignclient.other; |
| | | |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionDetailsVo; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionIns; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface QuestionClient { |
| | | |
| | | @PostMapping("/base/notice/queryQuestionDetails") |
| | | QuestionDetailsVo getSysQuestionDetails(); |
| | | |
| | | @PostMapping("/base/notice/queryQuestion") |
| | | QuestionIns getSysQuestionBuId(@RequestBody Integer quesId); |
| | | |
| | | } |
| | |
| | | package com.dsh.account.feignclient.other; |
| | | |
| | | import com.dsh.account.feignclient.other.model.StoreDetailOfCourse; |
| | | import com.dsh.account.feignclient.other.model.StoreInfo; |
| | | import com.dsh.account.feignclient.other.model.StoreLonLatList; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface StoreClient { |
| | |
| | | |
| | | @PostMapping("/storeDetail/courseOfSto") |
| | | public StoreDetailOfCourse getCourseOfStore(@RequestBody Integer storeId); |
| | | |
| | | |
| | | @PostMapping("/storeDetail/nearbyStore") |
| | | List<StoreInfo> getAllNearbyStoreList(@RequestBody String longitude, @RequestBody String latitude); |
| | | |
| | | |
| | | @PostMapping("/storeDetail/storeOfLonLat") |
| | | public List<StoreLonLatList> getAllStoreLonLats(@RequestBody String longitude, @RequestBody String latitude); |
| | | } |
New file |
| | |
| | | package com.dsh.account.feignclient.other.model; |
| | | |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StoreInfo { |
| | | |
| | | @ApiModelProperty(value = "门店id") |
| | | private Integer storeId; |
| | | |
| | | @ApiModelProperty(value = "门店背景图") |
| | | private String storeImg; |
| | | |
| | | @ApiModelProperty(value = "门店距离当前位置") |
| | | private long distance; |
| | | |
| | | @ApiModelProperty(value = "门店名称") |
| | | private String storeName; |
| | | |
| | | @ApiModelProperty(value = "门店详细地址") |
| | | private String storeAddr; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.feignclient.other.model; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StoreLonLatList { |
| | | |
| | | @ApiModelProperty(value = "门店id") |
| | | Integer storeId; |
| | | |
| | | @ApiModelProperty(value = "经度") |
| | | String longitude; |
| | | |
| | | @ApiModelProperty(value = "纬度") |
| | | String latitude; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.feignclient.other.model; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SysNotice { |
| | | |
| | | @ApiModelProperty(value = "公告id") |
| | | private Integer noticeId; |
| | | |
| | | @ApiModelProperty(value = "公告标题") |
| | | private String noticeTitle; |
| | | |
| | | @ApiModelProperty(value = "公告内容") |
| | | private String noticeContents; |
| | | |
| | | @ApiModelProperty(value = "公告发布时间") |
| | | private String noticeTime; |
| | | } |
New file |
| | |
| | | package com.dsh.account.model.vo.exploreDetail; |
| | | |
| | | import com.dsh.account.feignclient.other.model.StoreInfo; |
| | | import com.dsh.account.feignclient.other.model.StoreLonLatList; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class ExploreDatasVo { |
| | | |
| | | @ApiModelProperty(value = "前往玩湃-经度-纬度") |
| | | private List<StoreLonLatList> lonLatLists; |
| | | |
| | | @ApiModelProperty(value = "门店列表") |
| | | private List<StoreInfo> storeLists; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.model.vo.exploreDetail; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class LonLatRequest { |
| | | |
| | | @ApiModelProperty(value = "用户经度") |
| | | private String longitude; |
| | | |
| | | @ApiModelProperty(value = "用户纬度") |
| | | private String latitude; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.model.vo.exploreDetails; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class QuestionDetailsVo { |
| | | |
| | | @ApiModelProperty(value = "banner图") |
| | | private String bannerImg; |
| | | |
| | | @ApiModelProperty(value = "问题列表") |
| | | private List<QuestionIns> sysS; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.model.vo.exploreDetails; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | @Data |
| | | public class QuestionIns { |
| | | |
| | | @ApiModelProperty(value = "问题id") |
| | | private Integer noticeId; |
| | | |
| | | @ApiModelProperty(value = "问题标题") |
| | | private String noticeTitle; |
| | | |
| | | @ApiModelProperty(value = "答复内容") |
| | | private String noticeContents; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.account.model.vo.medalDetail; |
| | | |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StuMedalVo { |
| | | |
| | | @ApiModelProperty(value = "勋章类型(1=俱乐部之星,2=运动达人,3=社区之王,4=深度玩家)") |
| | | private Integer medalType; |
| | | |
| | | @ApiModelProperty(value = "勋章名称 例如:俱乐部之星") |
| | | private String medalName; |
| | | |
| | | @ApiModelProperty(value = "当前等级") |
| | | private Integer levelNum; |
| | | |
| | | @ApiModelProperty(value = "升级条件") |
| | | private String upgradeConditions; |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.account.entity.TStudent; |
| | | import com.dsh.account.feignclient.competition.model.PurchaseRecordVo; |
| | | import com.dsh.account.feignclient.other.model.SysNotice; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; |
| | | import com.dsh.account.model.vo.exploreDetail.ExploreDatasVo; |
| | | import com.dsh.account.model.vo.exploreDetail.LonLatRequest; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionDetailsVo; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionIns; |
| | | import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo; |
| | | import com.dsh.account.model.vo.sourceDetail.CourseDetailsOfContinuationResp; |
| | | import com.dsh.account.model.vo.sourceDetail.RecordTimeRequest; |
| | |
| | | List<CouponStuAvailableVo> queryStuOfConponDetails(Integer appUserId); |
| | | |
| | | CourseDetailsOfContinuationResp queryStuOfCourseDetails(Integer lessonId, Integer stuId, Integer appUserId); |
| | | /** |
| | | * 查询探索-公告列表 |
| | | */ |
| | | List<SysNotice> querySystemNoticeDetails(); |
| | | /** |
| | | * 查询公告详情 |
| | | */ |
| | | SysNotice queryNoticeData(Integer noId); |
| | | /** |
| | | * 查询常见问题列表 |
| | | */ |
| | | QuestionDetailsVo queryQuestionData(); |
| | | |
| | | /** |
| | | * 查询常见问题详情 |
| | | */ |
| | | QuestionIns queryQuestionDataInfo(Integer quesId); |
| | | |
| | | /** |
| | | * 查询客服列表 |
| | | */ |
| | | List<String> queryCustomerDetails(); |
| | | |
| | | /** |
| | | * 查询探索页面首页 |
| | | */ |
| | | ExploreDatasVo queryIndexOfExplores(LonLatRequest llrequest); |
| | | |
| | | } |
| | |
| | | import com.dsh.account.feignclient.course.model.StuSessionDetailsVo; |
| | | import com.dsh.account.feignclient.course.model.StuWithCoursesListVo; |
| | | import com.dsh.account.feignclient.course.model.StudentOfCourseVo; |
| | | import com.dsh.account.feignclient.other.NoticeClient; |
| | | import com.dsh.account.feignclient.other.QuestionClient; |
| | | import com.dsh.account.feignclient.other.StoreClient; |
| | | import com.dsh.account.feignclient.other.model.StoreDetailOfCourse; |
| | | import com.dsh.account.feignclient.other.model.StoreInfo; |
| | | import com.dsh.account.feignclient.other.model.StoreLonLatList; |
| | | import com.dsh.account.feignclient.other.model.SysNotice; |
| | | import com.dsh.account.mapper.TAppUserMapper; |
| | | import com.dsh.account.mapper.TStudentMapper; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo; |
| | | import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq; |
| | | import com.dsh.account.model.vo.exploreDetail.ExploreDatasVo; |
| | | import com.dsh.account.model.vo.exploreDetail.LonLatRequest; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionDetailsVo; |
| | | import com.dsh.account.model.vo.exploreDetails.QuestionIns; |
| | | import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo; |
| | | import com.dsh.account.model.vo.sourceDetail.CourseDetailsOfContinuationResp; |
| | | import com.dsh.account.model.vo.sourceDetail.RecordTimeRequest; |
| | |
| | | |
| | | @Autowired |
| | | private StoreClient storeClient; |
| | | |
| | | @Autowired |
| | | private NoticeClient noClient; |
| | | |
| | | @Autowired |
| | | private QuestionClient quesClient; |
| | | |
| | | @Autowired |
| | | private TAppUserMapper tauMapper; |
| | |
| | | return resp; |
| | | } |
| | | |
| | | @Override |
| | | public List<SysNotice> querySystemNoticeDetails() { |
| | | return noClient.getSysNoticeDetails(); |
| | | } |
| | | |
| | | @Override |
| | | public SysNotice queryNoticeData(Integer noId) { |
| | | return noClient.getSysNoticeBuId(noId); |
| | | } |
| | | |
| | | @Override |
| | | public QuestionDetailsVo queryQuestionData() { |
| | | return quesClient.getSysQuestionDetails(); |
| | | } |
| | | |
| | | @Override |
| | | public QuestionIns queryQuestionDataInfo(Integer quesId) { |
| | | return quesClient.getSysQuestionBuId(quesId); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> queryCustomerDetails() { |
| | | return noClient.queryCustomerTel(); |
| | | } |
| | | |
| | | @Override |
| | | public ExploreDatasVo queryIndexOfExplores(LonLatRequest llrequest) { |
| | | ExploreDatasVo datasVo = new ExploreDatasVo(); |
| | | List<StoreInfo> allNearbyStoreList = storeClient.getAllNearbyStoreList(llrequest.getLongitude(),llrequest.getLatitude()); |
| | | List<StoreLonLatList> allStoreLonLats = storeClient.getAllStoreLonLats(llrequest.getLongitude(), llrequest.getLatitude()); |
| | | datasVo.setStoreLists(allNearbyStoreList); |
| | | datasVo.setLonLatLists(allStoreLonLats); |
| | | return datasVo; |
| | | } |
| | | |
| | | |
| | | public static List<PurchaseRecordVo> dealDataOfTime(List<PurchaseRecordVo> purchaseRecords) { |
| | | Collections.sort(purchaseRecords, new Comparator<PurchaseRecordVo>() { |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.net.URLConnection; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 功能描述: 根据两个定位点的经纬度算出两点间的距离(米/m) |
| | | * |
| | | * @param startLonLat 起始经纬度 |
| | | * @param endLonLat 结束经纬度(目标经纬度) |
| | | * @return java.lang.Long 两个定位点之间的距离 |
| | | */ |
| | | public Long getDistance(String startLonLat, String endLonLat) { |
| | | try { |
| | | // 返回起始地startAddr与目的地endAddr之间的距离,单位:米 |
| | | Long result = new Long(0); |
| | | String queryUrl = |
| | | "http://restapi.amap.com/v3/distance?key=" + key + "&origins=" + startLonLat |
| | | + "&destination=" |
| | | + endLonLat; |
| | | String queryResult = getResponse(queryUrl); |
| | | JSONObject job = JSONObject.parseObject(queryResult); |
| | | JSONArray ja = job.getJSONArray("results"); |
| | | JSONObject jobO = JSONObject.parseObject(ja.getString(0)); |
| | | result = Long.parseLong(jobO.get("distance").toString()); |
| | | return result; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 功能描述: 根据两个定位点的经纬度算出两点间的距离(千米/km) |
| | | * |
| | | * @param startLonLat 起始经纬度 |
| | | * @param endLonLat 结束经纬度(目标经纬度) |
| | | * @return java.lang.Long 两个定位点之间的距离 |
| | | */ |
| | | public String getDistanceTOKilometer(String startLonLat, String endLonLat) { |
| | | try { |
| | | // 返回起始地startAddr与目的地endAddr之间的距离,单位:米 |
| | | Long result = new Long(0); |
| | | String queryUrl = |
| | | "http://restapi.amap.com/v3/distance?key=" + key + "&origins=" + startLonLat |
| | | + "&destination=" |
| | | + endLonLat; |
| | | String queryResult = getResponse(queryUrl); |
| | | JSONObject job = JSONObject.parseObject(queryResult); |
| | | JSONArray ja = job.getJSONArray("results"); |
| | | JSONObject jobO = JSONObject.parseObject(ja.getString(0)); |
| | | result = Long.parseLong(jobO.get("distance").toString()); |
| | | double kilDis = (double) result / 1000; |
| | | DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
| | | return decimalFormat.format(kilDis); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 功能描述: 发送请求 |
| | | * |
| | | * @param serverUrl 请求地址 |
| | | * @return java.lang.String |
| | | * @author isymikasan |
| | | * @date 2022-01-26 09:15:01 |
| | | */ |
| | | private static String getResponse(String serverUrl) { |
| | | // 用JAVA发起http请求,并返回json格式的结果 |
| | | StringBuffer result = new StringBuffer(); |
| | | try { |
| | | URL url = new URL(serverUrl); |
| | | URLConnection conn = url.openConnection(); |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
| | | String line; |
| | | while ((line = in.readLine()) != null) { |
| | | result.append(line); |
| | | } |
| | | in.close(); |
| | | } catch (MalformedURLException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dsh.account.mapper.EvaluateStudentMapper"> |
| | | |
| | | <!-- 开启二级缓存 --> |
| | | <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> |
| | | |
| | | </mapper> |
New file |
| | |
| | | package com.dsh.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.other.entity.FrequentlyAskedQuestions; |
| | | import com.dsh.other.model.vo.questionVo.QuestionDetailsVo; |
| | | import com.dsh.other.model.vo.questionVo.QuestionIns; |
| | | import com.dsh.other.service.FrequentlyAskedQuestionsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class AskedQuestionsController { |
| | | |
| | | |
| | | @Autowired |
| | | private FrequentlyAskedQuestionsService faqService; |
| | | |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | |
| | | |
| | | @PostMapping("/base/notice/queryQuestionDetails") |
| | | public QuestionDetailsVo getSysQuestionDetails(){ |
| | | QuestionDetailsVo notices = new QuestionDetailsVo(); |
| | | List<QuestionIns> sysS = new ArrayList<>(); |
| | | List<FrequentlyAskedQuestions> list = faqService.list(new QueryWrapper<FrequentlyAskedQuestions>() |
| | | .eq("state", 1) |
| | | .orderByDesc("insertTime")); |
| | | if (list.size() > 0 ){ |
| | | list.forEach(noList -> { |
| | | QuestionIns notice = new QuestionIns(); |
| | | notice.setQuesId(noList.getId()); |
| | | notice.setQuesTitle(noList.getContent()); |
| | | notice.setQuesContents(noList.getAnswer()); |
| | | sysS.add(notice); |
| | | }); |
| | | notices.setSysS(sysS); |
| | | } |
| | | return notices; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/notice/queryQuestion") |
| | | public QuestionIns getSysQuestionBuId(@RequestBody Integer quesId){ |
| | | QuestionIns sysNotice = new QuestionIns(); |
| | | FrequentlyAskedQuestions notice = faqService.getById(quesId); |
| | | if (null != notice){ |
| | | sysNotice.setQuesId(notice.getId()); |
| | | sysNotice.setQuesTitle(notice.getContent()); |
| | | sysNotice.setQuesContents(notice.getAnswer()); |
| | | sysNotice.setQuesTime(format.format(notice.getInsertTime())); |
| | | } |
| | | return sysNotice; |
| | | } |
| | | } |
| | |
| | | package com.dsh.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.other.entity.Store; |
| | | import com.dsh.other.feignclient.model.StoreDetailOfCourse; |
| | | import com.dsh.other.feignclient.model.StoreInfo; |
| | | import com.dsh.other.feignclient.model.StoreLonLatList; |
| | | import com.dsh.other.service.StoreService; |
| | | import com.dsh.other.util.GDMapGeocodingUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/base/protocol") |
| | |
| | | @Autowired |
| | | private StoreService stoService; |
| | | |
| | | |
| | | @Autowired |
| | | private GDMapGeocodingUtil gdMapGeocodingUtil; |
| | | |
| | | @PostMapping("/storeDetail/courseOfSto") |
| | | public StoreDetailOfCourse getCourseOfStore(@RequestBody Integer storeId){ |
| | |
| | | return ofCourse; |
| | | } |
| | | |
| | | @PostMapping("/storeDetail/nearbyStore") |
| | | public List<StoreInfo> getAllNearbyStoreList(@RequestBody String longitude,@RequestBody String latitude){ |
| | | String current = longitude+","+latitude; |
| | | List<StoreInfo> storeInfos = new ArrayList<>(); |
| | | String cityCode = ""; |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(longitude, latitude); |
| | | cityCode = geocode.get("cityCode"); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | List<Store> storeList = stoService.list(new QueryWrapper<Store>() |
| | | .eq("state", 1) |
| | | .eq("cityCode",cityCode)); |
| | | if (storeList.size() > 0){ |
| | | for (Store store : storeList) { |
| | | String storeLon = store.getLon(); |
| | | String storeLat = store.getLat(); |
| | | String result = storeLon+","+storeLat; |
| | | String distanceTOKilometer = gdMapGeocodingUtil.getDistanceTOKilometer(current, result); |
| | | StoreInfo info = new StoreInfo(); |
| | | info.setStoreId(store.getId()); |
| | | info.setStoreName(store.getName()); |
| | | info.setStoreImg(store.getRealPicture()); |
| | | info.setDistance(Long.parseLong(distanceTOKilometer)); |
| | | info.setStoreAddr(store.getAddress()); |
| | | storeInfos.add(info); |
| | | } |
| | | Comparator<StoreInfo> distanceComparator = new Comparator<StoreInfo>() { |
| | | @Override |
| | | public int compare(StoreInfo store1, StoreInfo store2) { |
| | | return Long.compare(store1.getDistance(), store2.getDistance()); |
| | | } |
| | | }; |
| | | Collections.sort(storeInfos, distanceComparator); |
| | | } |
| | | return storeInfos; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/storeDetail/storeOfLonLat") |
| | | public List<StoreLonLatList> getAllStoreLonLats(@RequestBody String longitude, @RequestBody String latitude){ |
| | | List<StoreLonLatList> storeInfos = new ArrayList<>(); |
| | | try { |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(longitude, latitude); |
| | | String cityCode = geocode.get("cityCode"); |
| | | List<Store> storeList = stoService.list(new QueryWrapper<Store>() |
| | | .eq("cityCode",cityCode)); |
| | | if (storeList.size() > 0){ |
| | | for (Store store : storeList) { |
| | | StoreLonLatList latList = new StoreLonLatList(); |
| | | latList.setStoreId(store.getId()); |
| | | latList.setLongitude(store.getLon()); |
| | | latList.setLatitude(store.getLat()); |
| | | storeInfos.add(latList); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return storeInfos; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.controller; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.other.entity.Notice; |
| | | import com.dsh.other.entity.Phone; |
| | | import com.dsh.other.feignclient.model.SysNotice; |
| | | import com.dsh.other.service.NoticeService; |
| | | import com.dsh.other.service.PhoneService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class SystemNoticeController { |
| | | |
| | | @Autowired |
| | | private NoticeService noticeSers; |
| | | |
| | | @Autowired |
| | | private PhoneService phoneService; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | |
| | | |
| | | @PostMapping("/base/notice/queryNoticeDetails") |
| | | public List<SysNotice> getSysNoticeDetails(){ |
| | | List<SysNotice> notices = new ArrayList<>(); |
| | | List<Notice> list = noticeSers.list(new QueryWrapper<Notice>() |
| | | .eq("state", 1) |
| | | .eq("upOrDown", 1) |
| | | .orderByDesc("insertTime")); |
| | | if (list.size() > 0 ){ |
| | | list.forEach(noList -> { |
| | | SysNotice notice = new SysNotice(); |
| | | notice.setNoticeId(noList.getId()); |
| | | notice.setNoticeTitle(noList.getName()); |
| | | notice.setNoticeContents(noList.getContent()); |
| | | notice.setNoticeTime(format.format(noList.getInsertTime())); |
| | | notices.add(notice); |
| | | }); |
| | | } |
| | | return notices; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/notice/queryNotice") |
| | | public SysNotice getSysNoticeBuId(@RequestBody Integer noticeId){ |
| | | SysNotice sysNotice = new SysNotice(); |
| | | Notice notice = noticeSers.getById(noticeId); |
| | | if (null != notice){ |
| | | sysNotice.setNoticeId(notice.getId()); |
| | | sysNotice.setNoticeTitle(notice.getName()); |
| | | sysNotice.setNoticeContents(notice.getContent()); |
| | | sysNotice.setNoticeTime(format.format(notice.getInsertTime())); |
| | | } |
| | | return sysNotice; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/notice/sysTell") |
| | | public List<String> queryCustomerTel(){ |
| | | List<String> tellS = new ArrayList<>(); |
| | | List<Phone> list = phoneService.list(); |
| | | if (list.size() > 0 ){ |
| | | tellS = list.stream().map(Phone::getPhone).collect(Collectors.toList()); |
| | | } |
| | | return tellS; |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * 常见问题 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @TableName("t_frequently_asked_questions") |
| | | public class FrequentlyAskedQuestions extends Model<FrequentlyAskedQuestions> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | /** |
| | | * 常见问题 |
| | | */ |
| | | private String content; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | private Integer state; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | private Date insertTime; |
| | | /** |
| | | * 答复内容 |
| | | */ |
| | | private String answer; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * 公告 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @TableName("t_notice") |
| | | public class Notice extends Model<Notice> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | /** |
| | | * 功能名称 |
| | | */ |
| | | private String name; |
| | | /** |
| | | * 公告内容 |
| | | */ |
| | | private String content; |
| | | /** |
| | | * 排序 |
| | | */ |
| | | private Integer sort; |
| | | /** |
| | | * 状态(1=正常,2=冻结,3=删除) |
| | | */ |
| | | private Integer state; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | private Date insertTime; |
| | | /** |
| | | * 0下架1上架 |
| | | */ |
| | | private Integer upOrDown; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.extension.activerecord.Model; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.experimental.Accessors; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * 客服电话 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @Accessors(chain = true) |
| | | @TableName("t_phone") |
| | | public class Phone extends Model<Phone> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * 主键 |
| | | */ |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | /** |
| | | * 电话 |
| | | */ |
| | | private String phone; |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | private Date insertTime; |
| | | |
| | | |
| | | @Override |
| | | protected Serializable pkVal() { |
| | | return this.id; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.feignclient; |
| | | |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface CustomerClient { |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.feignclient; |
| | | |
| | | import com.dsh.other.feignclient.model.SysNotice; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface NoticeClient { |
| | | |
| | | |
| | | @PostMapping("/base/notice/queryNoticeDetails") |
| | | List<SysNotice> getSysNoticeDetails(); |
| | | |
| | | @PostMapping("/base/notice/queryNotice") |
| | | SysNotice getSysNoticeBuId(@RequestBody Integer noticeId); |
| | | |
| | | @PostMapping("/base/notice/sysTell") |
| | | List<String> queryCustomerTel(); |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.feignclient; |
| | | |
| | | import com.dsh.other.model.vo.questionVo.QuestionDetailsVo; |
| | | import com.dsh.other.model.vo.questionVo.QuestionIns; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface QuestionClient { |
| | | |
| | | @PostMapping("/base/notice/queryQuestionDetails") |
| | | QuestionDetailsVo getSysQuestionDetails(); |
| | | |
| | | @PostMapping("/base/notice/queryQuestion") |
| | | QuestionIns getSysQuestionBuId(@RequestBody Integer quesId); |
| | | |
| | | } |
| | |
| | | package com.dsh.other.feignclient; |
| | | |
| | | import com.dsh.other.feignclient.model.StoreDetailOfCourse; |
| | | import com.dsh.other.feignclient.model.StoreInfo; |
| | | import com.dsh.other.feignclient.model.StoreLonLatList; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | @FeignClient(value = "mb-cloud-other") |
| | | public interface StoreClient { |
| | |
| | | |
| | | @PostMapping("/storeDetail/courseOfSto") |
| | | public StoreDetailOfCourse getCourseOfStore(@RequestBody Integer storeId); |
| | | |
| | | |
| | | @PostMapping("/storeDetail/nearbyStore") |
| | | List<StoreInfo> getAllNearbyStoreList(@RequestBody String longitude, @RequestBody String latitude); |
| | | |
| | | |
| | | @PostMapping("/storeDetail/storeOfLonLat") |
| | | public List<StoreLonLatList> getAllStoreLonLats(@RequestBody String longitude, @RequestBody String latitude); |
| | | } |
New file |
| | |
| | | package com.dsh.other.feignclient.model; |
| | | |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StoreInfo { |
| | | |
| | | @ApiModelProperty(value = "门店id") |
| | | private Integer storeId; |
| | | |
| | | @ApiModelProperty(value = "门店背景图") |
| | | private String storeImg; |
| | | |
| | | @ApiModelProperty(value = "门店距离当前位置") |
| | | private long distance; |
| | | |
| | | @ApiModelProperty(value = "门店名称") |
| | | private String storeName; |
| | | |
| | | @ApiModelProperty(value = "门店详细地址") |
| | | private String storeAddr; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.feignclient.model; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StoreLonLatList { |
| | | |
| | | @ApiModelProperty(value = "门店id") |
| | | Integer storeId; |
| | | |
| | | @ApiModelProperty(value = "经度") |
| | | String longitude; |
| | | |
| | | @ApiModelProperty(value = "纬度") |
| | | String latitude; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.feignclient.model; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SysNotice { |
| | | |
| | | @ApiModelProperty(value = "公告id") |
| | | private Integer noticeId; |
| | | |
| | | @ApiModelProperty(value = "公告标题") |
| | | private String noticeTitle; |
| | | |
| | | @ApiModelProperty(value = "公告内容") |
| | | private String noticeContents; |
| | | |
| | | @ApiModelProperty(value = "公告发布时间") |
| | | private String noticeTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dsh.other.entity.FrequentlyAskedQuestions; |
| | | |
| | | /** |
| | | * <p> |
| | | * 常见问题 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | public interface FrequentlyAskedQuestionsMapper extends BaseMapper<FrequentlyAskedQuestions> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dsh.other.entity.Notice; |
| | | |
| | | /** |
| | | * <p> |
| | | * 公告 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | public interface NoticeMapper extends BaseMapper<Notice> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.dsh.other.entity.Phone; |
| | | |
| | | /** |
| | | * <p> |
| | | * 客服电话 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | public interface PhoneMapper extends BaseMapper<Phone> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.model.vo.questionVo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class QuestionDetailsVo { |
| | | |
| | | @ApiModelProperty(value = "banner图") |
| | | private String bannerImg; |
| | | |
| | | @ApiModelProperty(value = "问题列表") |
| | | private List<QuestionIns> sysS; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.model.vo.questionVo; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | @Data |
| | | public class QuestionIns { |
| | | |
| | | @ApiModelProperty(value = "问题id") |
| | | private Integer quesId; |
| | | |
| | | @ApiModelProperty(value = "问题标题") |
| | | private String quesTitle; |
| | | |
| | | @ApiModelProperty(value = "答复内容") |
| | | private String quesContents; |
| | | |
| | | @ApiModelProperty(value = "答复内容") |
| | | private String quesTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.other.entity.FrequentlyAskedQuestions; |
| | | |
| | | /** |
| | | * <p> |
| | | * 常见问题 服务类 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | public interface FrequentlyAskedQuestionsService extends IService<FrequentlyAskedQuestions> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.other.entity.Notice; |
| | | |
| | | /** |
| | | * <p> |
| | | * 公告 服务类 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | public interface NoticeService extends IService<Notice> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.dsh.other.entity.Phone; |
| | | |
| | | /** |
| | | * <p> |
| | | * 客服电话 服务类 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | public interface PhoneService extends IService<Phone> { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.other.entity.FrequentlyAskedQuestions; |
| | | import com.dsh.other.mapper.FrequentlyAskedQuestionsMapper; |
| | | import com.dsh.other.service.FrequentlyAskedQuestionsService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 常见问题 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | @Service |
| | | public class FrequentlyAskedQuestionsServiceImpl extends ServiceImpl<FrequentlyAskedQuestionsMapper, FrequentlyAskedQuestions> implements FrequentlyAskedQuestionsService { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.other.entity.Notice; |
| | | import com.dsh.other.mapper.NoticeMapper; |
| | | import com.dsh.other.service.NoticeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 公告 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | @Service |
| | | public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements NoticeService { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.other.entity.Phone; |
| | | import com.dsh.other.mapper.PhoneMapper; |
| | | import com.dsh.other.service.PhoneService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 客服电话 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author jqs |
| | | * @since 2023-07-03 |
| | | */ |
| | | @Service |
| | | public class PhoneServiceImpl extends ServiceImpl<PhoneMapper, Phone> implements PhoneService { |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStreamReader; |
| | | import java.net.MalformedURLException; |
| | | import java.net.URL; |
| | | import java.net.URLConnection; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 高德地图的地理编码工具类 |
| | | */ |
| | | @Component |
| | | public class GDMapGeocodingUtil { |
| | | |
| | | private String key = "fb131ad2dbfb3f39d7d37d244b92aa2d"; |
| | | |
| | | @Autowired |
| | | private HttpClientUtil httpClientUtil; |
| | | |
| | | |
| | | /** |
| | | * 将行政区域名称转化为坐标 |
| | | * @param province |
| | | * @param city |
| | | * @param county |
| | | * @param address |
| | | * @return |
| | | */ |
| | | public Map<String, Object> geocoding(String province, String city, String county, String address) throws Exception{ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | if(ToolUtil.isEmpty(province)){ |
| | | map.put("status", -1); |
| | | map.put("data", "省不能为空"); |
| | | return map; |
| | | } |
| | | if((ToolUtil.isEmpty(city) && ToolUtil.isNotEmpty(county)) || (ToolUtil.isEmpty(city) && ToolUtil.isNotEmpty(address))){ |
| | | map.put("status", -1); |
| | | map.put("data", "市不能为空"); |
| | | return map; |
| | | } |
| | | if((ToolUtil.isEmpty(county) && ToolUtil.isNotEmpty(address))){ |
| | | map.put("status", -1); |
| | | map.put("data", "县/区不能为空"); |
| | | return map; |
| | | } |
| | | |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON"; |
| | | url += "&address=" + province + (ToolUtil.isNotEmpty(city) ? city : "") + (ToolUtil.isNotEmpty(county) ? county : "") + (ToolUtil.isNotEmpty(address) ? address : ""); |
| | | HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | String status = jsonObject.getString("status"); |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | | // gdInterfaceService.saveData("https://restapi.amap.com/v3/geocode/geo", "行政区域转经纬度"); |
| | | |
| | | if(status.equals("1")){ |
| | | JSONArray geocodes = jsonObject.getJSONArray("geocodes"); |
| | | for(int i = 0; i < geocodes.size(); i++){ |
| | | String location = geocodes.getJSONObject(i).getString("location"); |
| | | list.add(location); |
| | | } |
| | | } |
| | | map.put("status", 0); |
| | | map.put("data", list); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | public Map<String, Object> geocoding(String address) throws Exception{ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | String url = "https://restapi.amap.com/v3/geocode/geo?key=" + key + "&output=JSON&address=" + address; |
| | | HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | String status = jsonObject.getString("status"); |
| | | List<String> list = new ArrayList<>(); |
| | | |
| | | // gdInterfaceService.saveData("https://restapi.amap.com/v3/geocode/geo", "行政区域转经纬度"); |
| | | |
| | | if(status.equals("1")){ |
| | | JSONArray geocodes = jsonObject.getJSONArray("geocodes"); |
| | | for(int i = 0; i < geocodes.size(); i++){ |
| | | String location = geocodes.getJSONObject(i).getString("location"); |
| | | list.add(location); |
| | | } |
| | | } |
| | | map.put("status", 0); |
| | | map.put("data", list); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据经纬度获取行政区域信息 |
| | | * @param lon |
| | | * @param lan |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, String> geocode(String lon, String lan) throws Exception{ |
| | | String url = "https://restapi.amap.com/v3/geocode/regeo?key=" + key + "&location=" + lon + "," + lan; |
| | | HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | Map<String, String> map = new HashMap<>(); |
| | | |
| | | // gdInterfaceService.saveData("https://restapi.amap.com/v3/geocode/regeo", "经纬度转行政区域"); |
| | | |
| | | if(jsonObject.getString("status").equals("1")){ |
| | | JSONObject regeocode = jsonObject.getJSONObject("regeocode"); |
| | | JSONObject addressComponent = regeocode.getJSONObject("addressComponent"); |
| | | String address = regeocode.getString("formatted_address"); |
| | | map.put("address", address); |
| | | String code = addressComponent.getString("adcode"); |
| | | String province = addressComponent.getString("province"); |
| | | String city = addressComponent.getString("city"); |
| | | String district = addressComponent.getString("district"); |
| | | map.put("province", province); |
| | | map.put("provinceCode", code.substring(0, 2) + "0000"); |
| | | map.put("city", city); |
| | | map.put("cityCode", code.substring(0, 4) + "00"); |
| | | map.put("district", district); |
| | | map.put("districtCode", code); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 坐标转换 |
| | | * @param locations 经度和纬度用","分割,经度在前,纬度在后,经纬度小数点后不得超过6位。多个坐标对之间用”|”进行分隔最多支持40对坐标。 |
| | | * @param coordsys 可选值:gps;mapbar;baidu;autonavi(不进行转换) |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public Map<String, String> convert(String locations, String coordsys) throws Exception{ |
| | | String url = "https://restapi.amap.com/v3/assistant/coordinate/convert?locations=" + locations + "&coordsys=" + coordsys + "&output=json&key=" + key; |
| | | HttpResult httpResult = httpClientUtil.pushHttpRequset("GET", url, null, null, "json"); |
| | | JSONObject jsonObject = JSON.parseObject(httpResult.getData()); |
| | | Map<String, String> map = new HashMap<>(); |
| | | if("1".equals(jsonObject.getString("status"))){ |
| | | map.put("code", jsonObject.getString("infocode"));//"10000" |
| | | map.put("info", jsonObject.getString("info"));//status为0时,info返回错误原;否则返回“OK”。 |
| | | map.put("locations", jsonObject.getString("locations").split(";")[0]);//转换之后的坐标。若有多个坐标,则用 “;”进行区分和间隔 |
| | | }else{ |
| | | map.put("code", jsonObject.getString("infocode")); |
| | | map.put("info", jsonObject.getString("info"));//status为0时,info返回错误原;否则返回“OK”。 |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 功能描述: 根据两个定位点的经纬度算出两点间的距离(米/m) |
| | | * |
| | | * @param startLonLat 起始经纬度 |
| | | * @param endLonLat 结束经纬度(目标经纬度) |
| | | * @return java.lang.Long 两个定位点之间的距离 |
| | | */ |
| | | public Long getDistance(String startLonLat, String endLonLat) { |
| | | try { |
| | | // 返回起始地startAddr与目的地endAddr之间的距离,单位:米 |
| | | Long result = new Long(0); |
| | | String queryUrl = |
| | | "http://restapi.amap.com/v3/distance?key=" + key + "&origins=" + startLonLat |
| | | + "&destination=" |
| | | + endLonLat; |
| | | String queryResult = getResponse(queryUrl); |
| | | JSONObject job = JSONObject.parseObject(queryResult); |
| | | JSONArray ja = job.getJSONArray("results"); |
| | | JSONObject jobO = JSONObject.parseObject(ja.getString(0)); |
| | | result = Long.parseLong(jobO.get("distance").toString()); |
| | | return result; |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 功能描述: 根据两个定位点的经纬度算出两点间的距离(千米/km) |
| | | * |
| | | * @param startLonLat 起始经纬度 |
| | | * @param endLonLat 结束经纬度(目标经纬度) |
| | | * @return java.lang.Long 两个定位点之间的距离 |
| | | */ |
| | | public String getDistanceTOKilometer(String startLonLat, String endLonLat) { |
| | | try { |
| | | // 返回起始地startAddr与目的地endAddr之间的距离,单位:米 |
| | | Long result = new Long(0); |
| | | String queryUrl = |
| | | "http://restapi.amap.com/v3/distance?key=" + key + "&origins=" + startLonLat |
| | | + "&destination=" |
| | | + endLonLat; |
| | | String queryResult = getResponse(queryUrl); |
| | | JSONObject job = JSONObject.parseObject(queryResult); |
| | | JSONArray ja = job.getJSONArray("results"); |
| | | JSONObject jobO = JSONObject.parseObject(ja.getString(0)); |
| | | result = Long.parseLong(jobO.get("distance").toString()); |
| | | double kilDis = (double) result / 1000; |
| | | DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
| | | return decimalFormat.format(kilDis); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 功能描述: 发送请求 |
| | | * |
| | | * @param serverUrl 请求地址 |
| | | * @return java.lang.String |
| | | * @author isymikasan |
| | | * @date 2022-01-26 09:15:01 |
| | | */ |
| | | private static String getResponse(String serverUrl) { |
| | | // 用JAVA发起http请求,并返回json格式的结果 |
| | | StringBuffer result = new StringBuffer(); |
| | | try { |
| | | URL url = new URL(serverUrl); |
| | | URLConnection conn = url.openConnection(); |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); |
| | | String line; |
| | | while ((line = in.readLine()) != null) { |
| | | result.append(line); |
| | | } |
| | | in.close(); |
| | | } catch (MalformedURLException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return result.toString(); |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.conn.ssl.SSLConnectionSocketFactory; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.http.entity.StringEntity; |
| | | import org.apache.http.impl.client.CloseableHttpClient; |
| | | import org.apache.http.impl.client.HttpClients; |
| | | import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; |
| | | import org.apache.http.message.BasicNameValuePair; |
| | | import org.apache.http.ssl.SSLContexts; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.net.ssl.SSLContext; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.nio.charset.Charset; |
| | | import java.security.KeyStore; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * http工具类 |
| | | */ |
| | | @Component |
| | | public class HttpClientUtil { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(HttpClientUtil.class); |
| | | |
| | | private PoolingHttpClientConnectionManager connectionManager; |
| | | |
| | | |
| | | public HttpClientUtil(){ |
| | | //1.创建连接池管理器 |
| | | connectionManager = new PoolingHttpClientConnectionManager(60000, |
| | | TimeUnit.MILLISECONDS); |
| | | connectionManager.setMaxTotal(1000); |
| | | connectionManager.setDefaultMaxPerRoute(50); |
| | | } |
| | | |
| | | /** |
| | | * 创建一个httpClient对象 |
| | | */ |
| | | private CloseableHttpClient getHttpCline(){ |
| | | return HttpClients.custom() |
| | | .setConnectionManager(connectionManager) |
| | | .disableAutomaticRetries() |
| | | .build(); |
| | | } |
| | | |
| | | private RequestConfig getRequestConfig(){ |
| | | RequestConfig.Builder builder = RequestConfig.custom(); |
| | | builder.setSocketTimeout(60000)//3.1设置客户端等待服务端返回数据的超时时间 |
| | | .setConnectTimeout(30000)//3.2设置客户端发起TCP连接请求的超时时间 |
| | | .setExpectContinueEnabled(true) |
| | | .setConnectionRequestTimeout(30000);//3.3设置客户端从连接池获取链接的超时时间 |
| | | return builder.build(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 创建一个POST请求实例 |
| | | * @param url 请求地址 |
| | | * @param params 请求参数 |
| | | */ |
| | | private CloseableHttpResponse setPostHttpRequset(String url, Map<String, Object> params, Map<String, String> header, String contentType) throws Exception{ |
| | | HttpPost httpPost = new HttpPost(url); |
| | | httpPost.setConfig(this.getRequestConfig()); |
| | | if(null != header){ |
| | | for(String key : header.keySet()){ |
| | | httpPost.setHeader(key, header.get(key)); |
| | | } |
| | | } |
| | | List<NameValuePair> list = new ArrayList<>(); |
| | | if(null != params){ |
| | | Set<String> keys = params.keySet(); |
| | | for(String key : keys){ |
| | | list.add(new BasicNameValuePair(key, null == params.get(key) ? null : params.get(key).toString())); |
| | | } |
| | | } |
| | | switch (contentType){ |
| | | case "form": |
| | | httpPost.setEntity(new UrlEncodedFormEntity(list, "UTF-8")); |
| | | break; |
| | | case "json": |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | String s =objectMapper.writeValueAsString(params); |
| | | httpPost.setEntity(new StringEntity(s, ContentType.create(ContentType.APPLICATION_JSON.getMimeType(), Charset.forName("UTF-8")))); |
| | | break; |
| | | } |
| | | return getHttpCline().execute(httpPost); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取get请求实例 |
| | | * @param url 请求地址 |
| | | * @param params 请求参数 |
| | | */ |
| | | private CloseableHttpResponse setGetHttpRequset(String url, Map<String, Object> params, Map<String, String> header) throws Exception{ |
| | | StringBuffer sb = new StringBuffer(); |
| | | String p = ""; |
| | | if(null != params){ |
| | | Set<String> keys = params.keySet(); |
| | | for(String key : keys){ |
| | | sb.append(key + "=" + params.get(key) + "&"); |
| | | } |
| | | p = "?" + sb.substring(0, sb.length() - 1); |
| | | } |
| | | HttpGet httpGet = new HttpGet(url + p); |
| | | httpGet.setConfig(getRequestConfig()); |
| | | if(null != header){ |
| | | for(String key : header.keySet()){ |
| | | httpGet.setHeader(key, header.get(key)); |
| | | } |
| | | } |
| | | return getHttpCline().execute(httpGet); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送http请求 |
| | | * @param mothed "GET、POST、PUT、HEAD、DELETE、HEAD、OPTIONS" |
| | | * @param url 请求地址 |
| | | * @param params 请求参数 |
| | | * @param header 请求头 |
| | | * @param contentType 参数请求方式form/json |
| | | * @return |
| | | */ |
| | | public HttpResult pushHttpRequset(String mothed, String url, Map<String, Object> params, Map<String, String> header, String contentType) throws Exception{ |
| | | String randome = UUID.randomUUID().toString(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); |
| | | logger.info(sdf.format(new Date()) + "----(" + randome + ")请求参数:" + JSON.toJSONString(params)); |
| | | CloseableHttpResponse httpResponse = null; |
| | | switch (mothed){ |
| | | case "GET": |
| | | httpResponse = this.setGetHttpRequset(url, params, header); |
| | | break; |
| | | case "POST": |
| | | httpResponse = setPostHttpRequset(url, params, header, contentType); |
| | | break; |
| | | } |
| | | int statusCode = httpResponse.getStatusLine().getStatusCode(); |
| | | String content = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); |
| | | logger.info(sdf.format(new Date()) + "----(" + randome + ")返回结果:" + content); |
| | | HttpResult httpResult = HttpResult.getHttpResult(statusCode, content); |
| | | this.close(httpResponse); |
| | | return httpResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送XML请求 |
| | | * @param url 请求地址 |
| | | * @param xml XML数据 |
| | | * @param header 自定义请求头 |
| | | * @return |
| | | */ |
| | | public HttpResult pushHttpRequsetXml(String url, String xml, Map<String, String> header) throws Exception{ |
| | | HttpPost httpPost = new HttpPost(url); |
| | | httpPost.setConfig(getRequestConfig()); |
| | | for(String key : header.keySet()){ |
| | | httpPost.setHeader(key, header.get(key)); |
| | | } |
| | | httpPost.setHeader("Content-Type", "application/xml"); |
| | | httpPost.setEntity(new StringEntity(xml, "UTF-8")); |
| | | CloseableHttpResponse httpResponse = getHttpCline().execute(httpPost); |
| | | int statusCode = httpResponse.getStatusLine().getStatusCode(); |
| | | String content = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); |
| | | HttpResult httpResult = HttpResult.getHttpResult(statusCode, content); |
| | | this.close(httpResponse); |
| | | return httpResult; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 请求https发送XML请求 |
| | | * @param url 接口路径 |
| | | * @param xml 内容 |
| | | * @param header 请求头 |
| | | * @param certPassword 证书密码 |
| | | * @param certPath 证书路径 |
| | | * @param certType 证书类型 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public String pushHttpsRequsetXml(String url, String xml, Map<String, String> header, String certPassword, String certPath, String certType) throws Exception{ |
| | | HttpPost httpPost = new HttpPost(url); |
| | | for(String key : header.keySet()){ |
| | | httpPost.setHeader(key, header.get(key)); |
| | | } |
| | | httpPost.setHeader("Content-Type", "application/xml"); |
| | | httpPost.setEntity(new StringEntity(xml, "UTF-8")); |
| | | CloseableHttpClient httpCline = this.initCert(certPassword, certPath, certType); |
| | | CloseableHttpResponse httpResponse = httpCline.execute(httpPost); |
| | | String content = null; |
| | | if(httpResponse.getStatusLine().getStatusCode() == 200){ |
| | | content = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); |
| | | }else{ |
| | | content = "返回状态码:" + httpResponse.getStatusLine() + "。" + EntityUtils.toString(httpResponse.getEntity()); |
| | | } |
| | | this.close(httpResponse); |
| | | httpCline.close(); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 初始化https对象(带证书) |
| | | * @param key 证书密码 |
| | | * @param certPath 证书路径 |
| | | * @param certType 证书类型 |
| | | * @throws Exception |
| | | */ |
| | | private CloseableHttpClient initCert(String key, String certPath, String certType) throws Exception { |
| | | KeyStore keyStore = KeyStore.getInstance(certType); |
| | | InputStream inputStream = new FileInputStream(new File(certPath)); |
| | | try { |
| | | keyStore.load(inputStream, key.toCharArray()); |
| | | } finally { |
| | | inputStream.close(); |
| | | } |
| | | SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, key.toCharArray()).build(); |
| | | SSLConnectionSocketFactory sslsf = |
| | | new SSLConnectionSocketFactory(sslcontext, new String[] {"TLSv1"}, null, |
| | | SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER); |
| | | return HttpClients.custom().setSSLSocketFactory(sslsf).build(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 关闭资源 |
| | | */ |
| | | private void close(CloseableHttpResponse httpResponse){ |
| | | try { |
| | | if(null != httpResponse){ |
| | | EntityUtils.consume(httpResponse.getEntity());//此处高能,通过源码分析,由EntityUtils是否回收HttpEntity |
| | | httpResponse.close(); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | try { |
| | | if(null != httpResponse){ |
| | | httpResponse.close(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.dsh.other.util; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * http请求返回封装 |
| | | */ |
| | | @Data |
| | | public class HttpResult { |
| | | /** |
| | | * 返回状态码 |
| | | */ |
| | | private Integer code; |
| | | /** |
| | | * 返回结果 |
| | | */ |
| | | private String data; |
| | | |
| | | /** |
| | | * 返回封装结果 |
| | | * @param code |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public static HttpResult getHttpResult(Integer code, String data){ |
| | | HttpResult httpResult = new HttpResult(); |
| | | httpResult.setCode(code); |
| | | httpResult.setData(data); |
| | | return httpResult; |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dsh.other.mapper.FrequentlyAskedQuestionsMapper"> |
| | | |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dsh.other.mapper.NoticeMapper"> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.dsh.other.mapper.PhoneMapper"> |
| | | |
| | | |
| | | </mapper> |