贡献值满,升级
This commit is contained in:
@@ -349,15 +349,19 @@ public class UserDao {
|
||||
|
||||
public void LevelUp(String username){
|
||||
String sql = "UPDATE user SET userLevel = userLevel+1 WHERE userName = ? AND contributionValue >= 100;";
|
||||
String sql1 = "UPDATE user SET contributionValue = 0;";
|
||||
String sql1 = "UPDATE user SET contributionValue = 0 WHERE userName = ?;";
|
||||
try{
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
Connection conn1 = JdbcUtils.getConnection();
|
||||
PreparedStatement prep = conn.prepareStatement(sql);
|
||||
PreparedStatement prep1 = null;
|
||||
prep.setString(1, username);
|
||||
prep.executeUpdate();
|
||||
PreparedStatement prep1 = conn1.prepareStatement(sql1);
|
||||
prep1.executeUpdate();
|
||||
int match = prep.executeUpdate();
|
||||
if(match == 1){
|
||||
prep1 = conn1.prepareStatement(sql1);
|
||||
prep1.setString(1, username);
|
||||
prep1.executeUpdate();
|
||||
}
|
||||
JdbcUtils.closeConnection(prep,conn);
|
||||
JdbcUtils.closeConnection(prep1,conn1);
|
||||
}catch(SQLException e){
|
||||
|
@@ -3,11 +3,11 @@ package com.hellogithub.servlet;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hellogithub.entity.userEntity;
|
||||
import com.hellogithub.service.UserService;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import java.io.IOException;
|
||||
|
Reference in New Issue
Block a user