pull/1/head
tanghc 6 years ago
parent 691d642f26
commit f123472912
  1. 2
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteCache.java
  2. 4
      sop-example/readme.md
  3. 174
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/AlipayController.java
  4. 30
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/FileUploadDemoController.java
  5. 7
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/PermissionDemoController.java
  6. 11
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/PostJsonController.java
  7. 49
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/Story2Controller.java
  8. 29
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/StoryController.java
  9. 13
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/param/CategoryParam.java
  10. 13
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/result/CategoryResult.java
  11. 4
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/result/FileUploadResult.java
  12. 23
      sop-example/sop-story/sop-story-web/src/main/java/com/gitee/sop/storyweb/controller/result/StoryResult.java

@ -13,7 +13,7 @@ import org.springframework.cloud.netflix.zuul.filters.Route;
public class ZuulRouteCache extends BaseRouteCache<ZuulTargetRoute> { public class ZuulRouteCache extends BaseRouteCache<ZuulTargetRoute> {
/** 路由重试 */ /** 路由重试 */
public static final boolean RETRYABLE = true; private static final boolean RETRYABLE = true;
public ZuulRouteCache(RouteRepository<ZuulTargetRoute> routeRepository) { public ZuulRouteCache(RouteRepository<ZuulTargetRoute> routeRepository) {
super(routeRepository); super(routeRepository);

@ -1,7 +1,7 @@
# 服务示例 # 服务示例
- sop-auth:应用授权示例
- sop-springmvc:springmvc工程实例
- sop-story:微服务示例,story服务,同时作为Provider提供服务。本地文档:http://localhost:2222/doc.html - sop-story:微服务示例,story服务,同时作为Provider提供服务。本地文档:http://localhost:2222/doc.html
- sop-book:微服务示例,book服务,也是Consumer,调用story提供的服务 - sop-book:微服务示例,book服务,也是Consumer,调用story提供的服务
- sop-auth:应用授权示例
- sop-springmvc:springmvc工程实例
- sop-easyopen:整合easyopen示例 - sop-easyopen:整合easyopen示例

@ -6,12 +6,15 @@ import com.gitee.sop.servercommon.annotation.ApiMapping;
import com.gitee.sop.servercommon.bean.OpenContext; import com.gitee.sop.servercommon.bean.OpenContext;
import com.gitee.sop.servercommon.bean.ServiceContext; import com.gitee.sop.servercommon.bean.ServiceContext;
import com.gitee.sop.story.api.domain.Story; import com.gitee.sop.story.api.domain.Story;
import com.gitee.sop.storyweb.controller.param.CategoryParam;
import com.gitee.sop.storyweb.controller.param.StoryParam; import com.gitee.sop.storyweb.controller.param.StoryParam;
import com.gitee.sop.storyweb.controller.result.CategoryResult;
import com.gitee.sop.storyweb.controller.result.StoryResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -24,6 +27,7 @@ import java.util.List;
/** /**
* 支付宝服务端假设签名验证通过后到达这里进行具体的业务处理 * 支付宝服务端假设签名验证通过后到达这里进行具体的业务处理
*
* @author tanghc * @author tanghc
*/ */
@RestController @RestController
@ -34,52 +38,56 @@ public class AlipayController {
// http://localhost:2222/story_get // http://localhost:2222/story_get
// 原生的接口,可正常调用 // 原生的接口,可正常调用
@RequestMapping("story_get") @RequestMapping("story_get")
public Story story_get() { public StoryResult story_get() {
Story story = new Story(); StoryResult result = new StoryResult();
story.setId(1); result.setId(1L);
story.setName("海底小纵队(原生)"); result.setName("海底小纵队(原生)");
return story; return result;
} }
// http://localhost:2222/story.get/ // http://localhost:2222/story.get/
// 接口名,使用默认版本号 // 接口名,使用默认版本号
@ApiMapping(value = "story.get") @ApiMapping(value = "story.get")
public Story storyget() { public StoryResult storyget() {
// 获取开放平台参数 // 获取开放平台参数
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext(); OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
String appId = openContext.getAppId(); String appId = openContext.getAppId();
Story story = new Story(); StoryResult result = new StoryResult();
story.setId(1); result.setId(1L);
story.setName("海底小纵队(默认版本号), app_id:" + appId); result.setName("海底小纵队(默认版本号), app_id:" + appId);
return story; return result;
} }
// http://localhost:2222/story.get/?version=1.1 // http://localhost:2222/story.get/?version=1.1
// 接口名 + 版本号 // 接口名 + 版本号
@ApiMapping(value = "story.get", version = "1.1") @ApiMapping(value = "story.get", version = "1.1")
public Story getStory2() { public StoryResult getStory2() {
Story story = new Story(); StoryResult result = new StoryResult();
story.setId(1); result.setId(1L);
story.setName("海底小纵队1.0"); result.setName("海底小纵队1.0");
return story; return result;
} }
// http://localhost:2222/story.get/?name=111&version=2.0 // http://localhost:2222/story.get/?name=111&version=2.0
// 接口名 + 版本号 // 接口名 + 版本号
// StoryParam对应biz_content内容
@ApiMapping(value = "story.get", version = "2.0") @ApiMapping(value = "story.get", version = "2.0")
public Story getStory20(Story story) { public StoryResult getStory20(StoryParam param) {
return story; StoryResult result = new StoryResult();
BeanUtils.copyProperties(param, result);
return result;
} }
// 忽略验证 // 忽略验证
@ApiMapping(value = "story.get", version = "2.1", ignoreValidate = true) @ApiMapping(value = "story.get", version = "2.1", ignoreValidate = true)
public Story getStory21(Story story) { public StoryResult getStory21(StoryParam story) {
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext(); OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
// 此处的param和story参数是一样的 // 此处的param和story参数是一样的
Story param = openContext.getBizObject(Story.class); StoryParam param = openContext.getBizObject(StoryParam.class);
boolean isSame = story == param; boolean isSame = story == param;
story.setName(story.getName() + ", story.get2.1, ignoreValidate = true, story==param:" + isSame); StoryResult result = new StoryResult();
return story; result.setName(story.getName() + ", story.get2.1, ignoreValidate = true, story==param:" + isSame);
return result;
} }
/** /**
@ -95,23 +103,26 @@ public class AlipayController {
* return bizObject; * return bizObject;
* } * }
* </pre> * </pre>
*
* @param openContext * @param openContext
* @return * @return
*/ */
@ApiMapping(value = "story.get", version = "2.2") @ApiMapping(value = "story.get", version = "2.2")
public Story getStory22(OpenContext<Story> openContext) { public StoryResult getStory22(OpenContext<StoryParam> openContext) {
Story bizObject = openContext.getBizObject(); StoryParam bizObject = openContext.getBizObject();
// 获取appid,更多方法查看OpenContext类 // 获取appid,更多方法查看OpenContext类
String appId = openContext.getAppId(); String appId = openContext.getAppId();
bizObject.setName("appId:" + appId + ", " + bizObject.getName()); StoryResult result = new StoryResult();
return bizObject; result.setName("appId:" + appId + ", " + bizObject.getName());
return result;
} }
@ApiMapping(value = "story.get", version = "2.3") @ApiMapping(value = "story.get", version = "2.3")
public Story getStory23(Story story, HttpServletRequest request) { public StoryResult getStory23(StoryParam param, HttpServletRequest request) {
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext(); OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
String appId = openContext.getAppId(); String appId = openContext.getAppId();
System.out.println(appId); System.out.println(appId);
StoryResult story = new StoryResult();
story.setName("appId:" + appId + ", " + story.getName() + ",ip:" + request.getLocalAddr()); story.setName("appId:" + appId + ", " + story.getName() + ",ip:" + request.getLocalAddr());
return story; return story;
} }
@ -120,9 +131,9 @@ public class AlipayController {
// 遗留接口具备开放平台能力 // 遗留接口具备开放平台能力
@ApiAbility @ApiAbility
@GetMapping("getStory2") @GetMapping("getStory2")
public Story getStory2_0() { public StoryResult getStory2_0() {
Story story = new Story(); StoryResult story = new StoryResult();
story.setId(1); story.setId(1L);
story.setName("海底小纵队(默认版本号)"); story.setName("海底小纵队(默认版本号)");
return story; return story;
} }
@ -131,118 +142,117 @@ public class AlipayController {
// 遗留接口具备开放平台能力,在原来的基础上加版本号 // 遗留接口具备开放平台能力,在原来的基础上加版本号
@ApiAbility(version = "2.1") @ApiAbility(version = "2.1")
@GetMapping("getStory2") @GetMapping("getStory2")
public Story getStory2_1() { public StoryResult getStory2_1() {
Story story = new Story(); StoryResult story = new StoryResult();
story.setId(1); story.setId(1L);
story.setName("海底小纵队2.1"); story.setName("海底小纵队2.1");
return story; return story;
} }
// http://localhost:2222/alipay.story.get/ // http://localhost:2222/alipay.story.get/
@ApiOperation(value="获取故事信息2", notes = "获取故事信息2的详细信息")
@ApiMapping(value = "alipay.story.get") @ApiMapping(value = "alipay.story.get")
public Story getStory(Story param) { public StoryResult getStory(StoryParam param) {
Story story = new Story(); StoryResult story = new StoryResult();
story.setId(1); story.setId(1L);
story.setName("海底小纵队(alipay.story.get1.0), param:" + param); story.setName("海底小纵队(alipay.story.get1.0), param:" + param);
return story; return story;
} }
/** /**
*
* @param param 对应biz_content中的内容并自动JSR-303校验 * @param param 对应biz_content中的内容并自动JSR-303校验
* @return * @return
*/ */
@ApiMapping(value = "alipay.story.get", version = "1.2") @ApiMapping(value = "alipay.story.get", version = "1.2")
public Story getStory11(Story param) { public StoryResult getStory11(StoryParam param) {
Story story2 = new Story(); StoryResult story2 = new StoryResult();
story2.setId(1); story2.setId(1L);
story2.setName("海底小纵队(alipay.story.get1.2), param:" + param); story2.setName("海底小纵队(alipay.story.get1.2), param:" + param);
return story2; return story2;
} }
/** /**
* 验证字符串乱码问题 * 验证字符串乱码问题
*
* @param param * @param param
* @return * @return
*/ */
@ApiMapping(value = "story.string.get", version = "1.0") @ApiMapping(value = "story.string.get", version = "1.0")
public String string(Story param) { public String string(StoryParam param) {
Story story2 = new Story(); StoryResult story2 = new StoryResult();
story2.setId(1); story2.setId(1L);
story2.setName("海底小纵队"); story2.setName("海底小纵队");
return JSON.toJSONString(story2); return JSON.toJSONString(story2);
} }
/** /**
* 参数绑定 * 参数绑定
*
* @param story 对应biz_content中的内容并自动JSR-303校验 * @param story 对应biz_content中的内容并自动JSR-303校验
* @return * @return
*/ */
@ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。") @ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。")
@ApiMapping(value = "alipay.story.find") @ApiMapping(value = "alipay.story.find")
public StoryVO getStory2(StoryParam story) { public StoryResult getStory2(StoryParam story) {
log.info("获取故事信息参数, story: {}", story); log.info("获取故事信息参数, story: {}", story);
// 获取其它参数 // 获取其它参数
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext(); OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
String app_id = openContext.getAppId(); String app_id = openContext.getAppId();
StoryVO storyVO = new StoryVO(); StoryResult storyVO = new StoryResult();
storyVO.id = 1L; storyVO.setName("白雪公主, app_id:" + app_id);
storyVO.name = "白雪公主, app_id:" + app_id; storyVO.setGmt_create(new Date());
storyVO.gmt_create = new Date();
return storyVO; return storyVO;
} }
@ApiOperation(value = "返回数组结果", notes = "返回数组结果") @ApiOperation(value = "返回数组结果", notes = "返回数组结果")
@ApiMapping(value = "alipay.story.find2") @ApiMapping(value = "alipay.story.find2")
public List<StoryVO> getStory3(StoryParam story) { public List<StoryResult> getStory3(StoryParam story) {
int index = 0; int index = 0;
StoryVO storyVO = new StoryVO(); StoryResult storyVO = new StoryResult();
storyVO.id = 1L; storyVO.setId(1L);
storyVO.name = "白雪公主, index:" + index++; storyVO.setName("白雪公主, index:" + index++);
storyVO.gmt_create = new Date(); storyVO.setGmt_create(new Date());
StoryVO storyVO2 = new StoryVO(); StoryResult storyVO2 = new StoryResult();
storyVO2.id = 1L; storyVO2.setId(1L);
storyVO2.name = "白雪公主, index:" + index++; storyVO2.setName("白雪公主, index:" + index++);
storyVO2.gmt_create = new Date(); storyVO2.setGmt_create(new Date());
return Arrays.asList(storyVO, storyVO2); return Arrays.asList(storyVO, storyVO2);
} }
/** /**
* 演示文档表格树 * 演示文档表格树
* @param story *
* @param param
* @return * @return
*/ */
@ApiOperation(value="获取分类信息", notes = "演示表格树") @ApiOperation(value = "获取分类信息", notes = "演示表格树")
@ApiMapping(value = "alipay.category.get", method = RequestMethod.POST) @ApiMapping(value = "alipay.category.get", method = RequestMethod.POST)
public Category getCategory(Category story) { public CategoryResult getCategory(CategoryParam param) {
StoryVO storyVO = new StoryVO(); StoryResult result = new StoryResult();
storyVO.id = 1L; result.setId(1L);
storyVO.name = "白雪公主"; result.setName("白雪公主");
storyVO.gmt_create = new Date(); result.setGmt_create(new Date());
Category category = new Category(); CategoryResult categoryResult = new CategoryResult();
category.setCategoryName("娱乐"); categoryResult.setCategoryName("娱乐");
category.setStory(storyVO); categoryResult.setStoryResult(result);
return category; return categoryResult;
} }
@Data // 测试参数绑定,http://localhost:2222/story/getStory4?biz_content=%7b%22id%22%3a1%2c%22name%22%3a%22aaaa%22%7d
public static class StoryVO { @ApiAbility
@ApiModelProperty(value = "故事ID", example = "1") @GetMapping("getStory4")
private Long id; public StoryResult getStory4(Story param, P p2) {
@ApiModelProperty(value = "故事名称", example = "海底小纵队") System.out.println(param + ", p2=" + p2);
private String name; StoryResult result = new StoryResult();
@ApiModelProperty(value = "创建时间", example = "2019-04-14 19:02:12") result.setId(1L);
private Date gmt_create; result.setName("海底小纵队(默认版本号)" + param + ", p2=" + p2);
return result;
} }
@Data @Data
public static class Category { public static class P {
@ApiModelProperty(value = "分类名称", example = "娱乐") private String name;
private String categoryName;
@ApiModelProperty(value = "分类故事")
private StoryVO story;
} }
} }

@ -4,7 +4,7 @@ import com.gitee.sop.servercommon.annotation.ApiMapping;
import com.gitee.sop.servercommon.util.UploadUtil; import com.gitee.sop.servercommon.util.UploadUtil;
import com.gitee.sop.storyweb.controller.param.FileUploadParam; import com.gitee.sop.storyweb.controller.param.FileUploadParam;
import com.gitee.sop.storyweb.controller.param.FileUploadParam2; import com.gitee.sop.storyweb.controller.param.FileUploadParam2;
import com.gitee.sop.storyweb.vo.FileUploadVO; import com.gitee.sop.storyweb.controller.result.FileUploadResult;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Extension; import io.swagger.annotations.Extension;
@ -33,19 +33,19 @@ public class FileUploadDemoController {
*/ */
@ApiOperation(value = "文件上传例1", notes = "上传文件demo") @ApiOperation(value = "文件上传例1", notes = "上传文件demo")
@ApiMapping(value = "demo.file.upload") @ApiMapping(value = "demo.file.upload")
public FileUploadVO file1(FileUploadParam param) { public FileUploadResult file1(FileUploadParam param) {
System.out.println(param.getRemark()); System.out.println(param.getRemark());
// 获取上传的文件 // 获取上传的文件
MultipartFile file1 = param.getFile1(); MultipartFile file1 = param.getFile1();
MultipartFile file2 = param.getFile2(); MultipartFile file2 = param.getFile2();
FileUploadVO vo = new FileUploadVO(); FileUploadResult result = new FileUploadResult();
FileUploadVO.FileMeta fileMeta1 = buildFileMeta(file1); FileUploadResult.FileMeta fileMeta1 = buildFileMeta(file1);
FileUploadVO.FileMeta fileMeta2 = buildFileMeta(file2); FileUploadResult.FileMeta fileMeta2 = buildFileMeta(file2);
vo.getFiles().add(fileMeta1); result.getFiles().add(fileMeta1);
vo.getFiles().add(fileMeta2); result.getFiles().add(fileMeta2);
return vo; return result;
} }
/** /**
@ -58,19 +58,19 @@ public class FileUploadDemoController {
// 多文件上传、不确定文件数量上传,必须申明下面这句,否则沙盒界面不会出现上传控件 // 多文件上传、不确定文件数量上传,必须申明下面这句,否则沙盒界面不会出现上传控件
, extensions = @Extension(properties = @ExtensionProperty(name = "multiple", value = "multiple"))) , extensions = @Extension(properties = @ExtensionProperty(name = "multiple", value = "multiple")))
@ApiMapping(value = "demo.file.upload2") @ApiMapping(value = "demo.file.upload2")
public FileUploadVO file2(FileUploadParam2 param, HttpServletRequest request) { public FileUploadResult file2(FileUploadParam2 param, HttpServletRequest request) {
System.out.println(param.getRemark()); System.out.println(param.getRemark());
FileUploadVO vo = new FileUploadVO(); FileUploadResult result = new FileUploadResult();
// 获取上传的文件 // 获取上传的文件
Collection<MultipartFile> uploadFiles = UploadUtil.getUploadFiles(request); Collection<MultipartFile> uploadFiles = UploadUtil.getUploadFiles(request);
for (MultipartFile multipartFile : uploadFiles) { for (MultipartFile multipartFile : uploadFiles) {
FileUploadVO.FileMeta fileMeta = buildFileMeta(multipartFile); FileUploadResult.FileMeta fileMeta = buildFileMeta(multipartFile);
vo.getFiles().add(fileMeta); result.getFiles().add(fileMeta);
} }
return vo; return result;
} }
private FileUploadVO.FileMeta buildFileMeta(MultipartFile multipartFile) { private FileUploadResult.FileMeta buildFileMeta(MultipartFile multipartFile) {
// 文件名 // 文件名
String fileName = multipartFile.getOriginalFilename(); String fileName = multipartFile.getOriginalFilename();
// 文件大小 // 文件大小
@ -82,6 +82,6 @@ public class FileUploadDemoController {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return new FileUploadVO.FileMeta(fileName, size, fileContent); return new FileUploadResult.FileMeta(fileName, size, fileContent);
} }
} }

@ -2,6 +2,7 @@ package com.gitee.sop.storyweb.controller;
import com.gitee.sop.servercommon.annotation.ApiMapping; import com.gitee.sop.servercommon.annotation.ApiMapping;
import com.gitee.sop.story.api.domain.Story; import com.gitee.sop.story.api.domain.Story;
import com.gitee.sop.storyweb.controller.result.StoryResult;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
@ -13,9 +14,9 @@ import org.springframework.web.bind.annotation.RestController;
public class PermissionDemoController { public class PermissionDemoController {
@ApiMapping(value = "permission.story.get", permission = true) @ApiMapping(value = "permission.story.get", permission = true)
public Story getStory() { public StoryResult getStory() {
Story story = new Story(); StoryResult story = new StoryResult();
story.setId(1); story.setId(1L);
story.setName("海底小纵队(permission.story.get)"); story.setName("海底小纵队(permission.story.get)");
return story; return story;
} }

@ -5,6 +5,7 @@ import com.gitee.sop.servercommon.bean.ServiceContext;
import com.gitee.sop.servercommon.bean.OpenContext; import com.gitee.sop.servercommon.bean.OpenContext;
import com.gitee.sop.story.api.domain.Story; import com.gitee.sop.story.api.domain.Story;
import com.gitee.sop.storyweb.controller.param.StoryParam; import com.gitee.sop.storyweb.controller.param.StoryParam;
import com.gitee.sop.storyweb.controller.result.StoryResult;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -24,7 +25,7 @@ public class PostJsonController {
* @return * @return
*/ */
@ApiMapping("demo.post.json") @ApiMapping("demo.post.json")
public Story postJson(@RequestBody StoryParam param) { public StoryResult postJson(@RequestBody StoryParam param) {
// 获取开放平台请求参数 // 获取开放平台请求参数
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext(); OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
List<Object> params = Arrays.asList( List<Object> params = Arrays.asList(
@ -32,10 +33,10 @@ public class PostJsonController {
openContext.getMethod(), openContext.getMethod(),
openContext.getVersion() openContext.getVersion()
); );
Story story = new Story(); StoryResult result = new StoryResult();
story.setId(1); result.setId(1L);
story.setName("参数:" + param.getName() + ", openParams:" + StringUtils.join(params)); result.setName("参数:" + param.getName() + ", openParams:" + StringUtils.join(params));
return story; return result;
} }
/** /**

@ -1,49 +0,0 @@
package com.gitee.sop.storyweb.controller;
import com.gitee.sop.servercommon.annotation.ApiAbility;
import com.gitee.sop.servercommon.annotation.ApiMapping;
import com.gitee.sop.story.api.domain.Story;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author tanghc
*/
@ApiAbility // 放在这里,下面所有的接口都具备接口提供能力
@RestController
@RequestMapping("story2")
@Api(tags = "故事接口2")
public class Story2Controller{
@RequestMapping("getStory4")
public Story getStory4() {
Story story = new Story();
story.setId(1);
story.setName("海底小纵队(getStory4)");
return story;
}
// 优先使用方法上@ApiAbility
@ApiOperation(value="获取故事信息2", notes = "获取故事信息2的详细信息")
@ApiAbility(version = "1.4")
@RequestMapping("getStory4")
public Story storyget() {
Story story = new Story();
story.setId(1);
story.setName("海底小纵队(1.4)");
return story;
}
// 优先使用@ApiMapping
@ApiMapping(value = "story.get2")
public Story getStory2() {
Story story = new Story();
story.setId(1);
story.setName("海底小纵队story.get2");
return story;
}
}

@ -1,10 +1,7 @@
package com.gitee.sop.storyweb.controller; package com.gitee.sop.storyweb.controller;
import com.gitee.sop.servercommon.annotation.ApiAbility;
import com.gitee.sop.story.api.domain.Story; import com.gitee.sop.story.api.domain.Story;
import com.gitee.sop.story.api.service.StoryService; import com.gitee.sop.story.api.service.StoryService;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
@ -22,31 +19,5 @@ public class StoryController implements StoryService {
return story; return story;
} }
// 测试参数绑定
@ApiAbility
@GetMapping("getStory3")
public Story getStory3(String id) {
System.out.println(id);
Story story = new Story();
story.setId(1);
story.setName("海底小纵队(默认版本号)");
return story;
}
// 测试参数绑定,http://localhost:2222/story/getStory4?biz_content={"id":1, "name":"aaaa"}
@ApiAbility
@GetMapping("getStory4")
public Story getStory4(Story param, P p2) {
System.out.println(param + ", p2=" + p2);
Story story = new Story();
story.setId(1);
story.setName("海底小纵队(默认版本号)");
return story;
}
@Data
public static class P {
private String name;
}
} }

@ -0,0 +1,13 @@
package com.gitee.sop.storyweb.controller.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CategoryParam {
@ApiModelProperty(value = "分类名称", example = "娱乐")
private String categoryName;
@ApiModelProperty(value = "分类故事")
private StoryParam storyParam;
}

@ -0,0 +1,13 @@
package com.gitee.sop.storyweb.controller.result;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CategoryResult {
@ApiModelProperty(value = "分类名称", example = "娱乐")
private String categoryName;
@ApiModelProperty(value = "分类故事")
private StoryResult storyResult;
}

@ -1,4 +1,4 @@
package com.gitee.sop.storyweb.vo; package com.gitee.sop.storyweb.controller.result;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -10,7 +10,7 @@ import java.util.List;
* @author tanghc * @author tanghc
*/ */
@Data @Data
public class FileUploadVO { public class FileUploadResult {
private List<FileMeta> files = new ArrayList(); private List<FileMeta> files = new ArrayList();

@ -0,0 +1,23 @@
package com.gitee.sop.storyweb.controller.result;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.util.Date;
/**
* @author tanghc
*/
@Data
public class StoryResult {
@ApiModelProperty(value = "故事ID", example = "1")
private Long id;
@ApiModelProperty(value = "故事名称", example = "海底小纵队")
private String name;
@ApiModelProperty(value = "创建时间", example = "2019-04-14 19:02:12")
private Date gmt_create;
}
Loading…
Cancel
Save