提交 06e41cb5 authored 作者: renjiancai's avatar renjiancai

--no commit message

上级 38381754
...@@ -66,22 +66,11 @@ public class RecommendController { ...@@ -66,22 +66,11 @@ public class RecommendController {
@ApiOperation(value = "更新" , notes ="根据ID更新,空值默认不更新") @ApiOperation(value = "更新" , notes ="根据ID更新,空值默认不更新")
@PostMapping(value = ResourceRequestPath.UPDATE) @PostMapping(value = ResourceRequestPath.UPDATE)
public CallBack<Boolean> update(@RequestBody UpdateRecommendForm form){ public CallBack<Boolean> update(@RequestBody UpdateRecommendForm form){
if(form.getId() == null && form.getNationsType() == null){ if(form.getId() == null){
throw new ParameterValidateException(1,"推进位id和民族id不能同时为空"); throw new ParameterValidateException(1,"推进位id不能为空");
} }
Recommend recommend = new Recommend(); Recommend recommend = new Recommend();
BeanUtils.copyProperties(form, recommend); BeanUtils.copyProperties(form, recommend);
//民族主页推荐位需要另外判断
if(form.getId() == null && form.getNationsType() != null){
Integer recomId = service.queryRecommendIdByNationAndRecommendType(form.getNationsType());
if(recomId == null){
throw new BusinessValidateException("操作失败");
}else{
recommend.setId(recomId);
}
}else{
recommend.setId(form.getId());
}
if(!service.updateByPrimaryKeySelective(recommend)){ if(!service.updateByPrimaryKeySelective(recommend)){
throw new BusinessValidateException("操作失败"); throw new BusinessValidateException("操作失败");
} }
...@@ -91,23 +80,12 @@ public class RecommendController { ...@@ -91,23 +80,12 @@ public class RecommendController {
@ApiOperation(value = "删除" , notes ="删除") @ApiOperation(value = "删除" , notes ="删除")
@PostMapping(value = ResourceRequestPath.DELETE) @PostMapping(value = ResourceRequestPath.DELETE)
public CallBack<Boolean> delete(@RequestBody DeleteRecommendForm form){ public CallBack<Boolean> delete(@RequestBody DeleteRecommendForm form){
if(form.getId() == null && form.getNationsType() == null){ if(form.getId() == null ){
throw new ParameterValidateException(1,"推进位id和民族id不能同时为空"); throw new ParameterValidateException(1,"推进位id不能为空");
} }
service.deleteByPrimaryKey(form.getId());
RecommendResource record = new RecommendResource(); RecommendResource record = new RecommendResource();
//民族主页推荐位需要另外判断 record.setRecomId(form.getId());
if(form.getId() == null && form.getNationsType() != null){
Integer recomId = service.queryRecommendIdByNationAndRecommendType(form.getNationsType());
if(recomId == null){
throw new BusinessValidateException("操作失败");
}else{
record.setRecomId(recomId);
service.deleteByPrimaryKey(recomId);
}
}else{
record.setRecomId(form.getId());
service.deleteByPrimaryKey(form.getId());
}
recommendResourceService.delete(record); recommendResourceService.delete(record);
return CallBack.success(); return CallBack.success();
} }
...@@ -194,15 +172,5 @@ public class RecommendController { ...@@ -194,15 +172,5 @@ public class RecommendController {
return recommendResourceService.updateResourceContent(form) ? CallBack.success() : CallBack.fail(); return recommendResourceService.updateResourceContent(form) ? CallBack.success() : CallBack.fail();
} }
/*@ApiOperation(value = "获取推荐组下推荐资源的所有类别")
@GetMapping(value = SysUserRequestPath.GET_TYPE)
public CallBack<Map<String,String>> getAllType() {
return CallBack.success(RecommendResourceTypeEnum.getAllEnumMap());
}*/
/* public Integer queryRecommendIdByNationAndRecommendType(Integer nationsType){
Integer recomId = service.queryRecommendIdByNationAndRecommendType(nationsType);
return recomId;
}*/
} }
...@@ -42,7 +42,6 @@ import com.zrqx.core.model.resource.authorLibrary.AuthorLibrary; ...@@ -42,7 +42,6 @@ import com.zrqx.core.model.resource.authorLibrary.AuthorLibrary;
import com.zrqx.core.model.resource.ebook.Book; import com.zrqx.core.model.resource.ebook.Book;
import com.zrqx.core.model.resource.ebook.Ebook; import com.zrqx.core.model.resource.ebook.Ebook;
import com.zrqx.core.model.resource.marketing.PromotionContent; import com.zrqx.core.model.resource.marketing.PromotionContent;
import com.zrqx.core.model.resource.recommend.RecommendResource;
import com.zrqx.core.util.datatype.ArrayUtils; import com.zrqx.core.util.datatype.ArrayUtils;
import com.zrqx.core.util.page.PageInfo; import com.zrqx.core.util.page.PageInfo;
import com.zrqx.core.util.page.PageParam; import com.zrqx.core.util.page.PageParam;
...@@ -162,60 +161,6 @@ public class ResourceLibraryController { ...@@ -162,60 +161,6 @@ public class ResourceLibraryController {
} }
return CallBack.success(); return CallBack.success();
} }
@ApiOperation(value = "推荐位弹框查询资源" , notes ="资源类型 0全部 理论 药物 方剂 临床 医案 文化 机构 医论 其他 医著 医家")
@GetMapping(value = ResourceRequestPath.RECOMMEND + ResourceRequestPath.PAGE)
public CallBack<PageInfo<?>> queryRecommend(QueryLibraryForm form, PageParam pageParam){
//先查询出推荐位列表中已存在的资源
List<RecommendResource> list = new ArrayList<RecommendResource>();
if(form.getRecomId() != null){
//公共推进位和民族推荐位
RecommendResource recommendResource = new RecommendResource();
recommendResource.setRecomId(form.getRecomId());
list = recommendResourceService.select(recommendResource);
}else{
//民族主页推荐位
Integer recomId = recommendService.queryRecommendIdByNationAndRecommendType(form.getNationsType());
if(recomId == null){
throw new BusinessValidateException(1,"无该民族主页");
}else{
RecommendResource recommendResource = new RecommendResource();
recommendResource.setRecomId(recomId);
list = recommendResourceService.select(recommendResource);
}
}
List<String> authorIdList = null;
List<String> ebookIdList = null;
List<String> articleIdList = null;
if(ArrayUtils.isNotEmpty(list)){
Map<Integer, List<String>> resultMap = list.stream().collect(Collectors.groupingBy(RecommendResource :: getResType,
Collectors.mapping(RecommendResource :: getResId, Collectors.toList())));
authorIdList = resultMap.get(AllResourceTypeEnum.ZHUANJIA.getCode());
ebookIdList = resultMap.get(AllResourceTypeEnum.TUSHU.getCode());
Stream<ArticleTypeEnum> streamType = Stream.of(ArticleTypeEnum.values());
articleIdList = streamType.map(ArticleTypeEnum :: getCode)
.map(resultMap :: get).flatMap(List :: stream).collect(Collectors.toList());
}
QueryResourceForPoPForm f = new QueryResourceForPoPForm();
BeanUtils.copyProperties(form, f);
//医家库列表查询
if(form.getResourceType() == AllResourceTypeEnum.ZHUANJIA.getCode()){
f.setIds(authorIdList);
return CallBack.success(authorLibraryService.pageByTitleAndDiyType(f, pageParam));
}
//医著库列表查询
if(form.getResourceType() == AllResourceTypeEnum.TUSHU.getCode()){
f.setIds(ebookIdList);
return CallBack.success(ebookservice.pageByTitleAndDiyType(f, pageParam));
}
//文章库列表查询
if(ArticleTypeEnum.getName(form.getResourceType().toString()) != null){
f.setIds(articleIdList);
return CallBack.success(articleLibraryService.pageByTitleAndDiyType(f, pageParam));
}
return CallBack.success();
}
@ApiOperation(value = "选择弹窗中的列表", notes = "查询选择弹窗中的列表") @ApiOperation(value = "选择弹窗中的列表", notes = "查询选择弹窗中的列表")
@GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.POPPAGE) @GetMapping(value = ResourceRequestPath.RELATION_RESOURCE + ResourceRequestPath.POPPAGE)
public CallBack<PageInfo<ResourceRelationListVo>> page(QueryResourceForPoPForm form, PageParam pageParam) { public CallBack<PageInfo<ResourceRelationListVo>> page(QueryResourceForPoPForm form, PageParam pageParam) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论