Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringCloud-study
提交
8279e992
S
SpringCloud-study
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
SpringCloud-study
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringCloud-study
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8279e992
编写于
1月 09, 2023
作者:
Q
qinyingjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:微服务代码
上级
b941f0aa
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
32 addition
and
25 deletion
+32
-25
springcloud-service-common/pom.xml
springcloud-service-common/pom.xml
+7
-0
springcloud-service-common/src/main/java/com/kwan/springcloud/response/Result.java
...n/src/main/java/com/kwan/springcloud/response/Result.java
+1
-1
springcloud-service-eureka/pom.xml
springcloud-service-eureka/pom.xml
+5
-0
springcloud-service-goods/pom.xml
springcloud-service-goods/pom.xml
+6
-8
springcloud-service-goods/src/main/java/com/kwan/springcloud/controller/HelloController.java
...java/com/kwan/springcloud/controller/HelloController.java
+11
-8
springcloud-service-goods/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
.../kwan/springcloud/controller/KwanGoodsInfoController.java
+2
-8
未找到文件。
springcloud-service-common/pom.xml
浏览文件 @
8279e992
...
...
@@ -35,6 +35,13 @@
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.83
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
springcloud-service-common/src/main/java/com/kwan/springcloud/response/Result.java
浏览文件 @
8279e992
...
...
@@ -76,7 +76,7 @@ public class Result<T> implements Serializable {
}
public
static
Result
<
Object
>
ok
(
String
msg
)
{
Result
<
Object
>
r
=
new
Result
<
Object
>();
Result
<
Object
>
r
=
new
Result
<>();
r
.
setSuccess
(
true
);
r
.
setCode
(
CommonConstant
.
SC_OK_200
);
r
.
setMessage
(
msg
);
...
...
springcloud-service-eureka/pom.xml
浏览文件 @
8279e992
...
...
@@ -34,6 +34,11 @@
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
...
...
springcloud-service-goods/pom.xml
浏览文件 @
8279e992
...
...
@@ -23,6 +23,12 @@
<version>
1.0.0
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
...
...
@@ -57,14 +63,6 @@
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-server
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.9.0
</version>
</dependency>
</dependencies>
<build>
...
...
springcloud-service-goods/src/main/java/com/kwan/springcloud/controller/HelloController.java
浏览文件 @
8279e992
package
com.kwan.springcloud.controller
;
import
com.google.gson.Gson
;
import
com.alibaba.fastjson.JSONArray
;
import
com.kwan.springcloud.response.Result
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -22,14 +24,15 @@ public class HelloController {
private
Registration
registration
;
@RequestMapping
(
"/hello"
)
public
String
index
()
{
/**
* produces = MediaType.APPLICATION_PROBLEM_JSON_VALUE
* 解决不是json显示问题
*/
@RequestMapping
(
value
=
"/hello"
,
produces
=
MediaType
.
APPLICATION_PROBLEM_JSON_VALUE
)
public
Result
index
()
{
List
<
ServiceInstance
>
instances
=
client
.
getInstances
(
registration
.
getServiceId
());
log
.
info
(
new
Gson
().
toJson
(
instances
));
return
"hello world"
;
log
.
info
(
JSONArray
.
toJSONString
(
instances
));
return
Result
.
ok
(
instances
);
}
}
...
...
springcloud-service-goods/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
浏览文件 @
8279e992
package
com.kwan.springcloud.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
import
com.kwan.springcloud.response.Result
;
import
com.kwan.springcloud.service.KwanGoodsInfoService
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* (KwanGoodsInfo)表控制层
*
* @author makejava
* @since 2023-01-08 10:21:26
*/
@RestController
@RequestMapping
(
"kwanGoodsInfo"
)
public
class
KwanGoodsInfoController
{
...
...
@@ -45,7 +39,7 @@ public class KwanGoodsInfoController {
* @param id 主键
* @return 单条数据
*/
@GetMapping
(
"{id}"
)
@GetMapping
(
value
=
"{id}"
,
produces
=
MediaType
.
APPLICATION_PROBLEM_JSON_VALUE
)
public
Result
selectOne
(
@PathVariable
Serializable
id
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
getById
(
id
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录