Commit 4e39694e authored by zhengjie's avatar zhengjie
Browse files

v1.6 版本发布 ,详情查看版本说明

parent f63407fd
...@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy; ...@@ -10,7 +10,7 @@ import org.mapstruct.ReportingPolicy;
* @author jie * @author jie
* @date 2018-11-23 * @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> { public interface RoleMapper extends EntityMapper<RoleDTO, Role> {
} }
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
maigin-bottom: 10px; maigin-bottom: 10px;
font-size: 14px; font-size: 14px;
color: #555;"> 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> <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>
<div class="foot-hr hr" style="margin: 0 auto; <div class="foot-hr hr" style="margin: 0 auto;
......
...@@ -30,12 +30,6 @@ public class ${className}Controller { ...@@ -30,12 +30,6 @@ public class ${className}Controller {
private static final String ENTITY_NAME = "${changeClassName}"; private static final String ENTITY_NAME = "${changeClassName}";
@GetMapping(value = "/${changeClassName}/{id}")
@PreAuthorize("hasAnyRole('ADMIN')")
public ResponseEntity get${className}(@PathVariable ${pkColumnType} id){
return new ResponseEntity(${changeClassName}Service.findById(id), HttpStatus.OK);
}
@Log("查询${className}") @Log("查询${className}")
@GetMapping(value = "/${changeClassName}") @GetMapping(value = "/${changeClassName}")
@PreAuthorize("hasAnyRole('ADMIN')") @PreAuthorize("hasAnyRole('ADMIN')")
......
...@@ -3,7 +3,6 @@ package me.zhengjie.config; ...@@ -3,7 +3,6 @@ package me.zhengjie.config;
import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement; import javax.servlet.MultipartConfigElement;
import java.io.File; import java.io.File;
...@@ -20,7 +19,7 @@ public class MultipartConfig { ...@@ -20,7 +19,7 @@ public class MultipartConfig {
@Bean @Bean
MultipartConfigElement multipartConfigElement() { MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory(); 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); File tmpFile = new File(location);
if (!tmpFile.exists()) { if (!tmpFile.exists()) {
tmpFile.mkdirs(); tmpFile.mkdirs();
......
...@@ -60,8 +60,8 @@ public class QiniuController { ...@@ -60,8 +60,8 @@ public class QiniuController {
public ResponseEntity upload(@RequestParam MultipartFile file){ public ResponseEntity upload(@RequestParam MultipartFile file){
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find()); QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
Map map = new HashMap(); Map map = new HashMap();
map.put("errno",0);
map.put("id",qiniuContent.getId()); map.put("id",qiniuContent.getId());
map.put("errno",0);
map.put("data",new String[]{qiniuContent.getUrl()}); map.put("data",new String[]{qiniuContent.getUrl()});
return new ResponseEntity(map,HttpStatus.OK); return new ResponseEntity(map,HttpStatus.OK);
} }
......
package me.zhengjie.service.impl; package me.zhengjie.service.impl;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
...@@ -12,17 +13,12 @@ import me.zhengjie.utils.ElAdminConstant; ...@@ -12,17 +13,12 @@ import me.zhengjie.utils.ElAdminConstant;
import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.FileUtil;
import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired; 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.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; 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 org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.HashMap;
import java.util.Optional; import java.util.Optional;
/** /**
...@@ -47,25 +43,16 @@ public class PictureServiceImpl implements PictureService { ...@@ -47,25 +43,16 @@ public class PictureServiceImpl implements PictureService {
@Transactional(rollbackFor = Throwable.class) @Transactional(rollbackFor = Throwable.class)
public Picture upload(MultipartFile multipartFile, String username) { public Picture upload(MultipartFile multipartFile, String username) {
File file = FileUtil.toFile(multipartFile); File file = FileUtil.toFile(multipartFile);
//将参数合成一个请求
RestTemplate rest = new RestTemplate();
FileSystemResource resource = new FileSystemResource(file); HashMap<String, Object> paramMap = new HashMap<>();
MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();
param.add("smfile", resource);
//设置头部,必须 paramMap.put("smfile", file);
HttpHeaders headers = new HttpHeaders(); String result= HttpUtil.post(ElAdminConstant.Url.SM_MS_URL, paramMap);
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");
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(param,headers); JSONObject jsonObject = JSONUtil.parseObj(result);
ResponseEntity<String> responseEntity = rest.exchange(ElAdminConstant.Url.SM_MS_URL, HttpMethod.POST, httpEntity, String.class);
JSONObject jsonObject = JSONUtil.parseObj(responseEntity.getBody());
Picture picture = null; Picture picture = null;
if(!jsonObject.get(CODE).toString().equals(SUCCESS)){ 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); picture = JSON.parseObject(jsonObject.get("data").toString(), Picture.class);
...@@ -76,6 +63,7 @@ public class PictureServiceImpl implements PictureService { ...@@ -76,6 +63,7 @@ public class PictureServiceImpl implements PictureService {
//删除临时文件 //删除临时文件
FileUtil.deleteFile(file); FileUtil.deleteFile(file);
return picture; return picture;
} }
@Override @Override
...@@ -88,13 +76,9 @@ public class PictureServiceImpl implements PictureService { ...@@ -88,13 +76,9 @@ public class PictureServiceImpl implements PictureService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delete(Picture picture) { public void delete(Picture picture) {
RestTemplate rest = new RestTemplate();
try { try {
ResponseEntity<String> str = rest.getForEntity(picture.getDelete(), String.class); String result= HttpUtil.get(picture.getDelete());
if(str.getStatusCode().is2xxSuccessful()){ pictureRepository.delete(picture);
pictureRepository.delete(picture);
}
//如果删除的地址出错,直接删除数据库数据
} catch(Exception e){ } catch(Exception e){
pictureRepository.delete(picture); pictureRepository.delete(picture);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment