|
@@ -3,11 +3,13 @@ package org.jeecg.modules.app.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.jeecg.modules.app.dto.GetPlaceListDTO;
|
|
|
+import org.jeecg.modules.app.dto.SearchDTO;
|
|
|
import org.jeecg.modules.app.service.IAppHomeService;
|
|
|
import org.jeecg.modules.app.vo.*;
|
|
|
import org.jeecg.modules.system.app.entity.AppBanner;
|
|
|
-import org.jeecg.modules.system.app.entity.AppCourese;
|
|
|
+import org.jeecg.modules.system.app.entity.AppCourses;
|
|
|
import org.jeecg.modules.system.app.entity.AppInstructor;
|
|
|
+import org.jeecg.modules.system.app.entity.AppSearchHot;
|
|
|
import org.jeecg.modules.system.app.mapper.*;
|
|
|
import org.jeecg.modules.system.entity.SysDepart;
|
|
|
import org.jeecg.modules.system.entity.SysUser;
|
|
@@ -29,7 +31,7 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
@Resource
|
|
|
private AppBannerMapper appBannerMapper;
|
|
|
@Resource
|
|
|
- private AppCoureseMapper appCoureseMapper;
|
|
|
+ private AppCoursesMapper appCoursesMapper;
|
|
|
@Resource
|
|
|
private AppInstructorMapper appInstructorMapper;
|
|
|
@Resource
|
|
@@ -40,6 +42,10 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
private AppSiteMapper appSiteMapper;
|
|
|
@Resource
|
|
|
private AppCategoryMapper appCategoryMapper;
|
|
|
+ @Resource
|
|
|
+ private AppGameMapper appGameMapper;
|
|
|
+ @Resource
|
|
|
+ private AppSearchHotMapper appSearchHotMapper;
|
|
|
|
|
|
@Override
|
|
|
public HomeVO homeInfo() {
|
|
@@ -48,17 +54,17 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
.eq(AppBanner::getDelFlag, 0).eq(AppBanner::getIsEnabled,1));
|
|
|
|
|
|
// 精品课程(最多3个)
|
|
|
- List<AppCourese> appCoureseFine = appCoureseMapper.selectList(Wrappers.<AppCourese>lambdaQuery()
|
|
|
- .eq(AppCourese::getPriceType, 0).last("LIMIT 3"));
|
|
|
+ List<AppCourses> appCoursesFine = appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery()
|
|
|
+ .eq(AppCourses::getPriceType, 0).last("LIMIT 3"));
|
|
|
|
|
|
// 免费课程(最多3个)
|
|
|
- List<AppCourese> appCoureseFree = appCoureseMapper.selectList(Wrappers.<AppCourese>lambdaQuery()
|
|
|
- .eq(AppCourese::getPriceType, 1).last("LIMIT 3"));
|
|
|
+ List<AppCourses> appCoursesFree = appCoursesMapper.selectList(Wrappers.<AppCourses>lambdaQuery()
|
|
|
+ .eq(AppCourses::getPriceType, 1).last("LIMIT 3"));
|
|
|
|
|
|
// 合并课程信息
|
|
|
List<CoureseVO> courseVO = new ArrayList<>();
|
|
|
- courseVO.addAll(convertToCoureseVOList(appCoureseFine));
|
|
|
- courseVO.addAll(convertToCoureseVOList(appCoureseFree));
|
|
|
+ courseVO.addAll(convertToCoureseVOList(appCoursesFine));
|
|
|
+ courseVO.addAll(convertToCoureseVOList(appCoursesFree));
|
|
|
|
|
|
// 获取好评率最高的两个教练 ID
|
|
|
List<String> topInstructorUserIds = sysUserMapper.getUserIdListByRoleId(INSTRUCTOR).stream()
|
|
@@ -92,8 +98,8 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
.eq(SysDepart::getOrgCode, sysUser.getOrgCode())).getDepartName());
|
|
|
|
|
|
// 获取该教练的课程(最多取2个)
|
|
|
- List<AppCourese> courses = appCoureseMapper.selectList(
|
|
|
- Wrappers.<AppCourese>lambdaQuery().eq(AppCourese::getUserId, userId).last("LIMIT 2"));
|
|
|
+ List<AppCourses> courses = appCoursesMapper.selectList(
|
|
|
+ Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, userId).last("LIMIT 2"));
|
|
|
|
|
|
List<InstructorVO.CourseInfoVO> courseInfoVOS = courses.stream()
|
|
|
.map(course -> {
|
|
@@ -125,10 +131,10 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
* @Author SheepHy
|
|
|
* @Description 合并课程信息
|
|
|
* @Date 9:14 2025/7/4
|
|
|
- * @Param appCoureseList {@link List<AppCourese>}
|
|
|
+ * @Param appCoureseList {@link List<AppCourses>}
|
|
|
* @return List<CoureseVO> {@link List<CoureseVO>}
|
|
|
**/
|
|
|
- private List<CoureseVO> convertToCoureseVOList(List<AppCourese> appCoureseList) {
|
|
|
+ private List<CoureseVO> convertToCoureseVOList(List<AppCourses> appCoureseList) {
|
|
|
return appCoureseList.stream()
|
|
|
.map(courese -> new CoureseVO()
|
|
|
.setId(courese.getId()).setCover(courese.getCover())
|
|
@@ -142,18 +148,13 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
Page<PlaceVO> page = new Page<>(getPlaceListDTO.getCurrent(), getPlaceListDTO.getSize());
|
|
|
Page<PlaceVO> placeList = appSiteMapper.getPlaceList(page, getPlaceListDTO.getVenueType());
|
|
|
placeList.getRecords().forEach(placeVO -> {
|
|
|
- List<String> list = new ArrayList<>();
|
|
|
- String[] split = placeVO.getCategoryId().split(",");
|
|
|
- Arrays.stream(split).forEach(id -> {
|
|
|
- list.add(appCategoryMapper.selectById(id).getName());
|
|
|
- });
|
|
|
//todo 待申请第三方地图接口
|
|
|
placeVO.setKm(0.0)
|
|
|
- .setCategory(list);
|
|
|
+ .setCategory(getCategoryName(placeVO.getCategoryId()));
|
|
|
});
|
|
|
- if(getPlaceListDTO.getVenueType().equals("1")
|
|
|
- || getPlaceListDTO.getVenueType().equals("2")
|
|
|
- || getPlaceListDTO.getVenueType().equals("3")){
|
|
|
+ if(getPlaceListDTO.getVenueType().equals("0-2")
|
|
|
+ || getPlaceListDTO.getVenueType().equals("1-1")
|
|
|
+ || getPlaceListDTO.getVenueType().equals("2-1")){
|
|
|
// 按 km 升序排序(从近到远)
|
|
|
placeList.getRecords().sort((p1, p2) -> {
|
|
|
Double km1 = p1.getKm();
|
|
@@ -163,4 +164,143 @@ public class AppHomeServiceImpl implements IAppHomeService {
|
|
|
}
|
|
|
return placeList;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object search(SearchDTO searchDTO) {
|
|
|
+ AppSearchHot appSearchHot = appSearchHotMapper.selectOne(Wrappers.<AppSearchHot>lambdaQuery()
|
|
|
+ .eq(AppSearchHot::getSearchContent, searchDTO.getKeyword())
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ if(null == appSearchHot){
|
|
|
+ appSearchHotMapper.insert(new AppSearchHot()
|
|
|
+ .setSearchContent(searchDTO.getKeyword())
|
|
|
+ .setSearchCount(1)
|
|
|
+ .setIsActive(1)
|
|
|
+ .setIsRecommend(0));
|
|
|
+ }else {
|
|
|
+ appSearchHotMapper.updateById(appSearchHot.setSearchCount(appSearchHot.getSearchCount() + 1));
|
|
|
+ }
|
|
|
+ switch (searchDTO.getVenueType().charAt(0)) {
|
|
|
+ case '0':
|
|
|
+ return convertSearchPlaceVOPage(searchDTO);
|
|
|
+ case '1':
|
|
|
+ return convertSearchTrainVOPage(searchDTO);
|
|
|
+ case '2':
|
|
|
+ return convertSearchCompetitionVOPage(searchDTO);
|
|
|
+ case '3':
|
|
|
+ return convertSearchInstructorVOPage(searchDTO);
|
|
|
+ }
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<AppSearchHot> getHotSearch() {
|
|
|
+ return appSearchHotMapper.selectList(Wrappers.<AppSearchHot>lambdaQuery()
|
|
|
+ .last("LIMIT 10").orderByDesc(AppSearchHot::getSearchCount));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description 全局搜索场地分页查询
|
|
|
+ * @Date 11:05 2025/7/7
|
|
|
+ * @Param searchDTO {@link SearchDTO}
|
|
|
+ * @return Page<SearchVO.SearchPlaceVO>
|
|
|
+ **/
|
|
|
+ private Page<SearchVO.SearchPlaceVO> convertSearchPlaceVOPage(SearchDTO searchDTO) {
|
|
|
+ Page<SearchVO.SearchPlaceVO> page = new Page<>(searchDTO.getCurrent(), searchDTO.getSize());
|
|
|
+ Page<SearchVO.SearchPlaceVO> searchPlaceVOPage = appSiteMapper.convertSearchPlaceVOPage(page, searchDTO);
|
|
|
+ searchPlaceVOPage.getRecords().forEach(placeVO -> {
|
|
|
+ //todo 待申请第三方地图接口
|
|
|
+ placeVO.setKm(0.0)
|
|
|
+ .setCategory(getCategoryName(placeVO.getCategoryId()));
|
|
|
+ });
|
|
|
+ if(searchDTO.getVenueType().equals("0-2")
|
|
|
+ || searchDTO.getVenueType().equals("1-1")
|
|
|
+ || searchDTO.getVenueType().equals("2-1")){
|
|
|
+ // 按 km 升序排序(searchDTO)
|
|
|
+ searchPlaceVOPage.getRecords().sort((p1, p2) -> {
|
|
|
+ Double km1 = p1.getKm();
|
|
|
+ Double km2 = p2.getKm();
|
|
|
+ return km1.compareTo(km2);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return searchPlaceVOPage;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description 根据类目ID获取完整的类目名称
|
|
|
+ * @Date 13:31 2025/7/7
|
|
|
+ * @Param categoryId 类目ID
|
|
|
+ * @return List<String>
|
|
|
+ **/
|
|
|
+ private List<String> getCategoryName(String categoryId) {
|
|
|
+ List<String> list = new ArrayList<>();
|
|
|
+ if(null != categoryId){
|
|
|
+ String[] split = categoryId.split(",");
|
|
|
+ Arrays.stream(split).forEach(id -> {
|
|
|
+ list.add(appCategoryMapper.selectById(id).getName());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description 培训课程分页查询
|
|
|
+ * @Date 13:37 2025/7/7
|
|
|
+ * @Param searchDTO {@link SearchDTO}
|
|
|
+ * @return Page<SearchVO.SearchTrainVO>
|
|
|
+ **/
|
|
|
+ private Page<SearchVO.SearchTrainVO> convertSearchTrainVOPage(SearchDTO searchDTO) {
|
|
|
+ Page<SearchVO.SearchTrainVO> page = new Page<>(searchDTO.getCurrent(), searchDTO.getSize());
|
|
|
+ Page<SearchVO.SearchTrainVO> searchTrainVOPage = appCoursesMapper.convertSearchTrainVOPage(page, searchDTO);
|
|
|
+ searchTrainVOPage.getRecords().forEach(trainVO -> {
|
|
|
+ //todo 待申请第三方地图接口
|
|
|
+ trainVO.setKm(0.0);
|
|
|
+ });
|
|
|
+ return searchTrainVOPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description 赛事分页查询
|
|
|
+ * @Date 14:04 2025/7/7
|
|
|
+ * @Param searchDTO {@link SearchDTO}
|
|
|
+ * @return Page<SearchVO.SearchRaceVO>
|
|
|
+ **/
|
|
|
+ private Page<SearchVO.SearchRaceVO> convertSearchCompetitionVOPage(SearchDTO searchDTO) {
|
|
|
+ Page<SearchVO.SearchRaceVO> page = new Page<>(searchDTO.getCurrent(), searchDTO.getSize());
|
|
|
+ Page<SearchVO.SearchRaceVO> searchCompetitionVOPage = appGameMapper.convertSearchCompetitionVOPage(page, searchDTO);
|
|
|
+ searchCompetitionVOPage.getRecords().forEach(competitionVO -> {
|
|
|
+ //todo 待申请第三方地图接口
|
|
|
+ competitionVO.setKm(0.0);
|
|
|
+ });
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @Author SheepHy
|
|
|
+ * @Description //TODO
|
|
|
+ * @Date 14:43 2025/7/7
|
|
|
+ * @Param searchDTO {@link SearchDTO}
|
|
|
+ * @return Page<SearchVO.SearchInstructorVO>
|
|
|
+ **/
|
|
|
+ private Page<SearchVO.SearchInstructorVO> convertSearchInstructorVOPage(SearchDTO searchDTO) {
|
|
|
+ Page<SearchVO.SearchInstructorVO> page = new Page<>(searchDTO.getCurrent(), searchDTO.getSize());
|
|
|
+ Page<SearchVO.SearchInstructorVO> searchInstructorVOPage = appInstructorMapper.convertSearchInstructorVOPage(page, searchDTO);
|
|
|
+ searchInstructorVOPage.getRecords().forEach(instructorVO -> {
|
|
|
+ // 获取该教练的课程(最多取2个)
|
|
|
+ List<AppCourses> courses = appCoursesMapper.selectList(
|
|
|
+ Wrappers.<AppCourses>lambdaQuery().eq(AppCourses::getUserId, instructorVO.getUserId()).last("LIMIT 2"));
|
|
|
+ List<SearchVO.SearchCoursesVO> courseInfoVOS = courses.stream()
|
|
|
+ .map(course -> {
|
|
|
+ SearchVO.SearchCoursesVO vo = new SearchVO.SearchCoursesVO();
|
|
|
+ BeanUtils.copyProperties(vo, course);
|
|
|
+ return vo;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ instructorVO.setKm(0.0)
|
|
|
+ .setCourseList(courseInfoVOS);
|
|
|
+ });
|
|
|
+ return searchInstructorVOPage;
|
|
|
+ }
|
|
|
}
|