文章图片处理
This commit is contained in:
parent
3e552134d9
commit
da26943ea5
|
@ -4,8 +4,12 @@ import com.len.entity.BlogArticle;
|
||||||
import com.len.service.BlogArticleService;
|
import com.len.service.BlogArticleService;
|
||||||
import com.len.util.JsonUtil;
|
import com.len.util.JsonUtil;
|
||||||
import com.len.util.ReType;
|
import com.len.util.ReType;
|
||||||
|
import com.len.util.UploadUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
import tk.mybatis.mapper.entity.Condition;
|
import tk.mybatis.mapper.entity.Condition;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -27,6 +31,12 @@ public class BlogAdminController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BlogArticleService articleService;
|
private BlogArticleService articleService;
|
||||||
|
|
||||||
|
@Value("${lenosp.imagePath}")
|
||||||
|
private String imagePath;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UploadUtil uploadUtil;
|
||||||
|
|
||||||
@GetMapping("/article/getList")
|
@GetMapping("/article/getList")
|
||||||
public ReType getArticleList(BlogArticle article, Integer page, Integer limit) {
|
public ReType getArticleList(BlogArticle article, Integer page, Integer limit) {
|
||||||
return articleService.getList(article, page, limit);
|
return articleService.getList(article, page, limit);
|
||||||
|
@ -54,5 +64,17 @@ public class BlogAdminController {
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/article/addImage")
|
||||||
|
public JsonUtil addImage(MultipartHttpServletRequest request) {
|
||||||
|
MultipartFile multipartFile = request.getFile("file");
|
||||||
|
String path = uploadUtil.upload(multipartFile);
|
||||||
|
JsonUtil json = new JsonUtil();
|
||||||
|
StringBuffer requestURL = request.getRequestURL();
|
||||||
|
int serverPort = request.getServerPort();
|
||||||
|
int i = requestURL.indexOf(String.valueOf(serverPort));
|
||||||
|
String url= requestURL.substring(0,i);
|
||||||
|
json.setData(url+String.valueOf(serverPort)+"/img/"+path);
|
||||||
|
json.setFlag(true);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,7 @@ public class ShiroConfig {
|
||||||
filterMap.put("/login", "verCode,anon");
|
filterMap.put("/login", "verCode,anon");
|
||||||
filterMap.put("/blogLogin", "verCode,anon");
|
filterMap.put("/blogLogin", "verCode,anon");
|
||||||
filterMap.put("/getCode", "anon");
|
filterMap.put("/getCode", "anon");
|
||||||
|
filterMap.put("/img/**", "anon");
|
||||||
filterMap.put("/logout", "logout");
|
filterMap.put("/logout", "logout");
|
||||||
filterMap.put("/plugin/**", "anon");
|
filterMap.put("/plugin/**", "anon");
|
||||||
filterMap.put("/user/**", "per");
|
filterMap.put("/user/**", "per");
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class WebMvcConfig extends WebMvcConfigurationSupport {
|
||||||
.addResourceLocations("classpath:/plugin/", "classpath:/static/");
|
.addResourceLocations("classpath:/plugin/", "classpath:/static/");
|
||||||
registry.addResourceHandler("/ftl/**").addResourceLocations("classpath:/ftl/");
|
registry.addResourceHandler("/ftl/**").addResourceLocations("classpath:/ftl/");
|
||||||
registry.addResourceHandler("/images/**").addResourceLocations("file:" + imagePath);
|
registry.addResourceHandler("/images/**").addResourceLocations("file:" + imagePath);
|
||||||
|
registry.addResourceHandler("/img/**").addResourceLocations("file:" + imagePath);
|
||||||
registry.addResourceHandler("/file/**").addResourceLocations("file:" + imagePath);
|
registry.addResourceHandler("/file/**").addResourceLocations("file:" + imagePath);
|
||||||
super.addResourceHandlers(registry);
|
super.addResourceHandlers(registry);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue