Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Mar 17, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
2fc94169
Show 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;
...
@@ -4,6 +4,7 @@ import org.apache.commons.io.FilenameUtils;
import
org.csource.common.MyException
;
import
org.csource.common.MyException
;
import
org.csource.common.NameValuePair
;
import
org.csource.common.NameValuePair
;
import
org.csource.fastdfs.*
;
import
org.csource.fastdfs.*
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.ClassPathResource
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -16,6 +17,13 @@ import java.util.Properties;
...
@@ -16,6 +17,13 @@ import java.util.Properties;
*/
*/
public
class
FastDFSUtils
{
public
class
FastDFSUtils
{
private
static
String
dfsFileAccessBasePath
;
@Value
(
"${dfsFileAccessBasePath:#{null}}"
)
public
static
void
setDfsFileAccessBasePath
(
String
dfsFileAccessBasePath
)
{
FastDFSUtils
.
dfsFileAccessBasePath
=
dfsFileAccessBasePath
;
}
static
{
static
{
try
{
try
{
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
...
@@ -53,8 +61,8 @@ public class FastDFSUtils {
...
@@ -53,8 +61,8 @@ public class FastDFSUtils {
return
fileIds
;
return
fileIds
;
}
}
public
static
String
[]
uploadPic
(
InputStream
inStream
,
String
fileName
,
long
size
)
{
public
static
String
uploadInputStream
(
InputStream
inStream
,
String
fileName
,
long
size
)
{
String
[]
fileIds
=
null
;
String
[]
fileIds
;
try
{
try
{
// ClientGloble 读配置文件
// ClientGloble 读配置文件
// 老大客户端
// 老大客户端
...
@@ -64,19 +72,16 @@ public class FastDFSUtils {
...
@@ -64,19 +72,16 @@ public class FastDFSUtils {
StorageClient
storageClient
=
new
StorageClient
(
trackerServer
,
storageServer
);
StorageClient
storageClient
=
new
StorageClient
(
trackerServer
,
storageServer
);
String
extName
=
FilenameUtils
.
getExtension
(
fileName
);
String
extName
=
FilenameUtils
.
getExtension
(
fileName
);
NameValuePair
[]
meta_list
=
new
NameValuePair
[
3
];
NameValuePair
[]
meta_list
=
new
NameValuePair
[
3
];
meta_list
[
0
]
=
new
NameValuePair
(
"fileName"
,
fileName
);
meta_list
[
0
]
=
new
NameValuePair
(
"fileName"
,
fileName
);
meta_list
[
1
]
=
new
NameValuePair
(
"fileExt"
,
extName
);
meta_list
[
1
]
=
new
NameValuePair
(
"fileExt"
,
extName
);
meta_list
[
2
]
=
new
NameValuePair
(
"fileSize"
,
String
.
valueOf
(
size
));
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
);
fileIds
=
storageClient
.
upload_file
(
null
,
size
,
new
UploadFileSender
(
inStream
),
extName
,
meta_list
);
return
dfsFileAccessBasePath
+
"/"
+
fileIds
[
0
]
+
"/"
+
fileIds
[
1
];
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
fileIds
;
return
null
;
}
}
public
static
String
uploadPic
(
byte
[]
pic
,
String
fileName
,
long
size
)
{
public
static
String
uploadPic
(
byte
[]
pic
,
String
fileName
,
long
size
)
{
...
@@ -137,16 +142,19 @@ public class FastDFSUtils {
...
@@ -137,16 +142,19 @@ public class FastDFSUtils {
}
}
private
static
class
UploadFileSender
implements
UploadCallback
{
private
static
class
UploadFileSender
implements
UploadCallback
{
private
InputStream
inStream
;
public
UploadFileSender
(
InputStream
inStream
)
{
private
InputStream
is
;
this
.
inStream
=
inStream
;
public
UploadFileSender
(
InputStream
is
)
{
this
.
is
=
is
;
}
}
@Override
public
int
send
(
OutputStream
out
)
throws
IOException
{
public
int
send
(
OutputStream
out
)
throws
IOException
{
byte
[]
b
=
new
byte
[
1024
];
int
readBytes
;
int
readBytes
;
while
((
readBytes
=
i
nStream
.
read
())
>
0
)
{
while
((
readBytes
=
i
s
.
read
(
b
))
!=
-
1
)
{
out
.
write
(
readBytes
);
out
.
write
(
b
,
0
,
readBytes
);
}
}
return
0
;
return
0
;
}
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/common/enums/AuditStatusEnum.java
View file @
d726ac9c
...
@@ -7,7 +7,7 @@ public enum AuditStatusEnum {
...
@@ -7,7 +7,7 @@ public enum AuditStatusEnum {
TBC
(
"1"
,
"待审核"
),
TBC
(
"1"
,
"待审核"
),
REFUSED
(
"2"
,
"已驳回"
),
REFUSED
(
"2"
,
"已驳回"
),
APPROVED
(
"3"
,
"已
通过"
);
APPROVED
_FIRST
(
"3"
,
"初审
通过"
);
// 错误编码
// 错误编码
private
String
code
;
private
String
code
;
...
...
src/main/java/cn/wisenergy/chnmuseum/party/model/Asset.java
View file @
d726ac9c
package
cn
.
wisenergy
.
chnmuseum
.
party
.
model
;
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
com.baomidou.mybatisplus.annotation.*
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -7,6 +9,7 @@ import lombok.*;
...
@@ -7,6 +9,7 @@ import lombok.*;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -25,33 +28,34 @@ import java.time.LocalDateTime;
...
@@ -25,33 +28,34 @@ import java.time.LocalDateTime;
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@EqualsAndHashCode
(
callSuper
=
false
)
@EqualsAndHashCode
(
callSuper
=
false
)
@TableName
(
"asset"
)
@TableName
(
"asset"
)
@ApiModel
(
value
=
"
Asset对象
"
,
description
=
"视频"
)
@ApiModel
(
value
=
"
视频
"
,
description
=
"视频"
)
public
class
Asset
implements
Serializable
{
public
class
Asset
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
"视频ID"
)
@ApiModelProperty
(
"视频ID"
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@TableId
(
value
=
"id"
,
type
=
IdType
.
ASSIGN_ID
)
@NotNull
(
message
=
"视频ID不能为空"
,
groups
=
{
Update
.
class
})
private
String
id
;
private
String
id
;
@ApiModelProperty
(
"视频名称"
)
@ApiModelProperty
(
"视频名称"
)
@TableField
(
"name"
)
@TableField
(
"name"
)
@NotBlank
(
message
=
"视频名称不能为空"
)
@NotBlank
(
message
=
"视频名称不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
name
;
private
String
name
;
@ApiModelProperty
(
"视频版权方ID"
)
@ApiModelProperty
(
"视频版权方ID"
)
@TableField
(
"asset_copyright_owner_id"
)
@TableField
(
"asset_copyright_owner_id"
)
@NotBlank
(
message
=
"视频版权方ID不能为空"
)
@NotBlank
(
message
=
"视频版权方ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
assetCopyrightOwnerId
;
private
String
assetCopyrightOwnerId
;
@ApiModelProperty
(
"视频类别ID"
)
@ApiModelProperty
(
"视频类别ID"
)
@TableField
(
"asset_type_id"
)
@TableField
(
"asset_type_id"
)
@NotBlank
(
message
=
"视频类别ID不能为空"
)
@NotBlank
(
message
=
"视频类别ID不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
assetTypeId
;
private
String
assetTypeId
;
@ApiModelProperty
(
"视频缩略图"
)
@ApiModelProperty
(
"视频缩略图"
)
@TableField
(
"thumbnail"
)
@TableField
(
"thumbnail"
)
@NotBlank
(
message
=
"视频缩略图不能为空"
)
@NotBlank
(
message
=
"视频缩略图不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
private
String
thumbnail
;
private
String
thumbnail
;
@ApiModelProperty
(
"视频链接"
)
@ApiModelProperty
(
"视频链接"
)
...
@@ -70,4 +74,12 @@ public class Asset implements Serializable {
...
@@ -70,4 +74,12 @@ public class Asset implements Serializable {
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
@TableField
(
value
=
"update_time"
,
fill
=
FieldFill
.
INSERT_UPDATE
)
private
LocalDateTime
updateTime
;
private
LocalDateTime
updateTime
;
@ApiModelProperty
(
"视频分类"
)
@TableField
(
exist
=
false
)
private
String
assetTypeName
;
@ApiModelProperty
(
"版权方"
)
@TableField
(
exist
=
false
)
private
String
assetCopyrightOwnerName
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/AssetController.java
View file @
d726ac9c
package
cn
.
wisenergy
.
chnmuseum
.
party
.
web
.
controller
;
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.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.Add
;
import
cn.wisenergy.chnmuseum.party.common.validator.groups.Update
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam
;
import
cn.wisenergy.chnmuseum.party.model.Asset
;
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.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
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.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
...
@@ -17,11 +26,14 @@ import io.swagger.annotations.ApiOperation;
...
@@ -17,11 +26,14 @@ import io.swagger.annotations.ApiOperation;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.http.MediaType
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.IOException
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -42,25 +54,27 @@ public class AssetController extends BaseController {
...
@@ -42,25 +54,27 @@ public class AssetController extends BaseController {
@Resource
@Resource
private
AssetService
assetService
;
private
AssetService
assetService
;
@PostMapping
(
"/batchSave"
)
@Resource
@RequiresPermissions
(
"asset:batch:save"
)
private
CopyrightOwnerService
copyrightOwnerService
;
@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
();
}
}
@PostMapping
(
"/save"
)
@Resource
private
AssetTypeService
assetTypeService
;
@PostMapping
(
value
=
"/save"
,
headers
=
"content-type=multipart/form-data"
,
produces
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
@RequiresPermissions
(
"asset:save"
)
@RequiresPermissions
(
"asset:save"
)
@ApiOperation
(
value
=
"添加视频"
,
notes
=
"添加视频"
)
@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
);
boolean
result
=
assetService
.
save
(
asset
);
// 返回操作结果
// 返回操作结果
...
@@ -75,7 +89,18 @@ public class AssetController extends BaseController {
...
@@ -75,7 +89,18 @@ public class AssetController extends BaseController {
@PutMapping
(
"/update"
)
@PutMapping
(
"/update"
)
@RequiresPermissions
(
"asset:update"
)
@RequiresPermissions
(
"asset:update"
)
@ApiOperation
(
value
=
"修改视频信息"
,
notes
=
"修改视频信息"
)
@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
);
boolean
flag
=
assetService
.
updateById
(
asset
);
if
(
flag
)
{
if
(
flag
)
{
return
getSuccessResult
();
return
getSuccessResult
();
...
@@ -121,7 +146,7 @@ public class AssetController extends BaseController {
...
@@ -121,7 +146,7 @@ public class AssetController extends BaseController {
@ApiImplicitParams
(
value
=
{
@ApiImplicitParams
(
value
=
{
@ApiImplicitParam
(
name
=
"auditStatus"
,
value
=
"审核状态"
,
paramType
=
"query"
,
dataType
=
"String"
)
@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
()));
List
<
Asset
>
assetList
=
assetService
.
list
(
Wrappers
.<
Asset
>
lambdaQuery
().
eq
(
Asset:
:
getAuditStatus
,
auditStatus
.
name
()));
return
getResult
(
assetList
);
return
getResult
(
assetList
);
}
}
...
@@ -163,7 +188,11 @@ public class AssetController extends BaseController {
...
@@ -163,7 +188,11 @@ public class AssetController extends BaseController {
Asset:
:
getUpdateTime
);
Asset:
:
getUpdateTime
);
Page
<
Asset
>
page
=
this
.
assetService
.
page
(
getPage
(),
queryWrapper
);
Page
<
Asset
>
page
=
this
.
assetService
.
page
(
getPage
(),
queryWrapper
);
for
(
Asset
asset
:
page
.
getRecords
())
{
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
);
return
getResult
(
page
);
}
}
...
@@ -173,9 +202,15 @@ public class AssetController extends BaseController {
...
@@ -173,9 +202,15 @@ public class AssetController extends BaseController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
dataType
=
"String"
,
paramType
=
"path"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"标识ID"
,
dataType
=
"String"
,
paramType
=
"path"
)
})
})
@GetMapping
(
"/get/{id}"
)
@GetMapping
(
"/get/{id}"
)
@RequiresPermissions
(
"asset:get
ByI
d"
)
@RequiresPermissions
(
"asset:get
:i
d"
)
public
Map
<
String
,
Object
>
getById
(
@PathVariable
(
"id"
)
String
id
)
{
public
Map
<
String
,
Object
>
getById
(
@PathVariable
(
"id"
)
String
id
)
{
Asset
asset
=
assetService
.
getById
(
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
);
return
getResult
(
asset
);
}
}
...
...
src/main/resources/templates/controller.java.vm
View file @
d726ac9c
...
@@ -207,7 +207,7 @@ public class ${table.controllerName} {
...
@@ -207,7 +207,7 @@ public class ${table.controllerName} {
})
})
@
GetMapping
(
"/get/{id}"
)
@
GetMapping
(
"/get/{id}"
)
#
if
(${
cfg
.
requiresPermissions
})
#
if
(${
cfg
.
requiresPermissions
})
@
RequiresPermissions
(
"$!{cfg.colonTableName}:get
ByI
d"
)
@
RequiresPermissions
(
"$!{cfg.colonTableName}:get
:i
d"
)
#
end
#
end
public
Map
<
String
,
Object
>
getById
(@
PathVariable
(
"id"
)
String
id
)
{
public
Map
<
String
,
Object
>
getById
(@
PathVariable
(
"id"
)
String
id
)
{
${
entity
}
${
table
.
entityPath
}
=
${
table
.
entityPath
}
Service
.
getById
(
id
);
${
entity
}
${
table
.
entityPath
}
=
${
table
.
entityPath
}
Service
.
getById
(
id
);
...
...
src/main/resources/templates/entity.java.vm
View file @
d726ac9c
...
@@ -52,7 +52,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
...
@@ -52,7 +52,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
@
TableName
(
"${table.name}"
)
@
TableName
(
"${table.name}"
)
#
end
#
end
#
if
(${
swagger2
})
#
if
(${
swagger2
})
@
ApiModel
(
value
=
"$
{entity}对象
"
,
description
=
"$!{table.comment}"
)
@
ApiModel
(
value
=
"$
!{table.comment}
"
,
description
=
"$!{table.comment}"
)
#
end
#
end
#
if
(${
superEntityClass
})
#
if
(${
superEntityClass
})
public
class
${
entity
}
extends
${
superEntityClass
}#
if
(${
activeRecord
})<${
entity
}>#
end
{
public
class
${
entity
}
extends
${
superEntityClass
}#
if
(${
activeRecord
})<${
entity
}>#
end
{
...
@@ -87,6 +87,7 @@ public class ${entity} implements Serializable {
...
@@ -87,6 +87,7 @@ public class ${entity} implements Serializable {
#
elseif
(
!$null.isNull(${idType}) && "$!idType" != "")
#
elseif
(
!$null.isNull(${idType}) && "$!idType" != "")
##
设置主键注解
##
设置主键注解
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
@
TableId
(
value
=
"${field.name}"
,
type
=
IdType
.${
idType
})
@
NotNull
(
message
=
"${field.propertyName}不能为空"
,
groups
=
{
Update
.
class
})
##
是主键类型
##
是主键类型
#
set
($
custom_is_pk
=
true
)
#
set
($
custom_is_pk
=
true
)
#
elseif
(${
field
.
convert
})
#
elseif
(${
field
.
convert
})
...
@@ -119,9 +120,9 @@ public class ${entity} implements Serializable {
...
@@ -119,9 +120,9 @@ public class ${entity} implements Serializable {
#
if
(${
field
.
keyIdentityFlag
})
#
if
(${
field
.
keyIdentityFlag
})
@
NotNull
(
message
=
"${field.propertyName}不能为空"
,
groups
=
{
Update
.
class
})
@
NotNull
(
message
=
"${field.propertyName}不能为空"
,
groups
=
{
Update
.
class
})
#
elseif
(${
field
.
propertyType
}
==
'String'
)
#
elseif
(${
field
.
propertyType
}
==
'String'
)
@
NotBlank
(
message
=
"${field.comment}不能为空"
)
@
NotBlank
(
message
=
"${field.comment}不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
#
else
#
else
@
NotNull
(
message
=
"${field.comment}不能为空"
)
@
NotNull
(
message
=
"${field.comment}不能为空"
,
groups
=
{
Add
.
class
,
Update
.
class
}
)
#
end
#
end
private
${
field
.
propertyType
}
${
field
.
propertyName
};
private
${
field
.
propertyType
}
${
field
.
propertyName
};
#
else
#
else
...
...
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