12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package ${package.Controller};
- import org.springframework.web.bind.annotation.RequestMapping;
- import ${package.Entity}.${entity};
- import ${package.Service}.${table.serviceName};
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.List;
- <#if superControllerClassPackage??>
- import ${superControllerClassPackage};
- </#if>
- /**
- * <p>
- * ${table.comment!} 前端控制器
- * </p>
- *
- * @author ${author}
- * @since ${date}
- */
- <#if restControllerStyle>
- @RestController
- <#else>
- @Controller
- </#if>
- @RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
- <#if kotlin>
- class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
- <#else>
- <#if superControllerClass??>
- public class ${table.controllerName} extends ${superControllerClass} {
- <#else>
- public class ${table.controllerName} {
- </#if>
- @Resource
- private ${table.serviceName} ${table.entityPath}Service;
- @PostMapping
- public Boolean save(@RequestBody ${entity} ${table.entityPath}) {
- return ${table.entityPath}Service.saveOrUpdate(${table.entityPath});
- }
- @DeleteMapping("/{id}")
- public Boolean delete(@PathVariable Integer id) {
- return ${table.entityPath}Service.removeById(id);
- }
- @GetMapping
- public List<${entity}> findAll() {
- return ${table.entityPath}Service.list();
- }
- @GetMapping("/{id}")
- public List<${entity}> findOne(@PathVariable Integer id) {
- return ${table.entityPath}Service.list();
- }
- @GetMapping("/page")
- public Page<${entity}> findPage(@RequestParam Integer pageNum,
- @RequestParam Integer pageSize) {
- return ${table.entityPath}Service.page(new Page<>(pageNum, pageSize));
- }
- }
- </#if>
|