com.xnx3.DateUtil Java Examples
The following examples show how to use
com.xnx3.DateUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageReply.java From xnx3 with Apache License 2.0 | 6 votes |
/** * 向微信服务器进行图文回复(MsgType=news)的XML格式字符串,可以将此直接回复微信服务器即可达到回复效果。 * <br/>此项即向微信服务器自动回复xml * @param response {@link HttpServletResponse}响应,输出返回值给微信服务器。 * @param content 微信自动回复用户的内容 */ public void replyNews(HttpServletResponse response, List<NewsItem> itemList){ String items = ""; for (int i = 0; i < itemList.size(); i++) { items = items + itemList.get(i).getXMLString(); } String text = "<xml>" + "<ToUserName><![CDATA["+this.toUserName+"]]></ToUserName>" + "<FromUserName><![CDATA["+this.fromUserName+"]]></FromUserName>" + "<CreateTime>"+DateUtil.timeForUnix10()+"</CreateTime>" + "<MsgType><![CDATA[news]]></MsgType>" + "<ArticleCount><![CDATA["+itemList.size()+"]]></ArticleCount>" + "<Articles>"+items+"</Articles>" + "</xml>"; System.out.println("--------"); System.out.println(text); System.out.println("--------"); reply(response, text); }
Example #2
Source File: ImController.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 历史聊天人列表,会话列表,每一项都是一个人 */ @RequestMapping("hostoryChatList${url.suffix}") public String hostoryChatList(HttpServletRequest request,Model model){ if(Global.aliyunLogUtil == null){ return error(model, "您未开启IM客服访问相关的日志服务!"); } User user = getUser(); int currentTime = DateUtil.timeForUnix10(); int startTime = currentTime - 86400*30; //30天内有效 try { AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil); JSONArray jsonArray = log.listForJSONArray("receiveId = "+user.getId()+" | select max(sendId) , map_agg('array',sendUserName) as sendUserName,max(sendId) as sendIds, count(*) as count, max(__time__) as time group by sendId order by time desc limit 100", "", false, startTime, currentTime, 100, request); model.addAttribute("list", jsonArray); } catch (LogException e) { e.printStackTrace(); } return "im/hostoryChatList"; }
Example #3
Source File: TemplateController.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 导出当前网站当前的模版文件,包含模版页面,模版变量、栏目 * @throws FileNotFoundException * @throws UnsupportedEncodingException */ @RequestMapping("exportTemplate${url.suffix}") public void exportTemplate(HttpServletRequest request, HttpServletResponse response) throws FileNotFoundException, UnsupportedEncodingException { BaseVO vo = templateService.exportTemplate(request); String fileName = "template"+DateUtil.currentDate("yyyyMMdd_HHmm")+".wscso".toString(); // 文件的默认保存名 //读到流中 InputStream inStream = new ByteArrayInputStream(vo.getInfo().getBytes("UTF-8")); AliyunLog.addActionLog(getSiteId(), "导出当前网站当前的模版文件"); // 设置输出的格式 response.reset(); response.setContentType("bin"); response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); // 循环取出流中的数据 byte[] b = new byte[1000]; int len; try { while ((len = inStream.read(b)) > 0) response.getOutputStream().write(b, 0, len); inStream.close(); } catch (IOException e) { e.printStackTrace(); } }
Example #4
Source File: TemplateCMS.java From wangmarket with Apache License 2.0 | 6 votes |
private void templateCMS(Site site, com.xnx3.wangmarket.admin.entity.Template template){ linuxTime = DateUtil.timeForUnix10(); this.site = site; this.template = template; if(Global.get("MASTER_SITE_URL") != null && Global.get("MASTER_SITE_URL").equals("http://wang.market/")){ if(site.getId() - 255 > 0){ //site.id < 255 的站点,是code模式 generateUrlRule = "code"; } if(site.getId() - 218 == 0){ //site.id 218 是qiye1,作为调试使用 generateUrlRule = "code"; } }else{ //后台主域名不是wang.market,那可能就是别人在使用这个程序,直接使用code模式生成html文件 generateUrlRule = "code"; } }
Example #5
Source File: ImController.java From wangmarket with Apache License 2.0 | 6 votes |
@RequestMapping("previewByToken${url.suffix}") public String previewByToken(HttpServletRequest request,Model model, @RequestParam(value = "token", required = false , defaultValue="") String token){ //进行安全过滤 token = token.replaceAll("\\s*", ""); token = filter(token); if(token.length() != 64){ return error(model, "授权码错误"); }else{ int currentTime = DateUtil.timeForUnix10(); int startTime = currentTime - 86400*30; //30天内有效 try { AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil); JSONArray jsonArray = log.listForJSONArray("receiveSocketUuid="+token, "", false, startTime, currentTime, 100, request); model.addAttribute("list", jsonArray); } catch (LogException e) { e.printStackTrace(); } } return "im/perviewByToken"; }
Example #6
Source File: ImController.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 聊天记录,跟某个人之间,一个会话的聊天记录,两个人之间的聊天记录 * @param id 跟自己会话的那个人的id,对方的id */ @RequestMapping("chatRecord${url.suffix}") public String chatRecord(HttpServletRequest request,Model model, @RequestParam(value = "id", required = false , defaultValue="0") long id){ if(id == 0){ return error(model, "请输入要查看得对方得id编号"); } User user = getUser(); int currentTime = DateUtil.timeForUnix10(); int startTime = currentTime - 86400*30; //30天内有效 try { AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil); JSONArray jsonArray = log.listForJSONArray("(receiveId = "+user.getId()+" and sendId = "+id+" ) or (receiveId = "+id+" and sendId = "+user.getId()+" )", "", false, startTime, currentTime, 100, request); JSONArray ja = new JSONArray(); //将其倒序 for (int i = jsonArray.size()-1; i >-1 ; --i) { ja.add(jsonArray.get(i)); } model.addAttribute("list", ja); } catch (LogException e) { e.printStackTrace(); } model.addAttribute("user", user); return "im/chatRecord"; }
Example #7
Source File: JavaMQUtils.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 发送信息到 domain 项目的插件中 * @param pluginId 插件的id,如 kefu、formManage、learnExample、newsSearch 等 * @param text 发送到插件的内容,一般是 json.toString() */ public static void sendMessage(String pluginId, String content){ if(cacheMap.get(pluginId) == null){ cacheMap.put(pluginId, new ArrayList<JavaQueueBean>()); } JavaQueueBean queue = new JavaQueueBean(); queue.setAddtime(DateUtil.timeForUnix10()); queue.setContent(content); cacheMap.get(pluginId).add(queue); if(receiveInterfaceMap.get(pluginId) != null){ receiveInterfaceMap.get(pluginId).receive(content); } }
Example #8
Source File: Log.java From wangmarket with Apache License 2.0 | 6 votes |
public static void requestLog(HttpServletRequest request, RequestInfo requestInfo, SImpleSiteVO simpleSiteVO){ //未开启日志记录 if(aliyunLogUtil == null){ return; } if(simpleSiteVO.getResult() - SImpleSiteVO.FAILURE == 0){ //失败的,没有访问正规站点的,可能是ip直接访问的,或者访问的未绑定上的域名过来的。这样的不与记录。 return; } LogItem logItem = new LogItem(DateUtil.timeForUnix10()); logItem.PushBack("ip", requestInfo.getIp()); logItem.PushBack("referer", requestInfo.getReferer()); logItem.PushBack("userAgent", requestInfo.getUserAgent()); logItem.PushBack("htmlFile", requestInfo.getHtmlFile()); logItem.PushBack("siteid", simpleSiteVO.getSimpleSite().getId()+""); logItem.PushBack("serverName", requestInfo.getServerName()); try { aliyunLogUtil.cacheLog(logItem); } catch (LogException e1) { e1.printStackTrace(); } }
Example #9
Source File: SystemAdminController_.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 新增、修改全局变量后的保存。根据 name 来进行增、改 */ @RequiresPermissions("adminSystemVariable") @RequestMapping(value="variableSave${url.suffix}", method = RequestMethod.POST) @ResponseBody public BaseVO variableSave(System sys, Model model, HttpServletRequest request){ System system = sqlService.findAloneByProperty(System.class, "name", sys.getName()); if(system == null){ //新增 system = new System(); system.setName(sys.getName()); }else{ //编辑 } system.setDescription(sys.getDescription()); system.setLasttime(DateUtil.timeForUnix10()); system.setValue(sys.getValue()); sqlService.save(system); /***更新内存数据****/ systemService.refreshSystemCache(); ActionLogCache.insert(request, system.getId(), "保存系统变量", system.getName()+"="+system.getValue()); return success(); }
Example #10
Source File: AllInterceptor.java From wangmarket with Apache License 2.0 | 6 votes |
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { if(useExecuteTime){ long startTime = (Long)request.getAttribute("startTime"); long endTime = System.currentTimeMillis(); long executeTime = endTime - startTime; if(executeTime > recordTime){ System.out.println(DateUtil.currentDate("MM-dd HH:mm:ss")+" ControllerExecuteTime : "+executeTime+" ms , "+handler); } } //v4.10 增加,资源文件css、js的引用路径,是本地引用,还是cdn引用 String static_resource_path = StaticResource.getPath(); if(modelAndView != null){ modelAndView.addObject("STATIC_RESOURCE_PATH", static_resource_path); } }
Example #11
Source File: AliyunLogUtil.java From xnx3 with Apache License 2.0 | 6 votes |
/** * 手动将 {@link #cacheLog(LogItem)} 缓存中的数据提交到阿里云日志服务中去。若提交成功,便清空缓存。 * <br/>此方法会在 {@link #cacheLog(LogItem)} 向缓存中添加日志时,当达到 {@link #setCacheLogMaxNumber(int)} 设置的缓存最大条数后会自动触发。 * <br/>当然,比如Tomcat停止时,或者其他意外情况,也可以手动调用此处方法触发提交到阿里云日志服务中的命令 * @return {@link PutLogsResponse} 提交返回的结果 * @throws LogException */ public PutLogsResponse cacheCommit() throws LogException{ PutLogsResponse r = saveByGroup("", "", logGroupCache); if(r != null && r.GetRequestId() != null && r.GetRequestId().length() > 0){ //数据提交成功 //清空日志缓存及条数 logGroupCache.clear(); //同步最后提交时间 int currentTime = DateUtil.timeForUnix10(); //当前时间 if(lastSubmitTime < currentTime){ lastSubmitTime = currentTime; } } return r; }
Example #12
Source File: AliyunLogUtil.java From xnx3 with Apache License 2.0 | 5 votes |
/** * 缓存日志。缓存的并不会立即联网提交到阿里云日志服务,而是达到一定条数 {@link #setCacheLogMaxNumber(int)} 达到这里设置的条数后才会触发 {@link #cacheCommit()} 提交到阿里云日志服务 * <br/>这里缓存的日志,没提供设置topic、source,可以将其记录到日志本身中去 * @param logItem 要缓存的日志,可用 {@link AliyunLogUtil#newLogItem()} 获取创建 {@link LogItem} 对象,然后将要记录的日志类似JSON, {@link LogItem#PushBack(String, String)} 加入 * @throws LogException */ public void cacheLog(LogItem logItem) throws LogException{ if(logItem == null){ return; } /*使用的类的信息,来源位置*/ if(stack_trace_deep > 0){ StackTraceElement st = Thread.currentThread().getStackTrace()[stack_trace_deep]; logItem.PushBack("className", st.getClassName()); logItem.PushBack("methodName", st.getMethodName()); logItem.PushBack("fileName", st.getFileName()); } logGroupCache.add(logItem); boolean submit = false; //提交日志 if(logGroupCache.size() > cacheLogMaxNumber){ //超过定义的缓存最大值,那么将缓存中的日志数据提交到阿里日志服务中去 submit = true; }else{ int currentTime = DateUtil.timeForUnix10(); //当前时间 if(lastSubmitTime + cacheLogMaxTime < currentTime){ submit = true; lastSubmitTime = currentTime; } } if(submit){ cacheCommit(); } }
Example #13
Source File: PublicController.java From wangmarket with Apache License 2.0 | 5 votes |
/** * sitemap.xml展示 * @param request {@link HttpServletRequest} * @param model {@link Model} */ @RequestMapping("sitemap.xml") public String sitemap(HttpServletRequest request, Model model){ SImpleSiteVO simpleSiteVO = getCurrentSimpleSite(request); RequestInfo requestInfo = new RequestInfo(); requestInfo.setHtmlFile("sitemap.xml"); requestInfo.setIp(IpUtil.getIpAddress(request)); requestInfo.setReferer(request.getHeader("referer")); requestInfo.setServerName(request.getServerName()); requestInfo.setTime(DateUtil.timeForUnix10()); requestInfo.setUserAgent(request.getHeader("User-Agent")); if(simpleSiteVO.getResult() - SImpleSiteVO.FAILURE == 0){ return error404(); }else{ //访问日志记录 // requestLog(request, requestInfo); Log.requestLog(request, requestInfo, simpleSiteVO); HttpResponse hr = http.get(AttachmentFile.netUrl()+"site/"+simpleSiteVO.getSimpleSite().getId()+"/sitemap.xml"); if(hr.getCode() - 404 == 0){ return error404(); }else{ model.addAttribute("html", hr.getContent()); return "domain/sitemap"; } } }
Example #14
Source File: BaseGenerate.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 生成js缓存文件保存 */ public void generateCacheFile(){ addCommonJsFunction(); initCacheFolder(); String filePath = Global.getProjectPath()+Global.CACHE_FILE+getClass().getSimpleName()+"_"+objName+".js"; try { content = content + " var xnx3_r"+DateUtil.timeForUnix10()+" = '"+getRandomValue()+"';"; FileUtil.write(filePath, content,FileUtil.UTF8); com.xnx3.j2ee.func.Log.info("create cache js file success ! file path : "+filePath); } catch (IOException e) { e.printStackTrace(); } this.content=null; }
Example #15
Source File: DelayCycleExecuteUtil__Simple__Demo.java From xnx3 with Apache License 2.0 | 5 votes |
public static void main(String[] args) { DelayCycleExecuteUtil dct = new DelayCycleExecuteUtil(new DelayCycleExecute() { public void success() { System.out.println("执行成功"); } public void failure() { System.out.println("执行失败"); } public boolean executeProcedures(int i) { System.out.println("当前第"+i+"次执行,当前时间:"+DateUtil.currentDate("yyyy-MM-dd HH:mm:ss")); if(i==3){ //假设在执行第三次的时候,执行成功了,返回true。 (true:执行成功,跳出循环,不再执行) return true; } return false; } }); /** * 设置每次执行的延迟时间,单位:毫秒。 * 如果执行 {@link DelayCycleExecute#executeProcedures(int)} 失败,则延迟指定时间后,继续执行。直到成功为止,才退出循环 * 如设定数组为:{0,2000,6000,20000} * 则第一次执行时,立即执行,不延迟; * 若失败,则延迟2秒后再次执行; * 若还失败,则延迟6秒后再次执行; * (若成功,退出循环,不再向下执行。同时运行 {@link DelayCycleExecute#success()} 方法) * 若还失败,则延迟20秒后再次执行; * 若还失败,此此时数组已到末尾,结束线程。同时会运行 {@link DelayCycleExecute#failure()} 方法 * * 若不设置,默认为: * {0,3000,10000,60000,600000,6000000} * @param sleepArray 设定的延迟数组。 */ dct.setSleepArray(new int[]{0,1000,2000,2000,1000,2000}); //开启此线程。本身是一个多线程 Thread dct.start(); }
Example #16
Source File: AliyunLogPageUtil.java From xnx3 with Apache License 2.0 | 5 votes |
/** * 列出日志服务的列表记录 * <br/>获取当前生成得分页信息可用 {@link #getPage()} 得到 * @param query 查询条件。若divQuery为true,开启用户自定义检索,这里会先将query的查询条件作为首要查询。总之查询时无论是用户传入什么条件,都会加上此指定的查询条件一并 and 查询。(<a href="https://help.aliyun.com/document_detail/29060.html">查询语法参考</a>) * @param topic topic主题,若不指定查询主题,可为空字符串"" * @param divQuery 是否开启用户自定义检索。若是开启,则用户可以通过<a href="https://help.aliyun.com/document_detail/29060.html">查询语法</a>进行自定义查询。GET或者POST传入queryString=查询条件 * @param startTime 筛选日志的开始时间,10位时间戳,若为0,则为结束时间以前1000天的时刻 * @param endTime 筛选日志的结束时间,10位时间戳,若为0,则为当前时间 * @param everyPageNumber 分页列表每页显示的条数 * @param request 主要用于获取当前url中的get传递的参数。分页数都是通过get传递的。同样,分页的参数也是自动根据这个计算出来的 * @return 返回查询的结果。 * @throws LogException */ public ArrayList<QueriedLog> list(String query, String topic, boolean divQuery, int startTime, int endTime, int everyPageNumber, HttpServletRequest request) throws LogException{ if(endTime == 0){ endTime = DateUtil.timeForUnix10(); } if(startTime == 0){ startTime = DateUtil.getDateZeroTime(endTime - 86400000); } if(divQuery){ String queryStringRequest = request.getParameter("queryString"); //查询的关键词,可模糊查询 if(queryStringRequest == null || queryStringRequest.length() == 0){ }else{ if(query != null && query.length() > 0){ query = query + " and "+queryStringRequest; }else{ query = queryStringRequest; } } } //统计1000天内的符合条件的总数量 int count = (int) aliyunLogUtil.queryCount(query, "", startTime, endTime); page = new Page(count, everyPageNumber, request); //最近三个月访问量统计 ArrayList<QueriedLog> logList = aliyunLogUtil.queryList(query, "", startTime, endTime, page.getLimitStart(), page.getEveryNumber(), true); return logList; }
Example #17
Source File: WeiXinUtil.java From xnx3 with Apache License 2.0 | 5 votes |
/** * 获取最新的普通access_token * @return AccessToken 若返回null,则获取access_token失败 */ public AccessToken getAccessToken(){ boolean refreshToken = false; //需重新刷新获取token,默认是不需要 if(accessToken == null){ accessToken = new AccessToken(); refreshToken = true; } //是否过时,需要重新获取token if(DateUtil.timeForUnix10()>accessToken.getGainTime()+ACCESS_TOKEN_DELAY_TIME){ refreshToken = true; } //避免一次可能网络中断,连续获取三次,减小误差 boolean success = !refreshToken; int i = 0; for (; i < 3 && !success ; i++) { success = refreshAccessToken(); } if(!success){ debug("连续获取"+i+"次access_token,均失败!" ); return null; }else{ return accessToken; } }
Example #18
Source File: MessageReply.java From xnx3 with Apache License 2.0 | 5 votes |
/** * 向微信服务器进行文字回复(MsgType=text)的XML格式字符串,可以将此直接回复微信服务器即可达到回复效果。 * <br/>此项即向微信服务器自动回复xml * @param response {@link HttpServletResponse}响应,输出返回值给微信服务器。 * @param content 微信自动回复用户的内容 */ public void replyText(HttpServletResponse response, String content){ String text = "<xml>" + "<ToUserName><![CDATA["+this.toUserName+"]]></ToUserName>" + "<FromUserName><![CDATA["+this.fromUserName+"]]></FromUserName>" + "<CreateTime>"+DateUtil.timeForUnix10()+"</CreateTime>" + "<MsgType><![CDATA[text]]></MsgType>" + "<Content><![CDATA["+content+"]]></Content>" + "</xml>"; reply(response, text); }
Example #19
Source File: AdminRequestLogController.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 折线图,当月(最近30天),每天的访问情况 */ @RequiresPermissions("adminRequestLogFangWen") @RequestMapping("dayLineForCurrentMonth${url.suffix}") @ResponseBody public RequestLogDayLineVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{ RequestLogDayLineVO vo = new RequestLogDayLineVO(); //当前10位时间戳 int currentTime = DateUtil.timeForUnix10(); String query = "Mozilla | timeslice 24h | count as c"; //当月访问量统计 ArrayList<QueriedLog> jinriQlList = Log.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true); JSONArray jsonArrayDate = new JSONArray(); //天数 JSONArray jsonArrayFangWen = new JSONArray(); //某天访问量,pv for (int i = 0; i < jinriQlList.size(); i++) { LogItem li = jinriQlList.get(i).GetLogItem(); JSONObject json = JSONObject.fromObject(li.ToJsonString()); try { jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd")); } catch (NotReturnValueException e) { e.printStackTrace(); } jsonArrayFangWen.add(json.getInt("c")); } vo.setJsonArrayFangWen(jsonArrayFangWen); vo.setJsonArrayDate(jsonArrayDate); AliyunLog.addActionLog(0, "总管理后台,获取最近30天的访问数据统计记录"); return vo; }
Example #20
Source File: AliyunLogUtil.java From xnx3 with Apache License 2.0 | 5 votes |
public static void main(String args[]) throws LogException, InterruptedException, NotReturnValueException { AliyunLogUtil aliyunLogUtil = new AliyunLogUtil("cn-hongkong.log.aliyuncs.com", "121212", "121212", "requestlog", "fangwen"); ArrayList<QueriedLog> qlList = aliyunLogUtil.queryList("*", "leiwen.wang.market", DateUtil.timeForUnix10()-10000000, DateUtil.timeForUnix10(), 0, 100, true); for (int i = 0; i < qlList.size(); i++) { System.out.println(i); QueriedLog ll = qlList.get(i); LogItem li = ll.GetLogItem(); System.out.println(li.GetLogContents().toString()); } System.out.println("qlList : "+qlList.size()); }
Example #21
Source File: SmsLogServiceImpl.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 通用手机验证码验证方法。输入手机号、动态验证码,验证是否成功 * @param phone 目标手机号 * @param code 六位数动态验证码 * @param type 发送类型,位于 {@link SmsLog}, {@link SmsLog}.type的值 * <ul> * <li>1:{@link SmsLog#TYPE_LOGIN}登录 </li>,若是使用此类型,则后面的overdue过期时间无用 * <li>2:{@link SmsLog#TYPE_FIND_PASSWORD}找回密码 </li> * <li>3:{@link SmsLog#TYPE_BIND_PHONE}绑定手机 </li> * </ul> * @param overdue 验证码过期时间,单位为秒。除了type为{@link SmsLog#TYPE_LOGIN}以外都有效 * @return {@link BaseVO} */ public BaseVO verifyPhoneAndCode(String phone, String code, Short type, int overdue) { BaseVO baseVO = new BaseVO(); if(phone==null || phone.length() != 11){ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("sms_sendSmsPhoneNumberFailure")); return baseVO; } if(code==null || code.length() != 6){ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeCodeFailure")); return baseVO; } int queryAddtime = 0; if(type - SmsLog.TYPE_LOGIN ==0){ //登录,传入的过期时间无效,使用xml中配置的登录的过期时间 overdue = SmsLog.codeValidity; } if(overdue > 0){ int currentTime = DateUtil.timeForUnix10(); queryAddtime = currentTime-overdue; } SmsLog smsLog = findByPhoneAddtimeUsedTypeCode(phone, queryAddtime, SmsLog.USED_FALSE, type, code); if(smsLog != null){ /****更改SmsLog状态*****/ smsLog.setUserid(0); smsLog.setUsed(SmsLog.USED_TRUE); sqlDAO.save(smsLog); baseVO.setResult(BaseVO.SUCCESS); return baseVO; }else{ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("user_loginByPhoneAndCodeCodeNotFind")); return baseVO; } }
Example #22
Source File: CollectServiceImpl.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 增加关注 * @param userid 要关注的用户的id * @return {@link BaseVO} 若成功,info返回关注成功的 collect.id */ public BaseVO addCollect(int userid){ BaseVO baseVO = new BaseVO(); if(ShiroFunc.getUser().getId() == userid){ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("collect_notCollectOneself")); return baseVO; } User user = sqlDAO.findById(User.class, userid); if(user == null){ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("collect_null")); return baseVO; } Collect collect = sqlDAO.findAloneBySqlQuery("SELECT * FROM collect WHERE othersid = " + userid + " AND userid = " + ShiroFunc.getUser().getId(), Collect.class); if(collect != null){ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("collect_already")); return baseVO; } collect = new Collect(); collect.setOthersid(userid); collect.setUserid(ShiroFunc.getUser().getId()); collect.setAddtime(DateUtil.timeForUnix10()); sqlDAO.save(collect); if(collect.getId()>0){ baseVO.setBaseVO(BaseVO.SUCCESS, collect.getId()+""); return baseVO; }else{ baseVO.setBaseVO(BaseVO.FAILURE, Language.show("collect_saveFailure")); return baseVO; } }
Example #23
Source File: LoginController_.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 用户登陆成功后,计算其所使用的资源,如OSS占用 * <br/>1.计算用户空间大小 * <br/>2.设定用户是否可进行上传附件、图片 */ public void loginSuccessComputeUsedResource(){ //获取其下有多少网站 final List<Site> list = sqlService.findBySqlQuery("SELECT * FROM site WHERE userid = "+getUserId(), Site.class); //如果这个用户是单纯的网站用户,并且今天并没有过空间计算,那么就要计算其所有的空间了 final String currentDate = DateUtil.currentDate("yyyyMMdd"); if((getUser().getOssUpdateDate() == null) || (getUser().getAuthority().equals(Global.get("USER_REG_ROLE")) && !getUser().getOssUpdateDate().equals(currentDate))){ //计算当前用户下面有多少站点,每个站点的OSS的news文件夹下用了多少存储空间了 new Thread(new Runnable() { public void run() { //属于该用户的这些网站共占用了多少存储空间去 long sizeB = 0; try { for (int i = 0; i < list.size(); i++) { sizeB += AttachmentFile.getDirectorySize("site/"+list.get(i).getId()+"/"); } } catch (Exception e) { e.printStackTrace(); System.out.println("你应该是还没配置开通OSS吧~~要想上传图片上传附件,还是老老实实,访问 /instal/index.do 进行安装吧"); } int kb = Math.round(sizeB/1024); sqlService.executeSql("UPDATE user SET oss_update_date = '"+currentDate+"' , oss_size = "+kb+" WHERE id = "+getUserId()); ShiroFunc.getUser().setOssSize(kb); ShiroFunc.setUEditorAllowUpload(kb<ShiroFunc.getUser().getOssSizeHave()*1000); } }).start(); }else{ ShiroFunc.setUEditorAllowUpload(getUser().getOssSize()<ShiroFunc.getUser().getOssSizeHave()*1000); } }
Example #24
Source File: LogAdminController_.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 折线图,当月(最近30天),每天的访问情况 */ @RequiresPermissions("adminLogCartogram") @RequestMapping("dayLineForCurrentMonth${url.suffix}") @ResponseBody public LogLineGraphVO dayLineForCurrentMonth(HttpServletRequest request) throws LogException{ LogLineGraphVO vo = new LogLineGraphVO(); //当前10位时间戳 int currentTime = DateUtil.timeForUnix10(); String query = "Mozilla | timeslice 24h | count as c"; //当月访问量统计 ArrayList<QueriedLog> jinriQlList = ActionLogCache.aliyunLogUtil.queryList(query, "", DateUtil.getDateZeroTime(currentTime - 2592000), currentTime, 0, 100, true); JSONArray jsonArrayDate = new JSONArray(); //天数 JSONArray jsonArrayFangWen = new JSONArray(); //某天访问量,pv for (int i = 0; i < jinriQlList.size(); i++) { LogItem li = jinriQlList.get(i).GetLogItem(); JSONObject json = JSONObject.fromObject(li.ToJsonString()); try { jsonArrayDate.add(DateUtil.dateFormat(json.getInt("logtime"), "MM-dd")); } catch (NotReturnValueException e) { e.printStackTrace(); } jsonArrayFangWen.add(json.getInt("c")); } vo.setDataArray(jsonArrayFangWen); vo.setNameArray(jsonArrayDate); return vo; }
Example #25
Source File: TemplateTemporaryFolder.java From wangmarket with Apache License 2.0 | 5 votes |
public void run() { Log.info("start template temporary folder timing check thread."); while (true) { try { Thread.sleep(TIMEOUT*1000); } catch (InterruptedException e) { e.printStackTrace(); } File file = new File(folderPath); if(file == null){ Log.error("folderPath --- null"); } File subFiles[] = file.listFiles(); if(subFiles != null){ for (int i = 0; i < subFiles.length; i++) { File subFile = subFiles[i]; if((subFile.lastModified() + (TIMEOUT*1000)) < DateUtil.timeForUnix13()){ //如果文件创建时间超过2分钟,那么就删除掉这个临时的模版文件夹 subFile.delete(); deleteFile(subFile); } } } } }
Example #26
Source File: JavaMQUtils.java From wangmarket with Apache License 2.0 | 5 votes |
public void run() { System.out.println("start domain update thread -- javamq"); Log.info("start domain update thread -- javamq"); while(true){ try { Thread.sleep(EXPIRE_TIME*1000); } catch (InterruptedException e) { e.printStackTrace(); } int currentTime = DateUtil.timeForUnix10(); //当前时间 for (Map.Entry<String, List<JavaQueueBean>> entry : cacheMap.entrySet()) { List<JavaQueueBean> list = entry.getValue(); if(list != null && list.size() > 0){ //取最上面的一个,也就是最早加入的,因为即使过期,肯定是最早加入的开始过期。一直从最早加入的开始遍历,直到遍历到不过期的信息为止 JavaQueueBean queue = list.get(0); while(queue != null && currentTime - queue.getAddtime() > EXPIRE_TIME){ //已过期,那么就将其删除掉 list.remove(0); //将指针指向删除后的第一个,也就是 queue if(list.size() > 0){ queue = list.get(0); }else{ queue = null; } } //遍历完之后,重新将其赋予 cacheMap cacheMap.put(entry.getKey(), list); } } } }
Example #27
Source File: JavaMQUtil.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 发送信息到 domain 项目的插件中 * @param pluginId 插件的id,如 kefu、formManage、learnExample、newsSearch 等 * @param text 发送到插件的内容,一般是 json.toString() */ public static void sendMessage(String pluginId, String content){ JavaQueueBean queue = new JavaQueueBean(); queue.setAddtime(DateUtil.timeForUnix10()); queue.setContent(content); if(receiveInterfaceMap.get(pluginId) != null){ receiveInterfaceMap.get(pluginId).receive(content); } }
Example #28
Source File: Action.java From templatespider with Apache License 2.0 | 5 votes |
/** * 获取当前操作的模版,保存路径的模版名,将要保存到文件夹的名称 * @return */ public static String getTemplatePathName(){ String uiTN = Global.mainUI.getTextField_templateName().getText(); if(uiTN == null || uiTN.length() == 0){ try { uiTN = "template_"+DateUtil.dateFormat(DateUtil.timeForUnix10(), "yyyy_MM_dd__hh_mm"); } catch (NotReturnValueException e) { e.printStackTrace(); } } return uiTN; }
Example #29
Source File: GenerateHTML.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 替换News表的相关数据。List列表页面的列表项News相关参数 * @param itemText * @param news * @return */ public String replaceNewsListItem(String itemText,News news){ //获取到文章图片 String titlePic = news.getTitlepic(); if(titlePic == null){ // titlePic = G.DEFAULT_PC_ABOUT_US_TITLEPIC; titlePic = Global.get("MASTER_SITE_URL")+"default/aboutUs.jpg"; } String text = itemText.replaceAll(GenerateHTML.regex("news.id"), news.getId()+""); text = text.replaceAll(GenerateHTML.regex("news.addtime"), DateUtil.intToString(news.getAddtime(), "yyyy-MM-dd")); text = Template.replaceAll(text, GenerateHTML.regex("news.title"), news.getTitle()+""); text = Template.replaceAll(text, GenerateHTML.regex("news.intro"), news.getIntro()+""); if(editMode){ //编辑模式 if(titlePic.indexOf("http://") == -1){ titlePic = AttachmentFile.netUrl()+"site/"+news.getSiteid()+"/news/"+titlePic; } text = text.replaceAll(GenerateHTML.regex("news.titlepic"), titlePic); text = text.replaceAll(GenerateHTML.regex("news.url"), "news.do?id="+news.getId()+"&editMode=edit"); //client=wap& 去掉,自动根据浏览器识别 }else{ //正常访问模式 //文章头图在正常访问时,使用相对路径 if(titlePic.indexOf("http://") == -1){ titlePic = "news/"+titlePic; } text = text.replaceAll(GenerateHTML.regex("news.titlepic"), titlePic); text = text.replaceAll(GenerateHTML.regex("news.url"), news.getId()+".html"); } return text; }
Example #30
Source File: CustomRealm.java From wangmarket with Apache License 2.0 | 5 votes |
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException{ // token是用户输入的用户名和密码 // 第一步从token中取出用户名 String username = (String) token.getPrincipal(); SqlService sqlService = SpringContextUtils.getBean(SqlServiceImpl.class); RoleService roleService = SpringContextUtils.getBean(RoleServiceImpl.class); User user = sqlService.findAloneBySqlQuery("SELECT * FROM user WHERE username = '"+username+"'", User.class); if(user!=null){ user.setLasttime(DateUtil.timeForUnix10()); sqlService.save(user); } if (user != null) { ActiveUser activeUser = new ActiveUser(); activeUser.setUser(user); //根据用户id查询权限url List<Permission> permissions = roleService.findPermissionByUser(user); activeUser.setPermissions(permissions); //转换为树状集合 List<PermissionTree> permissionTreeList = new ShiroFunc().PermissionToTree(new ArrayList<Permission>(), permissions); activeUser.setPermissionTreeList(permissionTreeList); String md5Password = new Md5Hash(user.getUsername(), user.getSalt(), 2).toString(); //将activeUser设置simpleAuthenticationInfo SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo( activeUser, md5Password,ByteSource.Util.bytes(user.getSalt()), this.getName()); return simpleAuthenticationInfo; } return null; }