提交 7429b1c3 编写于 作者: sq3536's avatar sq3536

提交,规范地址栏

上级 07ebbb1f
...@@ -177,7 +177,14 @@ public class DOModel implements Serializable { ...@@ -177,7 +177,14 @@ public class DOModel implements Serializable {
if (keyMap.size()==1) if (keyMap.size()==1)
{ {
PojoSchema keyProperty=this.getKeyProperty(); PojoSchema keyProperty=this.getKeyProperty();
Object key=data.get(this.getKeyPropertyName()); String keyPropertyName=keyProperty.getName().toLowerCase();
Object key=data.get(keyPropertyName);
if(ObjectUtils.isEmpty(key))
{
key=data.getKey();
if(!ObjectUtils.isEmpty(key))
data.set(keyPropertyName, key);
}
if(ObjectUtils.isEmpty(key)) if(ObjectUtils.isEmpty(key))
{ {
if(genKeyWhenNotExists) if(genKeyWhenNotExists)
...@@ -186,7 +193,7 @@ public class DOModel implements Serializable { ...@@ -186,7 +193,7 @@ public class DOModel implements Serializable {
key=IdWorker.getId(); key=IdWorker.getId();
else else
key=IdWorker.get32UUID(); key=IdWorker.get32UUID();
data.set(this.getKeyPropertyName(),key); data.set(keyPropertyName,key);
} }
else else
return null; return null;
......
...@@ -116,4 +116,9 @@ public class BaseData extends DataObj ...@@ -116,4 +116,9 @@ public class BaseData extends DataObj
{ {
return this.set("_key",key); return this.set("_key",key);
} }
public Serializable getKey()
{
return getSerializableValue("_key");
}
} }
...@@ -22,24 +22,11 @@ public class RequestData<T> extends BaseData ...@@ -22,24 +22,11 @@ public class RequestData<T> extends BaseData
public RequestData setKey(Object key) public RequestData setKey(Object key)
{ {
this.key=key; super.setKey(key);
return this; return this;
}
public Serializable getKey()
{
Object key=this.key;
if(key==null)
key=this.get("key");
if(key!=null)
return (Serializable)key;
else
return null;
} }
private Object key;
private String system; private String system;
private String scope; private String scope;
private String entity; private String entity;
......
...@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.FilterData; ...@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.FilterData;
import cn.ibizlab.core.data.dto.RequestData; import cn.ibizlab.core.data.dto.RequestData;
import cn.ibizlab.core.data.dto.ResponseData; import cn.ibizlab.core.data.dto.ResponseData;
import cn.ibizlab.core.data.service.IDataService; import cn.ibizlab.core.data.service.IDataService;
import cn.ibizlab.util.errors.BadRequestAlertException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -13,6 +14,7 @@ import org.springframework.data.domain.Page; ...@@ -13,6 +14,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -27,17 +29,35 @@ public class DataResource ...@@ -27,17 +29,35 @@ public class DataResource
@Autowired @Autowired
public IDataService dataService; public IDataService dataService;
@ApiOperation(value = "保存数据", tags = {"数据" }, notes = "保存数据") @ApiOperation(value = "callMethod数据", tags = {"数据" }, notes = "callMethod数据")
@RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/{method}","/ibiz-repo/{system}/{entity}/{method}"}) @RequestMapping(method = {RequestMethod.POST,RequestMethod.GET}, value = {"/ibiz-repository/{system}/{scope}/{entity}/{method}","/ibiz-repo/{system}/{entity}/{method}",
"/ibiz-repository/{system}/{scope}/{entity}/{key}/{method}","/ibiz-repo/{system}/{entity}/{key}/{method}"})
public ResponseEntity call(@PathVariable(name = "system",required = true) String system, public ResponseEntity call(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource, @RequestParam(name = "datasource",required = false) String datasource,
@PathVariable(name = "method",required = true) String method, @PathVariable(name = "method",required = true) String method,
@RequestBody RequestData requestData) { @PathVariable(name = "key",required = false) String key,@RequestBody(required = false) RequestData requestData) {
ResponseData responseData=dataService.call(system,scope,entity,datasource,method,requestData); if(requestData==null)
{
if(StringUtils.isEmpty(key))
throw new BadRequestAlertException("未找到要检查的键值信息",entity,null);
requestData=new RequestData();
}
ResponseData responseData=dataService.call(system,scope,entity,datasource,method,requestData.setKey(key));
return ResponseEntity.status(HttpStatus.OK).body(responseData.getBody()); return ResponseEntity.status(HttpStatus.OK).body(responseData.getBody());
} }
@ApiOperation(value = "批量callMethod数据", tags = {"数据" }, notes = "批量callMethod数据")
@RequestMapping(method = {RequestMethod.POST,RequestMethod.GET}, value = {"/ibiz-repository/{system}/{scope}/{entity}/{method}batch","/ibiz-repo/{system}/{entity}/{method}batch"})
public ResponseEntity callBatch(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource,
@PathVariable(name = "method",required = true) String method,@RequestBody List<RequestData> requestDatas) {
if(requestDatas!=null)
requestDatas.forEach(requestData ->dataService.call(system,scope,entity,datasource,method,requestData) );
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "新建数据", tags = {"数据" }, notes = "新建数据") @ApiOperation(value = "新建数据", tags = {"数据" }, notes = "新建数据")
...@@ -69,25 +89,39 @@ public class DataResource ...@@ -69,25 +89,39 @@ public class DataResource
} }
@ApiOperation(value = "获取数据", tags = {"数据" }, notes = "获取数据") @ApiOperation(value = "获取数据", tags = {"数据" }, notes = "获取数据")
@RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/get","/ibiz-repo/{system}/{entity}/get"}) @RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/get","/ibiz-repo/{system}/{entity}/get",
"/ibiz-repository/{system}/{scope}/{entity}/{key}/get","/ibiz-repo/{system}/{entity}/{key}/get"})
public ResponseEntity<BaseData> get(@PathVariable(name = "system",required = true) String system, public ResponseEntity<BaseData> get(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource, @Validated @RequestBody BaseData baseData) { @RequestParam(name = "datasource",required = false) String datasource,
return ResponseEntity.status(HttpStatus.OK).body(dataService.getByMap(system,scope,entity,datasource,baseData)); @PathVariable(name = "key",required = false) String key,@Validated @RequestBody BaseData baseData) {
return ResponseEntity.status(HttpStatus.OK).body(dataService.getByMap(system,scope,entity,datasource,baseData.setKey(key)));
} }
@ApiOperation(value = "删除数据", tags = {"数据" }, notes = "删除数据") @ApiOperation(value = "删除数据", tags = {"数据" }, notes = "删除数据")
@RequestMapping(method = RequestMethod.DELETE, value = {"/ibiz-repository/{system}/{scope}/{entity}/{key}","/ibiz-repo/{system}/{entity}/{key}"}) @RequestMapping(method = RequestMethod.DELETE, value = {"/ibiz-repository/{system}/{scope}/{entity}/{key}","/ibiz-repo/{system}/{entity}/{key}",
public ResponseEntity<Boolean> remove(@PathVariable(name = "system",required = true) String system,@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,@RequestParam(name = "datasource",required = false) String datasource, @PathVariable(name = "key",required = true) String key) { "/ibiz-repository/{system}/{scope}/{entity}","/ibiz-repo/{system}/{entity}"})
return ResponseEntity.status(HttpStatus.OK).body(dataService.remove(system,scope,entity,datasource,key)); public ResponseEntity<Boolean> remove(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource,
@PathVariable(name = "key",required = false) String key,@RequestBody(required = false) BaseData baseData) {
if(baseData==null)
{
if(StringUtils.isEmpty(key))
throw new BadRequestAlertException("未找到要检查的键值信息",entity,null);
baseData=new BaseData();
}
return ResponseEntity.status(HttpStatus.OK).body(dataService.removeByMap(system,scope,entity,datasource,baseData.setKey(key)));
} }
@ApiOperation(value = "删除数据", tags = {"数据" }, notes = "删除数据") @ApiOperation(value = "删除数据", tags = {"数据" }, notes = "删除数据")
@RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/remove","/ibiz-repo/{system}/{entity}/remove"}) @RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/remove","/ibiz-repo/{system}/{entity}/remove",
public ResponseEntity<Boolean> remove(@PathVariable(name = "system",required = true) String system, "/ibiz-repository/{system}/{scope}/{entity}/{key}/remove","/ibiz-repo/{system}/{entity}/{key}/remove"})
public ResponseEntity<Boolean> remove2(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource, @Validated @RequestBody BaseData baseData) { @RequestParam(name = "datasource",required = false) String datasource,
return ResponseEntity.status(HttpStatus.OK).body(dataService.removeByMap(system,scope,entity,datasource,baseData)); @PathVariable(name = "key",required = false) String key,@Validated @RequestBody BaseData baseData) {
return ResponseEntity.status(HttpStatus.OK).body(dataService.removeByMap(system,scope,entity,datasource,baseData.setKey(key)));
} }
@ApiOperation(value = "批量删除数据", tags = {"数据" }, notes = "批量删除数据") @ApiOperation(value = "批量删除数据", tags = {"数据" }, notes = "批量删除数据")
...@@ -120,11 +154,13 @@ public class DataResource ...@@ -120,11 +154,13 @@ public class DataResource
} }
@ApiOperation(value = "更新数据", tags = {"数据" }, notes = "更新数据") @ApiOperation(value = "更新数据", tags = {"数据" }, notes = "更新数据")
@RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/update","/ibiz-repo/{system}/{entity}/update"}) @RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/update","/ibiz-repo/{system}/{entity}/update",
public ResponseEntity<BaseData> update(@PathVariable(name = "system",required = true) String system, "/ibiz-repository/{system}/{scope}/{entity}/{key}/update","/ibiz-repo/{system}/{entity}/{key}/update"})
public ResponseEntity<BaseData> update2(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource, @RequestBody BaseData baseData) { @RequestParam(name = "datasource",required = false) String datasource,
dataService.update(system,scope,entity,datasource,baseData); @PathVariable(name = "key",required = false) String key, @RequestBody BaseData baseData) {
dataService.update(system,scope,entity,datasource,baseData.setKey(key));
return ResponseEntity.status(HttpStatus.OK).body(baseData); return ResponseEntity.status(HttpStatus.OK).body(baseData);
} }
...@@ -147,28 +183,41 @@ public class DataResource ...@@ -147,28 +183,41 @@ public class DataResource
} }
@ApiOperation(value = "检查数据", tags = {"数据" }, notes = "检查数据") @ApiOperation(value = "检查数据", tags = {"数据" }, notes = "检查数据")
@RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/checkkey","/ibiz-repo/{system}/{entity}/checkkey"}) @RequestMapping(method = {RequestMethod.GET,RequestMethod.POST}, value = {"/ibiz-repository/{system}/{scope}/{entity}/checkkey","/ibiz-repo/{system}/{entity}/checkkey",
"/ibiz-repository/{system}/{scope}/{entity}/{key}/checkkey","/ibiz-repo/{system}/{entity}/{key}/checkkey"})
public ResponseEntity<Boolean> checkKey(@PathVariable(name = "system",required = true) String system, public ResponseEntity<Boolean> checkKey(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource, @RequestBody BaseData baseData) { @RequestParam(name = "datasource",required = false) String datasource,
return ResponseEntity.status(HttpStatus.OK).body(dataService.checkKey(system,scope,entity,datasource,baseData)); @PathVariable(name = "key",required = false) String key,@RequestBody(required = false) BaseData baseData) {
if(baseData==null)
{
if(StringUtils.isEmpty(key))
throw new BadRequestAlertException("未找到要检查的键值信息",entity,null);
baseData=new BaseData();
}
return ResponseEntity.status(HttpStatus.OK).body(dataService.checkKey(system,scope,entity,datasource,baseData.setKey(key)));
} }
@ApiOperation(value = "获取数据草稿", tags = {"数据" }, notes = "获取数据草稿") @ApiOperation(value = "获取数据草稿", tags = {"数据" }, notes = "获取数据草稿")
@RequestMapping(method = {RequestMethod.GET,RequestMethod.POST}, value = {"/ibiz-repository/{system}/{scope}/{entity}/getdraft","/ibiz-repo/{system}/{entity}/getdraft"}) @RequestMapping(method = {RequestMethod.GET,RequestMethod.POST}, value = {"/ibiz-repository/{system}/{scope}/{entity}/getdraft","/ibiz-repo/{system}/{entity}/getdraft",
"/ibiz-repository/{system}/{scope}/{entity}/{key}/getdraft","/ibiz-repo/{system}/{entity}/{key}/getdraft"})
public ResponseEntity<BaseData> getDraft(@PathVariable(name = "system",required = true) String system, public ResponseEntity<BaseData> getDraft(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource, @RequestBody(required = false) BaseData baseData) { @RequestParam(name = "datasource",required = false) String datasource,
dataService.getDraft(system,scope,entity,datasource,baseData); @PathVariable(name = "key",required = false) String key, @RequestBody(required = false) BaseData baseData) {
return ResponseEntity.status(HttpStatus.OK).body(baseData); if(baseData==null)baseData=new BaseData();
return ResponseEntity.status(HttpStatus.OK).body(dataService.getDraft(system,scope,entity,datasource,baseData.setKey(key)));
} }
@ApiOperation(value = "保存数据", tags = {"数据" }, notes = "保存数据") @ApiOperation(value = "保存数据", tags = {"数据" }, notes = "保存数据")
@RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/save","/ibiz-repo/{system}/{entity}/save"}) @RequestMapping(method = RequestMethod.POST, value = {"/ibiz-repository/{system}/{scope}/{entity}/save","/ibiz-repo/{system}/{entity}/save",
"/ibiz-repository/{system}/{scope}/{entity}/{key}/save","/ibiz-repo/{system}/{entity}/{key}/save"})
public ResponseEntity<BaseData> save(@PathVariable(name = "system",required = true) String system, public ResponseEntity<BaseData> save(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@RequestParam(name = "datasource",required = false) String datasource,@RequestBody BaseData baseData) { @RequestParam(name = "datasource",required = false) String datasource,
dataService.save(system,scope,entity,datasource,baseData); @PathVariable(name = "key",required = false) String key, @RequestBody BaseData baseData) {
dataService.save(system,scope,entity,datasource,baseData.setKey(key));
return ResponseEntity.status(HttpStatus.OK).body(baseData); return ResponseEntity.status(HttpStatus.OK).body(baseData);
} }
...@@ -185,7 +234,7 @@ public class DataResource ...@@ -185,7 +234,7 @@ public class DataResource
@RequestMapping(method= RequestMethod.GET , value={"/ibiz-repository/{system}/{scope}/{entity}/fetch{dataset}","/ibiz-repo/{system}/{entity}/fetch{dataset}"}) @RequestMapping(method= RequestMethod.GET , value={"/ibiz-repository/{system}/{scope}/{entity}/fetch{dataset}","/ibiz-repo/{system}/{entity}/fetch{dataset}"})
public ResponseEntity<List<BaseData>> fetch(@PathVariable(name = "system",required = true) String system, public ResponseEntity<List<BaseData>> fetch(@PathVariable(name = "system",required = true) String system,
@PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity, @PathVariable(name = "scope",required = false) String scope,@PathVariable(name = "entity",required = true) String entity,
@PathVariable(name = "dataset",required = true) String dataset, @RequestParam(name = "datasource",required = false) String datasource,@PathVariable(name = "dataset",required = true) String dataset,
FilterData context) { FilterData context) {
Page<BaseData> baseDatas = dataService.fetch(system,scope,entity,context.getDataSource(),dataset,context,context.getPageable()) ; Page<BaseData> baseDatas = dataService.fetch(system,scope,entity,context.getDataSource(),dataset,context,context.getPageable()) ;
List<BaseData> list = baseDatas.getContent(); List<BaseData> list = baseDatas.getContent();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册