gasWellWatch/src/main/java/com/isu/gaswellwatch/controller/GasWellController.java

84 lines
2.7 KiB
Java

package com.isu.gaswellwatch.controller;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isu.gaswellwatch.service.GasWellService;
import com.isu.gaswellwatch.entity.Response;
import com.isu.gaswellwatch.enums.LogType;
import com.isu.gaswellwatch.dto.GasWellCreateRequest;
import com.isu.gaswellwatch.dto.GasWellEditRequest;
import com.isu.gaswellwatch.vo.GasWellVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isu.gaswellwatch.annotation.OperationLog;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;
/**
* 气井管理
*
* @author scwsl
* @date 2024-11-17
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/gasWell")
public class GasWellController {
private final GasWellService gasWellService;
/**
* 查询气井列表
*/
@GetMapping(value = "/page")
public Response<Page<GasWellVO>> page(@RequestParam(defaultValue = "1") Integer currentPage,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(required = false) String name,
@RequestParam Long blockId) {
return Response.succeed(gasWellService.pageForQuery(currentPage, pageSize, name,blockId));
}
/**
* 获取气井详细信息
*/
@GetMapping(value = "/getGasWell")
public Response<GasWellVO> getGasWell(@RequestParam Long id) {
return Response.succeed(gasWellService.selectGasWellById(id));
}
/**
* 新增气井
*/
@PostMapping(value = "/add")
@OperationLog(description = "新增气井", type = LogType.ADD)
public Response<String> add(@RequestBody @Valid GasWellCreateRequest gasWellCreateRequest) {
gasWellService.insertGasWell(gasWellCreateRequest);
return Response.succeed();
}
/**
* 修改气井
*/
@PostMapping("/edit")
@OperationLog(description = "修改气井", type = LogType.UPDATE)
public Response<String> edit(@RequestBody GasWellEditRequest gasWellEditRequest) {
gasWellService.updateGasWell(gasWellEditRequest);
return Response.succeed();
}
/**
* 删除气井
*/
@GetMapping("/delete")
@OperationLog(description = "删除气井", type = LogType.DELETE)
public Response<String> delete(@RequestParam Long id) {
gasWellService.deleteGasWellById(id);
return Response.succeed();
}
}