2024-07-08 17:47:02 +08:00
|
|
|
package com.gunshi.project.xyt.controller;
|
|
|
|
|
|
2024-07-17 17:38:06 +08:00
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.core.result.R;
|
2024-07-17 17:38:06 +08:00
|
|
|
import com.gunshi.project.xyt.entity.so.GeneralDataPage;
|
2024-07-08 17:47:02 +08:00
|
|
|
import com.gunshi.project.xyt.model.AttGateValve;
|
|
|
|
|
import com.gunshi.project.xyt.service.AttGateValveService;
|
|
|
|
|
import com.gunshi.project.xyt.validate.markers.Insert;
|
|
|
|
|
import com.gunshi.project.xyt.validate.markers.Update;
|
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.List;
|
2024-07-17 17:38:06 +08:00
|
|
|
import java.util.Objects;
|
|
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
/**
|
|
|
|
|
* 描述: 闸阀信息表
|
|
|
|
|
* author: xusan
|
|
|
|
|
* date: 2024-07-08 17:40:37
|
|
|
|
|
*/
|
|
|
|
|
@Tag(name = "闸阀信息表")
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping(value="/attGateValve")
|
|
|
|
|
public class AttGateValveController {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AttGateValveService service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "新增")
|
|
|
|
|
@PostMapping("/insert")
|
|
|
|
|
public R<AttGateValve> insert(@Validated(Insert.class) @RequestBody AttGateValve dto) {
|
2024-07-30 17:52:25 +08:00
|
|
|
if (Objects.nonNull(service.getById(dto.getValveCode()))){
|
|
|
|
|
throw new IllegalArgumentException("当前闸阀编码已存在");
|
|
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
boolean result = service.save(dto);
|
|
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "修改")
|
|
|
|
|
@PostMapping("/update")
|
|
|
|
|
public R<AttGateValve> update(@Validated(Update.class) @RequestBody AttGateValve dto) {
|
2024-07-17 17:38:06 +08:00
|
|
|
if (Objects.isNull(service.getById(dto.getValveCode()))) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
2024-07-17 17:38:06 +08:00
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
boolean result = service.updateById(dto);
|
|
|
|
|
return R.ok(result ? dto : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "删除")
|
|
|
|
|
@GetMapping("/del/{id}")
|
|
|
|
|
public R<Boolean> del(@Schema(name = "id") @PathVariable("id") Serializable id) {
|
2024-07-17 17:38:06 +08:00
|
|
|
if (Objects.isNull(service.getById(id))) {
|
2024-07-22 17:11:26 +08:00
|
|
|
throw new IllegalArgumentException("当前数据不存在");
|
2024-07-17 17:38:06 +08:00
|
|
|
}
|
2024-07-08 17:47:02 +08:00
|
|
|
return R.ok(service.removeById(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "列表")
|
|
|
|
|
@PostMapping("/list")
|
|
|
|
|
public R<List<AttGateValve>> list() {
|
|
|
|
|
return R.ok(service.lambdaQuery().list());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "分页")
|
|
|
|
|
@PostMapping("/page")
|
2024-07-17 17:38:06 +08:00
|
|
|
public R<Page<AttGateValve>> page(@RequestBody @Validated GeneralDataPage page) {
|
|
|
|
|
LambdaQueryChainWrapper<AttGateValve> query = service.lambdaQuery();
|
|
|
|
|
if (ObjectUtils.isNotNull(page.getCode())){
|
|
|
|
|
query.like(AttGateValve::getValveCode, page.getCode());
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtils.isNotNull(page.getName())){
|
|
|
|
|
query.like(AttGateValve::getValveName, page.getName());
|
|
|
|
|
}
|
|
|
|
|
return R.ok(service.page(page.getPageSo().toPage(),query));
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|
|
|
|
|
|
2024-07-23 09:48:51 +08:00
|
|
|
@Operation(summary = "详情")
|
|
|
|
|
@GetMapping("/detail")
|
|
|
|
|
public R<AttGateValve> detail(@Schema(name = "valveCode",description = "闸阀编码") @RequestParam("valveCode") String valveCode) {
|
|
|
|
|
return R.ok(service.getById(valveCode));
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-08 17:47:02 +08:00
|
|
|
}
|