Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
361d64ca
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看板
提交
361d64ca
编写于
10月 07, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:算法页面
上级
7db3fcb7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
139 addition
and
58 deletion
+139
-58
src/main/java/com/kwan/springbootkwan/controller/AlgorithmicProblemController.java
...ringbootkwan/controller/AlgorithmicProblemController.java
+90
-0
src/main/java/com/kwan/springbootkwan/entity/query/AlgorithmicProblemQuery.java
.../springbootkwan/entity/query/AlgorithmicProblemQuery.java
+16
-0
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestionAdd.java
...wan/springbootkwan/entity/query/InterviewQuestionAdd.java
+1
-2
src/main/java/com/kwan/springbootkwan/entity/query/QueryInfo.java
.../java/com/kwan/springbootkwan/entity/query/QueryInfo.java
+0
-2
src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java
...kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java
+15
-54
src/main/java/com/kwan/springbootkwan/service/AlgorithmicProblemService.java
...wan/springbootkwan/service/AlgorithmicProblemService.java
+12
-0
src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java
...gbootkwan/service/impl/AlgorithmicProblemServiceImpl.java
+5
-0
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/AlgorithmicProblemController.java
浏览文件 @
361d64ca
...
@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -6,9 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.kwan.springbootkwan.entity.AlgorithmicProblem
;
import
com.kwan.springbootkwan.entity.AlgorithmicProblem
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicProblemDTO
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicProblemDTO
;
import
com.kwan.springbootkwan.entity.query.AlgorithmicProblemQuery
;
import
com.kwan.springbootkwan.service.AlgorithmicProblemService
;
import
com.kwan.springbootkwan.service.AlgorithmicProblemService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.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
;
...
@@ -41,6 +45,16 @@ public class AlgorithmicProblemController {
...
@@ -41,6 +45,16 @@ public class AlgorithmicProblemController {
return
Result
.
ok
(
this
.
algorithmicProblemService
.
questionType
());
return
Result
.
ok
(
this
.
algorithmicProblemService
.
questionType
());
}
}
/**
* 获取面试题的种类的数量
*
* @return
*/
@GetMapping
(
"/allQuestionType"
)
public
Result
allQuestionType
()
{
return
Result
.
ok
(
this
.
algorithmicProblemService
.
allQuestionType
());
}
/**
/**
* 分页查询所有数据
* 分页查询所有数据
*
*
...
@@ -76,5 +90,81 @@ public class AlgorithmicProblemController {
...
@@ -76,5 +90,81 @@ public class AlgorithmicProblemController {
wrapper
.
orderByAsc
(
"rand()"
).
last
(
"limit 1"
);
wrapper
.
orderByAsc
(
"rand()"
).
last
(
"limit 1"
);
return
Result
.
ok
(
AlgorithmicProblemDTO
.
Converter
.
INSTANCE
.
from
(
this
.
algorithmicProblemService
.
getOne
(
wrapper
)));
return
Result
.
ok
(
AlgorithmicProblemDTO
.
Converter
.
INSTANCE
.
from
(
this
.
algorithmicProblemService
.
getOne
(
wrapper
)));
}
}
/**
* 新增问题
*
* @return 所有数据
*/
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
AlgorithmicProblemQuery
addInfo
)
{
final
Integer
addType
=
addInfo
.
getAddType
();
final
String
questionName
=
addInfo
.
getQuestionName
();
if
(
StringUtils
.
isEmpty
(
questionName
))
{
return
Result
.
error
(
"问题不能为空"
);
}
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
questionName
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
().
replace
(
"- "
,
""
);
if
(
StringUtils
.
isEmpty
(
str
))
{
continue
;
}
AlgorithmicProblem
algorithmicProblem
=
new
AlgorithmicProblem
();
QueryWrapper
<
AlgorithmicProblem
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"question_name"
,
str
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
AlgorithmicProblem
one
=
this
.
algorithmicProblemService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
algorithmicProblem
);
algorithmicProblem
.
setQuestionName
(
str
);
this
.
algorithmicProblemService
.
save
(
algorithmicProblem
);
}
}
}
else
{
AlgorithmicProblem
algorithmicProblem
=
new
AlgorithmicProblem
();
QueryWrapper
<
AlgorithmicProblem
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"question_name"
,
questionName
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
AlgorithmicProblem
one
=
this
.
algorithmicProblemService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
algorithmicProblem
);
this
.
algorithmicProblemService
.
save
(
algorithmicProblem
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
(
"该面试问题已存在"
);
}
}
return
Result
.
ok
();
}
/**
* 更新面试题
*
* @param query
* @return
*/
@PostMapping
(
"/update"
)
public
Result
update
(
@RequestBody
AlgorithmicProblemQuery
query
)
{
AlgorithmicProblem
algorithmicProblem
=
new
AlgorithmicProblem
();
BeanUtils
.
copyProperties
(
query
,
algorithmicProblem
);
return
Result
.
ok
(
this
.
algorithmicProblemService
.
updateById
(
algorithmicProblem
));
}
/**
* 删除面试题
*
* @param id
* @return
*/
@GetMapping
(
"/delete"
)
public
Result
delete
(
@RequestParam
(
"id"
)
Integer
id
)
{
AlgorithmicProblem
algorithmicProblem
=
new
AlgorithmicProblem
();
algorithmicProblem
.
setIsDelete
(
1
);
QueryWrapper
<
AlgorithmicProblem
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"id"
,
id
);
return
Result
.
ok
(
this
.
algorithmicProblemService
.
update
(
algorithmicProblem
,
wrapper
));
}
}
}
src/main/java/com/kwan/springbootkwan/entity/query/AlgorithmicProblemQuery.java
0 → 100644
浏览文件 @
361d64ca
package
com.kwan.springbootkwan.entity.query
;
import
lombok.Data
;
@Data
public
class
AlgorithmicProblemQuery
{
private
Integer
id
;
private
Integer
addType
;
private
String
questionName
;
private
Integer
questionType
;
private
Integer
degreeOfImportance
;
private
Integer
degreeOfDifficulty
;
private
Integer
difficultyOfScore
;
private
Integer
leetcodeNumber
;
private
String
leetcodeLink
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/query/InterviewQuestionAdd.java
浏览文件 @
361d64ca
...
@@ -4,8 +4,7 @@ import lombok.Data;
...
@@ -4,8 +4,7 @@ import lombok.Data;
@Data
@Data
public
class
InterviewQuestionAdd
{
public
class
InterviewQuestionAdd
{
private
Integer
addType
;
private
String
question
;
private
String
question
;
private
Integer
questionType
;
private
Integer
questionType
;
private
Integer
addType
;
}
}
src/main/java/com/kwan/springbootkwan/entity/query/QueryInfo.java
浏览文件 @
361d64ca
...
@@ -4,10 +4,8 @@ import lombok.Data;
...
@@ -4,10 +4,8 @@ import lombok.Data;
@Data
@Data
public
class
QueryInfo
{
public
class
QueryInfo
{
private
String
invQtyA
;
private
String
invQtyA
;
private
String
invQtyB
;
private
String
invQtyB
;
private
String
invQtyC
;
private
String
invQtyC
;
private
String
invQtyD
;
private
String
invQtyD
;
}
}
src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java
浏览文件 @
361d64ca
package
com.kwan.springbootkwan.enums
;
package
com.kwan.springbootkwan.enums
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.ToString
;
import
lombok.ToString
;
import
java.util.LinkedList
;
@Getter
@Getter
@ToString
@ToString
public
enum
AlgorithmicProblemTypeEnum
{
public
enum
AlgorithmicProblemTypeEnum
{
...
@@ -19,55 +22,17 @@ public enum AlgorithmicProblemTypeEnum {
...
@@ -19,55 +22,17 @@ public enum AlgorithmicProblemTypeEnum {
*/
*/
type_02
(
2
,
"数组"
),
type_02
(
2
,
"数组"
),
/**
/**
* JVM
* 二叉树
*/
type_03
(
3
,
"JVM"
),
/**
* 并发编程
*/
type_04
(
4
,
"并发编程"
),
/**
* MySql
*/
type_05
(
5
,
"MySql"
),
/**
* Redis
*/
type_06
(
6
,
"Redis"
),
/**
* 中间件
*/
type_07
(
7
,
"中间件"
),
/**
* Spring
*/
type_08
(
8
,
"Spring"
),
/**
* 微服务
*/
type_09
(
9
,
"微服务"
),
/**
* 分布式
*/
type_10
(
10
,
"分布式"
),
/**
* 项目
*/
type_11
(
11
,
"项目"
),
/**
* 算法
*/
*/
type_
12
(
12
,
"算法
"
),
type_
03
(
3
,
"二叉树
"
),
/**
/**
*
反问环节
*
贪心
*/
*/
type_
13
(
13
,
"反问环节
"
),
type_
04
(
4
,
"贪心
"
),
/**
/**
*
设计模式
*
动态规划
*/
*/
type_
14
(
14
,
"设计模式
"
),
type_
05
(
5
,
"动态规划
"
),
/**
/**
* 其他
* 其他
*/
*/
...
@@ -96,20 +61,16 @@ public enum AlgorithmicProblemTypeEnum {
...
@@ -96,20 +61,16 @@ public enum AlgorithmicProblemTypeEnum {
}
}
/**
/**
*
通过value取
枚举
*
获取所有
枚举
*
*
* @param value
* @return
* @return
*/
*/
public
static
AlgorithmicProblemTypeEnum
getBrandDetailNoByValue
(
String
value
)
{
public
static
LinkedList
<
AlgorithmicQuestionTypeDTO
>
getAll
()
{
if
(
null
==
value
)
{
LinkedList
<
AlgorithmicQuestionTypeDTO
>
list
=
new
LinkedList
<>();
return
null
;
}
for
(
AlgorithmicProblemTypeEnum
enums
:
AlgorithmicProblemTypeEnum
.
values
())
{
for
(
AlgorithmicProblemTypeEnum
enums
:
AlgorithmicProblemTypeEnum
.
values
())
{
if
(
enums
.
getCode
().
equals
(
value
))
{
AlgorithmicQuestionTypeDTO
algorithmicQuestionTypeDTO
=
new
AlgorithmicQuestionTypeDTO
(
enums
.
getCode
(),
enums
.
getName
(),
0
);
return
enums
;
list
.
add
(
algorithmicQuestionTypeDTO
);
}
}
}
return
null
;
return
list
;
}
}
}
}
src/main/java/com/kwan/springbootkwan/service/AlgorithmicProblemService.java
浏览文件 @
361d64ca
...
@@ -14,7 +14,19 @@ import java.util.List;
...
@@ -14,7 +14,19 @@ import java.util.List;
*/
*/
public
interface
AlgorithmicProblemService
extends
IService
<
AlgorithmicProblem
>
{
public
interface
AlgorithmicProblemService
extends
IService
<
AlgorithmicProblem
>
{
/**
* 根据已有数据查询类型
*
* @return
*/
List
<
AlgorithmicQuestionTypeDTO
>
questionType
();
List
<
AlgorithmicQuestionTypeDTO
>
questionType
();
/**
* 问题类型字典
*
* @return
*/
List
<
AlgorithmicQuestionTypeDTO
>
allQuestionType
();
}
}
src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java
浏览文件 @
361d64ca
...
@@ -35,5 +35,10 @@ public class AlgorithmicProblemServiceImpl extends ServiceImpl<AlgorithmicProble
...
@@ -35,5 +35,10 @@ public class AlgorithmicProblemServiceImpl extends ServiceImpl<AlgorithmicProble
}
}
return
types
;
return
types
;
}
}
@Override
public
List
<
AlgorithmicQuestionTypeDTO
>
allQuestionType
()
{
return
AlgorithmicProblemTypeEnum
.
getAll
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录