ScanController.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package com.bofeng.wx.controller;
  2. import com.bofeng.dao.*;
  3. import com.bofeng.entity.*;
  4. import com.bofeng.service.HomeService;
  5. import com.fasterxml.jackson.core.JsonProcessingException;
  6. import com.yvan.platform.JsonWapper;
  7. import io.swagger.annotations.Api;
  8. import io.swagger.annotations.ApiImplicitParam;
  9. import io.swagger.annotations.ApiImplicitParams;
  10. import io.swagger.annotations.ApiOperation;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.ui.ModelMap;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.RequestParam;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import org.springframework.web.servlet.ModelAndView;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. @Api("进出扫码")
  20. @RestController
  21. public class ScanController {
  22. @Autowired
  23. private HomeService homeService;
  24. @Autowired
  25. private UserRoleMapper userRoleMapper;
  26. @Autowired
  27. private UserOpenMapper userOpenMapper;
  28. @Autowired
  29. private UptownHomeMapper uptownHomeMapper;
  30. @Autowired
  31. private UptownUnitMapper uptownUnitMapper;
  32. @Autowired
  33. private UptownDoorMapper uptownDoorMapper;
  34. @ApiOperation("进出扫码页面")
  35. @GetMapping("/user/scan.html")
  36. public ModelAndView home(ModelMap model, @RequestParam(value = "doorId", required = false, defaultValue = "0") Long doorId) {
  37. // UserOpen userOpen = homeService.getUserOpen();
  38. // List<UserRole> list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId());
  39. List<UserRole> list = userRoleMapper.getUserRoleByUserId(1L);
  40. UserOpen userOpen = userOpenMapper.selectByUserId(1L);
  41. model.put("user", userOpen);
  42. model.put("user_id", "\"" + userOpen.getUserId() + "\"");
  43. if (list.size() == 0) {
  44. return new ModelAndView("/user/home.ftl", model);
  45. } else {
  46. UptownDoor uptownDoor = uptownDoorMapper.getUptownDoorById(doorId);
  47. List<UptownHome> uptownHomes = uptownHomeMapper.getUptownHomeByUserId(userOpen.getUserId());
  48. UptownUnit unit = uptownUnitMapper.getUptownUnitByUser(userOpen.getUserId());
  49. if (!unit.getUptownId().equals(uptownDoor.getUptownId())) {
  50. model.put("type", "-1");
  51. return new ModelAndView("/user/scan.ftl", model);
  52. }
  53. model.put("door", uptownDoor.getUptownName() + uptownDoor.getDoorName());
  54. model.put("doorplate", unit.getRidgepole() + "栋" + unit.getUnit() + "单元" +unit.getDoorplate());
  55. model.put("name", uptownHomes.get(0).getLinkman());
  56. return new ModelAndView("/user/scan.ftl", model);
  57. }
  58. }
  59. }