Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
软件工程实践2022年春W班
Followers
Project_Team4
提交
f9f70a80
P
Project_Team4
项目概览
软件工程实践2022年春W班
/
Followers
/
Project_Team4
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Project_Team4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f9f70a80
编写于
5月 01, 2022
作者:
LKJKJOIUIU
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加data的size
上级
d6d84c26
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
37 addition
and
20 deletion
+37
-20
backend/src/main/java/com/nav/common/api/CommonResult.java
backend/src/main/java/com/nav/common/api/CommonResult.java
+20
-0
backend/src/main/java/com/nav/controller/PostController.java
backend/src/main/java/com/nav/controller/PostController.java
+2
-6
backend/src/main/java/com/nav/service/PostServiceImpl.java
backend/src/main/java/com/nav/service/PostServiceImpl.java
+2
-1
backend/src/test/java/com/nav/NavApplicationTests.java
backend/src/test/java/com/nav/NavApplicationTests.java
+13
-13
未找到文件。
backend/src/main/java/com/nav/common/api/CommonResult.java
浏览文件 @
f9f70a80
...
...
@@ -19,6 +19,7 @@ public class CommonResult<T> {
* 数据封装
*/
private
T
data
;
private
int
size
;
protected
CommonResult
()
{
}
...
...
@@ -29,6 +30,13 @@ public class CommonResult<T> {
this
.
data
=
data
;
}
protected
CommonResult
(
long
code
,
String
message
,
int
size
,
T
data
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
data
=
data
;
this
.
size
=
size
;
}
/**
* 成功返回结果
*
...
...
@@ -48,6 +56,10 @@ public class CommonResult<T> {
return
new
CommonResult
<
T
>(
ResultCode
.
SUCCESS
.
getCode
(),
message
,
data
);
}
public
static
<
T
>
CommonResult
<
T
>
success
(
T
data
,
int
size
,
String
message
)
{
return
new
CommonResult
<
T
>(
ResultCode
.
SUCCESS
.
getCode
(),
message
,
size
,
data
);
}
/**
* 失败返回结果
* @param errorCode 错误码
...
...
@@ -140,4 +152,12 @@ public class CommonResult<T> {
public
void
setData
(
T
data
)
{
this
.
data
=
data
;
}
public
int
getSize
()
{
return
size
;
}
public
void
setSize
(
int
size
)
{
this
.
size
=
size
;
}
}
backend/src/main/java/com/nav/controller/PostController.java
浏览文件 @
f9f70a80
...
...
@@ -53,12 +53,8 @@ public class PostController {
}
@GetMapping
(
"comment/{id}"
)
public
Map
<
Integer
,
CommonResult
>
getCommentByPostId
(
@PathVariable
long
id
)
{
Map
<
Integer
,
CommonResult
>
map
=
new
HashMap
<>();
CommonResult
commonResult
=
postService
.
getCommentByPostId
(
id
);
List
<
CommentResult
>
commentResult
=
(
List
<
CommentResult
>)
commonResult
.
getData
();
map
.
put
(
commentResult
.
size
(),
commonResult
);
return
map
;
public
CommonResult
getCommentByPostId
(
@PathVariable
long
id
)
{
return
postService
.
getCommentByPostId
(
id
);
}
@GetMapping
(
"lifePost/tag/{tag}"
)
...
...
backend/src/main/java/com/nav/service/PostServiceImpl.java
浏览文件 @
f9f70a80
...
...
@@ -50,7 +50,8 @@ public class PostServiceImpl implements PostService{
@Override
public
CommonResult
getCommentByPostId
(
long
id
)
{
return
CommonResult
.
success
(
commentDao
.
selectCommentByPostId
(
id
),
"请求成功"
);
List
<
Comment
>
commentList
=
commentDao
.
selectCommentByPostId
(
id
);
return
CommonResult
.
success
(
commentList
,
commentList
.
size
(),
"请求成功"
);
}
@Override
...
...
backend/src/test/java/com/nav/NavApplicationTests.java
浏览文件 @
f9f70a80
package
com.nav
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
@SpringBootTest
class
NavApplicationTests
{
@Test
void
contextLoads
()
{
}
}
//
package com.nav;
//
//
import org.junit.jupiter.api.Test;
//
import org.springframework.boot.test.context.SpringBootTest;
//
//
@SpringBootTest
//
class NavApplicationTests {
//
//
@Test
//
void contextLoads() {
//
}
//
//
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录