| | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | |
| | | * @author ${author} |
| | | * @date ${datetime} |
| | | */ |
| | | @Api("${functionName}") |
| | | @Api(description = "${functionName}") |
| | | @RestController |
| | | @RequestMapping("/${moduleName}/${businessName}") |
| | | public class ${ClassName}Controller extends BaseController |
| | | { |
| | | public class ${ClassName}Controller extends BaseController { |
| | | @Autowired |
| | | private I${ClassName}Service ${className}Service; |
| | | |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | @ApiOperation("查询${functionName}列表") |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") |
| | | @GetMapping("/list") |
| | | #if($table.crud || $table.sub) |
| | | public TableDataInfo list(${ClassName} ${className}) |
| | | { |
| | | startPage(); |
| | | List<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | return getDataTable(list); |
| | | ##/** |
| | | ## * 查询${functionName}列表 |
| | | ## */ |
| | | ##@ApiOperation("查询${functionName}列表") |
| | | ##// @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") |
| | | ##@PostMapping("/list") |
| | | ## #if($table.crud || $table.sub) |
| | | ## public TableDataInfo list(@RequestBody ${ClassName} ${className}) { |
| | | ## startPage(); |
| | | ## List<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | ## return getDataTable(list); |
| | | ## } |
| | | ## #elseif($table.tree) |
| | | ## public AjaxResult list(${ClassName} ${className}) { |
| | | ## List<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | ## return AjaxResult.success(list); |
| | | ## } |
| | | ## #end |
| | | |
| | | /** |
| | | * 查询${functionName}列表 |
| | | */ |
| | | @ApiOperation("查询${functionName}列表") |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')") |
| | | @PostMapping("/list") |
| | | #if($table.crud || $table.sub) |
| | | public Map<String, Object> list(@RequestBody ${ClassName} ${className}) { |
| | | Page<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | return getDataTable(list.getRecords(), (int) list.getTotal()); |
| | | } |
| | | #elseif($table.tree) |
| | | public AjaxResult list(${ClassName} ${className}) |
| | | { |
| | | List<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | return AjaxResult.success(list); |
| | | } |
| | | #end |
| | | #elseif($table.tree) |
| | | public AjaxResult list(${ClassName} ${className}) { |
| | | List<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | return AjaxResult.success(list); |
| | | } |
| | | #end |
| | | |
| | | /** |
| | | * 导出${functionName}列表 |
| | |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.EXPORT) |
| | | @GetMapping("/export") |
| | | public AjaxResult export(${ClassName} ${className}) |
| | | { |
| | | List<${ClassName}> list = ${className}Service.queryList(${className}); |
| | | ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class); |
| | | public AjaxResult export(${ClassName} ${className}) { |
| | | List<${ClassName}> list = ${className}Service.exportQueryList(${className}); |
| | | ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class); |
| | | return util.exportExcel(list, "${functionName}数据"); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("获取${functionName}详细信息") |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')") |
| | | @GetMapping(value = "/{${pkColumn.javaField}}") |
| | | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) |
| | | { |
| | | @GetMapping(value = "/getInfo/{${pkColumn.javaField}}") |
| | | public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) { |
| | | return AjaxResult.success(${className}Service.getById(${pkColumn.javaField})); |
| | | } |
| | | |
| | |
| | | @ApiOperation("新增${functionName}") |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | @PostMapping("/add") |
| | | @RepeatSubmit |
| | | public AjaxResult add(@RequestBody ${ClassName} ${className}) |
| | | { |
| | | public AjaxResult add(@RequestBody ${ClassName} ${className}) { |
| | | return toAjax(${className}Service.save(${className})); |
| | | } |
| | | |
| | |
| | | @ApiOperation("修改${functionName}") |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | @PostMapping("/edit") |
| | | @RepeatSubmit |
| | | public AjaxResult edit(@RequestBody ${ClassName} ${className}) |
| | | { |
| | | public AjaxResult edit(@RequestBody ${ClassName} ${className}) { |
| | | return toAjax(${className}Service.updateById(${className})); |
| | | } |
| | | |
| | |
| | | @ApiOperation("删除${functionName}") |
| | | // @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')") |
| | | @Log(title = "${functionName}", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{${pkColumn.javaField}s}") |
| | | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) |
| | | { |
| | | @GetMapping("/remove/{${pkColumn.javaField}s}") |
| | | public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) { |
| | | return toAjax(${className}Service.removeByIds(Arrays.asList(${pkColumn.javaField}s))); |
| | | } |
| | | } |