package #{action_p};
import static com.jeecms.common.page.SimplePage.cpn;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.jeecms.common.page.Pagination;
import com.jeecms.common.web.CookieUtils;
import com.jeecms.core.entity.Website;
import com.jeecms.core.web.SiteUtils;
import com.jeecms.core.web.WebErrors;
import #{entity_p}.#{Entity};
import #{manager_p}.#{Entity}Mng;
@Controller
public class #{Entity}Act {
private static final Logger log = LoggerFactory.getLogger(#{Entity}Act.class);
@RequestMapping("/#{config_entity}/v_list.do")
public String list(Integer pageNo, HttpServletRequest request, ModelMap model) {
Pagination pagination = manager.getPage(cpn(pageNo), CookieUtils
.getPageSize(request));
model.addAttribute("pagination",pagination);
return "#{config_entity}/list";
}
@RequestMapping("/#{config_entity}/v_add.do")
public String add(ModelMap model) {
return "#{config_entity}/add";
}
@RequestMapping("/#{config_entity}/v_edit.do")
public String edit(Integer id, HttpServletRequest request, ModelMap model) {
WebErrors errors = validateEdit(id, request);
if (errors.hasErrors()) {
return errors.showErrorPage(model);
}
model.addAttribute("#{entity}", manager.findById(id));
return "#{config_entity}/edit";
}
@RequestMapping("/#{config_entity}/o_save.do")
public String save(#{Entity} bean, HttpServletRequest request, ModelMap model) {
WebErrors errors = validateSave(bean, request);
if (errors.hasErrors()) {
return errors.showErrorPage(model);
}
bean = manager.save(bean);
log.info("save #{Entity} id={}", bean.getId());
return "redirect:v_list.do";
}
@RequestMapping("/#{config_entity}/o_update.do")
public String update(#{Entity} bean, Integer pageNo, HttpServletRequest request,
ModelMap model) {
WebErrors errors = validateUpdate(bean.getId(), request);
if (errors.hasErrors()) {
return errors.showErrorPage(model);
}
bean = manager.update(bean);
log.info("update #{Entity} id={}.", bean.getId());
return list(pageNo, request, model);
}
@RequestMapping("/#{config_entity}/o_delete.do")
public String delete(Integer[] ids, Integer pageNo, HttpServletRequest request,
ModelMap model) {
WebErrors errors = validateDelete(ids, request);
if (errors.hasErrors()) {
return errors.showErrorPage(model);
}
#{Entity}[] beans = manager.deleteByIds(ids);
for (#{Entity} bean : beans) {
log.info("delete #{Entity} id={}", bean.getId());
}
return list(pageNo, request, model);
}
private WebErrors validateSave(#{Entity} bean, HttpServletRequest request) {
WebErrors errors = WebErrors.create(request);
Website web = SiteUtils.getWeb(request);
bean.setWebsite(web);
return errors;
}
private WebErrors validateEdit(Integer id, HttpServletRequest request) {
WebErrors errors = WebErrors.create(request);
Website web = SiteUtils.getWeb(request);
if (vldExist(id, web.getId(), errors)) {
return errors;
}
return errors;
}
private WebErrors validateUpdate(Integer id, HttpServletRequest request) {
WebErrors errors = WebErrors.create(request);
Website web = SiteUtils.getWeb(request);
if (vldExist(id, web.getId(), errors)) {
return errors;
}
return errors;
}
private WebErrors validateDelete(Integer[] ids, HttpServletRequest request) {
WebErrors errors = WebErrors.create(request);
Website web = SiteUtils.getWeb(request);
errors.ifEmpty(ids, "ids");
for (Integer id : ids) {
vldExist(id, web.getId(), errors);
}
return errors;
}
private boolean vldExist(Integer id,WebErrors errors) {
if (errors.ifNull(id, "id")) {
return true;
}
#{Entity} entity = manager.findById(id);
if(errors.ifNotExist(entity, #{Entity}.class, id)) {
return true;
}
return false;
}
@Autowired
private #{Entity}Mng manager;
}
步伐_
- 粉丝: 12
- 资源: 20
最新资源
- 基于卷积神经网络的语音识别声学模型的研究详细文档+全部资料+优秀项目+源码.zip
- 基于卷积神经网络的自动驾驶系统的设计与实现详细文档+全部资料+优秀项目+源码.zip
- 基于卷积神经网络和软件无线电的在线识别框架和系统详细文档+全部资料+优秀项目+源码.zip
- 基于卷积神经网络识别金融票据中的数字串详细文档+全部资料+优秀项目+源码.zip
- 基于卷积神经网络模型输出的LAMOST观测数据的恒星光谱型星表详细文档+全部资料+优秀项目+源码.zip
- 基于梅尔倒谱系数mfcc与卷积神经网络CNN详细文档+全部资料+优秀项目+源码.zip
- 基于卷积循环神经网络的数字识别详细文档+全部资料+优秀项目+源码.zip
- 基于全卷积神经网络的语音识别系统详细文档+全部资料+优秀项目+源码.zip
- 基于深度卷积神经网络的K折交叉验证详细文档+全部资料+优秀项目+源码.zip
- 基于深度堆叠卷积神经网络的图像融合详细文档+全部资料+优秀项目+源码.zip
- 基于软件无线电和卷积神经网络的GNSS保护系统中app代码详细文档+全部资料+优秀项目+源码.zip
- 基于一维卷积神经网络(1D-CNN)的多元时间序列分类详细文档+全部资料+优秀项目+源码.zip
- 基于深度学习的人脸识别项目数字图像处理采用三层卷积池化+全连接神经网络详细文档+全部资料+优秀项目+源码.zip
- 空中视图车辆检测3-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 基于copula的风光联合场景生成方法 同时生成考虑空间相关性的风电和光伏联合场景,用于风光不确定性分析 说明:地理位置相近的风电机组和光伏机组具有极大的相关性,但是当前研究更多的是不计风光出力之间的
- 计算机语言学中并查集数据结构的C++实现
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
前往页