mirror of
https://gitee.com/durcframework/SOP.git
synced 2025-08-11 21:57:56 +08:00
demo整理
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.gitee.sop.storyweb.controller;
|
package com.gitee.sop.storyweb.controller;
|
||||||
|
|
||||||
|
import com.gitee.sop.servercommon.annotation.ApiAbility;
|
||||||
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.param.StoryParam;
|
import com.gitee.sop.storyweb.controller.param.StoryParam;
|
||||||
@@ -7,6 +8,8 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -14,13 +17,71 @@ import java.util.Date;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝服务端,假设签名验证通过后,到达这里进行具体的业务处理。
|
* 支付宝服务端,假设签名验证通过后,到达这里进行具体的业务处理。
|
||||||
* 这里演示如何接受业务参数。
|
|
||||||
* @author tanghc
|
* @author tanghc
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@Api(tags = "故事接口")
|
@Api(tags = "故事接口")
|
||||||
public class AlipayController {
|
public class AlipayController {
|
||||||
|
|
||||||
|
// http://localhost:2222/story_get
|
||||||
|
// 原生的接口,可正常调用
|
||||||
|
@RequestMapping("story_get")
|
||||||
|
public Story getStory4() {
|
||||||
|
Story story = new Story();
|
||||||
|
story.setId(1);
|
||||||
|
story.setName("海底小纵队(原生)");
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://localhost:2222/story.get/
|
||||||
|
// 接口名,使用默认版本号
|
||||||
|
@ApiMapping(value = "story.get")
|
||||||
|
public Story storyget() {
|
||||||
|
Story story = new Story();
|
||||||
|
story.setId(1);
|
||||||
|
story.setName("海底小纵队(默认版本号)");
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://localhost:2222/story.get/?version=1.1
|
||||||
|
// 接口名 + 版本号
|
||||||
|
@ApiMapping(value = "story.get", version = "1.1")
|
||||||
|
public Story getStory2() {
|
||||||
|
Story story = new Story();
|
||||||
|
story.setId(1);
|
||||||
|
story.setName("海底小纵队1.0");
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://localhost:2222/story.get/?name=111&version=2.0
|
||||||
|
// 接口名 + 版本号
|
||||||
|
@ApiMapping(value = "story.get", version = "2.0")
|
||||||
|
public Story getStory20(Story story) {
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://localhost:2222/getStory2
|
||||||
|
// 遗留接口具备开放平台能力
|
||||||
|
@ApiAbility
|
||||||
|
@GetMapping("getStory2")
|
||||||
|
public Story getStory2_0() {
|
||||||
|
Story story = new Story();
|
||||||
|
story.setId(1);
|
||||||
|
story.setName("海底小纵队(默认版本号)");
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
|
// http://localhost:2222/getStory2?version=2.1
|
||||||
|
// 遗留接口具备开放平台能力,在原来的基础上加版本号
|
||||||
|
@ApiAbility(version = "2.1")
|
||||||
|
@RequestMapping("getStory2")
|
||||||
|
public Story getStory2_1() {
|
||||||
|
Story story = new Story();
|
||||||
|
story.setId(1);
|
||||||
|
story.setName("海底小纵队2.1");
|
||||||
|
return story;
|
||||||
|
}
|
||||||
|
|
||||||
@ApiMapping(value = "alipay.story.get")
|
@ApiMapping(value = "alipay.story.get")
|
||||||
public Story getStory() {
|
public Story getStory() {
|
||||||
Story story = new Story();
|
Story story = new Story();
|
||||||
@@ -29,10 +90,18 @@ public class AlipayController {
|
|||||||
return story;
|
return story;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数绑定
|
||||||
|
* @param story 对应biz_content中的内容,并自动JSR-303校验
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。")
|
@ApiOperation(value = "获取故事信息", notes = "说明接口的详细信息,介绍,用途,注意事项等。")
|
||||||
@ApiMapping(value = "alipay.story.find")
|
@ApiMapping(value = "alipay.story.find")
|
||||||
// 参数必须封装在类中
|
|
||||||
public StoryVO getStory2(StoryParam story, HttpServletRequest request) {
|
public StoryVO getStory2(StoryParam story, HttpServletRequest request) {
|
||||||
|
System.out.println(story);
|
||||||
|
// 获取其它参数
|
||||||
|
System.out.println(request.getParameter("app_id"));
|
||||||
StoryVO storyVO = new StoryVO();
|
StoryVO storyVO = new StoryVO();
|
||||||
storyVO.id = 1L;
|
storyVO.id = 1L;
|
||||||
storyVO.name = "白雪公主";
|
storyVO.name = "白雪公主";
|
||||||
@@ -40,6 +109,11 @@ public class AlipayController {
|
|||||||
return storyVO;
|
return storyVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param story 对应biz_content中的内容,并自动JSR-303校验
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@ApiMapping(value = "alipay.story.get", version = "1.2")
|
@ApiMapping(value = "alipay.story.get", version = "1.2")
|
||||||
public Story getStory11(Story story) {
|
public Story getStory11(Story story) {
|
||||||
return story;
|
return story;
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
package com.gitee.sop.storyweb.controller;
|
package com.gitee.sop.storyweb.controller;
|
||||||
|
|
||||||
import com.gitee.sop.servercommon.annotation.ApiAbility;
|
import com.gitee.sop.servercommon.annotation.ApiAbility;
|
||||||
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.story.api.service.StoryService;
|
import com.gitee.sop.story.api.service.StoryService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
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.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,65 +22,6 @@ public class StoryController implements StoryService {
|
|||||||
return story;
|
return story;
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://localhost:2222/story/story_get
|
|
||||||
// 原生的接口,可正常调用
|
|
||||||
@RequestMapping("story_get")
|
|
||||||
public Story getStory4() {
|
|
||||||
Story story = new Story();
|
|
||||||
story.setId(1);
|
|
||||||
story.setName("海底小纵队(原生)");
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://localhost:2222/story/story.get/
|
|
||||||
// 接口名,使用默认版本号
|
|
||||||
@ApiMapping(value = "story.get")
|
|
||||||
public Story storyget() {
|
|
||||||
Story story = new Story();
|
|
||||||
story.setId(1);
|
|
||||||
story.setName("海底小纵队(默认版本号)");
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://localhost:2222/story/story.get/?version=1.1
|
|
||||||
// 接口名 + 版本号
|
|
||||||
@ApiMapping(value = "story.get", version = "1.1")
|
|
||||||
public Story getStory2() {
|
|
||||||
Story story = new Story();
|
|
||||||
story.setId(1);
|
|
||||||
story.setName("海底小纵队1.0");
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://localhost:2222/story/story.get/?version=2.0
|
|
||||||
// 接口名 + 版本号
|
|
||||||
@ApiMapping(value = "story.get", version = "2.0")
|
|
||||||
public Story getStory20(Story story) {
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://localhost:2222/story/getStory2
|
|
||||||
// 遗留接口具备开放平台能力
|
|
||||||
@ApiAbility
|
|
||||||
@GetMapping("getStory2")
|
|
||||||
public Story getStory2_0() {
|
|
||||||
Story story = new Story();
|
|
||||||
story.setId(1);
|
|
||||||
story.setName("海底小纵队(默认版本号)");
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://localhost:2222/story/getStory2?version=2.1
|
|
||||||
// 在原来的基础上加版本号
|
|
||||||
@ApiAbility(version = "2.1")
|
|
||||||
@RequestMapping("getStory2")
|
|
||||||
public Story getStory2_1() {
|
|
||||||
Story story = new Story();
|
|
||||||
story.setId(1);
|
|
||||||
story.setName("海底小纵队2.1");
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 测试参数绑定
|
// 测试参数绑定
|
||||||
@ApiAbility
|
@ApiAbility
|
||||||
@GetMapping("getStory3")
|
@GetMapping("getStory3")
|
||||||
|
Reference in New Issue
Block a user