调整层级关系
Showing
19 changed files
with
203 additions
and
150 deletions
| ... | @@ -28,11 +28,6 @@ public class BuildingBlock extends BaseEntity { | ... | @@ -28,11 +28,6 @@ public class BuildingBlock extends BaseEntity { |
| 28 | private String id; | 28 | private String id; |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * 套件ID | ||
| 32 | */ | ||
| 33 | private String entiretyId; | ||
| 34 | |||
| 35 | /** | ||
| 36 | * 广告名称 | 31 | * 广告名称 |
| 37 | */ | 32 | */ |
| 38 | private String name; | 33 | private String name; | ... | ... |
| ... | @@ -28,19 +28,19 @@ public class Entirety extends BaseEntity { | ... | @@ -28,19 +28,19 @@ public class Entirety extends BaseEntity { |
| 28 | private String id; | 28 | private String id; |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * 广告名称 | 31 | * 系列ID |
| 32 | */ | 32 | */ |
| 33 | private String name; | 33 | private String buildingBlockId; |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * 排序 | 36 | * 套件名称 |
| 37 | */ | 37 | */ |
| 38 | private Long sort; | 38 | private String name; |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | * 类型(0词语 1图标 ) | 41 | * 排序 |
| 42 | */ | 42 | */ |
| 43 | private String type; | 43 | private Long sort; |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * 文件ID | 46 | * 文件ID | ... | ... |
| ... | @@ -78,4 +78,9 @@ public class Question extends BaseEntity { | ... | @@ -78,4 +78,9 @@ public class Question extends BaseEntity { |
| 78 | @TableLogic | 78 | @TableLogic |
| 79 | private String delFlag; | 79 | private String delFlag; |
| 80 | 80 | ||
| 81 | /** | ||
| 82 | * 系列ID | ||
| 83 | */ | ||
| 84 | private String buildingBlockId; | ||
| 85 | |||
| 81 | } | 86 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -23,12 +23,6 @@ public class BuildingBlockBo extends BaseBO { | ... | @@ -23,12 +23,6 @@ public class BuildingBlockBo extends BaseBO { |
| 23 | private String id; | 23 | private String id; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * 套件ID | ||
| 27 | */ | ||
| 28 | @NotBlank(message = "套件不能为空") | ||
| 29 | private String entiretyId; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * 系列名称 | 26 | * 系列名称 |
| 33 | */ | 27 | */ |
| 34 | @NotBlank(message = "系列名称不能为空") | 28 | @NotBlank(message = "系列名称不能为空") | ... | ... |
| ... | @@ -25,8 +25,8 @@ public class CourseBo extends BaseBO { | ... | @@ -25,8 +25,8 @@ public class CourseBo extends BaseBO { |
| 25 | /** | 25 | /** |
| 26 | * 系列ID | 26 | * 系列ID |
| 27 | */ | 27 | */ |
| 28 | @NotBlank(message = "系列不能为空") | 28 | @NotBlank(message = "套件不能为空") |
| 29 | private String buildingBlockId; | 29 | private String entiretyId; |
| 30 | 30 | ||
| 31 | /** | 31 | /** |
| 32 | * 课程名称 | 32 | * 课程名称 | ... | ... |
| ... | @@ -23,6 +23,12 @@ public class EntiretyBo extends BaseBO { | ... | @@ -23,6 +23,12 @@ public class EntiretyBo extends BaseBO { |
| 23 | private String id; | 23 | private String id; |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * 系列ID | ||
| 27 | */ | ||
| 28 | @NotBlank(message = "系列不能为空") | ||
| 29 | private String buildingBlockId; | ||
| 30 | |||
| 31 | /** | ||
| 26 | * 套件名称 | 32 | * 套件名称 |
| 27 | */ | 33 | */ |
| 28 | @NotBlank(message = "套件名称不能为空") | 34 | @NotBlank(message = "套件名称不能为空") |
| ... | @@ -36,12 +42,6 @@ public class EntiretyBo extends BaseBO { | ... | @@ -36,12 +42,6 @@ public class EntiretyBo extends BaseBO { |
| 36 | private Long sort; | 42 | private Long sort; |
| 37 | 43 | ||
| 38 | /** | 44 | /** |
| 39 | * 类型(0词语 1图标 ) | ||
| 40 | */ | ||
| 41 | @NotBlank(message = "类别不能为空") | ||
| 42 | private String type; | ||
| 43 | |||
| 44 | /** | ||
| 45 | * 文件ID | 45 | * 文件ID |
| 46 | */ | 46 | */ |
| 47 | private String ossId; | 47 | private String ossId; | ... | ... |
| ... | @@ -63,4 +63,9 @@ public class QuestionBo extends BaseBO { | ... | @@ -63,4 +63,9 @@ public class QuestionBo extends BaseBO { |
| 63 | * 排序 | 63 | * 排序 |
| 64 | */ | 64 | */ |
| 65 | private Long sort; | 65 | private Long sort; |
| 66 | |||
| 67 | /** | ||
| 68 | * 系列ID | ||
| 69 | */ | ||
| 70 | private String buildingBlockId; | ||
| 66 | } | 71 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -2,6 +2,8 @@ package com.lego.core.domin.vo; | ... | @@ -2,6 +2,8 @@ package com.lego.core.domin.vo; |
| 2 | 2 | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | import java.util.List; | ||
| 6 | |||
| 5 | /** | 7 | /** |
| 6 | * 系列视图对象 core_building_block | 8 | * 系列视图对象 core_building_block |
| 7 | * | 9 | * |
| ... | @@ -20,17 +22,7 @@ public class BuildingBlockVo { | ... | @@ -20,17 +22,7 @@ public class BuildingBlockVo { |
| 20 | private String id; | 22 | private String id; |
| 21 | 23 | ||
| 22 | /** | 24 | /** |
| 23 | * 套件ID | 25 | * 系列名称 |
| 24 | */ | ||
| 25 | private String entiretyId; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * 套件名称 | ||
| 29 | */ | ||
| 30 | private String entiretyName; | ||
| 31 | |||
| 32 | /** | ||
| 33 | * 广告名称 | ||
| 34 | */ | 26 | */ |
| 35 | private String name; | 27 | private String name; |
| 36 | 28 | ||
| ... | @@ -53,4 +45,10 @@ public class BuildingBlockVo { | ... | @@ -53,4 +45,10 @@ public class BuildingBlockVo { |
| 53 | * 排序 | 45 | * 排序 |
| 54 | */ | 46 | */ |
| 55 | private Long sort; | 47 | private Long sort; |
| 48 | |||
| 49 | |||
| 50 | /** | ||
| 51 | * 套件信息 | ||
| 52 | */ | ||
| 53 | List<EntiretyVo> entiretyList; | ||
| 56 | } | 54 | } | ... | ... |
| ... | @@ -22,14 +22,14 @@ public class CourseVo { | ... | @@ -22,14 +22,14 @@ public class CourseVo { |
| 22 | private String id; | 22 | private String id; |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * 系列ID | 25 | * 套件ID |
| 26 | */ | 26 | */ |
| 27 | private String buildingBlockId; | 27 | private String entiretyId; |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * 系列名称 | 30 | * 套件名称 |
| 31 | */ | 31 | */ |
| 32 | private String buildingBlockName; | 32 | private String entiretyName; |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * 课程名称 | 35 | * 课程名称 | ... | ... |
| ... | @@ -22,7 +22,17 @@ public class EntiretyVo { | ... | @@ -22,7 +22,17 @@ public class EntiretyVo { |
| 22 | private String id; | 22 | private String id; |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | * 广告名称 | 25 | * 系列ID |
| 26 | */ | ||
| 27 | private String buildingBlockId; | ||
| 28 | |||
| 29 | /** | ||
| 30 | * 系列名称 | ||
| 31 | */ | ||
| 32 | private String buildingBlockName; | ||
| 33 | |||
| 34 | /** | ||
| 35 | * 套件名称 | ||
| 26 | */ | 36 | */ |
| 27 | private String name; | 37 | private String name; |
| 28 | 38 | ||
| ... | @@ -31,10 +41,6 @@ public class EntiretyVo { | ... | @@ -31,10 +41,6 @@ public class EntiretyVo { |
| 31 | */ | 41 | */ |
| 32 | private Long sort; | 42 | private Long sort; |
| 33 | 43 | ||
| 34 | /** | ||
| 35 | * 类型(0词语 1图标 ) | ||
| 36 | */ | ||
| 37 | private String type; | ||
| 38 | 44 | ||
| 39 | /** | 45 | /** |
| 40 | * 文件ID | 46 | * 文件ID |
| ... | @@ -50,9 +56,4 @@ public class EntiretyVo { | ... | @@ -50,9 +56,4 @@ public class EntiretyVo { |
| 50 | * 前端APP数据国际化(zh_CN、en_US、ru_RU) | 56 | * 前端APP数据国际化(zh_CN、en_US、ru_RU) |
| 51 | */ | 57 | */ |
| 52 | private String language; | 58 | private String language; |
| 53 | |||
| 54 | /** | ||
| 55 | * 系列信息 | ||
| 56 | */ | ||
| 57 | List<BuildingBlockVo> BuildingblockList; | ||
| 58 | } | 59 | } | ... | ... |
| ... | @@ -78,4 +78,13 @@ public class QuestionVo { | ... | @@ -78,4 +78,13 @@ public class QuestionVo { |
| 78 | * 前端APP数据国际化(zh_CN、en_US、ru_RU) | 78 | * 前端APP数据国际化(zh_CN、en_US、ru_RU) |
| 79 | */ | 79 | */ |
| 80 | private String language; | 80 | private String language; |
| 81 | |||
| 82 | /** | ||
| 83 | * 系列ID | ||
| 84 | */ | ||
| 85 | private String buildingBlockId; | ||
| 86 | /** | ||
| 87 | * 系列名称 | ||
| 88 | */ | ||
| 89 | private String buildingBlockName; | ||
| 81 | } | 90 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -40,13 +40,6 @@ public interface IBuildingBlockService { | ... | @@ -40,13 +40,6 @@ public interface IBuildingBlockService { |
| 40 | List<BuildingBlockVo> list(); | 40 | List<BuildingBlockVo> list(); |
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | * (根据套件ID)不带分页查询 | ||
| 44 | * | ||
| 45 | * @return | ||
| 46 | */ | ||
| 47 | List<BuildingBlockVo> list(String language, Collection<String> entiretyIds); | ||
| 48 | |||
| 49 | /** | ||
| 50 | * 新增 | 43 | * 新增 |
| 51 | * | 44 | * |
| 52 | * @param blockBo | 45 | * @param blockBo | ... | ... |
| ... | @@ -26,10 +26,10 @@ public interface ICourseService { | ... | @@ -26,10 +26,10 @@ public interface ICourseService { |
| 26 | /** | 26 | /** |
| 27 | * 根据系列id查找的课程列表 | 27 | * 根据系列id查找的课程列表 |
| 28 | * | 28 | * |
| 29 | * @param buildingBlockId | 29 | * @param entiretyId |
| 30 | * @return | 30 | * @return |
| 31 | */ | 31 | */ |
| 32 | List<CourseVo> list(String buildingBlockId); | 32 | List<CourseVo> list(String entiretyId); |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * 获取所有课程 | 35 | * 获取所有课程 | ... | ... |
| ... | @@ -6,6 +6,7 @@ import com.lego.common.core.page.TableDataInfo; | ... | @@ -6,6 +6,7 @@ import com.lego.common.core.page.TableDataInfo; |
| 6 | import com.lego.core.domin.bo.AdvertBo; | 6 | import com.lego.core.domin.bo.AdvertBo; |
| 7 | import com.lego.core.domin.bo.EntiretyBo; | 7 | import com.lego.core.domin.bo.EntiretyBo; |
| 8 | import com.lego.core.domin.vo.AdvertVo; | 8 | import com.lego.core.domin.vo.AdvertVo; |
| 9 | import com.lego.core.domin.vo.BuildingBlockVo; | ||
| 9 | import com.lego.core.domin.vo.EntiretyVo; | 10 | import com.lego.core.domin.vo.EntiretyVo; |
| 10 | 11 | ||
| 11 | import java.rmi.ServerException; | 12 | import java.rmi.ServerException; |
| ... | @@ -74,4 +75,11 @@ public interface IEntiretyService { | ... | @@ -74,4 +75,11 @@ public interface IEntiretyService { |
| 74 | * @throws ServerException | 75 | * @throws ServerException |
| 75 | */ | 76 | */ |
| 76 | List<EntiretyVo> getListByIds(Collection<String> ids); | 77 | List<EntiretyVo> getListByIds(Collection<String> ids); |
| 78 | |||
| 79 | /** | ||
| 80 | * (根据系列ID)不带分页查询 | ||
| 81 | * | ||
| 82 | * @return | ||
| 83 | */ | ||
| 84 | List<EntiretyVo> list(String language, Collection<String> buildingBlockIds); | ||
| 77 | } | 85 | } | ... | ... |
| ... | @@ -9,15 +9,18 @@ import com.lego.common.core.page.TableDataInfo; | ... | @@ -9,15 +9,18 @@ import com.lego.common.core.page.TableDataInfo; |
| 9 | import com.lego.common.core.service.OssService; | 9 | import com.lego.common.core.service.OssService; |
| 10 | import com.lego.common.utils.MessageUtils; | 10 | import com.lego.common.utils.MessageUtils; |
| 11 | import com.lego.common.utils.StreamUtils; | 11 | import com.lego.common.utils.StreamUtils; |
| 12 | import com.lego.common.utils.spring.SpringUtils; | ||
| 12 | import com.lego.core.annotation.LanguageAnnotation; | 13 | import com.lego.core.annotation.LanguageAnnotation; |
| 13 | import com.lego.core.domin.BuildingBlock; | 14 | import com.lego.core.domin.BuildingBlock; |
| 14 | import com.lego.core.domin.Course; | 15 | import com.lego.core.domin.Course; |
| 16 | import com.lego.core.domin.Entirety; | ||
| 15 | import com.lego.core.domin.bo.BuildingBlockBo; | 17 | import com.lego.core.domin.bo.BuildingBlockBo; |
| 16 | import com.lego.core.domin.bo.BuildingBlockQueryBo; | 18 | import com.lego.core.domin.bo.BuildingBlockQueryBo; |
| 17 | import com.lego.core.domin.vo.BuildingBlockVo; | 19 | import com.lego.core.domin.vo.BuildingBlockVo; |
| 18 | import com.lego.core.domin.vo.EntiretyVo; | 20 | import com.lego.core.domin.vo.EntiretyVo; |
| 19 | import com.lego.core.mapper.BuildingBlockMapper; | 21 | import com.lego.core.mapper.BuildingBlockMapper; |
| 20 | import com.lego.core.mapper.CourseMapper; | 22 | import com.lego.core.mapper.CourseMapper; |
| 23 | import com.lego.core.mapper.EntiretyMapper; | ||
| 21 | import com.lego.core.service.IBuildingBlockService; | 24 | import com.lego.core.service.IBuildingBlockService; |
| 22 | import com.lego.core.service.IEntiretyService; | 25 | import com.lego.core.service.IEntiretyService; |
| 23 | import com.lego.system.domain.vo.SysOssVo; | 26 | import com.lego.system.domain.vo.SysOssVo; |
| ... | @@ -28,10 +31,7 @@ import org.springframework.stereotype.Service; | ... | @@ -28,10 +31,7 @@ import org.springframework.stereotype.Service; |
| 28 | import org.springframework.util.CollectionUtils; | 31 | import org.springframework.util.CollectionUtils; |
| 29 | 32 | ||
| 30 | import java.rmi.ServerException; | 33 | import java.rmi.ServerException; |
| 31 | import java.util.Collection; | 34 | import java.util.*; |
| 32 | import java.util.List; | ||
| 33 | import java.util.Map; | ||
| 34 | import java.util.Set; | ||
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * 系列Service业务层处理 | 37 | * 系列Service业务层处理 |
| ... | @@ -43,10 +43,13 @@ import java.util.Set; | ... | @@ -43,10 +43,13 @@ import java.util.Set; |
| 43 | @Service | 43 | @Service |
| 44 | public class BuildingBlockServiceImpl implements IBuildingBlockService { | 44 | public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 45 | private final BuildingBlockMapper baseMapper; | 45 | private final BuildingBlockMapper baseMapper; |
| 46 | private final IEntiretyService entiretyService; | 46 | private final EntiretyMapper entiretyMapper; |
| 47 | private final CourseMapper courseMapper; | ||
| 48 | private final ISysOssService iSysOssService; | ||
| 49 | private final OssService ossUrlService; | 47 | private final OssService ossUrlService; |
| 48 | private final ISysOssService iSysOssService; | ||
| 49 | |||
| 50 | public IEntiretyService getEntiretyService() { | ||
| 51 | return SpringUtils.getBean(IEntiretyService.class); | ||
| 52 | } | ||
| 50 | 53 | ||
| 51 | /** | 54 | /** |
| 52 | * 查询所有列表(带分页) | 55 | * 查询所有列表(带分页) |
| ... | @@ -58,26 +61,34 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -58,26 +61,34 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 58 | public TableDataInfo<BuildingBlockVo> listPage(BuildingBlockQueryBo queryBo, String language) { | 61 | public TableDataInfo<BuildingBlockVo> listPage(BuildingBlockQueryBo queryBo, String language) { |
| 59 | Page<BuildingBlockVo> page = baseMapper.selectVoPage(queryBo.build(), Wrappers.<BuildingBlock>lambdaQuery() | 62 | Page<BuildingBlockVo> page = baseMapper.selectVoPage(queryBo.build(), Wrappers.<BuildingBlock>lambdaQuery() |
| 60 | .like(StrUtil.isNotBlank(queryBo.getSearchKey()), BuildingBlock::getName, queryBo.getSearchKey()) | 63 | .like(StrUtil.isNotBlank(queryBo.getSearchKey()), BuildingBlock::getName, queryBo.getSearchKey()) |
| 61 | .eq(BuildingBlock::getLanguage, language).orderByAsc(BuildingBlock::getId)); | 64 | .eq(BuildingBlock::getLanguage, language).orderByAsc(BuildingBlock::getSort)); |
| 62 | setInfo(page.getRecords()); | 65 | /** |
| 63 | return TableDataInfo.build(page); | 66 | * 处理二级数据 |
| 64 | } | 67 | */ |
| 65 | 68 | List<BuildingBlockVo> list = page.getRecords(); | |
| 66 | private void setInfo(List<BuildingBlockVo> list) { | 69 | Set<String> entiretyIdList = StreamUtils.toSet(list,BuildingBlockVo::getId); |
| 67 | if (ObjectUtil.isNotEmpty(list)) { | 70 | List<EntiretyVo> entiretyList = getEntiretyService().list(language, entiretyIdList); |
| 68 | Set<String> ids = StreamUtils.toSet(list, BuildingBlockVo::getEntiretyId); | 71 | for(EntiretyVo vo : entiretyList){ |
| 69 | List<EntiretyVo> entiretyList = entiretyService.getListByIds(ids); | 72 | if(Objects.nonNull(vo)) { |
| 70 | Map<String, EntiretyVo> entiretyMap = StreamUtils.toMap(entiretyList, EntiretyVo::getId, v -> v); | ||
| 71 | for (BuildingBlockVo vo : list) { | ||
| 72 | vo.setEntiretyName(entiretyMap.getOrDefault(vo.getEntiretyId(), new EntiretyVo()).getName()); | ||
| 73 | if (StrUtil.isNotBlank(vo.getOssId())) { | 73 | if (StrUtil.isNotBlank(vo.getOssId())) { |
| 74 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | 74 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | Map<String,List<EntiretyVo>> entiretyMap = StreamUtils.groupByKey(entiretyList,EntiretyVo::getBuildingBlockId); | ||
| 79 | |||
| 80 | for(BuildingBlockVo vo:list){ | ||
| 81 | if(StrUtil.isNotBlank(vo.getOssId())) { | ||
| 82 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | ||
| 83 | } | ||
| 84 | vo.setEntiretyList(entiretyMap.get(vo.getId())); | ||
| 85 | } | ||
| 86 | return TableDataInfo.build(page); | ||
| 78 | } | 87 | } |
| 79 | 88 | ||
| 80 | 89 | ||
| 90 | |||
| 91 | |||
| 81 | /** | 92 | /** |
| 82 | * 不带分页查询 | 93 | * 不带分页查询 |
| 83 | * | 94 | * |
| ... | @@ -85,7 +96,7 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -85,7 +96,7 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 85 | */ | 96 | */ |
| 86 | @Override | 97 | @Override |
| 87 | public List<BuildingBlockVo> list(String language) { | 98 | public List<BuildingBlockVo> list(String language) { |
| 88 | List<BuildingBlockVo> list = baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getLanguage, language)); | 99 | List<BuildingBlockVo> list = baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getLanguage, language).orderByAsc(BuildingBlock::getSort)); |
| 89 | setInfo(list); | 100 | setInfo(list); |
| 90 | return list; | 101 | return list; |
| 91 | } | 102 | } |
| ... | @@ -102,31 +113,18 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -102,31 +113,18 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 102 | if (StrUtil.isNotBlank(vo.getOssId())) { | 113 | if (StrUtil.isNotBlank(vo.getOssId())) { |
| 103 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | 114 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); |
| 104 | } | 115 | } |
| 116 | List<EntiretyVo> entiretyVoList = entiretyMapper.selectVoList(Wrappers.<Entirety>lambdaQuery().eq(Entirety::getBuildingBlockId, vo.getId())); | ||
| 117 | for(EntiretyVo entiretyVo:entiretyVoList){ | ||
| 118 | if(StrUtil.isNotBlank(entiretyVo.getOssId())){ | ||
| 119 | entiretyVo.setOssUrl(ossUrlService.selectUrlByIds(entiretyVo.getOssId())); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | vo.setEntiretyList(entiretyVoList); | ||
| 105 | } | 123 | } |
| 106 | return list; | 124 | return list; |
| 107 | } | 125 | } |
| 108 | 126 | ||
| 109 | /** | 127 | /** |
| 110 | * (根据套件ID)不带分页查询 | ||
| 111 | * | ||
| 112 | * @param language | ||
| 113 | * @param entiretyIds | ||
| 114 | * @return | ||
| 115 | */ | ||
| 116 | @Override | ||
| 117 | public List<BuildingBlockVo> list(String language, Collection<String> entiretyIds) { | ||
| 118 | List<BuildingBlockVo> list = Lists.newArrayList(); | ||
| 119 | if(!CollectionUtils.isEmpty(entiretyIds)) { | ||
| 120 | list = baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getLanguage, language).in(BuildingBlock::getEntiretyId, entiretyIds)); | ||
| 121 | } | ||
| 122 | else{ | ||
| 123 | list = baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getLanguage, language)); | ||
| 124 | } | ||
| 125 | setInfo(list); | ||
| 126 | return list; | ||
| 127 | } | ||
| 128 | |||
| 129 | /** | ||
| 130 | * 新增 | 128 | * 新增 |
| 131 | * | 129 | * |
| 132 | * @param blockBo | 130 | * @param blockBo |
| ... | @@ -164,7 +162,7 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -164,7 +162,7 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 164 | @Override | 162 | @Override |
| 165 | public boolean remove(String id) throws ServerException { | 163 | public boolean remove(String id) throws ServerException { |
| 166 | checkExists(id); | 164 | checkExists(id); |
| 167 | checkCourseExists(id); | 165 | checkEntiretyExists(id); |
| 168 | return baseMapper.deleteById(id) > 0; | 166 | return baseMapper.deleteById(id) > 0; |
| 169 | } | 167 | } |
| 170 | 168 | ||
| ... | @@ -205,9 +203,19 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -205,9 +203,19 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 205 | * @param id | 203 | * @param id |
| 206 | * @throws ServerException | 204 | * @throws ServerException |
| 207 | */ | 205 | */ |
| 208 | private void checkCourseExists(String id) throws ServerException { | 206 | private void checkEntiretyExists(String id) throws ServerException { |
| 209 | if (courseMapper.exists(Wrappers.<Course>lambdaQuery().eq(Course::getBuildingBlockId, id))) { | 207 | if (entiretyMapper.exists(Wrappers.<Entirety>lambdaQuery().eq(Entirety::getBuildingBlockId, id))) { |
| 210 | throw new ServerException(MessageUtils.message("core.data.exists")); | 208 | throw new ServerException(MessageUtils.message("core.data.exists")); |
| 211 | } | 209 | } |
| 212 | } | 210 | } |
| 211 | |||
| 212 | private void setInfo(List<BuildingBlockVo> list) { | ||
| 213 | if (ObjectUtil.isNotEmpty(list)) { | ||
| 214 | for (BuildingBlockVo vo : list) { | ||
| 215 | if (StrUtil.isNotBlank(vo.getOssId())) { | ||
| 216 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | } | ||
| 220 | } | ||
| 213 | } | 221 | } | ... | ... |
| ... | @@ -14,11 +14,11 @@ import com.lego.core.annotation.LanguageAnnotation; | ... | @@ -14,11 +14,11 @@ import com.lego.core.annotation.LanguageAnnotation; |
| 14 | import com.lego.core.domin.Course; | 14 | import com.lego.core.domin.Course; |
| 15 | import com.lego.core.domin.bo.CourseBo; | 15 | import com.lego.core.domin.bo.CourseBo; |
| 16 | import com.lego.core.domin.bo.CourseQueryBo; | 16 | import com.lego.core.domin.bo.CourseQueryBo; |
| 17 | import com.lego.core.domin.vo.BuildingBlockVo; | ||
| 18 | import com.lego.core.domin.vo.CourseVo; | 17 | import com.lego.core.domin.vo.CourseVo; |
| 18 | import com.lego.core.domin.vo.EntiretyVo; | ||
| 19 | import com.lego.core.mapper.CourseMapper; | 19 | import com.lego.core.mapper.CourseMapper; |
| 20 | import com.lego.core.service.IBuildingBlockService; | ||
| 21 | import com.lego.core.service.ICourseService; | 20 | import com.lego.core.service.ICourseService; |
| 21 | import com.lego.core.service.IEntiretyService; | ||
| 22 | import com.lego.system.domain.vo.SysOssVo; | 22 | import com.lego.system.domain.vo.SysOssVo; |
| 23 | import com.lego.system.service.ISysOssService; | 23 | import com.lego.system.service.ISysOssService; |
| 24 | import lombok.RequiredArgsConstructor; | 24 | import lombok.RequiredArgsConstructor; |
| ... | @@ -39,7 +39,7 @@ import java.util.Set; | ... | @@ -39,7 +39,7 @@ import java.util.Set; |
| 39 | @Service | 39 | @Service |
| 40 | public class CourseServiceImpl implements ICourseService { | 40 | public class CourseServiceImpl implements ICourseService { |
| 41 | private final CourseMapper baseMapper; | 41 | private final CourseMapper baseMapper; |
| 42 | private final IBuildingBlockService buildingBlockService; | 42 | private final IEntiretyService entiretyService; |
| 43 | private final ISysOssService iSysOssService; | 43 | private final ISysOssService iSysOssService; |
| 44 | private final OssService ossUrlService; | 44 | private final OssService ossUrlService; |
| 45 | 45 | ||
| ... | @@ -56,11 +56,11 @@ public class CourseServiceImpl implements ICourseService { | ... | @@ -56,11 +56,11 @@ public class CourseServiceImpl implements ICourseService { |
| 56 | .eq(Course::getLanguage, language).orderByAsc(Course::getSort)); | 56 | .eq(Course::getLanguage, language).orderByAsc(Course::getSort)); |
| 57 | List<CourseVo> list = page.getRecords(); | 57 | List<CourseVo> list = page.getRecords(); |
| 58 | if (ObjectUtil.isNotEmpty(list)) { | 58 | if (ObjectUtil.isNotEmpty(list)) { |
| 59 | Set<String> ids = StreamUtils.toSet(list, CourseVo::getBuildingBlockId); | 59 | Set<String> ids = StreamUtils.toSet(list, CourseVo::getEntiretyId); |
| 60 | List<BuildingBlockVo> blockList = buildingBlockService.getListByIds(ids); | 60 | List<EntiretyVo> entiretyList = entiretyService.getListByIds(ids); |
| 61 | Map<String, BuildingBlockVo> blockMap = StreamUtils.toMap(blockList, BuildingBlockVo::getId, v -> v); | 61 | Map<String, EntiretyVo> entiretyMap = StreamUtils.toMap(entiretyList, EntiretyVo::getId, v -> v); |
| 62 | for (CourseVo vo : list) { | 62 | for (CourseVo vo : list) { |
| 63 | vo.setBuildingBlockName(blockMap.getOrDefault(vo.getBuildingBlockId(), new BuildingBlockVo()).getName()); | 63 | vo.setEntiretyName(entiretyMap.getOrDefault(vo.getEntiretyId(), new EntiretyVo()).getName()); |
| 64 | if(StrUtil.isNotBlank(vo.getTwoDimensionalOssId())){ | 64 | if(StrUtil.isNotBlank(vo.getTwoDimensionalOssId())){ |
| 65 | vo.setTwoDimensionalOssUrl(ossUrlService.selectUrlByIds(vo.getTwoDimensionalOssId())); | 65 | vo.setTwoDimensionalOssUrl(ossUrlService.selectUrlByIds(vo.getTwoDimensionalOssId())); |
| 66 | } | 66 | } |
| ... | @@ -83,12 +83,12 @@ public class CourseServiceImpl implements ICourseService { | ... | @@ -83,12 +83,12 @@ public class CourseServiceImpl implements ICourseService { |
| 83 | 83 | ||
| 84 | /** | 84 | /** |
| 85 | * | 85 | * |
| 86 | * @param buildingBlockId | 86 | * @param entiretyId |
| 87 | * @return | 87 | * @return |
| 88 | */ | 88 | */ |
| 89 | @Override | 89 | @Override |
| 90 | public List<CourseVo> list(String buildingBlockId) { | 90 | public List<CourseVo> list(String entiretyId) { |
| 91 | List<CourseVo> list = baseMapper.selectVoList(Wrappers.<Course>lambdaQuery().eq(Course::getBuildingBlockId, buildingBlockId).orderByAsc(Course::getSort)); | 91 | List<CourseVo> list = baseMapper.selectVoList(Wrappers.<Course>lambdaQuery().eq(Course::getEntiretyId, entiretyId).orderByAsc(Course::getSort)); |
| 92 | for (CourseVo vo : list) { | 92 | for (CourseVo vo : list) { |
| 93 | if(StrUtil.isNotBlank(vo.getTwoDimensionalOssId())){ | 93 | if(StrUtil.isNotBlank(vo.getTwoDimensionalOssId())){ |
| 94 | vo.setTwoDimensionalOssUrl(ossUrlService.selectUrlByIds(vo.getTwoDimensionalOssId())); | 94 | vo.setTwoDimensionalOssUrl(ossUrlService.selectUrlByIds(vo.getTwoDimensionalOssId())); | ... | ... |
| 1 | package com.lego.core.service.impl; | 1 | package com.lego.core.service.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | import cn.hutool.core.util.ObjectUtil; | ||
| 4 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 6 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| ... | @@ -11,12 +12,12 @@ import com.lego.common.utils.MessageUtils; | ... | @@ -11,12 +12,12 @@ import com.lego.common.utils.MessageUtils; |
| 11 | import com.lego.common.utils.StreamUtils; | 12 | import com.lego.common.utils.StreamUtils; |
| 12 | import com.lego.common.utils.spring.SpringUtils; | 13 | import com.lego.common.utils.spring.SpringUtils; |
| 13 | import com.lego.core.annotation.LanguageAnnotation; | 14 | import com.lego.core.annotation.LanguageAnnotation; |
| 14 | import com.lego.core.domin.BuildingBlock; | 15 | import com.lego.core.domin.Course; |
| 15 | import com.lego.core.domin.Entirety; | 16 | import com.lego.core.domin.Entirety; |
| 16 | import com.lego.core.domin.bo.EntiretyBo; | 17 | import com.lego.core.domin.bo.EntiretyBo; |
| 17 | import com.lego.core.domin.vo.BuildingBlockVo; | 18 | import com.lego.core.domin.vo.BuildingBlockVo; |
| 18 | import com.lego.core.domin.vo.EntiretyVo; | 19 | import com.lego.core.domin.vo.EntiretyVo; |
| 19 | import com.lego.core.mapper.BuildingBlockMapper; | 20 | import com.lego.core.mapper.CourseMapper; |
| 20 | import com.lego.core.mapper.EntiretyMapper; | 21 | import com.lego.core.mapper.EntiretyMapper; |
| 21 | import com.lego.core.service.IBuildingBlockService; | 22 | import com.lego.core.service.IBuildingBlockService; |
| 22 | import com.lego.core.service.IEntiretyService; | 23 | import com.lego.core.service.IEntiretyService; |
| ... | @@ -24,10 +25,15 @@ import com.lego.system.domain.vo.SysOssVo; | ... | @@ -24,10 +25,15 @@ import com.lego.system.domain.vo.SysOssVo; |
| 24 | import com.lego.system.service.ISysOssService; | 25 | import com.lego.system.service.ISysOssService; |
| 25 | import io.micrometer.core.instrument.util.StringUtils; | 26 | import io.micrometer.core.instrument.util.StringUtils; |
| 26 | import lombok.RequiredArgsConstructor; | 27 | import lombok.RequiredArgsConstructor; |
| 28 | import org.apache.commons.compress.utils.Lists; | ||
| 27 | import org.springframework.stereotype.Service; | 29 | import org.springframework.stereotype.Service; |
| 30 | import org.springframework.util.CollectionUtils; | ||
| 28 | 31 | ||
| 29 | import java.rmi.ServerException; | 32 | import java.rmi.ServerException; |
| 30 | import java.util.*; | 33 | import java.util.Collection; |
| 34 | import java.util.List; | ||
| 35 | import java.util.Map; | ||
| 36 | import java.util.Set; | ||
| 31 | 37 | ||
| 32 | /** | 38 | /** |
| 33 | * 套件Service业务层处理 | 39 | * 套件Service业务层处理 |
| ... | @@ -39,9 +45,9 @@ import java.util.*; | ... | @@ -39,9 +45,9 @@ import java.util.*; |
| 39 | @Service | 45 | @Service |
| 40 | public class EntiretyServiceImpl implements IEntiretyService { | 46 | public class EntiretyServiceImpl implements IEntiretyService { |
| 41 | private final EntiretyMapper baseMapper; | 47 | private final EntiretyMapper baseMapper; |
| 42 | private final BuildingBlockMapper buildingBlockMapper; | ||
| 43 | private final ISysOssService iSysOssService; | 48 | private final ISysOssService iSysOssService; |
| 44 | private final OssService ossUrlService; | 49 | private final OssService ossUrlService; |
| 50 | private final CourseMapper courseMapper; | ||
| 45 | 51 | ||
| 46 | public IBuildingBlockService getBuildingBlockService() { | 52 | public IBuildingBlockService getBuildingBlockService() { |
| 47 | return SpringUtils.getBean(IBuildingBlockService.class); | 53 | return SpringUtils.getBean(IBuildingBlockService.class); |
| ... | @@ -59,28 +65,8 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -59,28 +65,8 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 59 | language = "zh_CN"; | 65 | language = "zh_CN"; |
| 60 | Page<EntiretyVo> page = baseMapper.selectVoPage(query.build(), Wrappers.<Entirety>lambdaQuery() | 66 | Page<EntiretyVo> page = baseMapper.selectVoPage(query.build(), Wrappers.<Entirety>lambdaQuery() |
| 61 | .eq(Entirety::getLanguage, language).orderByAsc(Entirety::getSort)); | 67 | .eq(Entirety::getLanguage, language).orderByAsc(Entirety::getSort)); |
| 62 | /** | 68 | |
| 63 | * 处理二级数据 | 69 | setInfo(page.getRecords()); |
| 64 | */ | ||
| 65 | List<EntiretyVo> list = page.getRecords(); | ||
| 66 | Set<String> buildingBlockIdList = StreamUtils.toSet(list,EntiretyVo::getId); | ||
| 67 | List<BuildingBlockVo> buildingBlockList = getBuildingBlockService().list(language, buildingBlockIdList); | ||
| 68 | for(BuildingBlockVo vo : buildingBlockList){ | ||
| 69 | if(Objects.nonNull(vo)) { | ||
| 70 | if (StrUtil.isNotBlank(vo.getOssId())) { | ||
| 71 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | Map<String,List<BuildingBlockVo>> buildingBlockMap = StreamUtils.groupByKey(buildingBlockList,BuildingBlockVo::getEntiretyId); | ||
| 76 | for(EntiretyVo vo:list){ | ||
| 77 | if(Objects.nonNull(vo)) { | ||
| 78 | if (StrUtil.isNotBlank(vo.getOssId())) { | ||
| 79 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | ||
| 80 | } | ||
| 81 | vo.setBuildingblockList(buildingBlockMap.get(vo.getId())); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | return TableDataInfo.build(page); | 70 | return TableDataInfo.build(page); |
| 85 | } | 71 | } |
| 86 | 72 | ||
| ... | @@ -96,13 +82,6 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -96,13 +82,6 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 96 | if(StrUtil.isNotBlank(vo.getOssId())){ | 82 | if(StrUtil.isNotBlank(vo.getOssId())){ |
| 97 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | 83 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); |
| 98 | } | 84 | } |
| 99 | List<BuildingBlockVo> buildingBlockVoList = buildingBlockMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getLanguage, language).eq(BuildingBlock::getEntiretyId, vo.getId())); | ||
| 100 | for(BuildingBlockVo blockVo:buildingBlockVoList){ | ||
| 101 | if(StrUtil.isNotBlank(blockVo.getOssId())){ | ||
| 102 | vo.setOssUrl(ossUrlService.selectUrlByIds(blockVo.getOssId())); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | vo.setBuildingblockList(buildingBlockVoList); | ||
| 106 | } | 85 | } |
| 107 | 86 | ||
| 108 | return list; | 87 | return list; |
| ... | @@ -126,6 +105,26 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -126,6 +105,26 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 126 | } | 105 | } |
| 127 | 106 | ||
| 128 | /** | 107 | /** |
| 108 | * (根据套件ID)不带分页查询 | ||
| 109 | * | ||
| 110 | * @param language | ||
| 111 | * @param buildingBlockIds | ||
| 112 | * @return | ||
| 113 | */ | ||
| 114 | @Override | ||
| 115 | public List<EntiretyVo> list(String language, Collection<String> buildingBlockIds) { | ||
| 116 | List<EntiretyVo> list = Lists.newArrayList(); | ||
| 117 | if(!CollectionUtils.isEmpty(buildingBlockIds)) { | ||
| 118 | list = baseMapper.selectVoList(Wrappers.<Entirety>lambdaQuery().eq(Entirety::getLanguage, language).in(Entirety::getBuildingBlockId, buildingBlockIds)); | ||
| 119 | } | ||
| 120 | else{ | ||
| 121 | list = baseMapper.selectVoList(Wrappers.<Entirety>lambdaQuery().eq(Entirety::getLanguage, language)); | ||
| 122 | } | ||
| 123 | setInfo(list); | ||
| 124 | return list; | ||
| 125 | } | ||
| 126 | |||
| 127 | /** | ||
| 129 | * 新增 | 128 | * 新增 |
| 130 | * | 129 | * |
| 131 | * @param entiretyBo | 130 | * @param entiretyBo |
| ... | @@ -164,7 +163,7 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -164,7 +163,7 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 164 | @Override | 163 | @Override |
| 165 | public boolean remove(String id) throws ServerException { | 164 | public boolean remove(String id) throws ServerException { |
| 166 | checkExists(id); | 165 | checkExists(id); |
| 167 | checkBuildingBlockExists(id); | 166 | checkCourseExists(id); |
| 168 | return baseMapper.deleteById(id) > 0; | 167 | return baseMapper.deleteById(id) > 0; |
| 169 | } | 168 | } |
| 170 | 169 | ||
| ... | @@ -185,6 +184,19 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -185,6 +184,19 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 185 | } | 184 | } |
| 186 | } | 185 | } |
| 187 | 186 | ||
| 187 | private void setInfo(List<EntiretyVo> list) { | ||
| 188 | if (ObjectUtil.isNotEmpty(list)) { | ||
| 189 | Set<String> ids = StreamUtils.toSet(list, EntiretyVo::getBuildingBlockId); | ||
| 190 | List<BuildingBlockVo> buildingBlockList = getBuildingBlockService().getListByIds(ids); | ||
| 191 | Map<String, BuildingBlockVo> buildingBlockMap = StreamUtils.toMap(buildingBlockList, BuildingBlockVo::getId, v -> v); | ||
| 192 | for (EntiretyVo vo : list) { | ||
| 193 | vo.setBuildingBlockName(buildingBlockMap.getOrDefault(vo.getBuildingBlockId(), new BuildingBlockVo()).getName()); | ||
| 194 | if (StrUtil.isNotBlank(vo.getOssId())) { | ||
| 195 | vo.setOssUrl(ossUrlService.selectUrlByIds(vo.getOssId())); | ||
| 196 | } | ||
| 197 | } | ||
| 198 | } | ||
| 199 | } | ||
| 188 | 200 | ||
| 189 | /** | 201 | /** |
| 190 | * 校验数据是否存在 | 202 | * 校验数据是否存在 |
| ... | @@ -192,8 +204,8 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -192,8 +204,8 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 192 | * @param id | 204 | * @param id |
| 193 | * @throws ServerException | 205 | * @throws ServerException |
| 194 | */ | 206 | */ |
| 195 | private void checkBuildingBlockExists(String id) throws ServerException { | 207 | private void checkCourseExists(String id) throws ServerException { |
| 196 | if (buildingBlockMapper.exists(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getEntiretyId, id))) { | 208 | if (courseMapper.exists(Wrappers.<Course>lambdaQuery().eq(Course::getEntiretyId, id))) { |
| 197 | throw new ServerException(MessageUtils.message("core.data.exists")); | 209 | throw new ServerException(MessageUtils.message("core.data.exists")); |
| 198 | } | 210 | } |
| 199 | } | 211 | } | ... | ... |
| 1 | package com.lego.core.service.impl; | 1 | package com.lego.core.service.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.bean.BeanUtil; | 3 | import cn.hutool.core.bean.BeanUtil; |
| 4 | import cn.hutool.core.util.ObjectUtil; | ||
| 4 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | 6 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 7 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 7 | import com.lego.common.core.page.TableDataInfo; | 8 | import com.lego.common.core.page.TableDataInfo; |
| 8 | import com.lego.common.utils.MessageUtils; | 9 | import com.lego.common.utils.MessageUtils; |
| 10 | import com.lego.common.utils.StreamUtils; | ||
| 11 | import com.lego.common.utils.spring.SpringUtils; | ||
| 9 | import com.lego.core.annotation.LanguageAnnotation; | 12 | import com.lego.core.annotation.LanguageAnnotation; |
| 10 | import com.lego.core.domin.Question; | 13 | import com.lego.core.domin.Question; |
| 11 | import com.lego.core.domin.bo.QuestionBo; | 14 | import com.lego.core.domin.bo.QuestionBo; |
| 12 | import com.lego.core.domin.bo.QuestionQueryBo; | 15 | import com.lego.core.domin.bo.QuestionQueryBo; |
| 16 | import com.lego.core.domin.vo.BuildingBlockVo; | ||
| 17 | import com.lego.core.domin.vo.EntiretyVo; | ||
| 13 | import com.lego.core.domin.vo.QuestionVo; | 18 | import com.lego.core.domin.vo.QuestionVo; |
| 14 | import com.lego.core.enums.StatusEnums; | 19 | import com.lego.core.enums.StatusEnums; |
| 15 | import com.lego.core.mapper.QuestionMapper; | 20 | import com.lego.core.mapper.QuestionMapper; |
| 21 | import com.lego.core.service.IBuildingBlockService; | ||
| 16 | import com.lego.core.service.IQuestionService; | 22 | import com.lego.core.service.IQuestionService; |
| 17 | import com.lego.system.domain.vo.SysOssVo; | 23 | import com.lego.system.domain.vo.SysOssVo; |
| 18 | import com.lego.system.service.ISysOssService; | 24 | import com.lego.system.service.ISysOssService; |
| ... | @@ -21,6 +27,8 @@ import org.springframework.stereotype.Service; | ... | @@ -21,6 +27,8 @@ import org.springframework.stereotype.Service; |
| 21 | 27 | ||
| 22 | import java.rmi.ServerException; | 28 | import java.rmi.ServerException; |
| 23 | import java.util.List; | 29 | import java.util.List; |
| 30 | import java.util.Map; | ||
| 31 | import java.util.Set; | ||
| 24 | 32 | ||
| 25 | /** | 33 | /** |
| 26 | * 问题MService业务层处理 | 34 | * 问题MService业务层处理 |
| ... | @@ -47,6 +55,7 @@ public class QuestionServiceImpl implements IQuestionService { | ... | @@ -47,6 +55,7 @@ public class QuestionServiceImpl implements IQuestionService { |
| 47 | .eq(Question::getLanguage,language) | 55 | .eq(Question::getLanguage,language) |
| 48 | .orderByAsc(Question::getSort)); | 56 | .orderByAsc(Question::getSort)); |
| 49 | List<QuestionVo> listVO = page.getRecords(); | 57 | List<QuestionVo> listVO = page.getRecords(); |
| 58 | setInfo(listVO); | ||
| 50 | for (QuestionVo vo : listVO) { | 59 | for (QuestionVo vo : listVO) { |
| 51 | StringBuilder sb = new StringBuilder(); | 60 | StringBuilder sb = new StringBuilder(); |
| 52 | if (StrUtil.equals(vo.getShowAndroid(), "1")) { | 61 | if (StrUtil.equals(vo.getShowAndroid(), "1")) { |
| ... | @@ -80,6 +89,7 @@ public class QuestionServiceImpl implements IQuestionService { | ... | @@ -80,6 +89,7 @@ public class QuestionServiceImpl implements IQuestionService { |
| 80 | @Override | 89 | @Override |
| 81 | public List<QuestionVo> list() { | 90 | public List<QuestionVo> list() { |
| 82 | List<QuestionVo> list = baseMapper.selectVoList(Wrappers.<Question>lambdaQuery().eq(Question::getStatus, "1")); | 91 | List<QuestionVo> list = baseMapper.selectVoList(Wrappers.<Question>lambdaQuery().eq(Question::getStatus, "1")); |
| 92 | setInfo(list); | ||
| 83 | for (QuestionVo vo : list) { | 93 | for (QuestionVo vo : list) { |
| 84 | StringBuilder sb = new StringBuilder(); | 94 | StringBuilder sb = new StringBuilder(); |
| 85 | if (StrUtil.equals(vo.getShowAndroid(), "1")) { | 95 | if (StrUtil.equals(vo.getShowAndroid(), "1")) { |
| ... | @@ -189,4 +199,19 @@ public class QuestionServiceImpl implements IQuestionService { | ... | @@ -189,4 +199,19 @@ public class QuestionServiceImpl implements IQuestionService { |
| 189 | throw new ServerException(MessageUtils.message("core.data.not.exists")); | 199 | throw new ServerException(MessageUtils.message("core.data.not.exists")); |
| 190 | } | 200 | } |
| 191 | } | 201 | } |
| 202 | |||
| 203 | private void setInfo(List<QuestionVo> list) { | ||
| 204 | if (ObjectUtil.isNotEmpty(list)) { | ||
| 205 | Set<String> ids = StreamUtils.toSet(list, QuestionVo::getBuildingBlockId); | ||
| 206 | List<BuildingBlockVo> buildingBlockList = getBuildingBlockService().getListByIds(ids); | ||
| 207 | Map<String, BuildingBlockVo> buildingBlockMap = StreamUtils.toMap(buildingBlockList, BuildingBlockVo::getId, v -> v); | ||
| 208 | for (QuestionVo vo : list) { | ||
| 209 | vo.setBuildingBlockName(buildingBlockMap.getOrDefault(vo.getBuildingBlockId(), new BuildingBlockVo()).getName()); | ||
| 210 | } | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | public IBuildingBlockService getBuildingBlockService() { | ||
| 215 | return SpringUtils.getBean(IBuildingBlockService.class); | ||
| 216 | } | ||
| 192 | } | 217 | } | ... | ... |
-
Please register or sign in to post a comment