From 41403ffdf90569e8b0a16aedf68d2e7e1f676727 Mon Sep 17 00:00:00 2001 From: p6xft4ki7 <2244365857@qq.com> Date: Wed, 6 Apr 2022 16:36:40 +0800 Subject: [PATCH] ADD file via upload --- 代码/OA/src/com/oa/action/ReplyAction.java | 80 ++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 代码/OA/src/com/oa/action/ReplyAction.java diff --git a/代码/OA/src/com/oa/action/ReplyAction.java b/代码/OA/src/com/oa/action/ReplyAction.java new file mode 100644 index 0000000..48f9e0a --- /dev/null +++ b/代码/OA/src/com/oa/action/ReplyAction.java @@ -0,0 +1,80 @@ +package com.oa.action; + +import java.util.Date; + +import org.apache.struts2.ServletActionContext; + +import com.oa.pojo.Reply; +import com.oa.pojo.Topic; +import com.oa.pojo.User; +import com.oa.service.ReplyService; +import com.oa.service.TopicService; +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.ModelDriven; + +public class ReplyAction extends ActionSupport implements ModelDriven{ + + private Long topicId; + private ReplyService replyService; + private TopicService topicService; + private Reply reply=new Reply(); + + public String addUI(){ + + Topic t=topicService.getById(topicId); + ActionContext.getContext().put("topic",t); + return "add"; + } + + //添加新回复 + public String add(){ + + Topic t=topicService.getById(topicId); + //封装信息 + reply.setTopic(t); + reply.setAuthor((User) ServletActionContext.getRequest().getSession().getAttribute("user")); + reply.setPostTime(new Date()); + reply.setIpAddr(ServletActionContext.getRequest().getRemoteAddr()); + replyService.save(reply); + return "toTopicShow"; + } + + //删除回复帖,涉及到引用问题,将回复贴改为 本回帖已删除 + public String delete(){ + Reply r=replyService.getById(reply.getId()); + r.setContent("此回帖已被管理员删除"); + replyService.update(r); + return "delete"; + } + + public Long getTopicId() { + return topicId; + } + + public void setTopicId(Long topicId) { + this.topicId = topicId; + } + + public ReplyService getReplyService() { + return replyService; + } + + public void setReplyService(ReplyService replyService) { + this.replyService = replyService; + } + + @Override + public Reply getModel() { + return reply; + } + + public TopicService getTopicService() { + return topicService; + } + + public void setTopicService(TopicService topicService) { + this.topicService = topicService; + } + +}