?? digestdo.java
字號:
package com.lovo.servlet;
import java.io.IOException;
import java.sql.SQLException;
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 com.lovo.factory.BOFactory;
import com.lovo.po.PublishPO;
import com.lovo.po.UserPO;
public class DigestDO extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
HttpSession session = request.getSession(true);
String publishIdStr = request.getParameter("publishId");
int publishId = 0;
try {
publishId = Integer.parseInt(publishIdStr);
} catch(NumberFormatException e) {
response.sendRedirect("../web/error.jsp");
session.setAttribute("errorInfo", "數據傳輸錯誤");
return;
}
PublishPO publish = BOFactory.getPublishBOInstance().queryById(publishId);
boolean isSuc = BOFactory.getPublishBOInstance().digest(publish);
if(isSuc) {
UserPO user = BOFactory.getUserBOInstance().queryById(publish.getPublishMan().getId());
try {
int prestigeForDigestPub = BOFactory.getConfigBOInstance().queryVlaueByPurpose("精華帖獲得威望");
user.setPrestige(user.getPrestige() + prestigeForDigestPub);
boolean isModify = BOFactory.getUserBOInstance().modifyInfo(user);
if(!isModify) {
response.sendRedirect("../web/error.jsp");
session.setAttribute("errorInfo", "加精操作成功但是未能正確修改用戶信息");
return;
}
} catch (SQLException e) {
e.printStackTrace();
response.sendRedirect("../web/error.jsp");
session.setAttribute("errorInfo", "讀取配置信息出錯");
return;
}
response.sendRedirect("QueryBlockPublishDO");
} else {
response.sendRedirect("../web/error.jsp");
session.setAttribute("errorInfo", "加精操作不成功");
return;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -