// @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"; }
// @RequiresPermissions("gen:genTable:view") @RequestMapping(value = {"list", ""}) public String list(@PageableDefault Pageable pageable, GenTable genTable, Model model) { UserToken user = UserUtils.getUserToken(); if (!user.isAdmin()) { genTable.setCreatedBy(user); } Page<GenTable> page = genTableService.find(genTable, pageable); model.addAttribute("page", page); return "admin/gen/genTableList"; }