初始化git 基础代码
This commit is contained in:
8
heima-leadnews-feign-api/heima-leadnews-feign-api.iml
Normal file
8
heima-leadnews-feign-api/heima-leadnews-feign-api.iml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
||||
34
heima-leadnews-feign-api/pom.xml
Normal file
34
heima-leadnews-feign-api/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>heima-leadnews</artifactId>
|
||||
<groupId>com.heima</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>heima-leadnews-feign-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.heima</groupId>
|
||||
<artifactId>heima-leadnews-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.heima</groupId>
|
||||
<artifactId>heima-leadnews-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.heima.apis.article;
|
||||
|
||||
import com.heima.apis.article.fallback.IArticleClientFallback;
|
||||
import com.heima.model.article.dtos.ArticleDto;
|
||||
import com.heima.model.common.dtos.ResponseResult;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(value = "leadnews-article",fallback = IArticleClientFallback.class)
|
||||
public interface IArticleClient {
|
||||
|
||||
|
||||
|
||||
@PostMapping("/api/v1/article/save")
|
||||
public ResponseResult saveArticle(@RequestBody ArticleDto dto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.heima.apis.article.fallback;
|
||||
|
||||
import com.heima.apis.article.IArticleClient;
|
||||
import com.heima.model.article.dtos.ArticleDto;
|
||||
import com.heima.model.common.dtos.ResponseResult;
|
||||
import com.heima.model.common.enums.AppHttpCodeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class IArticleClientFallback implements IArticleClient {
|
||||
@Override
|
||||
public ResponseResult saveArticle(ArticleDto dto) {
|
||||
return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.heima.apis.schedule;
|
||||
|
||||
import com.heima.model.common.dtos.ResponseResult;
|
||||
import com.heima.model.schedule.dtos.Task;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient("leadnews-schedule")
|
||||
public interface IScheduleClient {
|
||||
/**
|
||||
* 添加任务
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/v1/task/add")
|
||||
public ResponseResult addTask(@RequestBody Task task);
|
||||
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/api/v1/task/{taskId}")
|
||||
public ResponseResult cancelTask(@PathVariable("taskId") long taskId);
|
||||
|
||||
/**
|
||||
* 按照类型和优先级获取任务
|
||||
* @param type
|
||||
* @param priority
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/api/v1/task/{type}/{priority}")
|
||||
public ResponseResult poll(@PathVariable("type") int type,@PathVariable("priority") int priority);
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user