Java高级架构师(一)第18节:X-gen所需service、web层模板
2024-09-03 19:35:56
以X-gen的Controller为例:
package $#modulePackge#.web; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import $#modulePackge#.service.I$#moduleNameSuperCase#Service;
import $#modulePackge#.vo.$#moduleNameSuperCase#Model;
import $#modulePackge#.vo.$#moduleNameSuperCase#QueryModel;
import com.sishuok.pageutil.Page;
import com.sishuok.util.format.DateFormatHelper;
import com.sishuok.util.json.JsonHelper; @Controller
@RequestMapping(value="/$#moduleName#")
public class $#moduleNameSuperCase#Controller {
@Autowired
private I$#moduleNameSuperCase#Service iservice = null; @RequestMapping(value="toAdd",method=RequestMethod.GET)
public String toAdd(){ return "$#moduleName#/add";
}
@RequestMapping(value="add",method=RequestMethod.POST)
public String add(@ModelAttribute("m") $#moduleNameSuperCase#Model m){
iservice.create(m);
return "$#moduleName#/success";
}
@RequestMapping(value="toUpdate/{uuid}",method=RequestMethod.GET)
public String toUpdate(Model model,@PathVariable("uuid") int uuid){
$#moduleNameSuperCase#Model m = iservice.getByUuid(uuid);
model.addAttribute("m", m);
return "$#moduleName#/update";
}
@RequestMapping(value="update",method=RequestMethod.POST)
public String post(@ModelAttribute("m") $#moduleNameSuperCase#Model m){
iservice.update(m);
return "$#moduleName#/success";
}
@RequestMapping(value="toDelete/{uuid}",method=RequestMethod.GET)
public String toDelete(Model model,@PathVariable("uuid") int uuid){
$#moduleNameSuperCase#Model m = iservice.getByUuid(uuid);
model.addAttribute("m", m);
return "$#moduleName#/delete";
}
@RequestMapping(value="delete",method=RequestMethod.POST)
public String post(@RequestParam("uuid") int uuid){
iservice.delete(uuid);
return "$#moduleName#/success";
}
@RequestMapping(value="toList",method=RequestMethod.GET)
public String toList(@ModelAttribute("wm")$#moduleNameSuperCase#WebModel wm,Model model){
$#moduleNameSuperCase#QueryModel qm = null;
if(wm.getQueryJsonStr()==null || wm.getQueryJsonStr().trim().length()==0){
qm = new $#moduleNameSuperCase#QueryModel();
}else{
String s = wm.getQueryJsonStr();
s = s.replace("-", "%");
qm = ($#moduleNameSuperCase#QueryModel)JsonHelper.str2Object(s, $#moduleNameSuperCase#QueryModel.class);
} qm.getPage().setNowPage(wm.getNowPage());
if(wm.getPageShow() > 0){
qm.getPage().setPageShow(wm.getPageShow());
} Page dbPage = iservice.getByConditionPage(qm); //
model.addAttribute("wm", wm);
model.addAttribute("page", dbPage); return "$#moduleName#/list";
}
@RequestMapping(value="toQuery",method=RequestMethod.GET)
public String toQuery(){
return "$#moduleName#/query";
}
}
最新文章
- Java进击C#——项目开发环境
- Mysql的一些常用方法
- AX函数,将EXCEL列号转为列名
- VM 启动时报错:Failed to lock the file
- poj2926 曼哈顿最远距离
- Oracle merge into 使用记录
- Java中循环删除list中元素的方法总结
- DELPHI编写服务程序总结
- ORACLE+PYTHON实战:复制A表数据到B表
- springboot情操陶冶-web配置(三)
- 在Mac 系统上使用MAMP搭建PHP开发环境
- Keepalived+LVS实现高可用负载均衡双主模式
- FZU - 1989 AntiAC
- WCF系列(六) - WCF安全系列(一) - basicHttpBinding
- 类中函数前、后、参数加const
- 图像_pytesseract
- RNA Sequencing
- float浮点数的四舍五入
- WPF样式——经典博客
- 【转】Base64算法详解
热门文章
- bzoj 1201[HNOI2005]数三角形 1202 [HNOI2005]狡猾的商人 暴力 权值并查集
- transition(动画属性)
- [04] css 选择器
- MVC 自定义HtmlHelper帮助类型之分页
- 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined
- bzoj4602 [Sdoi2016]齿轮
- 【洛谷 P2515】 [HAOI2010]软件安装 (缩点+树形背包)
- 【洛谷 P1653】 猴子 (并查集)
- 干货:MySQL数据库优化参考
- 教你从头到尾利用DQN自动玩flappy bird(全程命令提示,GPU+CPU版)【转】