校园兼职——与Mysql交互

本次项目改进了校园兼职平台,引入了发布兼职人员角色,允许发布和管理兼职信息,并需经过管理员审批。新增功能包括发布、查看、撤销兼职信息以及管理员审批和管理。采用三层架构,增强了系统稳定性和数据交互效率。

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

本次项目是基于上次的校园兼职的基础改进的,将之前的IO流转换成了Mysql,同时新增了一些需求。

 

相较于之前项目,提供了又一个新的角色,发布兼职人员。他的角色就相当于公司的招聘人员,可以根据公司需求,去这个平台上发布自己公司对应需要的兼职信息。

发布兼职人员基本功能:

  1. 可以对兼职信息进行发布
  2. 可以对自己发布的兼职信息进行查看(状态:未通过,已通过,未审批),还可以查看审核过关的信息是否有兼职人员已经接取。
  3. 可以对自己发布的兼职信息进行撤销

为了保证兼职人员的安全性,所有发布兼职人员发布的信息都需要管理员审批通过后才能展示给兼职人员,如果信息虚假可由管理员直接拒绝。

管理员添加的功能

  1. 可以对兼职信息进行审批
  2. 可以有审批通过的信息才能展示给兼职人员查看
  3. 可以发布兼职人员进行增,删,改,查

本次版本采用了三层架构的模式,新增了一个controller类,与根据该类的一些实现

ControllerDaoimpl类的实现:
public class ControllerDaoimpl implements ControllerDao {

    private JdbcTemplate runner = new JdbcTemplate(JDBCUtils.getDataSource());

    @Override
    public Controller query(String ID) {
        Controller controller = null;
        try {
            String sql = "select * from controller where ID=?";
            controller = runner.queryForObject(sql, new BeanPropertyRowMapper<>(Controller.class), ID);
        }catch (Exception e){
            return controller;
        }
        return controller;
    }

    @Override
    public Controller query2(String ID, String password) {
        Controller controller = null;
        try {
            String sql = "select * from controller where ID=? and password=?";
            controller = runner.queryForObject(sql, new BeanPropertyRowMapper<>(Controller.class), ID,password);
        }catch (Exception e){
            return controller;
        }
        return controller;
    }
    @Override
    public int insert(String ID, String name, String password, String sex, String phone) {
        int update = 0;
        try {
            String sql = "insert into controller values(?,?,?,?,?)";
            update = runner.update(sql,ID,name,password,sex,phone);

        }catch (Exception e){
            e.printStackTrace();
        }
        return update;
    }

    @Override
    public int delete(String ID) {
        int update =0;
        try {
            String sql = "delete from controller where ID=?";
            update = runner.update(sql, ID);
        }catch (Exception e){
            return update;
        }
        return update;
    }

    @Override
    public int update(String ID, String name, String password, String sex, String phone) {

        int update =0;
        try {
            String sql = "update controller set name=?,password=?,sex=?,phone =? where ID=?";
            update = runner.update(sql, name, password, sex, phone, ID);
        }catch (Exception e){

            return update;
        }
        return update;
    }

    @Override
    public List<Controller> query1() {
        List<Controller> list =null;
        try {
            String sql ="select * from controller";
            list = runner.query(sql, new BeanPropertyRowMapper<>(Controller.class));
        }catch (Exception e){
            return list;
        }
        return list;
    }

    @Override
    public List<Job> queryinformation(String ID) {

        List<Job> list =null;
        try {
            String sql = "select * from job where ID=?";
            list = runner.query(sql, new BeanPropertyRowMapper<>(Job.class), ID);
        }catch (Exception e){
            return list;
        }
        return list;
    }

    @Override
    public Job queryinformation1(String ID, String JID) {
        Job job =null;
        try{
            String sql ="select * from job where ID=? and JID=?";
            job = runner.queryForObject(sql, new BeanPropertyRowMapper<>(Job.class), JID, ID);
        }catch (Exception e){
            return job;
        }
        return job;
    }

    @Override
    public int deleteinformation(String JID) {
        int delete =0;
        try {
            String sql ="delete from job where JID =?";
            delete = runner.update(sql, JID);
        }catch (Exception e){
            return delete;
        }
        return delete;
    }

    @Override
    public int update(String JID) {
        int update =0;
        try {
            String sql ="update job set state=? where JID=?";
            update = runner.update(sql, 1, JID);
        }catch (Exception e){
            return update;
        }
        return update;
    }

    @Override
    public int update2(String JID) {
        int update =0;
        try {
            String sql ="update job set state=? where JID=?";
            update = runner.update(sql, 2, JID);
        }catch (Exception e){
            return update;
        }
        return update;
    }

    @Override
    public List<Job> query5(String ID) {
        List<Job> list =null;
        try {
            String sql = "select * from job where ID=?";
            list = runner.query(sql, new BeanPropertyRowMapper<>(Job.class), ID);
        }catch (Exception e){
            return list;
        }
        return list;
    }
}

通过本次项目,更加深入的了解三层架构的模式,也更加娴熟了与MYsql交互的操作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值