📄 topicadminactionservice.java
字号:
int highlightTemp = highlight/10;
highLightVO.setBchecked((highlightTemp&4)>0);
highLightVO.setIchecked((highlightTemp&2)>0);
highLightVO.setUchecked((highlightTemp&1)>0);
highLightVO.setHighlight_color(highlight%10);
}
return highLightVO;
}
private TopicAdmin_MoveVO geFinalTopicAdmin_MoveVO(short groupid,Members member){
TopicAdmin_MoveVO topicAdmin_MoveVO = new TopicAdmin_MoveVO();
topicAdmin_MoveVO.setSelectContent(Common.forumselect(false, false,groupid,member!=null?member.getExtgroupids():"",null,false));
return topicAdmin_MoveVO;
}
private CloseOrOpenTopicVO getCloseOrOpenTopicVO(String[] moderates){
CloseOrOpenTopicVO closeOrOpenTopicVO = new CloseOrOpenTopicVO();
if(moderates.length!=1){
closeOrOpenTopicVO.setClose("2");
}else{
closeOrOpenTopicVO.setClose(((ThreadsDao)BeanFactory.getBean("threadsDao")).findByTid(Integer.valueOf(moderates[0])).getClosed().toString());
}
return closeOrOpenTopicVO;
}
private ToTopAndEliteVO geToTopAndEliteVO(Map<String,Object> transfersMap){
String[] moderates = (String[])transfersMap.get("moderates");
String operation = (String)transfersMap.get("operation");
ToTopAndEliteVO toTopAndEliteVO = new ToTopAndEliteVO();
if(operation.equals("stick")){
Integer allowstickthread = Integer.valueOf((String)transfersMap.get("allowstickthread"));
toTopAndEliteVO.setStickPurview(allowstickthread);
}
boolean showUnchain = false;
if(moderates.length==1){
Threads threads = ((ThreadsDao)BeanFactory.getBean("threadsDao")).findByTid(Integer.valueOf(moderates[0]));
if(operation.equals("stick")){
if(threads.getDisplayorder()!=0){
showUnchain = true;
toTopAndEliteVO.setLevel(threads.getDisplayorder().toString());
}else{
toTopAndEliteVO.setLevel("1");
}
}else{
if(threads.getDigest()!=0){
showUnchain = true;
toTopAndEliteVO.setLevel(threads.getDigest().toString());
}else{
toTopAndEliteVO.setLevel("1");
}
}
toTopAndEliteVO.setShowUnchain(showUnchain);
}else{
List<Integer> tidList = new ArrayList<Integer>();
for(String moderate : moderates){
tidList.add(Integer.valueOf(moderate));
}
List<Threads> threadsList = ((ThreadsDao)BeanFactory.getBean("threadsDao")).getThreadsByThreadIdList(tidList);
for (Threads threads : threadsList) {
if (operation.equals("stick")) {
if (threads.getDisplayorder() != 0) {
showUnchain = true;
break;
}
}else{
if (threads.getDigest() != 0) {
showUnchain = true;
break;
}
}
}
toTopAndEliteVO.setLevel("");
toTopAndEliteVO.setShowUnchain(showUnchain);
}
return toTopAndEliteVO;
}
public String removereward(Threads currentThread,Map<String,String> settingsMap,int currentUid){
int tid = currentThread.getTid();
int price = Math.abs(currentThread.getPrice());
if(currentThread.getSpecial()!=3 || currentThread.getPrice()>=0){
return "对不起,请确认是否是悬赏贴或者悬赏已经结束。";
}
DataBaseDao dataBaseDao = ((DataBaseDao)BeanFactory.getBean("dataBaseDao"));
List<Map<String,String>> sRewardlogResult = dataBaseDao.executeQuery("SELECT authorid, answererid FROM "+tableprefix+"rewardlog WHERE tid='"+tid+"'");
String authorid = null;
String answererid = null;
if(sRewardlogResult != null){
for(Map<String,String> tempMap : sRewardlogResult){
if(tempMap!=null&&!tempMap.get("authorid").equals("0")){
authorid = tempMap.get("authorid");
answererid = tempMap.get("answererid");
}
}
}
String creditstrans = settingsMap.get("creditstrans");
if(authorid!=null){
dataBaseDao.execute("UPDATE "+tableprefix+"members SET extcredits"+creditstrans+"=extcredits"+creditstrans+"+"+price+" WHERE uid='"+authorid+"'");
Common.updatepostcredits(Integer.valueOf(authorid), settingsMap.get("creditsformula"));
}
if(answererid!=null&&!answererid.equals("0")){
dataBaseDao.execute("UPDATE "+tableprefix+"members SET extcredits"+creditstrans+"=extcredits"+creditstrans+"-"+price+" WHERE uid='"+answererid+"'");
Common.updatepostcredits(Integer.valueOf(answererid), settingsMap.get("creditsformula"));
}
dataBaseDao.execute("UPDATE "+tableprefix+"threads SET special='0', price='0' WHERE tid='"+tid+"'");
dataBaseDao.execute("DELETE FROM "+tableprefix+"rewardlog WHERE tid='"+tid+"'");
return null;
}
public void repairTopic(Integer topicId){
PostsDao postsDao = ((PostsDao)BeanFactory.getBean("postsDao"));
Integer replies = postsDao.getCountOfReplyForTopic(topicId);
if(replies==-1){
System.out.println("IN TopicAdminActionService 主题 ID 不存在");
return ;
}
byte attachment = 0;
List<Map<String,String>> resultList = ((DataBaseDao)BeanFactory.getBean("dataBaseDao")).executeQuery("SELECT a.aid FROM "+tableprefix+"posts p, "+tableprefix+"attachments a WHERE a.tid="+topicId+" AND a.pid=p.pid AND p.invisible='0' LIMIT 1");
if(resultList!=null&&resultList.size()>0&&resultList.get(0).get("aid")!=null){
attachment = 1;
}
resultList = null;
Posts firstPosts = postsDao.getFirstPosts(topicId);
String subject = firstPosts.getSubject();
if(subject.length()>80){
subject = subject.substring(0,80);
}
firstPosts.setFirst((byte)1);
firstPosts.setSubject(subject);
Short rate = firstPosts.getRate();
if(rate!=0){
rate = Integer.valueOf((rate/Math.abs(rate.intValue()))).shortValue();
}
Posts lastPosts = postsDao.getLastPosts(topicId);
ThreadsDao threadsDao = ((ThreadsDao)BeanFactory.getBean("threadsDao"));
Threads threads = threadsDao.findByTid(topicId);
threads.setSubject(subject);
subject = null;
threads.setReplies(replies);
replies = null;
threads.setLastpost(lastPosts.getDateline());
threads.setLastposter(lastPosts.getAuthor());
lastPosts = null;
threads.setRate(rate.byteValue());
rate = null;
threads.setAttachment(attachment);
threadsDao.updateThreads(threads);
threads = null;
threadsDao = null;
postsDao.updatePosts(firstPosts);
postsDao.updatePostsByHQL("UPDATE Posts SET first=0 WHERE tid="+topicId+" AND pid<>"+firstPosts.getPid());
postsDao = null;
firstPosts = null;
}
private TopicClassVO geTopicClassVO(String fid){
TopicClassVO topicClassVO = new TopicClassVO();
Map<Integer,String> topicClassMap = topicClassVO.getTopicClassMap();
DataParse dataParse = new DataParse();
Forumfields forumfields = ((ForumfieldsDao)BeanFactory.getBean("forumfieldsDao")).findById(Short.valueOf(fid));
String threadTypes = forumfields.getThreadtypes();
Map resultMap = dataParse.characterParse(threadTypes, false);
if(resultMap!=null&&resultMap.size()>0){
Map<Integer,String> specialMap = (Map<Integer,String>)resultMap.get("special");
Map<Integer,String> typesMap = (Map<Integer,String>)resultMap.get("types");
Iterator<Integer> specialMapKeys = specialMap.keySet().iterator();
while(specialMapKeys.hasNext()){
Integer key = specialMapKeys.next();
String temp = specialMap.get(key);
if(temp.equals("0")){
topicClassMap.put(key, typesMap.get(key));
}
}
}
return topicClassVO;
}
public TopicPublicVO geTopicMergeVO(Map<String,Object> transfersMap){
Threads currentThread = (Threads)transfersMap.get("currentThread");
Forums currentForum = (Forums)transfersMap.get("currentforum");
String reasonpm = (String)transfersMap.get("reasonpm");
String[] modreasonsArray = ((String)transfersMap.get("modreasons")).split("\r\n");
TopicPublicVO topicMergeVO = new TopicPublicVO();
setTopicPublicVO(topicMergeVO, currentForum, currentThread, reasonpm, modreasonsArray);
return topicMergeVO;
}
public String operatingMerge(Map<String,Object> transfersMap){
Integer fid = (Integer)transfersMap.get("fid");
Threads operatingThread = (Threads)transfersMap.get("operatingThread");
Threads targetThread = (Threads)transfersMap.get("targetThread");
Members currentMember = (Members)transfersMap.get("currentMember");
String targetThreadName = targetThread.getSubject();
Integer targetTid = targetThread.getTid();
String operatingThreadName = operatingThread.getSubject();
Integer opseratingTid = operatingThread.getTid();
PostsDao postsDao = ((PostsDao)BeanFactory.getBean("postsDao"));
String operationE = "MRG";
int timestamp = Common.time();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String nowTime = dateFormat.format(timestamp*1000L);
List<Posts> postsList = postsDao.getPostsListByTid(targetThread.getTid());
for(Posts posts : postsList){
posts.setFid(operatingThread.getFid());
posts.setTid(operatingThread.getTid());
}
postsDao.updatePosts(postsList);
AttachmentsDao attachmentsDao = ((AttachmentsDao)BeanFactory.getBean("attachmentsDao"));
List<Attachments> attachmentList = attachmentsDao.getAttachmentListByTid(targetThread.getTid());
for(Attachments attachments : attachmentList){
attachments.setTid(operatingThread.getTid());
}
attachmentsDao.updateAttachment(attachmentList);
((ThreadsDao)BeanFactory.getBean("threadsDao")).deleteThreads(targetThread);
((ThreadsmodDao)BeanFactory.getBean("threadsmodDao")).deleteThreadsmod(targetThread.getTid());
((MythreadDao)BeanFactory.getBean("mythreadDao")).deleteMythread(targetThread.getTid());
((MypostsDao)BeanFactory.getBean("mypostDao")).deleteMyposts(targetThread.getTid());
List<Posts> postList = postsDao.getPostsListByTid(operatingThread.getTid());
List<Posts> firstPostsList = new ArrayList<Posts>();
for(Posts posts : postList){
if(posts.getFirst()==1){
firstPostsList.add(posts);
}
posts.setFirst((byte)0);
}
postsDao.updatePosts(postList);
Posts firstPost = postsDao.getFirstPosts(operatingThread.getTid());
firstPost.setFirst((byte)1);
for(Posts tempPosts : firstPostsList){
if(tempPosts.getPid().intValue()!=firstPost.getPid().intValue()){
tempPosts.setSubject(tempPosts.getSubject()+" (本主题由 "+currentMember.getUsername()+" 于 "+nowTime+" 合并)");
postsDao.updatePosts(tempPosts);
}
}
postsDao.updatePosts(firstPost);
operatingThread.setAuthor(firstPost.getAuthor());
operatingThread.setAuthorid(firstPost.getAuthorid());
operatingThread.setSubject(firstPost.getSubject());
operatingThread.setDateline(firstPost.getDateline());
operatingThread.setViews(operatingThread.getViews()+targetThread.getViews());
operatingThread.setReplies(operatingThread.getReplies()+targetThread.getReplies()+1);
operatingThread.setModerated((byte)1);
((ThreadsDao)BeanFactory.getBean("threadsDao")).updateThreads(operatingThread);
DataBaseDao dataBaseDao = (DataBaseDao)BeanFactory.getBean("dataBaseDao");
if(fid==targetThread.getFid().shortValue()){
dataBaseDao.execute("UPDATE "+tableprefix+"forums SET threads=threads-1 WHERE fid='"+fid+"'");
}else{
dataBaseDao.execute("UPDATE "+tableprefix+"forums SET threads=threads-1, posts=posts-"+postsList.size()+" WHERE fid='"+targetThread.getFid()+"'");
dataBaseDao.execute("UPDATE "+tableprefix+"forums SET posts=posts+"+postsList.size()+" WHERE fid='"+fid+"'");
}
List<Map<String,String>> tempML = dataBaseDao.executeQuery("SELECT name FROM "+tableprefix+"forums WHERE fid='"+fid+"'");
String currentForumsName = tempML!=null && tempML.size()>0 ? tempML.get(0).get("name") : "";
transfersMap.put("username", currentMember.getUsername());
transfersMap.put("adminId", currentMember.getAdminid());
transfersMap.put("forumName", currentForumsName);
transfersMap.put("uid",currentMember.getUid());
writeLog(transfersMap,currentForumsName, operatingThreadName,opseratingTid+"", operationE,timestamp);
List<Threads> threadsList = new ArrayList<Threads>();
threadsList.add(operatingThread);
Float timeoffset = (Float)transfersMap.get("timeoffset");
sendMessageToAuthor(transfersMap,currentForumsName, (String)transfersMap.get("url"), operationE, threadsList,timeoffset);
Forums targetForums = ((ForumsDao)BeanFactory.getBean("forumsDao")).findById(targetThread.getFid());
transfersMap.put("fid", targetForums.getFid());
transfersMap.put("forumName", targetForums.getName());
if(operatingThread.getAuthorid().byteValue()!=targetThread.getAuthorid().byteValue()){
List<Threads> threadsList2 = new ArrayList<Threads>();
threadsList2.add(targetThread);
sendMessageToAuthor(transfersMap,currentForumsName, (String)transfersMap.get("url"), operationE, threadsList2,timeoffset);
}
writeLog(transfersMap,currentForumsName, targetThreadName,targetTid+"", operationE,timestamp);
Common.updatemodworks((Map<String,String>)transfersMap.get("settingMap"), currentMember.getUid(), timestamp, operationE, (short)1);
Threadsmod threadsmod = new Threadsmod();
ThreadsmodId threadsmodId = new ThreadsmodId();
threadsmodId.setAction(operationE);
threadsmodId.setDateline(timestamp);
threadsmodId.setExpiration(0);
threadsmodId.setMagicid((short)0);
threadsmodId.setStatus((byte)1);
threadsmodId.setTid(operatingThread.getTid());
threadsmodId.setUid(currentMember.getUid());
threadsmodId.setUsername(currentMember.getUsername());
threadsmod.setId(threadsmodId);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -