修改代码,通过ResultDto返回mercid
时间: 2024-03-12 10:48:18 浏览: 14
可以修改 editScmBusinessRelationShip 方法以返回 mercid 值。具体地,可以将最后返回的 ResultDto 对象的 data 属性设置为 mercid,示例代码如下:
```java
@Override
public ResultDto<String> editScmBusinessRelationShip(ScmBusinessRelationshipEditRequest editRequest) {
if (LongUtil.isEmpty(editRequest.getId()) && exits(editRequest.getTenantId(), editRequest.getSupplierId())) {
return ResultDto.fail(ResponseStatusConstants.Code.DATA_EXISTS, "数据已存在");
}
if (LongUtil.isEmpty(editRequest.getId())) {
editRequest.setId(SnowFlake.getInstance().newId());
}
String rowKey = Long.toString(editRequest.getId());
if (conflictWithScm(editRequest.getTenantId(), editRequest.getSupplierId(), rowKey)) {
return ResultDto.fail(ResponseStatusConstants.Code.DATA_EXISTS, "数据已存在");
}
// 将生成或修改的商业编号复制给 mercid
String mercid = String.valueOf(editRequest.getId());
// 保存到大数据中
List<HbasePut> putList = new ArrayList<>();
putList.add(HbasePut.builder()
.tableName(SCM_HBASE_TABLE_NAME)
.rowKey(rowKey)
.cf(CF)
.data(JSONObject.parseObject(JSON.toJSONString(BeanConverter.INSTANCE.businessRelationshipToScmHbasePutItem(editRequest))))
.build());
HbasePutList hbasePutList = HbasePutList.builder()
.tableName(SCM_HBASE_TABLE_NAME)
.putList(putList)
.build();
bigdataUtil.update(hbasePutList);
// 返回商编
return ResultDto.ok(mercid);
}
```
需要注意的是,返回类型需要修改为 `ResultDto<String>`,并且在返回时调用 `ResultDto.ok(mercid)` 方法。