Commit 6977b318 by zhangxiaoyan

log list api

parent 1e361435
package common.controller;
import common.model.UserLog;
import common.service.UserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import util.ResultModel;
import java.util.List;
/**
* Created by zxy on 2017/12/27.
*/
@Controller
@RequestMapping(value = "userlog")
public class UserLogController
{
@Autowired UserLogService userLogService;
///api/userlog/list?startDate=2017-12-26&endDate=2017-12-27
@RequestMapping(value = "list", method = RequestMethod.GET)
@ResponseBody
public ResultModel findByDS(@RequestParam String startDate, @RequestParam String endDate) {
return ResultModel.OK(userLogService.findUserLog(startDate, endDate));
}
}
......@@ -13,7 +13,7 @@ import java.util.Date;
public class UserLog
{
private Long id;
private Date operateTime;
private String operateTime;
private String operaAccount;
private String accountName;
private String ip;
......@@ -34,12 +34,12 @@ public class UserLog
this.id = id;
}
public Date getOperateTime()
public String getOperateTime()
{
return operateTime;
}
public void setOperateTime(Date operateTime)
public void setOperateTime(String operateTime)
{
this.operateTime = operateTime;
}
......
......@@ -2,10 +2,15 @@ package common.repository;
import common.model.UserLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
/**
* Created by zxy on 2017/12/27.
*/
public interface UserLogRepository extends JpaRepository<UserLog, Long>
{
@Query(value = "select * from user_log where substr(operate_time, 1, 10)>=?1 and substr(operate_time, 1, 10)<=?2", nativeQuery = true)
List<UserLog> findByOperateTime(String startDate, String endDate);
}
package common.service;
import common.model.UserLog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.List;
/**
* Created by zxy on 2017/12/27.
*/
public interface UserLogService
{
List<UserLog> findUserLog(String startDate, String endDate);
}
package common.service.impl;
import common.model.UserLog;
import common.repository.UserLogRepository;
import common.service.UserLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import util.StringUtil;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zxy on 2017/12/27.
*/
@Service
public class UserLogServiceImpl implements UserLogService
{
@Autowired UserLogRepository userLogRepository;
@Override
public List<UserLog> findUserLog(String startDate, String endDate)
{
return userLogRepository.findByOperateTime(startDate, endDate);
}
}
......@@ -3,15 +3,12 @@ package util;
import common.context.AppUtils;
import common.model.UserLog;
import common.repository.UserLogRepository;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
/**
* Created by zxy on 2017/12/15.
......@@ -61,7 +58,7 @@ public class UserLogThread
audit.setAccountName(this.accountName);
audit.setOperateObjectType(this.operateObjectType);
audit.setOperateObject(this.operateObject);
audit.setOperateTime(new Date());
audit.setOperateTime(DateUtil.format(new Date(), DateUtil.C_TIME_PATTON_DEFAULT));
audit.setOperateType(this.operateType);
if (this.request != null) {
......
......@@ -69,6 +69,7 @@ common\repository\UserRepository.class
util\ResultModel.class
dic\RoleEnum.class
util\CipherUtil.class
common\controller\UserLogController.class
tkio\model\App.class
security\resolvers\LoginUserMethodArgumentsResolver.class
tkio\service\TkioAccountService.class
......@@ -82,12 +83,14 @@ common\controller\AppController.class
common\service\MenuService.class
common\repository\AppCategoryRepository.class
tkio\repository\AppRepository.class
common\service\impl\UserLogServiceImpl.class
dmp\repository\TagCrawlerAppsWandoujiaRepository.class
security\RedisLoginStatusManagerImpl.class
tkio\model\AccountRestrict4Web.class
dic\OperateObjectTypeEnum.class
common\service\UserService.class
common\service\AppService.class
common\service\UserLogService.class
tkio\service\impl\AccountFlowRestrictServiceImpl.class
common\repository\CityRepository.class
common\model\Code.class
......
......@@ -5,6 +5,7 @@ E:\IDEA_workspace\manager\src\main\java\common\repository\CodeRepository.java
E:\IDEA_workspace\manager\src\main\java\util\Constant.java
E:\IDEA_workspace\manager\src\main\java\common\controller\UserController.java
E:\IDEA_workspace\manager\src\main\java\util\ResultStatus.java
E:\IDEA_workspace\manager\src\main\java\common\service\impl\UserLogServiceImpl.java
E:\IDEA_workspace\manager\src\main\java\security\RedisLoginStatusManagerImpl.java
E:\IDEA_workspace\manager\src\main\java\tkio\service\AccountFlowRestrictService.java
E:\IDEA_workspace\manager\src\main\java\common\service\impl\UserServiceImpl.java
......@@ -29,6 +30,7 @@ E:\IDEA_workspace\manager\src\main\java\util\HttpClientUtil.java
E:\IDEA_workspace\manager\src\main\java\util\UserLogThread.java
E:\IDEA_workspace\manager\src\main\java\tkio\model\Auth.java
E:\IDEA_workspace\manager\src\main\java\dmp\model\TagCrawlerAppsWandoujia.java
E:\IDEA_workspace\manager\src\main\java\common\controller\UserLogController.java
E:\IDEA_workspace\manager\src\main\java\common\model\Code.java
E:\IDEA_workspace\manager\src\main\java\exception\GlobalExceptionAdvice.java
E:\IDEA_workspace\manager\src\main\java\security\annotation\CurrentAccount.java
......@@ -60,6 +62,7 @@ E:\IDEA_workspace\manager\src\main\java\util\StringUtil.java
E:\IDEA_workspace\manager\src\main\java\security\cors\CorsFilter.java
E:\IDEA_workspace\manager\src\main\java\util\DateUtil.java
E:\IDEA_workspace\manager\src\main\java\common\controller\AppController.java
E:\IDEA_workspace\manager\src\main\java\common\service\UserLogService.java
E:\IDEA_workspace\manager\src\main\java\common\model\Auth.java
E:\IDEA_workspace\manager\src\main\java\common\repository\UserLogRepository.java
E:\IDEA_workspace\manager\src\main\java\security\resolvers\LoginUserMethodArgumentsResolver.java
......
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