Пример #1
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;
	}
Пример #2
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;
	}
Пример #3
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;
   }
 }
Пример #4
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;
	}
Пример #5
0
 // 退出
 public String out() {
   HttpSession session = getHttpSession();
   user = (Users) session.getAttribute("loginAdmin");
   if (user != null) {
     OperLogUtil.log(user.getLoginname(), "退出系统", getHttpRequest());
   }
   session.removeAttribute("loginAdmin");
   session.removeAttribute("manageSite");
   session.removeAttribute("siteAdmin");
   session.removeAttribute("loginUnits");
   session.removeAttribute("loginRoles");
   session.removeAttribute("funcs");
   return "login";
 }