Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blog-api/src/main/java/com/shimh/config/WebMvcConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void configureMessageConverters(List<HttpMessageConverter<?>> converters)
);


List<MediaType> fastMediaTypes = new ArrayList<>();
List<MediaType> fastMediaTypes = new ArrayList();
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);

fastConverter.setFastJsonConfig(fastJsonConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public Result updateArticle(@RequestBody Article article) {
Result r = new Result();

if (null == article.getId()) {
r.setResultCode(ResultCode.USER_NOT_EXIST);
r.setResultCode(ResultCode.PARAM_IS_BLANK);
return r;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public Result updateCategory(@RequestBody Category category) {
Result r = new Result();

if (null == category.getId()) {
r.setResultCode(ResultCode.USER_NOT_EXIST);
r.setResultCode(ResultCode.PARAM_IS_BLANK);
return r;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public Result listTags() {

@GetMapping("detail")
@LogAnnotation(module = "标签", operation = "获取所有标签,详细")
public Result listCategorysDetail() {
List<TagVO> categorys = tagService.findAllDetail();
public Result listTagsDetail() {
List<TagVO> tags = tagService.findAllDetail();

return Result.success(categorys);
return Result.success(tags);
}

@GetMapping("/hot")
Expand Down Expand Up @@ -116,7 +116,7 @@ public Result updateTag(@RequestBody Tag tag) {
Result r = new Result();

if (null == tag.getId()) {
r.setResultCode(ResultCode.USER_NOT_EXIST);
r.setResultCode(ResultCode.PARAM_IS_BLANK);
return r;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -32,7 +33,7 @@ public class UploadController {
@PostMapping("/upload")
@RequiresAuthentication
@LogAnnotation(module = "文件上传", operation = "文件上传")
public Result upload(HttpServletRequest request, MultipartFile image) {
public Result upload(HttpServletRequest request, @RequestParam("image") MultipartFile image) {

Result r = new Result();

Expand Down
11 changes: 7 additions & 4 deletions blog-api/src/main/java/com/shimh/oauth/OAuthSessionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ protected Serializable getSessionId(ServletRequest request, ServletResponse resp
HttpServletRequest httpRequest = (HttpServletRequest) request;
String id = httpRequest.getHeader(OAUTH_TOKEN);

request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, REFERENCED_SESSION_ID_SOURCE);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, id);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
return id;
if (!StringUtils.isEmpty(id)) {
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, REFERENCED_SESSION_ID_SOURCE);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, id);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
return id;
}
return super.getSessionId(request, response);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public List<Article> findAll() {

@Override
public Article getArticleById(Integer id) {
return articleRepository.getOne(id);
return articleRepository.findOne(id);
}

@Override
Expand Down Expand Up @@ -86,7 +86,7 @@ public Integer saveArticle(Article article) {
@Override
@Transactional
public Integer updateArticle(Article article) {
Article oldArticle = articleRepository.getOne(article.getId());
Article oldArticle = articleRepository.findOne(article.getId());

oldArticle.setTitle(article.getTitle());
oldArticle.setSummary(article.getSummary());
Expand Down Expand Up @@ -122,7 +122,7 @@ public List<Article> listArticlesByCategory(Integer id) {
@Transactional
public Article getArticleAndAddViews(Integer id) {
int count = 1;
Article article = articleRepository.getOne(id);
Article article = articleRepository.findOne(id);
article.setViewCounts(article.getViewCounts() + count);
return article;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public List<Category> findAll() {

@Override
public Category getCategoryById(Integer id) {
return categoryRepository.getOne(id);
return categoryRepository.findOne(id);
}

@Override
Expand All @@ -43,7 +43,7 @@ public Integer saveCategory(Category category) {
@Override
@Transactional
public Integer updateCategory(Category category) {
Category oldCategory = categoryRepository.getOne(category.getId());
Category oldCategory = categoryRepository.findOne(category.getId());

oldCategory.setCategoryname(category.getCategoryname());
oldCategory.setAvatar(category.getAvatar());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public List<Comment> findAll() {

@Override
public Comment getCommentById(Integer id) {
return commentRepository.getOne(id);
return commentRepository.findOne(id);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public List<Tag> findAll() {

@Override
public Tag getTagById(Integer id) {
return tagRepository.getOne(id);
return tagRepository.findOne(id);
}

@Override
Expand All @@ -43,7 +43,7 @@ public Integer saveTag(Tag tag) {
@Override
@Transactional
public Integer updateTag(Tag tag) {
Tag oldTag = tagRepository.getOne(tag.getId());
Tag oldTag = tagRepository.findOne(tag.getId());

oldTag.setTagname(tag.getTagname());
oldTag.setAvatar(tag.getAvatar());
Expand Down
4 changes: 2 additions & 2 deletions blog-api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/reso

# datasource
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.url=jdbc:mysql://localhost:3306/blog?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
spring.datasource.url=jdbc:mysql://gz-cdb-rh50u3k3.sql.tencentcdb.com:26324/blog?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.password=1qaz@WSX3edc@123
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

#spring.datasource.initialize=true
Expand Down