示例#1
0
  @RequestMapping
  public String view(Model model, Long id) {
    SysDept sysDept = sysDeptService.get(id);

    model.addAttribute("bean", sysDept);
    return "view/sys/sysDeptView";
  }
示例#2
0
  @RequestMapping
  public void save(
      HttpServletResponse response, Model model, @ModelAttribute("bean") SysDept entity)
      throws Exception {
    try {
      String[] columns =
          new String[] {
            "code",
            "name",
            "shortName",
            "cardNo",
            "cityCode",
            "cityName",
            "provinceCode",
            "provinceName",
            "address",
            "orderNo",
            "isValid",
            "type",
            "linker",
            "email",
            "telephone",
            "fax",
            "netSite",
            "memo"
          };

      SysDept target;
      if (entity.getId() != null) {
        target = sysDeptService.get(entity.getId());

        ReflectionUtils.copyBean(entity, target, columns);
      } else {
        target = entity;
      }

      sysDeptService.save(target);
    } catch (Exception e) {
      log.error("error", e);
      super.processException(response, e);
    }

    sendSuccessJSON(response, "保存成功");
  }
示例#3
0
  @RequestMapping
  public String init(Model model, SysDept entity) throws Exception {
    try {
      if (entity != null && entity.getId() != null) {
        entity = sysDeptService.get(entity.getId());

        LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
        for (int i = 0; i < companyTypeStr.length; i++) {
          map.put(companyType[i], companyTypeStr[i]);
        }
        model.addAttribute("bean", entity);
        model.addAttribute("companyTypeItems", map);
      }
    } catch (Exception e) {
      log.error("error", e);
    }

    return "view/sys_new/sysDeptEdit";
  }