校园兼职项目(合作)总结

该项目使用JavaSE、JDBC、Git进行开发,集成数据库连接池Druid和Apache-DBUtils工具库。实现了包括兼职审批、基本信息维护、兼职管理和系统管理在内的功能,展示了三层架构的运用和Git的协同操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 功能需求图:

该小项目主要用到了:



  • javaSE
  • JDBC
  • Git(进行合作项目的管理)

 下图是代码设计和基本框架和需要用到的工具,Mysql的与java连接的驱动,以及数据库连接池国货之光——德鲁伊(druid),以及开源 JDBC工具类库Apache-DBUtils。

 其中的JobDao的接口定义如下:

项目效果图:

 控制台输出的界面代码:

public void screen() throws InterruptedException {
        boolean flag = true ;
        while (flag) {
            System.out.println("   ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓");
            System.out.println("  🔣                                       🔣");
            System.out.println(" 🔣              ~管理员主菜单~                🔣");
            System.out.println("🔣                                            🔣");
            System.out.println("   ┃                                       ┃");
            System.out.println("   ┃         欢迎:" + admin.getuser_name() + "   ~");
            System.out.println("   ┃                                       ┃");
            System.out.println("   ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛");
            System.out.println("🐻1. <兼职审批>                *");
            System.out.println("🐘2. <基本信息维护>         *");
            System.out.println("🦁3. <兼职管理>                    *");
            System.out.println("🐻4. <系统管理>                 *");
            System.out.println("🦊5. <退出软件>                    *");
            char key = TSUtility.readMenuSelectionPro();
            switch (key) {
                case '1':
                    //兼职审批(有问题)
                    adminService.approval();
                    TSUtility.loadSpecialEffects();

                    break;
                case '2':
                    //基本信息维护
                    modifyJobInfoView();
                    TSUtility.loadSpecialEffects();

                    break;
                case '3':
                    //兼职管理界面
                    jobManageView();
                    TSUtility.loadSpecialEffects();
                    break;
                case '4':
                    //系统管理
                    managementSysView();
                    TSUtility.loadSpecialEffects();
                    break;
                case '5':
                    //退出软件
                    System.out.println("是否退出?(Y/N)");
                    char yn = TSUtility.readConfirmSelection();
                    if (yn == 'Y') {
                        flag = false;
                    }
                    TSUtility.loadSpecialEffects();
                    break;
            }
        }
    }

 以下是使用的输入工具类,有需要可以自取(但是有的方法并不是很好,因为还没有那么强):

public class TSUtility {
    private static Scanner scanner = new Scanner(System.in);
    public static char readSelection() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1, false);
            c = str.charAt(0);
            if (c != '1' && c != '2' && c != '3' && c != '4') {
                System.out.print("选择错误,请重新输入:");
            } else break;
        }
        return c;
    }

    public static String readSex() {
        String str;
        for (; ; ) {
            str = readKeyBoard(2, false);
            if (str.equals("男") || str.equals("女")) {
                break;
            } else {
                System.out.print("选择错误,请重新输入:");
            }
        }
        return str;
    }

    public static int read_Int(int limit) {
        int n;
        for (; ; ) {
            String str = readKeyBoard(limit, false);
            try {
                n = Integer.parseInt(str);
                break;
            } catch (NumberFormatException e) {
                System.out.print("数字输入错误,请重新输入:");
            }
        }
        return n;
    }

    public static void logging(String str) {
        FileWriter fileWriter = null;
        try {
            fileWriter = new FileWriter("src\\file\\logging.txt");
            fileWriter.write(str);
            fileWriter.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static char readMenuSelectionMin() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1, false);
            c = str.charAt(0);
            if (c != '1' && c != '2' &&
                    c != '3') {
                System.out.print("选择错误,请重新输入:");
            } else break;
        }
        return c;
    }

    /**
     * 选择相关相应的菜单编号,只有4个选项
     *
     * @return
     */
    public static char readMenuSelection() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1, false);
            c = str.charAt(0);
            if (c != '1' && c != '2' &&
                    c != '3' && c != '4') {
                System.out.print("选择错误,请重新输入:");
            } else break;
        }
        return c;
    }

    /**
     * 选择相关相应的菜单编号
     *
     * @return char
     */
    public static char readMenuSelectionPro() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1, false);
            c = str.charAt(0);
            if (c != '1' && c != '2' &&
                    c != '3' && c != '4' && c != '5') {
                System.out.print("选择错误,请重新输入:");
            } else break;
        }
        return c;
    }

    /**
     * 判断输入的时间的格式并且输入的日期不小于当天
     */
    public static boolean isDateFormatValid(String dateString) {
        if (dateString == null || dateString.length() != 10) {
            return false;
        }
        try {
            // 解析日期字符串
            LocalDate date = LocalDate.parse(dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));

            // 获取当前日期
            LocalDate currentDate = LocalDate.now();

            // 判断日期是否在当前日期之前
            if (date.isBefore(currentDate)) {
                System.out.println("输入的日期不能小于当天的日期");
                return false;
            }
            return true;
        } catch (DateTimeParseException e) {
            System.out.println("输入的日期的格式错误!(yyyy-MM-dd)");
            return false;
        }
    }

    public static LocalDate read_startDate(int limit, boolean blankReturn) {

        boolean flag = true;
        LocalDate startime = null;
        while (flag) {
            String dateString = TSUtility.readPhone(limit, blankReturn);
            //这里一直循环
            if (isDateFormatValid(dateString)) {
                flag = false;
                startime = LocalDate.parse(dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
            }
        }
        return startime;
    }

    /**
     * @param limit       输入字符的个数限制
     * @param blankReturn
     * @param start_date
     * @return
     */
    public static LocalDate read_endDate(int limit, boolean blankReturn, LocalDate start_date) {

        boolean flag = true;
        LocalDate date = null;
        while (flag) {
            String end_dateString = TSUtility.readPhone(limit, blankReturn);
            date = LocalDate.parse(end_dateString, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
            //这里一直循环
            if (date.equals(start_date) || date.isAfter(start_date)) {
                flag = false;
            } else {
                System.out.println("输入的时间要在工作开始时间之后!");
            }
        }
        return date;
    }

    /**
     * 从键盘输入时间,格式为:HH:mm:ss,输入的时间没有限制
     */
    public static boolean isTimeFormatValid(String Timestring) {
        try {
            LocalTime time = LocalTime.parse(Timestring, DateTimeFormatter.ofPattern("HH:mm:ss"));
            return true;
        } catch (Exception e) {
            System.out.println("输入的日期的格式错误!(HH:mm:ss)");
            return false;
        }
    }

    public static LocalTime read_startTime(int limit, boolean blankReturn) {
        boolean flag = true;
        LocalTime time = null;
        while (flag) {
            String timestring = TSUtility.readPhone(limit, blankReturn);
            if (isTimeFormatValid(timestring)) {
                time = LocalTime.parse(timestring, DateTimeFormatter.ofPattern("HH:mm:ss"));
                flag = false;
            }
        }
        return time;
    }

    public static LocalTime read_endTime(int limit , boolean blankReturn , LocalTime startTime)
    {
        boolean flag = true;
        LocalTime time = null;
        while (flag) {
            String timestring = TSUtility.readPhone(limit, blankReturn);
            if (isTimeFormatValid(timestring)) {
                time = LocalTime.parse(timestring, DateTimeFormatter.ofPattern("HH:mm:ss"));
                if(time.isAfter(startTime))
                {
                    flag = false;
                }else {
                    System.out.println("结束时间需要在开始时间之后!");
                }
            }
        }
        return time;
    }

    /**
     * 按回车键继续
     */
    public static void readReturn() {
        System.out.print("按回车键继续...");
        readKeyBoard(100, true);
    }

    public static int readInt(int minLimit, int maxLimit) {
        int str = 0;
        boolean flag =true;
        while (flag) {
            try {
                str = Integer.valueOf(scanner.nextLine());
                flag =false ;
            } catch (NumberFormatException e) {
                System.out.println("输入了不正确的值!!!请正确输入");
                flag =true;
            }
            if (minLimit <= str && str <= maxLimit) {
                flag =false ;;
            } else {
                System.out.println("输入错误,输入值应在" + minLimit + "和" + maxLimit + "之间");
                 flag =true;
            }
        }
        return str;
    }

    public static int readInt(int length) {
        String input;
        int num;

        do {
            input = scanner.nextLine();
            System.out.println("请输入长度为" +length+ "的数!!!");
        } while (!isNumeric(input) || input.length() != length);

        num = Integer.parseInt(input);
        return num;
    }

    public static int readstock() {
        int n;
        for (; ; ) {
            String str = readKeyBoard(6, false);
            try {
                n = Integer.parseInt(str);
                break;
            } catch (NumberFormatException e) {
                System.out.print("数字输入错误,请重新输入:");
            }
        }
        return n;
    }

    public static Double readDouble() {
        Double n;
        for (; ; ) {
            String str = readKeyBoard(6, false);
            try {
                n = Double.parseDouble(str);
                break;
            } catch (NumberFormatException e) {
                System.out.print("数字输入错误,请重新输入:");
            }
        }
        return n;
    }

    public static char readConfirmSelection() {
        char c;
        for (; ; ) {
            String str = readKeyBoard(1, false).toUpperCase();
            c = str.charAt(0);
            if (c == 'Y' || c == 'N') {
                break;
            } else {
                System.out.print("选择错误,请重新输入:");
            }
        }
        return c;
    }

    /**
     * 从键盘读取一个长度不超过limit的字符串,并将其作为方法的返回值。
     * 如果用户不输入字符而直接回车,方法将以defaultValue 作为返回值。
     */
    public static String readString(int limit, String defaultValue) {
        String str = readKeyBoard(limit, true);
        return str.equals("") ? defaultValue : str;
    }

    public static String readString(int limit) {
        String str = readKeyBoard(limit, false);
        return str;
    }

    public static int readString(int limit, int defaultValue) {
        String str = readKeyBoard(limit, true);
        return str.equals("") ? defaultValue : Integer.parseInt(str);
    }

    public static double readString(int limit, double defaultValue) {
        String str = readKeyBoard(limit, true);
        return str.equals("") ? defaultValue : Double.parseDouble(str);
    }

    public static String readPhone(int limit, String defaultValue) {
        String str = readPhone(limit, true);
        return str.equals("") ? defaultValue : str;
    }


    public static String readKeyBoard(int limit, boolean blankReturn) {
        String line = "";
        while (scanner.hasNextLine()) {
            line = scanner.nextLine();
            if (line.length() == 0) {
                if (blankReturn) return line;
                else continue;
            }

            if (line.length() < 1 || line.length() > limit) {
                System.out.print("输入长度(不大于" + limit + ")错误,请重新输入:");
                continue;
            } else {

            }
            break;
        }

        return line;
    }

    /*
     * 输入电话号码的长度为11
     * */
    public static String readPhone(int limit, boolean blankReturn) {
        String phone = "";
        while (scanner.hasNextLine()) {
            phone = scanner.nextLine();
            if (phone.length() == 0) {
                if (blankReturn) return phone;
                else continue;
            }
            if (phone.length() != limit) {
                System.out.println("输入长度为" + limit + "输入错误,请重新输入:");
                continue;
            }
            break;
        }
        return phone;
    }


    /**
     * 键盘输入用户名和密码长度是否合法的方法
     */
    public static String user_readKeyBoard(int slimit, int blimit, boolean blankReturn) {
        String line = "";

        while (scanner.hasNextLine()) {
            line = scanner.nextLine();
            if (line.length() == 0) {
                if (blankReturn) return line;
                else continue;
            }
            //长度在slimit和blimit之间

            if (line.length() < slimit || line.length() > blimit) {
                System.out.print("输入长度(在" + slimit + "和" + blimit + "之间)错误,请重新输入:");
                continue;
            } else {

            }
            break;
        }

        return line;
    }
    public static String readUsername(String message, int maxLength, String startString) {
        Scanner scanner = new Scanner(System.in);
        String input;

        do {
            System.out.println(message);
            input = scanner.nextLine();
        } while (input.length() > maxLength || !input.startsWith(startString));

        return input;
    }

    //判断输入的是否为数字
    public static boolean isNumeric(String str) {
        if (str == null || str.length() == 0)
            return false;

        for (char c : str.toCharArray()) {
            if (!Character.isDigit(c)) {
                return false;
            }
        }
        return true;
    }
    /**
     * 一个显示加载的方法(可能为了好看吧)
     *
     * @throws InterruptedException
     */
    public static void loadSpecialEffects() throws InterruptedException {
        System.out.println("请稍等:");
        for (int i1 = 1; i1 <= 100; i1++) {
            System.out.print("加载中:" + i1 + "%");
            Thread.sleep(new Random().nextInt(25) + 1);
            if (i1 == 100) {
                Thread.sleep(50);
            }
            System.out.print("\r");
        }
    }
}

 完成该项目最大的收获就是,三层架构的实战,以及利用Git进行项目的合作,Git的操作等

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值