Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
337a5874
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看板
提交
337a5874
编写于
9月 09, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:优化
上级
e4b3b1e3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
54 deletion
+86
-54
src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java
...pringbootkwan/controller/InterviewQuestionController.java
+72
-53
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestionAdd.java
...wan/springbootkwan/entity/query/InterviewQuestionAdd.java
+11
-0
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestionUpdate.java
.../springbootkwan/entity/query/InterviewQuestionUpdate.java
+3
-1
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/InterviewQuestionController.java
浏览文件 @
337a5874
...
@@ -6,22 +6,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -6,22 +6,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.kwan.springbootkwan.entity.InterviewQuestion
;
import
com.kwan.springbootkwan.entity.InterviewQuestion
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.InterviewQuestionDTO
;
import
com.kwan.springbootkwan.entity.dto.InterviewQuestionDTO
;
import
com.kwan.springbootkwan.entity.query.InterviewQuestionAddQuery
;
import
com.kwan.springbootkwan.entity.query.InterviewQuestionAdd
;
import
com.kwan.springbootkwan.entity.query.InterviewQuestionUpdate
;
import
com.kwan.springbootkwan.service.InterviewQuestionService
;
import
com.kwan.springbootkwan.service.InterviewQuestionService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.Serializable
;
import
java.util.List
;
/**
/**
* 面试题(InterviewQuestion)表控制层
* 面试题(InterviewQuestion)表控制层
...
@@ -48,6 +44,16 @@ public class InterviewQuestionController {
...
@@ -48,6 +44,16 @@ public class InterviewQuestionController {
return
Result
.
ok
(
this
.
interviewQuestionService
.
uploadFile
(
path
));
return
Result
.
ok
(
this
.
interviewQuestionService
.
uploadFile
(
path
));
}
}
/**
* 获取面试题的种类的数量
*
* @return
*/
@GetMapping
(
"/questionType"
)
public
Result
questionType
()
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
questionType
());
}
/**
/**
* 分页查询所有数据
* 分页查询所有数据
*
*
...
@@ -79,65 +85,78 @@ public class InterviewQuestionController {
...
@@ -79,65 +85,78 @@ public class InterviewQuestionController {
* @return 所有数据
* @return 所有数据
*/
*/
@PostMapping
(
"/add"
)
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
InterviewQuestionAddQuery
addInfo
)
{
public
Result
add
(
@RequestBody
InterviewQuestionAdd
addInfo
)
{
InterviewQuestion
interviewQuestion
=
new
InterviewQuestion
();
final
Integer
addType
=
addInfo
.
getAddType
();
interviewQuestion
.
setQuestion
(
addInfo
.
getQuestion
());
final
String
question
=
addInfo
.
getQuestion
();
interviewQuestion
.
setQuestionType
(
addInfo
.
getQuestionType
());
if
(
StringUtils
.
isEmpty
(
question
))
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
save
(
interviewQuestion
));
return
Result
.
error
(
"问题不能为空"
);
}
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
question
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
().
replace
(
"- "
,
""
);
if
(
StringUtils
.
isEmpty
(
str
))
{
continue
;
}
InterviewQuestion
interviewQuestion
=
new
InterviewQuestion
();
QueryWrapper
<
InterviewQuestion
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"question"
,
str
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
InterviewQuestion
one
=
this
.
interviewQuestionService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
interviewQuestion
.
setQuestion
(
str
);
interviewQuestion
.
setQuestionType
(
addInfo
.
getQuestionType
());
this
.
interviewQuestionService
.
save
(
interviewQuestion
);
}
}
}
else
{
InterviewQuestion
interviewQuestion
=
new
InterviewQuestion
();
QueryWrapper
<
InterviewQuestion
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"question"
,
question
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
InterviewQuestion
one
=
this
.
interviewQuestionService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
interviewQuestion
.
setQuestion
(
question
);
interviewQuestion
.
setQuestionType
(
addInfo
.
getQuestionType
());
this
.
interviewQuestionService
.
save
(
interviewQuestion
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
(
"该面试问题已存在"
);
}
}
return
Result
.
ok
();
}
}
/**
/**
*
获取面试题的种类的数量
*
更新面试题
*
*
* @param addInfo
* @return
* @return
*/
*/
@GetMapping
(
"/questionType"
)
@PostMapping
(
"/update"
)
public
Result
questionType
()
{
public
Result
update
(
@RequestBody
InterviewQuestionUpdate
addInfo
)
{
return
Result
.
ok
(
interviewQuestionService
.
questionType
());
InterviewQuestion
interviewQuestion
=
new
InterviewQuestion
();
}
interviewQuestion
.
setId
(
addInfo
.
getId
());
interviewQuestion
.
setQuestion
(
addInfo
.
getQuestion
());
/**
interviewQuestion
.
setQuestionType
(
addInfo
.
getQuestionType
());
* 通过主键查询单条数据
*
* @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
));
return
Result
.
ok
(
this
.
interviewQuestionService
.
updateById
(
interviewQuestion
));
}
}
/**
/**
* 删除
数据
* 删除
面试题
*
*
* @param id
List 主键结合
* @param id
* @return
删除结果
* @return
*/
*/
@DeleteMapping
@GetMapping
(
"/delete"
)
public
Result
delete
(
@RequestParam
(
"idList"
)
List
<
Long
>
idList
)
{
public
Result
delete
(
@RequestParam
(
"id"
)
Integer
id
)
{
return
Result
.
ok
(
this
.
interviewQuestionService
.
removeByIds
(
idList
));
InterviewQuestion
interviewQuestion
=
new
InterviewQuestion
();
interviewQuestion
.
setIsDelete
(
1
);
QueryWrapper
<
InterviewQuestion
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"id"
,
id
);
return
Result
.
ok
(
this
.
interviewQuestionService
.
update
(
interviewQuestion
,
wrapper
));
}
}
}
}
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestionAdd.java
0 → 100644
浏览文件 @
337a5874
package
com.kwan.springbootkwan.entity.query
;
import
lombok.Data
;
@Data
public
class
InterviewQuestionAdd
{
private
String
question
;
private
Integer
questionType
;
private
Integer
addType
;
}
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestion
AddQuery
.java
→
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestion
Update
.java
浏览文件 @
337a5874
...
@@ -3,7 +3,9 @@ package com.kwan.springbootkwan.entity.query;
...
@@ -3,7 +3,9 @@ package com.kwan.springbootkwan.entity.query;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
public
class
InterviewQuestionAddQuery
{
public
class
InterviewQuestionUpdate
{
private
Integer
id
;
private
String
question
;
private
String
question
;
private
Integer
questionType
;
private
Integer
questionType
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录