测站采集项新增,修改,删除和查询接口调整,

监测断面删除接口开发调整
master
徐杰盟 2024-01-30 16:29:38 +08:00
parent 4c0d44d179
commit 35baafdfb2
4 changed files with 54 additions and 12 deletions

View File

@ -225,22 +225,22 @@ public class BasicDataController {
}
@Post(path ="/stcd/stch/insert", summary = "测站采集项新增")
@Post(path ="/stch/manage/insert", summary = "测站采集项新增")
public R<Boolean> insertStch(@RequestBody @Validated StStchB stStchB) {
return R.ok(stStchBService.insert(stStchB));
}
@Get(path ="/stcd/stch/del/{id}", summary = "测站采集项删除")
@Get(path ="/stch/manage/del/{id}", summary = "测站采集项删除")
public R<Boolean> delStch(@Schema(description="测站采集项id") @PathVariable("id") Integer id) {
return R.ok(stStchBService.removeById(id));
}
@Post(path ="/stcd/stch/update", summary = "测站采集项修改")
public R<Boolean> updateStch(@RequestBody @Validated StStchB bean) {
@Post(path ="/stch/manage/update", summary = "测站采集项修改")
public R<Boolean> updateStch(@RequestBody @Validated(Update.class) StStchB bean) {
return R.ok(stStchBService.update(bean));
}
@Post(path = "/stcd/stch/page", summary = "测站采集项分页查询")
@Post(path = "/stch/manage/page", summary = "测站采集项分页查询")
public R<IPage<StStchB>> PageStch(@RequestBody StStchBSo findDto) {
return R.ok(stStchBService.page(findDto));
}
@ -264,6 +264,12 @@ public class BasicDataController {
return R.ok(true);
}
@Get(path = "/monct/manage/delete/{crId}", summary = "删除监测断面接口")
public R<Boolean> deleteMonCr(@Validated @RequestBody Long crId) {
stMoncrService.delete(crId);
return R.ok(true);
}
@Post(path = "/monct/search/query", summary = "查询监测断面列表接口")
public R<Page<StMoncrB>> queryMonCrList(@Validated @RequestBody GeneralSearch search) {
return R.ok(stMoncrService.queryBySearch(search));

View File

@ -3,6 +3,7 @@ package com.gunshi.project.xyt.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gunshi.project.xyt.validate.markers.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
@ -35,6 +36,7 @@ public class StStchB implements Serializable {
@TableId(value = "ID", type = IdType.AUTO)
@Schema(description = "主键id")
@ExcelProperty("编号")
@NotNull(message = "断面ID不能为空", groups = {Update.class})
private Integer id;
/**
@ -136,7 +138,7 @@ public class StStchB implements Serializable {
* 0:, 1:
*/
@TableField(value = "DEL")
@Schema(description = "删除标记 0:未删除, 1: 删除")
@Schema(description = "删除标记 1:启用 0禁用")
private Integer del;

View File

@ -1,7 +1,9 @@
package com.gunshi.project.xyt.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.project.xyt.entity.basedata.CheckStringSearch;
import com.gunshi.project.xyt.entity.basedata.GeneralSearch;
@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.Objects;
/**
* @author Sun Lejun
@ -60,6 +63,25 @@ public class StMoncrService {
stMoncrBMapper.updateById(stMoncrB);
}
/**
*
* @param crId id
*/
public void delete(Long crId) {
LambdaQueryWrapper<StMoncrB> query = Wrappers.lambdaQuery();
query.eq(StMoncrB::getStatus, 1);
query.eq(StMoncrB::getCrId, crId);
StMoncrB obj = stMoncrBMapper.selectOne(query, false);
if (Objects.isNull(obj)) {
throw new IllegalArgumentException("未找到相关记录");
}
obj.setStatus(0);
stMoncrBMapper.updateById(obj);
}
public int getMaxSortOn(){
QueryWrapper<StMoncrB> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(StMoncrB.COL_STATUS, 1);

View File

@ -11,7 +11,6 @@ import com.gunshi.project.xyt.so.StStchBSo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.Objects;
@ -41,7 +40,7 @@ public class StStchBService extends BaseOrderDao<StStchBMapper, StStchB> {
*/
@Transactional
public boolean update(StStchB bean) {
if (Objects.isNull(baseMapper.selectById(bean.getId()))) {
if (Objects.isNull(this.selectById(bean.getId()))) {
throw new IllegalArgumentException("未找到相关记录");
}
@ -55,14 +54,15 @@ public class StStchBService extends BaseOrderDao<StStchBMapper, StStchB> {
* @return
*/
@Transactional
public boolean removeById(Serializable id) {
public boolean removeById(Integer id) {
StStchB obj = this.selectById(id);
StStchB obj = baseMapper.selectById(id);
if (Objects.isNull(obj)) {
throw new IllegalArgumentException("未找到相关记录");
}
obj.setDel(1);
obj.setDel(0);
return update(obj);
}
@ -81,9 +81,21 @@ public class StStchBService extends BaseOrderDao<StStchBMapper, StStchB> {
query.eq(StStchB::getStcd, stcd);
}
query.eq(StStchB::getDel, 0);
query.eq(StStchB::getDel, 1);
return super.page(so.getPageSo().toPage(), query);
}
/**
*
* @param id id
* @return
*/
private StStchB selectById(Integer id){
LambdaQueryWrapper<StStchB> query = Wrappers.lambdaQuery();
query.eq(StStchB::getDel, 1);
query.eq(StStchB::getId, id);
return super.getOne(query);
}
}