| | |
| | | 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 io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | |
| | | @GetMapping("/listPage") |
| | | @Operation(summary = "用电时段-分页查询") |
| | | @Log(title = "用电时段-分页查询", businessType = BusinessType.OTHER) |
| | | public AjaxResult listPage(Page page, EnergyPeriod energyPeriod) { |
| | | public R<?> listPage(Page page, EnergyPeriod energyPeriod) { |
| | | IPage<EnergyPeriod> listPage = energyPeriodService.listPage(page, energyPeriod); |
| | | return AjaxResult.success(listPage); |
| | | return R.ok(listPage); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @Operation(summary = "用电时段-新增") |
| | | @Log(title = "用电时段-新增", businessType = BusinessType.INSERT) |
| | | public AjaxResult add(@RequestBody EnergyPeriod energyPeriod) { |
| | | public R<?> add(@RequestBody EnergyPeriod energyPeriod) { |
| | | boolean save = energyPeriodService.save(energyPeriod); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | return save ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | @PostMapping("/addBatch") |
| | | @Operation(summary = "用电时段-批量新增") |
| | | @Log(title = "用电时段-批量新增", businessType = BusinessType.INSERT) |
| | | public AjaxResult addBatch(@RequestBody List<EnergyPeriod> energyPeriods) { |
| | | public R<?> addBatch(@RequestBody List<EnergyPeriod> energyPeriods) { |
| | | boolean save = energyPeriodService.saveBatch(energyPeriods); |
| | | return save ? AjaxResult.success() : AjaxResult.error(); |
| | | return save ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | @PostMapping("/update") |
| | | @Operation(summary = "用电时段-修改") |
| | | @Log(title = "用电时段-修改", businessType = BusinessType.UPDATE) |
| | | public AjaxResult update(@RequestBody EnergyPeriod energyPeriod) { |
| | | public R<?> update(@RequestBody EnergyPeriod energyPeriod) { |
| | | boolean update = energyPeriodService.updateById(energyPeriod); |
| | | return update ? AjaxResult.success() : AjaxResult.error(); |
| | | return update ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "用电时段-删除") |
| | | @Log(title = "用电时段-删除", businessType = BusinessType.DELETE) |
| | | 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 remove = energyPeriodService.removeBatchByIds(ids); |
| | | return remove ? AjaxResult.success() : AjaxResult.error("删除失败"); |
| | | return remove ? R.ok() : R.fail("删除失败"); |
| | | } |
| | | |
| | | |