|
|
|
|
@ -7,25 +7,32 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
|
import io.swagger.v3.oas.annotations.Operation; |
|
|
|
|
import io.swagger.v3.oas.annotations.Parameter; |
|
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import jakarta.annotation.Resource; |
|
|
|
|
import jakarta.validation.Valid; |
|
|
|
|
|
|
|
|
|
import lombok.Data; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import lombok.EqualsAndHashCode; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.secure.BladeUser; |
|
|
|
|
import org.springblade.core.secure.annotation.IsAdmin; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springframework.http.ResponseEntity; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import org.springblade.desk.basic.util.ExcelExtUtil; |
|
|
|
|
import ${packageName!}.pojo.entity.${entityKey!}; |
|
|
|
|
import ${packageName!}.pojo.vo.gen.${entityKey!}GenVO; |
|
|
|
|
import ${packageName!}.excel.gen.${entityKey!}GenExcel; |
|
|
|
|
import ${packageName!}.pojo.vo.${entityKey!}VO; |
|
|
|
|
import ${packageName!}.excel.${entityKey!}Excel; |
|
|
|
|
#if(hasWrapper) { |
|
|
|
|
import ${packageName!}.wrapper.gen.${entityKey!}GenWrapper; |
|
|
|
|
import ${packageName!}.wrapper.${entityKey!}Wrapper; |
|
|
|
|
#} |
|
|
|
|
import ${packageName!}.service.gen.${table.serviceName!}; |
|
|
|
|
import ${packageName!}.service.${table.serviceName!}; |
|
|
|
|
#if(isNotEmpty(superControllerClassPackage)){ |
|
|
|
|
import ${superControllerClassPackage!}; |
|
|
|
|
#} |
|
|
|
|
@ -43,12 +50,15 @@ import jakarta.servlet.http.HttpServletResponse; |
|
|
|
|
* @since ${date!} |
|
|
|
|
*/ |
|
|
|
|
@RestController |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
#if(hasServiceName) { |
|
|
|
|
@RequestMapping("${serviceName!}/${entityKeyPath!}") |
|
|
|
|
#}else{ |
|
|
|
|
@RequestMapping("/${entityKey!}") |
|
|
|
|
#} |
|
|
|
|
@Data |
|
|
|
|
@AllArgsConstructor |
|
|
|
|
@EqualsAndHashCode(callSuper = true) |
|
|
|
|
@Slf4j |
|
|
|
|
@Tag(name = "${table.comment!}", description = "${table.comment!}接口") |
|
|
|
|
#if(isNotEmpty(superControllerClass)){ |
|
|
|
|
public class ${table.controllerName!} extends ${superControllerClass!} { |
|
|
|
|
@ -57,29 +67,35 @@ public class ${table.controllerName!} extends ${superControllerClass!} { |
|
|
|
|
public class ${table.controllerName!} { |
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
private final ${table.serviceName!} ${entityKeyPath!}GenService; |
|
|
|
|
@Resource |
|
|
|
|
private ${table.serviceName!} service; |
|
|
|
|
|
|
|
|
|
#if(hasWrapper){ |
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 详情 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/detail") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
@Operation(summary = "详情", description = "传入${entityKey!}") |
|
|
|
|
public R<${entityKey!}GenVO> detail(${entityKey!} ${entityKeyPath!}) { |
|
|
|
|
${entityKey!} detail = ${entityKeyPath!}GenService.getOne(Condition.getQueryWrapper(${entityKeyPath!})); |
|
|
|
|
return R.data(${entityKey!}GenWrapper.build().entityVO(detail)); |
|
|
|
|
@ApiOperationSupport(order = 10) |
|
|
|
|
@Operation(summary = "详情", description = "传入${entityKey!} Obj") |
|
|
|
|
public R<${entityKey!}VO> detail(${entityKey!} ${entityKeyPath!}) { |
|
|
|
|
QueryWrapper<${entityKey!}> qw = Condition.getQueryWrapper(${entityKeyPath!}); |
|
|
|
|
${entityKey!} detail = service.getOne(qw); |
|
|
|
|
${entityKey!}VO detailVO = ${entityKey!}Wrapper.build().entityVO(detail); |
|
|
|
|
return R.data(detailVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 分页 |
|
|
|
|
* ${table.comment!} list分页 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/list") |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
@Operation(summary = "分页", description = "传入${entityKey!}") |
|
|
|
|
public R<IPage<${entityKey!}GenVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, Query query) { |
|
|
|
|
IPage<${entityKey!}> pages = ${entityKeyPath!}GenService.page(Condition.getPage(query), Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}.class)); |
|
|
|
|
return R.data(${entityKey!}GenWrapper.build().pageVO(pages)); |
|
|
|
|
@ApiOperationSupport(order = 20) |
|
|
|
|
@Operation(summary = "list分页", description = "传入${entityKey!} Obj") |
|
|
|
|
public R<IPage<${entityKey!}VO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, |
|
|
|
|
Query query) { |
|
|
|
|
QueryWrapper<${entityKey!}> qw = Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}.class); |
|
|
|
|
IPage<${entityKey!}> pages = service.page(Condition.getPage(query), qw); |
|
|
|
|
IPage<${entityKey!}VO> pagesVO = ${entityKey!}Wrapper.build().pageVO(pages); |
|
|
|
|
return R.data(pagesVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#}else{ |
|
|
|
|
@ -87,103 +103,184 @@ public class ${table.controllerName!} { |
|
|
|
|
* ${table.comment!} 详情 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/detail") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
@Operation(summary = "详情", description = "传入${entityKey!}") |
|
|
|
|
@ApiOperationSupport(order = 10) |
|
|
|
|
@Operation(summary = "详情", description = "传入${entityKey!} Obj") |
|
|
|
|
public R<${entityKey!}> detail(${entityKey!} ${entityKeyPath!}) { |
|
|
|
|
${entityKey!} detail = ${entityKeyPath!}GenService.getOne(Condition.getQueryWrapper(${entityKeyPath!})); |
|
|
|
|
QueryWrapper<${entityKey!}> qw = Condition.getQueryWrapper(${entityKeyPath!}) |
|
|
|
|
${entityKey!} detail = service.getOne(qw); |
|
|
|
|
return R.data(detail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 分页 |
|
|
|
|
* ${table.comment!} list分页 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/list") |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
@Operation(summary = "分页", description = "传入${entityKey!}") |
|
|
|
|
public R<IPage<${entityKey!}Entity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, Query query) { |
|
|
|
|
IPage<${entityKey!}Entity> pages = ${entityKeyPath!}GenService.page(Condition.getPage(query), Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}Entity.class)); |
|
|
|
|
@ApiOperationSupport(order = 20) |
|
|
|
|
@Operation(summary = "list分页", description = "传入${entityKey!} Obj") |
|
|
|
|
public R<IPage<${entityKey!}Entity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, |
|
|
|
|
Query query) { |
|
|
|
|
QueryWrapper<${entityKey!}> qw = Condition.getQueryWrapper(${entityKey!}, ${entityKey!}.class); |
|
|
|
|
IPage<${entityKey!}> pages = service.page(Condition.getPage(query), qw); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 自定义分页 |
|
|
|
|
* ${table.comment!} page分页 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/page") |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@Operation(summary = "分页", description = "传入${entityKey!}") |
|
|
|
|
public R<IPage<${entityKey!}GenVO>> page(${entityKey!}GenVO ${entityKeyPath!}, Query query) { |
|
|
|
|
IPage<${entityKey!}GenVO> pages = ${entityKeyPath!}GenService.select${entityKey!}Page(Condition.getPage(query), ${entityKeyPath!}); |
|
|
|
|
return R.data(pages); |
|
|
|
|
@ApiOperationSupport(order = 21) |
|
|
|
|
@Operation(summary = "page分页", description = "传入${entityKey!} Obj") |
|
|
|
|
public R<IPage<${entityKey!}VO>> page(${entityKey!}VO ${entityKeyPath!}, Query query) { |
|
|
|
|
IPage<${entityKey!}VO> pagesVO = service.select${entityKey!}Page( |
|
|
|
|
Condition.getPage(query), ${entityKeyPath!} |
|
|
|
|
); |
|
|
|
|
return R.data(pagesVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 新增 |
|
|
|
|
* ${table.comment!} list下拉选择 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/listForSelect") |
|
|
|
|
@ApiOperationSupport(order = 22) |
|
|
|
|
@Operation(summary = "list下拉选择", description = "") |
|
|
|
|
public R<List<${entityKey!}VO>> listForSelect() { |
|
|
|
|
List<${entityKey!}> list = service.list(); |
|
|
|
|
List<${entityKey!}VO> listVO = ${entityKey!}Wrapper.build().listVO(list); |
|
|
|
|
return R.data(listVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 新增一条 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
@Operation(summary = "新增", description = "传入${entityKey!}") |
|
|
|
|
public R save(@Valid @RequestBody ${entityKey!} ${entityKeyPath!}) { |
|
|
|
|
return R.status(${entityKeyPath!}GenService.save(${entityKeyPath!})); |
|
|
|
|
@ApiOperationSupport(order = 30) |
|
|
|
|
@Operation(summary = "新增一条", description = "传入${entityKey!} Obj") |
|
|
|
|
public R save(@Valid @RequestBody ${entityKey!} addOne) { |
|
|
|
|
addOne.setId(null); |
|
|
|
|
return R.status(service.save(addOne)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 修改 |
|
|
|
|
* ${table.comment!} 新增批量 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/saveBat") |
|
|
|
|
@ApiOperationSupport(order = 31) |
|
|
|
|
@Operation(summary = "新增批量", description = "传入${entityKey!} List") |
|
|
|
|
public R saveBat(@Valid @RequestBody List<${entityKey!}> addList) { |
|
|
|
|
addList.forEach(one -> { |
|
|
|
|
one.setId(null); |
|
|
|
|
}); |
|
|
|
|
return R.status(service.saveBatch(addList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 修改一条 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/update") |
|
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
|
@Operation(summary = "修改", description = "传入${entityKey!}") |
|
|
|
|
public R update(@Valid @RequestBody ${entityKey!} ${entityKeyPath!}) { |
|
|
|
|
return R.status(${entityKeyPath!}GenService.updateById(${entityKeyPath!})); |
|
|
|
|
@ApiOperationSupport(order = 40) |
|
|
|
|
@Operation(summary = "修改一条", description = "传入${entityKey!} Obj") |
|
|
|
|
public R update(@Valid @RequestBody ${entityKey!} updateOne) { |
|
|
|
|
return R.status(service.updateById(updateOne)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* [工作中心] 修改批量 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/updateBat") |
|
|
|
|
@ApiOperationSupport(order = 41) |
|
|
|
|
@Operation(summary = "修改批量", description = "传入${entityKey!} List") |
|
|
|
|
public R updateBat(@Valid @RequestBody List<${entityKey!}> updateList) { |
|
|
|
|
return R.status(service.updateBatchById(updateList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 新增或修改 |
|
|
|
|
* ${table.comment!} 新增或修改一条 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/submit") |
|
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
|
@Operation(summary = "新增或修改", description = "传入${entityKey!}") |
|
|
|
|
public R submit(@Valid @RequestBody ${entityKey!} ${entityKeyPath!}) { |
|
|
|
|
return R.status(${entityKeyPath!}GenService.saveOrUpdate(${entityKeyPath!})); |
|
|
|
|
@ApiOperationSupport(order = 50) |
|
|
|
|
@Operation(summary = "新增或修改一条", description = "传入${entityKey!} Obj") |
|
|
|
|
public R submit(@Valid @RequestBody ${entityKey!} mergeOne) { |
|
|
|
|
return R.status(service.saveOrUpdate(mergeOne)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 新增或修改批量 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/submitBat") |
|
|
|
|
@ApiOperationSupport(order = 51) |
|
|
|
|
@Operation(summary = "新增或修改批量", description = "传入${entityKey!} List") |
|
|
|
|
public R submitBat(@Valid @RequestBody List<${entityKey!}> mergeList) { |
|
|
|
|
return R.status(service.saveOrUpdateBatch(mergeList)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if(hasSuperEntity){ |
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 删除 |
|
|
|
|
* ${table.comment!} 逻辑删除 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/remove") |
|
|
|
|
@ApiOperationSupport(order = 7) |
|
|
|
|
@ApiOperationSupport(order = 61) |
|
|
|
|
@Operation(summary = "逻辑删除", description = "传入ids") |
|
|
|
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
return R.status(${entityKeyPath!}GenService.deleteLogic(Func.toLongList(ids))); |
|
|
|
|
return R.status(service.deleteLogic(Func.toLongList(ids))); |
|
|
|
|
} |
|
|
|
|
#}else{ |
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 删除 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/remove") |
|
|
|
|
@ApiOperationSupport(order = 7) |
|
|
|
|
@ApiOperationSupport(order = 61) |
|
|
|
|
@Operation(summary = "删除", description = "传入ids") |
|
|
|
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
return R.status(${entityKeyPath!}Service.removeByIds(Func.toLongList(ids))); |
|
|
|
|
return R.status(service.removeByIds(Func.toLongList(ids))); |
|
|
|
|
} |
|
|
|
|
#} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出数据 |
|
|
|
|
* ${table.comment!} 导出Excel |
|
|
|
|
*/ |
|
|
|
|
@IsAdmin |
|
|
|
|
@GetMapping("/export-excel") |
|
|
|
|
@ApiOperationSupport(order = 8) |
|
|
|
|
@Operation(summary = "导出数据", description = "传入${entityKey!}") |
|
|
|
|
public void export${entityKey!}(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
QueryWrapper<${entityKey!}> queryWrapper = Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}.class); |
|
|
|
|
@GetMapping("/exportExcel") |
|
|
|
|
@ApiOperationSupport(order = 70) |
|
|
|
|
@Operation(summary = "导出Excel", description = "传入${entityKey!}") |
|
|
|
|
public void exportExcel(@Parameter(hidden = true) @RequestParam Map<String, Object> ${entityKeyPath!}, |
|
|
|
|
BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
QueryWrapper<${entityKey!}> qw = Condition.getQueryWrapper(${entityKeyPath!}, ${entityKey!}.class); |
|
|
|
|
//if (!AuthUtil.isAdministrator()) { |
|
|
|
|
// queryWrapper.lambda().eq(${entity!}::getTenantId, bladeUser.getTenantId()); |
|
|
|
|
//} |
|
|
|
|
//queryWrapper.lambda().eq(${entityKey!}Entity::getIsDeleted, BladeConstant.DB_NOT_DELETED); |
|
|
|
|
List<${entityKey!}GenExcel> list = ${entityKeyPath!}GenService.export${entityKey!}(queryWrapper); |
|
|
|
|
ExcelUtil.export(response, "${table.comment!}数据" + DateUtil.time(), "${table.comment!}数据表", list, ${entityKey!}GenExcel.class); |
|
|
|
|
List<${entityKey!}Excel> list = service.export${entityKey!}(qw); |
|
|
|
|
ExcelUtil.export(response, "${table.comment!}数据" + DateUtil.time(), |
|
|
|
|
"${table.comment!}数据表", list, ${entityKey!}Excel.class); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 下载Excel模板 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/downloadExcelTemplate") |
|
|
|
|
@ApiOperationSupport(order = 71) |
|
|
|
|
@Operation(summary = "下载Excel模板", description = "") |
|
|
|
|
public ResponseEntity<org.springframework.core.io.Resource> downloadExcelTemplate() { |
|
|
|
|
return ExcelExtUtil.downloadXlsTemplate( |
|
|
|
|
"Excel/QA/ImportTemplate-CycleTestItem.xls", |
|
|
|
|
"导入模版-周期试验项目.xls"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* ${table.comment!} 导入Excel |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/importExcel") |
|
|
|
|
@ApiOperationSupport(order = 72) |
|
|
|
|
@Operation(summary = "导入Excel", description = "MultipartFile") |
|
|
|
|
public R importExcel(@RequestParam("file") MultipartFile file) { |
|
|
|
|
R checkR = ExcelExtUtil.importExcelCheck(file); |
|
|
|
|
if (checkR != null) { |
|
|
|
|
return checkR; |
|
|
|
|
} |
|
|
|
|
List<${entityKey!}> importList = ExcelUtil.read( |
|
|
|
|
file, 0, 1, ${entityKey!}.class |
|
|
|
|
); |
|
|
|
|
return R.status(service.saveBatch(importList)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|