InstrumentController.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.caimei.www.controller.unlimited;
  2. import com.caimei.www.controller.BaseController;
  3. import com.caimei.www.pojo.JsonModel;
  4. import com.caimei.www.pojo.page.PageContent;
  5. import com.caimei.www.pojo.page.PageFloor;
  6. import com.caimei.www.service.InstrumentService;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.ui.Model;
  10. import org.springframework.web.bind.annotation.GetMapping;
  11. import org.springframework.web.bind.annotation.RequestParam;
  12. import org.springframework.web.bind.annotation.ResponseBody;
  13. import java.util.List;
  14. /**
  15. * 项目仪器(instrument)
  16. *
  17. * @author : Charles
  18. * @date : 2020/7/16
  19. */
  20. @Controller
  21. public class InstrumentController extends BaseController {
  22. private static final String INSTRUMENT_SEARCH_PATH = "instrument/search";
  23. private static final String INSTRUMENT_DETAIL_PATH = "instrument/detail";
  24. private InstrumentService instrumentService;
  25. @Autowired
  26. public void setInstrumentService(InstrumentService instrumentService) {
  27. this.instrumentService = instrumentService;
  28. }
  29. /**
  30. * 项目仪器搜索结果页
  31. */
  32. @GetMapping("/instrument/list.html")
  33. public String search() {
  34. return INSTRUMENT_SEARCH_PATH;
  35. }
  36. /**
  37. * 项目仪器详情页
  38. */
  39. @GetMapping("/instrument/detail.html")
  40. public String home(final Model model, @RequestParam("id") Integer instrumentId) {
  41. PageContent detail = instrumentService.getInstrumentById(instrumentId);
  42. model.addAttribute("instrument", detail);
  43. return INSTRUMENT_DETAIL_PATH;
  44. }
  45. /**
  46. * 获取项目仪器详情页中层信息(搭配推荐,相似商品)
  47. */
  48. @GetMapping("/instrument/recommend")
  49. @ResponseBody
  50. public JsonModel<List<PageFloor>> getInstrumentRecommendById(Integer instrumentId) {
  51. return instrumentService.getInstrumentRecommendById(instrumentId);
  52. }
  53. }