Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
a34eee65
提交
a34eee65
authored
4月 08, 2019
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
后端:增加 cart 系统
上级
235da59f
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
443 行增加
和
21 行删除
+443
-21
pom.xml
cart/cart-application/pom.xml
+70
-0
CartApplication.java
...ava/cn/iocoder/mall/cart/application/CartApplication.java
+13
-0
MVCConfiguration.java
...ocoder/mall/cart/application/config/MVCConfiguration.java
+42
-0
SwaggerConfiguration.java
...er/mall/cart/application/config/SwaggerConfiguration.java
+36
-0
application.yaml
cart/cart-application/src/main/resources/application.yaml
+9
-0
pom.xml
cart/cart-service-api/pom.xml
+40
-0
CartService.java
...i/src/main/java/cn/iocoder/mall/cart/api/CartService.java
+4
-0
CartErrorCodeEnum.java
.../cn/iocoder/mall/cart/api/constant/CartErrorCodeEnum.java
+28
-0
pom.xml
cart/cart-service-impl/pom.xml
+66
-0
DatabaseConfiguration.java
...n/iocoder/mall/cart/biz/config/DatabaseConfiguration.java
+14
-0
ServiceExceptionConfiguration.java
...r/mall/cart/biz/config/ServiceExceptionConfiguration.java
+19
-0
package-info.java
.../src/main/java/cn/iocoder/mall/cart/biz/package-info.java
+1
-0
application.properties
...ice-impl/src/main/resources/config/application.properties
+2
-0
application.yaml
...t-service-impl/src/main/resources/config/application.yaml
+44
-0
mybatis-config.xml
cart/cart-service-impl/src/main/resources/mybatis-config.xml
+20
-0
pom.xml
cart/pom.xml
+21
-0
ModuleErrorCodeInterval.java
...er/common/framework/constant/ModuleErrorCodeInterval.java
+2
-3
pom.xml
pay/pay-application/pom.xml
+0
-5
pom.xml
pay/pay-service-api/pom.xml
+1
-0
pom.xml
pay/pay-service-impl/pom.xml
+0
-4
pom.xml
pom.xml
+1
-0
MVCConfiguration.java
...der/mall/product/application/config/MVCConfiguration.java
+10
-9
没有找到文件。
cart/cart-application/pom.xml
0 → 100644
浏览文件 @
a34eee65
<?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>
cart
</artifactId>
<groupId>
cn.iocoder.mall
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cart-application
</artifactId>
<dependencies>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
common-framework
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
user-sdk
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</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>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
dubbo
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba.boot
</groupId>
<artifactId>
dubbo-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-framework
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
</dependency>
</dependencies>
</project>
cart/cart-application/src/main/java/cn/iocoder/mall/cart/application/CartApplication.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
application
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
(
scanBasePackages
=
{
"cn.iocoder.mall.cart"
})
public
class
CartApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
CartApplication
.
class
,
args
);
}
}
cart/cart-application/src/main/java/cn/iocoder/mall/cart/application/config/MVCConfiguration.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
application
.
config
;
import
cn.iocoder.common.framework.config.GlobalExceptionHandler
;
import
cn.iocoder.common.framework.servlet.CorsFilter
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.web.servlet.config.annotation.*
;
@EnableWebMvc
@Configuration
@Import
(
value
=
{
GlobalExceptionHandler
.
class
})
// 统一全局返回
public
class
MVCConfiguration
implements
WebMvcConfigurer
{
// @Autowired
// private SecurityInterceptor securityInterceptor;
// @Reference
// private OAuth2Service oauth2Service;
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
// registry.addInterceptor(securityInterceptor);
}
@Override
public
void
addResourceHandlers
(
ResourceHandlerRegistry
registry
)
{
// 解决 swagger-ui.html 的访问,参考自 https://stackoverflow.com/questions/43545540/swagger-ui-no-mapping-found-for-http-request 解决
registry
.
addResourceHandler
(
"swagger-ui.html**"
).
addResourceLocations
(
"classpath:/META-INF/resources/swagger-ui.html"
);
registry
.
addResourceHandler
(
"webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
@Bean
public
FilterRegistrationBean
<
CorsFilter
>
corsFilter
()
{
FilterRegistrationBean
<
CorsFilter
>
registrationBean
=
new
FilterRegistrationBean
<>();
registrationBean
.
setFilter
(
new
CorsFilter
());
registrationBean
.
addUrlPatterns
(
"/*"
);
return
registrationBean
;
}
}
cart/cart-application/src/main/java/cn/iocoder/mall/cart/application/config/SwaggerConfiguration.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
application
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
@Configuration
@EnableSwagger2
public
class
SwaggerConfiguration
{
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"cn.iocoder.mall.biz.application.controller"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"购物车子系统"
)
.
description
(
"购物车子系统"
)
.
termsOfServiceUrl
(
"http://www.iocoder.cn"
)
.
version
(
"1.0.0"
)
.
build
();
}
}
cart/cart-application/src/main/resources/application.yaml
0 → 100644
浏览文件 @
a34eee65
spring
:
application
:
name
:
cart-application
# server
server
:
port
:
18086
servlet
:
context-path
:
/cart-api/
cart/cart-service-api/pom.xml
0 → 100644
浏览文件 @
a34eee65
<?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>
cart
</artifactId>
<groupId>
cn.iocoder.mall
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cart-service-api
</artifactId>
<dependencies>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
common-framework
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
javax.validation
</groupId>
<artifactId>
validation-api
</artifactId>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct
</artifactId>
<!-- use mapstruct-jdk8 for Java 8 or higher -->
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-jdk8
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
</dependency>
</dependencies>
</project>
cart/cart-service-api/src/main/java/cn/iocoder/mall/cart/api/CartService.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
api
;
public
interface
CartService
{
}
cart/cart-service-api/src/main/java/cn/iocoder/mall/cart/api/constant/CartErrorCodeEnum.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
api
.
constant
;
/**
* 错误码枚举类
*
* 购物车系统,使用 1-005-000-000 段
*/
public
enum
CartErrorCodeEnum
{
;
private
final
int
code
;
private
final
String
message
;
CartErrorCodeEnum
(
int
code
,
String
message
)
{
this
.
code
=
code
;
this
.
message
=
message
;
}
public
int
getCode
()
{
return
code
;
}
public
String
getMessage
()
{
return
message
;
}
}
cart/cart-service-impl/pom.xml
0 → 100644
浏览文件 @
a34eee65
<?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>
cart
</artifactId>
<groupId>
cn.iocoder.mall
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cart-service-impl
</artifactId>
<dependencies>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
dubbo
</artifactId>
</dependency>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
cart-service-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
</dependency>
<dependency>
<groupId>
com.xuxueli
</groupId>
<artifactId>
xxl-job-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.rocketmq
</groupId>
<artifactId>
rocketmq-spring-boot-starter
</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 提供给 mapstruct 使用 -->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
cart/cart-service-impl/src/main/java/cn/iocoder/mall/cart/biz/config/DatabaseConfiguration.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
biz
.
config
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
@Configuration
@MapperScan
(
"cn.iocoder.mall.cart.biz.dao"
)
// 扫描对应的 Mapper 接口
@EnableTransactionManagement
(
proxyTargetClass
=
true
)
// 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
public
class
DatabaseConfiguration
{
// 数据源,使用 HikariCP
}
cart/cart-service-impl/src/main/java/cn/iocoder/mall/cart/biz/config/ServiceExceptionConfiguration.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
biz
.
config
;
import
cn.iocoder.common.framework.util.ServiceExceptionUtil
;
import
cn.iocoder.mall.cart.api.constant.CartErrorCodeEnum
;
import
org.springframework.boot.context.event.ApplicationReadyEvent
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.event.EventListener
;
@Configuration
public
class
ServiceExceptionConfiguration
{
@EventListener
(
ApplicationReadyEvent
.
class
)
// 可参考 https://www.cnblogs.com/ssslinppp/p/7607509.html
public
void
initMessages
()
{
for
(
CartErrorCodeEnum
item
:
CartErrorCodeEnum
.
values
())
{
ServiceExceptionUtil
.
put
(
item
.
getCode
(),
item
.
getMessage
());
}
}
}
cart/cart-service-impl/src/main/java/cn/iocoder/mall/cart/biz/package-info.java
0 → 100644
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
cart
.
biz
;
cart/cart-service-impl/src/main/resources/config/application.properties
0 → 100644
浏览文件 @
a34eee65
#####################
业务模块
#####################
\ No newline at end of file
cart/cart-service-impl/src/main/resources/config/application.yaml
0 → 100644
浏览文件 @
a34eee65
spring
:
# datasource
datasource
:
url
:
jdbc:mysql://180.167.213.26:13306/mall_cart?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name
:
com.mysql.jdbc.Driver
username
:
root
password
:
${MALL_MYSQL_PASSWORD}
# mybatis
mybatis
:
config-location
:
classpath:mybatis-config.xml
mapper-locations
:
classpath:mapper/*.xml
type-aliases-package
:
cn.iocoder.mall.cart.biz.dataobject
# dubbo
dubbo
:
application
:
name
:
cart-service
registry
:
address
:
zookeeper://127.0.0.1:2181
protocol
:
port
:
-1
name
:
dubbo
scan
:
base-packages
:
cn.iocoder.mall.cart.biz.service
# xxl-job
#xxl:
# job:
# admin:
# addresses: http://127.0.0.1:8080/xxl-job-admin
# executor:
# appname: cart-job-executor
# ip:
# port: 0
# logpath: /Users/yunai/logs/xxl-job/
# logretentiondays: 1
# accessToken:
# rocketmq
#rocketmq:
# name-server: 127.0.0.1:9876
# producer:
# group: cart-producer-group
cart/cart-service-impl/src/main/resources/mybatis-config.xml
0 → 100644
浏览文件 @
a34eee65
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 使用驼峰命名法转换字段。 -->
<setting
name=
"mapUnderscoreToCamelCase"
value=
"true"
/>
</settings>
<typeAliases>
<typeAlias
alias=
"Integer"
type=
"java.lang.Integer"
/>
<typeAlias
alias=
"Long"
type=
"java.lang.Long"
/>
<typeAlias
alias=
"HashMap"
type=
"java.util.HashMap"
/>
<typeAlias
alias=
"LinkedHashMap"
type=
"java.util.LinkedHashMap"
/>
<typeAlias
alias=
"ArrayList"
type=
"java.util.ArrayList"
/>
<typeAlias
alias=
"LinkedList"
type=
"java.util.LinkedList"
/>
</typeAliases>
</configuration>
\ No newline at end of file
cart/pom.xml
0 → 100644
浏览文件 @
a34eee65
<?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>
mall-parent
</artifactId>
<groupId>
cn.iocoder.mall
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
cart
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
cart-application
</module>
<module>
cart-service-api
</module>
<module>
cart-service-impl
</module>
</modules>
</project>
common/common-framework/src/main/java/cn/iocoder/common/framework/constant/ModuleErrorCodeInterval.java
浏览文件 @
a34eee65
...
...
@@ -27,9 +27,9 @@ public class ModuleErrorCodeInterval {
// pay 错误码区间 [1-004-000-000 ~ 1-005-000-000)
// cart 错误码区间 [1-005-000-000 ~ 1-006-000-000)
// promotion 错误码区间 [1-006-000-000 ~ 1-007-000-000)
}
\ No newline at end of file
}
pay/pay-application/pom.xml
浏览文件 @
a34eee65
...
...
@@ -11,12 +11,7 @@
<artifactId>
pay-application
</artifactId>
<properties>
<org.mapstruct.version>
1.3.0.Final
</org.mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
common-framework
</artifactId>
...
...
pay/pay-service-api/pom.xml
浏览文件 @
a34eee65
...
...
@@ -10,6 +10,7 @@
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
pay-service-api
</artifactId>
<dependencies>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
...
...
pay/pay-service-impl/pom.xml
浏览文件 @
a34eee65
...
...
@@ -11,10 +11,6 @@
<artifactId>
pay-service-impl
</artifactId>
<properties>
<org.mapstruct.version>
1.3.0.Final
</org.mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.alibaba
</groupId>
...
...
pom.xml
浏览文件 @
a34eee65
...
...
@@ -22,6 +22,7 @@
<module>
ops
</module>
<module>
pay
</module>
<module>
promotion
</module>
<module>
cart
</module>
</modules>
<packaging>
pom
</packaging>
...
...
product/product-application/src/main/java/cn/iocoder/mall/product/application/config/MVCConfiguration.java
浏览文件 @
a34eee65
package
cn
.
iocoder
.
mall
.
product
.
application
.
config
;
import
cn.iocoder.common.framework.config.GlobalExceptionHandler
;
import
cn.iocoder.common.framework.servlet.CorsFilter
;
import
org.springframework.boot.web.servlet.FilterRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.web.servlet.config.annotation.*
;
...
...
@@ -28,13 +31,12 @@ public class MVCConfiguration implements WebMvcConfigurer {
registry
.
addResourceHandler
(
"webjars/**"
).
addResourceLocations
(
"classpath:/META-INF/resources/webjars/"
);
}
// TODO 芋艿,允许跨域
@Override
public
void
addCorsMappings
(
CorsRegistry
registry
)
{
registry
.
addMapping
(
"/**"
)
.
allowedHeaders
(
"*"
)
.
allowedMethods
(
"*"
)
.
allowedOrigins
(
"*"
);
@Bean
public
FilterRegistrationBean
<
CorsFilter
>
corsFilter
()
{
FilterRegistrationBean
<
CorsFilter
>
registrationBean
=
new
FilterRegistrationBean
<>();
registrationBean
.
setFilter
(
new
CorsFilter
());
registrationBean
.
addUrlPatterns
(
"/*"
);
return
registrationBean
;
}
}
\ No newline at end of file
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论