public void modifyFuncGroupRelation(String funcGroupId, String targetGroupId) { // 查找当前功能组currentGroup AppFuncgroup currentGroup = AppFuncgroup.FACTORY.create(); currentGroup.setFuncgroupid(NumberUtils.createBigDecimal(funcGroupId)); getDASTemplate().expandEntity(currentGroup); String currentAppId = currentGroup.getAppApplication().getAppid().toString(); // 查找目标功能组targetGroup AppFuncgroup targetGroup = AppFuncgroup.FACTORY.create(); targetGroup.setFuncgroupid(NumberUtils.createBigDecimal(targetGroupId)); getDASTemplate().expandEntity(targetGroup); String targetAppId = targetGroup.getAppApplication().getAppid().toString(); // 查找当前功能组的所有子孙 funcGroups AppFuncgroup[] groups = getChildFuncGroups(currentGroup); // 遍历funcGroups List<AppFuncgroup> updateList = new ArrayList<AppFuncgroup>(); List<String> idList = new ArrayList<String>(); for (AppFuncgroup funcGroup : groups) { // 为当前功能组 if (StringUtils.equals(funcGroup.getFuncgroupid().toString(), funcGroupId)) { // 修改当前功能组的父功能组 funcGroup.setAppFuncgroup(targetGroup); funcGroup.setFuncgroupseq(targetGroup.getFuncgroupseq() + funcGroupId + "."); } else { funcGroup.setFuncgroupseq( StringUtils.replace( funcGroup.getFuncgroupseq(), currentGroup.getFuncgroupseq(), targetGroup.getFuncgroupseq() + funcGroupId + ".")); } // 如果应用发生改变修改所有子孙的appid if (!StringUtils.equals(currentAppId, targetAppId)) { funcGroup.setAppApplication(targetGroup.getAppApplication()); } updateList.add(funcGroup); idList.add(funcGroup.getFuncgroupid().toString()); } targetGroup.setSubcount( targetGroup.getSubcount().add(NumberUtils.createBigDecimal(String.valueOf(groups.length)))); updateList.add(targetGroup); try { // 批量更新子功能组,功能组,父功能组 getDASTemplate().updateEntityBatch(updateList.toArray(new AppFuncgroup[updateList.size()])); // 如果应用改变了需要更新资源 if (!StringUtils.equals(currentAppId, targetAppId)) { BeanFactory beanFactory = BeanFactory.newInstance(); IAppFunctionService functionService = beanFactory.getBean("AppFunctionBean"); String[] funcGroupIds = idList.toArray(new String[idList.size()]); AppFunction[] functions = functionService.getFunctionsByFuncGroupIds(funcGroupIds); // 更新资源 functionService.updateResoucesBatch(functions); } } catch (Throwable t) { log.error( "Update funcgroup failure, please do the operation again or contact the sysadmin.", t); } }
public Response getCommunityByDistance(String auth, String lonAndLat, String r) { Double distance = 0.0; if (StringUtils.isBlank(r) || !NumberUtils.isNumber(r)) { distance = 3.0; // 默认是3千米 } else { distance = Double.valueOf(r); } List<CommunityVo> comms = commDao.getCommunityByDistance(lonAndLat, distance); Map<String, Object> result = new HashMap<String, Object>(); FaultTolerant fault = new Gson().fromJson(auth, FaultTolerant.class); // 进行验证 if (!"0".equals(fault.getUid())) { if (Auth.auth(fault) == false) { result.put("code", CommonErrorEnum.FAULT_FOLERANT.getCode()); result.put("msg", CommonErrorEnum.FAULT_FOLERANT.getMessage()); return ReturnJSON.getInstance().ret(result); } } result.put("code", 0); result.put("msg", "查询成功"); result.put("data", comms); return ReturnJSON.getInstance().ret(result); }
public Map<String, Object> delete(String delIds) { // TODO 删除房源 Map<String, Object> map = new HashMap<String, Object>(); if (StringUtils.isBlank(delIds)) { map.put("error", "请选中要删除的数据"); return map; } String[] ids = delIds.split(","); StringBuilder sb = new StringBuilder("delete from " + Room.TABLENAME); StringBuilder condition = new StringBuilder(); for (String id : ids) { if (NumberUtils.isNumber(id)) { condition.append(" id = " + id + " or "); } } if (StringUtils.isNotBlank(condition.toString())) { sb.append(" where ").append(condition.toString()); } int pos = sb.toString().lastIndexOf("or"); String sql = ""; if (pos != -1) { sql = sb.toString().substring(0, pos); } else { sql = sb.toString(); } System.out.println("RoomDaoImpl.delete() Sql : " + sql); int affected = jdbcTemplate.update(sql); // 同时把图标标志位改为0 imageDaoImpl.delete(delIds); map.put("success", "已经成功删除" + affected + "条记录..."); return map; }
public void deleteFuncGroupById(String id) { AppFuncgroup appFuncgroup = AppFuncgroup.FACTORY.create(); appFuncgroup.setFuncgroupid(NumberUtils.createBigDecimal(id)); try { getDASTemplate().deleteEntityCascade(appFuncgroup); } catch (Throwable t) { log.error( "Delete funcgroup [funcgroupid=" + appFuncgroup.getFuncgroupid() + "] failure, please do the operation again or contact the sysadmin.", t); } }
@RequestMapping(value = "/uploadImage", method = RequestMethod.POST) public ModelAndView upload( HttpServletResponse resp, HttpServletRequest req, @RequestParam MultipartFile[] image) { String id = (String) req.getSession().getAttribute("room_id"); ModelAndView view = new ModelAndView("redirect:/fileUpView?id=" + id); Map<String, Object> map = new HashMap<String, Object>(); String room_id = (String) req.getSession().getAttribute("room_id"); if (NumberUtils.isNumber(room_id)) { String dir = req.getSession().getServletContext().getRealPath("/upload"); map = imageBo.upload(image, dir, Integer.parseInt(room_id)); // req.getSession().setAttribute("imageList", map.get("success")); return view; } else { // map.put("error", "房源为空..."); return new ModelAndView("error"); } }