| | |
| | | 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.framework.web.domain.R; |
| | | import com.ruoyi.waterrecord.pojo.WaterRecord; |
| | | import com.ruoyi.waterrecord.service.WaterRecordService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import lombok.AllArgsConstructor; |
| | | 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 jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @date : 2025/8/11 10:08 |
| | | */ |
| | | @RestController |
| | | @Api(tags = "用水管理") |
| | | @Tag(name = "用水管理") |
| | | @RequestMapping("/waterRecord") |
| | | @AllArgsConstructor |
| | | public class WaterRecordController extends BaseController { |
| | | |
| | | @Autowired |
| | | private WaterRecordService waterRecordService; |
| | | |
| | | @GetMapping("/listPage") |
| | | @Log(title = "用水管理-分页查询", businessType = BusinessType.OTHER) |
| | | public AjaxResult listPage(Page page, WaterRecord waterRecord){ |
| | | public R<?> listPage(Page page, WaterRecord waterRecord){ |
| | | IPage<WaterRecord> listPage = waterRecordService.listPage(page, waterRecord); |
| | | return AjaxResult.success(listPage); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @Log(title = "用水管理-新增", businessType = BusinessType.INSERT) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(@RequestBody WaterRecord waterRecord){ |
| | | public R<?> add(@RequestBody WaterRecord waterRecord){ |
| | | boolean save = waterRecordService.save(waterRecord); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | return save ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @Log(title = "用水管理-修改", businessType = BusinessType.UPDATE) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult update(@RequestBody WaterRecord waterRecord){ |
| | | public R<?> update(@RequestBody WaterRecord waterRecord){ |
| | | boolean update = waterRecordService.updateById(waterRecord); |
| | | return update ? AjaxResult.success() : AjaxResult.error(); |
| | | return update ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | @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("请选择至少一条数据"); |
| | | public R<?> delete(@RequestBody List<Long> ids){ |
| | | if(CollectionUtils.isEmpty(ids)) return R.fail("请选择至少一条数据"); |
| | | boolean delete = waterRecordService.removeBatchByIds(ids); |
| | | return delete ? AjaxResult.success() : AjaxResult.error(); |
| | | return delete ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Log(title = "导入用水管理", businessType = BusinessType.IMPORT) |
| | | @PostMapping("/importData") |
| | | @ApiOperation("导入用水管理") |
| | | public AjaxResult importData(MultipartFile file) throws Exception { |
| | | @Operation(summary = "导入用水管理") |
| | | public R<?> importData(MultipartFile file) throws Exception { |
| | | return waterRecordService.importData(file); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Log(title = "导出用水管理", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | @ApiOperation("导出用水管理") |
| | | @Operation(summary = "导出用水管理") |
| | | 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, null , "用水管理"); |
| | | util.exportExcel(response, listPage.getRecords() , "用水管理"); |
| | | } |
| | | |
| | | } |