Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
chnmuseum-party
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liqin
chnmuseum-party
Commits
d726ac9c
Commit
d726ac9c
authored
4 years ago
by
liqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
2fc94169
master
1.0
dev
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
41 deletions
+97
-41
FastDFSUtils.java
...cn/wisenergy/chnmuseum/party/common/dfs/FastDFSUtils.java
+20
-12
AuditStatusEnum.java
...senergy/chnmuseum/party/common/enums/AuditStatusEnum.java
+1
-1
Asset.java
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
+17
-5
AssetController.java
...nergy/chnmuseum/party/web/controller/AssetController.java
+54
-19
controller.java.vm
src/main/resources/templates/controller.java.vm
+1
-1
entity.java.vm
src/main/resources/templates/entity.java.vm
+4
-3
No files found.
src/main/java/cn/wisenergy/chnmuseum/party/common/dfs/FastDFSUtils.java
View file @
d726ac9c
...
...
@@ -4,6 +4,7 @@ import org.apache.commons.io.FilenameUtils;
import
org.csource.common.MyException
;
import
org.csource.common.NameValuePair
;
import
org.csource.fastdfs.*
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ClassPathResource
;
import
java.io.IOException
;
...
...
@@ -16,6 +17,13 @@ import java.util.Properties;
*/
public
class
FastDFSUtils
{
private
static
String
dfsFileAccessBasePath
;
@Value
(
"${dfsFileAccessBasePath:#{null}}"
)
public
static
void
setDfsFileAccessBasePath
(
String
dfsFileAccessBasePath
)
{
FastDFSUtils
.
dfsFileAccessBasePath
=
dfsFileAccessBasePath
;
}
static
{
try
{
Properties
props
=
new
Properties
();
...
...
@@ -53,8 +61,8 @@ public class FastDFSUtils {
return
fileIds
;
}
public
static
String
[]
uploadPic
(
InputStream
inStream
,
String
fileName
,
long
size
)
{
String
[]
fileIds
=
null
;
public
static
String
uploadInputStream
(
InputStream
inStream
,
String
fileName
,
long
size
)
{
String
[]
fileIds
;
try
{
// ClientGloble 读配置文件
// 老大客户端
...
...
@@ -64,19 +72,16 @@ public class FastDFSUtils {
StorageClient
storageClient
=
new
StorageClient
(
trackerServer
,
storageServer
);
String
extName
=
FilenameUtils
.
getExtension
(
fileName
);
NameValuePair
[]
meta_list
=
new
NameValuePair
[
3
];
meta_list
[
0
]
=
new
NameValuePair
(
"fileName"
,
fileName
);
meta_list
[
1
]
=
new
NameValuePair
(
"fileExt"
,
extName
);
meta_list
[
2
]
=
new
NameValuePair
(
"fileSize"
,
String
.
valueOf
(
size
));
// http://172.16.15.244:8081/group1/M00/00/00/rBAP9FfFG62AZsuBAADeW7MfEHA287.png
// group1/M00/00/01/wKjIgFWOYc6APpjAAAD-qk29i78248.jpg
fileIds
=
storageClient
.
upload_file
(
null
,
size
,
new
UploadFileSender
(
inStream
),
extName
,
meta_list
);
return
dfsFileAccessBasePath
+
"/"
+
fileIds
[
0
]
+
"/"
+
fileIds
[
1
];
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
fileIds
;
return
null
;
}
public
static
String
uploadPic
(
byte
[]
pic
,
String
fileName
,
long
size
)
{
...
...
@@ -137,16 +142,19 @@ public class FastDFSUtils {
}
private
static
class
UploadFileSender
implements
UploadCallback
{
private
InputStream
inStream
;
public
UploadFileSender
(
InputStream
inStream
)
{
this
.
inStream
=
inStream
;
private
InputStream
is
;
public
UploadFileSender
(
InputStream
is
)
{
this
.
is
=
is
;
}
@Override
public
int
send
(
OutputStream
out
)
throws
IOException
{
byte
[]
b
=
new
byte
[
1024
];
int
readBytes
;
while
((
readBytes
=
i
nStream
.
read
())
>
0
)
{
out
.
write
(
readBytes
);
while
((
readBytes
=
i
s
.
read
(
b
))
!=
-
1
)
{
out
.
write
(
b
,
0
,
readBytes
);
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/cn/wisenergy/chnmuseum/party/common/enums/AuditStatusEnum.java
View file @
d726ac9c
...
...
@@ -7,7 +7,7 @@ public enum AuditStatusEnum {
TBC
(
"1"
,
"待审核"
),
REFUSED
(
"2"
,
"已驳回"
),
APPROVED
(
"3"
,
"已
通过"
);
APPROVED
_FIRST
(
"3"
,
"初审
通过"
);
// 错误编码
private
String
code
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
View file @
d726ac9c
package
cn
.
wisenergy
.
chnmuseum
.
party
.
model
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
com.baomidou.mybatisplus.annotation.*
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -7,6 +9,7 @@ import lombok.*;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
...
...
@@ -25,33 +28,34 @@ import java.time.LocalDateTime;
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"asset"
)
@ApiModel
(
value
=
"
Asset对象
"
,
description
=
"视频"
)
@ApiModel
(
value
=
"
视频
"
,
description
=
"视频"
)
public
class
Asset
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"视频ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@NotNull
(
message
=
"视频ID不能为空"
,
groups
=
{
Update
.
class
})
private
String
id
;
@ApiModelProperty
(
"视频名称"
)
@TableField
(
"name"
)
@NotBlank
(
message
=
"视频名称不能为空"
)
@NotBlank
(
message
=
"视频名称不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
name
;
@ApiModelProperty
(
"视频版权方ID"
)
@TableField
(
"asset_copyright_owner_id"
)
@NotBlank
(
message
=
"视频版权方ID不能为空"
)
@NotBlank
(
message
=
"视频版权方ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
assetCopyrightOwnerId
;
@ApiModelProperty
(
"视频类别ID"
)
@TableField
(
"asset_type_id"
)
@NotBlank
(
message
=
"视频类别ID不能为空"
)
@NotBlank
(
message
=
"视频类别ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
assetTypeId
;
@ApiModelProperty
(
"视频缩略图"
)
@TableField
(
"thumbnail"
)
@NotBlank
(
message
=
"视频缩略图不能为空"
)
@NotBlank
(
message
=
"视频缩略图不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
thumbnail
;
@ApiModelProperty
(
"视频链接"
)
...
...
@@ -70,4 +74,12 @@ public class Asset implements Serializable {
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
private
LocalDateTime
updateTime
;
@ApiModelProperty
(
"视频分类"
)
@TableField
(
exist
=
false
)
private
String
assetTypeName
;
@ApiModelProperty
(
"版权方"
)
@TableField
(
exist
=
false
)
private
String
assetCopyrightOwnerName
;
}
This diff is collapsed.
Click to expand it.
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java
View file @
d726ac9c
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
import
cn.wisenergy.chnmuseum.party.common.dfs.FastDFSUtils
;
import
cn.wisenergy.chnmuseum.party.common.enums.AuditStatusEnum
;
import
cn.wisenergy.chnmuseum.party.common.enums.RESPONSE_CODE_ENUM
;
import
cn.wisenergy.chnmuseum.party.common.mvc.InterfaceException
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
import
cn.wisenergy.chnmuseum.party.model.AssetType
;
import
cn.wisenergy.chnmuseum.party.model.CopyrightOwner
;
import
cn.wisenergy.chnmuseum.party.service.AssetService
;
import
cn.wisenergy.chnmuseum.party.service.AssetTypeService
;
import
cn.wisenergy.chnmuseum.party.service.CopyrightOwnerService
;
import
cn.wisenergy.chnmuseum.party.web.controller.base.BaseController
;
import
com.baidu.ueditor.extend.MultipartFile
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
...
@@ -17,11 +26,14 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.http.MediaType
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotNull
;
import
java.io.IOException
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -42,25 +54,27 @@ public class AssetController extends BaseController {
@Resource
private
AssetService
assetService
;
@PostMapping
(
"/batchSave"
)
@RequiresPermissions
(
"asset:batch:save"
)
@ApiOperation
(
value
=
"批量添加视频"
,
notes
=
"批量添加视频"
)
public
Map
<
String
,
Object
>
batchSaveAsset
(
@Validated
(
value
=
{
Add
.
class
})
List
<
Asset
>
assetList
)
{
// 保存业务节点信息
boolean
result
=
assetService
.
saveBatch
(
assetList
);
// 返回操作结果
if
(
result
)
{
return
getSuccessResult
();
}
else
{
// 保存失败
return
getFailResult
();
}
}
@Resource
private
CopyrightOwnerService
copyrightOwnerService
;
@Resource
private
AssetTypeService
assetTypeService
;
@PostMapping
(
"/save"
)
@PostMapping
(
value
=
"/save"
,
headers
=
"content-type=multipart/form-data"
,
produces
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
@RequiresPermissions
(
"asset:save"
)
@ApiOperation
(
value
=
"添加视频"
,
notes
=
"添加视频"
)
public
Map
<
String
,
Object
>
saveAsset
(
@Validated
(
value
=
{
Add
.
class
})
Asset
asset
)
{
public
Map
<
String
,
Object
>
saveAsset
(
@Validated
(
value
=
{
Add
.
class
})
Asset
asset
,
@RequestParam
(
value
=
"files"
)
MultipartFile
[]
files
)
throws
IOException
{
if
(
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
REQUEST_PARAMS_ERROR
.
getCode
(),
"视频必须上传"
);
}
final
Map
<
String
,
String
>
filesMetadata
=
new
LinkedHashMap
<>(
2
);
for
(
MultipartFile
file
:
files
)
{
// 原始文件名
String
originalFilename
=
file
.
getOriginalFilename
();
String
url
=
FastDFSUtils
.
uploadInputStream
(
file
.
getInputStream
(),
originalFilename
,
file
.
getSize
());
filesMetadata
.
put
(
originalFilename
.
trim
(),
url
);
}
asset
.
setAuditStatus
(
AuditStatusEnum
.
TBC
.
name
());
// 保存业务节点信息
boolean
result
=
assetService
.
save
(
asset
);
// 返回操作结果
...
...
@@ -75,7 +89,18 @@ public class AssetController extends BaseController {
@PutMapping
(
"/update"
)
@RequiresPermissions
(
"asset:update"
)
@ApiOperation
(
value
=
"修改视频信息"
,
notes
=
"修改视频信息"
)
public
Map
<
String
,
Object
>
updateAsset
(
@Validated
Asset
asset
)
{
public
Map
<
String
,
Object
>
updateAsset
(
@Validated
(
value
=
{
Update
.
class
})
Asset
asset
,
@RequestParam
(
value
=
"files"
)
MultipartFile
[]
files
)
throws
IOException
{
if
(
files
.
length
>
0
)
{
final
Map
<
String
,
String
>
filesMetadata
=
new
LinkedHashMap
<>(
2
);
for
(
MultipartFile
file
:
files
)
{
// 上传简单文件名
String
originalFilename
=
file
.
getOriginalFilename
();
String
url
=
FastDFSUtils
.
uploadInputStream
(
file
.
getInputStream
(),
originalFilename
,
file
.
getSize
());
filesMetadata
.
put
(
originalFilename
.
trim
(),
url
);
}
asset
.
setAuditStatus
(
AuditStatusEnum
.
TBC
.
name
());
}
asset
.
setAuditStatus
(
AuditStatusEnum
.
TBC
.
name
());
boolean
flag
=
assetService
.
updateById
(
asset
);
if
(
flag
)
{
return
getSuccessResult
();
...
...
@@ -121,7 +146,7 @@ public class AssetController extends BaseController {
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"auditStatus"
,
value
=
"审核状态"
,
paramType
=
"query"
,
dataType
=
"String"
)
})
public
Map
<
String
,
Object
>
getAssetList
(
@RequestParam
(
value
=
"auditStatus"
,
defaultValue
=
"APPROVED"
,
required
=
false
)
AuditStatusEnum
auditStatus
)
{
public
Map
<
String
,
Object
>
getAssetList
(
@RequestParam
(
value
=
"auditStatus"
,
defaultValue
=
"APPROVED
_FIRST
"
,
required
=
false
)
AuditStatusEnum
auditStatus
)
{
List
<
Asset
>
assetList
=
assetService
.
list
(
Wrappers
.<
Asset
>
lambdaQuery
().
eq
(
Asset:
:
getAuditStatus
,
auditStatus
.
name
()));
return
getResult
(
assetList
);
}
...
...
@@ -163,7 +188,11 @@ public class AssetController extends BaseController {
Asset:
:
getUpdateTime
);
Page
<
Asset
>
page
=
this
.
assetService
.
page
(
getPage
(),
queryWrapper
);
for
(
Asset
asset
:
page
.
getRecords
())
{
AssetType
assetType
=
this
.
assetTypeService
.
getById
(
asset
.
getAssetTypeId
());
asset
.
setAssetTypeName
(
assetType
.
getName
());
CopyrightOwner
copyrightOwner
=
this
.
copyrightOwnerService
.
getById
(
asset
.
getAssetCopyrightOwnerId
());
asset
.
setAssetCopyrightOwnerName
(
copyrightOwner
.
getName
());
}
return
getResult
(
page
);
}
...
...
@@ -173,9 +202,15 @@ public class AssetController extends BaseController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
dataType
=
"String"
,
paramType
=
"path"
)
})
@GetMapping
(
"/get/{id}"
)
@RequiresPermissions
(
"asset:get
ByI
d"
)
@RequiresPermissions
(
"asset:get
:i
d"
)
public
Map
<
String
,
Object
>
getById
(
@PathVariable
(
"id"
)
String
id
)
{
Asset
asset
=
assetService
.
getById
(
id
);
AssetType
assetType
=
this
.
assetTypeService
.
getById
(
asset
.
getAssetTypeId
());
asset
.
setAssetTypeName
(
assetType
.
getName
());
CopyrightOwner
copyrightOwner
=
this
.
copyrightOwnerService
.
getById
(
asset
.
getAssetCopyrightOwnerId
());
asset
.
setAssetCopyrightOwnerName
(
copyrightOwner
.
getName
());
return
getResult
(
asset
);
}
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/templates/controller.java.vm
View file @
d726ac9c
...
...
@@ -207,7 +207,7 @@ public class ${table.controllerName} {
})
@
GetMapping
(
"/get/{id}"
)
#
if
(${
cfg
.
requiresPermissions
})
@
RequiresPermissions
(
"$!{cfg.colonTableName}:get
ByI
d"
)
@
RequiresPermissions
(
"$!{cfg.colonTableName}:get
:i
d"
)
#
end
public
Map
<
String
,
Object
>
getById
(@
PathVariable
(
"id"
)
String
id
)
{
${
entity
}
${
table
.
entityPath
}
=
${
table
.
entityPath
}
Service
.
getById
(
id
);
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/templates/entity.java.vm
View file @
d726ac9c
...
...
@@ -52,7 +52,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
@
TableName
(
"${table.name}"
)
#
end
#
if
(${
swagger2
})
@
ApiModel
(
value
=
"$
{entity}对象
"
,
description
=
"$!{table.comment}"
)
@
ApiModel
(
value
=
"$
!{table.comment}
"
,
description
=
"$!{table.comment}"
)
#
end
#
if
(${
superEntityClass
})
public
class
${
entity
}
extends
${
superEntityClass
}#
if
(${
activeRecord
})<${
entity
}>#
end
{
...
...
@@ -87,6 +87,7 @@ public class ${entity} implements Serializable {
#
elseif
(
!$null.isNull(${idType}) && "$!idType" != "")
##
设置主键注解
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
@
NotNull
(
message
=
"${field.propertyName}不能为空"
,
groups
=
{
Update
.
class
})
##
是主键类型
#
set
($
custom_is_pk
=
true
)
#
elseif
(${
field
.
convert
})
...
...
@@ -119,9 +120,9 @@ public class ${entity} implements Serializable {
#
if
(${
field
.
keyIdentityFlag
})
@
NotNull
(
message
=
"${field.propertyName}不能为空"
,
groups
=
{
Update
.
class
})
#
elseif
(${
field
.
propertyType
}
==
'String'
)
@
NotBlank
(
message
=
"${field.comment}不能为空"
)
@
NotBlank
(
message
=
"${field.comment}不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
#
else
@
NotNull
(
message
=
"${field.comment}不能为空"
)
@
NotNull
(
message
=
"${field.comment}不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
#
end
private
${
field
.
propertyType
}
${
field
.
propertyName
};
#
else
...
...
This diff is collapsed.
Click to expand it.
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