forked from cloudfavorites/favorites-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
277 changed files
with
77,841 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FROM maven:3.5-jdk-8 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.favorites</groupId> | ||
<artifactId>favorites-web</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>war</packaging> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.5.9.RELEASE</version> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-thymeleaf</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-mail</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>webjars-locator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>3.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars.bower</groupId> | ||
<artifactId>bootstrap</artifactId> | ||
<version>3.3.6</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars</groupId> | ||
<artifactId>vue</artifactId> | ||
<version>1.0.24</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.webjars.bower</groupId> | ||
<artifactId>vue-resource</artifactId> | ||
<version>0.7.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jsoup</groupId> | ||
<artifactId>jsoup</artifactId> | ||
<version>1.9.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.favorites; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.builder.SpringApplicationBuilder; | ||
import org.springframework.boot.web.support.SpringBootServletInitializer; | ||
|
||
@SpringBootApplication | ||
public class FavoritesApplication extends SpringBootServletInitializer{ | ||
|
||
@Override | ||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
return application.sources(FavoritesApplication.class); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(FavoritesApplication.class, args); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.favorites; | ||
|
||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import com.favorites.comm.filter.SecurityFilter; | ||
|
||
@Configuration | ||
public class WebConfiguration { | ||
|
||
@Bean | ||
public FilterRegistrationBean filterRegistration() { | ||
|
||
FilterRegistrationBean registration = new FilterRegistrationBean(); | ||
registration.setFilter(new SecurityFilter()); | ||
registration.addUrlPatterns("/*"); | ||
registration.addInitParameter("paramName", "paramValue"); | ||
registration.setName("MyFilter"); | ||
registration.setOrder(1); | ||
return registration; | ||
} | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.favorites.cache; | ||
|
||
import com.favorites.domain.UrlLibrary; | ||
import com.favorites.repository.UrlLibraryRepository; | ||
import com.favorites.utils.HtmlUtil; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by DingYS on 2016/12/29. | ||
*/ | ||
@Component | ||
public class CacheService { | ||
|
||
private Map<String,String> maps = new HashMap<String, String>(); | ||
@Autowired | ||
private UrlLibraryRepository urlLibraryRepository; | ||
|
||
public String getMap(String key){ | ||
if(maps.isEmpty()){ | ||
List<UrlLibrary> collectLibrarieList = urlLibraryRepository.findAll(); | ||
for(UrlLibrary urlLibrary : collectLibrarieList){ | ||
maps.put(urlLibrary.getUrl(), urlLibrary.getLogoUrl()); | ||
} | ||
} | ||
if(null == maps.get(key)){ | ||
this.addMaps(key); | ||
} | ||
return maps.get(key); | ||
} | ||
|
||
|
||
public void addMaps(String key){ | ||
String logoUrl = HtmlUtil.getImge(key); | ||
maps.put(key,logoUrl); | ||
UrlLibrary urlLibrary = new UrlLibrary(); | ||
urlLibrary.setUrl(key); | ||
urlLibrary.setLogoUrl(logoUrl); | ||
urlLibraryRepository.save(urlLibrary); | ||
} | ||
|
||
public boolean refreshOne(String key,String newValue){ | ||
if(StringUtils.isNotBlank(key)){ | ||
String value = getMap(key); | ||
if(StringUtils.isNotBlank(newValue) && !newValue.equals(value)){ | ||
maps.put(key,newValue); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.favorites.comm; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class Const { | ||
|
||
public static String BASE_PATH; | ||
|
||
public static String LOGIN_SESSION_KEY = "Favorites_user"; | ||
|
||
public static String PASSWORD_KEY = "@#$%^&*()OPG#$%^&*(HG"; | ||
|
||
public static String DES3_KEY = "9964DYByKL967c3308imytCB"; | ||
|
||
public static String default_logo="img/logo.jpg"; | ||
|
||
public static String userAgent="Mozilla"; | ||
|
||
public static String default_Profile=BASE_PATH+"/img/logo.jpg"; | ||
|
||
public static String LAST_REFERER = "LAST_REFERER"; | ||
|
||
public static int COOKIE_TIMEOUT= 30*24*60*60; | ||
|
||
|
||
@Autowired(required = true) | ||
public void setBasePath(@Value("${favorites.base.path}")String basePath) { | ||
Const.BASE_PATH = basePath; | ||
} | ||
|
||
|
||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/favorites/comm/aop/LoggerAdvice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.favorites.comm.aop; | ||
|
||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.log4j.Logger; | ||
import org.aspectj.lang.JoinPoint; | ||
import org.aspectj.lang.annotation.AfterReturning; | ||
import org.aspectj.lang.annotation.AfterThrowing; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* @Description: 日志管理 | ||
* @author Leo Wu | ||
* @date 2016年7月6日 下午5:36:38 | ||
* @version 1.0 | ||
*/ | ||
@Aspect | ||
@Service | ||
public class LoggerAdvice { | ||
|
||
private Logger logger = Logger.getLogger(this.getClass()); | ||
|
||
@Before("within(com.favorites..*) && @annotation(loggerManage)") | ||
public void addBeforeLogger(JoinPoint joinPoint, LoggerManage loggerManage) { | ||
logger.info("执行 " + loggerManage.description() + " 开始"); | ||
logger.info(joinPoint.getSignature().toString()); | ||
logger.info(parseParames(joinPoint.getArgs())); | ||
} | ||
|
||
@AfterReturning("within(com.favorites..*) && @annotation(loggerManage)") | ||
public void addAfterReturningLogger(JoinPoint joinPoint, LoggerManage loggerManage) { | ||
logger.info("执行 " + loggerManage.description() + " 结束"); | ||
} | ||
|
||
@AfterThrowing(pointcut = "within(com.favorites..*) && @annotation(loggerManage)", throwing = "ex") | ||
public void addAfterThrowingLogger(JoinPoint joinPoint, LoggerManage loggerManage, Exception ex) { | ||
logger.error("执行 " + loggerManage.description() + " 异常", ex); | ||
} | ||
|
||
private String parseParames(Object[] parames) { | ||
if (null == parames || parames.length <= 0) { | ||
return ""; | ||
} | ||
StringBuffer param = new StringBuffer("传入参数[{}] "); | ||
for (Object obj : parames) { | ||
param.append(ToStringBuilder.reflectionToString(obj)).append(" "); | ||
} | ||
return param.toString(); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/favorites/comm/aop/LoggerManage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.favorites.comm.aop; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* @Description: 日志注解 | ||
* @author Leo Wu | ||
* @date 2016年7月7日 上午11:34:57 | ||
* @version 1.0 | ||
*/ | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface LoggerManage { | ||
|
||
public String description(); | ||
} |
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/favorites/comm/config/MultipartConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.favorites.comm.config; | ||
|
||
import javax.servlet.MultipartConfigElement; | ||
|
||
import org.springframework.boot.web.servlet.MultipartConfigFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
*@ClassName: MultipartConfig | ||
*@Description: | ||
*@author YY | ||
*@date 2016年8月26日 下午2:39:37 | ||
*@version 1.0 | ||
*/ | ||
|
||
@Configuration | ||
public class MultipartConfig { | ||
|
||
@Bean | ||
public MultipartConfigElement multipartConfigElement() { | ||
MultipartConfigFactory factory = new MultipartConfigFactory(); | ||
factory.setMaxFileSize("50MB"); | ||
factory.setMaxRequestSize("50MB"); | ||
return factory.createMultipartConfig(); | ||
} | ||
|
||
} |
Oops, something went wrong.