mirror of https://github.com/halo-dev/halo
Remove Customized Logger
parent
272a38cf12
commit
3714e8e5bf
|
@ -1,6 +1,5 @@
|
||||||
package cc.ryanc.halo;
|
package cc.ryanc.halo;
|
||||||
|
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import cc.ryanc.halo.repository.base.BaseRepositoryImpl;
|
import cc.ryanc.halo.repository.base.BaseRepositoryImpl;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -24,8 +23,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableJpaRepositories(basePackages = {"cc.ryanc.halo.repository"}, repositoryBaseClass = BaseRepositoryImpl.class)
|
@EnableJpaRepositories(basePackages = {"cc.ryanc.halo.repository"}, repositoryBaseClass = BaseRepositoryImpl.class)
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
private final static Logger LOG = Logger.getLogger(Application.class);
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Customize the spring config location
|
// Customize the spring config location
|
||||||
System.setProperty("spring.config.additional-location", "file:${user.home}/halo/,file:${user.home}/halo-dev/");
|
System.setProperty("spring.config.additional-location", "file:${user.home}/halo/,file:${user.home}/halo-dev/");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package cc.ryanc.halo.filter;
|
package cc.ryanc.halo.filter;
|
||||||
|
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import cn.hutool.extra.servlet.ServletUtil;
|
import cn.hutool.extra.servlet.ServletUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
|
@ -15,17 +15,16 @@ import java.io.IOException;
|
||||||
*
|
*
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class LogFilter extends OncePerRequestFilter {
|
public class LogFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(getClass());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
|
||||||
String remoteAddr = ServletUtil.getClientIP(request);
|
String remoteAddr = ServletUtil.getClientIP(request);
|
||||||
|
|
||||||
logger.debug("");
|
log.debug("");
|
||||||
logger.debug("Starting url: [{}], method: [{}], ip: [{}]", request.getRequestURL(), request.getMethod(), remoteAddr);
|
log.debug("Starting url: [{}], method: [{}], ip: [{}]", request.getRequestURL(), request.getMethod(), remoteAddr);
|
||||||
|
|
||||||
// Set start time
|
// Set start time
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
@ -33,7 +32,7 @@ public class LogFilter extends OncePerRequestFilter {
|
||||||
// Do filter
|
// Do filter
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
|
|
||||||
logger.debug("Ending url: [{}], method: [{}], ip: [{}], status: [{}], usage: [{}] ms", request.getRequestURL(), request.getMethod(), remoteAddr, response.getStatus(), (System.currentTimeMillis() - startTime));
|
log.debug("Ending url: [{}], method: [{}], ip: [{}], status: [{}], usage: [{}] ms", request.getRequestURL(), request.getMethod(), remoteAddr, response.getStatus(), (System.currentTimeMillis() - startTime));
|
||||||
logger.debug("");
|
log.debug("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,436 +0,0 @@
|
||||||
package cc.ryanc.halo.logging;
|
|
||||||
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.slf4j.Marker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Customized log.
|
|
||||||
*
|
|
||||||
* @author johnniang
|
|
||||||
* @date 12/5/18
|
|
||||||
*/
|
|
||||||
public final class Logger implements org.slf4j.Logger {
|
|
||||||
|
|
||||||
private final org.slf4j.Logger proxy;
|
|
||||||
|
|
||||||
private Logger(final Class<?> clazz) {
|
|
||||||
proxy = LoggerFactory.getLogger(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Logger(final String className) {
|
|
||||||
proxy = LoggerFactory.getLogger(className);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Logger getLogger(final Class<?> clazz) {
|
|
||||||
return new Logger(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Logger getLogger(final String className) {
|
|
||||||
return new Logger(className);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return proxy.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTraceEnabled() {
|
|
||||||
return proxy.isTraceEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(String msg) {
|
|
||||||
if (isTraceEnabled()) {
|
|
||||||
proxy.trace(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(String format, Object arg) {
|
|
||||||
if (isTraceEnabled()) {
|
|
||||||
proxy.trace(format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(String format, Object arg1, Object arg2) {
|
|
||||||
if (isTraceEnabled()) {
|
|
||||||
proxy.trace(format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(String format, Object... arguments) {
|
|
||||||
if (isTraceEnabled()) {
|
|
||||||
proxy.trace(format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(String msg, Throwable t) {
|
|
||||||
if (isTraceEnabled()) {
|
|
||||||
proxy.trace(msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTraceEnabled(Marker marker) {
|
|
||||||
return proxy.isTraceEnabled(marker);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(Marker marker, String msg) {
|
|
||||||
if (isTraceEnabled(marker)) {
|
|
||||||
proxy.trace(marker, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(Marker marker, String format, Object arg) {
|
|
||||||
if (isTraceEnabled(marker)) {
|
|
||||||
proxy.trace(marker, format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(Marker marker, String format, Object arg1, Object arg2) {
|
|
||||||
if (isTraceEnabled(marker)) {
|
|
||||||
proxy.trace(marker, format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(Marker marker, String format, Object... argArray) {
|
|
||||||
if (isTraceEnabled(marker)) {
|
|
||||||
proxy.trace(marker, format, argArray);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void trace(Marker marker, String msg, Throwable t) {
|
|
||||||
if (isTraceEnabled(marker)) {
|
|
||||||
proxy.trace(marker, msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDebugEnabled() {
|
|
||||||
return proxy.isDebugEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(String msg) {
|
|
||||||
if (isDebugEnabled()) {
|
|
||||||
proxy.debug(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(String format, Object arg) {
|
|
||||||
if (isDebugEnabled()) {
|
|
||||||
proxy.debug(format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(String format, Object arg1, Object arg2) {
|
|
||||||
if (isDebugEnabled()) {
|
|
||||||
proxy.debug(format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(String format, Object... arguments) {
|
|
||||||
if (isDebugEnabled()) {
|
|
||||||
proxy.debug(format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(String msg, Throwable t) {
|
|
||||||
if (isDebugEnabled()) {
|
|
||||||
proxy.debug(msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isDebugEnabled(Marker marker) {
|
|
||||||
return proxy.isDebugEnabled(marker);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(Marker marker, String msg) {
|
|
||||||
if (isDebugEnabled(marker)) {
|
|
||||||
proxy.debug(marker, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(Marker marker, String format, Object arg) {
|
|
||||||
if (isDebugEnabled(marker)) {
|
|
||||||
proxy.debug(marker, format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(Marker marker, String format, Object arg1, Object arg2) {
|
|
||||||
if (isDebugEnabled(marker)) {
|
|
||||||
proxy.debug(marker, format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(Marker marker, String format, Object... arguments) {
|
|
||||||
if (isDebugEnabled(marker)) {
|
|
||||||
proxy.debug(marker, format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void debug(Marker marker, String msg, Throwable t) {
|
|
||||||
if (isDebugEnabled(marker)) {
|
|
||||||
proxy.debug(marker, msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInfoEnabled() {
|
|
||||||
return proxy.isInfoEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String msg) {
|
|
||||||
if (isInfoEnabled()) {
|
|
||||||
proxy.info(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String format, Object arg) {
|
|
||||||
if (isInfoEnabled()) {
|
|
||||||
proxy.info(format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String format, Object arg1, Object arg2) {
|
|
||||||
if (isInfoEnabled()) {
|
|
||||||
proxy.info(format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String format, Object... arguments) {
|
|
||||||
if (isInfoEnabled()) {
|
|
||||||
proxy.info(format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(String msg, Throwable t) {
|
|
||||||
if (isInfoEnabled()) {
|
|
||||||
proxy.info(msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInfoEnabled(Marker marker) {
|
|
||||||
return proxy.isInfoEnabled(marker);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(Marker marker, String msg) {
|
|
||||||
if (isInfoEnabled(marker)) {
|
|
||||||
proxy.info(marker, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(Marker marker, String format, Object arg) {
|
|
||||||
if (isInfoEnabled(marker)) {
|
|
||||||
proxy.info(marker, format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(Marker marker, String format, Object arg1, Object arg2) {
|
|
||||||
if (isInfoEnabled(marker)) {
|
|
||||||
proxy.info(marker, format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(Marker marker, String format, Object... arguments) {
|
|
||||||
if (isInfoEnabled(marker)) {
|
|
||||||
proxy.info(marker, format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void info(Marker marker, String msg, Throwable t) {
|
|
||||||
if (isInfoEnabled(marker)) {
|
|
||||||
proxy.info(marker, msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isWarnEnabled() {
|
|
||||||
return proxy.isWarnEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(String msg) {
|
|
||||||
if (isWarnEnabled()) {
|
|
||||||
proxy.warn(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(String format, Object arg) {
|
|
||||||
if (isWarnEnabled()) {
|
|
||||||
proxy.warn(format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(String format, Object... arguments) {
|
|
||||||
if (isWarnEnabled()) {
|
|
||||||
proxy.warn(format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(String format, Object arg1, Object arg2) {
|
|
||||||
if (isWarnEnabled()) {
|
|
||||||
proxy.warn(format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(String msg, Throwable t) {
|
|
||||||
if (isWarnEnabled()) {
|
|
||||||
proxy.warn(msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isWarnEnabled(Marker marker) {
|
|
||||||
return proxy.isWarnEnabled(marker);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(Marker marker, String msg) {
|
|
||||||
if (isWarnEnabled(marker)) {
|
|
||||||
proxy.warn(marker, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(Marker marker, String format, Object arg) {
|
|
||||||
if (isWarnEnabled(marker)) {
|
|
||||||
proxy.warn(marker, format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(Marker marker, String format, Object arg1, Object arg2) {
|
|
||||||
if (isWarnEnabled(marker)) {
|
|
||||||
proxy.warn(marker, format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(Marker marker, String format, Object... arguments) {
|
|
||||||
if (isWarnEnabled(marker)) {
|
|
||||||
proxy.warn(marker, format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void warn(Marker marker, String msg, Throwable t) {
|
|
||||||
if (isWarnEnabled(marker)) {
|
|
||||||
proxy.warn(marker, msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isErrorEnabled() {
|
|
||||||
return proxy.isErrorEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String msg) {
|
|
||||||
if (isErrorEnabled()) {
|
|
||||||
proxy.error(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String format, Object arg) {
|
|
||||||
if (isErrorEnabled()) {
|
|
||||||
proxy.error(format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String format, Object arg1, Object arg2) {
|
|
||||||
if (isErrorEnabled()) {
|
|
||||||
proxy.error(format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String format, Object... arguments) {
|
|
||||||
if (isErrorEnabled()) {
|
|
||||||
proxy.error(format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(String msg, Throwable t) {
|
|
||||||
if (isErrorEnabled()) {
|
|
||||||
proxy.error(msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isErrorEnabled(Marker marker) {
|
|
||||||
return proxy.isErrorEnabled(marker);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(Marker marker, String msg) {
|
|
||||||
if (isErrorEnabled(marker)) {
|
|
||||||
proxy.error(marker, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(Marker marker, String format, Object arg) {
|
|
||||||
if (isErrorEnabled(marker)) {
|
|
||||||
proxy.error(marker, format, arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(Marker marker, String format, Object arg1, Object arg2) {
|
|
||||||
if (isErrorEnabled(marker)) {
|
|
||||||
proxy.error(marker, format, arg1, arg2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(Marker marker, String format, Object... arguments) {
|
|
||||||
if (isErrorEnabled(marker)) {
|
|
||||||
proxy.error(marker, format, arguments);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void error(Marker marker, String msg, Throwable t) {
|
|
||||||
if (isErrorEnabled(marker)) {
|
|
||||||
proxy.error(marker, msg, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
package cc.ryanc.halo.repository.base;
|
package cc.ryanc.halo.repository.base;
|
||||||
|
|
||||||
import cc.ryanc.halo.logging.Logger;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.data.jpa.repository.support.JpaEntityInformation;
|
import org.springframework.data.jpa.repository.support.JpaEntityInformation;
|
||||||
|
@ -22,10 +22,9 @@ import java.util.List;
|
||||||
* @param <ID> id type
|
* @param <ID> id type
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN, ID> implements BaseRepository<DOMAIN, ID> {
|
public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN, ID> implements BaseRepository<DOMAIN, ID> {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(getClass());
|
|
||||||
|
|
||||||
private final JpaEntityInformation<DOMAIN, ID> entityInformation;
|
private final JpaEntityInformation<DOMAIN, ID> entityInformation;
|
||||||
|
|
||||||
private final EntityManager entityManager;
|
private final EntityManager entityManager;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package cc.ryanc.halo.service.base;
|
package cc.ryanc.halo.service.base;
|
||||||
|
|
||||||
import cc.ryanc.halo.exception.NotFoundException;
|
import cc.ryanc.halo.exception.NotFoundException;
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import cc.ryanc.halo.repository.base.BaseRepository;
|
import cc.ryanc.halo.repository.base.BaseRepository;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
|
@ -23,10 +23,9 @@ import java.util.Optional;
|
||||||
* @param <ID> id type
|
* @param <ID> id type
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public abstract class AbstractCrudService<DOMAIN, ID> implements CrudService<DOMAIN, ID> {
|
public abstract class AbstractCrudService<DOMAIN, ID> implements CrudService<DOMAIN, ID> {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(getClass());
|
|
||||||
|
|
||||||
private final String domainName;
|
private final String domainName;
|
||||||
|
|
||||||
private final BaseRepository<DOMAIN, ID> repository;
|
private final BaseRepository<DOMAIN, ID> repository;
|
||||||
|
@ -35,6 +34,7 @@ public abstract class AbstractCrudService<DOMAIN, ID> implements CrudService<DOM
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
|
|
||||||
// Get domain name
|
// Get domain name
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Class<DOMAIN> domainClass = (Class<DOMAIN>) fetchType(0);
|
Class<DOMAIN> domainClass = (Class<DOMAIN>) fetchType(0);
|
||||||
domainName = domainClass.getSimpleName();
|
domainName = domainClass.getSimpleName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package cc.ryanc.halo.utils;
|
package cc.ryanc.halo.utils;
|
||||||
|
|
||||||
import cc.ryanc.halo.exception.BeanUtilsException;
|
import cc.ryanc.halo.exception.BeanUtilsException;
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import org.springframework.beans.BeanWrapperImpl;
|
import org.springframework.beans.BeanWrapperImpl;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
|
@ -20,8 +19,6 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public class BeanUtils {
|
public class BeanUtils {
|
||||||
|
|
||||||
private final static Logger LOG = Logger.getLogger(BeanUtils.class);
|
|
||||||
|
|
||||||
private BeanUtils() {
|
private BeanUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package cc.ryanc.halo.utils;
|
package cc.ryanc.halo.utils;
|
||||||
|
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
@ -15,8 +14,6 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public class ServiceUtils {
|
public class ServiceUtils {
|
||||||
|
|
||||||
private final static Logger LOGGER = Logger.getLogger(ServiceUtils.class);
|
|
||||||
|
|
||||||
private ServiceUtils() {
|
private ServiceUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package cc.ryanc.halo.web.controller.base;
|
package cc.ryanc.halo.web.controller.base;
|
||||||
|
|
||||||
import cc.ryanc.halo.exception.HaloException;
|
import cc.ryanc.halo.exception.HaloException;
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import cc.ryanc.halo.model.support.BaseResponse;
|
import cc.ryanc.halo.model.support.BaseResponse;
|
||||||
import cc.ryanc.halo.utils.ExceptionUtils;
|
import cc.ryanc.halo.utils.ExceptionUtils;
|
||||||
import cc.ryanc.halo.utils.ValidationUtils;
|
import cc.ryanc.halo.utils.ValidationUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -29,10 +29,9 @@ import java.util.Set;
|
||||||
* @author johnniang
|
* @author johnniang
|
||||||
*/
|
*/
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
|
@Slf4j
|
||||||
public class ControllerExceptionHandler {
|
public class ControllerExceptionHandler {
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(getClass());
|
|
||||||
|
|
||||||
@ExceptionHandler(DataIntegrityViolationException.class)
|
@ExceptionHandler(DataIntegrityViolationException.class)
|
||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
public BaseResponse handleDataIntegrityViolationException(DataIntegrityViolationException e) {
|
public BaseResponse handleDataIntegrityViolationException(DataIntegrityViolationException e) {
|
||||||
|
@ -134,3 +133,4 @@ public class ControllerExceptionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package cc.ryanc.halo.web.controller.content.base;
|
package cc.ryanc.halo.web.controller.content.base;
|
||||||
|
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import cn.hutool.core.text.StrBuilder;
|
import cn.hutool.core.text.StrBuilder;
|
||||||
|
|
||||||
import static cc.ryanc.halo.model.support.HaloConst.DEFAULT_THEME_NAME;
|
import static cc.ryanc.halo.model.support.HaloConst.DEFAULT_THEME_NAME;
|
||||||
|
@ -18,8 +17,6 @@ public abstract class BaseContentController {
|
||||||
*/
|
*/
|
||||||
public static String THEME = DEFAULT_THEME_NAME;
|
public static String THEME = DEFAULT_THEME_NAME;
|
||||||
|
|
||||||
protected Logger log = Logger.getLogger(getClass());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render page by template name
|
* Render page by template name
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package cc.ryanc.halo.web.controller.core;
|
package cc.ryanc.halo.web.controller.core;
|
||||||
|
|
||||||
import cc.ryanc.halo.logging.Logger;
|
|
||||||
import cc.ryanc.halo.model.entity.User;
|
import cc.ryanc.halo.model.entity.User;
|
||||||
import cc.ryanc.halo.model.support.HaloConst;
|
import cc.ryanc.halo.model.support.HaloConst;
|
||||||
import cc.ryanc.halo.service.ThemeService;
|
import cc.ryanc.halo.service.ThemeService;
|
||||||
import cc.ryanc.halo.web.controller.content.base.BaseContentController;
|
import cc.ryanc.halo.web.controller.content.base.BaseContentController;
|
||||||
import cn.hutool.core.text.StrBuilder;
|
import cn.hutool.core.text.StrBuilder;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -22,6 +22,7 @@ import java.io.FileNotFoundException;
|
||||||
* @author : RYAN0UP
|
* @author : RYAN0UP
|
||||||
* @date : 2017/12/26
|
* @date : 2017/12/26
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Controller
|
@Controller
|
||||||
public class CommonController implements ErrorController {
|
public class CommonController implements ErrorController {
|
||||||
|
|
||||||
|
@ -33,8 +34,6 @@ public class CommonController implements ErrorController {
|
||||||
|
|
||||||
private static final String ADMIN_URL = "/admin";
|
private static final String ADMIN_URL = "/admin";
|
||||||
|
|
||||||
private final Logger log = Logger.getLogger(getClass());
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThemeService themeService;
|
private ThemeService themeService;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue