package com.ruoyi.safety.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.framework.aspectj.lang.annotation.Log; import com.ruoyi.framework.aspectj.lang.enums.BusinessType; import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.safety.pojo.SafetyWorkArea; import com.ruoyi.safety.service.SafetyWorkAreaService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; /** * 安环管理-作业区域接口。 */ @RestController @Api(tags = "安环管理-作业区域") @RequestMapping("/safety/workArea") public class SafetyWorkAreaController extends SafetyControllerSupport { @Autowired private SafetyWorkAreaService workAreaService; /** * 分页查询作业区域。 */ @Log(title = "安环管理-作业区域-分页查询", businessType = BusinessType.OTHER) @ApiOperation("分页查询作业区域") @GetMapping("/list") public AjaxResult list(Page page, SafetyWorkArea query, @RequestParam(value = "pageNum", required = false) Long pageNum, @RequestParam(value = "pageSize", required = false) Long pageSize) { return AjaxResult.success(workAreaService.queryPage(buildPage(page, pageNum, pageSize), query)); } /** * 新增作业区域。 */ @Log(title = "安环管理-作业区域-新增", businessType = BusinessType.INSERT) @ApiOperation("新增作业区域") @PostMapping("/add") public AjaxResult add(@RequestBody SafetyWorkArea workArea) { return toAjax(workAreaService.saveSafety(workArea)); } /** * 修改作业区域。 */ @Log(title = "安环管理-作业区域-修改", businessType = BusinessType.UPDATE) @ApiOperation("修改作业区域") @PutMapping("/update") public AjaxResult update(@RequestBody SafetyWorkArea workArea) { return toAjax(workAreaService.updateSafety(workArea)); } /** * 删除作业区域。 */ @Log(title = "安环管理-作业区域-删除", businessType = BusinessType.DELETE) @ApiOperation("删除作业区域") @DeleteMapping("/delete/{id}") public AjaxResult delete(@PathVariable Long id) { return toAjax(workAreaService.deleteSafetyById(id)); } /** * 查询作业区域详情。 */ @Log(title = "安环管理-作业区域-详情", businessType = BusinessType.OTHER) @ApiOperation("查询作业区域详情") @GetMapping("/detail/{id}") public AjaxResult detail(@PathVariable Long id) { return AjaxResult.success(workAreaService.getById(id)); } /** * 查询全部作业区域,用于下拉选择。 */ @Log(title = "安环管理-作业区域-全部查询", businessType = BusinessType.OTHER) @ApiOperation("查询全部作业区域") @GetMapping("/all") public AjaxResult all() { return AjaxResult.success(workAreaService.list(new QueryWrapper().orderByDesc("create_time"))); } }