whyclxw
2024-09-25 cbc41c9d271b6b13395d007884abd33d679f6c8e
测试服务器
2个文件已添加
45 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/TestParamController.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/TestParamService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/TestParamController.java
New file
@@ -0,0 +1,25 @@
package com.whyc.controller;
import com.whyc.pojo.Response;
import com.whyc.service.TestParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(("testParam"))
@Api(tags = "测试服务器")
public class TestParamController {
    @Autowired
    private TestParamService service;
    @ApiOperation("服务调用测试")
    @GetMapping("callService")
    public Response callService(@RequestParam Integer seconds) throws InterruptedException {
        service.callService(seconds);
        return new Response().set(1,"调用服务成功!");
    }
}
src/main/java/com/whyc/service/TestParamService.java
New file
@@ -0,0 +1,20 @@
package com.whyc.service;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class TestParamService {
    public void callService(int seconds) throws InterruptedException {
        //毫秒
        int milliseconds = seconds * 1000;
        int count = milliseconds/100;
        for (int i = 0; i < count; i++) {
            Thread.sleep(100);
        }
    }
}