Package org.jeecgframework.core.common.model.json

Examples of org.jeecgframework.core.common.model.json.AjaxJson


   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(TSTerritory territory, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    territory = systemService.getEntity(TSTerritory.class, territory.getId());
    message = "地域: " + territory.getTerritoryName() + "被删除成功";
    systemService.delete(territory);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    return j;
View Full Code Here


   * @return
   */
  @RequestMapping(params = "savenewpwd")
  @ResponseBody
  public AjaxJson savenewpwd(HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    TSUser user = ResourceUtil.getSessionUserName();
    String password = oConvertUtils.getString(request.getParameter("password"));
    String newpassword = oConvertUtils.getString(request.getParameter("newpassword"));
    String pString = PasswordUtil.encrypt(user.getUserName(), password, PasswordUtil.getStaticSalt());
    if (!pString.equals(user.getPassword())) {
      j.setMsg("原密码不正确");
      j.setSuccess(false);
    } else {
      try {
        user.setPassword(PasswordUtil.encrypt(user.getUserName(), newpassword, PasswordUtil.getStaticSalt()));
      } catch (Exception e) {
        e.printStackTrace();
      }
      systemService.updateEntitie(user);
      j.setMsg("修改成功");

    }
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(TSUser user, HttpServletRequest req) {
    AjaxJson j = new AjaxJson();
    if("admin".equals(user.getUserName())){
      message = "超级管理员[admin]不可删除";
      j.setMsg(message);
      return j;
    }
    user = systemService.getEntity(TSUser.class, user.getId());
    List<TSRoleUser> roleUser = systemService.findByProperty(TSRoleUser.class, "TSUser.id", user.getId());
    if (!user.getStatus().equals(Globals.User_ADMIN)) {
      if (roleUser.size()>0) {
        // 删除用户时先删除用户和角色关系表
        delRoleUser(user);
        userService.delete(user);
        message = "用户:" + user.getUserName() + "删除成功";
        systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
      } else {
        userService.delete(user);
        message = "用户:" + user.getUserName() + "删除成功";
      }
    } else {
      message = "超级管理员不可删除";
    }

    j.setMsg(message);
    return j;
  }
View Full Code Here

   */

  @RequestMapping(params = "saveUser")
  @ResponseBody
  public AjaxJson saveUser(HttpServletRequest req, TSUser user) {
    AjaxJson j = new AjaxJson();
    // 得到用户的角色
    String roleid = oConvertUtils.getString(req.getParameter("roleid"));
    String password = oConvertUtils.getString(req.getParameter("password"));
    if (StringUtil.isNotEmpty(user.getId())) {
      TSUser users = systemService.getEntity(TSUser.class, user.getId());
      users.setEmail(user.getEmail());
      users.setOfficePhone(user.getOfficePhone());
      users.setMobilePhone(user.getMobilePhone());
      users.setTSDepart(user.getTSDepart());
      users.setRealName(user.getRealName());
      users.setStatus(Globals.User_Normal);
      users.setActivitiSync(user.getActivitiSync());
      systemService.updateEntitie(users);
      List<TSRoleUser> ru = systemService.findByProperty(TSRoleUser.class, "TSUser.id", user.getId());
      systemService.deleteAllEntitie(ru);
      message = "用户: " + users.getUserName() + "更新成功";
      if (StringUtil.isNotEmpty(roleid)) {
        saveRoleUser(users, roleid);
      }
      systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    } else {
      TSUser users = systemService.findUniqueByProperty(TSUser.class, "userName",user.getUserName());
      if (users != null) {
        message = "用户: " + users.getUserName() + "已经存在";
      } else {
        user.setPassword(PasswordUtil.encrypt(user.getUserName(), password, PasswordUtil.getStaticSalt()));
        if (user.getTSDepart().equals("")) {
          user.setTSDepart(null);
        }
        user.setStatus(Globals.User_Normal);
        systemService.save(user);
        message = "用户: " + user.getUserName() + "添加成功";
        if (StringUtil.isNotEmpty(roleid)) {
          saveRoleUser(user, roleid);
        }
        systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
      }

    }
    j.setMsg(message);

    return j;
  }
View Full Code Here

    uploadFile.setCusPath("signature");
    uploadFile.setByteField("signature");
    uploadFile.setBasePath("resources");
    uploadFile.setRename(false);
    uploadFile.setObject(user);
    AjaxJson j = new AjaxJson();
    message = user.getUserName() + "设置签名成功";
    systemService.uploadFile(uploadFile);
    systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    j.setMsg(message);

    return j;
  }
View Full Code Here

  * @throws
   */
  @RequestMapping(params = "savestyle")
  @ResponseBody
  public AjaxJson saveStyle(HttpServletRequest request,HttpServletResponse response) {
    AjaxJson j = new AjaxJson();
    j.setSuccess(Boolean.FALSE);
    TSUser user = ResourceUtil.getSessionUserName();
    if(user!=null){
      String indexStyle = request.getParameter("indexStyle");
      if(StringUtils.isNotEmpty(indexStyle)){
        Cookie cookie = new Cookie("JEECGINDEXSTYLE", indexStyle);
        //设置cookie有效期为一个月
        cookie.setMaxAge(3600*24*30);
        response.addCookie(cookie);
        j.setSuccess(Boolean.TRUE);
        j.setMsg("样式修改成功,请刷新页面");
      }
    }else{
      j.setMsg("请登录后再操作");
    }
    return j;
  }
View Full Code Here

  @ResponseBody
  public AjaxJson checkuser(TSUser user, HttpServletRequest req) {
    HttpSession session = ContextHolderUtils.getSession();
    DataSourceContextHolder
        .setDataSourceType(DataSourceType.dataSource_jeecg);
    AjaxJson j = new AjaxJson();
    int users = userService.getList(TSUser.class).size();
    if (users == 0) {
      j.setMsg("a");
      j.setSuccess(false);
    } else {
      TSUser u = userService.checkUserExits(user);
      if (u != null) {
        // if (user.getUserKey().equals(u.getUserKey())) {
        if (true) {
          message = "用户: " + user.getUserName() + "["
              + u.getTSDepart().getDepartname() + "]" + "登录成功";
          Client client = new Client();
          client.setIp(IpUtil.getIpAddr(req));
          client.setLogindatetime(new Date());
          client.setUser(u);
          ClientManager.getInstance().addClinet(session.getId(),
              client);
          // 添加登陆日志
          systemService.addLog(message, Globals.Log_Type_LOGIN,
              Globals.Log_Leavel_INFO);

        } else {
          j.setMsg("请检查U盾是否正确");
          j.setSuccess(false);
        }
      } else {
        j.setMsg("用户名或密码错误!");
        j.setSuccess(false);
      }
    }
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "delTypeGridTree")
  @ResponseBody
  public AjaxJson delTypeGridTree(String id, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    if (id.startsWith("G")) {//分组
      TSTypegroup typegroup = systemService.getEntity(TSTypegroup.class, id.substring(1));
      message = "数据字典分组: " + typegroup.getTypegroupname() + "被删除 成功";
      systemService.delete(typegroup);
    } else {
      TSType type = systemService.getEntity(TSType.class, id.substring(1));
      message = "数据字典类型: " + type.getTypename() + "被删除 成功";
      systemService.delete(type);
    }
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    //刷新缓存
    systemService.refleshTypeGroupCach();
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "delTypeGroup")
  @ResponseBody
  public AjaxJson delTypeGroup(TSTypegroup typegroup, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    typegroup = systemService.getEntity(TSTypegroup.class, typegroup.getId());
    message = "类型分组: " + typegroup.getTypegroupname() + "被删除 成功";
    systemService.delete(typegroup);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    //刷新缓存
    systemService.refleshTypeGroupCach();
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "delType")
  @ResponseBody
  public AjaxJson delType(TSType type, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    type = systemService.getEntity(TSType.class, type.getId());
    message = "类型: " + type.getTypename() + "被删除 成功";
    systemService.delete(type);
    //刷新缓存
    systemService.refleshTypesCach(type);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    j.setMsg(message);
    return j;
  }
View Full Code Here

TOP

Related Classes of org.jeecgframework.core.common.model.json.AjaxJson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.