/* * Copyright 2019-2020 Zheng Jie * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package me.zhengjie.modules.conferenceRoom.rest; import me.zhengjie.annotation.Log; import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation; import me.zhengjie.modules.conferenceRoom.service.MeetingRoomReservationService; import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationQueryCriteria; import org.springframework.data.domain.Pageable; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; /** * @website https://eladmin.vip * @author wcd * @date 2023-02-09 **/ @RestController @RequiredArgsConstructor @Api(tags = "会议室预约管理") @RequestMapping("/api/meetingRoomReservation") public class MeetingRoomReservationController { private final MeetingRoomReservationService meetingRoomReservationService; @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") @PreAuthorize("@el.check('meetingRoomReservation:download')") public void exportMeetingRoomReservation(HttpServletResponse response, MeetingRoomReservationQueryCriteria criteria) throws IOException { meetingRoomReservationService.download(meetingRoomReservationService.queryAll(criteria), response); } @GetMapping @Log("查询会议室预约") @ApiOperation("查询会议室预约") @PreAuthorize("@el.check('meetingRoomReservation:list')") public ResponseEntity queryMeetingRoomReservation(MeetingRoomReservationQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(meetingRoomReservationService.queryAll(criteria,pageable),HttpStatus.OK); } @GetMapping(value = "/all") @Log("查询会议室预约") @ApiOperation("查询会议室预约") @PreAuthorize("@el.check('meetingRoomReservation:list')") public ResponseEntity queryMeetingRoomReservation(MeetingRoomReservationQueryCriteria criteria){ return new ResponseEntity<>(meetingRoomReservationService.queryAll(criteria),HttpStatus.OK); } @PostMapping @Log("新增会议室预约") @ApiOperation("新增会议室预约") @PreAuthorize("@el.check('meetingRoomReservation:add')") public ResponseEntity createMeetingRoomReservation(@Validated @RequestBody MeetingRoomReservation resources) throws Exception { return new ResponseEntity<>(meetingRoomReservationService.create(resources),HttpStatus.CREATED); } @PutMapping @Log("修改会议室预约") @ApiOperation("修改会议室预约") @PreAuthorize("@el.check('meetingRoomReservation:edit')") public ResponseEntity updateMeetingRoomReservation(@Validated @RequestBody MeetingRoomReservation resources) throws Exception { meetingRoomReservationService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @DeleteMapping @Log("删除会议室预约") @ApiOperation("删除会议室预约") @PreAuthorize("@el.check('meetingRoomReservation:del')") public ResponseEntity deleteMeetingRoomReservation(@RequestBody Long[] ids) { meetingRoomReservationService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } }