HealthEducationController.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package thyyxxk.wxservice_server.controller.isolations;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.web.bind.annotation.GetMapping;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RestController;
  6. import thyyxxk.wxservice_server.config.auth.PassToken;
  7. import thyyxxk.wxservice_server.dao.isolations.HealthEducationDao;
  8. import thyyxxk.wxservice_server.entity.ResultVo;
  9. import thyyxxk.wxservice_server.entity.isolations.HealthEducation;
  10. import thyyxxk.wxservice_server.utils.ResultVoUtil;
  11. import java.util.*;
  12. @RestController
  13. @RequestMapping("/healthEducation")
  14. public class HealthEducationController {
  15. private final HealthEducationDao dao;
  16. @Autowired
  17. public HealthEducationController(HealthEducationDao dao) {
  18. this.dao = dao;
  19. }
  20. @PassToken
  21. @GetMapping("/getVideoUrls")
  22. public ResultVo<LinkedHashMap<String, List<HealthEducation>>> getVideoUrls() {
  23. List<HealthEducation> urls = dao.selectHealthEducations();
  24. LinkedHashMap<String, List<HealthEducation>> map = new LinkedHashMap<>();
  25. for (HealthEducation item : urls) {
  26. String typeName = item.getTypeName();
  27. if (map.containsKey(typeName)) {
  28. map.get(typeName).add(item);
  29. } else {
  30. List<HealthEducation> tempList = new ArrayList<>();
  31. tempList.add(item);
  32. map.put(typeName, tempList);
  33. }
  34. }
  35. return ResultVoUtil.success(map);
  36. }
  37. }