1.全部查询 @GetMapping("/list/all") public JSONResult listAll() { return cylinderAssemblyOfflineService.listAll(); }
public JSONResult listAll(){ List<CylinderAssemblyOfflineEntity> frockEntities = cylinderAssemblyOfflineMapper.selectList(null); return JSONResult.ok("查询成功").put("data", frockEntities); }
2.查询某一个字段
@GetMapping("/list/all") public JSONResult listAll() { return cylinderAssemblyOfflineService.listAll(); }
public JSONResult listAll(){ LambdaQueryWrapper<CylinderAssemblyOfflineEntity> wrapper = new LambdaQueryWrapper<>(); wrapper.select(CylinderAssemblyOfflineEntity::getEngineNumber); // 选择要查询的字段 List<Object> engineNumbers = cylinderAssemblyOfflineMapper.selectObjs(wrapper); // 使用 HashSet 去除重复项 Set<Object> uniqueEngineNumbers = new HashSet<>(engineNumbers); return JSONResult.ok().put("data", uniqueEngineNumbers); }
3.条件删除
@PostMapping("/delete") public JSONResult saveCylinderdelete(@RequestBody CylinderAssemblyOfflineEntity param) { return cylinderAssemblyOfflineService.delete(param); }
public JSONResult delete(CylinderAssemblyOfflineEntity param) { // 构造删除条件 LambdaQueryWrapper<CylinderAssemblyOfflineEntity> wrapper = new LambdaQueryWrapper<>(); wrapper.eq(CylinderAssemblyOfflineEntity::getEngineNumber, param.getEngineNumber()); // 调用 Mapper 的删除方法 int result = cylinderAssemblyOfflineMapper.delete(wrapper); if (result > 0) { return JSONResult.ok("删除成功"); } else { return JSONResult.error("删除失败"); } }
4.前端vue调用get方法拿到所有数据
getListAll(){ requestGet('/cylinder/list/all').then(response => { this.Listfadongjihao = response.data console.log(this.Listfadongjihao) }).catch(error => { alert(error) }) },
5.删除
request('/control/plan/one/delete', { "planNo": row.planNo }).then(() => { this.upDataTable() }).catch((err) => { alert(err.msg) })