增加APP相关接口
Showing
9 changed files
with
136 additions
and
14 deletions
| ... | @@ -40,7 +40,18 @@ public class BuildingBlockController extends BaseController { | ... | @@ -40,7 +40,18 @@ public class BuildingBlockController extends BaseController { |
| 40 | @PostMapping("listPage") | 40 | @PostMapping("listPage") |
| 41 | public TableDataInfo<BuildingBlockVo> listPage(@RequestBody BuildingBlockQueryBo query, HttpServletRequest request) { | 41 | public TableDataInfo<BuildingBlockVo> listPage(@RequestBody BuildingBlockQueryBo query, HttpServletRequest request) { |
| 42 | String language = request.getHeader("content-language"); | 42 | String language = request.getHeader("content-language"); |
| 43 | return service.listPage(query,language); | 43 | return service.listPage(query, language); |
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * 根据ID查询详情 | ||
| 48 | * | ||
| 49 | * @param id | ||
| 50 | * @return | ||
| 51 | */ | ||
| 52 | @GetMapping("/getById/{id}") | ||
| 53 | public R<BuildingBlockVo> getById(@RequestParam("id") String id) { | ||
| 54 | return R.ok(service.get(id)); | ||
| 44 | } | 55 | } |
| 45 | 56 | ||
| 46 | /** | 57 | /** | ... | ... |
| ... | @@ -40,7 +40,29 @@ public class CourseController extends BaseController { | ... | @@ -40,7 +40,29 @@ public class CourseController extends BaseController { |
| 40 | @PostMapping("listPage") | 40 | @PostMapping("listPage") |
| 41 | public TableDataInfo<CourseVo> listPage(@RequestBody CourseQueryBo query, HttpServletRequest request) { | 41 | public TableDataInfo<CourseVo> listPage(@RequestBody CourseQueryBo query, HttpServletRequest request) { |
| 42 | String language = request.getHeader("content-language"); | 42 | String language = request.getHeader("content-language"); |
| 43 | return service.listPage(query,language); | 43 | return service.listPage(query, language); |
| 44 | } | ||
| 45 | |||
| 46 | /** | ||
| 47 | * 根据系列id查找的课程列表 | ||
| 48 | * | ||
| 49 | * @param buildingBlockId | ||
| 50 | * @return | ||
| 51 | */ | ||
| 52 | @GetMapping("/list/{buildingBlockId}") | ||
| 53 | public R<List<CourseVo>> list(@RequestParam("buildingBlockId") String buildingBlockId) { | ||
| 54 | return R.ok(service.list(buildingBlockId)); | ||
| 55 | } | ||
| 56 | |||
| 57 | /** | ||
| 58 | * 课程详情 | ||
| 59 | * | ||
| 60 | * @param id | ||
| 61 | * @return | ||
| 62 | */ | ||
| 63 | @GetMapping("/getById/{id}") | ||
| 64 | public R<CourseVo> getById(@RequestParam("id") String id) { | ||
| 65 | return R.ok(service.getById(id)); | ||
| 44 | } | 66 | } |
| 45 | 67 | ||
| 46 | /** | 68 | /** | ... | ... |
| ... | @@ -138,10 +138,14 @@ security: | ... | @@ -138,10 +138,14 @@ security: |
| 138 | - /actuator/** | 138 | - /actuator/** |
| 139 | - /core/advert/list | 139 | - /core/advert/list |
| 140 | - /core/buildingBlock/listPage | 140 | - /core/buildingBlock/listPage |
| 141 | - /core/buildingBlock/getById/** | ||
| 141 | - /core/course/listPage | 142 | - /core/course/listPage |
| 143 | - /core/course/** | ||
| 144 | - /core/getById/** | ||
| 142 | - /core/entirety/listPage | 145 | - /core/entirety/listPage |
| 143 | - /core/question/listPage | 146 | - /core/question/listPage |
| 144 | - /core/upgrade/listPage | 147 | - /core/upgrade/listPage |
| 148 | - | ||
| 145 | 149 | ||
| 146 | # MyBatisPlus配置 | 150 | # MyBatisPlus配置 |
| 147 | # https://baomidou.com/config/ | 151 | # https://baomidou.com/config/ | ... | ... |
| ... | @@ -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_entirety | 8 | * 套件视图对象 core_entirety |
| 7 | * | 9 | * |
| ... | @@ -43,4 +45,9 @@ public class EntiretyVo { | ... | @@ -43,4 +45,9 @@ public class EntiretyVo { |
| 43 | * 前端APP数据国际化(zh_CN、en_US、ru_RU) | 45 | * 前端APP数据国际化(zh_CN、en_US、ru_RU) |
| 44 | */ | 46 | */ |
| 45 | private String language; | 47 | private String language; |
| 48 | |||
| 49 | /** | ||
| 50 | * 系列信息 | ||
| 51 | */ | ||
| 52 | List<BuildingBlockVo> BuildingblockList; | ||
| 46 | } | 53 | } | ... | ... |
| 1 | package com.lego.core.service; | 1 | package com.lego.core.service; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import com.lego.common.core.domain.PageQuery; | ||
| 5 | import com.lego.common.core.page.TableDataInfo; | 4 | import com.lego.common.core.page.TableDataInfo; |
| 6 | import com.lego.core.domin.BuildingBlock; | ||
| 7 | import com.lego.core.domin.bo.AdvertBo; | ||
| 8 | import com.lego.core.domin.bo.BuildingBlockBo; | 5 | import com.lego.core.domin.bo.BuildingBlockBo; |
| 9 | import com.lego.core.domin.bo.BuildingBlockQueryBo; | 6 | import com.lego.core.domin.bo.BuildingBlockQueryBo; |
| 10 | import com.lego.core.domin.bo.EntiretyBo; | ||
| 11 | import com.lego.core.domin.vo.AdvertVo; | ||
| 12 | import com.lego.core.domin.vo.BuildingBlockVo; | 7 | import com.lego.core.domin.vo.BuildingBlockVo; |
| 13 | import com.lego.core.domin.vo.EntiretyVo; | ||
| 14 | 8 | ||
| 15 | import java.rmi.ServerException; | 9 | import java.rmi.ServerException; |
| 16 | import java.util.Collection; | 10 | import java.util.Collection; |
| ... | @@ -29,7 +23,7 @@ public interface IBuildingBlockService { | ... | @@ -29,7 +23,7 @@ public interface IBuildingBlockService { |
| 29 | * @param queryBo | 23 | * @param queryBo |
| 30 | * @return | 24 | * @return |
| 31 | */ | 25 | */ |
| 32 | TableDataInfo<BuildingBlockVo> listPage(BuildingBlockQueryBo queryBo,String language); | 26 | TableDataInfo<BuildingBlockVo> listPage(BuildingBlockQueryBo queryBo, String language); |
| 33 | 27 | ||
| 34 | /** | 28 | /** |
| 35 | * 不带分页查询 | 29 | * 不带分页查询 |
| ... | @@ -39,6 +33,13 @@ public interface IBuildingBlockService { | ... | @@ -39,6 +33,13 @@ public interface IBuildingBlockService { |
| 39 | List<BuildingBlockVo> list(String language); | 33 | List<BuildingBlockVo> list(String language); |
| 40 | 34 | ||
| 41 | /** | 35 | /** |
| 36 | * (根据套件ID)不带分页查询 | ||
| 37 | * | ||
| 38 | * @return | ||
| 39 | */ | ||
| 40 | List<BuildingBlockVo> list(String language, Collection<String> entiretyIds); | ||
| 41 | |||
| 42 | /** | ||
| 42 | * 新增 | 43 | * 新增 |
| 43 | * | 44 | * |
| 44 | * @param blockBo | 45 | * @param blockBo |
| ... | @@ -66,9 +67,19 @@ public interface IBuildingBlockService { | ... | @@ -66,9 +67,19 @@ public interface IBuildingBlockService { |
| 66 | 67 | ||
| 67 | /** | 68 | /** |
| 68 | * 根据ID集合获取积木 | 69 | * 根据ID集合获取积木 |
| 70 | * | ||
| 69 | * @param ids | 71 | * @param ids |
| 70 | * @return | 72 | * @return |
| 71 | * @throws ServerException | 73 | * @throws ServerException |
| 72 | */ | 74 | */ |
| 73 | List<BuildingBlockVo> getListByIds(Collection<String> ids); | 75 | List<BuildingBlockVo> getListByIds(Collection<String> ids); |
| 76 | |||
| 77 | /** | ||
| 78 | * 根据ID获取详情 | ||
| 79 | * | ||
| 80 | * @param id | ||
| 81 | * @return | ||
| 82 | */ | ||
| 83 | BuildingBlockVo get(String id); | ||
| 84 | |||
| 74 | } | 85 | } | ... | ... |
| ... | @@ -6,6 +6,7 @@ import com.lego.core.domin.bo.CourseQueryBo; | ... | @@ -6,6 +6,7 @@ import com.lego.core.domin.bo.CourseQueryBo; |
| 6 | import com.lego.core.domin.vo.CourseVo; | 6 | import com.lego.core.domin.vo.CourseVo; |
| 7 | 7 | ||
| 8 | import java.rmi.ServerException; | 8 | import java.rmi.ServerException; |
| 9 | import java.util.List; | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * 课程Service接口 | 12 | * 课程Service接口 |
| ... | @@ -20,7 +21,23 @@ public interface ICourseService { | ... | @@ -20,7 +21,23 @@ public interface ICourseService { |
| 20 | * @param query | 21 | * @param query |
| 21 | * @return | 22 | * @return |
| 22 | */ | 23 | */ |
| 23 | TableDataInfo<CourseVo> listPage(CourseQueryBo query,String language); | 24 | TableDataInfo<CourseVo> listPage(CourseQueryBo query, String language); |
| 25 | |||
| 26 | /** | ||
| 27 | * 根据系列id查找的课程列表 | ||
| 28 | * | ||
| 29 | * @param buildingBlockId | ||
| 30 | * @return | ||
| 31 | */ | ||
| 32 | List<CourseVo> list(String buildingBlockId); | ||
| 33 | |||
| 34 | /** | ||
| 35 | * 课程详情 | ||
| 36 | * | ||
| 37 | * @param id | ||
| 38 | * @return | ||
| 39 | */ | ||
| 40 | CourseVo getById(String id); | ||
| 24 | 41 | ||
| 25 | /** | 42 | /** |
| 26 | * 新增 | 43 | * 新增 | ... | ... |
| ... | @@ -72,6 +72,17 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -72,6 +72,17 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | /** | 74 | /** |
| 75 | * (根据套件ID)不带分页查询 | ||
| 76 | * @param language | ||
| 77 | * @param entiretyIds | ||
| 78 | * @return | ||
| 79 | */ | ||
| 80 | @Override | ||
| 81 | public List<BuildingBlockVo> list(String language, Collection<String> entiretyIds) { | ||
| 82 | return baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().eq(BuildingBlock::getLanguage, language).in(BuildingBlock::getEntiretyId,entiretyIds)); | ||
| 83 | } | ||
| 84 | |||
| 85 | /** | ||
| 75 | * 新增 | 86 | * 新增 |
| 76 | * | 87 | * |
| 77 | * @param blockBo | 88 | * @param blockBo |
| ... | @@ -123,6 +134,11 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { | ... | @@ -123,6 +134,11 @@ public class BuildingBlockServiceImpl implements IBuildingBlockService { |
| 123 | return baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().in(BuildingBlock::getId, ids)); | 134 | return baseMapper.selectVoList(Wrappers.<BuildingBlock>lambdaQuery().in(BuildingBlock::getId, ids)); |
| 124 | } | 135 | } |
| 125 | 136 | ||
| 137 | @Override | ||
| 138 | public BuildingBlockVo get(String id) { | ||
| 139 | return baseMapper.selectVoById(id); | ||
| 140 | } | ||
| 141 | |||
| 126 | 142 | ||
| 127 | /** | 143 | /** |
| 128 | * 校验数据是否存在 | 144 | * 校验数据是否存在 | ... | ... |
| ... | @@ -47,10 +47,10 @@ public class CourseServiceImpl implements ICourseService { | ... | @@ -47,10 +47,10 @@ public class CourseServiceImpl implements ICourseService { |
| 47 | * @return | 47 | * @return |
| 48 | */ | 48 | */ |
| 49 | @Override | 49 | @Override |
| 50 | public TableDataInfo<CourseVo> listPage(CourseQueryBo query,String language) { | 50 | public TableDataInfo<CourseVo> listPage(CourseQueryBo query, String language) { |
| 51 | Page<CourseVo> page = baseMapper.selectVoPage(query.build(), | 51 | Page<CourseVo> page = baseMapper.selectVoPage(query.build(), |
| 52 | Wrappers.<Course>lambdaQuery().eq(StrUtil.isNotBlank(query.getSearchKey()), Course::getName, query.getSearchKey()) | 52 | Wrappers.<Course>lambdaQuery().eq(StrUtil.isNotBlank(query.getSearchKey()), Course::getName, query.getSearchKey()) |
| 53 | .eq(Course::getLanguage,language)); | 53 | .eq(Course::getLanguage, language)); |
| 54 | List<CourseVo> list = page.getRecords(); | 54 | List<CourseVo> list = page.getRecords(); |
| 55 | if (ObjectUtil.isNotEmpty(list)) { | 55 | if (ObjectUtil.isNotEmpty(list)) { |
| 56 | Set<String> ids = StreamUtils.toSet(list, CourseVo::getBuildingBlockId); | 56 | Set<String> ids = StreamUtils.toSet(list, CourseVo::getBuildingBlockId); |
| ... | @@ -64,6 +64,26 @@ public class CourseServiceImpl implements ICourseService { | ... | @@ -64,6 +64,26 @@ public class CourseServiceImpl implements ICourseService { |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | /** | 66 | /** |
| 67 | * | ||
| 68 | * @param buildingBlockId | ||
| 69 | * @return | ||
| 70 | */ | ||
| 71 | @Override | ||
| 72 | public List<CourseVo> list(String buildingBlockId) { | ||
| 73 | return baseMapper.selectVoList(Wrappers.<Course>lambdaQuery().eq(Course::getBuildingBlockId, buildingBlockId)); | ||
| 74 | } | ||
| 75 | |||
| 76 | /** | ||
| 77 | * 课程详情 | ||
| 78 | * @param id | ||
| 79 | * @return | ||
| 80 | */ | ||
| 81 | @Override | ||
| 82 | public CourseVo getById(String id) { | ||
| 83 | return baseMapper.selectVoById(id); | ||
| 84 | } | ||
| 85 | |||
| 86 | /** | ||
| 67 | * 新增 | 87 | * 新增 |
| 68 | * | 88 | * |
| 69 | * @param courseBo | 89 | * @param courseBo |
| ... | @@ -96,6 +116,7 @@ public class CourseServiceImpl implements ICourseService { | ... | @@ -96,6 +116,7 @@ public class CourseServiceImpl implements ICourseService { |
| 96 | 116 | ||
| 97 | /** | 117 | /** |
| 98 | * 从上传文件中获取案例名称 | 118 | * 从上传文件中获取案例名称 |
| 119 | * | ||
| 99 | * @param course | 120 | * @param course |
| 100 | */ | 121 | */ |
| 101 | private void setCaseName(Course course) { | 122 | private void setCaseName(Course course) { | ... | ... |
| ... | @@ -7,18 +7,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ... | @@ -7,18 +7,20 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| 7 | import com.lego.common.core.domain.PageQuery; | 7 | import com.lego.common.core.domain.PageQuery; |
| 8 | import com.lego.common.core.page.TableDataInfo; | 8 | import com.lego.common.core.page.TableDataInfo; |
| 9 | import com.lego.common.utils.MessageUtils; | 9 | import com.lego.common.utils.MessageUtils; |
| 10 | import com.lego.common.utils.StreamUtils; | ||
| 10 | import com.lego.core.annotation.LanguageAnnotation; | 11 | import com.lego.core.annotation.LanguageAnnotation; |
| 11 | import com.lego.core.domin.Entirety; | 12 | import com.lego.core.domin.Entirety; |
| 12 | import com.lego.core.domin.bo.EntiretyBo; | 13 | import com.lego.core.domin.bo.EntiretyBo; |
| 14 | import com.lego.core.domin.vo.BuildingBlockVo; | ||
| 13 | import com.lego.core.domin.vo.EntiretyVo; | 15 | import com.lego.core.domin.vo.EntiretyVo; |
| 14 | import com.lego.core.mapper.EntiretyMapper; | 16 | import com.lego.core.mapper.EntiretyMapper; |
| 17 | import com.lego.core.service.IBuildingBlockService; | ||
| 15 | import com.lego.core.service.IEntiretyService; | 18 | import com.lego.core.service.IEntiretyService; |
| 16 | import lombok.RequiredArgsConstructor; | 19 | import lombok.RequiredArgsConstructor; |
| 17 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 18 | 21 | ||
| 19 | import java.rmi.ServerException; | 22 | import java.rmi.ServerException; |
| 20 | import java.util.Collection; | 23 | import java.util.*; |
| 21 | import java.util.List; | ||
| 22 | 24 | ||
| 23 | /** | 25 | /** |
| 24 | * 套件Service业务层处理 | 26 | * 套件Service业务层处理 |
| ... | @@ -30,6 +32,7 @@ import java.util.List; | ... | @@ -30,6 +32,7 @@ import java.util.List; |
| 30 | @Service | 32 | @Service |
| 31 | public class EntiretyServiceImpl implements IEntiretyService { | 33 | public class EntiretyServiceImpl implements IEntiretyService { |
| 32 | private final EntiretyMapper baseMapper; | 34 | private final EntiretyMapper baseMapper; |
| 35 | private final IBuildingBlockService buildingBlockService; | ||
| 33 | 36 | ||
| 34 | /** | 37 | /** |
| 35 | * 查询所有列表 | 38 | * 查询所有列表 |
| ... | @@ -41,6 +44,16 @@ public class EntiretyServiceImpl implements IEntiretyService { | ... | @@ -41,6 +44,16 @@ public class EntiretyServiceImpl implements IEntiretyService { |
| 41 | public TableDataInfo<EntiretyVo> listPage(PageQuery query, String language) { | 44 | public TableDataInfo<EntiretyVo> listPage(PageQuery query, String language) { |
| 42 | Page<EntiretyVo> page = baseMapper.selectVoPage(query.build(), Wrappers.<Entirety>lambdaQuery() | 45 | Page<EntiretyVo> page = baseMapper.selectVoPage(query.build(), Wrappers.<Entirety>lambdaQuery() |
| 43 | .eq(Entirety::getLanguage, language).orderByAsc(Entirety::getSort)); | 46 | .eq(Entirety::getLanguage, language).orderByAsc(Entirety::getSort)); |
| 47 | /** | ||
| 48 | * 处理二级数据 | ||
| 49 | */ | ||
| 50 | List<EntiretyVo> list = page.getRecords(); | ||
| 51 | Set<String> BuildingBlockIdList = StreamUtils.toSet(list,EntiretyVo::getId); | ||
| 52 | List<BuildingBlockVo> BuildingBlockList = buildingBlockService.list(language, BuildingBlockIdList); | ||
| 53 | Map<String,List<BuildingBlockVo>> buildingBlockMap = StreamUtils.groupByKey(BuildingBlockList,BuildingBlockVo::getEntiretyId); | ||
| 54 | for(EntiretyVo vo:list){ | ||
| 55 | vo.setBuildingblockList(buildingBlockMap.get(vo.getId())); | ||
| 56 | } | ||
| 44 | return TableDataInfo.build(page); | 57 | return TableDataInfo.build(page); |
| 45 | } | 58 | } |
| 46 | 59 | ... | ... |
-
Please register or sign in to post a comment