2021-03-06 20:06:43 +08:00
|
|
|
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName};
|
2021-02-09 12:51:01 +08:00
|
|
|
|
2021-02-05 01:31:53 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2021-02-09 12:51:01 +08:00
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2021-02-12 12:58:41 +08:00
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
2021-02-09 12:51:01 +08:00
|
|
|
|
2021-02-05 01:31:53 +08:00
|
|
|
import io.swagger.annotations.*;
|
2021-02-09 12:51:01 +08:00
|
|
|
|
2021-02-05 01:31:53 +08:00
|
|
|
import javax.validation.constraints.*;
|
|
|
|
import javax.validation.*;
|
2021-02-11 23:02:53 +08:00
|
|
|
import javax.servlet.http.*;
|
2021-02-05 01:31:53 +08:00
|
|
|
import java.util.*;
|
2021-02-11 23:02:53 +08:00
|
|
|
import java.io.IOException;
|
2021-02-05 01:31:53 +08:00
|
|
|
|
2021-02-09 12:51:01 +08:00
|
|
|
import ${PageResultClassName};
|
|
|
|
import ${CommonResultClassName};
|
|
|
|
import static ${CommonResultClassName}.success;
|
|
|
|
|
2021-02-11 23:02:53 +08:00
|
|
|
import ${ExcelUtilsClassName};
|
|
|
|
|
2021-02-12 12:58:41 +08:00
|
|
|
import ${OperateLogClassName};
|
|
|
|
import static ${OperateTypeEnumClassName}.*;
|
|
|
|
|
2021-03-06 20:06:43 +08:00
|
|
|
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*;
|
|
|
|
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
|
|
|
|
import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
|
|
|
|
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service;
|
2021-02-05 01:31:53 +08:00
|
|
|
|
2021-02-09 12:51:01 +08:00
|
|
|
@Api(tags = "${table.classComment}")
|
2021-02-05 01:31:53 +08:00
|
|
|
@RestController
|
2021-02-09 12:51:01 +08:00
|
|
|
##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写
|
|
|
|
@RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}")
|
2021-02-05 01:31:53 +08:00
|
|
|
@Validated
|
2021-02-09 12:51:01 +08:00
|
|
|
public class ${table.className}Controller {
|
2021-02-05 01:31:53 +08:00
|
|
|
|
2021-02-09 12:51:01 +08:00
|
|
|
@Resource
|
|
|
|
private ${table.className}Service ${classNameVar}Service;
|
2021-02-05 01:31:53 +08:00
|
|
|
|
|
|
|
@PostMapping("/create")
|
2021-02-12 12:58:41 +08:00
|
|
|
@ApiOperation("创建${table.classComment}")
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")
|
|
|
|
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${table.className}CreateReqVO createReqVO) {
|
2021-02-09 12:51:01 +08:00
|
|
|
return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
|
2021-02-05 01:31:53 +08:00
|
|
|
}
|
|
|
|
|
2021-02-09 12:51:01 +08:00
|
|
|
@PutMapping("/update")
|
2021-02-12 12:58:41 +08:00
|
|
|
@ApiOperation("更新${table.classComment}")
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")
|
|
|
|
public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${table.className}UpdateReqVO updateReqVO) {
|
2021-02-09 12:51:01 +08:00
|
|
|
${classNameVar}Service.update${simpleClassName}(updateReqVO);
|
2021-02-05 01:31:53 +08:00
|
|
|
return success(true);
|
|
|
|
}
|
|
|
|
|
2021-02-27 01:29:18 +08:00
|
|
|
@DeleteMapping("/delete")
|
2021-02-10 17:45:04 +08:00
|
|
|
@ApiOperation("删除${table.classComment}")
|
2021-02-09 12:51:01 +08:00
|
|
|
@ApiImplicitParam(name = "id", value = "编号", required = true)
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")
|
2021-02-09 12:51:01 +08:00
|
|
|
public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
|
|
|
${classNameVar}Service.delete${simpleClassName}(id);
|
2021-02-05 01:31:53 +08:00
|
|
|
return success(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/get")
|
2021-02-09 12:51:01 +08:00
|
|
|
@ApiOperation("获得${table.classComment}")
|
2021-02-14 23:01:21 +08:00
|
|
|
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = ${primaryColumn.javaType}.class)
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
2021-02-09 12:51:01 +08:00
|
|
|
public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
|
|
|
|
${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
|
|
|
|
return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
|
2021-02-05 01:31:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/list")
|
2021-02-09 12:51:01 +08:00
|
|
|
@ApiOperation("获得${table.classComment}列表")
|
2021-02-14 23:01:21 +08:00
|
|
|
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
2021-02-09 12:51:01 +08:00
|
|
|
public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
|
|
|
|
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);
|
|
|
|
return success(${table.className}Convert.INSTANCE.convertList(list));
|
2021-02-05 01:31:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/page")
|
2021-02-12 12:58:41 +08:00
|
|
|
@ApiOperation("获得${table.classComment}分页")
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")
|
2021-02-09 12:51:01 +08:00
|
|
|
public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) {
|
|
|
|
PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);
|
|
|
|
return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
|
2021-02-05 01:31:53 +08:00
|
|
|
}
|
|
|
|
|
2021-02-11 23:02:53 +08:00
|
|
|
@GetMapping("/export-excel")
|
|
|
|
@ApiOperation("导出${table.classComment} Excel")
|
2021-02-12 21:01:45 +08:00
|
|
|
@PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")
|
2021-02-12 12:58:41 +08:00
|
|
|
@OperateLog(type = EXPORT)
|
2021-02-11 23:02:53 +08:00
|
|
|
public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
|
|
|
|
HttpServletResponse response) throws IOException {
|
|
|
|
List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO);
|
|
|
|
// 导出 Excel
|
|
|
|
List<${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list);
|
|
|
|
ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}ExcelVO.class, datas);
|
|
|
|
}
|
2021-02-11 19:49:14 +08:00
|
|
|
|
2021-02-05 01:31:53 +08:00
|
|
|
}
|