Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
c33612cd
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看板
提交
c33612cd
编写于
9月 08, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:添加问题
上级
ab106e39
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
232 addition
and
11 deletion
+232
-11
src/main/java/com/kwan/springbootkwan/AppApplication.java
src/main/java/com/kwan/springbootkwan/AppApplication.java
+2
-2
src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java
...pringbootkwan/controller/InterviewQuestionController.java
+104
-0
src/main/java/com/kwan/springbootkwan/entity/InterviewQuestion.java
...ava/com/kwan/springbootkwan/entity/InterviewQuestion.java
+30
-0
src/main/java/com/kwan/springbootkwan/mapper/InterviewQuestionMapper.java
...m/kwan/springbootkwan/mapper/InterviewQuestionMapper.java
+15
-0
src/main/java/com/kwan/springbootkwan/service/InterviewQuestionService.java
...kwan/springbootkwan/service/InterviewQuestionService.java
+16
-0
src/main/java/com/kwan/springbootkwan/service/impl/InterviewQuestionServiceImpl.java
...ngbootkwan/service/impl/InterviewQuestionServiceImpl.java
+56
-0
src/test/java/com/kwan/springbootkwan/SensitiveTest.java
src/test/java/com/kwan/springbootkwan/SensitiveTest.java
+1
-1
src/test/java/com/kwan/springbootkwan/controller/ChatbotControllerTest.java
...kwan/springbootkwan/controller/ChatbotControllerTest.java
+2
-2
src/test/java/com/kwan/springbootkwan/utils/PinyinUtilTest.java
...st/java/com/kwan/springbootkwan/utils/PinyinUtilTest.java
+2
-2
src/test/java/com/kwan/springbootkwan/utils/SnowflakeUtilTest.java
...java/com/kwan/springbootkwan/utils/SnowflakeUtilTest.java
+2
-2
src/test/java/com/kwan/springbootkwan/utils/StringEncryptorUtil.java
...va/com/kwan/springbootkwan/utils/StringEncryptorUtil.java
+2
-2
未找到文件。
src/main/java/com/kwan/springbootkwan/
SpringBootKwan
Application.java
→
src/main/java/com/kwan/springbootkwan/
App
Application.java
浏览文件 @
c33612cd
...
...
@@ -12,10 +12,10 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableScheduling
@EnableBatchProcessing
@SpringBootApplication
public
class
SpringBootKwan
Application
{
public
class
App
Application
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SpringBootKwan
Application
.
class
,
args
);
SpringApplication
.
run
(
App
Application
.
class
,
args
);
System
.
out
.
println
(
"------------------SpringBootKwan应用启动成功--------------------"
);
}
}
src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java
0 → 100644
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.kwan.springbootkwan.entity.InterviewQuestion
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.service.InterviewQuestionService
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
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.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 面试题(InterviewQuestion)表控制层
*
* @author makejava
* @since 2023-09-08 16:31:51
*/
@RestController
@RequestMapping
(
"interviewQuestion"
)
public
class
InterviewQuestionController
{
/**
* 服务对象
*/
@Resource
private
InterviewQuestionService
interviewQuestionService
;
/**
* 导入问题
*
* @return 所有数据
*/
@GetMapping
(
"/upload"
)
public
Result
uploadFile
(
@RequestParam
String
path
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
uploadFile
(
path
));
}
/**
* 分页查询所有数据
*
* @param page 分页对象
* @param interviewQuestion 查询实体
* @return 所有数据
*/
@GetMapping
public
Result
selectAll
(
Page
<
InterviewQuestion
>
page
,
InterviewQuestion
interviewQuestion
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
page
(
page
,
new
QueryWrapper
<>(
interviewQuestion
)));
}
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping
(
"{id}"
)
public
Result
selectOne
(
@PathVariable
Serializable
id
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
getById
(
id
));
}
/**
* 新增数据
*
* @param interviewQuestion 实体对象
* @return 新增结果
*/
@PostMapping
public
Result
insert
(
@RequestBody
InterviewQuestion
interviewQuestion
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
save
(
interviewQuestion
));
}
/**
* 修改数据
*
* @param interviewQuestion 实体对象
* @return 修改结果
*/
@PutMapping
public
Result
update
(
@RequestBody
InterviewQuestion
interviewQuestion
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
updateById
(
interviewQuestion
));
}
/**
* 删除数据
*
* @param idList 主键结合
* @return 删除结果
*/
@DeleteMapping
public
Result
delete
(
@RequestParam
(
"idList"
)
List
<
Long
>
idList
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
removeByIds
(
idList
));
}
}
src/main/java/com/kwan/springbootkwan/entity/InterviewQuestion.java
0 → 100644
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.entity
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 面试题(InterviewQuestion)表实体类
*
* @author makejava
* @since 2023-09-08 16:31:53
*/
@Data
@SuppressWarnings
(
"serial"
)
public
class
InterviewQuestion
extends
Model
<
InterviewQuestion
>
{
//主键id
private
Integer
id
;
//面试问题
private
String
question
;
//问题回答
private
String
response
;
//知识类型,先默认0,后面再区分
private
Integer
type
;
//创建时间
private
Date
createTime
;
//逻辑删除,0未删除,1已删除
private
Integer
isDelete
;
}
src/main/java/com/kwan/springbootkwan/mapper/InterviewQuestionMapper.java
0 → 100644
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springbootkwan.entity.InterviewQuestion
;
/**
* 面试题(InterviewQuestion)表数据库访问层
*
* @author makejava
* @since 2023-09-08 16:31:51
*/
public
interface
InterviewQuestionMapper
extends
BaseMapper
<
InterviewQuestion
>
{
}
src/main/java/com/kwan/springbootkwan/service/InterviewQuestionService.java
0 → 100644
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.InterviewQuestion
;
/**
* 面试题(InterviewQuestion)表服务接口
*
* @author makejava
* @since 2023-09-08 16:31:53
*/
public
interface
InterviewQuestionService
extends
IService
<
InterviewQuestion
>
{
boolean
uploadFile
(
String
path
);
}
src/main/java/com/kwan/springbootkwan/service/impl/InterviewQuestionServiceImpl.java
0 → 100644
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.service.impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.entity.InterviewQuestion
;
import
com.kwan.springbootkwan.mapper.InterviewQuestionMapper
;
import
com.kwan.springbootkwan.service.InterviewQuestionService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.List
;
/**
* 面试题(InterviewQuestion)表服务实现类
*
* @author makejava
* @since 2023-09-08 16:31:53
*/
@Slf4j
@Service
(
"interviewQuestionService"
)
public
class
InterviewQuestionServiceImpl
extends
ServiceImpl
<
InterviewQuestionMapper
,
InterviewQuestion
>
implements
InterviewQuestionService
{
@Resource
private
InterviewQuestionMapper
interviewQuestionMapper
;
@Override
public
boolean
uploadFile
(
String
path
)
{
log
.
info
(
"uploadFile() called with: path= {}"
,
path
);
// 定义文件路径
Path
filePath
=
Paths
.
get
(
path
);
try
{
// 读取文件的所有行到List对象
List
<
String
>
lines
=
Files
.
readAllLines
(
filePath
);
// 遍历List对象并输出每一行
for
(
String
line
:
lines
)
{
QueryWrapper
<
InterviewQuestion
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"question"
,
line
);
// 按照 age 字段降序排列
final
InterviewQuestion
one
=
this
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
log
.
info
(
"uploadFile() called with: question= {}"
,
line
);
InterviewQuestion
interviewQuestion
=
new
InterviewQuestion
();
interviewQuestion
.
setQuestion
(
line
);
interviewQuestion
.
setResponse
(
""
);
this
.
save
(
interviewQuestion
);
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
true
;
}
}
\ No newline at end of file
src/test/java/com/kwan/springbootkwan/SensitiveTest.java
浏览文件 @
c33612cd
...
...
@@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@ContextConfiguration
(
classes
=
SpringBootKwan
Application
.
class
)
@ContextConfiguration
(
classes
=
App
Application
.
class
)
public
class
SensitiveTest
{
@Autowired
...
...
src/test/java/com/kwan/springbootkwan/controller/ChatbotControllerTest.java
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.controller
;
import
com.kwan.springbootkwan.
SpringBootKwan
Application
;
import
com.kwan.springbootkwan.
App
Application
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@ContextConfiguration
(
classes
=
SpringBootKwan
Application
.
class
)
@ContextConfiguration
(
classes
=
App
Application
.
class
)
class
ChatbotControllerTest
{
@Test
...
...
src/test/java/com/kwan/springbootkwan/utils/PinyinUtilTest.java
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.utils
;
import
com.kwan.springbootkwan.
SpringBootKwan
Application
;
import
com.kwan.springbootkwan.
App
Application
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -9,7 +9,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@ContextConfiguration
(
classes
=
SpringBootKwan
Application
.
class
)
@ContextConfiguration
(
classes
=
App
Application
.
class
)
public
class
PinyinUtilTest
{
@Test
...
...
src/test/java/com/kwan/springbootkwan/utils/SnowflakeUtilTest.java
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.utils
;
import
com.kwan.springbootkwan.
SpringBootKwan
Application
;
import
com.kwan.springbootkwan.
App
Application
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -8,7 +8,7 @@ import org.springframework.test.context.ContextConfiguration;
import
org.springframework.test.context.junit4.SpringRunner
;
@RunWith
(
SpringRunner
.
class
)
@ContextConfiguration
(
classes
=
SpringBootKwan
Application
.
class
)
@ContextConfiguration
(
classes
=
App
Application
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
public
class
SnowflakeUtilTest
{
@Test
...
...
src/test/java/com/kwan/springbootkwan/utils/StringEncryptorUtil.java
浏览文件 @
c33612cd
package
com.kwan.springbootkwan.utils
;
import
com.kwan.springbootkwan.
SpringBootKwan
Application
;
import
com.kwan.springbootkwan.
App
Application
;
import
org.jasypt.encryption.StringEncryptor
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -20,7 +20,7 @@ import org.springframework.test.context.junit4.SpringRunner;
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@ContextConfiguration
(
classes
=
SpringBootKwan
Application
.
class
)
@ContextConfiguration
(
classes
=
App
Application
.
class
)
public
class
StringEncryptorUtil
{
@Autowired
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录