2
0

feat: code gen

This commit is contained in:
caiyuchao
2024-12-19 17:47:13 +08:00
parent 2dcf1afe7f
commit cfbdb84261
2 changed files with 101 additions and 3 deletions

View File

@@ -0,0 +1,87 @@
#set(${serviceName} = "${table.serviceName.substring(1, 2).toLowerCase()}${table.serviceName.substring(2)}")
#set($entityName = "${entity.substring(0, 1).toLowerCase()}${entity.substring(1)}")
package ${package.Controller};
import cn.hutool.core.collection.CollUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.system.domain.SysRateLimit;
import org.wfc.system.service.ISysRateLimitService;
import java.util.List;
#if(${superControllerClassPackage})
import ${superControllerClassPackage};
#end
/**
* <p>
* $!{table.comment} 前端控制器
* </p>
*
* @author ${author}
* @since ${date}
*/
#if(${restControllerStyle})
@RestController
#else
@Controller
#end
@RequestMapping("#if(${package.ModuleName})/${package.ModuleName}#end/#if(${controllerMappingHyphenStyle})${controllerMappingHyphen}#else${table.entityPath}#end")
#if(${kotlin})
class ${table.controllerName}#if(${superControllerClass}) : ${superControllerClass}()#end
#else
#if(${superControllerClass})
public class ${table.controllerName} extends ${superControllerClass} {
#else
public class ${table.controllerName} extends BaseController {
#end
@Autowired
public ${table.serviceName} ${serviceName};
@GetMapping("/page")
public TableDataInfo page(${entity} $entityName) {
startPage();
List<${entity}> list = ${serviceName}.list();
return getDataTable(list);
}
@GetMapping("/list")
public AjaxResult list(${entity} $entityName) {
List<${entity}> list = ${serviceName}.list();
return success(list);
}
@GetMapping(value = "/{id}")
public AjaxResult getById(@PathVariable("id") Long id) {
return success(${serviceName}.getById(id));
}
@PostMapping
public AjaxResult add(@RequestBody ${entity} $entityName) {
return toAjax(${serviceName}.save($entityName));
}
@PutMapping
public AjaxResult edit(@RequestBody ${entity} $entityName) {
return toAjax(${serviceName}.updateById($entityName));
}
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(${serviceName}.removeByIds(CollUtil.newArrayList(ids)));
}
}
#end