模块化拆分
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package cn.celess.article;
|
||||
|
||||
import cn.celess.common.CommonApplication;
|
||||
import cn.celess.user.UserApplication;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {ArticleApplication.class, CommonApplication.class, UserApplication.class})
|
||||
public class ArticleApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ArticleApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -38,22 +39,22 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class ArticleServiceImpl implements ArticleService {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
TagMapper tagMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
CategoryMapper categoryMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
CommentMapper commentMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
ArticleTagMapper articleTagMapper;
|
||||
@Autowired
|
||||
@Resource
|
||||
UserService userService;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Autowired
|
||||
@Resource
|
||||
RedisUserUtil redisUserUtil;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.article;
|
||||
|
||||
import cn.celess.common.test.RedisServerMock;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(classes = {ArticleApplication.class})
|
||||
@RunWith(SpringRunner.class)
|
||||
public abstract class ArticleBaseTest extends RedisServerMock {
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.article.controller;
|
||||
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.article.ArticleBaseTest;
|
||||
import cn.celess.common.entity.Article;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.Tag;
|
||||
@@ -11,18 +11,18 @@ import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.celess.common.enmu.ResponseEnum.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class ArticleControllerTest extends BaseTest {
|
||||
@Autowired
|
||||
public class ArticleControllerTest extends ArticleBaseTest {
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
private static final TypeReference<?> ARTICLE_MODEL_TYPE = new TypeReference<Response<ArticleModel>>() {
|
||||
};
|
||||
@@ -204,18 +204,18 @@ public class ArticleControllerTest extends BaseTest {
|
||||
@Test
|
||||
public void adminArticles() {
|
||||
try {
|
||||
getMockData(get("/admin/articles?page=1&count=10")).andExpect(result ->
|
||||
assertEquals(HAVE_NOT_LOG_IN.getCode(), getResponse(result, STRING_TYPE).getCode())
|
||||
getMockData(get("/admin/articles?page=1&count=5")).andExpect(result ->
|
||||
assertEquals(HAVE_NOT_LOG_IN.getCode(), getResponse(result, ARTICLE_MODEL_PAGE_TYPE).getCode())
|
||||
);
|
||||
|
||||
// User权限登陆
|
||||
getMockData(get("/admin/articles?page=1&count=10"), userLogin()).andDo(result ->
|
||||
assertEquals(PERMISSION_ERROR.getCode(), getResponse(result, STRING_TYPE).getCode())
|
||||
getMockData(get("/admin/articles?page=1&count=5"), userLogin()).andDo(result ->
|
||||
assertEquals(PERMISSION_ERROR.getCode(), getResponse(result, ARTICLE_MODEL_PAGE_TYPE).getCode())
|
||||
);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// admin权限登陆
|
||||
int finalI = i;
|
||||
getMockData(get("/admin/articles?page=1&count=10&deleted=" + (i == 1)), adminLogin()).andDo(result -> {
|
||||
getMockData(get("/admin/articles?page=1&count=5&deleted=" + (i == 1)), adminLogin()).andDo(result -> {
|
||||
Response<PageData<ArticleModel>> response = getResponse(result, ARTICLE_MODEL_PAGE_TYPE);
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
assertNotNull(response.getResult());
|
||||
@@ -223,7 +223,7 @@ public class ArticleControllerTest extends BaseTest {
|
||||
PageData<ArticleModel> pageData = response.getResult();
|
||||
assertNotEquals(0, pageData.getTotal());
|
||||
assertEquals(1, pageData.getPageNum());
|
||||
assertEquals(10, pageData.getPageSize());
|
||||
assertEquals(5, pageData.getPageSize());
|
||||
// 内容完整
|
||||
for (ArticleModel a : pageData.getList()) {
|
||||
assertNotNull(a.getTitle());
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.service;
|
||||
package cn.celess.article.serviceimpl;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.article.ArticleBaseTest;
|
||||
import cn.celess.common.entity.vo.ArticleModel;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
@@ -9,13 +9,15 @@ import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ArticleServiceTest extends BaseTest {
|
||||
public class ArticleServiceTest extends ArticleBaseTest {
|
||||
|
||||
@Autowired
|
||||
ArticleService articleService;
|
||||
@Autowired
|
||||
@Resource
|
||||
ArticleMapper articleMapper;
|
||||
|
||||
@Test
|
||||
@@ -18,6 +18,12 @@
|
||||
<version>${blog-common.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.celess</groupId>
|
||||
<artifactId>blog-user</artifactId>
|
||||
<version>${blog-user.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.celess.categorytag;
|
||||
|
||||
|
||||
import cn.celess.common.CommonApplication;
|
||||
import cn.celess.user.UserApplication;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {CategoryTagApplication.class, CommonApplication.class, UserApplication.class})
|
||||
public class CategoryTagApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CategoryTagApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.categorytag;
|
||||
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(classes = {CategoryTagApplication.class})
|
||||
@RunWith(SpringRunner.class)
|
||||
public abstract class CategoryTagBaseTest extends BaseTest {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.categorytag.controller;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.categorytag.CategoryTagBaseTest;
|
||||
import cn.celess.common.entity.Category;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.vo.CategoryModel;
|
||||
@@ -14,7 +14,7 @@ import static cn.celess.common.enmu.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class CategoryControllerTest extends BaseTest {
|
||||
public class CategoryControllerTest extends CategoryTagBaseTest {
|
||||
|
||||
@Autowired
|
||||
CategoryMapper categoryMapper;
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.categorytag.controller;
|
||||
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.categorytag.CategoryTagBaseTest;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
@@ -18,7 +18,7 @@ import static cn.celess.common.enmu.ResponseEnum.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class TagControllerTest extends BaseTest {
|
||||
public class TagControllerTest extends CategoryTagBaseTest {
|
||||
@Autowired
|
||||
TagMapper tagMapper;
|
||||
private static final TypeReference<?> TAG_MODEL_TYPE = new TypeReference<Response<TagModel>>() {
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.celess.comment;
|
||||
|
||||
import cn.celess.common.CommonApplication;
|
||||
import cn.celess.user.UserApplication;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {CommentApplication.class, CommonApplication.class, UserApplication.class})
|
||||
public class CommentApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CommentApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.comment;
|
||||
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(classes = {CommentApplication.class})
|
||||
@RunWith(SpringRunner.class)
|
||||
public abstract class CommentBaseTest extends BaseTest {
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.comment.controller;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.comment.CommentBaseTest;
|
||||
import cn.celess.common.entity.Article;
|
||||
import cn.celess.common.entity.Comment;
|
||||
import cn.celess.common.entity.Response;
|
||||
@@ -21,7 +21,7 @@ import static cn.celess.common.enmu.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
public class CommentControllerTest extends BaseTest {
|
||||
public class CommentControllerTest extends CommentBaseTest {
|
||||
@Autowired
|
||||
ArticleMapper articleMapper;
|
||||
@Autowired
|
||||
@@ -12,6 +12,12 @@
|
||||
<artifactId>blog-common</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.celess</groupId>
|
||||
<artifactId>blog-resource</artifactId>
|
||||
<version>${blog-resource.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
@@ -28,22 +34,22 @@
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.8</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/resources/lib/tools.jar</systemPath>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun</groupId>
|
||||
<artifactId>jconsole</artifactId>
|
||||
<version>1.8</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/src/main/resources/lib/jconsole.jar</systemPath>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.sun</groupId>-->
|
||||
<!-- <artifactId>tools</artifactId>-->
|
||||
<!-- <version>1.8</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/src/main/resources/lib/tools.jar</systemPath>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.sun</groupId>-->
|
||||
<!-- <artifactId>jconsole</artifactId>-->
|
||||
<!-- <version>1.8</version>-->
|
||||
<!-- <scope>system</scope>-->
|
||||
<!-- <systemPath>${project.basedir}/src/main/resources/lib/jconsole.jar</systemPath>-->
|
||||
<!-- <optional>true</optional>-->
|
||||
<!-- </dependency>-->
|
||||
<!--druid-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.common;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CommonApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CommonApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,22 @@
|
||||
package cn.celess.common.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("cn.celess.common.mapper")
|
||||
@Slf4j
|
||||
public class MybatisConfig {
|
||||
|
||||
// @Bean
|
||||
// public SqlSessionFactory sqlSessionFactory() throws Exception {
|
||||
// log.info("配置Mybatis的配置项");
|
||||
// PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||
// SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
|
||||
// // 此处省略部分代码
|
||||
// bean.setMapperLocations(resolver.getResources("classpath:mapper/*.xml"));
|
||||
// bean.setTypeAliasesPackage("cn.celess.common.entity");
|
||||
// return bean.getObject();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
@@ -28,11 +27,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@ControllerAdvice
|
||||
public class ExceptionHandle {
|
||||
public static final Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
|
||||
@Resource
|
||||
@Autowired
|
||||
MailService mailService;
|
||||
@Autowired
|
||||
HttpServletRequest request;
|
||||
@Value("${spring.profiles.active}")
|
||||
@Value("${spring.profiles.active:dev}")
|
||||
private String activeModel;
|
||||
|
||||
@ExceptionHandler(value = Exception.class)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess;
|
||||
package cn.celess.common.test;
|
||||
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.dto.LoginReq;
|
||||
@@ -6,6 +6,7 @@ import cn.celess.common.entity.vo.QiniuResponse;
|
||||
import cn.celess.common.entity.vo.UserModel;
|
||||
import cn.celess.common.service.MailService;
|
||||
import cn.celess.common.service.QiniuService;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -13,17 +14,14 @@ import com.qiniu.storage.model.FileInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
@@ -42,19 +40,17 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static cn.celess.common.enmu.ResponseEnum.SUCCESS;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/08/22 12:46
|
||||
* @Description: 测试基类
|
||||
*/
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("test")
|
||||
public class BaseTest {
|
||||
|
||||
public abstract class BaseTest {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@@ -67,7 +63,6 @@ public class BaseTest {
|
||||
/**
|
||||
* jackson 序列化/反序列化Json
|
||||
*/
|
||||
protected final ObjectMapper mapper = new ObjectMapper();
|
||||
protected static final TypeReference<?> BOOLEAN_TYPE = new TypeReference<Response<Boolean>>() {
|
||||
};
|
||||
protected static final TypeReference<?> STRING_TYPE = new TypeReference<Response<String>>() {
|
||||
@@ -134,7 +129,7 @@ public class BaseTest {
|
||||
try {
|
||||
str = getMockData(MockMvcRequestBuilders.post("/login"), null, req)
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
Response<UserModel> response = mapper.readValue(str, new TypeReference<Response<UserModel>>() {
|
||||
Response<UserModel> response = new ObjectMapper().readValue(str, new TypeReference<Response<UserModel>>() {
|
||||
});
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
String token = response.getResult().getToken();
|
||||
@@ -148,20 +143,6 @@ public class BaseTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// 测试登录
|
||||
assertNotNull(userLogin());
|
||||
assertNotNull(adminLogin());
|
||||
assertNotEquals(userLogin(), adminLogin());
|
||||
try {
|
||||
// 测试getMockData方法
|
||||
assertNotNull(getMockData(MockMvcRequestBuilders.get("/headerInfo")));
|
||||
getMockData((MockMvcRequestBuilders.get("/headerInfo"))).andDo(result -> assertNotNull(getResponse(result, OBJECT_TYPE)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 产生指定长度的随机字符
|
||||
@@ -220,6 +201,7 @@ public class BaseTest {
|
||||
builder.header("Authorization", "Bearer "+token);
|
||||
}
|
||||
if (content != null) {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
builder.content(mapper.writeValueAsString(content)).contentType(MediaType.APPLICATION_JSON);
|
||||
logger.debug("param::json->{}", mapper.writeValueAsString(content));
|
||||
}
|
||||
@@ -245,6 +227,8 @@ public class BaseTest {
|
||||
protected <T> Response<T> getResponse(String json, TypeReference<?> responseType) {
|
||||
Response<T> response = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
|
||||
response = mapper.readValue(json, responseType);
|
||||
} catch (IOException e) {
|
||||
logger.error("解析json Response对象错误,json:[{}]", json);
|
||||
@@ -292,6 +276,7 @@ public class BaseTest {
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service("mailService")
|
||||
public static class TestMailServiceImpl implements MailService {
|
||||
|
||||
@Override
|
||||
@@ -323,6 +308,7 @@ public class BaseTest {
|
||||
}
|
||||
|
||||
@Slf4j
|
||||
@Service("qiniuService")
|
||||
public static class TestQiNiuServiceImpl implements QiniuService {
|
||||
@Override
|
||||
public QiniuResponse uploadFile(InputStream is, String fileName) {
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.celess.common.test;
|
||||
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2020/08/14 16:20
|
||||
*/
|
||||
public class RedisServerMock extends BaseTest {
|
||||
private static RedisServer redisServer;
|
||||
|
||||
@PostConstruct
|
||||
public static void startRedis() {
|
||||
try {
|
||||
if (redisServer == null) {
|
||||
redisServer = new RedisServer(6380);
|
||||
redisServer.start();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public static void stopRedis() {
|
||||
if (redisServer.isActive()) redisServer.stop();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,9 @@ import java.io.IOException;
|
||||
* @Desc:
|
||||
*/
|
||||
public class HttpUtil {
|
||||
/**
|
||||
* FIXME
|
||||
*/
|
||||
public static String get(String urlStr) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
|
||||
webClient.getOptions().setCssEnabled(false);
|
||||
@@ -34,7 +37,9 @@ public class HttpUtil {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FIXME
|
||||
*/
|
||||
public static String getAfterRendering(String url) {
|
||||
try (final WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED)) {
|
||||
webClient.getOptions().setCssEnabled(false);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.common;
|
||||
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(classes = CommonApplication.class)
|
||||
@RunWith(SpringRunner.class)
|
||||
public abstract class CommonBaseTest extends BaseTest {
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.celess.enmu;
|
||||
package cn.celess.common.enmu;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
@@ -10,7 +9,7 @@ import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class UserAccountStatusEnumTest extends BaseTest {
|
||||
public class UserAccountStatusEnumTest extends CommonBaseTest {
|
||||
|
||||
@Test
|
||||
public void get() {
|
||||
@@ -1,10 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.*;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.mapper.ArticleTagMapper;
|
||||
import cn.celess.common.mapper.TagMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -12,7 +9,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ArticleMapperTest extends BaseTest {
|
||||
public class ArticleMapperTest extends CommonBaseTest {
|
||||
@Autowired
|
||||
ArticleMapper articleMapper;
|
||||
@Autowired
|
||||
@@ -1,10 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.*;
|
||||
import cn.celess.common.mapper.ArticleMapper;
|
||||
import cn.celess.common.mapper.ArticleTagMapper;
|
||||
import cn.celess.common.mapper.TagMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -12,7 +9,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ArticleTagMapperTest extends BaseTest {
|
||||
public class ArticleTagMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
ArticleMapper articleMapper;
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.Category;
|
||||
import cn.celess.common.mapper.CategoryMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -11,7 +10,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class CategoryMapperTest extends BaseTest {
|
||||
public class CategoryMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
CategoryMapper categoryMapper;
|
||||
@@ -1,11 +1,9 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.enmu.CommentStatusEnum;
|
||||
import cn.celess.common.entity.Comment;
|
||||
import cn.celess.common.entity.User;
|
||||
import cn.celess.common.mapper.CommentMapper;
|
||||
import cn.celess.common.mapper.UserMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -13,7 +11,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class CommentMapperTest extends BaseTest {
|
||||
public class CommentMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import cn.celess.common.mapper.PartnerMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -10,7 +9,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class PartnerMapperTest extends BaseTest {
|
||||
public class PartnerMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
PartnerMapper partnerMapper;
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.Tag;
|
||||
import cn.celess.common.mapper.TagMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -11,7 +10,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TagMapperTest extends BaseTest {
|
||||
public class TagMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
TagMapper tagMapper;
|
||||
@@ -1,10 +1,9 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.enmu.RoleEnum;
|
||||
import cn.celess.common.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.common.entity.User;
|
||||
import cn.celess.common.mapper.UserMapper;
|
||||
import cn.celess.common.util.MD5Util;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,7 +12,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UserMapperTest extends BaseTest {
|
||||
public class UserMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.Visitor;
|
||||
import cn.celess.common.mapper.VisitorMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -11,7 +10,7 @@ import java.util.Date;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
public class VisitorMapperTest extends BaseTest {
|
||||
public class VisitorMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
VisitorMapper visitorMapper;
|
||||
@@ -1,8 +1,7 @@
|
||||
package cn.celess.mapper;
|
||||
package cn.celess.common.mapper;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import cn.celess.common.entity.WebUpdate;
|
||||
import cn.celess.common.mapper.WebUpdateInfoMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -10,7 +9,7 @@ import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class WebUpdateInfoMapperTest extends BaseTest {
|
||||
public class WebUpdateInfoMapperTest extends CommonBaseTest {
|
||||
|
||||
@Autowired
|
||||
WebUpdateInfoMapper webUpdateInfoMapper;
|
||||
@@ -1,14 +1,13 @@
|
||||
package cn.celess.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.util.DateFormatUtil;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class DateFormatUtilTest extends BaseTest {
|
||||
public class DateFormatUtilTest extends CommonBaseTest {
|
||||
|
||||
@Test
|
||||
public void get() {
|
||||
@@ -1,14 +1,15 @@
|
||||
package cn.celess.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.util.HttpUtil;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class HttpUtilTest extends BaseTest {
|
||||
public class HttpUtilTest extends CommonBaseTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void get() {
|
||||
String s = HttpUtil.get("https://api.celess.cn/headerInfo");
|
||||
assertNotNull(s);
|
||||
@@ -1,12 +1,11 @@
|
||||
package cn.celess.util;
|
||||
package cn.celess.common.util;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.util.MD5Util;
|
||||
import cn.celess.common.CommonBaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MD5UtilTest extends BaseTest {
|
||||
public class MD5UtilTest extends CommonBaseTest {
|
||||
|
||||
@Test
|
||||
public void getMD5() {
|
||||
@@ -15,29 +15,6 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.200</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.kstyrc</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<version>0.6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.celess.configuration;
|
||||
|
||||
import cn.celess.configuration.filter.AuthenticationFilter;
|
||||
import cn.celess.configuration.filter.MultipleSubmitFilter;
|
||||
import cn.celess.configuration.filter.VisitorRecord;
|
||||
import cn.celess.configuration.listener.SessionListener;
|
||||
@@ -16,17 +15,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
public class DeployInterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new MultipleSubmitFilter()).addPathPatterns("/**");
|
||||
registry.addInterceptor(new VisitorRecord()).addPathPatterns("/**");
|
||||
registry.addInterceptor(authenticationFilter()).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationFilter authenticationFilter() {
|
||||
return new AuthenticationFilter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -1,68 +0,0 @@
|
||||
server.port=8081
|
||||
# 七牛的密钥配置
|
||||
qiniu.accessKey=si3O2_Q7edFtjzmyyzXkoE9G1toxcjDfULhX5zdh
|
||||
qiniu.secretKey=Pnq8q2Iy1Ez8RQXQR33XmgAYlit7M8C197BZ4lCj
|
||||
qiniu.bucket=xiaohai
|
||||
# sitemap 存放地址
|
||||
sitemap.path=
|
||||
# 生成JWT时候的密钥
|
||||
jwt.secret=sdjfi77;47h7uuo4l;4lgiu4;dl5684aasdasdpsidf;sdf
|
||||
#mybatis.type-handlers-package=cn.celess.common.mapper.typehandler
|
||||
spring.jpa.show-sql=false
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
# 上传单个文件的大小
|
||||
spring.servlet.multipart.max-file-size=10MB
|
||||
# 上传文件的总大小
|
||||
spring.servlet.multipart.max-request-size=10MB
|
||||
spring.jackson.default-property-inclusion=non_null
|
||||
################# 数据库 ##################
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
# spring.datasource.url=jdbc:mysql://localhost:3306/blog?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/blog?characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=zhenghai
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.initialization-mode=never
|
||||
################## mybatis ##################
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=cn.celess.common.entity
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=true
|
||||
pagehelper.support-methods-arguments=true
|
||||
pagehelper.params=count=countSql
|
||||
#### 用于nginx的代理 获取真实ip
|
||||
server.use-forward-headers=true
|
||||
server.tomcat.remote-ip-header=X-Real-IP
|
||||
server.tomcat.protocol-header=X-Forwarded-Proto
|
||||
############### email ##############
|
||||
spring.mail.host=smtp.163.com
|
||||
spring.mail.username=xiaohai2271@163.com
|
||||
spring.mail.password=56462271Zh
|
||||
spring.mail.properties.mail.smtp.auth=true
|
||||
spring.mail.properties.mail.smtp.starttls.enable=true
|
||||
spring.mail.properties.mail.smtp.starttls.required=true
|
||||
spring.mail.default-encoding=UTF-8
|
||||
spring.mail.port=465
|
||||
spring.mail.properties.mail.smtp.socketFactory.port=465
|
||||
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
|
||||
spring.mail.properties.mail.smtp.socketFactory.fallback=false
|
||||
############### redis ##############
|
||||
# REDIS (RedisProperties)
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.redis.database=0
|
||||
# Redis服务器地址
|
||||
spring.redis.host=127.0.0.1
|
||||
# Redis服务器连接端口
|
||||
spring.redis.port=6379
|
||||
# Redis服务器连接密码(默认为空)
|
||||
spring.redis.password=zhenghai
|
||||
# 连接池最大连接数(使用负值表示没有限制)
|
||||
spring.redis.jedis.pool.max-active=-1
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
spring.redis.jedis.pool.max-wait=-1
|
||||
# 连接池中的最大空闲连接
|
||||
spring.redis.jedis.pool.max-idle=8
|
||||
# 连接池中的最小空闲连接
|
||||
spring.redis.jedis.pool.min-idle=0
|
||||
# 连接超时时间(毫秒)
|
||||
spring.redis.timeout=5000
|
||||
11
blog-deploy/src/test/java/cn/celess/DeployBaseTest.java
Normal file
11
blog-deploy/src/test/java/cn/celess/DeployBaseTest.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package cn.celess;
|
||||
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@SpringBootTest(classes = {BlogApplication.class})
|
||||
@RunWith(SpringRunner.class)
|
||||
public abstract class DeployBaseTest extends BaseTest {
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package cn.celess;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author : xiaohai
|
||||
* @date : 2020/08/14 16:20
|
||||
*/
|
||||
@Component
|
||||
public class RedisServerMock {
|
||||
|
||||
private RedisServer redisServer;
|
||||
|
||||
/**
|
||||
* 构造方法之后执行.
|
||||
*
|
||||
* @throws IOException e
|
||||
*/
|
||||
@PostConstruct
|
||||
public void startRedis() throws IOException {
|
||||
redisServer = new RedisServer(6380);
|
||||
redisServer.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* 析构方法之后执行.
|
||||
*/
|
||||
@PreDestroy
|
||||
public void stopRedis() {
|
||||
redisServer.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package cn.celess.filter;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.DeployBaseTest;
|
||||
import cn.celess.common.enmu.ResponseEnum;
|
||||
import cn.celess.common.entity.Response;
|
||||
import org.junit.Assert;
|
||||
@@ -13,7 +13,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
* @Date: 2019/11/28 16:17
|
||||
* @Description: 测试重复请求
|
||||
*/
|
||||
public class MultipleSubmitFilter extends BaseTest {
|
||||
public class MultipleSubmitFilter extends DeployBaseTest {
|
||||
|
||||
private MockHttpSession session = null;
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.extension;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ExtensionApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ExtensionApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.partnersite;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class PartnerSiteApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PartnerSiteApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.partnersite.controller;
|
||||
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.dto.LinkApplyReq;
|
||||
@@ -10,6 +9,7 @@ import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.exception.MyException;
|
||||
import cn.celess.common.mapper.PartnerMapper;
|
||||
import cn.celess.common.service.PartnerSiteService;
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
@@ -22,7 +22,7 @@ import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
@Slf4j
|
||||
public class LinksControllerTest extends BaseTest {
|
||||
public class PartnerSiteControllerTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
PartnerMapper mapper;
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.celess.service;
|
||||
package cn.celess.partnersite.serviceimpl;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.PartnerSite;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.service.PartnerSiteService;
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
19
blog-resource/pom.xml
Normal file
19
blog-resource/pom.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>blog</artifactId>
|
||||
<groupId>cn.celess</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>blog-resource</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>13</maven.compiler.source>
|
||||
<maven.compiler.target>13</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
0
blog-resource/src/main/java/.gitkeep
Normal file
0
blog-resource/src/main/java/.gitkeep
Normal file
@@ -33,20 +33,6 @@ spring.datasource.sql-script-encoding=utf-8
|
||||
spring.datasource.schema=classpath:sql/schema.sql
|
||||
spring.datasource.data=classpath:sql/data.sql
|
||||
|
||||
|
||||
################## mybatis ##################
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=cn.celess.common.entity
|
||||
|
||||
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=true
|
||||
pagehelper.support-methods-arguments=true
|
||||
pagehelper.params=count=countSql
|
||||
|
||||
|
||||
|
||||
|
||||
################ email ##############
|
||||
#请先填写下面的配置,不然可能运行不起来
|
||||
spring.mail.host=
|
||||
@@ -32,19 +32,6 @@ spring.datasource.initialization-mode=ALWAYS
|
||||
spring.datasource.schema=classpath:sql/schema_h2.sql
|
||||
spring.datasource.data=classpath:sql/data.sql
|
||||
|
||||
|
||||
################## mybatis ##################
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
mybatis.type-aliases-package=cn.celess.common.entity
|
||||
|
||||
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=true
|
||||
pagehelper.support-methods-arguments=true
|
||||
pagehelper.params=count=countSql
|
||||
|
||||
|
||||
|
||||
#### 用于nginx的代理 获取真实ip
|
||||
server.use-forward-headers = true
|
||||
server.tomcat.remote-ip-header = X-Real-IP
|
||||
@@ -4,5 +4,10 @@ spring.profiles.active=prod
|
||||
logging.level.cn.celess.blog=debug
|
||||
logging.level.cn.celess.common.mapper=info
|
||||
spring.cache.type=redis
|
||||
|
||||
mybatis.mapper-locations=classpath*:mapper/*.xml
|
||||
mybatis.type-aliases-package=cn.celess.common.entity
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=true
|
||||
pagehelper.support-methods-arguments=true
|
||||
pagehelper.params=count=countSql
|
||||
## 修改openSource 添加-test 文件用于测试 -prod文件用于线上发布
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.siteinfo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SiteInfoApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SiteInfoApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.siteinfo.controller;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.WebUpdate;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.WebUpdateModel;
|
||||
import cn.celess.common.mapper.WebUpdateInfoMapper;
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -21,7 +22,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
|
||||
@Slf4j
|
||||
public class WebUpdateInfoControllerTest extends BaseTest {
|
||||
|
||||
private final TypeReference<?> MODAL_TYPE = new TypeReference<Response<WebUpdateModel>>() {
|
||||
};
|
||||
private final TypeReference<?> MODAL_LIST_TYPE = new TypeReference<Response<List<WebUpdateModel>>>() {
|
||||
@@ -126,6 +126,7 @@ public class WebUpdateInfoControllerTest extends BaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void lastestUpdateTime() throws Exception {
|
||||
getMockData(get("/lastestUpdate")).andDo(result -> assertEquals(SUCCESS.getCode(), getResponse(result).getCode()));
|
||||
}
|
||||
@@ -29,5 +29,26 @@
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.3.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
12
blog-user/src/main/java/cn/celess/user/UserApplication.java
Normal file
12
blog-user/src/main/java/cn/celess/user/UserApplication.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package cn.celess.user;
|
||||
|
||||
import cn.celess.common.CommonApplication;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication(scanBasePackageClasses = {UserApplication.class, CommonApplication.class})
|
||||
public class UserApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.celess.user.config;
|
||||
|
||||
import cn.celess.user.filter.AuthenticationFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @Author: 小海
|
||||
* @Date: 2019/10/18 14:19
|
||||
* @Description:
|
||||
*/
|
||||
@Configuration
|
||||
public class AuthorizationInterceptorConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(authenticationFilter()).addPathPatterns("/**");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationFilter authenticationFilter() {
|
||||
return new AuthenticationFilter();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.celess.configuration.filter;
|
||||
package cn.celess.user.filter;
|
||||
|
||||
|
||||
import cn.celess.common.enmu.ResponseEnum;
|
||||
11
blog-user/src/test/java/cn/celess/user/UserBaseTest.java
Normal file
11
blog-user/src/test/java/cn/celess/user/UserBaseTest.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package cn.celess.user;
|
||||
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public abstract class UserBaseTest extends BaseTest {
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.user.controller;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.User;
|
||||
import cn.celess.common.entity.dto.LoginReq;
|
||||
@@ -11,6 +10,7 @@ import cn.celess.common.mapper.UserMapper;
|
||||
import cn.celess.common.service.UserService;
|
||||
import cn.celess.common.util.MD5Util;
|
||||
import cn.celess.common.util.RedisUtil;
|
||||
import cn.celess.user.UserBaseTest;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
|
||||
|
||||
public class UserControllerTest extends BaseTest {
|
||||
public class UserControllerTest extends UserBaseTest {
|
||||
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.celess.filter;
|
||||
package cn.celess.user.filter;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.user.UserBaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import static cn.celess.common.enmu.ResponseEnum.*;
|
||||
@@ -13,7 +13,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
||||
* @Date: 2019/11/28 16:05
|
||||
* @Description: 授权拦截器的测试类
|
||||
*/
|
||||
public class AuthorizationFilter extends BaseTest {
|
||||
public class AuthorizationFilter extends UserBaseTest {
|
||||
|
||||
@Test
|
||||
public void UserAccess() throws Exception {
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.celess.service;
|
||||
package cn.celess.user.serviceimpl;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.enmu.ResponseEnum;
|
||||
import cn.celess.common.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.common.entity.User;
|
||||
@@ -11,12 +10,13 @@ import cn.celess.common.exception.MyException;
|
||||
import cn.celess.common.mapper.UserMapper;
|
||||
import cn.celess.common.service.UserService;
|
||||
import cn.celess.common.util.MD5Util;
|
||||
import cn.celess.user.UserBaseTest;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class UserServiceTest extends BaseTest {
|
||||
public class UserServiceTest extends UserBaseTest {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
@Autowired
|
||||
@@ -1,25 +1,24 @@
|
||||
package cn.celess.util;
|
||||
package cn.celess.user.util;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.User;
|
||||
import cn.celess.user.util.JwtUtil;
|
||||
import cn.celess.user.UserBaseTest;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class JwtUtilTest extends BaseTest {
|
||||
public class JwtUtilTest extends UserBaseTest {
|
||||
|
||||
@Autowired
|
||||
@Resource
|
||||
JwtUtil jwtUtil;
|
||||
@Value("${jwt.secret}")
|
||||
private String secret;
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.celess.visitor;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class VisitorApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(VisitorApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.celess.controller;
|
||||
package cn.celess.visitor.controller;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.Response;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.VisitorModel;
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package cn.celess.service;
|
||||
package cn.celess.visitor.serviceimpl;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.common.entity.vo.PageData;
|
||||
import cn.celess.common.entity.vo.VisitorModel;
|
||||
import cn.celess.common.service.VisitorService;
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -1,7 +1,6 @@
|
||||
package cn.celess.util;
|
||||
package cn.celess.visitor.util;
|
||||
|
||||
import cn.celess.BaseTest;
|
||||
import cn.celess.visitor.util.AddressUtil;
|
||||
import cn.celess.common.test.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
25
pom.xml
25
pom.xml
@@ -14,6 +14,7 @@
|
||||
<module>blog-siteinfo</module>
|
||||
<module>blog-extension</module>
|
||||
<module>blog-deploy</module>
|
||||
<module>blog-resource</module>
|
||||
</modules>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -40,6 +41,7 @@
|
||||
<blog-visitor.version>0.0.1-SNAPSHOT</blog-visitor.version>
|
||||
<blog-siteinfo.version>0.0.1-SNAPSHOT</blog-siteinfo.version>
|
||||
<blog-extension.version>0.0.1-SNAPSHOT</blog-extension.version>
|
||||
<blog-resource.version>0.0.1-SNAPSHOT</blog-resource.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -49,7 +51,30 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.20</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.4.200</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.kstyrc</groupId>
|
||||
<artifactId>embedded-redis</artifactId>
|
||||
<version>0.6</version>
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>com.google.guava</groupId>-->
|
||||
<!-- <artifactId>guava</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
||||
Reference in New Issue
Block a user