Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
O
operate-customer-service
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
沈振路
operate-customer-service
Commits
40de5236
提交
40de5236
authored
9月 16, 2022
作者:
沈振路
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
基础搭建
上级
47d3f45d
显示空白字符变更
内嵌
并排
正在显示
28 个修改的文件
包含
768 行增加
和
9 行删除
+768
-9
pom.xml
pom.xml
+0
-6
BaseResult.java
src/main/java/com/yaoyaozw/customer/common/BaseResult.java
+66
-0
GenericsResult.java
...ain/java/com/yaoyaozw/customer/common/GenericsResult.java
+43
-0
PageParams.java
src/main/java/com/yaoyaozw/customer/common/PageParams.java
+34
-0
R.java
src/main/java/com/yaoyaozw/customer/common/R.java
+112
-0
SwaggerConfig.java
...ain/java/com/yaoyaozw/customer/configs/SwaggerConfig.java
+57
-0
ApiResultConstant.java
...va/com/yaoyaozw/customer/constants/ApiResultConstant.java
+18
-0
CrowdPackageController.java
.../yaoyaozw/customer/controller/CrowdPackageController.java
+57
-0
DelayCustomerController.java
...yaoyaozw/customer/controller/DelayCustomerController.java
+58
-0
CrowdPackageQueryDTO.java
...com/yaoyaozw/customer/dto/crowd/CrowdPackageQueryDTO.java
+19
-0
CrowdPackageSaveDTO.java
.../com/yaoyaozw/customer/dto/crowd/CrowdPackageSaveDTO.java
+19
-0
DelayCustomerGraphicsDTO.java
...yaozw/customer/dto/customer/DelayCustomerGraphicsDTO.java
+13
-0
DelayCustomerQueryDTO.java
...yaoyaozw/customer/dto/customer/DelayCustomerQueryDTO.java
+19
-0
DelayCustomerSaveDTO.java
.../yaoyaozw/customer/dto/customer/DelayCustomerSaveDTO.java
+24
-0
DelayCustomerTextDTO.java
.../yaoyaozw/customer/dto/customer/DelayCustomerTextDTO.java
+13
-0
CrowdPackage.java
src/main/java/com/yaoyaozw/customer/entity/CrowdPackage.java
+13
-0
DelayCustomer.java
...main/java/com/yaoyaozw/customer/entity/DelayCustomer.java
+13
-0
MaterialCrowdPackageMapper.java
.../yaoyaozw/customer/mapper/MaterialCrowdPackageMapper.java
+15
-0
MaterialDelayCustomerMapper.java
...yaoyaozw/customer/mapper/MaterialDelayCustomerMapper.java
+15
-0
TokenManager.java
...ain/java/com/yaoyaozw/customer/security/TokenManager.java
+67
-0
CrowdPackageService.java
...va/com/yaoyaozw/customer/service/CrowdPackageService.java
+6
-3
DelayCustomerService.java
...a/com/yaoyaozw/customer/service/DelayCustomerService.java
+11
-0
CrowdPackageServiceImpl.java
...oyaozw/customer/service/impl/CrowdPackageServiceImpl.java
+15
-0
DelayCustomerServiceImpl.java
...yaozw/customer/service/impl/DelayCustomerServiceImpl.java
+15
-0
CrowdPackageListVO.java
...va/com/yaoyaozw/customer/vo/crowd/CrowdPackageListVO.java
+23
-0
DelayCustomerListVO.java
...om/yaoyaozw/customer/vo/customer/DelayCustomerListVO.java
+13
-0
MaterialCrowdPackageMapper.xml
src/main/resources/mapper/MaterialCrowdPackageMapper.xml
+5
-0
MaterialDelayCustomerMapper.xml
src/main/resources/mapper/MaterialDelayCustomerMapper.xml
+5
-0
没有找到文件。
pom.xml
浏览文件 @
40de5236
...
@@ -34,12 +34,6 @@
...
@@ -34,12 +34,6 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-security
</artifactId>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<artifactId>
guava
</artifactId>
<version>
28.2-jre
</version>
<version>
28.2-jre
</version>
...
...
src/main/java/com/yaoyaozw/customer/common/BaseResult.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
common
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.yaoyaozw.customer.constants.ApiResultConstant
;
import
lombok.Data
;
/**
* @author darker
* @date 2022/9/16 10:59
*/
@Data
public
class
BaseResult
{
/**
* 结果标识码
*/
protected
Boolean
success
;
/**
* 返回信息描述
*/
protected
String
message
;
/**
* 结果码
*/
protected
Integer
code
;
public
BaseResult
()
{
}
public
BaseResult
success
()
{
this
.
success
=
Boolean
.
TRUE
;
this
.
code
=
ApiResultConstant
.
SUCCESS_CODE
;
if
(
ObjectUtil
.
isNull
(
this
.
message
))
{
this
.
message
=
ApiResultConstant
.
SUCCESS_MSG
;
}
return
this
;
}
/**
* 错误
*
* @return {@link GenericsResult}
*/
public
BaseResult
error
()
{
this
.
success
=
Boolean
.
FALSE
;
this
.
code
=
ApiResultConstant
.
FAILURE_CODE
;
this
.
message
=
ApiResultConstant
.
FAILURE_MSG
;
return
this
;
}
/**
* 错误
*
* @return {@link GenericsResult}
*/
public
BaseResult
error
(
String
message
)
{
this
.
success
=
Boolean
.
FALSE
;
this
.
code
=
ApiResultConstant
.
FAILURE_CODE
;
this
.
message
=
message
;
return
this
;
}
}
src/main/java/com/yaoyaozw/customer/common/GenericsResult.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
common
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* api结果
*
* @author Darker
* @date 2022/8/14 13:32
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
GenericsResult
<
T
>
extends
BaseResult
{
public
GenericsResult
(
Boolean
success
,
String
message
,
T
data
)
{
if
(
success
)
{
success
();
}
else
{
error
();
}
this
.
message
=
message
;
this
.
data
=
data
;
}
public
GenericsResult
(
String
message
,
T
data
)
{
success
();
this
.
message
=
message
;
this
.
data
=
data
;
}
public
GenericsResult
(
T
data
)
{
success
();
this
.
data
=
data
;
}
/**
* 返回数据
*/
private
T
data
;
}
src/main/java/com/yaoyaozw/customer/common/PageParams.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
common
;
import
java.io.Serializable
;
/**
* @author 10626
*/
public
class
PageParams
implements
Serializable
{
private
static
final
long
serialVersionUID
=
7779279293732755398L
;
private
Integer
currentPage
;
private
Integer
pageSize
;
public
Integer
getCurrentPage
()
{
if
(
currentPage
==
null
)
{
return
1
;
}
return
currentPage
;
}
public
Integer
getPageSize
()
{
if
(
pageSize
==
null
)
{
return
10
;
}
return
pageSize
;
}
public
void
setCurrentPage
(
Integer
currentPage
)
{
this
.
currentPage
=
currentPage
;
}
public
void
setPageSize
(
Integer
pageSize
)
{
this
.
pageSize
=
pageSize
;
}
}
src/main/java/com/yaoyaozw/customer/common/R.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
common
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.yaoyaozw.customer.constants.ApiResultConstant
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.HashMap
;
import
java.util.Map
;
@Data
public
class
R
{
@ApiModelProperty
(
value
=
"是否成功"
)
private
Boolean
success
;
@ApiModelProperty
(
value
=
"返回码"
)
private
Integer
code
;
@ApiModelProperty
(
value
=
"返回消息"
)
private
String
message
;
@ApiModelProperty
(
value
=
"返回数据"
)
private
Map
<
String
,
Object
>
data
=
new
HashMap
<
String
,
Object
>();
//把构造方法私有
private
R
()
{}
//成功静态方法
public
static
R
ok
()
{
R
r
=
new
R
();
r
.
setSuccess
(
true
);
r
.
setCode
(
ApiResultConstant
.
SUCCESS_CODE
);
r
.
setMessage
(
"成功"
);
return
r
;
}
//成功静态方法
public
static
R
copyError
()
{
R
r
=
new
R
();
r
.
setSuccess
(
true
);
r
.
setCode
(
ApiResultConstant
.
SUCCESS_CODE
);
r
.
setMessage
(
"成功"
);
return
r
;
}
//失败静态方法
public
static
R
error
()
{
R
r
=
new
R
();
r
.
setSuccess
(
false
);
r
.
setCode
(
ApiResultConstant
.
FAILURE_CODE
);
r
.
setMessage
(
"请求失败,请先登录"
);
return
r
;
}
//利用fastjson进行逆转
public
<
T
>
T
getData
(
String
key
,
TypeReference
<
T
>
typeReference
){
//默认是map
Object
d
=
data
.
get
(
key
);
String
s
=
JSON
.
toJSONString
(
d
);
T
t
=
JSON
.
parseObject
(
s
,
typeReference
);
return
t
;
}
//利用fastjson进行逆转
public
<
T
>
T
getData
(
TypeReference
<
T
>
typeReference
){
//默认是map
Object
d
=
data
.
get
(
"data"
);
String
s
=
JSON
.
toJSONString
(
d
);
T
t
=
JSON
.
parseObject
(
s
,
typeReference
);
return
t
;
}
//失败静态方法
public
static
R
error
(
String
message
)
{
R
r
=
new
R
();
r
.
setSuccess
(
false
);
r
.
setCode
(
ApiResultConstant
.
FAILURE_CODE
);
r
.
setMessage
(
message
);
return
r
;
}
//失败静态方法
public
static
R
loginError
()
{
R
r
=
new
R
();
r
.
setSuccess
(
false
);
r
.
setCode
(
ApiResultConstant
.
FAILURE_CODE
);
r
.
setMessage
(
"登录失败,请重新再试"
);
return
r
;
}
public
R
success
(
Boolean
success
){
this
.
setSuccess
(
success
);
return
this
;
}
public
R
message
(
String
message
){
this
.
setMessage
(
message
);
return
this
;
}
public
R
code
(
Integer
code
){
this
.
setCode
(
code
);
return
this
;
}
public
R
data
(
String
key
,
Object
value
){
this
.
data
.
put
(
key
,
value
);
return
this
;
}
public
R
data
(
Map
<
String
,
Object
>
map
){
this
.
setData
(
map
);
return
this
;
}
}
src/main/java/com/yaoyaozw/customer/configs/SwaggerConfig.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
configs
;
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.service.Contact
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* @author 10626
*/
@Configuration
@EnableSwagger2
public
class
SwaggerConfig
{
@Configuration
@EnableSwagger2
public
static
class
Swagger2Config
{
/**
* 用于配置swagger2,包含文档基本信息
* 指定swagger2的作用域(这里指定包路径下的所有API)
* @return Docket
*/
@Bean
public
Docket
createRestApi
()
{
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
//指定需要扫描的controller
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.yaoyaozw.customer"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
/**
* 构建文档基本信息,用于页面显示,可以包含版本、
* 联系人信息、服务地址、文档描述信息等
* @return ApiInfo
*/
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
//标题
.
title
(
"Spring Boot2中采用Swagger2构建RESTful APIs"
)
.
description
(
"通过访问swagger-ui.html,实现接口测试、文档生成"
)
.
termsOfServiceUrl
(
"http://localhost:8080"
)
//设置联系方式
.
contact
(
new
Contact
(
"西红柿丶番茄"
,
"https://blog.csdn.net/p_programmer"
,
"xxxxx@qq.com"
))
.
version
(
"1.0"
)
.
build
();
}
}
}
src/main/java/com/yaoyaozw/customer/constants/ApiResultConstant.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
constants
;
/**
* @author Darker
* @date 2022/8/14 13:37
*/
public
class
ApiResultConstant
{
public
final
static
String
SUCCESS_MSG
=
"成功"
;
public
final
static
Integer
SUCCESS_CODE
=
20000
;
public
final
static
String
FAILURE_MSG
=
"操作失败"
;
public
final
static
Integer
FAILURE_CODE
=
20001
;
}
src/main/java/com/yaoyaozw/customer/controller/CrowdPackageController.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
controller
;
import
com.yaoyaozw.customer.common.BaseResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageQueryDTO
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageSaveDTO
;
import
com.yaoyaozw.customer.security.TokenManager
;
import
com.yaoyaozw.customer.service.CrowdPackageService
;
import
com.yaoyaozw.customer.vo.crowd.CrowdPackageListVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author darker
* @date 2022/9/15 14:08
*/
@Api
(
tags
=
"人群包接口"
)
@RestController
@RequestMapping
(
"/crowd-package"
)
public
class
CrowdPackageController
{
@Autowired
private
CrowdPackageService
crowdPackageService
;
@ApiOperation
(
"保存"
)
@PostMapping
(
"/save"
)
public
BaseResult
saveCrowdPackage
(
@RequestBody
CrowdPackageSaveDTO
saveDto
)
{
return
new
BaseResult
().
success
();
}
@ApiOperation
(
"编辑"
)
@PostMapping
(
"/edit"
)
public
BaseResult
updateCrowdPackage
(
@RequestBody
CrowdPackageSaveDTO
saveDto
)
{
return
new
BaseResult
().
success
();
}
@ApiOperation
(
"查询"
)
@PostMapping
(
"/pageList"
)
public
GenericsResult
<
List
<
CrowdPackageListVO
>>
pageList
(
@RequestBody
CrowdPackageQueryDTO
queryDto
)
{
return
new
GenericsResult
<>(
new
ArrayList
<>());
}
@ApiOperation
(
"删除"
)
@GetMapping
(
"/remove/{id}"
)
public
BaseResult
removeCrowdPackage
(
@PathVariable
(
"id"
)
Long
id
)
{
return
new
BaseResult
().
success
();
}
}
src/main/java/com/yaoyaozw/customer/controller/DelayCustomerController.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
controller
;
import
com.yaoyaozw.customer.common.BaseResult
;
import
com.yaoyaozw.customer.common.GenericsResult
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageQueryDTO
;
import
com.yaoyaozw.customer.dto.crowd.CrowdPackageSaveDTO
;
import
com.yaoyaozw.customer.dto.customer.DelayCustomerQueryDTO
;
import
com.yaoyaozw.customer.dto.customer.DelayCustomerSaveDTO
;
import
com.yaoyaozw.customer.entity.DelayCustomer
;
import
com.yaoyaozw.customer.service.DelayCustomerService
;
import
com.yaoyaozw.customer.vo.crowd.CrowdPackageListVO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author darker
* @date 2022/9/15 11:13
*/
@Api
(
tags
=
"延时客服接口"
)
@RestController
@RequestMapping
(
"/delay-customer-service"
)
public
class
DelayCustomerController
{
@Autowired
private
DelayCustomerService
delayCustomerService
;
@ApiOperation
(
"保存"
)
@PostMapping
(
"/save"
)
public
BaseResult
saveCrowdPackage
(
@RequestBody
DelayCustomerSaveDTO
saveDto
)
{
return
new
BaseResult
().
success
();
}
@ApiOperation
(
"编辑"
)
@PostMapping
(
"/edit"
)
public
BaseResult
updateCrowdPackage
(
@RequestBody
DelayCustomerSaveDTO
saveDto
)
{
return
new
BaseResult
().
success
();
}
@ApiOperation
(
"查询"
)
@PostMapping
(
"/pageList"
)
public
GenericsResult
<
List
<
DelayCustomer
>>
pageList
(
@RequestBody
DelayCustomerQueryDTO
queryDto
)
{
return
new
GenericsResult
<>(
new
ArrayList
<>());
}
@ApiOperation
(
"删除"
)
@GetMapping
(
"/remove/{id}"
)
public
BaseResult
removeCrowdPackage
(
@PathVariable
(
"id"
)
Long
id
)
{
return
new
BaseResult
().
success
();
}
}
src/main/java/com/yaoyaozw/customer/dto/crowd/CrowdPackageQueryDTO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
dto
.
crowd
;
import
com.yaoyaozw.customer.common.PageParams
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/15 14:19
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
public
class
CrowdPackageQueryDTO
extends
PageParams
implements
Serializable
{
}
src/main/java/com/yaoyaozw/customer/dto/crowd/CrowdPackageSaveDTO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
dto
.
crowd
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/15 14:19
*/
@Data
public
class
CrowdPackageSaveDTO
implements
Serializable
{
private
String
packageName
;
}
src/main/java/com/yaoyaozw/customer/dto/customer/DelayCustomerGraphicsDTO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
dto
.
customer
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/15 11:15
*/
@Data
public
class
DelayCustomerGraphicsDTO
implements
Serializable
{
}
src/main/java/com/yaoyaozw/customer/dto/customer/DelayCustomerQueryDTO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
dto
.
customer
;
import
com.yaoyaozw.customer.common.PageParams
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/15 11:20
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
DelayCustomerQueryDTO
extends
PageParams
implements
Serializable
{
}
src/main/java/com/yaoyaozw/customer/dto/customer/DelayCustomerSaveDTO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
dto
.
customer
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/15 11:14
*/
@Data
public
class
DelayCustomerSaveDTO
implements
Serializable
{
private
Long
crowdPackageId
;
private
String
messageName
;
private
Integer
messageType
;
private
DelayCustomerGraphicsDTO
graphicsDto
;
private
DelayCustomerTextDTO
textDto
;
}
src/main/java/com/yaoyaozw/customer/dto/customer/DelayCustomerTextDTO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
dto
.
customer
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/15 11:16
*/
@Data
public
class
DelayCustomerTextDTO
implements
Serializable
{
}
src/main/java/com/yaoyaozw/customer/entity/CrowdPackage.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
entity
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/16 10:43
*/
@Data
public
class
CrowdPackage
implements
Serializable
{
}
src/main/java/com/yaoyaozw/customer/entity/DelayCustomer.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
entity
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/16 10:42
*/
@Data
public
class
DelayCustomer
implements
Serializable
{
}
src/main/java/com/yaoyaozw/customer/mapper/MaterialCrowdPackageMapper.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
mapper
;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.CrowdPackage
;
import
org.springframework.stereotype.Repository
;
/**
* @author darker
* @date 2022/9/16 10:44
*/
@DS
(
"material"
)
@Repository
public
interface
MaterialCrowdPackageMapper
extends
BaseMapper
<
CrowdPackage
>
{
}
src/main/java/com/yaoyaozw/customer/mapper/MaterialDelayCustomerMapper.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
mapper
;
import
com.baomidou.dynamic.datasource.annotation.DS
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yaoyaozw.customer.entity.DelayCustomer
;
import
org.springframework.stereotype.Repository
;
/**
* @author darker
* @date 2022/9/16 10:43
*/
@DS
(
"material"
)
@Repository
public
interface
MaterialDelayCustomerMapper
extends
BaseMapper
<
DelayCustomer
>
{
}
src/main/java/com/yaoyaozw/customer/security/TokenManager.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
security
;
import
cn.hutool.core.util.ObjectUtil
;
import
io.jsonwebtoken.CompressionCodecs
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
/**
* <p>
* token管理
* </p>
*
* @author qy
* @since 2019-11-08
*/
@Component
@Slf4j
public
class
TokenManager
{
private
final
static
long
TOKEN_EXPIRATION
=
24
*
60
*
60
*
1000
;
private
final
static
String
TOKEN_SINGLE_KEY
=
"123456"
;
public
String
createToken
(
String
id
,
String
username
)
{
return
Jwts
.
builder
().
setSubject
(
username
).
setId
(
id
).
setExpiration
(
new
Date
(
System
.
currentTimeMillis
()
+
TOKEN_EXPIRATION
)).
signWith
(
SignatureAlgorithm
.
HS512
,
TOKEN_SINGLE_KEY
).
compressWith
(
CompressionCodecs
.
GZIP
).
compact
();
}
public
String
getUserFromToken
(
String
token
)
{
return
Jwts
.
parser
().
setSigningKey
(
TOKEN_SINGLE_KEY
).
parseClaimsJws
(
token
).
getBody
().
getSubject
();
}
public
Long
getUserIdFromToken
()
{
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
ObjectUtil
.
isNull
(
requestAttributes
))
{
return
null
;
}
HttpServletRequest
request
=
requestAttributes
.
getRequest
();
String
token
=
request
.
getHeader
(
"token"
);
if
(
StringUtils
.
isBlank
(
token
)){
return
-
1L
;
}
String
userId
=
Jwts
.
parser
().
setSigningKey
(
TOKEN_SINGLE_KEY
).
parseClaimsJws
(
token
).
getBody
().
getId
();
return
ObjectUtil
.
isNull
(
userId
)
?
null
:
Long
.
parseLong
(
userId
);
}
public
String
getUserNameFromToken
()
{
ServletRequestAttributes
requestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
if
(
ObjectUtil
.
isNull
(
requestAttributes
))
{
return
null
;
}
HttpServletRequest
request
=
requestAttributes
.
getRequest
();
String
token
=
request
.
getHeader
(
"token"
);
return
Jwts
.
parser
().
setSigningKey
(
TOKEN_SINGLE_KEY
).
parseClaimsJws
(
token
).
getBody
().
getSubject
();
}
public
String
getUserIdFromToken
(
String
token
)
{
return
Jwts
.
parser
().
setSigningKey
(
TOKEN_SINGLE_KEY
).
parseClaimsJws
(
token
).
getBody
().
getId
();
}
}
src/main/java/com/yaoyaozw/customer/service/
impl/Init
Service.java
→
src/main/java/com/yaoyaozw/customer/service/
CrowdPackage
Service.java
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
service
.
impl
;
package
com
.
yaoyaozw
.
customer
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.entity.CrowdPackage
;
/**
/**
* @author darker
* @author darker
* @date 2022/9/16 1
0:24
* @date 2022/9/16 1
2:03
*/
*/
public
class
InitService
{
public
interface
CrowdPackageService
extends
IService
<
CrowdPackage
>
{
}
}
src/main/java/com/yaoyaozw/customer/service/DelayCustomerService.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.yaoyaozw.customer.entity.DelayCustomer
;
/**
* @author darker
* @date 2022/9/15 11:13
*/
public
interface
DelayCustomerService
extends
IService
<
DelayCustomer
>
{
}
src/main/java/com/yaoyaozw/customer/service/impl/CrowdPackageServiceImpl.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yaoyaozw.customer.entity.CrowdPackage
;
import
com.yaoyaozw.customer.mapper.MaterialCrowdPackageMapper
;
import
com.yaoyaozw.customer.service.CrowdPackageService
;
import
org.springframework.stereotype.Service
;
/**
* @author darker
* @date 2022/9/16 12:03
*/
@Service
public
class
CrowdPackageServiceImpl
extends
ServiceImpl
<
MaterialCrowdPackageMapper
,
CrowdPackage
>
implements
CrowdPackageService
{
}
src/main/java/com/yaoyaozw/customer/service/impl/DelayCustomerServiceImpl.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yaoyaozw.customer.entity.DelayCustomer
;
import
com.yaoyaozw.customer.mapper.MaterialDelayCustomerMapper
;
import
com.yaoyaozw.customer.service.DelayCustomerService
;
import
org.springframework.stereotype.Service
;
/**
* @author darker
* @date 2022/9/15 11:13
*/
@Service
public
class
DelayCustomerServiceImpl
extends
ServiceImpl
<
MaterialDelayCustomerMapper
,
DelayCustomer
>
implements
DelayCustomerService
{
}
src/main/java/com/yaoyaozw/customer/vo/crowd/CrowdPackageListVO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
vo
.
crowd
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/16 10:46
*/
@Data
@ApiModel
public
class
CrowdPackageListVO
implements
Serializable
{
@ApiModelProperty
(
"姓名"
)
private
String
name
;
@ApiModelProperty
(
"年龄"
)
private
Integer
age
;
}
src/main/java/com/yaoyaozw/customer/vo/customer/DelayCustomerListVO.java
0 → 100644
浏览文件 @
40de5236
package
com
.
yaoyaozw
.
customer
.
vo
.
customer
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author darker
* @date 2022/9/16 10:45
*/
@Data
public
class
DelayCustomerListVO
implements
Serializable
{
}
src/main/resources/mapper/MaterialCrowdPackageMapper.xml
0 → 100644
浏览文件 @
40de5236
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.yaoyaozw.customer.mapper.MaterialCrowdPackageMapper"
>
</mapper>
\ No newline at end of file
src/main/resources/mapper/MaterialDelayCustomerMapper.xml
0 → 100644
浏览文件 @
40de5236
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"com.yaoyaozw.customer.mapper.MaterialDelayCustomerMapper"
>
</mapper>
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论