From 3faea128cb8fb041c3164e2313a164d305660a62 Mon Sep 17 00:00:00 2001 From: lisy <linlangsur163@163.com> Date: 星期一, 03 七月 2023 16:16:27 +0800 Subject: [PATCH] 探索玩湃:接口开发 --- cloud-server-account/src/main/java/com/dsh/account/feignclient/other/NoticeClient.java | 24 cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/SysNotice.java | 20 cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionIns.java | 22 cloud-server-other/src/main/java/com/dsh/other/util/HttpResult.java | 31 cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java | 73 ++ cloud-server-other/src/main/java/com/dsh/other/mapper/PhoneMapper.java | 16 cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreInfo.java | 25 cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreInfo.java | 25 cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java | 32 + cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java | 50 + cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionIns.java | 19 cloud-server-other/src/main/java/com/dsh/other/feignclient/QuestionClient.java | 19 cloud-server-other/src/main/resources/mapper/NoticeMapper.xml | 5 cloud-server-other/src/main/java/com/dsh/other/mapper/NoticeMapper.java | 16 cloud-server-account/src/main/java/com/dsh/account/controller/ExploreWPController.java | 120 +++ cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionDetailsVo.java | 17 cloud-server-other/src/main/java/com/dsh/other/service/impl/PhoneServiceImpl.java | 20 cloud-server-other/src/main/resources/mapper/PhoneMapper.xml | 6 cloud-server-other/src/main/java/com/dsh/other/controller/AskedQuestionsController.java | 64 ++ cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java | 36 + cloud-server-account/src/main/java/com/dsh/account/feignclient/other/QuestionClient.java | 19 cloud-server-other/src/main/java/com/dsh/other/feignclient/NoticeClient.java | 25 cloud-server-account/src/main/java/com/dsh/account/util/GDMapGeocodingUtil.java | 93 ++ cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java | 29 cloud-server-other/src/main/java/com/dsh/other/entity/Notice.java | 66 ++ cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreLonLatList.java | 19 cloud-server-account/src/main/java/com/dsh/account/model/vo/medalDetail/StuMedalVo.java | 22 cloud-server-other/src/main/java/com/dsh/other/entity/Phone.java | 50 + cloud-server-other/src/main/java/com/dsh/other/service/NoticeService.java | 16 cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/ExploreDatasVo.java | 19 cloud-server-other/src/main/resources/mapper/FrequentlyAskedQuestionsMapper.xml | 6 cloud-server-other/src/main/java/com/dsh/other/mapper/FrequentlyAskedQuestionsMapper.java | 16 cloud-server-other/src/main/java/com/dsh/other/service/FrequentlyAskedQuestionsService.java | 16 cloud-server-other/src/main/java/com/dsh/other/service/PhoneService.java | 16 cloud-server-other/src/main/java/com/dsh/other/entity/FrequentlyAskedQuestions.java | 62 + cloud-server-other/src/main/java/com/dsh/other/feignclient/StoreClient.java | 12 cloud-server-other/src/main/java/com/dsh/other/service/impl/FrequentlyAskedQuestionsServiceImpl.java | 20 cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java | 249 +++++++ cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionDetailsVo.java | 17 cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreLonLatList.java | 19 cloud-server-other/src/main/java/com/dsh/other/feignclient/CustomerClient.java | 12 cloud-server-other/src/main/java/com/dsh/other/controller/SystemNoticeController.java | 80 ++ cloud-server-other/src/main/java/com/dsh/other/feignclient/model/SysNotice.java | 21 cloud-server-other/src/main/java/com/dsh/other/util/HttpClientUtil.java | 269 ++++++++ cloud-server-account/src/main/java/com/dsh/account/feignclient/other/StoreClient.java | 12 cloud-server-other/src/main/java/com/dsh/other/service/impl/NoticeServiceImpl.java | 20 cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/LonLatRequest.java | 15 cloud-server-account/src/main/resources/mapper/EvaluateStudentMapper.xml | 3 48 files changed, 1,857 insertions(+), 6 deletions(-) diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java index 076c089..ac52483 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java +++ b/cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java @@ -6,6 +6,7 @@ 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; @@ -206,7 +207,7 @@ /** - * 课时详情-续课 + * 课时详情-续课课包详情 */ @ResponseBody @PostMapping("/base/startCource/renewal") @@ -229,7 +230,7 @@ /** - * 课时详情-续课 + * 课时详情-选择优惠券 */ @ResponseBody @PostMapping("/base/startCource/conponList") @@ -253,7 +254,7 @@ /** - * 课时详情-续课 + * 课时详情-支付 */ @ResponseBody @PostMapping("/base/startCource/payment") @@ -290,5 +291,27 @@ } + /** + * 学员勋章 + */ + @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(); + } + } + } diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/ExploreWPController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/ExploreWPController.java new file mode 100644 index 0000000..cd8aaf7 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/controller/ExploreWPController.java @@ -0,0 +1,120 @@ +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(); + } + } + + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java new file mode 100644 index 0000000..fad5bff --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/controller/PaymentCallbackController.java @@ -0,0 +1,36 @@ +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(){ + + } + + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/NoticeClient.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/NoticeClient.java new file mode 100644 index 0000000..159b15a --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/NoticeClient.java @@ -0,0 +1,24 @@ +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(); + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/QuestionClient.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/QuestionClient.java new file mode 100644 index 0000000..9380603 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/QuestionClient.java @@ -0,0 +1,19 @@ +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); + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/StoreClient.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/StoreClient.java index 09f6ba7..aadb32f 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/StoreClient.java +++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/StoreClient.java @@ -1,9 +1,13 @@ 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 { @@ -11,4 +15,12 @@ @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); } diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreInfo.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreInfo.java new file mode 100644 index 0000000..5964072 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreInfo.java @@ -0,0 +1,25 @@ +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; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreLonLatList.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreLonLatList.java new file mode 100644 index 0000000..38646da --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/StoreLonLatList.java @@ -0,0 +1,19 @@ +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; + + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/SysNotice.java b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/SysNotice.java new file mode 100644 index 0000000..8929709 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/feignclient/other/model/SysNotice.java @@ -0,0 +1,20 @@ +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; +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/ExploreDatasVo.java b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/ExploreDatasVo.java new file mode 100644 index 0000000..bd52503 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/ExploreDatasVo.java @@ -0,0 +1,19 @@ +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; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/LonLatRequest.java b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/LonLatRequest.java new file mode 100644 index 0000000..1c9c54a --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetail/LonLatRequest.java @@ -0,0 +1,15 @@ +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; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionDetailsVo.java b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionDetailsVo.java new file mode 100644 index 0000000..89044aa --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionDetailsVo.java @@ -0,0 +1,17 @@ +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; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionIns.java b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionIns.java new file mode 100644 index 0000000..d1c3f66 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/model/vo/exploreDetails/QuestionIns.java @@ -0,0 +1,19 @@ +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; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/model/vo/medalDetail/StuMedalVo.java b/cloud-server-account/src/main/java/com/dsh/account/model/vo/medalDetail/StuMedalVo.java new file mode 100644 index 0000000..1e863f3 --- /dev/null +++ b/cloud-server-account/src/main/java/com/dsh/account/model/vo/medalDetail/StuMedalVo.java @@ -0,0 +1,22 @@ +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; + +} diff --git a/cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java b/cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java index df76367..e121355 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java +++ b/cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java @@ -3,8 +3,13 @@ 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; @@ -30,5 +35,32 @@ 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); } diff --git a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java index d632403..dc7cee2 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java +++ b/cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java @@ -15,12 +15,21 @@ 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; @@ -70,6 +79,12 @@ @Autowired private StoreClient storeClient; + + @Autowired + private NoticeClient noClient; + + @Autowired + private QuestionClient quesClient; @Autowired private TAppUserMapper tauMapper; @@ -175,6 +190,41 @@ 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>() { diff --git a/cloud-server-account/src/main/java/com/dsh/account/util/GDMapGeocodingUtil.java b/cloud-server-account/src/main/java/com/dsh/account/util/GDMapGeocodingUtil.java index 1b136d5..c9d9dc7 100644 --- a/cloud-server-account/src/main/java/com/dsh/account/util/GDMapGeocodingUtil.java +++ b/cloud-server-account/src/main/java/com/dsh/account/util/GDMapGeocodingUtil.java @@ -8,6 +8,13 @@ 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; @@ -155,4 +162,90 @@ } 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(); + } + + } diff --git a/cloud-server-account/src/main/resources/mapper/EvaluateStudentMapper.xml b/cloud-server-account/src/main/resources/mapper/EvaluateStudentMapper.xml index 47ed8a8..9730a83 100644 --- a/cloud-server-account/src/main/resources/mapper/EvaluateStudentMapper.xml +++ b/cloud-server-account/src/main/resources/mapper/EvaluateStudentMapper.xml @@ -2,7 +2,4 @@ <!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> diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/AskedQuestionsController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/AskedQuestionsController.java new file mode 100644 index 0000000..ae9072a --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/AskedQuestionsController.java @@ -0,0 +1,64 @@ +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; + } +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java index b75c2ee..f0ce01f 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/StoreController.java @@ -1,14 +1,20 @@ 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") @@ -17,6 +23,9 @@ @Autowired private StoreService stoService; + + @Autowired + private GDMapGeocodingUtil gdMapGeocodingUtil; @PostMapping("/storeDetail/courseOfSto") public StoreDetailOfCourse getCourseOfStore(@RequestBody Integer storeId){ @@ -29,4 +38,68 @@ 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; + } + } diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/SystemNoticeController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/SystemNoticeController.java new file mode 100644 index 0000000..04c441b --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/SystemNoticeController.java @@ -0,0 +1,80 @@ +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; + + } + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/entity/FrequentlyAskedQuestions.java b/cloud-server-other/src/main/java/com/dsh/other/entity/FrequentlyAskedQuestions.java new file mode 100644 index 0000000..ab07537 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/entity/FrequentlyAskedQuestions.java @@ -0,0 +1,62 @@ +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; + } + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/entity/Notice.java b/cloud-server-other/src/main/java/com/dsh/other/entity/Notice.java new file mode 100644 index 0000000..55be75b --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/entity/Notice.java @@ -0,0 +1,66 @@ +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; + } + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/entity/Phone.java b/cloud-server-other/src/main/java/com/dsh/other/entity/Phone.java new file mode 100644 index 0000000..885b4f5 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/entity/Phone.java @@ -0,0 +1,50 @@ +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; + } + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/CustomerClient.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/CustomerClient.java new file mode 100644 index 0000000..b917c98 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/CustomerClient.java @@ -0,0 +1,12 @@ +package com.dsh.other.feignclient; + +import org.springframework.cloud.openfeign.FeignClient; + +@FeignClient(value = "mb-cloud-other") +public interface CustomerClient { + + + + + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/NoticeClient.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/NoticeClient.java new file mode 100644 index 0000000..f42577e --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/NoticeClient.java @@ -0,0 +1,25 @@ +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(); + + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/QuestionClient.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/QuestionClient.java new file mode 100644 index 0000000..a37da84 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/QuestionClient.java @@ -0,0 +1,19 @@ +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); + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/StoreClient.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/StoreClient.java index 16b9a51..67097be 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/feignclient/StoreClient.java +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/StoreClient.java @@ -1,9 +1,13 @@ 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 { @@ -11,4 +15,12 @@ @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); } diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreInfo.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreInfo.java new file mode 100644 index 0000000..12f23b1 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreInfo.java @@ -0,0 +1,25 @@ +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; + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreLonLatList.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreLonLatList.java new file mode 100644 index 0000000..fffe6d1 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/StoreLonLatList.java @@ -0,0 +1,19 @@ +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; + + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/SysNotice.java b/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/SysNotice.java new file mode 100644 index 0000000..9335041 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/feignclient/model/SysNotice.java @@ -0,0 +1,21 @@ +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; + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/mapper/FrequentlyAskedQuestionsMapper.java b/cloud-server-other/src/main/java/com/dsh/other/mapper/FrequentlyAskedQuestionsMapper.java new file mode 100644 index 0000000..629c450 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/mapper/FrequentlyAskedQuestionsMapper.java @@ -0,0 +1,16 @@ +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> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/mapper/NoticeMapper.java b/cloud-server-other/src/main/java/com/dsh/other/mapper/NoticeMapper.java new file mode 100644 index 0000000..51dbcba --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/mapper/NoticeMapper.java @@ -0,0 +1,16 @@ +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> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/mapper/PhoneMapper.java b/cloud-server-other/src/main/java/com/dsh/other/mapper/PhoneMapper.java new file mode 100644 index 0000000..64d9a2b --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/mapper/PhoneMapper.java @@ -0,0 +1,16 @@ +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> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionDetailsVo.java b/cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionDetailsVo.java new file mode 100644 index 0000000..8296138 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionDetailsVo.java @@ -0,0 +1,17 @@ +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; + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionIns.java b/cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionIns.java new file mode 100644 index 0000000..9c2ccc6 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/model/vo/questionVo/QuestionIns.java @@ -0,0 +1,22 @@ +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; + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/FrequentlyAskedQuestionsService.java b/cloud-server-other/src/main/java/com/dsh/other/service/FrequentlyAskedQuestionsService.java new file mode 100644 index 0000000..bc2f6e7 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/service/FrequentlyAskedQuestionsService.java @@ -0,0 +1,16 @@ +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> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/NoticeService.java b/cloud-server-other/src/main/java/com/dsh/other/service/NoticeService.java new file mode 100644 index 0000000..8778f4b --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/service/NoticeService.java @@ -0,0 +1,16 @@ +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> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/PhoneService.java b/cloud-server-other/src/main/java/com/dsh/other/service/PhoneService.java new file mode 100644 index 0000000..1749fe4 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/service/PhoneService.java @@ -0,0 +1,16 @@ +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> { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/impl/FrequentlyAskedQuestionsServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/other/service/impl/FrequentlyAskedQuestionsServiceImpl.java new file mode 100644 index 0000000..0a60e66 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/service/impl/FrequentlyAskedQuestionsServiceImpl.java @@ -0,0 +1,20 @@ +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 { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/impl/NoticeServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/other/service/impl/NoticeServiceImpl.java new file mode 100644 index 0000000..c3a512a --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/service/impl/NoticeServiceImpl.java @@ -0,0 +1,20 @@ +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 { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/impl/PhoneServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/other/service/impl/PhoneServiceImpl.java new file mode 100644 index 0000000..6c5edfa --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/service/impl/PhoneServiceImpl.java @@ -0,0 +1,20 @@ +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 { + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java b/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java new file mode 100644 index 0000000..d25130a --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/util/GDMapGeocodingUtil.java @@ -0,0 +1,249 @@ +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(); + } + + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/HttpClientUtil.java b/cloud-server-other/src/main/java/com/dsh/other/util/HttpClientUtil.java new file mode 100644 index 0000000..4d493ae --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/util/HttpClientUtil.java @@ -0,0 +1,269 @@ +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(); + } + } + } + + +} diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/HttpResult.java b/cloud-server-other/src/main/java/com/dsh/other/util/HttpResult.java new file mode 100644 index 0000000..8ff2602 --- /dev/null +++ b/cloud-server-other/src/main/java/com/dsh/other/util/HttpResult.java @@ -0,0 +1,31 @@ +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; + } +} diff --git a/cloud-server-other/src/main/resources/mapper/FrequentlyAskedQuestionsMapper.xml b/cloud-server-other/src/main/resources/mapper/FrequentlyAskedQuestionsMapper.xml new file mode 100644 index 0000000..084e295 --- /dev/null +++ b/cloud-server-other/src/main/resources/mapper/FrequentlyAskedQuestionsMapper.xml @@ -0,0 +1,6 @@ +<?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> diff --git a/cloud-server-other/src/main/resources/mapper/NoticeMapper.xml b/cloud-server-other/src/main/resources/mapper/NoticeMapper.xml new file mode 100644 index 0000000..7113ac5 --- /dev/null +++ b/cloud-server-other/src/main/resources/mapper/NoticeMapper.xml @@ -0,0 +1,5 @@ +<?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> diff --git a/cloud-server-other/src/main/resources/mapper/PhoneMapper.xml b/cloud-server-other/src/main/resources/mapper/PhoneMapper.xml new file mode 100644 index 0000000..2f5221f --- /dev/null +++ b/cloud-server-other/src/main/resources/mapper/PhoneMapper.xml @@ -0,0 +1,6 @@ +<?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> -- Gitblit v1.7.1