Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
340333a4
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看板
提交
340333a4
编写于
10月 09, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:诗词的后端
上级
c103bd9e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
307 addition
and
0 deletion
+307
-0
src/main/java/com/kwan/springbootkwan/controller/AphorismPoetryController.java
...n/springbootkwan/controller/AphorismPoetryController.java
+145
-0
src/main/java/com/kwan/springbootkwan/entity/AphorismPoetry.java
...n/java/com/kwan/springbootkwan/entity/AphorismPoetry.java
+34
-0
src/main/java/com/kwan/springbootkwan/entity/dto/AphorismPoetryDTO.java
...com/kwan/springbootkwan/entity/dto/AphorismPoetryDTO.java
+65
-0
src/main/java/com/kwan/springbootkwan/entity/query/AphorismPoetryQuery.java
...kwan/springbootkwan/entity/query/AphorismPoetryQuery.java
+10
-0
src/main/java/com/kwan/springbootkwan/mapper/AphorismPoetryMapper.java
.../com/kwan/springbootkwan/mapper/AphorismPoetryMapper.java
+15
-0
src/main/java/com/kwan/springbootkwan/service/AphorismPoetryService.java
...om/kwan/springbootkwan/service/AphorismPoetryService.java
+15
-0
src/main/java/com/kwan/springbootkwan/service/impl/AphorismPoetryServiceImpl.java
...pringbootkwan/service/impl/AphorismPoetryServiceImpl.java
+19
-0
src/main/resources/mapper/AphorismPoetryMapper.xml
src/main/resources/mapper/AphorismPoetryMapper.xml
+4
-0
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/AphorismPoetryController.java
0 → 100644
浏览文件 @
340333a4
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.AphorismPoetry
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.AphorismPoetryDTO
;
import
com.kwan.springbootkwan.entity.query.AphorismPoetryQuery
;
import
com.kwan.springbootkwan.service.AphorismPoetryService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
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.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
/**
* 名言警句(AphorismPoetry)表控制层
*
* @author makejava
* @since 2023-10-09 11:13:12
*/
@RestController
@RequestMapping
(
"aphorismPoetry"
)
public
class
AphorismPoetryController
{
/**
* 服务对象
*/
@Resource
private
AphorismPoetryService
aphorismPoetryService
;
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@GetMapping
(
"/page"
)
public
Result
selectAll
(
@RequestParam
Integer
page
,
@RequestParam
Integer
pageSize
,
@RequestParam
String
poetryText
)
{
Page
<
AphorismPoetry
>
pageParm
=
new
Page
<>();
pageParm
.
setCurrent
(
page
);
pageParm
.
setSize
(
pageSize
);
QueryWrapper
<
AphorismPoetry
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
orderByDesc
(
"id"
);
wrapper
.
eq
(
"is_delete"
,
0
);
if
(
StringUtils
.
isNotEmpty
(
poetryText
))
{
wrapper
.
like
(
"poetry_text"
,
poetryText
);
}
return
Result
.
ok
(
AphorismPoetryDTO
.
Converter
.
INSTANCE
.
from
(
this
.
aphorismPoetryService
.
page
(
pageParm
,
wrapper
)));
}
/**
* 随机一题
*/
@GetMapping
(
"/random"
)
public
Result
random
()
{
QueryWrapper
<
AphorismPoetry
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
orderByAsc
(
"rand()"
).
last
(
"limit 1"
);
return
Result
.
ok
(
AphorismPoetryDTO
.
Converter
.
INSTANCE
.
from
(
this
.
aphorismPoetryService
.
getOne
(
wrapper
)));
}
/**
* 新增问题
*
* @return 所有数据
*/
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
AphorismPoetryQuery
poetryQuery
)
{
final
Integer
addType
=
poetryQuery
.
getAddType
();
final
String
poetryText
=
poetryQuery
.
getPoetryText
();
if
(
StringUtils
.
isEmpty
(
poetryText
))
{
return
Result
.
error
(
"内容不能为空"
);
}
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
poetryText
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
().
replace
(
"- "
,
""
);
if
(
StringUtils
.
isEmpty
(
str
))
{
continue
;
}
AphorismPoetry
algorithmicProblem
=
new
AphorismPoetry
();
QueryWrapper
<
AphorismPoetry
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"poetry_text"
,
str
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
AphorismPoetry
one
=
this
.
aphorismPoetryService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
poetryQuery
,
algorithmicProblem
);
algorithmicProblem
.
setPoetryText
(
str
);
this
.
aphorismPoetryService
.
save
(
algorithmicProblem
);
}
}
}
else
{
AphorismPoetry
aphorismPoetry
=
new
AphorismPoetry
();
QueryWrapper
<
AphorismPoetry
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"poetry_text"
,
poetryText
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
AphorismPoetry
one
=
this
.
aphorismPoetryService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
poetryQuery
,
aphorismPoetry
);
this
.
aphorismPoetryService
.
save
(
aphorismPoetry
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
(
"该诗词已存在"
);
}
}
return
Result
.
ok
();
}
/**
* 更新面试题
*
* @param query
* @return
*/
@PostMapping
(
"/update"
)
public
Result
update
(
@RequestBody
AphorismPoetryQuery
query
)
{
AphorismPoetry
aphorismPoetry
=
new
AphorismPoetry
();
BeanUtils
.
copyProperties
(
query
,
aphorismPoetry
);
return
Result
.
ok
(
this
.
aphorismPoetryService
.
updateById
(
aphorismPoetry
));
}
/**
* 删除面试题
*
* @param id
* @return
*/
@GetMapping
(
"/delete"
)
public
Result
delete
(
@RequestParam
(
"id"
)
Integer
id
)
{
AphorismPoetry
aphorismPoetry
=
new
AphorismPoetry
();
aphorismPoetry
.
setIsDelete
(
1
);
QueryWrapper
<
AphorismPoetry
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"id"
,
id
);
return
Result
.
ok
(
this
.
aphorismPoetryService
.
update
(
aphorismPoetry
,
wrapper
));
}
}
src/main/java/com/kwan/springbootkwan/entity/AphorismPoetry.java
0 → 100644
浏览文件 @
340333a4
package
com.kwan.springbootkwan.entity
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
lombok.Data
;
import
java.util.Date
;
/**
* 名言警句(AphorismPoetry)表实体类
*
* @author makejava
* @since 2023-10-09 11:13:13
*/
@SuppressWarnings
(
"serial"
)
@Data
public
class
AphorismPoetry
extends
Model
<
AphorismPoetry
>
{
/**
* 主键id
*/
private
Integer
id
;
/**
* 诗词内容
*/
private
String
poetryText
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 逻辑删除,0未删除,1已删除
*/
private
Integer
isDelete
;
}
src/main/java/com/kwan/springbootkwan/entity/dto/AphorismPoetryDTO.java
0 → 100644
浏览文件 @
340333a4
package
com.kwan.springbootkwan.entity.dto
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
com.kwan.springbootkwan.entity.AphorismPoetry
;
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
;
/**
* 诗词实体类
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/10/9 11:19
*/
@Data
@SuppressWarnings
(
"serial"
)
public
class
AphorismPoetryDTO
extends
Model
<
AphorismPoetryDTO
>
{
/**
* 主键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
<
AphorismPoetryDTO
,
AphorismPoetry
>
{
AphorismPoetryDTO
.
Converter
INSTANCE
=
Mappers
.
getMapper
(
AphorismPoetryDTO
.
Converter
.
class
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/query/AphorismPoetryQuery.java
0 → 100644
浏览文件 @
340333a4
package
com.kwan.springbootkwan.entity.query
;
import
lombok.Data
;
@Data
public
class
AphorismPoetryQuery
{
private
Integer
id
;
private
String
poetryText
;
private
Integer
addType
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/mapper/AphorismPoetryMapper.java
0 → 100644
浏览文件 @
340333a4
package
com.kwan.springbootkwan.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.kwan.springbootkwan.entity.AphorismPoetry
;
/**
* 名言警句(AphorismPoetry)表数据库访问层
*
* @author makejava
* @since 2023-10-09 11:13:12
*/
public
interface
AphorismPoetryMapper
extends
BaseMapper
<
AphorismPoetry
>
{
}
src/main/java/com/kwan/springbootkwan/service/AphorismPoetryService.java
0 → 100644
浏览文件 @
340333a4
package
com.kwan.springbootkwan.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.kwan.springbootkwan.entity.AphorismPoetry
;
/**
* 名言警句(AphorismPoetry)表服务接口
*
* @author makejava
* @since 2023-10-09 11:13:13
*/
public
interface
AphorismPoetryService
extends
IService
<
AphorismPoetry
>
{
}
src/main/java/com/kwan/springbootkwan/service/impl/AphorismPoetryServiceImpl.java
0 → 100644
浏览文件 @
340333a4
package
com.kwan.springbootkwan.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.kwan.springbootkwan.mapper.AphorismPoetryMapper
;
import
com.kwan.springbootkwan.entity.AphorismPoetry
;
import
com.kwan.springbootkwan.service.AphorismPoetryService
;
import
org.springframework.stereotype.Service
;
/**
* 名言警句(AphorismPoetry)表服务实现类
*
* @author makejava
* @since 2023-10-09 11:13:13
*/
@Service
(
"aphorismPoetryService"
)
public
class
AphorismPoetryServiceImpl
extends
ServiceImpl
<
AphorismPoetryMapper
,
AphorismPoetry
>
implements
AphorismPoetryService
{
}
src/main/resources/mapper/AphorismPoetryMapper.xml
0 → 100644
浏览文件 @
340333a4
<?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.AphorismPoetryMapper"
>
</mapper>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录