ArticleController.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.fdkankan.ucenter.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.fdkankan.ucenter.common.BaseController;
  4. import com.fdkankan.ucenter.common.Result;
  5. import com.fdkankan.ucenter.entity.Article;
  6. import com.fdkankan.ucenter.entity.Case;
  7. import com.fdkankan.ucenter.service.IArticleService;
  8. import com.fdkankan.ucenter.service.ICaseService;
  9. import org.apache.commons.lang3.StringUtils;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.util.ObjectUtils;
  12. import org.springframework.web.bind.annotation.*;
  13. /**
  14. * <p>
  15. * 前端控制器
  16. * </p>
  17. *
  18. * @author
  19. * @since 2022-10-13
  20. */
  21. @RestController
  22. @RequestMapping("/ucenter/article")
  23. public class ArticleController extends BaseController {
  24. @Autowired
  25. ICaseService caseService;
  26. /**
  27. * 行业解决方案-案例展示
  28. */
  29. @PostMapping("/detail")
  30. public Result detail(@RequestBody Case caseEntity) throws Exception {
  31. if(ObjectUtils.isEmpty(caseEntity.getId())){
  32. return Result.success();
  33. }
  34. return Result.success(caseService.getById(caseEntity.getId()));
  35. }
  36. @PostMapping("/allList")
  37. public Result allList(@RequestBody Case caseEntity) throws Exception {
  38. String lang = getLang();
  39. if("zh".equals(lang)){
  40. lang = "cn";
  41. }
  42. LambdaQueryWrapper<Case> wrapper = new LambdaQueryWrapper<>();
  43. if(StringUtils.isNotBlank(caseEntity.getTypeId())){
  44. wrapper.eq(Case::getTypeId,caseEntity.getTypeId());
  45. }
  46. wrapper.eq(Case::getLanguage,lang);
  47. wrapper.eq(Case::getIsPublic,1);
  48. wrapper.orderByAsc(Case::getSort);
  49. wrapper.orderByAsc(Case::getId);
  50. return Result.success(caseService.list(wrapper));
  51. }
  52. }