Skip to content

Commit

Permalink
Merge pull request otale#243 from otale/develop
Browse files Browse the repository at this point in the history
☔️ fix article delete fail [bug]
  • Loading branch information
hellokaton authored Sep 19, 2017
2 parents d79f957 + cc6182e commit e6b0f48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.tale.exception;

import com.blade.exception.ExceptionResolve;
import com.blade.ioc.annotation.Bean;
import com.blade.mvc.hook.Signature;
import com.blade.mvc.WebContext;
import com.blade.mvc.handler.DefaultExceptionHandler;
import com.blade.mvc.ui.RestResponse;
import com.blade.validator.exception.ValidateException;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -14,16 +14,17 @@
*/
@Slf4j
@Bean
public class GolbalExceptionResolve implements ExceptionResolve {
public class GolbalExceptionHandler extends DefaultExceptionHandler {

@Override
public boolean handle(Exception e, Signature signature) {
public void handle(Exception e) {
if (e instanceof ValidateException) {
ValidateException validateException = (ValidateException) e;
String msg = validateException.getErrMsg();
signature.response().json(RestResponse.fail(msg));
return false;
String msg = validateException.getErrMsg();
WebContext.response().json(RestResponse.fail(msg));
} else {
super.handle(e);
}
return true;
}

}
5 changes: 2 additions & 3 deletions src/main/java/com/tale/service/ContentsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,10 @@ public void updateArticle(Contents contents) {
*/
public void delete(int cid) {
Optional<Contents> contents = this.getContents(cid + "");
contents.ifPresent(content -> Base.atomic(() -> {
contents.ifPresent(content -> {
new Contents().delete(cid);
new Relationships().delete("cid", cid);
return true;
}));
});
}

/**
Expand Down

0 comments on commit e6b0f48

Please sign in to comment.