plus.controller.btl Maven / Gradle / Ivy
The newest version!
package ${package.Controller};
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import ${package.Entity}.${table.entityName};
import ${package.ServiceImpl}.${table.entityName}ServiceImpl;
import com.github.jackpanz.spring.util.ResultMap;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
/**
*
* ${table.comment!} 前端控制器
*
*
* @author ${author}
* @since ${date}
*/
@Controller
@RequestMapping("${cfg.pagePath}/${cfg.entityName}")
public class ${table.controllerName} {
@Autowired
private ${table.entityName}ServiceImpl ${cfg.entityName}Service;
@RequestMapping(value = "list")
public String list()
{
return "${cfg.pagePath}/${cfg.entityName}/list";
}
@RequestMapping(value = "edit")
public String edit()
{
return "${cfg.pagePath}/${cfg.entityName}/edit";
}
@ResponseBody
@RequestMapping(value = "page",method = {RequestMethod.GET,RequestMethod.POST})
public Map page(@RequestParam(required = false,defaultValue = "1") Integer page
,@RequestParam(required = false,defaultValue = "10") Integer length){
ResultMap result = new ResultMap(true);
IPage pagination = new Page(page, length);
pagination = ${cfg.entityName}Service.page(pagination);
result.setPageResult(pagination);
return result;
}
@ResponseBody
@RequestMapping(value = "get",method = {RequestMethod.GET,RequestMethod.POST})
public Map get(Integer id){
ResultMap result = new ResultMap();
result.put("data",${cfg.entityName}Service.getById(id));
return result.setSuccess();
}
@ResponseBody
@RequestMapping(value = "save",method = {RequestMethod.POST})
public Map save(${table.entityName} ${cfg.entityName}) {
ResultMap result = new ResultMap();
boolean flag = false;
if( ${cfg.entityName}.getId() != null ){
flag = ${cfg.entityName}Service.updateById(${cfg.entityName});
} else{
flag = ${cfg.entityName}Service.save(${cfg.entityName});
}
return result.setAction(flag);
}
@ResponseBody
@RequestMapping(value = "delete",method = {RequestMethod.GET,RequestMethod.POST})
public Map del(Integer id) {
ResultMap result = new ResultMap();
if(id != null){
result.setAction(${cfg.entityName}Service.removeById(id));
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy