59 lines
2.1 KiB
Java
59 lines
2.1 KiB
Java
package com.youlai.system.controller;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.youlai.system.common.result.PageResult;
|
|
import com.youlai.system.common.result.Result;
|
|
import com.youlai.system.model.form.GenConfigForm;
|
|
import com.youlai.system.model.query.TablePageQuery;
|
|
import com.youlai.system.model.vo.GeneratorPreviewVO;
|
|
import com.youlai.system.model.vo.TablePageVO;
|
|
import com.youlai.system.service.GeneratorService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
@Tag(name = "09.代码生成")
|
|
@RestController
|
|
@RequestMapping("/api/v1/generator")
|
|
@RequiredArgsConstructor
|
|
public class GeneratorController {
|
|
|
|
private final GeneratorService generatorService;
|
|
|
|
@Operation(summary = "获取数据表分页列表")
|
|
@GetMapping("/table/page")
|
|
public PageResult<TablePageVO> getTablePage(
|
|
TablePageQuery queryParams
|
|
) {
|
|
Page<TablePageVO> result = generatorService.getTablePage(queryParams);
|
|
return PageResult.success(result);
|
|
}
|
|
|
|
@Operation(summary = "获取代码生成配置")
|
|
@GetMapping("/{tableName}/config")
|
|
public Result<GenConfigForm> getGenConfig(
|
|
@Parameter(description = "表名", example = "sys_user") @PathVariable String tableName) {
|
|
GenConfigForm formData = generatorService.getGenConfig(tableName);
|
|
return Result.success(formData);
|
|
}
|
|
|
|
@Operation(summary = "保存代码生成配置")
|
|
@PostMapping("/{tableName}/config")
|
|
public Result saveGenConfig(@RequestBody GenConfigForm formData) {
|
|
generatorService.saveGenConfig(formData);
|
|
return Result.success();
|
|
}
|
|
|
|
@Operation(summary = "获取预览生成代码")
|
|
@GetMapping("/{tableName}/preview")
|
|
public Result<List<GeneratorPreviewVO>> getTablePreviewData(@PathVariable String tableName) {
|
|
List<GeneratorPreviewVO> list = generatorService.getTablePreviewData(tableName);
|
|
return Result.success(list);
|
|
}
|
|
|
|
}
|