Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringCloud-study
提交
ea47eff3
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看板
提交
ea47eff3
编写于
1月 10, 2023
作者:
Q
qinyingjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:ribbon负载均衡调用
上级
d7abb067
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
781 addition
and
10 deletion
+781
-10
pom.xml
pom.xml
+3
-1
springcloud-service-goods-9100/pom.xml
springcloud-service-goods-9100/pom.xml
+7
-7
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/GoodsApplication9100.java
.../main/java/com/kwan/springcloud/GoodsApplication9100.java
+2
-2
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/controller/HelloController.java
...java/com/kwan/springcloud/controller/HelloController.java
+0
-0
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
.../kwan/springcloud/controller/KwanGoodsInfoController.java
+0
-0
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
.../main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
+0
-0
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
.../main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
+0
-0
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
...va/com/kwan/springcloud/service/KwanGoodsInfoService.java
+0
-0
springcloud-service-goods-9100/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
...an/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
+0
-0
springcloud-service-goods-9100/src/main/resources/application.yaml
...ud-service-goods-9100/src/main/resources/application.yaml
+5
-0
springcloud-service-goods-9100/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
...test/java/com/kwan/springcloud/GoodsApplicationTests.java
+0
-0
springcloud-service-goods-9200/pom.xml
springcloud-service-goods-9200/pom.xml
+77
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/GoodsApplication9200.java
.../main/java/com/kwan/springcloud/GoodsApplication9200.java
+15
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/controller/HelloController.java
...java/com/kwan/springcloud/controller/HelloController.java
+40
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
.../kwan/springcloud/controller/KwanGoodsInfoController.java
+80
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
.../main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
+17
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
.../main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
+55
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
...va/com/kwan/springcloud/service/KwanGoodsInfoService.java
+16
-0
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
...an/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
+19
-0
springcloud-service-goods-9200/src/main/resources/application.yaml
...ud-service-goods-9200/src/main/resources/application.yaml
+50
-0
springcloud-service-goods-9200/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
...test/java/com/kwan/springcloud/GoodsApplicationTests.java
+13
-0
springcloud-service-goods-9300/pom.xml
springcloud-service-goods-9300/pom.xml
+77
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/GoodsApplication9300.java
.../main/java/com/kwan/springcloud/GoodsApplication9300.java
+15
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/controller/HelloController.java
...java/com/kwan/springcloud/controller/HelloController.java
+40
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
.../kwan/springcloud/controller/KwanGoodsInfoController.java
+80
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
.../main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
+17
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
.../main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
+55
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
...va/com/kwan/springcloud/service/KwanGoodsInfoService.java
+16
-0
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
...an/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
+19
-0
springcloud-service-goods-9300/src/main/resources/application.yaml
...ud-service-goods-9300/src/main/resources/application.yaml
+50
-0
springcloud-service-goods-9300/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
...test/java/com/kwan/springcloud/GoodsApplicationTests.java
+13
-0
未找到文件。
pom.xml
浏览文件 @
ea47eff3
...
@@ -25,7 +25,9 @@
...
@@ -25,7 +25,9 @@
</properties>
</properties>
<modules>
<modules>
<module>
springcloud-service-goods
</module>
<module>
springcloud-service-goods-9100
</module>
<module>
springcloud-service-goods-9200
</module>
<module>
springcloud-service-goods-9300
</module>
<module>
springcloud-service-common
</module>
<module>
springcloud-service-common
</module>
<module>
springcloud-service-portal
</module>
<module>
springcloud-service-portal
</module>
<module>
springcloud-service-eureka
</module>
<module>
springcloud-service-eureka
</module>
...
...
springcloud-service-goods/pom.xml
→
springcloud-service-goods
-9100
/pom.xml
浏览文件 @
ea47eff3
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
<artifactId>
springcloud-service-parent
</artifactId>
<artifactId>
springcloud-service-parent
</artifactId>
<version>
1.0.0
</version>
<version>
1.0.0
</version>
</parent>
</parent>
<artifactId>
springcloud-service-goods
</artifactId>
<artifactId>
springcloud-service-goods
-9100
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
springcloud-service-goods
</name>
<name>
springcloud-service-goods
-9100
</name>
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
...
@@ -48,11 +48,11 @@
...
@@ -48,11 +48,11 @@
<version>
8.0.11
</version>
<version>
8.0.11
</version>
</dependency>
</dependency>
<!--扩展包 -->
<!--扩展包 -->
<!-- <dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
<!-- <version>3.5.2</version>-->
<!-- <version>3.5.2</version>-->
<!-- </dependency>-->
<!-- </dependency>-->
<!--监控-->
<!--监控-->
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
springcloud-service-goods
/src/main/java/com/kwan/springcloud/GoodsApplication
.java
→
springcloud-service-goods
-9100/src/main/java/com/kwan/springcloud/GoodsApplication9100
.java
浏览文件 @
ea47eff3
...
@@ -6,10 +6,10 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
...
@@ -6,10 +6,10 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@EnableEurekaClient
@EnableEurekaClient
@SpringBootApplication
@SpringBootApplication
public
class
GoodsApplication
{
public
class
GoodsApplication
9100
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GoodsApplication
.
class
,
args
);
SpringApplication
.
run
(
GoodsApplication
9100
.
class
,
args
);
}
}
}
}
springcloud-service-goods/src/main/java/com/kwan/springcloud/controller/HelloController.java
→
springcloud-service-goods
-9100
/src/main/java/com/kwan/springcloud/controller/HelloController.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
→
springcloud-service-goods
-9100
/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
→
springcloud-service-goods
-9100
/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
→
springcloud-service-goods
-9100
/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
→
springcloud-service-goods
-9100
/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
→
springcloud-service-goods
-9100
/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods/src/main/resources/application.yaml
→
springcloud-service-goods
-9100
/src/main/resources/application.yaml
浏览文件 @
ea47eff3
...
@@ -18,6 +18,11 @@ eureka:
...
@@ -18,6 +18,11 @@ eureka:
client
:
client
:
service-url
:
service-url
:
defaultZone
:
http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/
defaultZone
:
http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/
instance
:
lease-renewal-interval-in-seconds
:
2
#每间隔2s,向服务端发送一次心跳,证明自己依然"存活”
lease-expiration-duration-in-seconds
:
10
#告诉服务端,如果我10s之内没有给你发心跳,就代表我故障了,将我踢出掉
prefer-ip-address
:
true
#告诉服务端,服务实例以IP作为链接,而不是取机器名
instance-id
:
springcloud-service-goods-9100
#告诉服务端,服务实例的id,id要是唯一的
management
:
management
:
endpoints
:
endpoints
:
...
...
springcloud-service-goods/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
→
springcloud-service-goods
-9100
/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
浏览文件 @
ea47eff3
文件已移动
springcloud-service-goods-9200/pom.xml
0 → 100644
浏览文件 @
ea47eff3
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.kwan.springcloud
</groupId>
<artifactId>
springcloud-service-parent
</artifactId>
<version>
1.0.0
</version>
</parent>
<artifactId>
springcloud-service-goods-9200
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
springcloud-service-goods-9200
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Hoxton.SR12
</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.kwan.springcloud
</groupId>
<artifactId>
springcloud-service-common
</artifactId>
<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>
<scope>
test
</scope>
</dependency>
<!--mybatis-plus的springboot支持-->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.4.3
</version>
</dependency>
<!--mysql驱动-->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.11
</version>
</dependency>
<!--扩展包 -->
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
<!-- <version>3.5.2</version>-->
<!-- </dependency>-->
<!--监控-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-server
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/GoodsApplication9200.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
@EnableEurekaClient
@SpringBootApplication
public
class
GoodsApplication9200
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GoodsApplication9200
.
class
,
args
);
}
}
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/controller/HelloController.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.controller
;
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
;
import
java.util.List
;
@Slf4j
@RestController
public
class
HelloController
{
@Autowired
private
DiscoveryClient
client
;
@Autowired
private
Registration
registration
;
/**
* 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
(
JSONArray
.
toJSONString
(
instances
));
return
Result
.
ok
(
instances
);
}
}
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
0 → 100644
浏览文件 @
ea47eff3
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
;
@RestController
@RequestMapping
(
"kwanGoodsInfo"
)
public
class
KwanGoodsInfoController
{
/**
* 服务对象
*/
@Resource
private
KwanGoodsInfoService
kwanGoodsInfoService
;
/**
* 分页查询所有数据
*
* @param page 分页对象
* @param kwanGoodsInfo 查询实体
* @return 所有数据
*/
@GetMapping
public
Result
selectAll
(
Page
<
KwanGoodsInfo
>
page
,
KwanGoodsInfo
kwanGoodsInfo
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
page
(
page
,
new
QueryWrapper
<>(
kwanGoodsInfo
)));
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping
(
value
=
"{id}"
,
produces
=
MediaType
.
APPLICATION_PROBLEM_JSON_VALUE
)
public
Result
selectOne
(
@PathVariable
Serializable
id
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
getById
(
id
));
}
/**
* 新增数据
*
* @param kwanGoodsInfo 实体对象
* @return 新增结果
*/
@PostMapping
public
Result
insert
(
@RequestBody
KwanGoodsInfo
kwanGoodsInfo
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
save
(
kwanGoodsInfo
));
}
/**
* 修改数据
*
* @param kwanGoodsInfo 实体对象
* @return 修改结果
*/
@PutMapping
public
Result
update
(
@RequestBody
KwanGoodsInfo
kwanGoodsInfo
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
updateById
(
kwanGoodsInfo
));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
public
Result
delete
(
@RequestParam
(
"idList"
)
List
<
Long
>
idList
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
removeByIds
(
idList
));
}
}
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* (KwanGoodsInfo)表数据库访问层
*
* @author makejava
* @since 2023-01-08 10:21:28
*/
@Mapper
public
interface
KwanGoodsInfoDao
extends
BaseMapper
<
KwanGoodsInfo
>
{
}
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.entity
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
java.io.Serializable
;
/**
* (KwanGoodsInfo)表实体类
*
* @author makejava
* @since 2023-01-08 10:21:28
*/
public
class
KwanGoodsInfo
extends
Model
<
KwanGoodsInfo
>
{
private
Integer
id
;
//商品名称
private
String
goodsName
;
//商品价格
private
Integer
goodsPrice
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getGoodsName
()
{
return
goodsName
;
}
public
void
setGoodsName
(
String
goodsName
)
{
this
.
goodsName
=
goodsName
;
}
public
Integer
getGoodsPrice
()
{
return
goodsPrice
;
}
public
void
setGoodsPrice
(
Integer
goodsPrice
)
{
this
.
goodsPrice
=
goodsPrice
;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
public
Serializable
pkVal
()
{
return
this
.
id
;
}
}
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
/**
* (KwanGoodsInfo)表服务接口
*
* @author makejava
* @since 2023-01-08 10:21:29
*/
public
interface
KwanGoodsInfoService
extends
IService
<
KwanGoodsInfo
>
{
}
springcloud-service-goods-9200/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springcloud.dao.KwanGoodsInfoDao
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
import
com.kwan.springcloud.service.KwanGoodsInfoService
;
import
org.springframework.stereotype.Service
;
/**
* (KwanGoodsInfo)表服务实现类
*
* @author makejava
* @since 2023-01-08 10:21:30
*/
@Service
(
"kwanGoodsInfoService"
)
public
class
KwanGoodsInfoServiceImpl
extends
ServiceImpl
<
KwanGoodsInfoDao
,
KwanGoodsInfo
>
implements
KwanGoodsInfoService
{
}
springcloud-service-goods-9200/src/main/resources/application.yaml
0 → 100644
浏览文件 @
ea47eff3
#端口号
server
:
port
:
9200
#兼容swagger配置
spring
:
# mysql
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://localhost:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username
:
root
password
:
716288qwe
application
:
name
:
goods-service
#服务名称
#服务提供者
eureka
:
client
:
service-url
:
defaultZone
:
http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/
instance
:
lease-renewal-interval-in-seconds
:
2
#每间隔2s,向服务端发送一次心跳,证明自己依然"存活”
lease-expiration-duration-in-seconds
:
10
#告诉服务端,如果我10s之内没有给你发心跳,就代表我故障了,将我踢出掉
prefer-ip-address
:
true
#告诉服务端,服务实例以IP作为链接,而不是取机器名
instance-id
:
springcloud-service-goods-9200
#告诉服务端,服务实例的id,id要是唯一的
management
:
endpoints
:
web
:
base-path
:
/actuator
#修改访问路径 2.0之前默认是/ 2.0默认是 /actuator 可以通过这个属性值修改
health
:
show-details
:
always
#显示健康具体信息 默认不会显示详细信息
#mybatis-plus配置
mybatis-plus
:
configuration
:
map-underscore-to-camel-case
:
true
call-setters-on-nulls
:
true
auto-mapping-behavior
:
full
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations
:
classpath*:mapper/**/*Mapper.xml
global-config
:
banner
:
false
# 逻辑删除配置
db-config
:
id-type
:
AUTO
logic-delete-field
:
delFlag
logic-delete-value
:
1
logic-not-delete-value
:
0
table-underline
:
true
\ No newline at end of file
springcloud-service-goods-9200/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
GoodsApplicationTests
{
@Test
void
contextLoads
()
{
}
}
springcloud-service-goods-9300/pom.xml
0 → 100644
浏览文件 @
ea47eff3
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.kwan.springcloud
</groupId>
<artifactId>
springcloud-service-parent
</artifactId>
<version>
1.0.0
</version>
</parent>
<artifactId>
springcloud-service-goods-9300
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<name>
springcloud-service-goods-9300
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Hoxton.SR12
</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.kwan.springcloud
</groupId>
<artifactId>
springcloud-service-common
</artifactId>
<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>
<scope>
test
</scope>
</dependency>
<!--mybatis-plus的springboot支持-->
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<version>
3.4.3
</version>
</dependency>
<!--mysql驱动-->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.11
</version>
</dependency>
<!--扩展包 -->
<!-- <dependency>-->
<!-- <groupId>com.baomidou</groupId>-->
<!-- <artifactId>mybatis-plus-extension</artifactId>-->
<!-- <version>3.5.2</version>-->
<!-- </dependency>-->
<!--监控-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-server
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/GoodsApplication9300.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
@EnableEurekaClient
@SpringBootApplication
public
class
GoodsApplication9300
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
GoodsApplication9300
.
class
,
args
);
}
}
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/controller/HelloController.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.controller
;
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
;
import
java.util.List
;
@Slf4j
@RestController
public
class
HelloController
{
@Autowired
private
DiscoveryClient
client
;
@Autowired
private
Registration
registration
;
/**
* 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
(
JSONArray
.
toJSONString
(
instances
));
return
Result
.
ok
(
instances
);
}
}
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/controller/KwanGoodsInfoController.java
0 → 100644
浏览文件 @
ea47eff3
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
;
@RestController
@RequestMapping
(
"kwanGoodsInfo"
)
public
class
KwanGoodsInfoController
{
/**
* 服务对象
*/
@Resource
private
KwanGoodsInfoService
kwanGoodsInfoService
;
/**
* 分页查询所有数据
*
* @param page 分页对象
* @param kwanGoodsInfo 查询实体
* @return 所有数据
*/
@GetMapping
public
Result
selectAll
(
Page
<
KwanGoodsInfo
>
page
,
KwanGoodsInfo
kwanGoodsInfo
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
page
(
page
,
new
QueryWrapper
<>(
kwanGoodsInfo
)));
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping
(
value
=
"{id}"
,
produces
=
MediaType
.
APPLICATION_PROBLEM_JSON_VALUE
)
public
Result
selectOne
(
@PathVariable
Serializable
id
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
getById
(
id
));
}
/**
* 新增数据
*
* @param kwanGoodsInfo 实体对象
* @return 新增结果
*/
@PostMapping
public
Result
insert
(
@RequestBody
KwanGoodsInfo
kwanGoodsInfo
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
save
(
kwanGoodsInfo
));
}
/**
* 修改数据
*
* @param kwanGoodsInfo 实体对象
* @return 修改结果
*/
@PutMapping
public
Result
update
(
@RequestBody
KwanGoodsInfo
kwanGoodsInfo
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
updateById
(
kwanGoodsInfo
));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
public
Result
delete
(
@RequestParam
(
"idList"
)
List
<
Long
>
idList
)
{
return
Result
.
ok
(
this
.
kwanGoodsInfoService
.
removeByIds
(
idList
));
}
}
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/dao/KwanGoodsInfoDao.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* (KwanGoodsInfo)表数据库访问层
*
* @author makejava
* @since 2023-01-08 10:21:28
*/
@Mapper
public
interface
KwanGoodsInfoDao
extends
BaseMapper
<
KwanGoodsInfo
>
{
}
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/entity/KwanGoodsInfo.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.entity
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
java.io.Serializable
;
/**
* (KwanGoodsInfo)表实体类
*
* @author makejava
* @since 2023-01-08 10:21:28
*/
public
class
KwanGoodsInfo
extends
Model
<
KwanGoodsInfo
>
{
private
Integer
id
;
//商品名称
private
String
goodsName
;
//商品价格
private
Integer
goodsPrice
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getGoodsName
()
{
return
goodsName
;
}
public
void
setGoodsName
(
String
goodsName
)
{
this
.
goodsName
=
goodsName
;
}
public
Integer
getGoodsPrice
()
{
return
goodsPrice
;
}
public
void
setGoodsPrice
(
Integer
goodsPrice
)
{
this
.
goodsPrice
=
goodsPrice
;
}
/**
* 获取主键值
*
* @return 主键值
*/
@Override
public
Serializable
pkVal
()
{
return
this
.
id
;
}
}
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/service/KwanGoodsInfoService.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
/**
* (KwanGoodsInfo)表服务接口
*
* @author makejava
* @since 2023-01-08 10:21:29
*/
public
interface
KwanGoodsInfoService
extends
IService
<
KwanGoodsInfo
>
{
}
springcloud-service-goods-9300/src/main/java/com/kwan/springcloud/service/impl/KwanGoodsInfoServiceImpl.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springcloud.dao.KwanGoodsInfoDao
;
import
com.kwan.springcloud.entity.KwanGoodsInfo
;
import
com.kwan.springcloud.service.KwanGoodsInfoService
;
import
org.springframework.stereotype.Service
;
/**
* (KwanGoodsInfo)表服务实现类
*
* @author makejava
* @since 2023-01-08 10:21:30
*/
@Service
(
"kwanGoodsInfoService"
)
public
class
KwanGoodsInfoServiceImpl
extends
ServiceImpl
<
KwanGoodsInfoDao
,
KwanGoodsInfo
>
implements
KwanGoodsInfoService
{
}
springcloud-service-goods-9300/src/main/resources/application.yaml
0 → 100644
浏览文件 @
ea47eff3
#端口号
server
:
port
:
9300
#兼容swagger配置
spring
:
# mysql
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://localhost:3306/kwan?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username
:
root
password
:
716288qwe
application
:
name
:
goods-service
#服务名称
#服务提供者
eureka
:
client
:
service-url
:
defaultZone
:
http://eureka8767:8767/eureka/,http://eureka8768:8768/eureka/,http://eureka8769:8769/eureka/
instance
:
lease-renewal-interval-in-seconds
:
2
#每间隔2s,向服务端发送一次心跳,证明自己依然"存活”
lease-expiration-duration-in-seconds
:
10
#告诉服务端,如果我10s之内没有给你发心跳,就代表我故障了,将我踢出掉
prefer-ip-address
:
true
#告诉服务端,服务实例以IP作为链接,而不是取机器名
instance-id
:
springcloud-service-goods-9300
#告诉服务端,服务实例的id,id要是唯一的
management
:
endpoints
:
web
:
base-path
:
/actuator
#修改访问路径 2.0之前默认是/ 2.0默认是 /actuator 可以通过这个属性值修改
health
:
show-details
:
always
#显示健康具体信息 默认不会显示详细信息
#mybatis-plus配置
mybatis-plus
:
configuration
:
map-underscore-to-camel-case
:
true
call-setters-on-nulls
:
true
auto-mapping-behavior
:
full
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations
:
classpath*:mapper/**/*Mapper.xml
global-config
:
banner
:
false
# 逻辑删除配置
db-config
:
id-type
:
AUTO
logic-delete-field
:
delFlag
logic-delete-value
:
1
logic-not-delete-value
:
0
table-underline
:
true
\ No newline at end of file
springcloud-service-goods-9300/src/test/java/com/kwan/springcloud/GoodsApplicationTests.java
0 → 100644
浏览文件 @
ea47eff3
package
com.kwan.springcloud
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
GoodsApplicationTests
{
@Test
void
contextLoads
()
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录