¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.device.pojo.DeviceBorrow; |
| | | import com.ruoyi.device.service.DeviceBorrowService; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | | * å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author æ±èéµ·éç½ç»ç§ææéå
¬å¸ |
| | | * @since 2024-09-21 10:53:51 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/deviceBorrow") |
| | | public class DeviceBorrowController { |
| | | |
| | | @Resource |
| | | private DeviceBorrowService deviceBorrowService; |
| | | |
| | | |
| | | //å页 |
| | | @GetMapping("/deviceBorrowPage") |
| | | public Result deviceBorrowPage(Page page, DeviceBorrow deviceBorrow) throws Exception { |
| | | return Result.success(deviceBorrowService.deviceBorrowPage(page, deviceBorrow)); |
| | | } |
| | | |
| | | //æ¥è¯¢ |
| | | @GetMapping("/getDeviceBorrow") |
| | | public Result getDeviceBorrow(Integer id) { |
| | | return Result.success(deviceBorrowService.getDeviceBorrow(id)); |
| | | } |
| | | |
| | | //æ°å¢ |
| | | @PostMapping("/saveDeviceBorrow") |
| | | public Result saveDeviceBorrow(@RequestBody DeviceBorrow deviceBorrow) { |
| | | return Result.success(deviceBorrowService.saveDeviceBorrow(deviceBorrow)); |
| | | } |
| | | |
| | | //å é¤ |
| | | @DeleteMapping("/deleteDeviceBorrow") |
| | | public Result deleteDeviceBorrow(Integer id) { |
| | | return Result.success(deviceBorrowService.removeById(id)); |
| | | } |
| | | |
| | | //å¯¼åº |
| | | @GetMapping("/deviceBorrowExport") |
| | | public Result deviceBorrowExport(@RequestParam("deviceId") Integer deviceId, HttpServletResponse response) throws Exception { |
| | | List<DeviceBorrow> deviceBorrows = deviceBorrowService.getDeviceBorrowBydeviceId(deviceId); |
| | | response.setHeader("requestType", "excel"); |
| | | response.setHeader("Access-Control-Expose-Headers", "requestType"); |
| | | // 设置åå
æ ¼æ ·å¼ |
| | | // ä¿åå°ç¬¬ä¸ä¸ªsheetä¸ |
| | | EasyExcel.write(response.getOutputStream()) |
| | | .head(DeviceBorrow.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // èªéåºå宽 |
| | | .sheet() |
| | | .doWrite(deviceBorrows); |
| | | return Result.success(); |
| | | } |
| | | |
| | | |
| | | } |