智慧保安后台管理项目备份
Administrator
2021-11-30 6036a3f2b7fba39cb6ec2a6e2a61b5ee06d5076f
ftp mysql 连接修改
2 files modified
157 ■■■■■ changed files
src/main/java/org/springblade/modules/FTP/MysqlCenlint.java 155 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml 2 ●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/FTP/MysqlCenlint.java
@@ -38,34 +38,54 @@
        mysqlCenlint.userService = this.userService;
    }
    /**
     * sql 连接
     * @param sql
     */
    public static void sqlConnect(String sql,Integer type){
        String driver = "com.mysql.cj.jdbc.Driver";
        String url = sqlConnect; //换成要连接的数据库信息
        String user = "root";
        String password = "zhba0728";
        Connection conn = null;
        PreparedStatement ps = null;
        try {
            Class.forName ( driver );
            conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                String sqls = sql;
                ps = conn.prepareStatement ( sqls );
                //判断是否为修改,删除
                if (type==1){
                    //修改删除
                    ps.executeUpdate();
                }else {
                    //新增
                    ps.execute();
                }
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace ();
        }finally {
            try {
                ps.close();
                conn.close();
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }
    /**
     * 连接mysql数据库 新增
     * @param sql
     */
    public static void inster(String sql) {
        try {
            int ColumnCount;
            //int RowCount;
            String driver = "com.mysql.cj.jdbc.Driver";
            String url = sqlConnect; //换成要连接的数据库信息
            String user = "root";
            String password = "zhba0728";
            Class.forName ( driver );
            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                String sqls = sql; //sql
                PreparedStatement ps = conn.prepareStatement ( sqls );
                boolean execute = ps.execute();
                ps.close ();
                conn.close ();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
        sqlConnect(sql,2);
        try {
            Thread.sleep(300);
            //对比 sql 字符串,如果是是往用户表里插入保安员数据,则调用公安审查接口
@@ -77,7 +97,6 @@
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    /**
@@ -177,28 +196,29 @@
     * @param sql
     */
    public static void update(String sql) {
        try {
            int ColumnCount;
            //int RowCount;
            String driver = "com.mysql.cj.jdbc.Driver";
            String url = sqlConnect; //换成要连接的数据库信息
            String user = "root";
            String password = "zhba0728";
            Class.forName ( driver );
            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                String sqls = sql; //sql
                PreparedStatement ps = conn.prepareStatement ( sqls );
                ps.executeUpdate();
                ps.close ();
                conn.close ();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
        sqlConnect(sql,1);
//        try {
//            int ColumnCount;
//            //int RowCount;
//            String driver = "com.mysql.cj.jdbc.Driver";
//            String url = sqlConnect; //换成要连接的数据库信息
//            String user = "root";
//            String password = "zhba0728";
//            Class.forName ( driver );
//            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
//            if (!conn.isClosed ()) {
//                System.out.println ( "数据库连接成功:" );
//                String sqls = sql; //sql
//                PreparedStatement ps = conn.prepareStatement ( sqls );
//                ps.executeUpdate();
//                ps.close ();
//                conn.close ();
//            }
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace ();
//        } catch (SQLException e) {
//            e.printStackTrace ();
//        }
    }
    /**
@@ -206,28 +226,29 @@
     * @param sql
     */
    public static void delete(String sql) {
        try {
            int ColumnCount;
            //int RowCount;
            String driver = "com.mysql.cj.jdbc.Driver";
            String url = sqlConnect; //换成要连接的数据库信息
            String user = "root";
            String password = "zhba0728";
            Class.forName ( driver );
            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
            if (!conn.isClosed ()) {
                System.out.println ( "数据库连接成功:" );
                String sqls = sql; //sql
                PreparedStatement ps = conn.prepareStatement ( sqls );
                ps.executeUpdate();
                ps.close ();
                conn.close ();
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
        sqlConnect(sql,1);
//        try {
//            int ColumnCount;
//            //int RowCount;
//            String driver = "com.mysql.cj.jdbc.Driver";
//            String url = sqlConnect; //换成要连接的数据库信息
//            String user = "root";
//            String password = "zhba0728";
//            Class.forName ( driver );
//            Connection conn = (Connection) DriverManager.getConnection ( url, user, password );
//            if (!conn.isClosed ()) {
//                System.out.println ( "数据库连接成功:" );
//                String sqls = sql; //sql
//                PreparedStatement ps = conn.prepareStatement ( sqls );
//                ps.executeUpdate();
//                ps.close ();
//                conn.close ();
//            }
//        } catch (ClassNotFoundException e) {
//            e.printStackTrace ();
//        } catch (SQLException e) {
//            e.printStackTrace ();
//        }
    }
    /**
src/main/java/org/springblade/modules/system/mapper/UserMapper.xml
@@ -277,7 +277,7 @@
            and bu.hold = #{user.hold}
        </if>
        <if test="user.type!=null">
            and bu.equipment_code !="" and bu.equipment_code is not null and bu.equipment_code !=null
            and bu.equipment_code is not null
        </if>
        <if test="user.jurisdiction!=null and user.jurisdiction != '' and user.jurisdiction != '1372091709474910209'">
            and (sj.id = #{user.jurisdiction} or sj.parent_id = #{user.jurisdiction})