Esempio n. 1
0
 public String weblogin() {
   try {
     // 记住用户名
     if ("on".equals(RememberMe)) {
       Cookie cookie = new Cookie("FreeCMS_loginName", EscapeUnescape.escape(user.getLoginname()));
       cookie.setMaxAge(60 * 60 * 24 * 365); // 有效时间为一年
       getHttpResponse().addCookie(cookie);
     }
     HttpSession session = getHttpSession();
     msg = userService.checkLogin(getHttpSession(), user);
     if (msg == null || "".equals(msg)) {
       OperLogUtil.log(user.getLoginname(), "登录系统", getHttpRequest());
       return "admin";
     } else {
       ResponseUtil.writeGBK(
           getHttpResponse(), "<script>alert('" + msg + "');history.back();</script>");
       return null;
     }
   } catch (Exception e) {
     try {
       MybatisSessionFactory.getSession().rollback();
     } catch (Exception e1) {
       e1.printStackTrace();
     }
     e.printStackTrace();
     OperLogUtil.log(user.getLoginname(), "登录系统失败:" + e.toString(), getHttpRequest());
     ResponseUtil.writeGBK(
         getHttpResponse(), "<script>alert('出现错误:" + e.toString() + "');history.back();</script>");
     return null;
   }
 }
Esempio n. 2
0
	//保存
	public String save(){
		Users users=getLoginAdmin();
		unitMapper=MybatisSessionFactory.getSession().getMapper(UnitMapper.class);
		String result="0";
		String idname="";
		try {
			if (unit.getId()!=null&&unit.getId().trim().length()>0) {
				msg="修改";
				unitMapper.updateByPrimaryKey(unit);
				MybatisSessionFactory.getSession().commit();
				unitService.callUnitUpdatePro(unit.getId());
			}else {
				msg="添加";
				unit.setId(UUID.randomUUID().toString());
				unitMapper.insert(unit);
				MybatisSessionFactory.getSession().commit();
				idname="<属性>"+unit.getId()+"<属性>"+unit.getName();
			}
			result="1";
		} catch (Exception e) {
			try {
				MybatisSessionFactory.getSession().rollback();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
			result="0";
			msg+="单位 "+unit.getName()+" 失败:"+e.toString();
		}
		msg+="单位 "+unit.getName()+" 成功"+idname;
		OperLogUtil.log(users.getLoginname(), msg, getHttpRequest());
		ResponseUtil.writeUTF(getHttpResponse(),result+msg);
		return null;
	}
Esempio n. 3
0
	//改变所属单位
	public String par(){

		Users users=getLoginAdmin();
		String result="0";
		msg="改变菜单 "+unit.getName()+" 的所属菜单为 "+parname+" ";
		try {
			if (unit.getId()!=null&&unit.getId().trim().length()>0) {
				unitMapper=MybatisSessionFactory.getSession().getMapper(UnitMapper.class);
				unitMapper.updatePar(unit);
				MybatisSessionFactory.getSession().commit();
				result="1";
				msg+="成功<属性>"+unit.getId()+"<属性>"+unit.getParid();
			}else {
				msg="删除时没有获取到菜单 "+unit.getName();
			}
		} catch (Exception e) {
			try {
				MybatisSessionFactory.getSession().rollback();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
			result="0";
			msg+="失败:"+e.toString();
		}
		OperLogUtil.log(users.getLoginname(), msg, getHttpRequest());
		ResponseUtil.writeUTF(getHttpResponse(),result+msg);
		return null;
	}
Esempio n. 4
0
	//保存
	public String find(){
		String result="0";
		StringBuilder sb=new StringBuilder();
		try {
			if (unit.getId()!=null && unit.getId().trim().length()>0) {
				unitMapper=MybatisSessionFactory.getSession().getMapper(UnitMapper.class);
				Unit currUnit=unitMapper.selectByPrimaryKey(unit.getId().trim());
				if (currUnit!=null) {
					sb.append(currUnit.getId());
					sb.append("<属性>");
					sb.append(currUnit.getName()!=null?currUnit.getName():"");
					sb.append("<属性>");
					sb.append(currUnit.getIsok());
					sb.append("<属性>");
					sb.append(currUnit.getOrdernum()!=null?currUnit.getOrdernum():"");
					sb.append("<属性>");
					sb.append(currUnit.getParid());
					sb.append("<属性>");
					sb.append(currUnit.getIsmail());
					result="1";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			result="0";	
		}
		ResponseUtil.writeUTF(getHttpResponse(),result+sb.toString());
		return null;
	}
Esempio n. 5
0
 /**
  * 查询子站点
  *
  * @return
  */
 public String authSon() {
   try {
     List<Site> list = null;
     // 提取子站点
     list = siteService.selectByParId(root);
     // 生成树
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.append("[");
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         if (site != null
             && site.getId() != null
             && site.getId().trim().length() > 0
             && site.getId().equals(list.get(i).getId())) {
           continue;
         }
         if (!"[".equals(stringBuilder.toString())) {
           stringBuilder.append(",");
         }
         stringBuilder.append("{ \"text\": \"<a  onclick=");
         if (onclick != null && onclick.trim().length() > 0) {
           stringBuilder.append(onclick);
         } else {
           stringBuilder.append("showDetail");
         }
         stringBuilder.append("('");
         stringBuilder.append(list.get(i).getId());
         stringBuilder.append(
             "','"
                 + list.get(i).getName().replaceAll(" ", "")
                 + "','"
                 + (site != null && site.getId() != null ? site.getId() : "")
                 + "')>");
         stringBuilder.append(list.get(i).getName());
         // 判断是否有权限
         if (role != null
             && role.getId().trim().length() > 0
             && roleSiteService.have(list.get(i).getId(), role.getId())) {
           stringBuilder.append(" ★");
         }
         stringBuilder.append("\", \"hasChildren\": ");
         if (siteService.hasChildren(list.get(i).getId())) {
           stringBuilder.append("true");
         } else {
           stringBuilder.append("false");
         }
         stringBuilder.append(",\"id\":\"");
         stringBuilder.append(list.get(i).getId());
         stringBuilder.append("\" }");
       }
     }
     stringBuilder.append("]");
     ResponseUtil.writeUTF(getHttpResponse(), stringBuilder.toString());
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Esempio n. 6
0
	public String son()
	{
		Users users=getLoginAdmin();
		List<Unit> list=null; 
		unitMapper=MybatisSessionFactory.getSession().getMapper(UnitMapper.class);
		if ("root".equals(root)) {
			//提取一级菜单 
			list=unitMapper.selectUnit("");
		}else {
			//提取子菜单
			list=unitMapper.selectUnit(root);
		}
		//生成树
		StringBuilder stringBuilder=new StringBuilder();
		stringBuilder.append("[");
		if (list!=null && list.size()>0) {
			for (int i = 0; i <list.size() ; i++) {
				if (!list.get(i).getId().equals(noid)) {
					if (!"[".equals(stringBuilder.toString())) {
						stringBuilder.append(",");
					}
					stringBuilder.append("{ \"text\": \"<a  onclick=");
					if (onclick!=null && onclick.trim().length()>0) {
						stringBuilder.append(onclick);
					}else {
						stringBuilder.append("showDetail");
					}
					stringBuilder.append("('");
					stringBuilder.append(list.get(i).getId());
					stringBuilder.append("','"+list.get(i).getName().replaceAll(" ", "")+"')>");
					stringBuilder.append(list.get(i).getName());
					stringBuilder.append("\", \"hasChildren\": ");
					if (unitService.hasChildren(list.get(i).getId())) {
						stringBuilder.append("true");
					}else {
						stringBuilder.append("false");
					}
					stringBuilder.append(",\"id\":\"");
					stringBuilder.append(list.get(i).getId());
					stringBuilder.append("\" }");
				}
			}
		}
		stringBuilder.append("]");
		ResponseUtil.writeUTF(getHttpResponse(), stringBuilder.toString());
		return null;
	}
Esempio n. 7
0
 /**
  * 查询子站点
  *
  * @return
  */
 public String checkSon() {
   try {
     List<Site> list = null;
     // 提取子站点
     list = siteService.selectByParId(root);
     // 生成树
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.append("[");
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         if (site != null
             && site.getId() != null
             && site.getId().trim().length() > 0
             && site.getId().equals(list.get(i).getId())) {
           continue;
         }
         if (!"[".equals(stringBuilder.toString())) {
           stringBuilder.append(",");
         }
         stringBuilder.append("{ \"text\": \"<input onclick='siteCheck(this)' type=checkbox ");
         if (sites != null
             && sites.trim().length() > 0
             && sites.indexOf(list.get(i).getId() + ";") > -1) {
           stringBuilder.append("checked");
         }
         stringBuilder.append(
             " name=sites value=" + list.get(i).getId() + " show=" + list.get(i).getName() + ">");
         stringBuilder.append(list.get(i).getName());
         stringBuilder.append("\", \"hasChildren\": ");
         if (siteService.hasChildren(list.get(i).getId())) {
           stringBuilder.append("true");
         } else {
           stringBuilder.append("false");
         }
         stringBuilder.append(",\"id\":\"");
         stringBuilder.append(list.get(i).getId());
         stringBuilder.append("\" }");
       }
     }
     stringBuilder.append("]");
     ResponseUtil.writeUTF(getHttpResponse(), stringBuilder.toString());
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Esempio n. 8
0
	//删除
	public String del(){

		Users users=getLoginAdmin();
		unitMapper=MybatisSessionFactory.getSession().getMapper(UnitMapper.class);
		String result="0";
		try {
			if (unit.getId()!=null&&unit.getId().trim().length()>0) {
				//先看是否有子单位
				List<Unit> sons=unitMapper.selectUnitByparid(unit.getId());
				if (sons!=null && sons.size()>0) {
					//删除子单位
					for (int i = 0; i < sons.size(); i++) {
						unitService.callUnitDelPro(sons.get(i).getId());
						unitMapper.deleteByPrimaryKey(sons.get(i).getId());
					}
				}
				unitService.callUnitDelPro(unit.getId());
				unitMapper.deleteByPrimaryKey(unit.getId());
				MybatisSessionFactory.getSession().commit();
				result="1";
				msg="删除单位 "+unit.getName()+" 成功<属性>"+unit.getId();
			}else {
				msg="删除时没有获取到单位 "+unit.getName();
			}
		} catch (Exception e) {
			try {
				MybatisSessionFactory.getSession().rollback();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
			result="0";
			msg="删除单位 "+unit.getName()+" 失败:"+e.toString();
		}
		OperLogUtil.log(users.getLoginname(), msg, getHttpRequest());
		ResponseUtil.writeUTF(getHttpResponse(),result+msg);
		return null;
	}