Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
4e39694e
Commit
4e39694e
authored
Feb 28, 2019
by
zhengjie
Browse files
v1.6 版本发布 ,详情查看版本说明
parent
f63407fd
Changes
46
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java
View file @
4e39694e
...
...
@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author jie
* @date 2018-11-23
*/
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
PermissionMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{
PermissionMapper
.
class
,
MenuMapper
.
class
},
unmappedTargetPolicy
=
ReportingPolicy
.
IGNORE
)
public
interface
RoleMapper
extends
EntityMapper
<
RoleDTO
,
Role
>
{
}
eladmin-system/src/main/resources/template/email/email.ftl
View file @
4e39694e
...
...
@@ -34,7 +34,6 @@
maigin-bottom: 10px;
font-size: 14px;
color: #555;">
<p style="line-height: 12px;">扣扣群:891137268</p>
<p style="line-height: 12px;">Github:<a hover="color: #DA251D;" style="color: #999;" href="https://github.com/elunez/eladmin" target="_blank">https://github.com/elunez/eladmin</a></p>
</div>
<div class="foot-hr hr" style="margin: 0 auto;
...
...
eladmin-system/src/main/resources/template/generator/admin/Controller.ftl
View file @
4e39694e
...
...
@@ -30,12 +30,6 @@ public class ${className}Controller {
private
static
final
S
tring
ENTITY
_
NAME
=
"${changeClassName}"
;
@
G
etMapping
(
value
=
"/${changeClassName}/{id}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN')"
)
public
R
esponseEntity
get
$
{
className
}(
@
P
athVariable
$
{
pkColumnType
}
id
){
return
new
R
esponseEntity
(
$
{
changeClassName
}
S
ervice
.findById
(
id
),
H
ttpStatus
.OK
)
;
}
@
L
og
(
"查询${className}"
)
@
G
etMapping
(
value
=
"/${changeClassName}"
)
@
P
reAuthorize
(
"hasAnyRole('ADMIN')"
)
...
...
eladmin-tools/src/main/java/me/zhengjie/config/MultipartConfig.java
View file @
4e39694e
...
...
@@ -3,7 +3,6 @@ package me.zhengjie.config;
import
org.springframework.boot.web.servlet.MultipartConfigFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.servlet.MultipartConfigElement
;
import
java.io.File
;
...
...
@@ -20,7 +19,7 @@ public class MultipartConfig {
@Bean
MultipartConfigElement
multipartConfigElement
()
{
MultipartConfigFactory
factory
=
new
MultipartConfigFactory
();
String
location
=
System
.
getProperty
(
"user.
dir
"
)
+
"
target
/file/tmp"
;
String
location
=
System
.
getProperty
(
"user.
home
"
)
+
"
/.eladmin
/file/tmp"
;
File
tmpFile
=
new
File
(
location
);
if
(!
tmpFile
.
exists
())
{
tmpFile
.
mkdirs
();
...
...
eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java
View file @
4e39694e
...
...
@@ -60,8 +60,8 @@ public class QiniuController {
public
ResponseEntity
upload
(
@RequestParam
MultipartFile
file
){
QiniuContent
qiniuContent
=
qiNiuService
.
upload
(
file
,
qiNiuService
.
find
());
Map
map
=
new
HashMap
();
map
.
put
(
"errno"
,
0
);
map
.
put
(
"id"
,
qiniuContent
.
getId
());
map
.
put
(
"errno"
,
0
);
map
.
put
(
"data"
,
new
String
[]{
qiniuContent
.
getUrl
()});
return
new
ResponseEntity
(
map
,
HttpStatus
.
OK
);
}
...
...
eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java
View file @
4e39694e
package
me.zhengjie.service.impl
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
...
...
@@ -12,17 +13,12 @@ import me.zhengjie.utils.ElAdminConstant;
import
me.zhengjie.utils.FileUtil
;
import
me.zhengjie.utils.ValidationUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.util.
Arrays
;
import
java.util.
HashMap
;
import
java.util.Optional
;
/**
...
...
@@ -47,25 +43,16 @@ public class PictureServiceImpl implements PictureService {
@Transactional
(
rollbackFor
=
Throwable
.
class
)
public
Picture
upload
(
MultipartFile
multipartFile
,
String
username
)
{
File
file
=
FileUtil
.
toFile
(
multipartFile
);
//将参数合成一个请求
RestTemplate
rest
=
new
RestTemplate
();
FileSystemResource
resource
=
new
FileSystemResource
(
file
);
MultiValueMap
<
String
,
Object
>
param
=
new
LinkedMultiValueMap
<>();
param
.
add
(
"smfile"
,
resource
);
HashMap
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
//设置头部,必须
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setAccept
(
Arrays
.
asList
(
MediaType
.
APPLICATION_JSON
));
headers
.
add
(
"user-agent"
,
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
);
paramMap
.
put
(
"smfile"
,
file
);
String
result
=
HttpUtil
.
post
(
ElAdminConstant
.
Url
.
SM_MS_URL
,
paramMap
);
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
httpEntity
=
new
HttpEntity
<
MultiValueMap
<
String
,
Object
>>(
param
,
headers
);
ResponseEntity
<
String
>
responseEntity
=
rest
.
exchange
(
ElAdminConstant
.
Url
.
SM_MS_URL
,
HttpMethod
.
POST
,
httpEntity
,
String
.
class
);
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
responseEntity
.
getBody
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
result
);
Picture
picture
=
null
;
if
(!
jsonObject
.
get
(
CODE
).
toString
().
equals
(
SUCCESS
)){
throw
new
BadRequestException
(
jsonObject
.
get
(
MSG
).
toString
());
throw
new
BadRequestException
(
jsonObject
.
get
(
MSG
).
toString
());
}
//转成实体类
picture
=
JSON
.
parseObject
(
jsonObject
.
get
(
"data"
).
toString
(),
Picture
.
class
);
...
...
@@ -76,6 +63,7 @@ public class PictureServiceImpl implements PictureService {
//删除临时文件
FileUtil
.
deleteFile
(
file
);
return
picture
;
}
@Override
...
...
@@ -88,13 +76,9 @@ public class PictureServiceImpl implements PictureService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
delete
(
Picture
picture
)
{
RestTemplate
rest
=
new
RestTemplate
();
try
{
ResponseEntity
<
String
>
str
=
rest
.
getForEntity
(
picture
.
getDelete
(),
String
.
class
);
if
(
str
.
getStatusCode
().
is2xxSuccessful
()){
pictureRepository
.
delete
(
picture
);
}
//如果删除的地址出错,直接删除数据库数据
String
result
=
HttpUtil
.
get
(
picture
.
getDelete
());
pictureRepository
.
delete
(
picture
);
}
catch
(
Exception
e
){
pictureRepository
.
delete
(
picture
);
}
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
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