LightStripGroupController.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package com.welampiot.controller;
  2. import com.welampiot.common.BaseResult;
  3. import com.welampiot.common.InterfaceResultEnum;
  4. import com.welampiot.dto.LightStripGroupDTO;
  5. import com.welampiot.service.LightStripGroupService;
  6. import com.welampiot.utils.ToolUtils;
  7. import com.welampiot.vo.LightStripGroupDetailVO;
  8. import com.welampiot.vo.LightStripGroupVO;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.CrossOrigin;
  11. import org.springframework.web.bind.annotation.RequestMapping;
  12. import org.springframework.web.bind.annotation.RequestMethod;
  13. import org.springframework.web.bind.annotation.RestController;
  14. import javax.servlet.http.HttpServletRequest;
  15. /**
  16. * ClassName: LightStripGroupController
  17. * Package: com.welampiot.controller
  18. * Description:
  19. *
  20. * @Author: zhj_Start
  21. * @Create: 2023/5/5 - 17:45
  22. * @Version: v1.0
  23. */
  24. @RestController
  25. @CrossOrigin
  26. @RequestMapping("/lightStripGroup")
  27. public class LightStripGroupController {
  28. @Autowired
  29. private LightStripGroupService lightStripGroupService;
  30. @Autowired
  31. private ToolUtils toolUtils;
  32. /**
  33. * 获取灯带分组列表
  34. * @param request
  35. * @return
  36. */
  37. @RequestMapping(value = "/getList", method = RequestMethod.POST)
  38. public BaseResult getList(HttpServletRequest request){
  39. int version = (Integer) toolUtils.getRequestContent(request,"version",1);
  40. int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
  41. int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count"));
  42. String keyword = (String) toolUtils.getRequestContent(request,"keyword",2);
  43. LightStripGroupDTO dto = new LightStripGroupDTO();
  44. dto.setPage(count * (page - 1));
  45. dto.setCount(count);
  46. dto.setVersion(version);
  47. dto.setKeyword(keyword);
  48. dto.setSectionList(toolUtils.getSectionList(request));
  49. LightStripGroupVO vo = lightStripGroupService.getLightStripGroupByDTO(dto);
  50. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo);
  51. }
  52. /**
  53. * 获取灯带分组列表详情
  54. * @param request
  55. * @return
  56. */
  57. @RequestMapping(value = "/details", method = RequestMethod.POST)
  58. public BaseResult details(HttpServletRequest request){
  59. int version = (Integer) toolUtils.getRequestContent(request,"version",1);
  60. int id = (Integer) toolUtils.getRequestContent(request,"id",1);
  61. if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version);
  62. LightStripGroupDetailVO lightStripGroupDetailsVO = lightStripGroupService.getLightStripGroupDetailsById(id, version);
  63. if (lightStripGroupDetailsVO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version);
  64. return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lightStripGroupDetailsVO);
  65. }
  66. }