Commit d3cbfeaf authored by duanledexianxianxian's avatar duanledexianxianxian 😁

代码重构

parent ec4188d8
......@@ -3,4 +3,5 @@ dependencies {
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.2'
compile 'org.asciidoctor:asciidoctorj:2.1.0'
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.30'
compile group: 'com.google.guava', name: 'guava', version: '23.0'
}
package com.github.fengyuchenglun.apidoc.core;
import com.github.fengyuchenglun.apidoc.core.common.Constants;
import com.github.fengyuchenglun.apidoc.core.render.AsciiDocRender;
import com.github.fengyuchenglun.apidoc.core.render.PostmanRender;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.github.fengyuchenglun.apidoc.core.common.helper.FileHelper;
......@@ -51,8 +53,8 @@ public class Context {
*/
@Setter
private List<ProjectRender> renders = Lists.newArrayList(
//new AsciiDocRender(),
//new PostmanRender(),
new AsciiDocRender(),
new PostmanRender(),
new MarkdownRender());
/**
......
......@@ -2,6 +2,8 @@ package com.github.fengyuchenglun.apidoc.core.common;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.ObjectUtils;
import java.util.Iterator;
......@@ -15,7 +17,7 @@ public class QueryStringBuilder {
}
builder.append(key);
builder.append("=");
builder.append(value);
builder.append(ObjectUtils.isEmpty(value) ? "xxx" : value);
return this;
}
......
......@@ -4,6 +4,7 @@ import com.github.fengyuchenglun.apidoc.core.common.ObjectMappers;
import com.github.fengyuchenglun.apidoc.core.schema.Row;
import com.fasterxml.jackson.databind.node.ArrayNode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.ArrayList;
import java.util.Collection;
......@@ -11,6 +12,7 @@ import java.util.Collection;
/**
* 数组类型描述
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ArrayTypeDescription extends TypeDescription {
......@@ -81,6 +83,7 @@ public class ArrayTypeDescription extends TypeDescription {
}
}
@Override
public ArrayNode getValue() {
return value;
}
......
......@@ -5,6 +5,7 @@ import com.github.fengyuchenglun.apidoc.core.schema.Row;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Lists;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
......@@ -17,6 +18,7 @@ import java.util.List;
* @author fengyuchenglun
* @version 1.0.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ObjectTypeDescription extends TypeDescription {
......@@ -136,11 +138,11 @@ public class ObjectTypeDescription extends TypeDescription {
}
@Override
public Collection<Row> rows(String requestParameterType) {
public Collection<Row> rows(String parameterType) {
Collection<Row> rows = super.rows(null);
for (TypeDescription member : members) {
if (member.isAvailable()) {
rows.addAll(member.rows(requestParameterType));
rows.addAll(member.rows(parameterType));
}
}
return rows;
......
......@@ -3,10 +3,12 @@ package com.github.fengyuchenglun.apidoc.core.common.description;
import com.github.javaparser.resolution.types.ResolvedPrimitiveType;
import com.github.javaparser.resolution.types.ResolvedReferenceType;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 原始类型描述
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class PrimitiveTypeDescription extends TypeDescription {
......
package com.github.fengyuchenglun.apidoc.core.common.description;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 字符串类型
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class StringTypeDescription extends TypeDescription {
......
......@@ -9,11 +9,13 @@ import com.google.common.collect.Lists;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.ObjectUtils;
import java.util.Collection;
/**
* The type Type description.
*
* @author duanledexianxianxian
*/
@Data
......@@ -51,7 +53,7 @@ public abstract class TypeDescription {
/**
* 是否必填.
*/
protected Boolean required=false;
protected Boolean required = false;
/**
* Is available boolean.
......@@ -173,7 +175,7 @@ public abstract class TypeDescription {
*
* @return the collection
*/
public Collection<Row> rows(String requestParameterType) {
public Collection<Row> rows(String parameterType) {
String fullKey = fullKey();
if (StringHelper.isBlank(fullKey)) {
return Lists.newArrayList();
......@@ -191,7 +193,7 @@ public abstract class TypeDescription {
// condition.append("required=").append(required);
// }
return Lists.newArrayList(new Row(key, type, required, condition.toString(), def, remark, requestParameterType));
return Lists.newArrayList(new Row(fullKey, type, required, condition.toString(), def, remark, parameterType));
}
......
......@@ -2,6 +2,7 @@ package com.github.fengyuchenglun.apidoc.core.common.description;
import com.github.fengyuchenglun.apidoc.core.schema.Row;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Collection;
......@@ -9,6 +10,7 @@ import java.util.Collection;
* 未知类型,应该忽略
* @author duanledexianxianxian
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class UnAvailableTypeDescription extends TypeDescription {
......
......@@ -33,16 +33,22 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
public void visit(final EnumDeclaration enumDeclaration, final Node arg) {
// 访问枚举
if (arg instanceof Project) {
Project project = (Project) arg;
// 章节
Chapter chapter = new Chapter();
enumDeclaration.getFullyQualifiedName().ifPresent(chapter::setId);
chapter.setName(enumDeclaration.getNameAsString());
enumDeclaration.getComment().ifPresent(chapter::accept);
OptionalHelper.any(chapter.getTag("book"), chapter.getTag("group"))
.ifPresent(tag -> chapter.setBookName(tag.getContent()));
project.addChapter(chapter);
super.visit(enumDeclaration, chapter);
// Project project = (Project) arg;
// // 章节
// Chapter chapter = new Chapter();
// enumDeclaration.getFullyQualifiedName().ifPresent(chapter::setId);
// chapter.setName(enumDeclaration.getNameAsString());
// enumDeclaration.getComment().ifPresent(chapter::accept);
// OptionalHelper.any(chapter.getTag("book"), chapter.getTag("group"))
// .ifPresent(tag -> chapter.setBookName(tag.getContent()));
// project.addChapter(chapter);
//放入附录
if (enumDeclaration.getJavadocComment().isPresent()) {
Appendix appendix = Appendix.parse(enumDeclaration.getJavadocComment().get());
ApiDoc.getInstance().getProject().getAppendices().add(appendix);
}
// super.visit(enumDeclaration, chapter);
}
}
......@@ -87,9 +93,7 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
if (commentedNode instanceof ClassOrInterfaceDeclaration
|| commentedNode instanceof EnumDeclaration) {
Appendix appendix = Appendix.parse(javadocComment);
if (appendix != null) {
ApiDoc.getInstance().getProject().getAppendices().add(appendix);
}
ApiDoc.getInstance().getProject().getAppendices().add(appendix);
}
}
});
......
......@@ -74,7 +74,7 @@ public class AsciiDocRender implements ProjectRender {
section.getInHeaders().values().forEach(header -> builder.textLine(header.toString()));
if (section.hasRequestBody()) {
b.br();
b.text(section.getParameterString());
b.text(section.getRequestBodyParameterString());
}
}, "source,HTTP");
......
......@@ -43,7 +43,6 @@ public class MarkdownRender implements ProjectRender {
}
private void build(Project project) throws Exception {
System.out.println(project);
String templatePath = ApiDoc.getInstance().getContext().getMarkdownTemplate();
String id = ApiDoc.getInstance().getContext().getId();
Path buildPath = ApiDoc.getInstance().getContext().getBuildPath();
......
......@@ -74,18 +74,18 @@ public class PostmanRender implements ProjectRender {
request.setMethod(section.getMethod());
request.getHeaders().addAll(section.getInHeaders().values());
ObjectNode objectNode = (ObjectNode) section.getQueryParameters();
for (String key : section.getRequestRows().keySet()) {
if (objectNode.has(key)) {
Row row = section.getRequestRows().get(key);
request.getUrl().getQuery().add(Parameter.of(row));
}
}
if (section.isQueryParameter()) {
if (Method.GET.equals(request.getMethod())) {
ObjectNode objectNode = (ObjectNode) section.getParameter();
for (String key : section.getRequestRows().keySet()) {
if (objectNode.has(key)) {
Row row = section.getRequestRows().get(key);
request.getUrl().getQuery().add(Parameter.of(row));
}
}
} else {
// get请求
if (!Method.GET.equals(request.getMethod())) {
request.getBody().setMode(BodyMode.urlencoded);
ObjectNode objectNode = (ObjectNode) section.getParameter();
objectNode = (ObjectNode) section.getRequestBodyParameters();
for (String key : section.getRequestRows().keySet()) {
if (objectNode.has(key)) {
Row row = section.getRequestRows().get(key);
......@@ -95,7 +95,7 @@ public class PostmanRender implements ProjectRender {
}
} else {
request.getBody().setMode(BodyMode.raw);
request.getBody().setRaw(section.getParameterString());
request.getBody().setRaw(section.getRequestBodyParameterString());
}
item.setRequest(request);
......
package com.github.fengyuchenglun.apidoc.core.schema;
import com.github.javaparser.ast.body.BodyDeclaration;
import com.github.javaparser.ast.body.EnumDeclaration;
import com.github.javaparser.ast.comments.JavadocComment;
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName;
import com.github.fengyuchenglun.apidoc.core.common.helper.EnumHelper;
......@@ -35,6 +36,8 @@ public class Appendix extends Node {
return cells.isEmpty();
}
/**
* Parse appendix.
*
......
......@@ -7,7 +7,7 @@ package com.github.fengyuchenglun.apidoc.core.schema;
* @date 2020 /3/29 0:37
* @since 1.0.0
*/
public enum RequestParameterType {
public enum ParameterType {
/**
* 查询参数.
*/
......@@ -29,7 +29,7 @@ public enum RequestParameterType {
*/
private String msg;
RequestParameterType(String code, String msg) {
ParameterType(String code, String msg) {
this.code = code;
this.msg = msg;
}
......
......@@ -42,7 +42,7 @@ public class Row {
/**
* 请求参数类型
*/
String requestParameterType;
String parameterType;
/**
......
......@@ -20,7 +20,7 @@ import java.util.*;
* @version 1.0.0
*/
@Data
@EqualsAndHashCode(callSuper=true)
@EqualsAndHashCode(callSuper = true)
public class Section extends Node {
/**
......@@ -39,14 +39,24 @@ public class Section extends Node {
* 路径变量.
*/
ObjectNode pathVariable = ObjectMappers.instance.createObjectNode();
/**
* The Parameter.
*/
JsonNode parameter;
/**
* The Query parameter.
*/
boolean queryParameter = true;
/**
* 查询参数+请求体参数
*/
JsonNode parameters = ObjectMappers.instance.createObjectNode();
/**
* 查询参数
*/
JsonNode queryParameters = ObjectMappers.instance.createObjectNode();
/**
* 请求体参数
*/
JsonNode requestBodyParameters = ObjectMappers.instance.createObjectNode();
/**
* The Request rows.
*/
......@@ -68,6 +78,38 @@ public class Section extends Node {
*/
Object rawResponse;
/**
* Sets parameter.
*
* @param parameter the parameter
*/
public void setParameters(JsonNode parameter) {
((ObjectNode) this.parameters).setAll((ObjectNode) parameter);
}
/**
* Sets query parameters.
*
* @param parameter the parameter
*/
public void setQueryParameters(JsonNode parameter) {
((ObjectNode) this.queryParameters).setAll((ObjectNode) parameter);
}
/**
* Sets request body parameters.
*
* @param parameter the parameter
*/
public void setRequestBodyParameters(JsonNode parameter) {
((ObjectNode) this.requestBodyParameters).setAll((ObjectNode) parameter);
}
/**
* Sets uri.
*
* @param uri the uri
*/
public void setUri(String uri) {
String value = "";
if (StringUtils.isNotBlank(uri)) {
......@@ -106,8 +148,8 @@ public class Section extends Node {
public String getRequestLine() {
StringBuilder builder = new StringBuilder(this.method.toString());
builder.append(" ").append(this.uri);
if (this.queryParameter && Objects.equals("GET", this.method)) {
String parameterString = getParameterString();
if (Objects.equals("GET", this.method)) {
String parameterString = getQueryParameterString();
if (StringHelper.nonBlank(parameterString)) {
builder.append("?").append(parameterString);
}
......@@ -116,16 +158,39 @@ public class Section extends Node {
return builder.toString();
}
/**
* Get parameter string string.
* Gets query parameter string.
*
* @return the string
* @return the query parameter string
*/
public String getParameterString() {
if (queryParameter && parameter instanceof ObjectNode) {
return new QueryStringBuilder().append((ObjectNode) parameter).toString();
if (queryParameter) {
// 查询参数
new QueryStringBuilder().append((ObjectNode) queryParameters).toString();
}
return ObjectMappers.pretty(parameter);
// 请求体参数
return ObjectMappers.pretty(parameters);
}
/**
* Gets query parameter string.
*
* @return the query parameter string
*/
public String getQueryParameterString() {
return new QueryStringBuilder().append((ObjectNode) queryParameters).toString();
}
/**
* Gets request body parameter string.
*
* @return the request body parameter string
*/
public String getRequestBodyParameterString() {
// 请求体参数
return ObjectMappers.pretty(requestBodyParameters);
}
/**
......@@ -137,7 +202,7 @@ public class Section extends Node {
if (Objects.equals("GET", this.method)) {
return false;
}
return parameter != null && parameter.size() > 0;
return requestBodyParameters != null && requestBodyParameters.size() > 0;
}
/**
......
......@@ -46,9 +46,13 @@ ${section.method} ${section.uri!''} HTTP/1.1
${inHeaderValue!''}
</#list>
</#if>
<#if section.hasRequestBody()>
<#if (section.getQueryParameterString()?length gt 1)>
${section.getParameterString()}
${section.getQueryParameterString()}
</#if>
<#if section.hasRequestBody()>
${section.getRequestBodyParameterString()}
</#if>
```
<#-- 请求参数table列表-->
......@@ -57,7 +61,7 @@ ${section.getParameterString()}
| 字段 | 类型 | 参数类型 | 是否必填 | 验证 | 默认值 | 描述 |
| :------- | :----- | :----- |:-------- |:-------- | :------ | :---------- |
<#list section.requestRows as rowKey,rowValue>
| ${rowValue.key!''} | ${rowValue.type!''} | **${rowValue.requestParameterType!''}** |${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} |
| ${rowValue.key!''} | ${rowValue.type!''} | **${rowValue.parameterType!''}** |${rowValue.required?string('true','false')} | ${rowValue.condition!''} | ${rowValue.def!''} | ${rowValue.remark!''} |
</#list>
</#if>
<#-- 响应-->
......@@ -85,3 +89,17 @@ ${section.getResponseString()}
</#list>
<#------------ END 循环遍历book ---------->
</#if>
# 附录
<#if appendices??>
<#list appendices as appendfix>
## ${appendfix.name}
<#if appendfix.cells?? && (appendfix.cells?size>0)>
| 编码 | 值 | 说明 |
| :------- | :----- |:-----
<#list appendfix.cells as cell>
| <#if (cell.values?size>0)>${cell.values[0]}</#if> | <#if (cell.values?size>1)>${cell.values[1]}</#if> | <#if (cell.values?size>2)>${cell.values[2]}</#if> |
</#list>
</#if>
</#list >
</#if>
......@@ -24,7 +24,7 @@ import com.github.fengyuchenglun.apidoc.springmvc.resovler.SpringComponentTypeRe
import java.util.List;
import java.util.Optional;
import static com.github.fengyuchenglun.apidoc.core.schema.RequestParameterType.*;
import static com.github.fengyuchenglun.apidoc.core.schema.ParameterType.*;
/**
......@@ -141,10 +141,12 @@ public class SpringParser implements ParserStrategy {
* @param section the section
*/
private void visitParameters(MethodDeclaration n, Chapter chapter, Section section) {
if (ParameterHelper.hasRequestBody(n.getParameters())) {
visitRequestBody(n, chapter, section);
} else {
visitParameter(n, chapter, section);
for (Parameter parameter : n.getParameters()) {
if (ParameterHelper.isRequestBody(parameter)) {
visitRequestBody(n, chapter, section);
} else {
visitParameter(n, chapter, section);
}
}
}
......@@ -160,7 +162,7 @@ public class SpringParser implements ParserStrategy {
if (ParameterHelper.isPathVariable(parameter)) {
section.getPathVariable().put(parameter.getNameAsString(), "");
Row row = new Row();
row.setRequestParameterType(PATH.getMsg());
row.setParameterType(PATH.getMsg());
row.setKey(parameter.getNameAsString());
row.setType(parameter.getType().toString());
// 路径参数必填
......@@ -235,9 +237,9 @@ public class SpringParser implements ParserStrategy {
TypeDescription description = ApiDoc.getInstance().getTypeResolvers().resolve(parameter.getType());
if (description.isAvailable()) {
if (description.isArray()) {
section.setParameter(description.asArray().getValue());
section.setRequestBodyParameters(description.asArray().getValue());
} else if (description.isObject()) {
section.setParameter(description.asObject().getValue());
section.setRequestBodyParameters(description.asObject().getValue());
}
section.addRequestRows(description.rows(BODY.getMsg()));
}
......@@ -299,7 +301,7 @@ public class SpringParser implements ParserStrategy {
}
}
}
section.setParameter(objectTypeDescription.getValue());
section.setQueryParameters(objectTypeDescription.getValue());
section.addRequestRows(objectTypeDescription.rows(QUERY.getMsg()));
}
......
......@@ -3,6 +3,8 @@ package com.github.fengyuchenglun.example.common;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
@Setter
@Getter
public class Query {
......@@ -13,8 +15,24 @@ public class Query {
public static final String CONSTANS = "";
/**
* 查询关键字
* 用户名称
*/
private String userName;
/**
* 用户手机号码
*/
private String userPhoneNum;
/**
* 用户邮箱
*/
private String userEmail;
/**
* 开始时间
*/
private LocalDateTime startTime;
/**
* 结束时间
*/
String q = "123";
private LocalDateTime endTime;
}
......@@ -4,7 +4,7 @@ import lombok.Getter;
import lombok.Setter;
/**
* The type Result data.
* 统一返回结果对象.
*
* @param <T> the type parameter
* @author fengyuchenglun
......@@ -25,7 +25,7 @@ public class ResultData<T> {
//返回信息
String msg;
/**
* The Data.
* 数据对象.
*/
T data;
......@@ -35,7 +35,7 @@ public class ResultData<T> {
* @param <T> the type parameter
* @return the result data
*/
public static <T> ResultData<T> ok(){
public static <T> ResultData<T> ok() {
return ok(null);
}
......@@ -46,7 +46,7 @@ public class ResultData<T> {
* @param data the data
* @return the result data
*/
public static <T> ResultData<T> ok(T data){
public static <T> ResultData<T> ok(T data) {
ResultData<T> resultData = new ResultData<>();
resultData.code = 0;
resultData.msg = "ok";
......
......@@ -8,6 +8,7 @@ import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* 用户对象
......@@ -19,30 +20,40 @@ import java.util.Date;
@Getter
public class User {
// /**
// * 用户编号.
// */
// int id;
// /**
// * 用户名称.
// */
// @NotBlank
// String name;
// /**
// * 用户年龄.
// */
// @Min(1)
// @NotNull
// Integer age;
// /**
// * 创建时间.
// */
// Date createAt;
// /**
// * 性别.
// */
// @NotBlank
// @JsonProperty("Sex")
// String sex;
/**
* 用户编号.
*/
int id;
/**
* 用户名称.
*/
@NotBlank
String name;
/**
* 用户年龄.
*/
@Min(1)
@NotNull
Integer age;
/**
* 创建时间.
* 用户.
*/
Date createAt;
private UserQuery query;
/**
* 性别.
* 用户.
*/
@NotBlank
@JsonProperty("Sex")
String sex;
private List<Menu> menus;
}
package com.github.fengyuchenglun.example.spring.advanced;
import com.github.fengyuchenglun.example.annotation.KimController;
import com.github.fengyuchenglun.example.common.Query;
import com.github.fengyuchenglun.example.common.User;
import com.github.fengyuchenglun.example.common.UserQuery;
......@@ -8,6 +7,7 @@ import lombok.Data;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
/**
* 用户接口.
......@@ -18,138 +18,141 @@ import java.io.Serializable;
* @index 20
* @since 1.0.0
*/
@KimController
@RestController
@RequestMapping("/api/v1/users")
public class UserController {
/**
* 查看用户详情
*
* @param userId 用户编号
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/{userId}")
public User detail(@PathVariable String userId, Query query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/detail1")
public User detail1(Query query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/detail3")
public User detail3(@RequestParam Query query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @param query 过滤条件
* @return 用户对象 user
*/
@GetMapping(value = "/detail4")
public User detail4(@RequestParam(required = false) Query query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @return 用户对象 user
*/
@GetMapping(value = "/detail5")
public User detail5() {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @param userName the user name
* @param age the age
* @param query the query
* @return 用户对象 user
*/
@GetMapping(value = "/detail6")
public User detail6(String userName, Integer age, UserQuery query) {
User user = new User();
return user;
}
/**
* 查看用户详情
*
* @return 用户对象 user
*/
@GetMapping(value = "/detail7")
public void detail7() {
}
/**
* 删除用户
*
* @param userId the user id
* @return boolean 是否成功
*/
@DeleteMapping(value = "/{userId}")
public Boolean deleteUser(@PathVariable("userId") Long userId) {
return true;
}
/**
* 用户表单对象.
*
* @author duanledexianxianxian
*/
@Data
public static class UserForm implements Serializable {
private static final long serialVersionUID = 5681371348688016281L;
/**
* 用户名
*/
private String userName;
/**
* 地址
*/
private String address;
/**
* 年龄
*/
private Integer age;
}
/**
* 添加用户
*
* @param form 用户表单对象
* @return integer 返回记录
*/
@PostMapping
public Integer add(@RequestBody UserForm form) {
return null;
}
//
// /**
// * 查看用户详情
// *
// * @param userId 用户编号
// * @param age 年龄
// * @param query 过滤条件
// * @return 用户对象 user
// */
// @PostMapping(value = "/{userId}")
// public User detail(@PathVariable String userId, String age, @RequestBody Query query) {
// User user = new User();
// return user;
// }
//
// /**
// * 查看用户详情
// * 测试get的query对象
// *
// * @param query 过滤条件
// * @return 用户对象 user
// */
// @GetMapping(value = "/detail1")
// public User detail1(Query query) {
// User user = new User();
// return user;
// }
//
//
// /**
// * 测试get的query对象,带RequestParam注解
// *
// * @param query 过滤条件
// * @return 用户对象 user
// */
// @GetMapping(value = "/detail3")
// public User detail3(@RequestParam String query) {
// User user = new User();
// return user;
// }
//
// /**
// * 测试get的query对象,带RequestParam注解,required=false
// *
// * @param query 过滤条件
// * @return 用户对象 user
// */
// @GetMapping(value = "/detail4")
// public User detail4(@RequestParam(required = false) String query) {
// User user = new User();
// return user;
// }
//
// /**
// * get-无查询参数
// *
// * @return 用户对象 user
// */
// @GetMapping(value = "/detail5")
// public List<User> detail5() {
// return null;
// }
//
// /**
// * get-原始对象+查询对象
// *
// * @param userName the user name
// * @param age the age
// * @param query the query
// * @return 用户对象 user
// */
// @GetMapping(value = "/detail6")
// public User detail6(String userName, Integer age, UserQuery query) {
// User user = new User();
// return user;
// }
//
// /**
// * post-
// *
// * @return 用户对象 user
// */
// @GetMapping(value = "/post1")
// public UserQuery post1() {
// return null;
// }
//
//
// /**
// * 删除用户
// *
// * @param userId the user id
// * @return boolean 是否成功
// */
// @DeleteMapping(value = "/{userId}")
// public Boolean deleteUser(@PathVariable("userId") Long userId) {
// return true;
// }
//
//
// /**
// * 用户表单对象.
// *
// * @author duanledexianxianxian
// */
// @Data
// public static class UserForm implements Serializable {
//
// private static final long serialVersionUID = 5681371348688016281L;
// /**
// * 用户名
// */
// private String userName;
// /**
// * 地址
// */
// private String address;
// /**
// * 年龄
// */
// private Integer age;
// }
//
// /**
// * 添加用户
// *
// * @param form 用户表单对象
// * @return integer 返回记录
// */
// @PostMapping
// public Integer add(@RequestBody UserForm form) {
// return null;
// }
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment