|  |  |  | 
|---|
|  |  |  | package com.doumee.api.business; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.model.LoginUserInfo; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.QrCodeUtils; | 
|---|
|  |  |  | import com.doumee.dao.business.model.RoomTime; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Rooms; | 
|---|
|  |  |  | import com.doumee.dao.web.request.RoomTimeRequest; | 
|---|
|  |  |  | import com.doumee.dao.web.request.RoomsRequest; | 
|---|
|  |  |  | import com.doumee.dao.web.response.RoomsResponse; | 
|---|
|  |  |  | import com.doumee.service.business.RoomTimeService; | 
|---|
|  |  |  | import com.doumee.service.business.RoomsService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParams; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.apache.shiro.SecurityUtils; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RoomsService roomsService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RoomTimeService roomTimeService; | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/updateStatusById") | 
|---|
|  |  |  | @RequiresPermissions("business:rooms:update") | 
|---|
|  |  |  | public ApiResponse updateStatusById(@RequestBody Rooms rooms) { | 
|---|
|  |  |  | roomsService.updateStatusById(rooms); | 
|---|
|  |  |  | roomsService.updateStatusById(rooms,this.getLoginUser(null)); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | 
|---|
|  |  |  | return ApiResponse.success(roomsService.findList(rooms)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("获取会议室开门二维码") | 
|---|
|  |  |  | @GetMapping("/getQrCode") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "id", value = "会议室主键", required = true), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ApiResponse<String> getQrCode(@RequestParam Integer id) { | 
|---|
|  |  |  | LoginUserInfo user = getLoginUser(null); | 
|---|
|  |  |  | return ApiResponse.success("查询成功", roomsService.getQrCode(id,user.getId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("获取会议室开门二维码-图片流") | 
|---|
|  |  |  | @GetMapping("/getQrCodeImg") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "id", value = "会议室主键", required = true) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public void getQrCodeImg(@RequestParam Integer id,@RequestParam String token, HttpServletResponse response) throws  Exception { | 
|---|
|  |  |  | LoginUserInfo user = getLoginUser(null); | 
|---|
|  |  |  | response.setHeader("Cache-Control", "no-store, no-cache"); | 
|---|
|  |  |  | response.setContentType("image/jpeg"); | 
|---|
|  |  |  | String content =roomsService.getQrCode(id,user.getId()); | 
|---|
|  |  |  | QrCodeUtils.encode(content,null, response.getOutputStream(), true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("会议室列表") | 
|---|
|  |  |  | @GetMapping("/roomsList") | 
|---|
|  |  |  | public ApiResponse<List<RoomsResponse>> roomsList() { | 
|---|
|  |  |  | return ApiResponse.success("查询成功",roomsService.getRoomsList()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("会议室时间开放列表") | 
|---|
|  |  |  | @PostMapping("/getRoomUseTime") | 
|---|
|  |  |  | public ApiResponse<List<RoomTime>> getRoomUseTime(@RequestBody RoomTimeRequest roomTimeRequest) { | 
|---|
|  |  |  | return ApiResponse.success("查询成功",roomTimeService.getRoomUseTime(roomTimeRequest)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("我的会议室列表") | 
|---|
|  |  |  | @PostMapping("/myRoomsPage") | 
|---|
|  |  |  | public ApiResponse<IPage<RoomsResponse>> myRoomsPage(@RequestBody PageWrap<RoomsRequest> pageWrap) { | 
|---|
|  |  |  | LoginUserInfo user = getLoginUser(null); | 
|---|
|  |  |  | pageWrap.getModel().setUserId(user.getId()); | 
|---|
|  |  |  | IPage<RoomsResponse> page = roomsService.getRoomsPage(pageWrap); | 
|---|
|  |  |  | return ApiResponse.success("查询成功",page); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("会议室详情") | 
|---|
|  |  |  | @GetMapping("/getRoomDetail") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "roomId", value = "会议室主键", required = true), | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | public ApiResponse<RoomsResponse> getRoomDetail(@RequestParam Integer roomId) { | 
|---|
|  |  |  | return ApiResponse.success("查询成功",roomsService.getRoomDetail(roomId)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|