Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
adbedb77
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看板
提交
adbedb77
编写于
10月 25, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:新增csdn用户crud
上级
6041f44d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
228 addition
and
3 deletion
+228
-3
src/main/java/com/kwan/springbootkwan/controller/AlgorithmicProblemController.java
...ringbootkwan/controller/AlgorithmicProblemController.java
+0
-3
src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java
...om/kwan/springbootkwan/controller/CsdnUserController.java
+132
-0
src/main/java/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java
...a/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java
+61
-0
src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
...m/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
+35
-0
未找到文件。
src/main/java/com/kwan/springbootkwan/controller/AlgorithmicProblemController.java
浏览文件 @
adbedb77
...
...
@@ -29,9 +29,6 @@ import javax.annotation.Resource;
@RequestMapping
(
"algorithmicProblem"
)
public
class
AlgorithmicProblemController
{
/**
* 服务对象
*/
@Resource
private
AlgorithmicProblemService
algorithmicProblemService
;
...
...
src/main/java/com/kwan/springbootkwan/controller/CsdnUserController.java
0 → 100644
浏览文件 @
adbedb77
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.CsdnUserInfo
;
import
com.kwan.springbootkwan.entity.Result
;
import
com.kwan.springbootkwan.entity.dto.CsdnUserInfoDTO
;
import
com.kwan.springbootkwan.entity.query.CsdnUserInfoQuery
;
import
com.kwan.springbootkwan.service.CsdnUserInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
;
@Slf4j
@RestController
@RequestMapping
(
"/csdn/user"
)
public
class
CsdnUserController
{
@Autowired
private
CsdnUserInfoService
csdnUserInfoService
;
/**
* 分页查询所有数据
*
* @return 所有数据
*/
@GetMapping
(
"/page"
)
public
Result
selectAll
(
@RequestParam
Integer
page
,
@RequestParam
Integer
pageSize
,
@RequestParam
String
userName
,
@RequestParam
String
nickName
)
{
Page
<
CsdnUserInfo
>
pageParm
=
new
Page
<>();
pageParm
.
setCurrent
(
page
);
pageParm
.
setSize
(
pageSize
);
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
orderByDesc
(
"user_weight"
);
wrapper
.
eq
(
"is_delete"
,
0
);
if
(
StringUtils
.
isNotEmpty
(
userName
))
{
wrapper
.
eq
(
"user_name"
,
userName
);
}
if
(
StringUtils
.
isNotEmpty
(
nickName
))
{
wrapper
.
like
(
"nick_name"
,
nickName
);
}
return
Result
.
ok
(
CsdnUserInfoDTO
.
Converter
.
INSTANCE
.
from
(
this
.
csdnUserInfoService
.
page
(
pageParm
,
wrapper
)));
}
/**
* 新增用户
*
* @return 所有数据
*/
@PostMapping
(
"/add"
)
public
Result
add
(
@RequestBody
CsdnUserInfoQuery
addInfo
)
{
final
String
userName
=
addInfo
.
getUserName
();
final
Integer
addType
=
addInfo
.
getAddType
();
if
(
StringUtils
.
isEmpty
(
userName
))
{
return
Result
.
error
(
"名字不能为空"
);
}
//批量添加
if
(
addType
==
1
)
{
final
String
[]
split
=
userName
.
split
(
"\n"
);
for
(
String
str
:
split
)
{
str
=
str
.
trim
();
if
(
StringUtils
.
isEmpty
(
str
))
{
continue
;
}
CsdnUserInfo
csdnUserInfo
=
new
CsdnUserInfo
();
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
str
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnUserInfo
one
=
this
.
csdnUserInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnUserInfo
);
csdnUserInfo
.
setUserName
(
str
);
this
.
csdnUserInfoService
.
save
(
csdnUserInfo
);
}
}
}
else
{
CsdnUserInfo
csdnUserInfo
=
new
CsdnUserInfo
();
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"user_name"
,
userName
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
CsdnUserInfo
one
=
this
.
csdnUserInfoService
.
getOne
(
wrapper
);
if
(
one
==
null
)
{
BeanUtils
.
copyProperties
(
addInfo
,
csdnUserInfo
);
this
.
csdnUserInfoService
.
save
(
csdnUserInfo
);
return
Result
.
ok
();
}
else
{
return
Result
.
error
(
"该用户已存在"
);
}
}
return
Result
.
ok
();
}
/**
* 更新用户
*
* @param query
* @return
*/
@PostMapping
(
"/update"
)
public
Result
update
(
@RequestBody
CsdnUserInfoQuery
query
)
{
CsdnUserInfo
csdnUserInfo
=
new
CsdnUserInfo
();
BeanUtils
.
copyProperties
(
query
,
csdnUserInfo
);
return
Result
.
ok
(
this
.
csdnUserInfoService
.
updateById
(
csdnUserInfo
));
}
/**
* 删除用户
*
* @param id
* @return
*/
@GetMapping
(
"/delete"
)
public
Result
delete
(
@RequestParam
(
"id"
)
Integer
id
)
{
CsdnUserInfo
csdnUserInfo
=
new
CsdnUserInfo
();
csdnUserInfo
.
setIsDelete
(
1
);
QueryWrapper
<
CsdnUserInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"id"
,
id
);
return
Result
.
ok
(
this
.
csdnUserInfoService
.
update
(
csdnUserInfo
,
wrapper
));
}
}
src/main/java/com/kwan/springbootkwan/entity/dto/CsdnUserInfoDTO.java
0 → 100644
浏览文件 @
adbedb77
package
com.kwan.springbootkwan.entity.dto
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
com.kwan.springbootkwan.entity.CsdnUserInfo
;
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
;
@Data
public
class
CsdnUserInfoDTO
extends
Model
<
CsdnUserInfoDTO
>
{
/**
* 主键id
*/
private
Integer
id
;
/**
* 用户code
*/
private
String
userName
;
/**
* CSDN用户名称
*/
private
String
nickName
;
/**
* 点赞状态
*/
private
Integer
likeStatus
;
/**
* 收藏状态
*/
private
Integer
collectStatus
;
/**
* 评论状态
*/
private
Integer
commentStatus
;
/**
* 用户权重
*/
private
Integer
userWeight
;
/**
* 文章类型
*/
private
String
articleType
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 逻辑删除,0未删除,1已删除
*/
private
Integer
isDelete
;
@Mapper
(
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
Converter
extends
FromConverter
<
CsdnUserInfoDTO
,
CsdnUserInfo
>
{
Converter
INSTANCE
=
Mappers
.
getMapper
(
Converter
.
class
);
}
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/query/CsdnUserInfoQuery.java
0 → 100644
浏览文件 @
adbedb77
package
com.kwan.springbootkwan.entity.query
;
import
lombok.Data
;
@Data
public
class
CsdnUserInfoQuery
{
/**
* 用户code
*/
private
String
userName
;
/**
* CSDN用户名称
*/
private
String
nickName
;
/**
* 点赞状态
*/
private
Integer
likeStatus
=
0
;
/**
* 收藏状态
*/
private
Integer
collectStatus
=
0
;
/**
* 评论状态
*/
private
Integer
commentStatus
=
0
;
/**
* 用户权重
*/
private
Integer
userWeight
;
/**
* 添加类型
*/
private
Integer
addType
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录