📄 personal.java
字号:
package ntsky.news;
import java.sql.*;
import ntsky.database.*;
public class Personal{
private String time=null;
private ResultSet rs=null;
private int purview;
private String popedom=null;
private int total;
//上次登陆时间
public String time(String user){
try{
String sql = "select * from usr where user='"+user+"';";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
rs.next();
time = rs.getString("loadtime");
}
catch(Exception e){
System.out.print("time" +e.getMessage());
}
return time;
}
//发表文章总数
public int articlenum(String user){
try{
String sql = "select count(*) as article_total from article where author='"+user+"' and state=1 and tag=1;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs!=null){
rs.next();
total = rs.getInt("article_total");
}else
total=0;
}
catch(Exception e){
System.out.print("total" +e.getMessage());
}
return total;
}
//权限
public String popedom(){
try{
DBConnect dbc = new DBConnect();
if(total<=10){
purview = 1;
String sql = "select * from popedom where gradeid="+purview+";";
ResultSet rs = dbc.executeQuery(sql);
rs.next();
popedom = rs.getString("grade");
}
else{
if((total>10)&&(total<=30)){
purview = 2;
String sql = "select * from popedom where gradeid="+purview+";";
ResultSet rs = dbc.executeQuery(sql);
rs.next();
popedom = rs.getString("grade");
}else{
if(total>30){
purview = 3;
String sql = "select * from popedom where gradeid="+purview+";";
ResultSet rs = dbc.executeQuery(sql);
rs.next();
popedom = rs.getString("grade");
}
}
}
}catch(Exception e){
System.out.print("popedom "+e.getMessage());
}
return popedom;
}
//更新权限
public void uppurview(String user){
try{
String sql_popedom = "select gradeid,grade from popedom where grade=?;";
DBConnect dbc_popedom = new DBConnect(sql_popedom);
dbc_popedom.setString(1,popedom);
rs = dbc_popedom.executeQuery();
rs.next();
int gradeid = rs.getInt("gradeid");
String sql = "update usr set purview='"+gradeid+"' where user='"+user+"';";
DBConnect dbc = new DBConnect();
dbc.executeUpdate(sql);
}catch(Exception e){
System.out.print("uppurview "+e.getMessage());
}
}
//更新下登陆时间
public void updatetime(String user){
try{
String sql = "update usr set loadtime=now() where user='"+user+"';";
DBConnect dbc = new DBConnect();
dbc.executeUpdate(sql);
}
catch(Exception e){
System.out.println("updatetime" +e.getMessage());
}
}
//用户发表的文章(审核)
public ResultSet rs_article(String sessionuser){
try{
String sql = "select * from article where author='"+sessionuser+"' and state=1 and tag=1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.println("updatetime" +e.getMessage());
}
return rs;
}
/**
*用户发表的文章(未审核)
*/
//未审核文章总数
public int articleunnum(String user){
try{
String sql = "select count(*) as article_total from article where author='"+user+"' and state=0 and tag=1;";
DBConnect dbc = new DBConnect();
rs=dbc.executeQuery(sql);
if(rs!=null){
rs.next();
total = rs.getInt("article_total");
}else
total=0;
}
catch(Exception e){
System.out.print("total" +e.getMessage());
}
return total;
}
//文章纪录
public ResultSet rs_unarticle(String sessionuser){
try{
String sql = "select * from article where author='"+sessionuser+"' and state=0 and tag=1;";
DBConnect dbc = new DBConnect();
rs = dbc.executeQuery(sql);
}
catch(Exception e){
System.out.println("updatetime" +e.getMessage());
}
return rs;
}
//关闭指针
public void close() throws Exception{
if(rs != null){
rs.close();
rs = null;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -