Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
1d86fd9f
Commit
1d86fd9f
authored
Jul 16, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑接口
parent
a74a2161
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
70 additions
and
26 deletions
+70
-26
MyCommentThemeQo.java
...va/com/tanpu/community/api/beans/qo/MyCommentThemeQo.java
+0
-11
CreateThemeResp.java
...a/com/tanpu/community/api/beans/resp/CreateThemeResp.java
+1
-1
FileUploadResp.java
...va/com/tanpu/community/api/beans/resp/FileUploadResp.java
+41
-0
ImagesDTO.java
...main/java/com/tanpu/community/api/beans/vo/ImagesDTO.java
+1
-2
FileController.java
...n/java/com/tanpu/community/controller/FileController.java
+2
-6
FileManager.java
...rc/main/java/com/tanpu/community/manager/FileManager.java
+5
-2
ProductService.java
...main/java/com/tanpu/community/service/ProductService.java
+5
-4
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+15
-0
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/MyCommentThemeQo.java
deleted
100644 → 0
View file @
a74a2161
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
MyCommentThemeQo
extends
ThemeQo
{
@ApiModelProperty
(
value
=
"评论内容"
)
private
String
comment
;
}
community-api/src/main/java/com/tanpu/community/api/beans/resp/CreateThemeResp.java
View file @
1d86fd9f
...
@@ -7,7 +7,7 @@ import lombok.Builder;
...
@@ -7,7 +7,7 @@ import lombok.Builder;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
@ApiModel
(
value
=
"创建主题"
)
@ApiModel
(
value
=
"创建主题
返回值
"
)
@Data
@Data
@Builder
@Builder
@NoArgsConstructor
@NoArgsConstructor
...
...
community-api/src/main/java/com/tanpu/community/api/beans/resp/FileUploadResp.java
0 → 100644
View file @
1d86fd9f
package
com
.
tanpu
.
community
.
api
.
beans
.
resp
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@ApiModel
(
value
=
"文件上传返回"
)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
FileUploadResp
{
@ApiModelProperty
(
value
=
"文件id"
)
private
String
fileId
;
@ApiModelProperty
(
value
=
"文件url"
)
private
String
url
;
@ApiModelProperty
(
value
=
"图片高度"
)
private
Integer
imgHeight
;
@ApiModelProperty
(
value
=
"图片宽度"
)
private
Integer
imgWidth
;
@ApiModelProperty
(
value
=
"类型:1:图片"
)
private
Integer
fileType
;
@ApiModelProperty
(
value
=
"文件名称"
)
private
String
fileName
;
@ApiModelProperty
(
value
=
"阿里云key"
)
private
String
fileOssKey
;
@ApiModelProperty
(
value
=
"预览url"
)
private
String
previewUrl
;
}
community-api/src/main/java/com/tanpu/community/api/beans/vo/ImagesDTO.java
View file @
1d86fd9f
...
@@ -19,8 +19,7 @@ public class ImagesDTO {
...
@@ -19,8 +19,7 @@ public class ImagesDTO {
@ApiModelProperty
(
"关联id"
)
@ApiModelProperty
(
"关联id"
)
private
String
relId
;
private
String
relId
;
@ApiModelProperty
(
"图片url"
)
private
String
remark
;
private
String
remark
;
@ApiModelProperty
(
"图片宽度"
)
@ApiModelProperty
(
"图片宽度"
)
...
...
community-service/src/main/java/com/tanpu/community/controller/FileController.java
View file @
1d86fd9f
package
com
.
tanpu
.
community
.
controller
;
package
com
.
tanpu
.
community
.
controller
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.community.api.beans.resp.FileUploadResp
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.manager.FileManager
;
import
com.tanpu.community.manager.FileManager
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.Date
;
@RestController
@RestController
@Slf4j
@Slf4j
@RequestMapping
(
value
=
"/api/file"
)
@RequestMapping
(
value
=
"/api/file"
)
...
@@ -22,7 +18,7 @@ public class FileController {
...
@@ -22,7 +18,7 @@ public class FileController {
@PostMapping
(
"/uploadFile"
)
@PostMapping
(
"/uploadFile"
)
@ResponseBody
@ResponseBody
public
CommonResp
<
File
RecordEntity
>
uploadToRemote
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
)
{
public
CommonResp
<
File
UploadResp
>
uploadToRemote
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
)
{
return
CommonResp
.
success
(
fileManager
.
uploadFile
(
file
));
return
CommonResp
.
success
(
fileManager
.
uploadFile
(
file
));
}
}
}
}
community-service/src/main/java/com/tanpu/community/manager/FileManager.java
View file @
1d86fd9f
...
@@ -2,8 +2,10 @@ package com.tanpu.community.manager;
...
@@ -2,8 +2,10 @@ package com.tanpu.community.manager;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.resp.FileUploadResp
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.service.OSSFileService
;
import
com.tanpu.community.service.OSSFileService
;
import
com.tanpu.community.util.ConvertUtil
;
import
lombok.extern.slf4j.Slf4j
;
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
;
...
@@ -22,7 +24,7 @@ public class FileManager {
...
@@ -22,7 +24,7 @@ public class FileManager {
@Autowired
@Autowired
private
OSSFileService
ossFileService
;
private
OSSFileService
ossFileService
;
public
File
RecordEntity
uploadFile
(
MultipartFile
file
)
{
public
File
UploadResp
uploadFile
(
MultipartFile
file
)
{
if
(
file
==
null
)
{
if
(
file
==
null
)
{
throw
new
BizException
(
ErrorCodeConstant
.
FILE_UPLOAD_FAIL
);
throw
new
BizException
(
ErrorCodeConstant
.
FILE_UPLOAD_FAIL
);
}
}
...
@@ -39,7 +41,8 @@ public class FileManager {
...
@@ -39,7 +41,8 @@ public class FileManager {
if
(
data
.
length
==
0
||
StringUtils
.
isEmpty
(
originalName
)){
if
(
data
.
length
==
0
||
StringUtils
.
isEmpty
(
originalName
)){
throw
new
BizException
(
"上传文件为空"
);
throw
new
BizException
(
"上传文件为空"
);
}
}
return
ossFileService
.
uploadFile
(
data
,
originalName
);
FileRecordEntity
fileRecordEntity
=
ossFileService
.
uploadFile
(
data
,
originalName
);
return
ConvertUtil
.
fileRecordEntity2Resp
(
fileRecordEntity
);
}
}
public
Map
<
String
,
String
>
getFileUrlByIds
(
List
<
String
>
fileIds
){
public
Map
<
String
,
String
>
getFileUrlByIds
(
List
<
String
>
fileIds
){
...
...
community-service/src/main/java/com/tanpu/community/service/ProductService.java
View file @
1d86fd9f
...
@@ -5,15 +5,15 @@ import com.google.common.collect.Sets;
...
@@ -5,15 +5,15 @@ import com.google.common.collect.Sets;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
com.tanpu.community.api.beans.qo.AttachmentDetailVo
;
import
com.tanpu.community.api.beans.qo.AttachmentDetailVo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeContentQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.qo.ThemeQo
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp
;
import
com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp
;
import
com.tanpu.community.api.beans.vo.feign.product.FundInfoBaseResp
;
import
com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO
;
import
com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO
;
import
com.tanpu.community.api.beans.vo.feign.course.ShortVideoBaseInfoResp
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp
;
import
com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp
;
import
com.tanpu.community.api.enums.RelTypeEnum
;
import
com.tanpu.community.api.enums.RelTypeEnum
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.dao.entity.community.FileRecordEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
...
@@ -225,6 +225,7 @@ public class ProductService {
...
@@ -225,6 +225,7 @@ public class ProductService {
imgMap
.
putAll
(
fileRecordEntities
.
stream
().
collect
(
Collectors
imgMap
.
putAll
(
fileRecordEntities
.
stream
().
collect
(
Collectors
.
toMap
(
FileRecordEntity:
:
getFileId
,
o
->
o
)));
.
toMap
(
FileRecordEntity:
:
getFileId
,
o
->
o
)));
}
}
}
}
if
(!
CollectionUtils
.
isEmpty
(
topicIds
))
{
if
(!
CollectionUtils
.
isEmpty
(
topicIds
))
{
// 查询话题标题
// 查询话题标题
...
@@ -430,7 +431,7 @@ public class ProductService {
...
@@ -430,7 +431,7 @@ public class ProductService {
themeContent
.
setImgList
(
Collections
.
singletonList
(
imagesDTO
));
themeContent
.
setImgList
(
Collections
.
singletonList
(
imagesDTO
));
}
}
}
}
}
else
if
(
themeContent
.
getType
().
equals
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
))
{
}
else
if
(
themeContent
.
getType
().
equals
(
RelTypeEnum
.
MULTIPLE_IMAGE
.
type
))
{
//多图写入图片宽高
//多图写入图片宽高
List
<
ImagesDTO
>
imgList
=
themeContent
.
getImgList
();
List
<
ImagesDTO
>
imgList
=
themeContent
.
getImgList
();
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
for
(
ImagesDTO
imagesDTO
:
imgList
)
{
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
1d86fd9f
...
@@ -2,6 +2,7 @@ package com.tanpu.community.util;
...
@@ -2,6 +2,7 @@ package com.tanpu.community.util;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.beans.resp.FileUploadResp
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
com.tanpu.community.api.beans.vo.ImagesDTO
;
import
com.tanpu.community.api.beans.vo.TopicDO
;
import
com.tanpu.community.api.beans.vo.TopicDO
;
import
com.tanpu.community.api.beans.qo.*
;
import
com.tanpu.community.api.beans.qo.*
;
...
@@ -12,9 +13,11 @@ import com.tanpu.community.api.enums.RelTypeEnum;
...
@@ -12,9 +13,11 @@ import com.tanpu.community.api.enums.RelTypeEnum;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.community.*
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
com.tanpu.community.dao.entity.user.UserInfoEntity
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
public
class
ConvertUtil
{
public
class
ConvertUtil
{
...
@@ -202,6 +205,18 @@ public class ConvertUtil {
...
@@ -202,6 +205,18 @@ public class ConvertUtil {
.
build
();
.
build
();
}
}
public
static
FileUploadResp
fileRecordEntity2Resp
(
FileRecordEntity
entity
){
FileUploadResp
resp
=
new
FileUploadResp
();
BeanUtils
.
copyProperties
(
entity
,
resp
);
String
extInfo
=
entity
.
getExtInfo
();
if
(!
StringUtils
.
isEmpty
(
extInfo
))
{
Map
<
String
,
Object
>
extMap
=
JsonUtil
.
toMap
(
extInfo
);
resp
.
setImgHeight
((
Integer
)
extMap
.
get
(
"height"
));
resp
.
setImgWidth
((
Integer
)
extMap
.
get
(
"width"
));
}
return
resp
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment