package com.bofeng.wx.controller; import com.bofeng.dao.*; import com.bofeng.entity.*; import com.bofeng.service.HomeService; import com.fasterxml.jackson.core.JsonProcessingException; import com.yvan.platform.JsonWapper; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import java.util.ArrayList; import java.util.List; @Api("进出扫码") @RestController public class ScanController { @Autowired private HomeService homeService; @Autowired private UserRoleMapper userRoleMapper; @Autowired private UserOpenMapper userOpenMapper; @Autowired private UptownHomeMapper uptownHomeMapper; @Autowired private UptownUnitMapper uptownUnitMapper; @Autowired private UptownDoorMapper uptownDoorMapper; @ApiOperation("进出扫码页面") @GetMapping("/user/scan.html") public ModelAndView home(ModelMap model, @RequestParam(value = "doorId", required = false, defaultValue = "0") Long doorId) { // UserOpen userOpen = homeService.getUserOpen(); // List list = userRoleMapper.getUserRoleByUserId(userOpen.getUserId()); List list = userRoleMapper.getUserRoleByUserId(1L); UserOpen userOpen = userOpenMapper.selectByUserId(1L); model.put("user", userOpen); model.put("user_id", "\"" + userOpen.getUserId() + "\""); if (list.size() == 0) { return new ModelAndView("/user/home.ftl", model); } else { UptownDoor uptownDoor = uptownDoorMapper.getUptownDoorById(doorId); List uptownHomes = uptownHomeMapper.getUptownHomeByUserId(userOpen.getUserId()); UptownUnit unit = uptownUnitMapper.getUptownUnitByUser(userOpen.getUserId()); if (!unit.getUptownId().equals(uptownDoor.getUptownId())) { model.put("type", "-1"); return new ModelAndView("/user/scan.ftl", model); } model.put("door", uptownDoor.getUptownName() + uptownDoor.getDoorName()); model.put("doorplate", unit.getRidgepole() + "栋" + unit.getUnit() + "单元" +unit.getDoorplate()); model.put("name", uptownHomes.get(0).getLinkman()); return new ModelAndView("/user/scan.ftl", model); } } }