每日总结-23.4.19

发布时间 2023-04-19 19:55:48作者: lao_bing
    /* notice view
     * 更新消息是否查看过的状态为“已查看”
     * 输入参数为:id(String)即消息id
     * 返回类型为boolean,true为修改成功,false为未有记录或修改失败
     * */
    public boolean view(String id) throws Exception
    {
        Pd_notice pd = query(id);
        pd.setIsView("已查看");
        return modify(pd);
    }
    /* notice delete
     * 删除消息记录
     * 输入参数为:id(String)即消息id
     * 返回类型为boolean,true为删除成功,false为未有记录或删除失败
     * */
    public boolean delete(String id) throws Exception
    {
        if(query(id)!=null)
        {
            String sql = "delete from student where notice_id=?";
            PreparedStatement pre = connect.prepareStatement(sql);
            pre.setString(1,id);
            int count = pre.executeUpdate();
            pre.close();
            return true;
        }
        else
        {
            return false;
        }
    }
    /* notice delete all view
     * 删除所有已查看的消息记录
     * 输入参数:无
     * 返回类型:无
     * */
    public void deleteAllView() throws Exception
    {
        String sql = "delete from student where notice_isview='已查看'";
        PreparedStatement pre = connect.prepareStatement(sql);
        int count = pre.executeUpdate();
        pre.close();
    }



}