update mongo log

master
wangning 6 years ago
parent ce5e9c574f
commit fad755de8d

@ -8,6 +8,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
/** /**
* Created by yixian on 2016-10-18. * Created by yixian on 2016-10-18.
@ -21,17 +23,20 @@ public class ConfigOperationQueryBean {
private String client_moniker; private String client_moniker;
public JSONObject toJSON() { public JSONObject toJSON() {
SimpleDateFormat utcFormater = new SimpleDateFormat("yyyyMMdd");
utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));//时区定义并进行时间获取
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
if (begin != null) { if (begin != null) {
try { try {
res.put("begin", DateUtils.parseDate(begin, pattern));
res.put("begin", utcFormater.parse(begin));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("begin", "error.payment.valid.invalid_time"); throw new ParamInvalidException("begin", "error.payment.valid.invalid_time");
} }
} }
if (end != null) { if (end != null) {
try { try {
res.put("end", DateUtils.parseDate(end, pattern)); res.put("end", DateUtils.addDays(utcFormater.parse(end),1));
} catch (ParseException e) { } catch (ParseException e) {
throw new ParamInvalidException("end", "error.payment.valid.invalid_time"); throw new ParamInvalidException("end", "error.payment.valid.invalid_time");
} }

@ -43,7 +43,7 @@ public class OperationLogServiceImpl implements OperationLogService {
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"))); 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)));

Loading…
Cancel
Save