diff --git a/doc/insert20190309.sql b/doc/insert20190309.sql
new file mode 100644
index 0000000000000000000000000000000000000000..5c48a755cd2eff1f7db9c79b129ae1265b015abf
--- /dev/null
+++ b/doc/insert20190309.sql
@@ -0,0 +1,12 @@
+
+insert into t_article(create_time, update_time,title, content) VALUES
+(1552068421000,1552068421000,'个人博客','Python简单。可以把开发者的思想从编程语言的细节里解放出来,更关注实际要解决的问题。'),
+(1552068421000,1552068421000,'个人博客','智联招聘某员工匿名透露:我们内部数据统计,通过大把(千万级)的简历分析得到的结果:。但Python从来不该背锅:!'),
+(1552068421000,1552068421000,'个人博客','人说巴甘长的像女孩:粉红的脸蛋上有一层黄绒毛,笑起来眼睛像弓一样弯着。他家在内蒙古东科尔沁的赫热塔拉村,春冬萧瑟,夏天才像草原。大片绿草'),
+(1552068421000,1552068421000,'个人博客','蹲下,再采红火苗似的萨日朗花。那时他三四岁,还穿着开裆裤,经常露出两瓣屁股。妈说:“老天爷'),
+(1552068421000,1552068421000,'个人博客','巴甘的父亲敏山被火车撞死了。他和妈妈一起生活,庄稼活------比如割玉米,由大舅江其布帮忙。大舅独身,只有一皮3岁的雪青骟马。'),
+(1552068421000,1552068421000,'个人博客','智联招聘某员工匿名透露:我们内部数据统计,通过大把(千万级)的简历分析得到的结果:。但Python从来不该背锅:!'),
+(1552068421000,1552068421000,'个人博客','Python简单。可以把开发者的思想从编程语言的细节里解放出来,更关注实际要解决的问题。'),
+(1552068421000,1552068421000,'个人博客','智联招聘某员工匿名透露:我们内部数据统计,通过大把(千万级)的简历分析得到的结果:。但Python从来不该背锅:!'),
+(1552068421000,1552068421000,'个人博客','Python简单。可以把开发者的思想从编程语言的细节里解放出来,更关注实际要解决的问题。'),
+(1552068421000,1552068421000,'个人博客','智联招聘某员工匿名透露:我们内部数据统计,通过大把(千万级)的简历分析得到的结果:。但Python从来不该背锅:!');
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index fc3813da55645a058a1e097625393fd4817c7959..b786ba19d5aad52a9a5423609bd8e114c8036035 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,6 +77,11 @@
hutool-all
4.1.14
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
diff --git a/src/main/java/com/library/nbt/aspect/WebLogAcpect.java b/src/main/java/com/library/nbt/aspect/WebLogAcpect.java
new file mode 100644
index 0000000000000000000000000000000000000000..c8e270f6083884fea030bf75a4d29fa851702bba
--- /dev/null
+++ b/src/main/java/com/library/nbt/aspect/WebLogAcpect.java
@@ -0,0 +1,58 @@
+package com.library.nbt.aspect;
+
+import com.alibaba.fastjson.JSON;
+import com.library.nbt.utils.DateUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+/**
+ * 使用@Aspect注解将一个java类定义为切面类
+ * 使用@Pointcut定义一个切入点,可以是一个规则表达式,比如下例中某个package下的所有函数,也可以是一个注解等。
+ * 根据需要在切入点不同位置的切入内容
+ * 使用@Before在切入点开始处切入内容
+ * 使用@After在切入点结尾处切入内容
+ * 使用@AfterReturning在切入点return内容之后切入内容(可以用来对处理返回值做一些加工处理)
+ * 使用@Around在切入点前后切入内容,并自己控制何时执行切入点自身的内容
+ * 使用@AfterThrowing用来处理当切入内容部分抛出异常之后的处理逻辑
+ */
+@Aspect
+@Component
+public class WebLogAcpect {
+
+ private static final Logger LOG = LoggerFactory.getLogger(WebLogAcpect.class);
+
+ @Pointcut("execution(public * com.library.nbt.service.impl..*.*(..))")
+ public void WebLog(){};
+
+
+ @Before("WebLog()")
+ public void doBefore(JoinPoint joinPoint)throws Exception{
+ // 接收到请求,记录请求内容
+ ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+ HttpServletRequest request = attributes.getRequest();
+
+ // 记录下请求内容
+ LOG.info("访问URL接口 : " + request.getRequestURL().toString());
+ LOG.info("请求IP : " + request.getRemoteAddr());
+ LOG.info("执行类 : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
+ LOG.info("运行时间:" + DateUtils.timeStamp2Date(String.valueOf(System.currentTimeMillis()),"yyyy-MM-dd HH:mm:ss"));
+ }
+
+ @AfterReturning(returning = "ret", pointcut = "WebLog()")
+ public void doAfterReturning(Object ret) throws Throwable {
+ // 处理完请求,返回内容
+ LOG.info("请求结束,返回数据 : " + JSON.toJSONString(ret));
+ LOG.info("运行结束时间:" + DateUtils.timeStamp2Date(String.valueOf(System.currentTimeMillis()),"yyyy-MM-dd HH:mm:ss"));
+ }
+}
diff --git a/src/main/java/com/library/nbt/controller/ArticleController.java b/src/main/java/com/library/nbt/controller/ArticleController.java
index a2ca1144cacbf494a1511b632c2d25a62580b199..6ee013aa84fde0ced5762b8c5ca1164304353594 100644
--- a/src/main/java/com/library/nbt/controller/ArticleController.java
+++ b/src/main/java/com/library/nbt/controller/ArticleController.java
@@ -30,7 +30,21 @@ public class ArticleController {
private String url;
- @ApiOperation(value = "通过ID获取单个文章表", notes = "通过id获取文章信息")
+ @ApiOperation(value = "通过获取最近文章表", notes = "通过获取最近文章信息")
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "successful request"),
+ @ApiResponse(code = 500, message = "internal server error")})
+ @RequestMapping(value = "/v1/article/lately/{number}", method = RequestMethod.GET)
+ public Result> getEntityNumber(@ApiParam(value = "条数", required = true) @PathVariable(value = "number") Integer number) {
+ try {
+ List articleEntityView = articleService.getEntityNumber(number);
+ return ResultUtil.success(ResultUtil.SUCCESS_CODE_200, articleEntityView);
+ } catch (Exception e) {
+ return ResultUtil.error(ResultUtil.SUCCESS_CODE_200, e.getMessage());
+ }
+ }
+
+ @ApiOperation(value = "通过id获取文章表", notes = "通过id获取文章信息")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful request"),
@ApiResponse(code = 500, message = "internal server error")})
diff --git a/src/main/java/com/library/nbt/controller/CodeController.java b/src/main/java/com/library/nbt/controller/CodeController.java
index 3c4752754b6ce4a2d895d779dcf98aaac2bec610..2fa6e80217382c74135a1f03925075f28457feef 100644
--- a/src/main/java/com/library/nbt/controller/CodeController.java
+++ b/src/main/java/com/library/nbt/controller/CodeController.java
@@ -37,7 +37,7 @@ public class CodeController {
Object[] objs = VerifyUtil.createImage();
//将验证码存入Session
session.setAttribute("imageCode", objs[0]);
- System.out.println("接收前的session:" + session.getId());
+// System.out.println("接收前的session:" + session.getId());
//将图片输出给浏览器
BufferedImage image = (BufferedImage) objs[1];
diff --git a/src/main/java/com/library/nbt/dao/ArticleEntityMapper.java b/src/main/java/com/library/nbt/dao/ArticleEntityMapper.java
index e8916d7150f616a7c28f13c314492473e5f0147a..6a4d010f8b5ca82e0a83f4d1f85f681c4de6a6ed 100644
--- a/src/main/java/com/library/nbt/dao/ArticleEntityMapper.java
+++ b/src/main/java/com/library/nbt/dao/ArticleEntityMapper.java
@@ -3,6 +3,8 @@ package com.library.nbt.dao;
import com.library.nbt.model.entity.ArticleEntity;
import org.apache.ibatis.annotations.Mapper;
+import java.util.List;
+
@Mapper
public interface ArticleEntityMapper {
int deleteByPrimaryKey(Integer id);
@@ -16,4 +18,6 @@ public interface ArticleEntityMapper {
int updateByPrimaryKeySelective(ArticleEntity record);
int updateByPrimaryKey(ArticleEntity record);
+
+ List getEntityNumber(Integer number);
}
\ No newline at end of file
diff --git a/src/main/java/com/library/nbt/dao/UserEntityMapper.java b/src/main/java/com/library/nbt/dao/UserEntityMapper.java
index a900c066e1501d1aed5fdbcd2bb69e2a8eb13073..5aa9b88dbe1e6ea753dee0350223d33e2bb6cf1b 100644
--- a/src/main/java/com/library/nbt/dao/UserEntityMapper.java
+++ b/src/main/java/com/library/nbt/dao/UserEntityMapper.java
@@ -21,5 +21,5 @@ public interface UserEntityMapper {
List findAll();
- UserEntity selectByPrimaryUsername(UserEntity userEntity);
+ UserEntity selectByPrimaryUserEntity(UserEntity userEntity);
}
\ No newline at end of file
diff --git a/src/main/java/com/library/nbt/dao/mapper/ArticleEntityMapper.xml b/src/main/java/com/library/nbt/dao/mapper/ArticleEntityMapper.xml
index ca73dd9523fcb4ece3b7807b01351c6d60d1bb7a..3fba6c9b0f16d3f960a289d9e65ba8c9fc80e156 100644
--- a/src/main/java/com/library/nbt/dao/mapper/ArticleEntityMapper.xml
+++ b/src/main/java/com/library/nbt/dao/mapper/ArticleEntityMapper.xml
@@ -125,4 +125,11 @@
comment_count = #{commentCount,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
+
\ No newline at end of file
diff --git a/src/main/java/com/library/nbt/dao/mapper/UserEntityMapper.xml b/src/main/java/com/library/nbt/dao/mapper/UserEntityMapper.xml
index 23a4936b8395d65d5c3ca8c3e0415cc6f0f4c53a..9912fdd34101dafd9720ef433b59eaabd2308b5c 100644
--- a/src/main/java/com/library/nbt/dao/mapper/UserEntityMapper.xml
+++ b/src/main/java/com/library/nbt/dao/mapper/UserEntityMapper.xml
@@ -18,11 +18,54 @@
- id, create_time, update_time, enabled, username, nick_name, password, phone, birthday,
+ id, create_time, update_time, enabled, username, nick_name, password, phone, birthday,
age, profile_photo, rights, ip, login_end_time
+
+
+
+ AND createTime = #{createTime,jdbcType=BIGINT}
+
+
+ AND update_time = #{updateTime,jdbcType=BIGINT}
+
+
+ AND enabled = #{enabled,jdbcType=INTEGER}
+
+
+ AND username = #{username,jdbcType=VARCHAR}
+
+
+ AND nick_name = #{nick_name,jdbcType=VARCHAR}
+
+
+ AND password = #{password,jdbcType=VARCHAR}
+
+
+ AND phone = #{phone,jdbcType=INTEGER}
+
+
+ AND birthday = #{birthday,jdbcType=BIGINT}
+
+
+ AND age = #{age,jdbcType=INTEGER}
+
+
+ AND profile_photo = #{profilePhoto,jdbcType=VARCHAR}
+
+
+ AND rights = #{rights,jdbcType=INTEGER}
+
+
+ AND ip = #{ip,jdbcType=VARCHAR}
+
+
+ AND login_end_time = #{loginEndTime,jdbcType=BIGINT}
+
+
+
-