| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | |
| | | @Log(title = "用电时段-新增", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody EnergyPeriod energyPeriod) { |
| | | boolean save = energyPeriodService.save(energyPeriod); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | | @PostMapping("/addBatch") |
| | | @ApiOperation("用电时段-批量新增") |
| | | @Log(title = "用电时段-批量新增", businessType = BusinessType.INSERT) |
| | | public AjaxResult addBatch(@RequestBody List<EnergyPeriod> energyPeriods) { |
| | | boolean save = energyPeriodService.saveBatch(energyPeriods); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | } |
| | | |
| | |
| | | @PostMapping("/export") |
| | | @ApiOperation("导出用电时段") |
| | | public void export(HttpServletResponse response) { |
| | | Page page = new Page(-1,-1); |
| | | EnergyPeriod energyPeriod = new EnergyPeriod(); |
| | | IPage<EnergyPeriod> listPage = energyPeriodService.listPage(page, energyPeriod); |
| | | ExcelUtil<EnergyPeriod> util = new ExcelUtil<EnergyPeriod>(EnergyPeriod.class); |
| | | util.exportExcel(response, null , "用电时段数据"); |
| | | util.exportExcel(response, listPage.getRecords() , "用电时段数据"); |
| | | } |
| | | |
| | | } |