| | |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | | import com.ruoyi.framework.config.GenConfig;
|
| | | import com.ruoyi.framework.web.controller.BaseController;
|
| | | import com.ruoyi.framework.web.domain.AjaxResult;
|
| | | import com.ruoyi.framework.web.domain.R; |
| | | import com.ruoyi.framework.web.page.TableDataInfo;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTable;
|
| | | import com.ruoyi.project.tool.gen.domain.GenTableColumn;
|
| | |
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:query')")
|
| | | @GetMapping(value = "/{talbleId}")
|
| | | public AjaxResult getInfo(@PathVariable Long talbleId)
|
| | | public R<?> getInfo(@PathVariable Long talbleId) |
| | | {
|
| | | GenTable table = genTableService.selectGenTableById(talbleId);
|
| | | List<GenTable> tables = genTableService.selectGenTableAll();
|
| | |
| | | map.put("info", table);
|
| | | map.put("rows", list);
|
| | | map.put("tables", tables);
|
| | | return success(map);
|
| | | return R.ok(map); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:import')")
|
| | | @Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
| | | @PostMapping("/importTable")
|
| | | public AjaxResult importTableSave(String tables)
|
| | | public R<?> importTableSave(String tables) |
| | | {
|
| | | String[] tableNames = Convert.toStrArray(tables);
|
| | | // 查询表信息
|
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
| | | genTableService.importGenTable(tableList, SecurityUtils.getUsername());
|
| | | return success();
|
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasRole('admin')")
|
| | | @Log(title = "创建表", businessType = BusinessType.OTHER)
|
| | | @PostMapping("/createTable")
|
| | | public AjaxResult createTableSave(String sql)
|
| | | public R<?> createTableSave(String sql) |
| | | {
|
| | | try
|
| | | {
|
| | |
| | | List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames.toArray(new String[tableNames.size()]));
|
| | | String operName = SecurityUtils.getUsername();
|
| | | genTableService.importGenTable(tableList, operName);
|
| | | return AjaxResult.success();
|
| | | return R.ok(); |
| | | }
|
| | | catch (Exception e)
|
| | | {
|
| | | logger.error(e.getMessage(), e);
|
| | | return AjaxResult.error("创建表结构异常");
|
| | | return R.fail("创建表结构异常"); |
| | | }
|
| | | }
|
| | |
|
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
|
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
| | | @PutMapping
|
| | | public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
|
| | | public R<?> editSave(@Validated @RequestBody GenTable genTable) |
| | | {
|
| | | genTableService.validateEdit(genTable);
|
| | | genTableService.updateGenTable(genTable);
|
| | | return success();
|
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:remove')")
|
| | | @Log(title = "代码生成", businessType = BusinessType.DELETE)
|
| | | @DeleteMapping("/{tableIds}")
|
| | | public AjaxResult remove(@PathVariable Long[] tableIds)
|
| | | public R<?> remove(@PathVariable Long[] tableIds) |
| | | {
|
| | | genTableService.deleteGenTableByIds(tableIds);
|
| | | return success();
|
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @PreAuthorize("@ss.hasPermi('tool:gen:preview')")
|
| | | @GetMapping("/preview/{tableId}")
|
| | | public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
|
| | | public R<?> preview(@PathVariable("tableId") Long tableId) throws IOException |
| | | {
|
| | | Map<String, String> dataMap = genTableService.previewCode(tableId);
|
| | | return success(dataMap);
|
| | | return R.ok(dataMap); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:code')")
|
| | | @Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
| | | @GetMapping("/genCode/{tableName}")
|
| | | public AjaxResult genCode(@PathVariable("tableName") String tableName)
|
| | | public R<?> genCode(@PathVariable("tableName") String tableName) |
| | | {
|
| | | if (!GenConfig.isAllowOverwrite())
|
| | | {
|
| | | return AjaxResult.error("【系统预设】不允许生成文件覆盖到本地");
|
| | | return R.fail("【系统预设】不允许生成文件覆盖到本地"); |
| | | }
|
| | | genTableService.generatorCode(tableName);
|
| | | return success();
|
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|
| | |
| | | @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
|
| | | @Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
| | | @GetMapping("/synchDb/{tableName}")
|
| | | public AjaxResult synchDb(@PathVariable("tableName") String tableName)
|
| | | public R<?> synchDb(@PathVariable("tableName") String tableName) |
| | | {
|
| | | genTableService.synchDb(tableName);
|
| | | return success();
|
| | | return R.ok(); |
| | | }
|
| | |
|
| | | /**
|