公司人才管理系统源码简易版(mvc框架进阶中1.0)

公司人才管理系统源码简易版(进阶中1.0)

Java 后端页面

controller控制层

AdminController 管理者层面
import com.gl.ams.pojo.vo.Admin;
import com.gl.ams.service.AdminService;
import com.gl.ams.service.impl.AdminServiceImpl;
import com.gl.ams.servlet.BaseServlet;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;

@WebServlet(urlPatterns = "/dologin")
public class AdminController extends HttpServlet {
   
    private AdminService adminService=new AdminServiceImpl();
    @Override
   //判断跳转登录页面
    public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
   
        //获取页面数据
        Map<String,String[]> map= request.getParameterMap();

        // 封装页面数据
        Admin admin=new Admin();
        try {
   
            BeanUtils.populate(admin,map);
        } catch (IllegalAccessException e) {
   
            e.printStackTrace();
        } catch (InvocationTargetException e) {
   
            e.printStackTrace();
        }
        //调用业务层
        Admin realadmin= adminService.login(admin);


        //获取业务层的执行结果
        //跳转到视图层
        if (realadmin==null){
   //登陆失败再次登录
           
            response.getWriter().print("<script>alert('login no ok');history.go(-1);</script>");

        }else{
   //登陆成功跳转详情管理页面
            request.getSession().setAttribute("loginadmin",realadmin);

            response.sendRedirect(request.getContextPath()+"/admin/index.jsp");

        }


    }
}
DeptController 部门层面
import com.gl.ams.pojo.vo.Dept;
import com.gl.ams.service.DeptService;
import com.gl.ams.service.impl.DeptServiceImpl;
import com.gl.ams.servlet.BaseServlet;
import com.gl.ams.utils.DateUtil;
import com.gl.ams.utils.JsonResult;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List;
import java.util.Map;
@WebServlet(urlPatterns = {
   "/admin/dept"})
public class DeptController extends BaseServlet {
   

    private DeptService deptService=new DeptServiceImpl();

    //控制部门添加
    public void doadd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InvocationTargetException, IllegalAccessException {
   

        // 接收数据
        Dept dept=new Dept();
        dept.setDeptname(request.getParameter("deptname"));
        dept.setDeptdesc(request.getParameter("deptdesc"));
        String datestr=request.getParameter("createdate");
        Date createdate= DateUtil.getDateByString(datestr,"yyyy-MM-dd");
        dept.setCreatedate(createdate);

        // 业务层处理数据
       int result= deptService.addDept(dept);

        // 依据业务的处理结果封装对客户端的jsonResult响应对象
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(result);
       if (result==-1){
   
           jsonResult.setResponseCode(500);
           jsonResult.setErrorMessage("部门名称重复,添加失败");
       }
       if (result==0){
   
         jsonResult.setResponseCode(500);
         jsonResult.setErrorMessage("未知异常,添加失败");
       }

        // jsonResult转成json字符串输出到客户端
        Gson gson = new Gson();
       response.getWriter().print(gson.toJson(jsonResult));
    }

     //控制修改
    public void doedit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InvocationTargetException, IllegalAccessException {
   
        //收集数据
        Dept dept=new Dept();
        dept.setDeptname(request.getParameter("deptname"));
        dept.setDeptdesc(request.getParameter("deptdesc"));
        String datestr=request.getParameter("createdate");
        Integer deptid=Integer.parseInt(request.getParameter("deptid"));
        dept.setDeptid(deptid);
        Date createdate= DateUtil.getDateByString(datestr,"yyyy-MM-dd");
        dept.setCreatedate(createdate);
        //业务层处理数据
        int result=  deptService.editDept(dept);
        // 依据业务的处理结果封装对客户端的jsonResult响应对象
        JsonResult jsonResult=new JsonResult();
        jsonResult.setData(result);
        if (result==-1){
   
            jsonResult.setResponseCode(500);
            jsonResult.setErrorMessage("部门名称重复,修改失败");
        }
        if(result==0){
   
            jsonResult.setResponseCode(500);
            jsonResult.setErrorMessage("未知异常,修改失败");
        }
        // jsonResult转成json字符串输出到客户端
        Gson gson=new Gson();
        response.getWriter().print(gson.toJson(jsonResult));
    }

     //控制删除
    public void remove(HttpServletRequest request,HttpServletResponse response) throws IOException {
   
        Integer deptid=Integer.parseInt(request.getParameter("id"));

        int result=  deptService.removeDeptById(deptid);
        // 依据业务的处理结果封装对客户端的jsonResult响应对象
        JsonResult jsonResult=new JsonResult();
        jsonResult.setData(result);
        if (result==-1){
   
            jsonResult.setResponseCode(500);
            jsonResult.setErrorMessage("该部门还有员工,删除失败");
        }
        if(result==0){
   
            jsonResult.setResponseCode(500);
            jsonResult.setErrorMessage("未知异常,删除失败");
        }
        // jsonResult转成json字符串输出到客户端
        Gson gson=new Gson();
        response.getWriter().print(gson.toJson(jsonResult));

    }

    //获取部门编号
    public void getdeptbyid(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
   
        //得到了要修改部门的编号
        Integer deptid = Integer.parseInt(request.getParameter("id"));
        // 依据部门编号获取部门对象
        Dept dept = deptService.getDeptById(deptid);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(dept);
        Gson gson = new Gson();
        response.getWriter().print(gson.toJson(jsonResult));
    }

    public void checkname(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InvocationTargetException, IllegalAccessException {
   
        String deptname = request.getParameter("deptname");
        Dept dept = deptService.getDeptByName(deptname);
        if (dept == null) {
   
            response.getWriter().print("true");
        } else {
   
            response.getWriter().print("false");
        }
    }

    //获取部门全部信息
    public void dolist(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
   
            List<Dept> depts= deptService.getAll();
            Gson gson=new Gson();
            String depts_json=gson.toJson(depts);
//            System.out.println(depts_json);
            response.getWriter().print(depts_json);
    }
}
EmpController 员工层面
import com.gl.ams.pojo.vo.Emp;
import com.gl.ams.service.EmpService;
import com.gl.ams.service.impl.EmpServiceImpl;
import com.gl.ams.servlet.BaseServlet;
import com.gl.ams.utils.JsonResult;
import com.gl.ams.utils.PageResult;
import com.google.gson.Gson;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;

@WebServlet(urlPatterns = "/admin/emp")
public class EmpController extends BaseServlet {
   

    private EmpService empService =new EmpServiceImpl();

     //控制员工添加
    public void doadd(HttpServletRequest request, HttpServletResponse response) throws InvocationTargetException, IllegalAccessException, IOException {
   
        //收集数据
        Map<String, String[]> map = request.getParameterMap();
        Emp emp = new Emp();
        BeanUtils.populate(emp,map);

        //调用业务层处理数据
        int result = empService.addEmp(emp);

        //依据业务层的执行结果——封装jsonresult对象
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(result);
        if (result==0){
   
            jsonResult.setErrorMessage("添加失败!");
            jsonResult.setResponseCode(500);
        }
        if (result==-1){
   
            jsonResult.setErrorMessage("员工编号重复,添加失败!");
            jsonResult.setResponseCode(500);
        }
        //将jsonresult转成json字符串输出到视图层
        response.getWriter().print(new Gson().toJson(jsonResult));
    }
   
    
    public void checkempid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InvocationTargetException, IllegalAccessException {
   
        //收集数据
        String empid=request.getParameter("empid");
        // 调用业务层处理数据
        Emp  emp= empService.getEmpById(empid);
        // 依据业务层的执行结果--封装jsonresult对象
        JsonResult jsonResult=new JsonResult();
        if (emp==null){
   
            jsonResult.setData(true);
        }else{
   
            jsonResult.setData(false);
            jsonResult.setResponseCode(500);
            jsonResult.setErrorMessage("员工编号重复,添加失败!");
        }
        // jsonresult转成json字符串输出到视图层
        response.getWriter().print(new Gson().toJson(jsonResult));

    }
    public void doedit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InvocationTargetException, IllegalAccessException {
   
        //收集数据
        Map<String,String[]> map= request.getParameterMap();
        Emp emp=new Emp();
        BeanUtils.populate(emp,map);
        // 调用业务层处理数据
        int result= empService.editEmp(emp);
        // 依据业务层的执行结果--封装jsonresult对象
        JsonResult jsonResult=new JsonResult();
        jsonResult.setData(result);
        if (result==0){
   
            jsonResult.setErrorMessage("修改失败!");
            jsonResult.setResponseCode(500);
        }
        // jsonresult转成json字符串输出到视图层
        response.getWriter().print(new Gson().toJson(jsonResult));

    }
    public void listpage(HttpServletRequest request,HttpServletResponse response) throws IOException {
   
        //收集数据
        int pageindex=1;
        String pageindex_str=request.getParameter("pageindex");
        if (pageindex_str!=null && !"".equals(pageindex_str)){
   
            pageindex=Integer.parseInt(pageindex_str);
        }
        int pagesize=2;
        String pagesize_str=request.getParameter("pagesize");
        if (pagesize_str!=null && !"".equals(pagesize_str)){
   
            pagesize=Integer.parseInt(pagesize_str);
        }

        //调用业务层处理数据
        List<Emp> emps = empService.getEmpByPage(pageindex, pagesize);
        long pagecount=empService.getPageCount(pagesize);

        // 封装成分页对象
        PageResult pageResult=new PageResult();
        pageResult.setPagecount(pagecount);
        pageResult.setPageindex(pageindex);
        pageResult.setPagesize(pagesize);
        pageResult.setDatas(emps);

        //依据业务层的执行结果——封装jsonresult对象
        JsonResult jsonResult = new JsonResult();
        jsonResult.setData(pageResult);

        //将jsonresult转成json字符串输出到视图层
        response.getWriter().print(new Gson().toJson(jsonResult));
    }
    public void getempbyid(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, InvocationTargetException, IllegalAccessException {
   
        //收集数据
        String empid=request.getParameter("id");
        // 调用业务层处理数据
        Emp  emp= empService.getEmpById(empid);
        // 依据业务层的执行结果--封装jsonresult对象
        JsonResult jsonResult=new JsonResult();
        jsonResult.setData(emp);
        // jsonresult转成json字符串输出到视图层
        response.getWriter().print(new Gson().toJson(jsonResult));

    }
}

mapper 数据库持久层

interface 接口
AdminMapper 管理者接口数据库
import com.gl.ams.pojo.vo.Admin;

import java.sql.Connection;
import java.sql.SQLException;

public interface AdminMapper {
   
    public Admin selectByUsername(Connection conn, String username)throws SQLException;
}
DeptMapper 部门接口数据库
import com.gl.ams.pojo.vo.Dept;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public interface DeptMapper {
   
    public  int insertDept(Connection conn, Dept dept)throws SQLException;
    public  int updateDept(Connection conn, Dept dept)throws SQLException;
    public  int deleteDeptById(Connection conn, Integer deptid)throws SQLException;
    public  Dept selectById(Connection conn, Integer deptid)throws SQLException;
    public  Dept selectByName(Connection conn, String deptname)throws SQLException;
    public List<Dept> selectAll(Connection conn)throws  SQLException;
}

EmpMapper 员工接口数据库
import com.gl.ams.pojo.vo.Emp;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public interface EmpMapper {
   
    public long selectEmpCountByDeptId(Connection conn, Integer deptid) throws SQLException;
    public int insertEmp(Connection conn, Emp emp)throws SQLException;
    public int updateEmp(Connection conn,Emp emp)throws SQLException;
    public int deleteEmpById(Connection conn,String empid)throws SQLException;
    public Emp selectEmpById(Connection conn,String empid)throws SQLException;
    public List<Emp> selectEmpByPage(Connection conn,int pageindex,int pagesize)throws SQLException;
    public long selectEmpCount(Connection conn)throws SQLException;
}
impl 存放接口实现类
AdminMapperImpl 管理者操作数据库
import com.gl.ams.mapper.AdminMapper;
import com.gl.ams.pojo.vo.Admin;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.sql.SQLException;

public class AdminMapperImpl implements AdminMapper {
   
    @Override
    public Admin selectByUsername(Connection conn, String username) throws SQLException {
   
        String sql="select * from admin where username=?";
        QueryRunner queryRunner=new QueryRunner();
       Admin admin=  queryRunner.query(conn,sql,new BeanHandler<Admin>(Admin.class),username);
        return admin;
    }
}
DeptMapperImpl 部门操作数据库
import com.gl.ams.mapper.DeptMapper;
import com.gl.ams.pojo.vo.Dept;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
一套很好用人才系统源代码 工作易人才招聘系统是面向企业和个人站长建站时,最具性价比的一套人才招聘系统。以《实用、稳定、快捷管理、价格低廉》为占据市场的一席之地。采用微软的.Net最新技术开发,完全不用担心系统漏洞和崩溃。 工作易人才招聘系统大致实用功能简介: 1、 整合在线支付功能,企业登录充值后立即将金额转换为后台点数。未登录情况下进行充值,可以进行其他功能的业务服务。 2、 邮件通知企业功能:后台邮件系统,自动提取设定天数内为登录的企业资料,进行邮件发送通知。 3、 后台模板和CSS样式功能:管理员通过后台系统的模板功能可以自行修改网页样式和CSS风格。并带有备份和还原功能,防止修改过程误操作造成无可挽回的损失。 4、 投递简历即通知企业:个人找到满意职位后进行求职申请,能第一时间通过邮件通知该企业有职位意向招聘,与企业之间达到人性化沟通服务。(后台设置启动功能) 5、 个人/企业登录跟踪IP地址:管理员可通过后台的注册栏目对个人/企业进行IP跟踪定位,防止非法用户。 6、 管理员权限功能:后台设定完美的管理权限,具体权限达30项之多。 超级管理员能自行建立子管理员,并对每一项功能的增、改、删、看功能进行详细设置。 7、 文章搜索功能:对文章进行更好的管理。 8、 整合收费制度:突破传统,整合市面上各种人才系统的收费制度为:点数+包月/年 制度。 9、 电子地图:让您的网站在各个人才系统行业更显专业风范。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨霖先森

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值