Ejemplo n.º 1
0
  /**
   * 增加模块
   *
   * @param request
   * @param response
   * @return 返回页面
   */
  @RequestMapping("/save")
  @ResponseBody
  public void save(
      @ModelAttribute ModelEntity model, HttpServletRequest request, HttpServletResponse response) {
    // 获取管理员id并赋值给模块的id
    model.setModelId(getManagerId(request));
    // 获取模块保存时间
    model.setModelDatetime(new Timestamp(System.currentTimeMillis()));
    if (!StringUtil.checkLength(model.getModelTitle(), 1, 20)) {
      this.outJson(
          response, getResString("err.length", this.getResString("modelTitle"), "2", "20"));
      return;
    }
    if (!StringUtil.checkLength(model.getModelCode(), 1, 20)) {
      this.outJson(response, getResString("err.length", this.getResString("modelCode"), "2", "20"));
      return;
    }

    // 判断图标是否为空,不为空去掉,图标地址中含有的“|”
    // 空值判断
    if (!StringUtil.isBlank(model.getModelIcon())) {
      model.setModelIcon(model.getModelIcon().replace("|", ""));
    }
    modelBiz.saveEntity(model);
    // 返回模块id到页面
    this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelId()));
  }
Ejemplo n.º 2
0
 /**
  * 修改模块
  *
  * @return 返回页面
  */
 @RequestMapping("/update")
 @ResponseBody
 public void update(
     @ModelAttribute ModelEntity model, HttpServletRequest request, HttpServletResponse response) {
   if (!StringUtil.checkLength(model.getModelTitle(), 2, 20)
       || !StringUtil.checkLength(model.getModelCode(), 2, 20)) {
     return;
   }
   // 判断图标是否为空,不为空去掉,图标地址中含有的“|”
   // 空值判断
   if (!StringUtil.isBlank(model.getModelIcon())) {
     model.setModelIcon(model.getModelIcon().replace("|", ""));
   }
   modelBiz.updateEntity(model);
   this.outJson(response, ModelCode.ROLE, true, String.valueOf(model.getModelId()));
 }
Ejemplo n.º 3
0
  /**
   * 更新字段信息
   *
   * @param field 要更新的字段信息的id
   * @param response
   */
  @RequestMapping("/update")
  @ResponseBody
  public void update(
      @ModelAttribute DiyFormFieldEntity diyFormfield, HttpServletResponse response) {
    // 更新前判断数据是否合法
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldTipsName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldTipsName"), "1", "20"));
      return;
    }
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldFieldName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldFieldName"), "1", "20"));
      return;
    }

    // 获取自定义表单实体
    DiyFormEntity diyForm =
        (DiyFormEntity) diyFormBiz.getEntity(diyFormfield.getDiyFormFieldFormId());
    // 读取属性配置文件
    Map<String, String> maps = new LinkedHashMap<String, String>();
    maps = getMapByProperties("com/mingsoft/basic/resources/field_data_type");
    // 获取更改前的字段实体
    DiyFormFieldEntity oldField =
        (DiyFormFieldEntity) diyFormFieldBiz.getEntity(diyFormfield.getDiyFormFieldId());
    Map fields = new HashMap();
    // 更改前的字段名
    fields.put("fieldOldName", oldField.getDiyFormFieldFieldName());
    // 新字段名
    fields.put("fieldName", diyFormfield.getDiyFormFieldFieldName());
    // 字段的数据类型
    fields.put("fieldType", maps.get(String.valueOf(diyFormfield.getDiyFormFieldType())));
    if (diyForm == null) {
      this.outJson(response, null, false, this.getResString("err.not.exist"));
      return;
    }
    // 更新表的字段名
    diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fields, "modify");
    diyFormFieldBiz.updateEntity(diyFormfield);
    this.outJson(response, null, true, null);
  }
Ejemplo n.º 4
0
  /**
   * @param diyFormfield
   * @param cmTableName
   * @param response
   */
  @RequestMapping("/{diyFormId}/save")
  @ResponseBody
  public void save(
      @ModelAttribute DiyFormFieldEntity diyFormfield,
      @PathVariable int diyFormId,
      HttpServletResponse response) {
    // 获取自定义表单实体
    DiyFormEntity diyForm = (DiyFormEntity) diyFormBiz.getEntity(diyFormId);
    if (diyForm == null) {
      this.outJson(
          response, null, false, this.getResString("err.not.exist", this.getResString("diy.form")));
      return;
    }
    // 更新前判断数据是否合法
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldTipsName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldTipsName"), "1", "20"));
      return;
    }
    if (!StringUtil.checkLength(diyFormfield.getDiyFormFieldFieldName(), 1, 20)) {
      this.outJson(
          response,
          null,
          false,
          getResString("err.length", this.getResString("fieldFieldName"), "1", "20"));
      return;
    }

    // 读取属性配置文件
    Map<String, String> maps = new LinkedHashMap<String, String>();
    maps = getMapByProperties("com/mingsoft/basic/resources/field_data_type");
    // 动态的修改表结构
    // 获取字段信息
    Map fileds = new HashMap();
    // 压入字段名
    fileds.put("fieldName", diyFormfield.getDiyFormFieldFieldName());
    // 字段的数据类型
    fileds.put("fieldType", maps.get(String.valueOf(diyFormfield.getDiyFormFieldType())));
    fileds.put("default", diyFormfield.getDiyFormFieldDefault());
    // 在表中创建字段
    diyFormFieldBiz.alterTable(diyForm.getDiyFormTableName(), fileds, "add");
    this.diyFormFieldBiz.saveEntity(diyFormfield);
    this.outJson(response, null, true, null);
  }
Ejemplo n.º 5
0
  /**
   * 修改密码
   *
   * @param people 用户信息<br>
   *     <i>people参数包含字段信息参考:</i><br>
   *     peopleOldPassword 用户旧密码<br>
   *     peoplePassword 用户新密码<br>
   *     <dt><span class="strong">返回</span><br>
   *         {code:"错误编码",<br>
   *         result:"true|false",<br>
   *         resultMsg:"错误信息"<br>
   *         }
   */
  @RequestMapping(value = "/changePassword", method = RequestMethod.POST)
  @ResponseBody
  public void changePassword(
      @ModelAttribute PeopleEntity people,
      HttpServletRequest request,
      HttpServletResponse response) {
    if (StringUtil.isBlank(people.getPeoplePassword())) {
      // 用户或密码不能为空
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.empty", this.getResString("people.password")));
      return;
    }

    if (StringUtil.isBlank(people.getPeopleOldPassword())) {
      // 用户或密码不能为空
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.empty", this.getResString("people.old.password")));
      return;
    }

    // 验证新密码的长度
    if (!StringUtil.checkLength(people.getPeoplePassword(), 6, 30)) {
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.length", this.getResString("people.password"), "6", "20"));
      return;
    }

    // 获取用户session
    PeopleEntity _people = this.getPeopleBySession(request);
    PeopleEntity curPeople = peopleBiz.getByPeople(_people, this.getAppId(request));
    if (!curPeople.getPeoplePassword().equals(StringUtil.Md5(people.getPeopleOldPassword()))) {
      // 用户或密码不能为空
      this.outJson(
          response,
          ModelCode.PEOPLE,
          false,
          this.getResString("err.error", this.getResString("people.password")));
      return;
    }
    // 将用户输入的原始密码用MD5加密再和数据库中的进行比对
    String peoplePassWord = StringUtil.Md5(people.getPeoplePassword(), Const.UTF8);
    // 执行修改
    _people.setPeoplePassword(peoplePassWord);
    this.peopleBiz.updateEntity(_people);
    this.outJson(response, ModelCode.PEOPLE, true);
  }