Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
2c849a9c
S
SpringBoot-kwan
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
SpringBoot-kwan
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringBoot-kwan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
2c849a9c
编写于
8月 10, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:添加转换工具
上级
3b31b76d
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
15762 addition
and
15097 deletion
+15762
-15097
logs/SpringBoot-kwan-2023-08-09.0.log
logs/SpringBoot-kwan-2023-08-09.0.log
+15009
-0
logs/SpringBoot-kwan.log
logs/SpringBoot-kwan.log
+545
-15009
pom.xml
pom.xml
+6
-1
src/main/java/com/kwan/springbootkwan/config/CsvBatchJobConfig.java
...ava/com/kwan/springbootkwan/config/CsvBatchJobConfig.java
+0
-83
src/main/java/com/kwan/springbootkwan/controller/ChatbotController.java
...com/kwan/springbootkwan/controller/ChatbotController.java
+4
-3
src/main/java/com/kwan/springbootkwan/entity/Chatbot.java
src/main/java/com/kwan/springbootkwan/entity/Chatbot.java
+0
-1
src/main/java/com/kwan/springbootkwan/entity/PageBean.java
src/main/java/com/kwan/springbootkwan/entity/PageBean.java
+93
-0
src/main/java/com/kwan/springbootkwan/entity/dto/ChatbotDTO.java
...n/java/com/kwan/springbootkwan/entity/dto/ChatbotDTO.java
+26
-0
src/main/java/com/kwan/springbootkwan/mapstruct/FromConverter.java
...java/com/kwan/springbootkwan/mapstruct/FromConverter.java
+35
-0
src/main/java/com/kwan/springbootkwan/mapstruct/PropertyCopier.java
...ava/com/kwan/springbootkwan/mapstruct/PropertyCopier.java
+6
-0
src/main/java/com/kwan/springbootkwan/mapstruct/ToConverter.java
...n/java/com/kwan/springbootkwan/mapstruct/ToConverter.java
+34
-0
src/main/java/com/kwan/springbootkwan/mapstruct/TwoWayConverter.java
...va/com/kwan/springbootkwan/mapstruct/TwoWayConverter.java
+4
-0
未找到文件。
logs/SpringBoot-kwan-2023-08-09.0.log
0 → 100644
浏览文件 @
2c849a9c
此差异已折叠。
点击以展开。
logs/SpringBoot-kwan.log
浏览文件 @
2c849a9c
此差异已折叠。
点击以展开。
pom.xml
浏览文件 @
2c849a9c
...
...
@@ -18,6 +18,7 @@
<!-- 与1.8配置在一起,设置编码集-->
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<mapstruct.version>
1.4.1.Final
</mapstruct.version>
</properties>
<dependencies>
<dependency>
...
...
@@ -175,7 +176,11 @@
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct
</artifactId>
<version>
${mapstruct.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
...
...
src/main/java/com/kwan/springbootkwan/config/CsvBatchJobConfig.java
已删除
100644 → 0
浏览文件 @
3b31b76d
//package com.kwan.springbootkwan.config;
//
//import com.kwan.springbootkwan.entity.Person;
//import org.springframework.batch.core.Job;
//import org.springframework.batch.core.Step;
//import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
//import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
//import org.springframework.batch.core.configuration.annotation.StepScope;
//import org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider;
//import org.springframework.batch.item.database.JdbcBatchItemWriter;
//import org.springframework.batch.item.file.FlatFileItemReader;
//import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper;
//import org.springframework.batch.item.file.mapping.DefaultLineMapper;
//import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.ClassPathResource;
//
//import javax.sql.DataSource;
//
//@Configuration
//public class CsvBatchJobConfig {
//
//
// @Autowired
// JobBuilderFactory jobBuilderFactory;
// @Autowired
// StepBuilderFactory stepBuilderFactory;
// @Autowired
// DataSource dataSource;
//
//
// @Bean
// @StepScope
// FlatFileItemReader<Person> itemReader() {
// FlatFileItemReader<Person> reader = new FlatFileItemReader<>();
// reader.setLinesToSkip(1);
// reader.setResource(new ClassPathResource("data.csv"));
// reader.setLineMapper(new DefaultLineMapper<Person>() {{
// setLineTokenizer(new DelimitedLineTokenizer() {
// {
// setNames("id", "username", "address", "gender");
// //配置列与列之间的间隔符(将通过间隔符对每一行的数据进行切分),最后设置要映射的实体类属性即可
// setDelimiter(",");
// }
// });
// setFieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {
// {
// setTargetType(Person.class);
// }
// });
//
// }});
// return reader;
// }
//
// @Bean
// public JdbcBatchItemWriter jdbcBatchItemWriter() {
// JdbcBatchItemWriter writer = new JdbcBatchItemWriter();
// writer.setDataSource(dataSource);
// writer.setSql("insert into person(id, username,address,gender)" + "values (:id, :username, :address, :gender)");
// writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>());
// return writer;
// }
//
// @Bean
// Step csvStep() {
// return stepBuilderFactory.get("csvStep")
// .<Person, Person>chunk(2)
// .reader(itemReader())
// .writer(jdbcBatchItemWriter())
// .build();
// }
//
// @Bean
// Job csvJob() {
// return jobBuilderFactory.get("csvJob")
// .start(csvStep())
// .build();
//
// }
//}
src/main/java/com/kwan/springbootkwan/controller/ChatbotController.java
浏览文件 @
2c849a9c
...
...
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.kwan.springbootkwan.entity.Chatbot
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.ChatbotDTO
;
import
com.kwan.springbootkwan.service.ChatbotService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
...
...
@@ -67,12 +68,12 @@ public class ChatbotController {
pageParm
.
setCurrent
(
page
);
pageParm
.
setSize
(
pageSize
);
QueryWrapper
<
Chatbot
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
orderByDesc
(
"id"
);
// 按照 id 字段降序排列
wrapper
.
eq
(
"is_delete"
,
0
);
// 按照 id 字段降序排列
wrapper
.
orderByDesc
(
"id"
);
wrapper
.
eq
(
"is_delete"
,
0
);
if
(
StringUtils
.
isNotEmpty
(
question
))
{
wrapper
.
like
(
"question"
,
question
);
}
return
Result
.
ok
(
this
.
chatbotService
.
page
(
pageParm
,
wrapper
));
return
Result
.
ok
(
ChatbotDTO
.
Converter
.
INSTANCE
.
from
(
this
.
chatbotService
.
page
(
pageParm
,
wrapper
)
));
}
/**
...
...
src/main/java/com/kwan/springbootkwan/entity/Chatbot.java
浏览文件 @
2c849a9c
...
...
@@ -13,7 +13,6 @@ import java.util.Date;
* @date : 2023/7/11 18:03
*/
@Data
@SuppressWarnings
(
"serial"
)
public
class
Chatbot
extends
Model
<
Chatbot
>
{
private
Integer
id
;
private
String
question
;
...
...
src/main/java/com/kwan/springbootkwan/entity/PageBean.java
0 → 100644
浏览文件 @
2c849a9c
package
com.kwan.springbootkwan.entity
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
PageBean
<
T
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
8656597559014685635L
;
private
long
totalElements
;
private
List
<
T
>
content
;
private
long
number
;
private
long
size
;
private
long
totalPages
;
private
long
numberOfElements
;
public
PageBean
()
{
}
public
PageBean
(
List
<
T
>
list
)
{
if
(
list
!=
null
)
{
this
.
number
=
1L
;
this
.
size
=
(
long
)
list
.
size
();
this
.
totalElements
=
(
long
)
list
.
size
();
this
.
totalPages
=
1L
;
this
.
content
=
list
;
this
.
numberOfElements
=
(
long
)
list
.
size
();
}
}
public
PageBean
(
IPage
<
T
>
page
)
{
if
(
page
!=
null
)
{
this
.
number
=
page
.
getCurrent
();
this
.
size
=
page
.
getSize
();
this
.
totalElements
=
page
.
getTotal
();
this
.
totalPages
=
page
.
getPages
();
this
.
content
=
page
.
getRecords
();
if
(
this
.
content
!=
null
&&
!
this
.
content
.
isEmpty
())
{
this
.
numberOfElements
=
(
long
)
this
.
content
.
size
();
}
else
{
this
.
numberOfElements
=
0L
;
}
}
}
public
List
<
T
>
getContent
()
{
return
this
.
content
;
}
public
void
setContent
(
List
<
T
>
content
)
{
this
.
content
=
content
;
}
public
long
getSize
()
{
return
this
.
size
;
}
public
void
setSize
(
long
size
)
{
this
.
size
=
size
;
}
public
long
getTotalElements
()
{
return
this
.
totalElements
;
}
public
void
setTotalElements
(
long
totalElements
)
{
this
.
totalElements
=
totalElements
;
}
public
long
getNumber
()
{
return
this
.
number
;
}
public
void
setNumber
(
long
number
)
{
this
.
number
=
number
;
}
public
long
getTotalPages
()
{
return
this
.
totalPages
;
}
public
void
setTotalPages
(
long
totalPages
)
{
this
.
totalPages
=
totalPages
;
}
public
long
getNumberOfElements
()
{
return
this
.
numberOfElements
;
}
public
void
setNumberOfElements
(
long
numberOfElements
)
{
this
.
numberOfElements
=
numberOfElements
;
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/dto/ChatbotDTO.java
0 → 100644
浏览文件 @
2c849a9c
package
com.kwan.springbootkwan.entity.dto
;
import
com.kwan.springbootkwan.entity.Chatbot
;
import
com.kwan.springbootkwan.mapstruct.FromConverter
;
import
lombok.Data
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.ReportingPolicy
;
import
org.mapstruct.factory.Mappers
;
import
java.util.Date
;
@Data
public
class
ChatbotDTO
{
private
Integer
id
;
private
String
question
;
private
String
response
;
private
Date
createTime
;
private
Integer
isDelete
;
@Mapper
(
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
Converter
extends
FromConverter
<
ChatbotDTO
,
Chatbot
>
{
Converter
INSTANCE
=
Mappers
.
getMapper
(
Converter
.
class
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/mapstruct/FromConverter.java
0 → 100644
浏览文件 @
2c849a9c
package
com.kwan.springbootkwan.mapstruct
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.kwan.springbootkwan.entity.PageBean
;
import
java.util.List
;
public
interface
FromConverter
<
T
,
FROM
>
{
T
from
(
FROM
from
);
List
<
T
>
from
(
List
<
FROM
>
list
);
default
PageBean
<
T
>
from
(
PageBean
<
FROM
>
page
)
{
PageBean
<
T
>
result
=
new
PageBean
<>();
result
.
setTotalElements
(
page
.
getTotalElements
());
result
.
setNumber
(
page
.
getNumber
());
result
.
setSize
(
page
.
getSize
());
result
.
setTotalPages
(
page
.
getTotalPages
());
result
.
setNumberOfElements
(
page
.
getNumberOfElements
());
result
.
setContent
(
this
.
from
(
page
.
getContent
()));
return
result
;
}
default
PageBean
<
T
>
from
(
IPage
<
FROM
>
page
)
{
PageBean
<
T
>
result
=
new
PageBean
<>();
result
.
setTotalElements
((
int
)
page
.
getTotal
());
result
.
setNumber
((
int
)
page
.
getCurrent
());
result
.
setSize
((
int
)
page
.
getSize
());
result
.
setTotalPages
((
int
)
page
.
getPages
());
result
.
setNumberOfElements
(
page
.
getRecords
().
size
());
result
.
setContent
(
this
.
from
(
page
.
getRecords
()));
return
result
;
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/mapstruct/PropertyCopier.java
0 → 100644
浏览文件 @
2c849a9c
package
com.kwan.springbootkwan.mapstruct
;
import
org.mapstruct.MappingTarget
;
public
interface
PropertyCopier
<
TARGET
,
T
>
{
void
copy
(
@MappingTarget
TARGET
target
,
T
t
);
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/mapstruct/ToConverter.java
0 → 100644
浏览文件 @
2c849a9c
package
com.kwan.springbootkwan.mapstruct
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.kwan.springbootkwan.entity.PageBean
;
import
java.util.List
;
public
interface
ToConverter
<
T
,
TO
>
{
TO
to
(
T
t
);
List
<
TO
>
to
(
List
<
T
>
list
);
default
PageBean
<
TO
>
to
(
PageBean
<
T
>
page
)
{
PageBean
<
TO
>
result
=
new
PageBean
<>();
result
.
setTotalElements
(
page
.
getTotalElements
());
result
.
setNumber
(
page
.
getNumber
());
result
.
setSize
(
page
.
getSize
());
result
.
setTotalPages
(
page
.
getTotalPages
());
result
.
setNumberOfElements
(
page
.
getNumberOfElements
());
result
.
setContent
(
this
.
to
(
page
.
getContent
()));
return
result
;
}
default
PageBean
<
TO
>
to
(
IPage
<
T
>
page
)
{
PageBean
<
TO
>
result
=
new
PageBean
<>();
result
.
setTotalElements
((
int
)
page
.
getTotal
());
result
.
setNumber
((
int
)
page
.
getCurrent
());
result
.
setSize
((
int
)
page
.
getSize
());
result
.
setTotalPages
((
int
)
page
.
getPages
());
result
.
setNumberOfElements
(
page
.
getRecords
().
size
());
result
.
setContent
(
this
.
to
(
page
.
getRecords
()));
return
result
;
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/mapstruct/TwoWayConverter.java
0 → 100644
浏览文件 @
2c849a9c
package
com.kwan.springbootkwan.mapstruct
;
public
interface
TwoWayConverter
<
SRC
,
DEST
>
extends
ToConverter
<
SRC
,
DEST
>,
FromConverter
<
SRC
,
DEST
>
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录