Commit e01a48ff by fsn

整理

parent e4673207
package com.stylefeng.guns.common.annotion;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 统计系统调用次数的注解
*
* @author fengshuonan
* @date 2017年3月4日 下午11:53:28
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface CountStat {
String[] value() default {};
}
package com.stylefeng.guns.common.page; package com.stylefeng.guns.common.page;
/** /**
*
* 分页参数类(for BootStrap Table) * 分页参数类(for BootStrap Table)
* *
* @author fengshuonan * @author fengshuonan
...@@ -9,58 +8,58 @@ package com.stylefeng.guns.common.page; ...@@ -9,58 +8,58 @@ package com.stylefeng.guns.common.page;
*/ */
public class PageBT { public class PageBT {
private int limit; // 每页显示个数 private int limit; // 每页显示个数
private int offset; // 查询的偏移量(查询的页数 = offset/limit + 1) private int offset; // 查询的偏移量(查询的页数 = offset/limit + 1)
private String order; // 排序方式 private String order; // 排序方式
public PageBT() {
super();
}
public PageBT(int limit, int offset) {
super();
this.limit = limit;
this.offset = offset;
}
public int getLimit() { public PageBT() {
return limit; super();
} }
public void setLimit(int limit) { public PageBT(int limit, int offset) {
this.limit = limit; super();
} this.limit = limit;
this.offset = offset;
}
public int getOffset() { public int getLimit() {
return offset; return limit;
} }
public void setOffset(int offset) { public void setLimit(int limit) {
this.offset = offset; this.limit = limit;
} }
public String getOrder() { public int getOffset() {
return order; return offset;
} }
public void setOrder(String order) { public void setOffset(int offset) {
this.order = order; this.offset = offset;
} }
public int getPageSize() { public String getOrder() {
return this.limit; return order;
} }
public int getPageNumber() { public void setOrder(String order) {
return this.offset / this.limit + 1; this.order = order;
} }
@Override public int getPageSize() {
public String toString() { return this.limit;
return "PageBT [limit=" + limit + ", offset=" + offset + ", order=" + order + "]"; }
}
public int getPageNumber() {
return this.offset / this.limit + 1;
}
@Override
public String toString() {
return "PageBT [limit=" + limit + ", offset=" + offset + ", order=" + order + "]";
}
} }
...@@ -5,38 +5,37 @@ import com.baomidou.mybatisplus.plugins.Page; ...@@ -5,38 +5,37 @@ import com.baomidou.mybatisplus.plugins.Page;
import java.util.List; import java.util.List;
/** /**
*
* 分页结果的封装(for Bootstrap Table) * 分页结果的封装(for Bootstrap Table)
* *
* @author fengshuonan * @author fengshuonan
* @Date 2017年1月22日 下午11:06:41 * @Date 2017年1月22日 下午11:06:41
*/ */
public class PageInfoBT<T> { public class PageInfoBT<T> {
// 结果集 // 结果集
private List<T> rows; private List<T> rows;
// 总数 // 总数
private long total; private long total;
public PageInfoBT(Page<T> page) { public PageInfoBT(Page<T> page) {
this.rows = page.getRecords(); this.rows = page.getRecords();
this.total = page.getTotal(); this.total = page.getTotal();
} }
public List<T> getRows() { public List<T> getRows() {
return rows; return rows;
} }
public void setRows(List<T> rows) { public void setRows(List<T> rows) {
this.rows = rows; this.rows = rows;
} }
public long getTotal() { public long getTotal() {
return total; return total;
} }
public void setTotal(long total) { public void setTotal(long total) {
this.total = total; this.total = total;
} }
} }
package com.stylefeng.guns.core.aop;
import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.core.support.HttpKit;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* 本系统调用次数的统计
*/
@Aspect
@Component
public class CountAop extends BaseController {
private static Object sync = new Object();
@Pointcut(value = "@annotation(com.stylefeng.guns.common.annotion.CountStat)")
private void cutPermission() {
}
@Around("cutPermission()")
public Object around(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request = HttpKit.getRequest();
Object systemCount = request.getServletContext().getAttribute("systemCount");
synchronized (sync) {
if(systemCount == null){
request.getServletContext().setAttribute("systemCount", 1);
}else{
request.getServletContext().setAttribute("systemCount", (Integer)systemCount + 1);
}
}
return point.proceed();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment