package com.welampiot.controller; import com.welampiot.common.BaseResult; import com.welampiot.common.InterfaceResultEnum; import com.welampiot.dto.LightStripGroupDTO; import com.welampiot.service.LightStripGroupService; import com.welampiot.utils.ToolUtils; import com.welampiot.vo.LightStripGroupDetailVO; import com.welampiot.vo.LightStripGroupVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; /** * ClassName: LightStripGroupController * Package: com.welampiot.controller * Description: * * @Author: zhj_Start * @Create: 2023/5/5 - 17:45 * @Version: v1.0 */ @RestController @CrossOrigin @RequestMapping("/lightStripGroup") public class LightStripGroupController { @Autowired private LightStripGroupService lightStripGroupService; @Autowired private ToolUtils toolUtils; /** * 获取灯带分组列表 * @param request * @return */ @RequestMapping(value = "/getList", method = RequestMethod.POST) public BaseResult getList(HttpServletRequest request){ int version = (Integer) toolUtils.getRequestContent(request,"version",1); int page = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page")); int count = request.getParameter("count") == null ? 16 : Integer.parseInt(request.getParameter("count")); String keyword = (String) toolUtils.getRequestContent(request,"keyword",2); LightStripGroupDTO dto = new LightStripGroupDTO(); dto.setPage(count * (page - 1)); dto.setCount(count); dto.setVersion(version); dto.setKeyword(keyword); dto.setSectionList(toolUtils.getSectionList(request)); LightStripGroupVO vo = lightStripGroupService.getLightStripGroupByDTO(dto); return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,vo); } /** * 获取灯带分组列表详情 * @param request * @return */ @RequestMapping(value = "/details", method = RequestMethod.POST) public BaseResult details(HttpServletRequest request){ int version = (Integer) toolUtils.getRequestContent(request,"version",1); int id = (Integer) toolUtils.getRequestContent(request,"id",1); if (id == 0) return toolUtils.response(InterfaceResultEnum.LACK_PARAM_ERROR,version); LightStripGroupDetailVO lightStripGroupDetailsVO = lightStripGroupService.getLightStripGroupDetailsById(id, version); if (lightStripGroupDetailsVO == null) return toolUtils.response(InterfaceResultEnum.PARAM_FAIL,version); return toolUtils.response(InterfaceResultEnum.OPERATION_SUCCESS,version,lightStripGroupDetailsVO); } }