| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.waterrecord.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.controller.BaseController; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.waterrecord.pojo.WaterRecord; |
| | | import com.ruoyi.waterrecord.service.WaterRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author :yys |
| | | * @date : 2025/8/11 10:08 |
| | | */ |
| | | @RestController |
| | | @Api(tags = "ç¨æ°´ç®¡ç") |
| | | @RequestMapping("/waterRecord") |
| | | public class WaterRecordController extends BaseController { |
| | | |
| | | @Autowired |
| | | private WaterRecordService waterRecordService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Log(title = "ç¨æ°´ç®¡ç-å页æ¥è¯¢", businessType = BusinessType.OTHER) |
| | | public AjaxResult listPage(Page page, WaterRecord waterRecord){ |
| | | IPage<WaterRecord> listPage = waterRecordService.listPage(page, waterRecord); |
| | | return AjaxResult.success(listPage); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @Log(title = "ç¨æ°´ç®¡ç-æ°å¢", businessType = BusinessType.INSERT) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(@RequestBody WaterRecord waterRecord){ |
| | | boolean save = waterRecordService.save(waterRecord); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @Log(title = "ç¨æ°´ç®¡ç-ä¿®æ¹", businessType = BusinessType.UPDATE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult update(@RequestBody WaterRecord waterRecord){ |
| | | boolean update = waterRecordService.updateById(waterRecord); |
| | | return update ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Log(title = "ç¨æ°´ç®¡ç-å é¤", businessType = BusinessType.DELETE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult delete(@RequestBody List<Long> ids){ |
| | | if(CollectionUtils.isEmpty(ids)) return AjaxResult.error("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | boolean delete = waterRecordService.removeBatchByIds(ids); |
| | | return delete ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | /** |
| | | * 导å
¥ç¨æ°´ç®¡ç |
| | | */ |
| | | @Log(title = "导å
¥ç¨æ°´ç®¡ç", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | @ApiOperation("导å
¥ç¨æ°´ç®¡ç") |
| | | public AjaxResult importData(MultipartFile file) throws Exception { |
| | | return waterRecordService.importData(file); |
| | | } |
| | | |
| | | /** |
| | | * 导åºç¨æ°´ç®¡ç |
| | | */ |
| | | @Log(title = "导åºç¨æ°´ç®¡ç", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | @ApiOperation("导åºç¨æ°´ç®¡ç") |
| | | public void export(HttpServletResponse response) { |
| | | Page page = new Page(-1,-1); |
| | | WaterRecord waterRecord = new WaterRecord(); |
| | | IPage<WaterRecord> listPage = waterRecordService.listPage(page, waterRecord); |
| | | ExcelUtil<WaterRecord> util = new ExcelUtil<WaterRecord>(WaterRecord.class); |
| | | util.exportExcel(response, listPage.getRecords() , "ç¨æ°´ç®¡ç"); |
| | | } |
| | | |
| | | } |