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(Long 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(Long[] 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(Long 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(Long 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(Long[] ids, HttpServletRequest request) {
WebErrors errors = WebErrors.create(request);
Website web = SiteUtils.getWeb(request);
errors.ifEmpty(ids, "ids");
for (Long id : ids) {
vldExist(id, web.getId(), errors);
}
return errors;
}
private boolean vldExist(Long id, Long webId, WebErrors errors) {
if (errors.ifNull(id, "id")) {
return true;
}
#{Entity} entity = manager.findById(id);
if(errors.ifNotExist(entity, #{Entity}.class, id)) {
return true;
}
if (!entity.getWebsite().getId().equals(webId)) {
errors.notInWeb(#{Entity}.class, id);
return true;
}
return false;
}
@Autowired
private #{Entity}Mng manager;
}
weixin_38739919
- 粉丝: 4
- 资源: 903
最新资源
- 基于全阶磁链观测器的异步电机矢量控制 全阶磁链观测器的主要思想是将异步电机模型作为参考,把状态估计的方程作为可调节部分 这两部分具有相同物理意义的输出量,利用两个部分的输出量误差再经过反馈校
- 事件触发控制代码+对应参考文献 1.2023IEEE TRANS 顶刊基于事件触发的深度强化学习自动驾驶决策(CCF-A) 2.多智能体分布式系统的事件触发控制 3.基于观测器的非理想线性多智能体事件
- 序列相关同步检测电路,电子科技大学电子设计自动化实验代码
- 微调 MySQL 全文搜索.pdf
- 直接扩频序列通信技术仿真与设计实验 实验设计m序列和gold序列在不同信道当中进行仿真,最后得出关于信噪比和误码率的规律 扩频序列实验、码序列、通信工程课程设计、matlab,附带报告一份
- Money Pro for Mac v2.11.3
- 光伏储能同步发电机VSG并网仿真模型C 光伏阵列搭建的光伏电池模型 光伏:采用扰动观察法最大功率点MPPT跟踪控制 储能:蓄电池充放电控制,双向Buck Boost变器,采用直流母线电压外环控制稳定直
- Visual Studio Code 中的配置文件.pdf
- 遥感目标检测 TAS遥感目标检测数据集.zip
- STM32三相电压型SVPWM整流器仿真,以电压外环和电流内环控制,双闭环PID控制,输出电压600V 三相电压型SVPWM整流器仿真,以电压外环和电流内环控制,双闭环PID控制,输出电压600V
- 在本地计算机上开发并行 MATLAB代码并扩展到集群.pdf
- Mellel 6 for Mac v6.2.1
- 电力系统11个节点无功补偿仿真,功率因数和谐波可观察,线路阻抗参数可改,matlab2018b及以上(可改版)
- Ls-dyna 聚能爆破.研究聚能射流击穿钢板,本模型为二维模型,研究聚能射流对钢板的破坏形式.可查看聚能射流的应力变化情况
- 改进的紧凑拉伸试样的疲劳裂纹扩展分析 - ANSYS Workbench
- 永磁同步电机的MTPA最大转矩电流比控制算法+弱磁控制的仿真模型 (附带一份建模及说明文档) 1. 永磁同步电机的数学模型; 2. 永磁同步电机的矢量控制原理; 3. 最大转矩电流比控制; 4.
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0