Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
后端镜像
java镜像
Spring Cloud Advance
提交
d1319e07
S
Spring Cloud Advance
项目概览
后端镜像
/
java镜像
/
Spring Cloud Advance
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Spring Cloud Advance
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d1319e07
编写于
9月 07, 2019
作者:
S
sprainkle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: adjust package structure
上级
99145d1b
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
594 addition
and
14 deletion
+594
-14
spring-cloud-advance-common/spring-cloud-advance-common-core/pom.xml
...d-advance-common/spring-cloud-advance-common-core/pom.xml
+0
-9
spring-cloud-advance-stream/pom.xml
spring-cloud-advance-stream/pom.xml
+1
-1
unified-exception-handling/ueh-discovery/pom.xml
unified-exception-handling/ueh-discovery/pom.xml
+1
-1
unified-exception-handling/ueh-licence/pom.xml
unified-exception-handling/ueh-licence/pom.xml
+1
-2
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/UehLicenceApplication.java
...ain/java/com/sprainkle/licence/UehLicenceApplication.java
+17
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/client/OrganizationClient.java
...java/com/sprainkle/licence/client/OrganizationClient.java
+23
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/config/MybatisPlusConfig.java
.../java/com/sprainkle/licence/config/MybatisPlusConfig.java
+27
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/constant/LicenceTypeEnum.java
.../java/com/sprainkle/licence/constant/LicenceTypeEnum.java
+52
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/constant/ResponseEnum.java
...ain/java/com/sprainkle/licence/constant/ResponseEnum.java
+36
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/controller/LicenceController.java
...a/com/sprainkle/licence/controller/LicenceController.java
+50
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/entity/Licence.java
...e/src/main/java/com/sprainkle/licence/entity/Licence.java
+36
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/mapper/LicenceMapper.java
...main/java/com/sprainkle/licence/mapper/LicenceMapper.java
+15
-0
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/service/LicenceService.java
...in/java/com/sprainkle/licence/service/LicenceService.java
+136
-0
unified-exception-handling/ueh-organization/pom.xml
unified-exception-handling/ueh-organization/pom.xml
+1
-1
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/UehOrganizationApplication.java
...om/sprainkle/organization/UehOrganizationApplication.java
+15
-0
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/config/MybatisPlusConfig.java
.../com/sprainkle/organization/config/MybatisPlusConfig.java
+27
-0
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/constant/ResponseEnum.java
...ava/com/sprainkle/organization/constant/ResponseEnum.java
+32
-0
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/controller/OrganizationController.java
...inkle/organization/controller/OrganizationController.java
+32
-0
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/entity/Organization.java
.../java/com/sprainkle/organization/entity/Organization.java
+29
-0
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/mapper/OrganizationMapper.java
...com/sprainkle/organization/mapper/OrganizationMapper.java
+15
-0
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/service/OrganizationService.java
...m/sprainkle/organization/service/OrganizationService.java
+48
-0
未找到文件。
spring-cloud-advance-common/spring-cloud-advance-common-core/pom.xml
浏览文件 @
d1319e07
...
@@ -38,13 +38,4 @@
...
@@ -38,13 +38,4 @@
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
</plugin>
</plugins>
</build>
</project>
</project>
spring-cloud-advance-stream/pom.xml
浏览文件 @
d1319e07
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<artifactId>
spring-cloud-advance-stream
</artifactId>
<artifactId>
spring-cloud-advance-stream
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
spring-cloud-advance-stream
</name>
<name>
spring-cloud-advance-stream
</name>
<description>
Demo project for Spring
Boot
</description>
<description>
Demo project for Spring
Cloud Stream.
</description>
<properties>
<properties>
<java.version>
1.8
</java.version>
<java.version>
1.8
</java.version>
...
...
unified-exception-handling/ueh-discovery/pom.xml
浏览文件 @
d1319e07
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<artifactId>
ueh-discovery
</artifactId>
<artifactId>
ueh-discovery
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
ueh-discovery
</name>
<name>
ueh-discovery
</name>
<description>
unified exception handling
service discovery
</description>
<description>
service discovery
</description>
<dependencies>
<dependencies>
<dependency>
<dependency>
...
...
unified-exception-handling/ueh-licence/pom.xml
浏览文件 @
d1319e07
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<artifactId>
ueh-licence
</artifactId>
<artifactId>
ueh-licence
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
ueh-licence
</name>
<name>
ueh-licence
</name>
<description>
unified exception handling
licence service
</description>
<description>
licence service
</description>
<dependencies>
<dependencies>
<dependency>
<dependency>
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
<version>
2.0.1.RELEASE
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/UehLicenceApplication.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public
class
UehLicenceApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
UehLicenceApplication
.
class
,
args
);
}
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/client/OrganizationClient.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.client
;
import
com.sprainkle.spring.cloud.advance.common.core.pojo.response.R
;
import
com.sprainkle.spring.cloud.advance.proto.organization.response.OrganizationDTO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/4
*/
@FeignClient
(
"ueh-organization"
)
public
interface
OrganizationClient
{
@GetMapping
(
"/organization/{organizationId}"
)
R
<
OrganizationDTO
>
getOrganization
(
@PathVariable
(
"organizationId"
)
Long
organizationId
);
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/config/MybatisPlusConfig.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.config
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
@Configuration
@MapperScan
(
"com.sprainkle.**.mapper"
)
public
class
MybatisPlusConfig
{
/**
* 分页插件
*/
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
return
new
PaginationInterceptor
();
}
}
\ No newline at end of file
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/constant/LicenceTypeEnum.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.constant
;
import
com.sprainkle.spring.cloud.advance.common.core.constant.Dictionary
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.ToString
;
/**
* licence type
*
* @author sprainkle
* @date 2019/5/3
*/
@Getter
@ToString
@AllArgsConstructor
public
enum
LicenceTypeEnum
implements
Dictionary
{
USER
(
"user"
,
"user"
),
CORE_PROD
(
"core-prod"
,
"core-prod"
),
;
private
String
code
;
private
String
name
;
/**
* code -> {@link LicenceTypeEnum}, 允许返回空
* @param code
* @return
*/
public
static
LicenceTypeEnum
parseOfNullable
(
String
code
)
{
if
(
code
!=
null
)
{
for
(
LicenceTypeEnum
e
:
values
())
{
if
(
e
.
code
.
equals
(
code
))
{
return
e
;
}
}
}
return
null
;
}
/**
* code -> name, 允许返回空
* @param code
* @return
*/
public
static
String
parseOfNameNullable
(
String
code
)
{
LicenceTypeEnum
enable
=
parseOfNullable
(
code
);
return
enable
==
null
?
null
:
enable
.
getName
();
}
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/constant/ResponseEnum.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.constant
;
import
com.sprainkle.spring.cloud.advance.common.core.exception.assertion.BusinessExceptionAssert
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* <p>返回结果</p>
*
* @author sprainkle
* @date 2018.09.17
*/
@Getter
@AllArgsConstructor
public
enum
ResponseEnum
implements
BusinessExceptionAssert
{
/**
*
*/
BAD_LICENCE_TYPE
(
7001
,
"Bad licence type."
),
/**
*
*/
LICENCE_NOT_FOUND
(
7002
,
"Licence not found."
)
;
/**
* 返回码
*/
private
int
code
;
/**
* 返回消息
*/
private
String
message
;
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/controller/LicenceController.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.controller
;
import
com.sprainkle.spring.cloud.advance.common.core.pojo.response.QR
;
import
com.sprainkle.spring.cloud.advance.common.core.pojo.response.R
;
import
com.sprainkle.spring.cloud.advance.proto.licence.param.LicenceParam
;
import
com.sprainkle.spring.cloud.advance.proto.licence.request.LicenceAddRequest
;
import
com.sprainkle.spring.cloud.advance.proto.licence.response.LicenceAddRespData
;
import
com.sprainkle.spring.cloud.advance.proto.licence.response.LicenceDTO
;
import
com.sprainkle.spring.cloud.advance.proto.licence.response.SimpleLicenceDTO
;
import
com.sprainkle.licence.service.LicenceService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
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
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
@RestController
@RequestMapping
(
value
=
"/licence"
)
public
class
LicenceController
{
@Autowired
private
LicenceService
licenceService
;
@GetMapping
(
value
=
"/{licenceId}"
)
public
R
<
LicenceDTO
>
getLicence
(
@PathVariable
(
"licenceId"
)
Long
licenceId
)
{
return
new
R
<>(
licenceService
.
queryDetail
(
licenceId
));
}
@GetMapping
(
value
=
"/list"
)
public
QR
<
SimpleLicenceDTO
>
getLicences
(
@Validated
LicenceParam
licenceParam
)
{
return
new
QR
<>(
licenceService
.
getLicences
(
licenceParam
));
}
@PostMapping
public
R
<
LicenceAddRespData
>
addLicence
(
@Validated
@RequestBody
LicenceAddRequest
request
)
{
return
new
R
<>(
licenceService
.
addLicence
(
request
));
}
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/entity/Licence.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
@Data
@TableName
(
"licence"
)
public
class
Licence
{
@TableId
(
value
=
"licence_id"
,
type
=
IdType
.
AUTO
)
private
Long
licenceId
;
private
Long
organizationId
;
private
String
licenceType
;
private
String
productName
;
private
Integer
licenceMax
;
private
Integer
licenceAllocated
;
private
String
comment
;
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/mapper/LicenceMapper.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.sprainkle.licence.entity.Licence
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
public
interface
LicenceMapper
extends
BaseMapper
<
Licence
>
{
}
unified-exception-handling/ueh-licence/src/main/java/com/sprainkle/licence/service/LicenceService.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.licence.service
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.sprainkle.licence.client.OrganizationClient
;
import
com.sprainkle.licence.constant.LicenceTypeEnum
;
import
com.sprainkle.licence.constant.ResponseEnum
;
import
com.sprainkle.licence.entity.Licence
;
import
com.sprainkle.licence.mapper.LicenceMapper
;
import
com.sprainkle.spring.cloud.advance.common.core.pojo.param.QueryPage
;
import
com.sprainkle.spring.cloud.advance.common.core.pojo.response.QueryData
;
import
com.sprainkle.spring.cloud.advance.common.core.util.ClientUtil
;
import
com.sprainkle.spring.cloud.advance.proto.licence.param.LicenceParam
;
import
com.sprainkle.spring.cloud.advance.proto.licence.request.LicenceAddRequest
;
import
com.sprainkle.spring.cloud.advance.proto.licence.response.LicenceAddRespData
;
import
com.sprainkle.spring.cloud.advance.proto.licence.response.LicenceDTO
;
import
com.sprainkle.spring.cloud.advance.proto.licence.response.SimpleLicenceDTO
;
import
com.sprainkle.spring.cloud.advance.proto.organization.response.OrganizationDTO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
@Service
public
class
LicenceService
extends
ServiceImpl
<
LicenceMapper
,
Licence
>
{
@Autowired
private
OrganizationClient
organizationClient
;
/**
* 查询{@link Licence} 详情
* @param licenceId
* @return
*/
public
LicenceDTO
queryDetail
(
Long
licenceId
)
{
Licence
licence
=
this
.
getById
(
licenceId
);
// 校验非空
ResponseEnum
.
LICENCE_NOT_FOUND
.
assertNotNull
(
licence
);
OrganizationDTO
org
=
ClientUtil
.
execute
(()
->
organizationClient
.
getOrganization
(
licence
.
getOrganizationId
()));
return
toLicenceDTO
(
licence
,
org
);
}
/**
* 分页获取
* @param licenceParam 分页查询参数
* @return
*/
public
QueryData
<
SimpleLicenceDTO
>
getLicences
(
LicenceParam
licenceParam
)
{
String
licenceType
=
licenceParam
.
getLicenceType
();
LicenceTypeEnum
licenceTypeEnum
=
LicenceTypeEnum
.
parseOfNullable
(
licenceType
);
// 断言, 非空
ResponseEnum
.
BAD_LICENCE_TYPE
.
assertNotNull
(
licenceTypeEnum
);
LambdaQueryWrapper
<
Licence
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
Licence:
:
getLicenceType
,
licenceType
);
IPage
<
Licence
>
page
=
this
.
page
(
new
QueryPage
<>(
licenceParam
),
wrapper
);
return
new
QueryData
<>(
page
,
this
::
toSimpleLicenceDTO
);
}
/**
* 新增{@link Licence}
* @param request 请求体
* @return
*/
@Transactional
(
rollbackFor
=
Throwable
.
class
)
public
LicenceAddRespData
addLicence
(
LicenceAddRequest
request
)
{
// 省略校验参数
Licence
licence
=
new
Licence
();
licence
.
setOrganizationId
(
request
.
getOrganizationId
());
licence
.
setLicenceType
(
request
.
getLicenceType
());
licence
.
setProductName
(
request
.
getProductName
());
licence
.
setLicenceMax
(
request
.
getLicenceMax
());
licence
.
setLicenceAllocated
(
request
.
getLicenceAllocated
());
licence
.
setComment
(
request
.
getComment
());
this
.
save
(
licence
);
return
new
LicenceAddRespData
(
licence
.
getLicenceId
());
}
/**
* entity -> simple dto
* @param licence {@link Licence} entity
* @return {@link SimpleLicenceDTO}
*/
private
SimpleLicenceDTO
toSimpleLicenceDTO
(
Licence
licence
)
{
SimpleLicenceDTO
simpleLicenceDTO
=
new
SimpleLicenceDTO
();
simpleLicenceDTO
.
setLicenceId
(
String
.
valueOf
(
licence
.
getLicenceId
()));
simpleLicenceDTO
.
setOrganizationId
(
String
.
valueOf
(
licence
.
getOrganizationId
()));
simpleLicenceDTO
.
setLicenceType
(
licence
.
getLicenceType
());
simpleLicenceDTO
.
setProductName
(
licence
.
getProductName
());
simpleLicenceDTO
.
setLicenceMax
(
licence
.
getLicenceMax
());
simpleLicenceDTO
.
setLicenceAllocated
(
licence
.
getLicenceAllocated
());
simpleLicenceDTO
.
setComment
(
licence
.
getComment
());
return
simpleLicenceDTO
;
}
/**
* entity -> dto
* @param licence {@link Licence} entity
* @param org {@link OrganizationDTO}
* @return {@link LicenceDTO}
*/
private
LicenceDTO
toLicenceDTO
(
Licence
licence
,
OrganizationDTO
org
)
{
LicenceDTO
licenceDTO
=
new
LicenceDTO
();
licenceDTO
.
setLicenceId
(
String
.
valueOf
(
licence
.
getLicenceId
()));
licenceDTO
.
setOrganizationId
(
String
.
valueOf
(
licence
.
getOrganizationId
()));
licenceDTO
.
setOrganizationName
(
org
.
getName
());
licenceDTO
.
setContactName
(
org
.
getContactName
());
licenceDTO
.
setContactEmail
(
org
.
getContactEmail
());
licenceDTO
.
setContactPhone
(
org
.
getContactPhone
());
licenceDTO
.
setLicenceType
(
licence
.
getLicenceType
());
licenceDTO
.
setProductName
(
licence
.
getProductName
());
licenceDTO
.
setLicenceMax
(
licence
.
getLicenceMax
());
licenceDTO
.
setLicenceAllocated
(
licence
.
getLicenceAllocated
());
licenceDTO
.
setComment
(
licence
.
getComment
());
return
licenceDTO
;
}
/**
* 校验{@link Licence}存在
* @param licence
*/
private
void
checkNotNull
(
Licence
licence
)
{
}
}
unified-exception-handling/ueh-organization/pom.xml
浏览文件 @
d1319e07
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<artifactId>
ueh-organization
</artifactId>
<artifactId>
ueh-organization
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<version>
0.0.1-SNAPSHOT
</version>
<name>
ueh-organization
</name>
<name>
ueh-organization
</name>
<description>
unified exception handling
organization service
</description>
<description>
organization service
</description>
<dependencies>
<dependencies>
<dependency>
<dependency>
...
...
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/UehOrganizationApplication.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
@SpringBootApplication
@EnableDiscoveryClient
public
class
UehOrganizationApplication
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
UehOrganizationApplication
.
class
,
args
);
}
}
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/config/MybatisPlusConfig.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization.config
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
@Configuration
@MapperScan
(
"com.sprainkle.**.mapper"
)
public
class
MybatisPlusConfig
{
/**
* 分页插件
*/
@Bean
public
PaginationInterceptor
paginationInterceptor
()
{
return
new
PaginationInterceptor
();
}
}
\ No newline at end of file
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/constant/ResponseEnum.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization.constant
;
import
com.sprainkle.spring.cloud.advance.common.core.exception.assertion.BusinessExceptionAssert
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* <p>返回结果</p>
*
* @author sprainkle
* @date 2018.09.17
*/
@Getter
@AllArgsConstructor
public
enum
ResponseEnum
implements
BusinessExceptionAssert
{
/**
*
*/
ORGANIZATION_NOT_FOUND
(
6001
,
"Organization not found."
)
;
/**
* 返回码
*/
private
int
code
;
/**
* 返回消息
*/
private
String
message
;
}
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/controller/OrganizationController.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization.controller
;
import
com.sprainkle.organization.service.OrganizationService
;
import
com.sprainkle.spring.cloud.advance.common.core.pojo.response.R
;
import
com.sprainkle.spring.cloud.advance.proto.organization.response.OrganizationDTO
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/18
*/
@RequestMapping
(
"/organization"
)
@RestController
public
class
OrganizationController
{
@Autowired
private
OrganizationService
organizationService
;
@GetMapping
(
"/{organizationId}"
)
public
R
<
OrganizationDTO
>
getOrganization
(
@PathVariable
(
"organizationId"
)
Long
organizationId
)
{
return
new
R
<>(
organizationService
.
queryDetail
(
organizationId
));
}
}
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/entity/Organization.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization.entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/3
*/
@Data
@TableName
(
"organization"
)
public
class
Organization
{
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Long
id
;
private
String
name
;
private
String
contactName
;
private
String
contactEmail
;
private
String
contactPhone
;
}
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/mapper/OrganizationMapper.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.sprainkle.organization.entity.Organization
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/18
*/
public
interface
OrganizationMapper
extends
BaseMapper
<
Organization
>
{
}
unified-exception-handling/ueh-organization/src/main/java/com/sprainkle/organization/service/OrganizationService.java
0 → 100644
浏览文件 @
d1319e07
package
com.sprainkle.organization.service
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.sprainkle.organization.constant.ResponseEnum
;
import
com.sprainkle.organization.entity.Organization
;
import
com.sprainkle.organization.mapper.OrganizationMapper
;
import
com.sprainkle.spring.cloud.advance.proto.organization.response.OrganizationDTO
;
import
org.springframework.stereotype.Service
;
/**
* <pre>
*
* </pre>
*
* @author sprainkle
* @date 2019/5/18
*/
@Service
public
class
OrganizationService
extends
ServiceImpl
<
OrganizationMapper
,
Organization
>
{
/**
* get organization detail by id.
* @param orgId organization id.
* @return {@link OrganizationDTO}
*/
public
OrganizationDTO
queryDetail
(
Long
orgId
)
{
Organization
organization
=
this
.
getById
(
orgId
);
ResponseEnum
.
ORGANIZATION_NOT_FOUND
.
assertNotNull
(
organization
);
return
toOrganizationDTO
(
organization
);
}
/**
* entity -> dto
* @param organization {@link Organization}
* @return
*/
private
OrganizationDTO
toOrganizationDTO
(
Organization
organization
)
{
OrganizationDTO
organizationDTO
=
new
OrganizationDTO
();
organizationDTO
.
setId
(
organization
.
getId
());
organizationDTO
.
setName
(
organization
.
getName
());
organizationDTO
.
setContactName
(
organization
.
getContactName
());
organizationDTO
.
setContactEmail
(
organization
.
getContactEmail
());
organizationDTO
.
setContactPhone
(
organization
.
getContactPhone
());
return
organizationDTO
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录