18.activiti工作流-业务层面

来源:互联网 发布:vb for 循环语句 编辑:程序博客网 时间:2024/06/05 17:06

1.知识点回顾

这里写图片描述

2.系统登录(Session)

public Employee findEmployeeByName(String name) {        String hql = "from Employee o where o.name=?";        List<Employee> list = this.getHibernateTemplate().find(hql, name);        Employee employee = null;        if (list != null && list.size() > 0) {            employee = list.get(0);        }        return employee;    }
public String login() {        // 1:获取用户名        String name = employee.getName();        // 2:使用用户名作为查询条件,查询员工表,获取当前用户名对应的信息        Employee emp = employeeService.findEmployeeByName(name);        // 3:将查询的对象(惟一)放置到Session中        SessionContext.setUser(emp);        return "success";    }
package cn.itcast.ssh.utils;import org.apache.struts2.ServletActionContext;import cn.itcast.ssh.domain.Employee;public class SessionContext {    public static final String GLOBLE_USER_SESSION = "globle_user";    public static void setUser(Employee user){        if(user!=null){            ServletActionContext.getRequest().getSession().setAttribute(GLOBLE_USER_SESSION, user);        }else{            ServletActionContext.getRequest().getSession().removeAttribute(GLOBLE_USER_SESSION);        }    }    public static Employee get(){        return (Employee) ServletActionContext.getRequest().getSession().getAttribute(GLOBLE_USER_SESSION);    }}
public String logout() {        // 清空Session        SessionContext.setUser(null);        return "login";    }

3.自定义拦截器实现Session验证

这里写图片描述

package cn.itcast.ssh.utils;import cn.itcast.ssh.domain.Employee;import com.opensymphony.xwork2.ActionInvocation;import com.opensymphony.xwork2.interceptor.Interceptor;/** * 登录验证拦截器 *  */@SuppressWarnings("serial")public class LoginInteceptor implements Interceptor {    @Override    public void destroy() {        // TODO Auto-generated method stub    }    @Override    public void init() {        // TODO Auto-generated method stub    }    /** 每次访问action类之前,先执行intercept */    @Override    public String intercept(ActionInvocation invocation) throws Exception {        //获取当前访问Action的URL        String actionName = invocation.getProxy().getActionName();        //如果当前访问Action的URL是"loginAction_login"表示此时还没有Sesion,需要放行        if(!"loginAction_login".equals(actionName)){            //从Session中获取当前用户对象            Employee employee = SessionContext.get();            //如果Session不存在,跳转到登录页面            if(employee==null){                return "login";            }        }        //放行,访问Action类中方法        return invocation.invoke();    }}

4.部署流程定义(zip文件部署)

这里写图片描述

这里写图片描述

这里写图片描述

5.流程定义和部署对象查询

这里写图片描述

这里写图片描述

这里写图片描述

6.查看流程图和删除流程定义

在前面基础课学习当中,我们知道查询流程图需要传递deploymentId和imageName,我们直接从模型驱动当中拿就行了。
这里写图片描述

这里写图片描述

这里写图片描述

删除

这里写图片描述

这里写图片描述

这里写图片描述

7.请假单业务的查询列表和新增保存

这里写图片描述
对应a_leavebill

这里写图片描述

这里写图片描述