📄 adminservlet.java
字号:
/*
* Created on 2007-2-26
* Last modified on 2007-9-24
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.controller.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import com.yeqiangwei.club.util.MessageUtils;
import com.yeqiangwei.club.controller.action.AdAction;
import com.yeqiangwei.club.controller.action.AdminAction;
import com.yeqiangwei.club.controller.action.BasicInfoAction;
import com.yeqiangwei.club.controller.action.ForumAction;
import com.yeqiangwei.club.controller.action.GroupAction;
import com.yeqiangwei.club.controller.action.GroupOfForumAction;
import com.yeqiangwei.club.controller.action.NoAllowedCharAction;
import com.yeqiangwei.club.controller.action.RoleAction;
import com.yeqiangwei.club.controller.action.RuleAction;
import com.yeqiangwei.club.controller.action.SearchAction;
import com.yeqiangwei.club.controller.action.UserAction;
import com.yeqiangwei.club.exception.ClubException;
import com.yeqiangwei.club.module.music.service.DiscJockeyService;
import com.yeqiangwei.club.module.music.service.SongService;
import com.yeqiangwei.club.module.music.controller.ConfigAction;
import com.yeqiangwei.club.module.music.controller.form.DiscJockeyForm;
import com.yeqiangwei.club.release.ReleaseAction;
import com.yeqiangwei.club.service.ServiceLocator;
import com.yeqiangwei.club.service.ServiceWrapper;
import com.yeqiangwei.club.controller.action.AEmailAction;
import com.yeqiangwei.util.HttpServletUtils;
import com.yeqiangwei.util.ParamUtils;
import com.yeqiangwei.util.Validator;
public class AdminServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1951344751602884911L;
private static final Logger logger = Logger.getLogger(AdminServlet.class);
private ForumAction forumAction;
private UserAction userAction;
private RoleAction roleAction;
private RuleAction ruleAction;
private GroupAction groupAction;
private GroupOfForumAction groupOfForumAction;
private NoAllowedCharAction noAllowedCharAction;
private AdminAction adminAction;
private SearchAction searchAction;
private BasicInfoAction basicInfoAction;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException
{
String act = ParamUtils.getStringParameter(request,"act");
if(act.equals("forumDelete")){
this.getForumAction().delete(request,response);
}
else if(act.equals("groupDelete")){
this.getGroupAction().delete(request,response);
}
else if(act.equals("roleDelete")){
this.getRoleAction().delete(request,response);
}
else if(act.equals("adminDelete")){
this.getAdminAction().delete(request,response);
}
else if(act.equals("clearForumCache")){
this.getForumAction().clearCache(request,response);
}
else if(act.equals("ruleDelete")){
this.getRuleAction().delete(request,response);
}
else if(act.equals("groupOfForumDel")){
this.getGroupOfForumAction().delete(request,response);
}
else if(act.equals("logout")){
this.getAdminAction().logout(request,response);
}
else if(act.equals("forumLabelDelete")){
this.getAdminAction().forumLabelDelete(request,response);
}
else if(act.equals("indexState")){
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
out.write(this.getSearchAction().indexState());
out.close();
}
else if(act.equals("songAllowed")){
try {
this.getSongService().update(ParamUtils.getIntParameter(request,"songId"));
request.setAttribute("message",MessageUtils.getMessage("success"));
} catch (ClubException e) {
request.setAttribute("message",e.toString());
}
HttpServletUtils.forward(request,response,"songs.jsp");
}
else if(act.equals("adDeleteById")){
AdAction adAction = new AdAction();
adAction.deleteById(request,response);
}
else if(act.equals("adClearCache")){
AdAction adAction = new AdAction();
adAction.clearCache(request,response);
}
else if(act.equals("getReleaseState")){
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
ReleaseAction releaseAction = new ReleaseAction();
out.print(releaseAction.getReleaseState());
out.close();
}
else if(act.equals("getAEmailJsonObject")){
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(AEmailAction.getAEmailJsonObject());
out.close();
}
else if(act.equals("getEmailJsonObject")){
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(AEmailAction.getAEmailJsonObject());
out.close();
}
else{
logger.debug("act:"+act);
logger.debug("do nothing..........");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException{
response.setContentType("text/HTML;charset=UTF-8");
String act = ParamUtils.getStringParameter(request,"act");
if(act.equals("forumEdit")){
this.getForumAction().createOrUpdate(request,response);
}
else if(act.equals("forumMerge")){ //合并
this.getAdminAction().forumMerge(request,response);
}
else if(act.equals("createForumMenu")){
this.getForumAction().createForumMenu(request,response);
}
else if(act.equals("userGroup")){
this.getUserAction().updateGroupIdByUserIds(request,response);
}
else if(act.equals("roleEdit")){
this.getRoleAction().createOrUpdate(request,response);
}
else if(act.equals("roleDelete")){
this.getRoleAction().delete(request,response);
}
else if(act.equals("groupEdit")){
this.getGroupAction().createOrUpdate(request,response);
}
else if(act.equals("groupDelete")){
this.getGroupAction().delete(request,response);
}
else if(act.equals("ruleEdit")){
this.getRuleAction().createOrUpdate(request,response);
}
else if(act.equals("ruleDelete")){
this.getRuleAction().delete(request,response);
}
else if(act.equals("groupOfForumEdit")){
this.getGroupOfForumAction().createOrUpdate(request,response);
}
else if(act.equals("adminEdit")){
this.getAdminAction().createOrUpdate(request,response);
}
else if(act.equals("adminLogin")){
this.getAdminAction().login(request,response);
}
else if(act.equals("noAllowedChar")){
this.getNoAllowedCharAction().createOrUpdate(request,response);
}
else if(act.equals("basicInfo")){
this.getBasicInfoAction().createOrUpdate(request,response);
}
else if(act.equals("forumLabel")){
this.getAdminAction().forumLabel(request,response);
}
else if(act.equals("searchIndex")){
this.getSearchAction().indexUtils(request,response);
}
else if(act.equals("profile")){
this.getUserAction().aprofile(request,response);
}
else if(act.equals("addDj")){
DiscJockeyForm form = new DiscJockeyForm();
form.setUserId(ParamUtils.getIntParameter(request,"userId"));
form.setUserName(ParamUtils.getStringParameter(request,"userName"));
try {
this.getDiscJockeyService().create(form);
request.setAttribute("message",MessageUtils.getMessage("success"));
} catch (ClubException e) {
request.setAttribute("message",e.getMessage());
}
HttpServletUtils.forward(request,response,"discJockeys.jsp");
}
else if(act.equals("deleteDj")){
this.getDiscJockeyService().delete(request.getParameterValues("djId"));
request.setAttribute("message",MessageUtils.getMessage("success"));
HttpServletUtils.forward(request,response,"discJockeys.jsp");
}
else if(act.equals("updateMusicConfig")){
ConfigAction action = new ConfigAction(request,response);
action.update();
}
else if(act.equals("songAllowed")){
try {
this.getSongService().update(ParamUtils.getIntParameter(request,"songId"));
request.setAttribute("message",MessageUtils.getMessage("success"));
} catch (ClubException e) {
request.setAttribute("message",e.toString());
}
HttpServletUtils.forward(request,response,"songs.jsp");
}
else if(act.equals("adCreateOrUpdate")){
AdAction adAction = new AdAction();
adAction.createOrUpdate(request,response);
}
else if(act.equals("releaseIndex")){
ReleaseAction releaseAction = new ReleaseAction();
releaseAction.releaseIndex(request,response);
}
else if(act.equals("releaseList")){
ReleaseAction releaseAction = new ReleaseAction();
releaseAction.releaseList(request,response);
}
else if(act.equals("releasePages")){
ReleaseAction releaseAction = new ReleaseAction();
releaseAction.releasePages(request,response);
}
else if(act.equals("releaseStopAll")){
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
ReleaseAction releaseAction = new ReleaseAction();
releaseAction.releaseStopAll();
out.print(MessageUtils.getMessage("success"));
out.close();
}
else if(act.equals("sendAEmail")){
AEmailAction.sendEmail(request, response);
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(request.getAttribute("message"));
out.close();
}
else if(act.equals("stopSendAEmail")||act.equals("stopSendsEmail")){
AEmailAction.stopSendAEmail(request, response);
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(request.getAttribute("message"));
out.close();
}
else if(act.equals("sendsEmail")){
AEmailAction.sendsEmail(request, response);
response.setContentType("text/HTML;charset=UTF-8");
PrintWriter out = response.getWriter();
out.print(request.getAttribute("message"));
out.close();
}
else if(act.equals("deleteTopicByUserId")){
this.getAdminAction().deleteTopicByUserId(request, response);
}
else{
logger.debug("act:"+act);
logger.debug("do nothing..........");
}
}
public ForumAction getForumAction() {
if(Validator.isEmpty(forumAction)){
forumAction = new ForumAction();
}
return forumAction;
}
public RoleAction getRoleAction() {
if(Validator.isEmpty(roleAction)){
roleAction = new RoleAction();
}
return roleAction;
}
public UserAction getUserAction() {
if(Validator.isEmpty(userAction)){
userAction = new UserAction();
}
return userAction;
}
public GroupAction getGroupAction() {
if(Validator.isEmpty(groupAction)){
groupAction = new GroupAction();
}
return groupAction;
}
public RuleAction getRuleAction() {
if(Validator.isEmpty(ruleAction)){
ruleAction = new RuleAction();
}
return ruleAction;
}
public GroupOfForumAction getGroupOfForumAction() {
groupOfForumAction = new GroupOfForumAction();
return groupOfForumAction;
}
public AdminAction getAdminAction() {
if(Validator.isEmpty(adminAction)){
adminAction = new AdminAction();
}
return adminAction;
}
public NoAllowedCharAction getNoAllowedCharAction() {
if(Validator.isEmpty(noAllowedCharAction)){
noAllowedCharAction = new NoAllowedCharAction();
}
return noAllowedCharAction;
}
public BasicInfoAction getBasicInfoAction() {
if(Validator.isEmpty(basicInfoAction)){
basicInfoAction = new BasicInfoAction();
}
return basicInfoAction;
}
public SearchAction getSearchAction() {
if(Validator.isEmpty(searchAction)){
searchAction = new SearchAction();
}
return searchAction;
}
public DiscJockeyService getDiscJockeyService() {
return ServiceWrapper.<DiscJockeyService>getSingletonInstance(ServiceLocator.DISCJOCKEY);
}
public SongService getSongService() {
return ServiceWrapper.<SongService>getSingletonInstance(ServiceLocator.MUSIC_SONG);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -