|
|
@@ -1,24 +1,24 @@
|
|
|
package ${packageName}.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ktg.common.annotation.Log;
|
|
|
import com.ktg.common.core.controller.BaseController;
|
|
|
-import com.ktg.common.core.domain.AjaxResult;
|
|
|
import com.ktg.common.enums.BusinessType;
|
|
|
+import com.ktg.common.pojo.CommonResult;
|
|
|
+import com.ktg.common.utils.poi.ExcelUtil;
|
|
|
import ${packageName}.domain.${ClassName};
|
|
|
import ${packageName}.service.I${ClassName}Service;
|
|
|
-import com.ktg.common.utils.poi.ExcelUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Parameters;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
#if($table.crud || $table.sub)
|
|
|
import com.ktg.common.core.page.TableDataInfo;
|
|
|
#elseif($table.tree)
|
|
|
@@ -26,10 +26,11 @@ import com.ktg.common.core.page.TableDataInfo;
|
|
|
|
|
|
/**
|
|
|
* ${functionName}Controller
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ${author}
|
|
|
* @date ${datetime}
|
|
|
*/
|
|
|
+@Api("${functionName}")
|
|
|
@RestController
|
|
|
@RequestMapping("/${moduleName}/${businessName}")
|
|
|
public class ${ClassName}Controller extends BaseController
|
|
|
@@ -38,16 +39,21 @@ public class ${ClassName}Controller extends BaseController
|
|
|
private I${ClassName}Service ${className}Service;
|
|
|
|
|
|
/**
|
|
|
- * 查询${functionName}列表
|
|
|
+ * 查询${functionName}分页
|
|
|
*/
|
|
|
+ @ApiOperation("查询${functionName}-分页")
|
|
|
+ @Parameters({
|
|
|
+ @Parameter(name = "page", description = "Page"),
|
|
|
+ @Parameter(name = "sysTeam", description = "实体参数")
|
|
|
+ })
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
|
|
- @GetMapping("/list")
|
|
|
+ @GetMapping("/get${ClassName}Page")
|
|
|
#if($table.crud || $table.sub)
|
|
|
- public TableDataInfo list(${ClassName} ${className})
|
|
|
+ public CommonResult<Page<${ClassName}>> get${ClassName}Page(Page<${ClassName}> page, ${ClassName} ${className})
|
|
|
{
|
|
|
- startPage();
|
|
|
- List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
|
- return getDataTable(list);
|
|
|
+ Page<${ClassName}> result = ${className}Service.page(page, Wrappers.<${ClassName}>lambdaQuery()
|
|
|
+ .orderByDesc(${ClassName}::getId));
|
|
|
+ return CommonResult.success(result);
|
|
|
}
|
|
|
#elseif($table.tree)
|
|
|
public AjaxResult list(${ClassName} ${className})
|
|
|
@@ -60,10 +66,12 @@ public class ${ClassName}Controller extends BaseController
|
|
|
/**
|
|
|
* 导出${functionName}列表
|
|
|
*/
|
|
|
+ @ApiOperation("导出${functionName}列表")
|
|
|
+ @Parameter(name = "${className}", description = "实体参数")
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
|
|
|
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
|
|
- @PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, ${ClassName} ${className})
|
|
|
+ @PostMapping("/export${ClassName}")
|
|
|
+ public void export${ClassName}(HttpServletResponse response, ${ClassName} ${className})
|
|
|
{
|
|
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
|
|
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
|
|
@@ -73,43 +81,48 @@ public class ${ClassName}Controller extends BaseController
|
|
|
/**
|
|
|
* 获取${functionName}详细信息
|
|
|
*/
|
|
|
+ @ApiOperation("获取${functionName}详细信息")
|
|
|
+ @Parameter(name = "${pkColumn.javaField}", description = "${pkColumn.javaField}")
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
|
|
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
|
|
- public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
|
|
+ public CommonResult<${ClassName}> select${ClassName}ById(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
|
|
{
|
|
|
- return AjaxResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
|
|
+ return CommonResult.success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增${functionName}
|
|
|
*/
|
|
|
+ @ApiOperation("新增${functionName}")
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
|
|
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
|
|
- @PostMapping
|
|
|
- public AjaxResult add(@RequestBody ${ClassName} ${className})
|
|
|
+ @PostMapping("/insert${ClassName}")
|
|
|
+ public CommonResult<Boolean> insert${ClassName}(@RequestBody @Parameter(name = "${className}", description = "新增数据类,放到body") ${ClassName} ${className})
|
|
|
{
|
|
|
- return toAjax(${className}Service.insert${ClassName}(${className}));
|
|
|
+ return CommonResult.success(${className}Service.insert${ClassName}(${className}) == 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改${functionName}
|
|
|
*/
|
|
|
+ @ApiOperation("修改${functionName}")
|
|
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
|
|
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
- public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
|
|
+ @PutMapping("/update${ClassName}")
|
|
|
+ public CommonResult<Boolean> update${ClassName}(@RequestBody @Parameter(name = "${className}", description = "修改数据类,放到body") ${ClassName} ${className})
|
|
|
{
|
|
|
- return toAjax(${className}Service.update${ClassName}(${className}));
|
|
|
+ return CommonResult.success(${className}Service.update${ClassName}(${className}) == 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除${functionName}
|
|
|
*/
|
|
|
+ @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)
|
|
|
+ public CommonResult<Boolean> deleteBy${pkColumn.capJavaField}s(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
|
|
{
|
|
|
- return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
|
|
+ return CommonResult.success(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s) == 1);
|
|
|
}
|
|
|
}
|