Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
notes2.0
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zjm
notes2.0
Commits
83cc0a73
提交
83cc0a73
authored
3月 08, 2020
作者:
zjm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改附件接口
上级
c360fe55
流水线
#46
已取消 于阶段
变更
5
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
58 行增加
和
3 行删除
+58
-3
AttachmentController.java
...ty/tynotes/job/basic/controller/AttachmentController.java
+11
-2
WorkController.java
...com/zjty/tynotes/job/basic/controller/WorkController.java
+1
-1
AttachmentService.java
...com/zjty/tynotes/job/basic/service/AttachmentService.java
+10
-0
AttachmentServiceImpl.java
...tynotes/job/basic/service/impl/AttachmentServiceImpl.java
+33
-0
ConversionServiceImpl.java
...tynotes/job/basic/service/impl/ConversionServiceImpl.java
+3
-0
没有找到文件。
notes-job/src/main/java/com/zjty/tynotes/job/basic/controller/AttachmentController.java
浏览文件 @
83cc0a73
...
@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
static
org
.
springframework
.
http
.
ResponseEntity
.
ok
;
import
static
org
.
springframework
.
http
.
ResponseEntity
.
ok
;
/**
/**
...
@@ -32,12 +34,19 @@ public class AttachmentController {
...
@@ -32,12 +34,19 @@ public class AttachmentController {
}
}
@PostMapping
(
"/{workId}"
)
@PostMapping
(
"/{workId}"
)
@ApiOperation
(
value
=
"新增附件并将其添加到所属工作中."
,
notes
=
"新增不可在数据中附带id.需要在路径中指定所属工作的id.成功时返回新增数据保存的id."
)
@ApiOperation
(
value
=
"新增附件
结合
并将其添加到所属工作中."
,
notes
=
"新增不可在数据中附带id.需要在路径中指定所属工作的id.成功时返回新增数据保存的id."
)
public
ResponseEntity
<
JobResponse
>
add
(
@RequestBody
Attachment
attachment
,
@PathVariable
String
workId
)
{
public
ResponseEntity
<
JobResponse
>
add
(
@RequestBody
List
<
Attachment
>
attachment
,
@PathVariable
String
workId
)
{
String
saveId
=
attachmentService
.
add
(
attachment
,
workId
);
String
saveId
=
attachmentService
.
add
(
attachment
,
workId
);
return
ok
(
new
JobResponse
(
saveId
));
return
ok
(
new
JobResponse
(
saveId
));
}
}
@PostMapping
(
"/one/{workId}"
)
@ApiOperation
(
value
=
"新增附件并将其添加到所属工作中."
,
notes
=
"新增不可在数据中附带id.需要在路径中指定所属工作的id.成功时返回新增数据保存的id."
)
public
ResponseEntity
<
JobResponse
>
add
(
@RequestBody
Attachment
attachment
)
{
String
saveId
=
attachmentService
.
add
(
attachment
);
return
ok
(
new
JobResponse
(
saveId
));
}
@PutMapping
()
@PutMapping
()
@ApiOperation
(
value
=
"修改附件."
,
notes
=
"修改必须在数据中附带id."
)
@ApiOperation
(
value
=
"修改附件."
,
notes
=
"修改必须在数据中附带id."
)
public
ResponseEntity
<
JobResponse
>
modify
(
@RequestBody
Attachment
attachment
)
{
public
ResponseEntity
<
JobResponse
>
modify
(
@RequestBody
Attachment
attachment
)
{
...
...
notes-job/src/main/java/com/zjty/tynotes/job/basic/controller/WorkController.java
浏览文件 @
83cc0a73
...
@@ -48,7 +48,7 @@ public class WorkController {
...
@@ -48,7 +48,7 @@ public class WorkController {
@ApiOperation
(
value
=
"根据id查询工作."
,
notes
=
"在路径中指定要查询的工作id."
)
@ApiOperation
(
value
=
"根据id查询工作."
,
notes
=
"在路径中指定要查询的工作id."
)
public
ResponseEntity
<
WorkVo
>
findById
(
@PathVariable
String
workId
)
{
public
ResponseEntity
<
WorkVo
>
findById
(
@PathVariable
String
workId
)
{
return
ok
(
conversionService
.
workToVo
(
workService
.
findById
(
workId
)));
return
ok
(
conversionService
.
workToVo
(
workService
.
findById
(
workId
)));
}
}
...
...
notes-job/src/main/java/com/zjty/tynotes/job/basic/service/AttachmentService.java
浏览文件 @
83cc0a73
...
@@ -36,6 +36,16 @@ public interface AttachmentService {
...
@@ -36,6 +36,16 @@ public interface AttachmentService {
*/
*/
String
add
(
Attachment
attachment
,
String
workId
);
String
add
(
Attachment
attachment
,
String
workId
);
/**
* 根据workId新增Attachment并与所属Work建立关系
* 不可附带id
*
* @param attachments Attachment集合对象
* @param workId 所属工作id
* @return Attachment对象的id
*/
String
add
(
List
<
Attachment
>
attachments
,
String
workId
);
/**
/**
* 修改Attachment
* 修改Attachment
* 必须附带id
* 必须附带id
...
...
notes-job/src/main/java/com/zjty/tynotes/job/basic/service/impl/AttachmentServiceImpl.java
浏览文件 @
83cc0a73
...
@@ -90,6 +90,39 @@ public class AttachmentServiceImpl implements AttachmentService {
...
@@ -90,6 +90,39 @@ public class AttachmentServiceImpl implements AttachmentService {
}
}
}
}
@Override
public
String
add
(
List
<
Attachment
>
attachments
,
String
workId
)
{
if
(
attachments
.
size
()
==
0
)
{
String
msg
=
"[Attachment] 没有附件"
;
log
.
error
(
msg
);
throw
new
BadRequestException
(
msg
);
}
for
(
Attachment
attachment
:
attachments
){
Boolean
idMustNull
=
isNull
(
attachment
.
getId
());
if
(
idMustNull
)
{
Boolean
workMustExist
=
workService
.
idExists
(
workId
);
if
(
workMustExist
)
{
String
saveId
=
attachmentRepository
.
save
(
attachment
).
getId
();
Work
work
=
workService
.
findById
(
workId
);
if
(
isNull
(
work
.
getAttachment
()))
{
work
.
setAttachment
(
Lists
.
newArrayList
());
}
work
.
getAttachment
().
add
(
saveId
);
workService
.
modify
(
work
);
}
else
{
String
msg
=
"[job] 指定id的所属工作不存在."
;
log
.
error
(
msg
);
throw
new
NotFoundException
(
msg
);
}
}
else
{
String
msg
=
"[job] 新增数据不可附带id."
;
log
.
error
(
msg
);
throw
new
BadRequestException
(
msg
);
}
}
return
"添加附件成功"
;
}
@Override
@Override
public
String
modify
(
Attachment
attachment
)
{
public
String
modify
(
Attachment
attachment
)
{
Boolean
idExist
=
nonNull
(
attachment
.
getId
());
Boolean
idExist
=
nonNull
(
attachment
.
getId
());
...
...
notes-job/src/main/java/com/zjty/tynotes/job/basic/service/impl/ConversionServiceImpl.java
浏览文件 @
83cc0a73
...
@@ -7,6 +7,7 @@ import com.zjty.tynotes.job.basic.service.AttachmentService;
...
@@ -7,6 +7,7 @@ import com.zjty.tynotes.job.basic.service.AttachmentService;
import
com.zjty.tynotes.job.basic.service.ConversionService
;
import
com.zjty.tynotes.job.basic.service.ConversionService
;
import
com.zjty.tynotes.pas.entity.User
;
import
com.zjty.tynotes.pas.entity.User
;
import
com.zjty.tynotes.pas.service.IUserService
;
import
com.zjty.tynotes.pas.service.IUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -14,6 +15,7 @@ import java.util.ArrayList;
...
@@ -14,6 +15,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
@Slf4j
public
class
ConversionServiceImpl
implements
ConversionService
{
public
class
ConversionServiceImpl
implements
ConversionService
{
@Autowired
@Autowired
IUserService
iUserService
;
IUserService
iUserService
;
...
@@ -23,6 +25,7 @@ public class ConversionServiceImpl implements ConversionService {
...
@@ -23,6 +25,7 @@ public class ConversionServiceImpl implements ConversionService {
@Override
@Override
public
WorkVo
workToVo
(
Work
work
)
{
public
WorkVo
workToVo
(
Work
work
)
{
log
.
info
(
"开始转换对象"
);
User
pUser
=
iUserService
.
findUserById
(
work
.
getPublisher
());
User
pUser
=
iUserService
.
findUserById
(
work
.
getPublisher
());
User
eUser
=
iUserService
.
findUserById
(
work
.
getExecutor
());
User
eUser
=
iUserService
.
findUserById
(
work
.
getExecutor
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论