Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
7db3fcb7
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看板
提交
7db3fcb7
编写于
10月 07, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:随机一题
上级
2c2601dd
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
443 addition
and
0 deletion
+443
-0
src/main/java/com/kwan/springbootkwan/controller/AlgorithmicProblemController.java
...ringbootkwan/controller/AlgorithmicProblemController.java
+80
-0
src/main/java/com/kwan/springbootkwan/entity/AlgorithmicProblem.java
...va/com/kwan/springbootkwan/entity/AlgorithmicProblem.java
+68
-0
src/main/java/com/kwan/springbootkwan/entity/dto/AlgorithmicProblemDTO.java
...kwan/springbootkwan/entity/dto/AlgorithmicProblemDTO.java
+63
-0
src/main/java/com/kwan/springbootkwan/entity/dto/AlgorithmicQuestionTypeDTO.java
...springbootkwan/entity/dto/AlgorithmicQuestionTypeDTO.java
+25
-0
src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java
...kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java
+115
-0
src/main/java/com/kwan/springbootkwan/mapper/AlgorithmicProblemMapper.java
.../kwan/springbootkwan/mapper/AlgorithmicProblemMapper.java
+19
-0
src/main/java/com/kwan/springbootkwan/service/AlgorithmicProblemService.java
...wan/springbootkwan/service/AlgorithmicProblemService.java
+20
-0
src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java
...gbootkwan/service/impl/AlgorithmicProblemServiceImpl.java
+39
-0
src/main/resources/mapper/AlgorithmicProblemMapper.xml
src/main/resources/mapper/AlgorithmicProblemMapper.xml
+14
-0
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/AlgorithmicProblemController.java
0 → 100644
浏览文件 @
7db3fcb7
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.AlgorithmicProblem
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicProblemDTO
;
import
com.kwan.springbootkwan.service.AlgorithmicProblemService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
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
;
/**
* 算法题(AlgorithmicProblem)表控制层
*
* @author makejava
* @since 2023-10-07 09:15:45
*/
@RestController
@RequestMapping
(
"algorithmicProblem"
)
public
class
AlgorithmicProblemController
{
/**
* 服务对象
*/
@Resource
private
AlgorithmicProblemService
algorithmicProblemService
;
/**
* 获取面试题的种类的数量
*
* @return
*/
@GetMapping
(
"/questionType"
)
public
Result
questionType
()
{
return
Result
.
ok
(
this
.
algorithmicProblemService
.
questionType
());
}
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@GetMapping
(
"/page"
)
public
Result
selectAll
(
@RequestParam
Integer
page
,
@RequestParam
Integer
pageSize
,
@RequestParam
String
questionName
,
@RequestParam
Integer
questionType
)
{
Page
<
AlgorithmicProblem
>
pageParm
=
new
Page
<>();
pageParm
.
setCurrent
(
page
);
pageParm
.
setSize
(
pageSize
);
QueryWrapper
<
AlgorithmicProblem
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
orderByDesc
(
"id"
);
if
(
questionType
!=
0
)
{
wrapper
.
eq
(
"question_type"
,
questionType
);
}
wrapper
.
eq
(
"is_delete"
,
0
);
if
(
StringUtils
.
isNotEmpty
(
questionName
))
{
wrapper
.
like
(
"question_name"
,
questionName
);
}
return
Result
.
ok
(
AlgorithmicProblemDTO
.
Converter
.
INSTANCE
.
from
(
this
.
algorithmicProblemService
.
page
(
pageParm
,
wrapper
)));
}
/**
* 随机一题
*/
@GetMapping
(
"/random"
)
public
Result
random
()
{
QueryWrapper
<
AlgorithmicProblem
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
orderByAsc
(
"rand()"
).
last
(
"limit 1"
);
return
Result
.
ok
(
AlgorithmicProblemDTO
.
Converter
.
INSTANCE
.
from
(
this
.
algorithmicProblemService
.
getOne
(
wrapper
)));
}
}
src/main/java/com/kwan/springbootkwan/entity/AlgorithmicProblem.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.entity
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 算法题(AlgorithmicProblem)表实体类
*
* @author makejava
* @since 2023-10-07 09:15:47
*/
@Data
public
class
AlgorithmicProblem
extends
Model
<
AlgorithmicProblem
>
{
/**
* 主键id
*/
private
Integer
id
;
/**
* 问题名称
*/
private
String
questionName
;
/**
* 0:'全部';
* 1: '链表';
* 2: '数组';
* 3: 'JVM';
* 4: '并发编程';
* 5:'MySql';
* 6: 'Redis';
* 7: '中间件';
* 8: 'Spring';
* 9: '微服务';
* 10:'分布式';
* 11:'项目';
* 12:'算法';
* 99: '其他';
*/
private
Integer
questionType
;
/**
* 1~10的分值
*/
private
Integer
degreeOfImportance
;
/**
* 1:简单;2:中等;3:困难
*/
private
Integer
degreeOfDifficulty
;
/**
* 困难指数
*/
private
Integer
difficultyOfScore
;
/**
* 力扣的问题号
*/
private
Integer
leetcodeNumber
;
/**
* 力扣的问题链接
*/
private
String
leetcodeLink
;
/**
* 创建时间
*/
private
Date
createTime
;
//逻辑删除,0未删除,1已删除
private
Integer
isDelete
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/dto/AlgorithmicProblemDTO.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.entity.dto
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
com.kwan.springbootkwan.entity.AlgorithmicProblem
;
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
;
/**
* 面试题(InterviewQuestion)表实体类
*
* @author makejava
* @since 2023-09-08 16:31:53
*/
@Data
@SuppressWarnings
(
"serial"
)
public
class
AlgorithmicProblemDTO
extends
Model
<
AlgorithmicProblemDTO
>
{
/**
* 主键id
*/
private
Integer
id
;
/**
* 面试问题
*/
private
String
questionName
;
/**
* 类型
*/
private
Integer
questionType
;
/**
* 1~10的分值
*/
private
Integer
degreeOfImportance
;
/**
* 1:简单;2:中等;3:困难
*/
private
Integer
degreeOfDifficulty
;
/**
* 困难指数
*/
private
Integer
difficultyOfScore
;
/**
* 力扣的问题号
*/
private
Integer
leetcodeNumber
;
/**
* 力扣的问题链接
*/
private
String
leetcodeLink
;
/**
* 创建时间
*/
private
Date
createTime
;
@Mapper
(
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
Converter
extends
FromConverter
<
AlgorithmicProblemDTO
,
AlgorithmicProblem
>
{
AlgorithmicProblemDTO
.
Converter
INSTANCE
=
Mappers
.
getMapper
(
AlgorithmicProblemDTO
.
Converter
.
class
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/dto/AlgorithmicQuestionTypeDTO.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.entity.dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
AlgorithmicQuestionTypeDTO
{
/**
* 问题类型编码
*/
private
Integer
questionType
;
/**
* 问题类型名称
*/
private
String
name
;
/**
* 问题类型数量
*/
private
Integer
typeSize
;
}
src/main/java/com/kwan/springbootkwan/enums/AlgorithmicProblemTypeEnum.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.enums
;
import
lombok.Getter
;
import
lombok.ToString
;
@Getter
@ToString
public
enum
AlgorithmicProblemTypeEnum
{
/**
* 全部
*/
type_00
(
0
,
"全部"
),
/**
* 链表
*/
type_01
(
1
,
"链表"
),
/**
* 数组
*/
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_13
(
13
,
"反问环节"
),
/**
* 设计模式
*/
type_14
(
14
,
"设计模式"
),
/**
* 其他
*/
type_99
(
99
,
"其他"
);
private
Integer
code
;
private
String
name
;
AlgorithmicProblemTypeEnum
(
Integer
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
/**
* 通过code获取name
*
* @param code
* @return
*/
public
static
String
getNameByCode
(
Integer
code
)
{
for
(
AlgorithmicProblemTypeEnum
enums
:
AlgorithmicProblemTypeEnum
.
values
())
{
if
(
enums
.
getCode
().
equals
(
code
))
{
return
enums
.
getName
();
}
}
return
null
;
}
/**
* 通过value取枚举
*
* @param value
* @return
*/
public
static
AlgorithmicProblemTypeEnum
getBrandDetailNoByValue
(
String
value
)
{
if
(
null
==
value
)
{
return
null
;
}
for
(
AlgorithmicProblemTypeEnum
enums
:
AlgorithmicProblemTypeEnum
.
values
())
{
if
(
enums
.
getCode
().
equals
(
value
))
{
return
enums
;
}
}
return
null
;
}
}
src/main/java/com/kwan/springbootkwan/mapper/AlgorithmicProblemMapper.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springbootkwan.entity.AlgorithmicProblem
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO
;
import
java.util.LinkedList
;
/**
* 算法题(AlgorithmicProblem)表数据库访问层
*
* @author makejava
* @since 2023-10-07 09:15:45
*/
public
interface
AlgorithmicProblemMapper
extends
BaseMapper
<
AlgorithmicProblem
>
{
LinkedList
<
AlgorithmicQuestionTypeDTO
>
questionType
();
}
src/main/java/com/kwan/springbootkwan/service/AlgorithmicProblemService.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.AlgorithmicProblem
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO
;
import
java.util.List
;
/**
* 算法题(AlgorithmicProblem)表服务接口
*
* @author makejava
* @since 2023-10-07 09:15:47
*/
public
interface
AlgorithmicProblemService
extends
IService
<
AlgorithmicProblem
>
{
List
<
AlgorithmicQuestionTypeDTO
>
questionType
();
}
src/main/java/com/kwan/springbootkwan/service/impl/AlgorithmicProblemServiceImpl.java
0 → 100644
浏览文件 @
7db3fcb7
package
com.kwan.springbootkwan.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.entity.AlgorithmicProblem
;
import
com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO
;
import
com.kwan.springbootkwan.enums.AlgorithmicProblemTypeEnum
;
import
com.kwan.springbootkwan.mapper.AlgorithmicProblemMapper
;
import
com.kwan.springbootkwan.service.AlgorithmicProblemService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
* 算法题(AlgorithmicProblem)表服务实现类
*
* @author makejava
* @since 2023-10-07 09:15:47
*/
@Service
(
"algorithmicProblemService"
)
public
class
AlgorithmicProblemServiceImpl
extends
ServiceImpl
<
AlgorithmicProblemMapper
,
AlgorithmicProblem
>
implements
AlgorithmicProblemService
{
@Autowired
private
AlgorithmicProblemMapper
interviewQuestionMapper
;
@Override
public
List
<
AlgorithmicQuestionTypeDTO
>
questionType
()
{
//获取种类,并按数量排序
LinkedList
<
AlgorithmicQuestionTypeDTO
>
types
=
interviewQuestionMapper
.
questionType
();
types
.
addFirst
(
new
AlgorithmicQuestionTypeDTO
(
0
,
"全部"
,
0
));
for
(
AlgorithmicQuestionTypeDTO
algorithmicQuestionTypeDTO
:
types
)
{
//数据库存的是问题类型的编码
algorithmicQuestionTypeDTO
.
setName
(
AlgorithmicProblemTypeEnum
.
getNameByCode
(
algorithmicQuestionTypeDTO
.
getQuestionType
()));
}
return
types
;
}
}
src/main/resources/mapper/AlgorithmicProblemMapper.xml
0 → 100644
浏览文件 @
7db3fcb7
<?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.kwan.springbootkwan.mapper.AlgorithmicProblemMapper"
>
<select
id=
"questionType"
resultType=
"com.kwan.springbootkwan.entity.dto.AlgorithmicQuestionTypeDTO"
>
SELECT DISTINCT question_type AS questionType, COUNT(*) AS typeSize
FROM algorithmic_problem
WHERE 1 = 1
AND is_delete = 0
AND question_type != 0
GROUP BY question_type
ORDER BY typeSize DESC
</select>
</mapper>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录