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

basePath

上级 b7fdef29
......@@ -82,48 +82,64 @@ public class ApiMethodModel extends BaseModel {
return strName;
}
private String requestPath;
public String getRequestPath() {
String path = "";
if (!CollectionUtils.isEmpty(parentApiEntities)) {
for (ApiEntityRSModel apiRs : parentApiEntities) {
String strMajorEntityPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiRs.getMajorEntityCodeName()).toLowerCase());
path = String.format("/%s/{%s}", strMajorEntityPlurlize, StringAdvUtils.camelcase(apiRs.getParentIdFieldCodeName())) + path;
if(requestPath==null)
{
String path = "";
if (!CollectionUtils.isEmpty(parentApiEntities)) {
for (ApiEntityRSModel apiRs : parentApiEntities) {
String strMajorEntityPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiRs.getMajorEntityCodeName()).toLowerCase());
path = String.format("/%s/{%s}", strMajorEntityPlurlize, StringAdvUtils.camelcase(apiRs.getParentIdFieldCodeName())) + path;
}
}
}
//主键
String strPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiEntity.getCodeName()).toLowerCase());
if (getPSDEServiceAPIMethod().isNeedResourceKey()&&(!"save".equalsIgnoreCase(name))) {
path = path + String.format("/%s/{%s}", strPlurlize, StringAdvUtils.camelcase(apiEntity.getEntity().getKeyField().getCodeName()));
} else {
path = path + String.format("/%s", strPlurlize);
}
//主键
String strPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiEntity.getCodeName()).toLowerCase());
if (getPSDEServiceAPIMethod().isNeedResourceKey()&&(!"save".equalsIgnoreCase(name))) {
path = path + String.format("/%s/{%s}", strPlurlize, StringAdvUtils.camelcase(apiEntity.getEntity().getKeyField().getCodeName()));
} else {
path = path + String.format("/%s", strPlurlize);
}
//方法名
if (!ArrayUtils.contains(ignoreMethodNames, this.getName().toUpperCase())) {
path = path + String.format("/%s", this.getName().toLowerCase());
//方法名
if (!ArrayUtils.contains(ignoreMethodNames, this.getName().toUpperCase())) {
path = path + String.format("/%s", this.getName().toLowerCase());
}
requestPath=path;
}
return requestPath;
}
return path;
public String getRequestPath2() {
if(!ObjectUtils.isEmpty(this.getRequestPath()))
return requestPath.substring(1);
return "";
}
private List pathVariables;
public List getPathVariables() {
List pathVariables = new ArrayList();
if (!CollectionUtils.isEmpty(parentApiEntities)) {
for (ApiEntityRSModel apiRs : parentApiEntities) {
String strMajorEntityPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiRs.getMajorEntityCodeName()).toLowerCase());
if(pathVariables==null)
{
pathVariables = new ArrayList();
if (!CollectionUtils.isEmpty(parentApiEntities)) {
for (ApiEntityRSModel apiRs : parentApiEntities) {
String strMajorEntityPlurlize = Inflector.getInstance().pluralize(StringAdvUtils.camelcase(apiRs.getMajorEntityCodeName()).toLowerCase());
JSONObject pathVariable = new JSONObject();
pathVariable.put("name", apiRs.getParentIdFieldCodeName());
pathVariable.put("type", PropType.findType(apiRs.getParentIdFieldType()));
pathVariables.add(0, pathVariable);
}
}
if (getPSDEServiceAPIMethod().isNeedResourceKey()&&(!"save".equalsIgnoreCase(name))) {
JSONObject pathVariable = new JSONObject();
pathVariable.put("name", apiRs.getParentIdFieldCodeName());
pathVariable.put("type", PropType.findType(apiRs.getParentIdFieldType()));
pathVariables.add(0, pathVariable);
pathVariable.put("name", apiEntity.getEntity().getKeyField().getCodeName());
pathVariable.put("type", apiEntity.getEntity().getKeyField().getType());
pathVariables.add(pathVariable);
}
}
if (getPSDEServiceAPIMethod().isNeedResourceKey()&&(!"save".equalsIgnoreCase(name))) {
JSONObject pathVariable = new JSONObject();
pathVariable.put("name", apiEntity.getEntity().getKeyField().getCodeName());
pathVariable.put("type", apiEntity.getEntity().getKeyField().getType());
pathVariables.add(pathVariable);
}
return pathVariables;
}
......
......@@ -36,6 +36,10 @@ public class ApiModel extends BaseModel {
}
public String getBasePath()
{
return "${ibiz.rest.basePath."+this.codeName.toLowerCase()+":/"+this.codeName.toLowerCase()+"/}";
}
private SystemModel system;
......
......@@ -98,6 +98,11 @@ public class BootSecurityConfig extends WebSecurityConfigurerAdapter {
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.png",
"/**/*.ttf",
"/**/*.woff",
"/**/*.eot",
"/**/*.woff2",
"/**/*.ico",
"/**/assets/**",
"/**/css/**",
......
......@@ -38,7 +38,7 @@ import cn.ibizlab.util.annotation.VersionCheck;
@Slf4j
@Api(tags = {"{{apiEntity.apiName}}" })
@RestController("{{lowerCase apiEntity.api.codeName}}-{{lowerCase apiEntity.codeName}}")
@RequestMapping("/{{lowerCase apiEntity.api.codeName}}")
@RequestMapping("{{apiEntity.api.basePath}}")
public class {{apiEntity.codeName}}Resource {
@Autowired
......@@ -66,7 +66,7 @@ public class {{apiEntity.codeName}}Resource {
{{/if}}
{{/eq}}
{{/eq}}
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath}}")
@RequestMapping(method = RequestMethod.{{requestMethod}}, value = "{{requestPath2}}")
public ResponseEntity<{{outParam}}> {{camelCase name}}{{#each pathVariables}}{{#if @first}}By{{else}}And{{/if}}{{pascalCase name}}{{/each}}
({{#each pathVariables}}{{#unless @first}}, {{/unless}}@PathVariable("{{camelCase name}}") {{type.java}} {{camelCase name}}{{/each}}{{#if body}}{{#if pathVariables}}, {{/if}}{{#neq requestMethod 'GET'}}@Validated @RequestBody {{/neq}}{{body}}{{/if}}) {
{{!行为}}
......@@ -121,7 +121,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Create-all')")
@ApiOperation(value = "批量新建{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量新建{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/batch")
@RequestMapping(method = RequestMethod.POST, value = "{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
{{camelCase apiEntity.entity.codeName}}Service.createBatch({{camelCase apiEntity.defaultDto.codeName}}Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
......@@ -129,7 +129,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Update-all')")
@ApiOperation(value = "批量更新{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量更新{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.PUT, value = "/{{pluralize apiEntity.codeName}}/batch")
@RequestMapping(method = RequestMethod.PUT, value = "{{pluralize apiEntity.codeName}}/batch")
public ResponseEntity<Boolean> updateBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
{{camelCase apiEntity.entity.codeName}}Service.updateBatch({{camelCase apiEntity.defaultDto.codeName}}Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
......@@ -137,7 +137,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Save-all')")
@ApiOperation(value = "批量保存{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量保存{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.POST, value = "/{{pluralize apiEntity.codeName}}/savebatch")
@RequestMapping(method = RequestMethod.POST, value = "{{pluralize apiEntity.codeName}}/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<{{apiEntity.codeName}}DTO> dtos) {
{{camelCase apiEntity.entity.codeName}}Service.saveBatch({{camelCase apiEntity.defaultDto.codeName}}Mapping.toDomain(dtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
......@@ -145,7 +145,7 @@ public class {{apiEntity.codeName}}Resource {
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','{{projectName}}-{{apiEntity.entity.codeName}}-Remove-all')")
@ApiOperation(value = "批量删除{{apiEntity.entity.logicName}}", tags = {"{{apiEntity.entity.logicName}}" }, notes = "批量删除{{apiEntity.entity.logicName}}")
@RequestMapping(method = RequestMethod.DELETE, value = {"/{{pluralize apiEntity.codeName}}","/{{pluralize apiEntity.codeName}}/batch"})
@RequestMapping(method = RequestMethod.DELETE, value = {"{{pluralize apiEntity.codeName}}","/{{pluralize apiEntity.codeName}}/batch"})
public ResponseEntity<Boolean> removeBatch(@RequestBody List<{{apiEntity.entity.keyField.type.java}}> ids) {
{{camelCase apiEntity.entity.codeName}}Service.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册