Ejemplo n.º 1
0
  /**
   * 方法描述:修改圈子地图经纬度信息
   *
   * @param circle圈子实体信息
   * @return 等于1修改成功,否则失败 date:2014-12-17
   * @author [email protected]
   */
  public int updateCircleMap(Circle circle) throws SPTException {
    logger.debug("[CircleDaoImpl.updateCircleMap] start...");

    /** 修改角色返回结果参数默认为 -1 (失败) */
    int resultNum = -1;

    /** 更新时各字段对应值 map */
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("id", circle.getId());
    paramMap.put("longitude", circle.getLongitude());
    paramMap.put("latitude", circle.getLatitude());

    resultNum = commonDao.update(UPDATA_CIRCLE_MAP, paramMap);
    logger.debug("[CircleDaoImpl.updateCircleMap] end...");
    return resultNum;
  }
Ejemplo n.º 2
0
  /**
   * 方法描述:用户登录(返回毁掉url,登录结果 0:登录失败 1:登录成功) view viewId(1:创建圈子 2:加入圈子 其他:直接登录) date:2015-01-09 add
   * by: Cooper
   *
   * @throws IOException
   */
  @ResponseBody
  @RequestMapping("login.action")
  public String login(
      String mobilePhone,
      String password,
      String viewId,
      String circleId,
      HttpServletRequest request,
      HttpServletResponse response)
      throws IOException {
    viewId = viewId == null ? "" : viewId;
    JSONObject josnResult = new JSONObject();
    HttpSession session = request.getSession();
    String msg = "";
    String url = "";
    int result = 0;
    User user = null; // 用户登录对象

    // 登录结果
    if (!CommonUtil.isEmpty(mobilePhone) && !CommonUtil.isEmpty(password)) {
      try {
        user = loginService.login(mobilePhone, password);
      } catch (Exception e) {
        logger.error(CommonUtil.getErrorMessage(Thread.currentThread().getStackTrace()[1], e));
      }
      // 登录失败
      if (null == user) {
        msg = "用户名或密码错误,请重新输入!";
        result = 0;
      }
      // 登录成功
      else {
        session.setAttribute(ConstantBusiKeys.SessionKey.SYS_USER, user);
        // 记录最后登录质检
        try {
          loginService.updateUserLastLoginTimer(mobilePhone);
        } catch (SPTException e) {
          logger.error(CommonUtil.getErrorMessage(Thread.currentThread().getStackTrace()[1], e));
        }
        msg = "";
        result = 1;
      }
    }

    // 创建圈子登录
    if (viewId.equals("1")) {
      url = "/usercenter/toCreateCircle.action";
    }
    // 加入圈子登录
    else if (viewId.equals("2") && user != null) {
      try {
        Circle circle = circleService.queryCircleByCircleId(circleId);
        if (user.getId() == circle.getCreateUserId()) {
          msg = "您是农场主,无须加入!";
          josnResult.put("msg", msg);
          josnResult.put("url", url);
          josnResult.put("result", result);
          josnResult.put("viewId", viewId);
          return josnResult.toString();
        }
        // 圈子 允许 直接加入
        if (circle.getJoinType().equals(SystemDict.CIRCLE_AUTO_JOIN)) {
          msg =
              circleService.queryCircleMemberByCircleIdAndUserId(circleId, user.getId() + "") == 0
                  ? ""
                  : "您已是农场成员!";
          if (!msg.equals("")) {
            josnResult.put("msg", msg);
            josnResult.put("url", url);
            josnResult.put("result", result);
            josnResult.put("viewId", viewId);
            return josnResult.toString();
          }
          msg =
              circleService.AddUserToCircle(user.getId(), circleId, SystemDict.NORMAL_USER) == true
                  ? "success"
                  : "加入失败!";

          if (msg.equals("success")) {
            List<Circle> myCircle = circleService.queryMyCircleList(user.getId());
            request.getSession().setAttribute(ConstantBusiKeys.SessionKey.MY_CIRCLE, myCircle);

            MessageBean msgBean =
                new MessageBean(
                    SystemDict.MESSAGE_NORMAL,
                    "您好," + user.getName() + "加入了你的[" + circle.getName() + "]农场!",
                    user.getId() + "",
                    circle.getCreateUserId() + "",
                    "");
            MsgQueue.GROUP_QUEUE.add(msgBean);
          }
        } else {
          JSONObject jsonResult = new JSONObject();
          jsonResult.put("userId", user.getId());
          jsonResult.put("circleId", circleId);
          jsonResult.put("createUserId", circle.getCreateUserId());
          jsonResult.put("userName", user.getName());
          jsonResult.put("circleName", circle.getName());

          // 需要农场主审核
          if (circleService.queryCircleMemberAuditByCircleIdAndUserId(circleId, user.getId() + "")
              == 0) {
            boolean flag =
                circleService.AddUserToCircleAudit(
                    user.getId() + "", circleId, SystemDict.NORMAL_USER, SystemDict.EXAMINEING);
            if (flag) {
              // 消息记录中没有,添加消息
              if (msgService.queryCircleMsgCount(user.getId() + "", circle.getCreateUserId() + "")
                  == 0) {
                MessageBean msgBean =
                    new MessageBean(
                        SystemDict.MESSAGE_CIRCLE,
                        "您好," + user.getName() + "申请加入你的[!" + circle.getName() + "]农场!",
                        user.getId() + "",
                        circle.getCreateUserId() + "",
                        jsonResult.toString());
                MsgQueue.GROUP_QUEUE.add(msgBean);
              }
              msg = "已发送加入申请,请等待审核!";
            } else {
              msg = "加入农场失败!";
            }
          } else {
            msg = "您已是农场成员!";
          }
        }

      } catch (SPTException e) {
        e.printStackTrace();
        msg = "加入农场失败!";
      }

    } else if (viewId.equals("3") && user != null) { // 注册进入
      url = "";
      response.sendRedirect(request.getContextPath() + url);
      return null;
    }
    josnResult.put("msg", msg);
    josnResult.put("url", url);
    josnResult.put("result", result);
    josnResult.put("viewId", viewId);
    return josnResult.toString();
  }
Ejemplo n.º 3
0
  /**
   * 方法描述:根据ID修改圈子信息
   *
   * @param circle 圈子实体信息
   * @return resultNum-受影响行数:1为更新成功,其他为更新失败 date:2014-12-14 add by: [email protected]
   * @throws SPTException
   */
  public int updateCircle(Circle circle) throws SPTException {
    logger.debug("[CircleDaoImpl.updateCircle] start...");

    /** 修改角色返回结果参数默认为 -1 (失败) */
    int resultNum = -1;

    /** 更新时各字段对应值 map */
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("id", circle.getId());
    paramMap.put("name", circle.getName());
    paramMap.put("description", circle.getDescription());
    paramMap.put("headPath", circle.getHeadPath());
    paramMap.put("joinType", circle.getJoinType());
    paramMap.put("issueAddress", circle.getIssueAddress());
    paramMap.put("createUserid", circle.getCreateUser());
    paramMap.put("address", circle.getAddress());
    paramMap.put("province", circle.getProvince());
    paramMap.put("city", circle.getCity());
    paramMap.put("longitude", circle.getLongitude());
    paramMap.put("latitude", circle.getLatitude());

    resultNum = commonDao.update(UPDATA_CIRCLE, paramMap);
    logger.debug("[CircleDaoImpl.updateCircle] end...");
    return resultNum;
  }
Ejemplo n.º 4
0
  /**
   * 方法描述:添加圈子信息
   *
   * @param circle 圈子实体信息
   * @return 1添加成功,否则失败 date:2014-12-14
   * @author [email protected]
   */
  public int addCicle(Circle circle) throws SPTException {
    logger.debug("[CircleDaoImpl.addCicle] start...");

    /** 增加圈子信息返回结果参数默认为 -1 (失败) */
    int resultNum = -1;

    /** 增加时各字段对应值 map */
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("name", circle.getName());
    paramMap.put("description", circle.getDescription());
    paramMap.put("headPath", circle.getHeadPath());
    paramMap.put("joinType", circle.getJoinType());
    paramMap.put("issueAddress", circle.getIssueAddress());
    paramMap.put("createUserid", circle.getCreateUser());
    paramMap.put("issueTime", circle.getIssueTime());
    paramMap.put("endTime", circle.getEndTime());
    paramMap.put("address", circle.getAddress());
    paramMap.put("notice", circle.getNotice());
    paramMap.put("province", circle.getProvince());
    paramMap.put("city", circle.getCity());
    paramMap.put("longitude", circle.getLongitude());
    paramMap.put("latitude", circle.getLatitude());
    paramMap.put("postWeek", circle.getPostWeek() + "");
    paramMap.put("postAmPm", circle.getPostAmPm() + "");

    resultNum = commonDao.update(ADD_CIRCLE, paramMap);
    int id = commonDao.getLastId(CircleTable.CIRCLE.getTableName(), "id");
    circle.setId(id + "");
    logger.debug("[CircleDaoImpl.addCicle] end...");
    return resultNum;
  }