update mongo log

master
wangning 7 years ago
parent 65baad8331
commit ce5e9c574f

@ -0,0 +1,84 @@
package au.com.royalpay.payment.manage.logview.beans;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import java.text.ParseException;
/**
* Created by yixian on 2016-10-18.
*/
public class ConfigOperationQueryBean {
private static final String[] pattern = {"yyyyMMdd"};
private String begin;
private String end;
private int page = 1;
private int limit = 20;
private String client_moniker;
public JSONObject toJSON() {
JSONObject res = new JSONObject();
if (begin != null) {
try {
res.put("begin", DateUtils.parseDate(begin, pattern));
} catch (ParseException e) {
throw new ParamInvalidException("begin", "error.payment.valid.invalid_time");
}
}
if (end != null) {
try {
res.put("end", DateUtils.parseDate(end, pattern));
} catch (ParseException e) {
throw new ParamInvalidException("end", "error.payment.valid.invalid_time");
}
}
if(StringUtils.isNotEmpty(this.client_moniker)){
res.put("client_moniker",this.client_moniker);
}
return res;
}
public String getBegin() {
return begin;
}
public void setBegin(String begin) {
this.begin = begin;
}
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
public String getClient_moniker() {
return client_moniker;
}
public void setClient_moniker(String client_moniker) {
this.client_moniker = client_moniker;
}
}

@ -9,6 +9,7 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.Paginator; import com.github.miemiedev.mybatis.paginator.domain.Paginator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
@ -38,9 +39,11 @@ public class OperationLogServiceImpl implements OperationLogService {
} }
} }
Query query = new Query(); Query query = new Query();
query.with(new Sort(new Sort.Order(Sort.Direction.DESC,"createTime")));
if (params.getIntValue("client_id") != 0) { if (params.getIntValue("client_id") != 0) {
query.addCriteria(Criteria.where("clientId").is(params.getIntValue("client_id"))); query.addCriteria(Criteria.where("clientId").is(params.getIntValue("client_id")));
} }
query.addCriteria(Criteria.where("createTime").gt(params.getDate("begin")).lt(params.getDate("end")));
List<ClientConfigLog> clientConfigLogList = mongoTemplate.find(query, ClientConfigLog.class); List<ClientConfigLog> clientConfigLogList = mongoTemplate.find(query, ClientConfigLog.class);
return buildPageListResult(clientConfigLogList, return buildPageListResult(clientConfigLogList,
new Paginator(pageBounds.getPage(), pageBounds.getLimit(), (int) mongoTemplate.count(query, ClientConfigLog.class))); new Paginator(pageBounds.getPage(), pageBounds.getLimit(), (int) mongoTemplate.count(query, ClientConfigLog.class)));

@ -1,5 +1,6 @@
package au.com.royalpay.payment.manage.logview.web; package au.com.royalpay.payment.manage.logview.web;
import au.com.royalpay.payment.manage.logview.beans.ConfigOperationQueryBean;
import au.com.royalpay.payment.manage.logview.core.OperationLogService; import au.com.royalpay.payment.manage.logview.core.OperationLogService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -7,7 +8,6 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -22,9 +22,7 @@ public class ConfigOperationController {
private OperationLogService operationLogService; private OperationLogService operationLogService;
@RequestMapping(method = RequestMethod.GET) @RequestMapping(method = RequestMethod.GET)
public JSONObject list(@RequestParam(required = false) String client_moniker,@RequestParam(defaultValue = "1") int page,@RequestParam(defaultValue = "10") int limit){ public JSONObject list(ConfigOperationQueryBean configOperationQueryBean){
JSONObject params = new JSONObject(); return operationLogService.query(configOperationQueryBean.toJSON(),new PageBounds(configOperationQueryBean.getPage(),configOperationQueryBean.getLimit()));
params.put("client_moniker",client_moniker);
return operationLogService.query(params,new PageBounds(page,limit));
} }
} }

@ -117,11 +117,17 @@ define(['angular', 'uiRouter'], function (angular) {
app.controller('configOperationLogCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) { app.controller('configOperationLogCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.pagination = {}; $scope.pagination = {};
$scope.params = {}; $scope.params = {begin:new Date().setDate(new Date().getDate()-1),end:new Date()};
$scope.listConfiglogs = function (page) { $scope.listConfiglogs = function (page) {
var params = angular.copy($scope.params) || {}; var params = angular.copy($scope.params) || {};
params.page = page || $scope.pagination.page || 1; params.page = page || $scope.pagination.page || 1;
params.date = $filter('date')(params.date, 'yyyyMMdd'); if (params.begin != null) {
params.begin = $filter('date')(params.begin, 'yyyyMMdd');
}
if (params.end != null) {
params.end = $filter('date')(params.end, 'yyyyMMdd');
}
params.page = page || $scope.pagination.page || 1;
$http.get('/sys_logs/config/operation', {params: params}).then(function (resp) { $http.get('/sys_logs/config/operation', {params: params}).then(function (resp) {
$scope.logs = resp.data.data; $scope.logs = resp.data.data;
$scope.pagination = resp.data.pagination; $scope.pagination = resp.data.pagination;

@ -1,3 +1,17 @@
<section class="content-header">
<h1>Config Operation Logs</h1>
<ol class="breadcrumb">
<li>
<i class="fa fa-file-text-o"></i> Basic Config
</li>
<li>
<a ui-sref="^">Log Views</a>
</li>
<li class="active">Config Operation Logs</li>
</ol>
</section>
<section class="content">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<div class="form-inline"> <div class="form-inline">
@ -5,7 +19,21 @@
<label class="control-label" for="moniker-input">Client Moniker</label> <label class="control-label" for="moniker-input">Client Moniker</label>
<input class="form-control" size="5" id="moniker-input" ng-model="params.client_moniker" ng-enter="listConfiglogs(1)"> <input class="form-control" size="5" id="moniker-input" ng-model="params.client_moniker" ng-enter="listConfiglogs(1)">
</div> </div>
<button class="btn btn-success" type="button" ng-click="listClientLoginLogs(1)"> <div class="form-group">
<label class="control-label" for="date-from-input">From</label>
<input class="form-control" id="date-from-input" ng-model="params.begin"
uib-datepicker-popup size="10" placeholder="From"
is-open="dateBegin.open" ng-click="dateBegin.open=true"
datepicker-options="{maxDate:params.end||today}">
</div>
<div class="form-group">
<label class="control-label" for="date-to-input">To</label>
<input class="form-control" id="date-to-input" ng-model="params.end"
uib-datepicker-popup size="10" placeholder="To"
is-open="dateEnd.open" ng-click="dateEnd.open=true"
datepicker-options="{minDate:params.begin,maxDate:today}">
</div>
<button class="btn btn-success" type="button" ng-click="listConfiglogs(1)">
<i class="fa fa-search"></i> Search <i class="fa fa-search"></i> Search
</button> </button>
</div> </div>
@ -53,3 +81,4 @@
</div> </div>
</div> </div>
</div> </div>
</section>
Loading…
Cancel
Save