vm10.java.controller.vm Maven / Gradle / Ivy
package ${packageName}.controller;
#foreach ($item in $importList)
${item}
#end
@RestController
@RequestMapping("/${configEntity.moduleName}/${businessName}")
public class ${ClassName}Controller
{
@Autowired
private I${ClassName}Service ${t.sc($ClassName)}Service;
@GetMapping("/page")
public AjaxResult page(PageEntity pageEntity,${ClassName} ${t.sc($ClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.page(pageEntity.toPage(), Wrappers.lambdaQuery(${t.sc($ClassName)})));
}
@GetMapping("/list")
public AjaxResult list(${ClassName} ${t.sc($ClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.list(Wrappers.lambdaQuery(${t.sc($ClassName)})));
}
#if($!pkColumn.fieldName)
@PostMapping("/add")
public AjaxResult add(@RequestBody ${ClassName} ${t.sc($ClassName)}) {
return AjaxResult.success(${t.sc($ClassName)}Service.save(${t.sc($ClassName)}));
}
@PutMapping("/edit")
public AjaxResult edit(@RequestBody ${ClassName} ${t.sc($ClassName)}) {
return AjaxResult.success(${t.sc($ClassName)}Service.updateById(${t.sc($ClassName)}));
}
@DeleteMapping("/delete/{${pkColumn.fieldName}s}")
public AjaxResult delete(@PathVariable ${pkColumn.fieldType}[] ${pkColumn.fieldName}s) {
return AjaxResult.success(${t.sc($ClassName)}Service.removeByIds(Arrays.asList(${pkColumn.fieldName}s)));
}
@GetMapping(value = "/detail/{${pkColumn.fieldName}}")
public AjaxResult detail(@PathVariable("${pkColumn.fieldName}") ${pkColumn.fieldType} ${pkColumn.fieldName}) {
return AjaxResult.success(${t.sc($ClassName)}Service.getById(${pkColumn.fieldName}));
}
#if($joinQuery&&$flagCode == 11)
@GetMapping("/vo/page")
public AjaxResult pageVo(PageEntity pageEntity,${ClassName} ${t.sc($ClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.pageVo(pageEntity.toPage(), ${t.sc($ClassName)}));
}
#end
#if($joinQuery&&$flagCode == 12)
@GetMapping("/vo/page")
public AjaxResult pageVo(PageEntity pageEntity,${ClassName} ${t.sc($ClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.pageVo(pageEntity.toPage(), ${t.sc($ClassName)}));
}
#end
#if($joinQuery&&$flagCode == 22 && $LKeyColumn && $RKeyColumn)
@GetMapping("/${t.sc($LKeyColumn.referencedClassName)}/page")
public AjaxResult pageVo(PageEntity pageEntity,${LKeyColumn.referencedClassName} ${t.sc($LKeyColumn.referencedClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.pageVo(pageEntity.toPage(), ${t.sc($LKeyColumn.referencedClassName)}));
}
@GetMapping("/${t.sc($RKeyColumn.referencedClassName)}/page")
public AjaxResult pageVo(PageEntity pageEntity,${RKeyColumn.referencedClassName} ${t.sc($RKeyColumn.referencedClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.pageVo(pageEntity.toPage(), ${t.sc($RKeyColumn.referencedClassName)}));
}
#end
#if($joinQuery&&$flagCode == 11)
@GetMapping("/vo/list")
public AjaxResult listVo(${ClassName} ${t.sc($ClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.listVo(${t.sc($ClassName)}));
}
#end
#if($joinQuery&&$flagCode == 12)
@GetMapping("/vo/list")
public AjaxResult listVo(${ClassName} ${t.sc($ClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.listVo(${t.sc($ClassName)}));
}
#end
#if($joinQuery&&$flagCode == 22 && $LKeyColumn && $RKeyColumn)
@GetMapping("/${t.sc($LKeyColumn.referencedClassName)}/list")
public AjaxResult listVo(${LKeyColumn.referencedClassName} ${t.sc($LKeyColumn.referencedClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.listVo(${t.sc($LKeyColumn.referencedClassName)}));
}
@GetMapping("/${t.sc($RKeyColumn.referencedClassName)}/list")
public AjaxResult listVo(${RKeyColumn.referencedClassName} ${t.sc($RKeyColumn.referencedClassName)}){
return AjaxResult.success(${t.sc($ClassName)}Service.listVo(${t.sc($RKeyColumn.referencedClassName)}));
}
#end
#if($joinQuery&&$flagCode == 11)
@GetMapping(value = "/vo/detail/{${pkColumn.fieldName}}")
public AjaxResult detailVo(@PathVariable("${pkColumn.fieldName}") ${pkColumn.fieldType} ${pkColumn.fieldName}) {
return AjaxResult.success(${t.sc($ClassName)}Service.getOneVo(${pkColumn.fieldName}));
}
#end
#if($joinQuery&&$flagCode == 12)
@GetMapping(value = "/vo/detail/{${pkColumn.fieldName}}")
public AjaxResult detailVo(@PathVariable("${pkColumn.fieldName}") ${pkColumn.fieldType} ${pkColumn.fieldName}) {
return AjaxResult.success(${t.sc($ClassName)}Service.getOneVo(${pkColumn.fieldName}));
}
#end
#if($joinQuery&&$flagCode == 22 && $LKeyColumn && $RKeyColumn)
@GetMapping(value = "/${t.sc($LKeyColumn.referencedClassName)}/detail/{${LKeyColumn.referencedFieldName}}")
public AjaxResult detail${LKeyColumn.referencedClassName}Vo(@PathVariable("${LKeyColumn.referencedFieldName}") ${LKeyColumn.referencedFieldType} ${LKeyColumn.referencedFieldName}) {
return AjaxResult.success(${t.sc($ClassName)}Service.get${LKeyColumn.referencedClassName}Vo(${LKeyColumn.referencedFieldName}));
}
@GetMapping(value = "/${t.sc($RKeyColumn.referencedClassName)}/detail/{${RKeyColumn.referencedFieldName}}")
public AjaxResult detail${RKeyColumn.referencedClassName}Vo(@PathVariable("${RKeyColumn.referencedFieldName}") ${RKeyColumn.referencedFieldType} ${RKeyColumn.referencedFieldName}) {
return AjaxResult.success(${t.sc($ClassName)}Service.get${RKeyColumn.referencedClassName}Vo(${RKeyColumn.referencedFieldName}));
}
#end
#end
}