后端部门管理页面代码

后端部门管理代码找代写,就一点点,不多,拉一下苦命的大学生吧!可➕V联系

java 编程语言的可以使用若依框架,比较简单
https://gitee.com/y_project/RuoYi-Vue

  • 你可以看下这个问题的回答https://ask.csdn.net/questions/7624970
  • 你也可以参考下这篇文章:编写三个系别的学生类:英语系,计算机系,文学系(要求通过继承学生抽象类)各系来显示以下成绩:
  • 除此之外, 这篇博客: 操作系统实验报告(二)银行家算法中的 八、 实验数据及源代码(学生必须提交自己设计的程序源代码,并有注释,源代码电子版也一并提交),包括思考题的程序。 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
  • 实验源代码:

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int resourceNum = 5;  //资源数量
    const int processNum = 5;   //进程数量
    //系统可用的剩余资源
    int available[resourceNum];
    //进程的最大需求
    int maxRequest[processNum][resourceNum];
    //进程已经占有的资源
    int allocation[processNum][resourceNum];
    //进程还需要的资源(满足关系need + allocation == maxRequest)
    int need[processNum][resourceNum];
    //复制available数组,复制的目的仅是为了在检查系统是否安全的时候不破坏原来的available数组
    int work[resourceNum];
    //进程是否已经完成(为true代表已经完成,全部为true就代表安全)
    int finish[processNum];
    //安全序列号
    int safeSeries[processNum];
    //申请资源的数量
    int request[resourceNum];
    //已经完成的进程数量
    int cnt = 0;
    
    //判断某一进程的need[]是不是全部为0(全部为0就代表该进程已完成)
    bool isAllZero(int pid){
        for(int j = 0;j<resourceNum;++j){
            if(need[pid][j]){
                return 0;
            }
        }
        return 1;
    }
    
    //目前资源使用情况
    void info(){
        printf("当前系统剩余资源:");
        for(int i = 0;i < resourceNum;++i){
            printf("%d ",available[i]);
        }
        printf("\n");
        printf("当前所有进程的资源使用情况如下:\n");
        printf("PID\t\tmaxRequest\t\tallocation\t\tneed\n");
        for(int i = 0;i < processNum;++i){
            printf("%05d\t\t",i);   //输出PID
            //输出maxRequest
            for(int j = 0;j<resourceNum;++j){
                printf("%-2d ",maxRequest[i][j]);
            }
            printf("\t\t");
            //输出allocation
            for(int j = 0;j<resourceNum;++j){
                printf("%-2d ",allocation[i][j]);
            }
            printf("\t\t");
            //输出need
            for(int j = 0;j<resourceNum;++j){
                printf("%-2d ",need[i][j]);
            }
            printf("\n");
        }
    }
    
    //判断当前系统是否安全
    bool isSafe(bool showinfo = 1/*showinfo:是否显示分配过程,默认显示*/){
        //初始化finish
        memset(finish,0,sizeof(finish));
        int finishNum = 0;  //已经完成的进程数量
        int safeIndex = 0;  //安全序列的下标
        //复制available数组给work
        for(int i = 0;i < resourceNum;++i){
            work[i] = available[i];
        }
        //检查是否有进程已经完成(所需资源全部为0就视为完成)
        for(int i = 0;i < processNum;++i){
            if(isAllZero(i)){
                finish[i] = 1;
                finishNum += 1;
            }
        }
        int lastFinishNum = -1;//上一趟循环之后完成的进程数量
        int pid = 0;    //当前是哪个进程
        bool tag = 1;   //标识系统是否安全
        while(finishNum < processNum){
            int num;
            pid %= processNum;
            if(pid == 0){
                //pid==0,说明这是新的一趟循环
                //如果一趟循环之后,完成的进程数量都还没有增加,那么剩下的资源都不可能有完成的了,所以不安全
                if(finishNum == lastFinishNum){
                    tag = 0;
                    break; 
                }
                lastFinishNum = finishNum;
            }
            if(finish[pid]){
                ++pid;
                continue;  //当前进程已完成,跳过
            }
            num = 0;
            for(int j = 0;j < resourceNum;++j){
                num += need[pid][j] <= work[j];
            }
            //当前系统资源能满足进程j所需的所有资源,说明该进程能完成
            if(num == resourceNum){
                for(int j = 0;j<resourceNum;++j){
                    work[j] += allocation[pid][j]; //释放该进程占有的资源
                }
                finish[pid] = 1;    //标记一下该进程已完成
                safeSeries[safeIndex++] = pid;  //安全序列
                if(showinfo){
                    printf("----------------------------------------------------\n");
                    printf("%d) 把当前系统资源分配给进程%05d\n",safeIndex,pid);
                    printf(">>> 进程%05d目前还需要的资源为", pid);
                    for(int j = 0;j < resourceNum;++j){
                        printf("%-2d ", need[pid][j]);
                    }
                    printf("能满足要求!\n");
                    printf(">>> 进程%05d运行完成后,释放掉该进程占有的资源后,当前系统剩余资源为",pid);
                    for(int j = 0;j < resourceNum;++j){
                        printf("%-2d ", work[j]);
                    }
                    printf("\n");
                }
                finishNum++;
            }
            ++pid;
        }
        if(showinfo){
            if(tag){
                printf("\n当前系统安全,安全序列为:");
                for(int i = 0;i < safeIndex;++i){
                    printf("%d ",safeSeries[i]);
                }
                printf("\n");
            }else{
                printf("\n当前剩余资源无法使接下来的任一进程完成工作,所以当前系统不安全!\n");
            }
        }
        return tag;
    }
    
    //初始化数据
    void init(){
        int i,j;
        //随机数种子
        srand((unsigned long)time(0));
        
        //写available数组
        for(i = 0;i < resourceNum;++i){
            available[i] = rand() % 5 + 3;
        }
        //写maxRequest数组
        for(i = 0;i < processNum;++i){
            for(j = 0;j < resourceNum;++j){
                maxRequest[i][j] = rand() % 5 + 5;
            }
        }
        //写allocation数组
        for(i = 0;i < processNum;++i){
            for(j = 0;j < resourceNum;++j){
                allocation[i][j] = rand() % (maxRequest[i][j]);
            }
        }
        //根据maxRequest和allocation写need数组
        for(i = 0;i < processNum;++i){
            for(j = 0;j < resourceNum;++j){
                need[i][j] = maxRequest[i][j] - allocation[i][j];
            }
        }
    }
    
    //随机分配资源
    void allot(){
        //随机数种子
        srand((unsigned long)time(0));
        int pid = 0;
        //随机一个进程,但是该进程不能是已经完成的进程
        do{
            pid = rand() % processNum;
        }while(isAllZero(pid));
        //随机分配资源
        for(int i = 0;i < resourceNum;++i){
            request[i] = rand() % min(available[i] + 1, need[pid][i] + 1); //随机分配资源
        }
        printf("正在尝试对进程%05d分配资源:",pid);
        for(int j = 0;j < resourceNum;++j){
            printf("%-2d ", request[j]);
        }
        printf("\n");
        //分配资源
        for(int j = 0;j < resourceNum;++j){
            need[pid][j] -= request[j];
            allocation[pid][j] += request[j];
            available[j] -= request[j];
        }
        info();
        //如果本次分配能直接满足该进程的要求,那么直接同意分配!
        if(isAllZero(pid)){
            printf("本次分配之后,已经能满足该进程的要求,同意分配!进程完成之后释放资源!\n");
            for(int j = 0;j < resourceNum;++j){
                available[j] += allocation[pid][j];
            }
            ++cnt;
        }else{
            printf("本次分配之后,仍未能满足该进程的要求\n");
            //检查分配之后是否安全
            if(isSafe()){
                //同意分配
                printf("同意本次分配!\n");
            }else{
                printf("回滚本次分配!\n");
                for(int j = 0;j < resourceNum;++j){
                    need[pid][j] += request[j];
                    allocation[pid][j] -= request[j];
                    available[j] += request[j];
                }
            }
        }
        
        info();
    }
    
    
    //菜单
    bool menu(){
        printf("***************************\n");
        printf("1. 查看系统当前资源使用情况\n");
        printf("2. 分析当前系统安全性\n");
        printf("3. 分配资源\n");
        printf("4. 重新生成系统资源数据\n");
        printf("0. 退出程序\n");
        printf("***************************\n");
        printf("请选择:");
        int a = -1; //当前选择
        do{
            scanf("%d",&a);
            if(a < 0 || a > 4){
                printf("请输入正确的数字!");
                a = -1;
            }	
            while(getchar() != '\n'){};//清空缓冲区	
        }while(a == -1);
        if(a == 0){
            return 0; //退出程序
        }else if(a == 1){
            info();
        }else if(a == 2){
            info();
            isSafe();
        }else if(a == 3){
            allot();
        }else if(a == 4){
            //初始化数据(要保证初始化之后系统是安全的!)
            do{
                init();
            }while(!isSafe(0));
            printf("初始化数据完成!\n");
            info();
        }
        cout << endl;
        system("pause");
        return 1;
    };
    
    int main() {
    	//初始化数据(要保证初始化之后系统是安全的!)
        do{
            init();
        }while(!isSafe(0));
        //检查系统中是否已经有进程完成:
        for(int i = 0;i < processNum;++i){
            if(isAllZero(i)){
                ++cnt;
                //释放资源
                for(int j = 0;j < resourceNum;++j){
                    available[j] += allocation[i][j]; 
                }
            }
        }
        while(menu()){ //显示菜单
            if(cnt >= processNum){
                printf("当前所有进程已经完成,程序结束!\n");
                break;
            }
            system("cls");  //清屏操作
        }
    	return 0;
    }
    
    
  • 您还可以看一下 唐宇迪老师的深度学习模型部署与剪枝优化实例课程中的 课程简介(课程数据代码下载,需网页登录)小节, 巩固相关知识点

可以试试

package com.hjf.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.hjf.entity.Course;
import com.hjf.util.DBUtil;

/**
 * 课程Dao
 * Dao层操作数据
 * @author Hu
 *
 */
public class CourseDao {

    /**
     * 添加
     * @param course
     * @return
     */
    public boolean add(Course course) {
        String sql = "insert into course(name, sex,minzu,zhuce,age,zhengzhi,fuwu) values('" + course.getName() + "','" + course.getSex() + "','" + course.getMinzu() + "','" + course.getZhuce()+ "','" + course.getAge() + "','" + course.getZhengzhi() + "','" + course.getFuwu()  + "')";
        //创建数据库链接
        Connection conn = DBUtil.getConn();
        Statement state = null;
        boolean f = false;
        int a = 0;
        
        try {
            state = conn.createStatement();
            state.executeUpdate(sql);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            //关闭连接
            DBUtil.close(state, conn);
        }
        
        if (a > 0) {
            f = true;
        }
        return f;
    }

    /**
     * 删除
     * 
     * @param id
     * @return
     */
    public boolean delete (int id) {
        boolean f = false;
        String sql = "delete from course where id='" + id + "'";
        
        Connection conn = DBUtil.getConn();
        Statement state = null;
        int a = 0;
        
        try {
            state = conn.createStatement();
            a = state.executeUpdate(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(state, conn);
        }
        
        if (a > 0) {
            f = true;
        }
        return f;
    }

    /**
     * 修改
     * @param name
     * @param pass
     */
    public boolean update(Course course) {
        String sql = "update course set name='" + course.getName() + "', sex='" + course.getSex() + "', minzu='" + course.getMinzu()+ "', zhuce='" + course.getZhuce()+ "', age='" + course.getAge()+ "', zhengzhi='" + course.getZhengzhi()+ "', fuwu='" + course.getFuwu()
            + "' where id='" + course.getId() + "'";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        boolean f = false;
        int a = 0;

        try {
            state = conn.createStatement();
            a = state.executeUpdate(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(state, conn);
        }
        
        if (a > 0) {
            f = true;
        }
        return f;
    }
    
    /**
     * 验证课程名称是否唯一
     * true --- 不唯一
     * @param name
     * @return
     */
    public boolean name(String name) {
        boolean flag = false;
        String sql = "select name from course where name = '" + name + "'";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;
        
        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            while (rs.next()) {
                flag = true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }
        return flag;
    }
    
    /**
     * 通过ID得到课程信息
     * @param id
     * @return
     */
    public Course getCourseById(int id) {
        String sql = "select * from course where id ='" + id + "'";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;
        Course course = null;
        
        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            while (rs.next()) {
                String name = rs.getString("name");
                String sex = rs.getString("sex");
                String minzu = rs.getString("minzu");
                String zhuce = rs.getString("zhuce");
                String age = rs.getString("age");
                String zhengzhi = rs.getString("zhengzhi");
                String fuwu = rs.getString("fuwu");
                
                course = new Course(id, name, sex, minzu,zhuce,age,zhengzhi,fuwu);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }
        
        return course;
    }
    
    /**
     * 通过name得到Course
     * @param name
     * @return
     */
    public Course getCourseByName(String name) {
        String sql = "select * from course where name ='" + name + "'";
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;
        Course course = null;
        
        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            while (rs.next()) {
                int id = rs.getInt("id");
                
                String sex = rs.getString("sex");
                String minzu = rs.getString("minzu");
                String zhuce = rs.getString("zhuce");
                String age = rs.getString("age");
                String zhengzhi = rs.getString("zhengzhi");
                String fuwu = rs.getString("fuwu");
                
                course = new Course(id, name, sex, minzu,zhuce,age,zhengzhi,fuwu);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }
        
        return course;
    }
    
    /**
     * 查找
     * @param name
     * @param teacher
     * @param classroom
     * @return
     */
    public List<Course> search(String name, String sex, String minzu, String zhuce, String age, String zhengzhi, String fuwu) {
        String sql = "select * from course where ";
        if (name != ""&&sex !=""&&minzu!=""&&zhuce!=""&&age!=""&&zhengzhi!=""&&fuwu!="") {
            sql += "name like '%" + name + "%'&&sex like '%" + sex + "%'&&minzu like '%" + minzu + "%'&&zhuce like '%" + zhuce + "%'&&age like '%" + age + "%'&&zhengzhi like '%" + zhengzhi + "%'&&fuwu like '%" + fuwu + "%'";
        }
        if (sex != "") {
            sql += "sex like '%" + sex + "%'";
        }
        if (minzu != "") {
            sql += "minzu like '%" + minzu + "%'";
        }
        if (zhuce != "") {
            sql += "zhuce like '%" + zhuce + "%'";
        }
        if (age != "") {
            sql += "age like '%" + age + "%'";
        }
        if (zhengzhi != "") {
            sql += "zhengzhi like '%" + zhengzhi + "%'";
        }
        if (fuwu != "") {
            sql += "fuwu like '%" + fuwu + "%'";
        }
        List<Course> list = new ArrayList<>();
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;

        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            Course bean = null;
            while (rs.next()) {
                int id = rs.getInt("id");
                String name2 = rs.getString("name");
                String sex2 = rs.getString("sex");
                String minzu2 = rs.getString("minzu");
                String zhuce2 = rs.getString("zhuce");
                String age2 = rs.getString("age");
                String zhengzhi2 = rs.getString("zhengzhi");
                String fuwu2 = rs.getString("fuwu");
                
                bean = new Course(id, name2, sex2, minzu2,zhuce2,age2,zhengzhi2,fuwu2);
                list.add(bean);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }
        
        return list;
    }
    
    /**
     * 全部数据
     * @param name
     * @param teacher
     * @param classroom
     * @return
     */
    public List<Course> list() {
        String sql = "select * from course";
        List<Course> list = new ArrayList<>();
        Connection conn = DBUtil.getConn();
        Statement state = null;
        ResultSet rs = null;

        try {
            state = conn.createStatement();
            rs = state.executeQuery(sql);
            Course bean = null;
            while (rs.next()) {
                int id = rs.getInt("id");
                String name2 = rs.getString("name");
                String sex2 = rs.getString("sex");
                String minzu2 = rs.getString("minzu");
                String zhuce2 = rs.getString("zhuce");
                String age2 = rs.getString("age");
                String zhengzhi2 = rs.getString("zhengzhi");
                String fuwu2 = rs.getString("fuwu");
                
                bean = new Course(id, name2, sex2, minzu2,zhuce2,age2,zhengzhi2,fuwu2);
                list.add(bean);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close(rs, state, conn);
        }
        
        return list;
    }

}
package com.hjf.entity;

public class Course {

    private int id;
    private String name;
    private String sex;
    private String minzu;
    private String zhuce;
    private String age;
    private String zhengzhi;
    private String fuwu;
    
    
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    public String getMinzu() {
        return minzu;
    }
    public void setMinzu(String minzu) {
        this.minzu = minzu;
    }
    public String getZhuce() {
        return zhuce;
    }
    public void setZhuce(String zhuce) {
        this.zhuce = zhuce;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    public String getZhengzhi() {
        return zhengzhi;
    }
    public void setZhengzhi(String zhengzhi) {
        this.zhengzhi = zhengzhi;
    }
    public String getFuwu() {
        return fuwu;
    }
    public void setFuwu(String fuwu) {
        this.fuwu = fuwu;
    }
    public Course() {}
    
    public Course(int id, String name, String sex, String minzu,String zhuce, String age, String zhengzhi,String fuwu) {
        this.id = id;
        this.name = name;
        this.sex = sex;
        this.minzu = minzu;
        this.zhuce = zhuce;
        this.age = age;
        this.zhengzhi = zhengzhi;
        this.fuwu = fuwu;
        
    }
    
    public Course(String name, String sex, String minzu,String zhuce, String age, String zhengzhi,String fuwu) {
        this.name = name;
        this.sex = sex;
        this.minzu = minzu;
        this.zhuce = zhuce;
        this.age = age;
        this.zhengzhi = zhengzhi;
        this.fuwu = fuwu;
    }
}
package com.hjf.service;

import java.util.List;

import com.hjf.dao.CourseDao;
import com.hjf.entity.Course;

/**
 * CourseService
 * 服务层
 * @author Hu
 *
 */
public class CourseService {

    CourseDao cDao = new CourseDao();
    
    /**
     * 添加
     * @param course
     * @return
     */
    public boolean add(Course course) {
        boolean f = false;
        if(!cDao.name(course.getName())) {
            cDao.add(course);
            f = true;
        }
        return f;
    }
    
    /**
     * 删除
     */
    public void del(int id) {
        cDao.delete(id);
    }
    
    /**
     * 修改
     * @return 
     */
    public void update(Course course) {
        cDao.update(course);
    }
    
    /**
     * 通过ID得到一个Course
     * @return 
     */
    public Course getCourseById(int id) {
        return cDao.getCourseById(id);
    }

    /**
     * 通过Name得到一个Course
     * @return 
     */
    public Course getCourseByName(String name) {
        return cDao.getCourseByName(name);
    }
    
    /**
     * 查找
     * @return 
     */
    public List<Course> search(String name, String sex, String minzu,String zhuce, String age, String zhengzhi,String fuwu) {
        return cDao.search( name, sex, minzu,zhuce, age, zhengzhi,fuwu);
    }
    
    /**
     * 全部数据
     * @return 
     */
    public List<Course> list() {
        return cDao.list();
    }
}
package com.hjf.servlet;

import java.io.IOException;
import java.util.List;

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 com.hjf.entity.Course;
import com.hjf.service.CourseService;

@WebServlet("/CourseServlet")
public class CourseServlet extends HttpServlet {
    
    private static final long serialVersionUID = 1L;

    CourseService service = new CourseService();
    
    /**
     * 方法选择
     */
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String method = req.getParameter("method");
        
        if ("add".equals(method)) {
            add(req, resp);
        } else if ("del".equals(method)) {
            del(req, resp);
        } else if ("update".equals(method)) {
            update(req, resp);
        } else if ("search".equals(method)) {
            search(req, resp);
        } else if ("getcoursebyid".equals(method)) {
            getCourseById(req, resp);
        } else if ("getcoursebyname".equals(method)) {
            getCourseByName(req, resp);
        } else if ("list".equals(method)) {
            list(req, resp);
        }
    }

    /**
     * 添加
     * @param req
     * @param resp
     * @throws IOException 
     * @throws ServletException 
     */
    private void add(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        req.setCharacterEncoding("utf-8");
        //获取数据
        String name = req.getParameter("name");
        String sex = req.getParameter("sex");
        String minzu = req.getParameter("minzu");
        String zhuce = req.getParameter("zhuce");
        String age = req.getParameter("age");
        String zhengzhi = req.getParameter("zhengzhi");
        String fuwu = req.getParameter("fuwu");
        Course course = new Course(name, sex, minzu,zhuce, age, zhengzhi,fuwu);
        
        //添加后消息显示
        if(service.add(course)) {
            req.setAttribute("message", "添加成功");
            req.getRequestDispatcher("add.jsp").forward(req,resp);
        } else {
            req.setAttribute("message", "课程名称重复,请重新录入");
            req.getRequestDispatcher("add.jsp").forward(req,resp);
        }
    }
    
    /**
     * 全部
     * @param req
     * @param resp
     * @throws ServletException 
     */
    private void list(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        
        List<Course> courses = service.list();
        req.setAttribute("courses", courses);
        req.getRequestDispatcher("list.jsp").forward(req,resp);
    }

    /**
     * 通过ID得到Course
     * @param req
     * @param resp
     * @throws ServletException 
     */
    private void getCourseById(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        int id = Integer.parseInt(req.getParameter("id"));
        Course course = service.getCourseById(id);
        req.setAttribute("course", course);
        req.getRequestDispatcher("detail2.jsp").forward(req,resp);
    }

    /**
     * 通过名字查找
     * 跳转至删除
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException 
     */
    private void getCourseByName(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        Course course = service.getCourseByName(name);
        if(course == null) {
            req.setAttribute("message", "查无此课程!");
            req.getRequestDispatcher("del.jsp").forward(req,resp);
        } else {
            req.setAttribute("course", course);
            req.getRequestDispatcher("detail.jsp").forward(req,resp);
        }
    }
    
    /**
     * 删除
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException 
     */
    private void del(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        int id = Integer.parseInt(req.getParameter("id"));
        service.del(id);
        req.setAttribute("message", "删除成功!");
        req.getRequestDispatcher("del.jsp").forward(req,resp);
    }
    
    /**
     * 修改
     * @param req
     * @param resp
     * @throws IOException
     * @throws ServletException 
     */
    private void update(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        int id = Integer.parseInt(req.getParameter("id"));
        String name = req.getParameter("name");
        String sex = req.getParameter("sex");
        String minzu = req.getParameter("minzu");
        String zhuce = req.getParameter("zhuce");
        String age = req.getParameter("age");
        String zhengzhi = req.getParameter("zhengzhi");
        String fuwu = req.getParameter("fuwu");
        Course course = new Course(id,name, sex, minzu,zhuce, age, zhengzhi,fuwu);
        
        
        service.update(course);
        req.setAttribute("message", "修改成功");
        req.getRequestDispatcher("CourseServlet?method=list").forward(req,resp);
    }
    
    /**
     * 查找
     * @param req
     * @param resp
     * @throws ServletException 
     */
    private void search(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{
        req.setCharacterEncoding("utf-8");
        String name = req.getParameter("name");
        String sex = req.getParameter("sex");
        String minzu = req.getParameter("minzu");
        String zhuce = req.getParameter("zhuce");
        String age = req.getParameter("age");
        String zhengzhi = req.getParameter("zhengzhi");
        String fuwu = req.getParameter("fuwu");
        List<Course> courses = service.search(name, sex, minzu,zhuce, age, zhengzhi,fuwu);
        req.setAttribute("courses", courses);
        req.getRequestDispatcher("searchlist.jsp").forward(req,resp);
    }
}
package com.hjf.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 数据库连接工具
 * @author Hu
 *
 */
public class DBUtil {
    
    public static String db_url = "jdbc:mysql://localhost:3306/user";
    public static String db_user = "root";
    public static String db_pass = "root";
    
    public static Connection getConn () {
        Connection conn = null;
        
        try {
            Class.forName("com.mysql.jdbc.Driver");//加载驱动
            conn = DriverManager.getConnection(db_url, db_user, db_pass);
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        return conn;
    }
    
    /**
     * 关闭连接
     * @param state
     * @param conn
     */
    public static void close (Statement state, Connection conn) {
        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    
    public static void close (ResultSet rs, Statement state, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        
        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws SQLException {
        Connection conn = getConn();
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        String sql ="select * from course";
        pstmt = conn.prepareStatement(sql);
        rs = pstmt.executeQuery();
        if(rs.next()){
            System.out.println("空");
        }else{
            System.out.println("不空");
        }
    }
}

是要实现部门管理的后台业务处理呢,还是只需要前台页面呢。后台的话无非就是和数据库交互,对数据实现增删改查即可,这个应该没有问题。前台的话,可以参考这位博主的:
https://blog.csdn.net/qq_41071754/article/details/130020396
写的很详细,应该对你有帮助

基于Java的部门管理系统_miqq_79120063的博客-CSDN博客 技术:Java等摘要:本文主要介绍了部门管理系统,尤其是当前非常重要的部门人事管理系统。在网络信息化高速发展的今天,企业办公电子信息化己经成为很多企业高效率办公的一个标志,应用办公电子信息化可以节省大量的人力、物力和财力等资源。对于一个大型企业来说,企业的部门管理是一项复杂的工作。公司的部门管理系统主要用于部门及各部门员工信息数据的录入、修改、查找和删除。该系统使用了MyEc1ipse和 MySQL数据库作为开发软件系统,采用Java技术创建出最适合企业部门运用的管理系统。避免了纷杂的部门管理实务,简洁直 https://blog.csdn.net/m0_68844522/article/details/124162804

这个是比较复杂的哦,要连接数据库、还要面向前端提供接口,一般建议使用spring boot进行开发,数据库可以使用mysql

由于后端部门需要处理复杂的技术任务,并涉及到数据库、服务器和应用架构的管理,因此其管理代码的实现可能较为复杂。以下是一份 Python3 实现的代码示例,仅供参考:


from datetime import datetime
import random


class Employee:

    def __init__(self, emp_id, emp_name):
        self.id = emp_id
        self.name = emp_name
        self.status = "Idle"

    def work_on_task(self, task):
        self.status = "Working"
        task.status = "In Progress"
        task.worker = self

    def complete_task(self, task):
        task.status = "Completed"
        task.worker = None
        self.status = "Idle"


class Task:

    def __init__(self, task_id, task_name, assignee=None):
        self.id = task_id
        self.name = task_name
        self.status = "Unassigned"
        self.worker = assignee

    def assign_to(self, employee):
        if self.status == "Unassigned":
            self.status = "Assigned"
        else:
            self.status = "Reassigned"
            self.worker.status = "Idle"
        self.worker = employee

    def __str__(self):
        if self.worker:
            return f"Task {self.id}: {self.name} (Status: {self.status}, Worker: {self.worker.name})"
        else:
            return f"Task {self.id}: {self.name} (Status: {self.status}, Worker: None)"


class Manager:

    def __init__(self, emp_list):
        self.employees = emp_list
        self.tasks = []

    def create_task(self, task_name):
        task_id = len(self.tasks) + 1
        return Task(task_id, task_name)

    def hire_employee(self, emp_name):
        emp_id = len(self.employees) + 1
        emp = Employee(emp_id, emp_name)
        self.employees.append(emp)
        return emp

    def assign_task(self, task):
        available_employees = [emp for emp in self.employees if emp.status == "Idle"]
        if not available_employees:
            task.status = "Unassigned"
            return
        random_employee = random.choice(available_employees)
        random_employee.work_on_task(task)
        task.assign_to(random_employee)

    def complete_task(self, task):
        if task.worker is not None and task.status == "In Progress":
            task.worker.complete_task(task)
        elif task.worker is None and task.status == "Assigned":
            task.status = "Unassigned"


if __name__ == '__main__':
    emp1 = Employee(1, "Employee1")
    emp2 = Employee(2, "Employee2")
    emp3 = Employee(3, "Employee3")
    emp_list = [emp1, emp2, emp3]

    manager = Manager(emp_list)

    task1 = manager.create_task("Build database schema")
    task2 = manager.create_task("Configure server settings")
    task3 = manager.create_task("Implement REST API")

    manager.assign_task(task1)
    manager.assign_task(task2)
    manager.assign_task(task3)

    manager.complete_task(task1)
    manager.assign_task(task2)
    manager.complete_task(task2)
    manager.assign_task(task3)
    manager.complete_task(task3)

    for task in manager.tasks:
        print(task)

该代码实现了一个简单的员工、任务和部门经理的管理模型,可以根据需要进行扩展。

后端管理页面代码还是比较简单的

写什么,用什么框架,三条内完成可行?

写完了吗

还有需要吗?可以私信一下,这个可以帮你解决。