@ModelAttribute public GenTable get(@RequestParam(required = false) Long id) { if (StringUtils.isNotBlank(id)) { return genTableService.get(id); } else { return new GenTable(); } }
// @RequiresPermissions("gen:genTable:edit") @RequestMapping(value = "save") public String save(GenTable genTable, Model model, RedirectAttributes redirectAttributes) { if (!beanValidator(model, genTable)) { return form(genTable, model); } // 验证表是否已经存在 if (StringUtils.isBlank(genTable.getId()) && !genTableService.checkTableName(genTable.getName())) { addMessage(model, "保存失败!" + genTable.getName() + " 表已经存在!"); genTable.setName(""); return form(genTable, model); } genTableService.save(genTable); addMessage(redirectAttributes, "保存业务表'" + genTable.getName() + "'成功"); return "redirect:" + adminPath + "/gen/genTable/?repage"; }
// @RequiresPermissions("gen:genTable:view") @RequestMapping(value = "form") public String form(GenTable genTable, Model model) { // 获取物理表列表 List<GenTable> tableList = genTableService.findTableListFormDb(new GenTable()); model.addAttribute("tableList", tableList); // 验证表是否存在 if (StringUtils.isBlank(genTable.getId()) && !genTableService.checkTableName(genTable.getName())) { addMessage(model, "下一步失败!" + genTable.getName() + " 表已经添加!"); genTable.setName(""); } // 获取物理表字段 else { genTable = genTableService.getTableFormDb(genTable); } model.addAttribute("genTable", genTable); model.addAttribute("config", GenUtils.getConfig()); return "admin/gen/genTableForm"; }