package com.withstars.controller; import com.withstars.domain.Reply; import com.withstars.service.impl.ReplyServiceImpl; import com.withstars.service.impl.UserServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import java.io.UnsupportedEncodingException; import java.util.Date; /** * 回复相关控制类 */ @Controller public class ReplyController { @Autowired public ReplyServiceImpl replyService; @Autowired public UserServiceImpl userService; /** * 添加评论 */ @RequestMapping(value = "/reply/add",method = RequestMethod.POST) public ModelAndView addReply(HttpServletRequest request, HttpSession session){ try { request.setCharacterEncoding("utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } //处理参数 Integer topicId=Integer.parseInt(request.getParameter("topicId")); Integer replyUserId=Integer.parseInt(request.getParameter("replyUserId")); String content=request.getParameter("content"); //创建reply Reply reply=new Reply(); reply.setTopicId(topicId); reply.setReplyUserId(replyUserId); reply.setContent(content); reply.setCreateTime(new Date()); reply.setUpdateTime(new Date()); //执行添加 boolean ifSucc=replyService.addReply(reply); //添加积分 boolean ifSuccAddCredit=userService.addCredit(1,replyUserId); //新建视图 ModelAndView view=new ModelAndView("redirect:/t/"+topicId); return view; } }
最近下载更多
2131234536546 LV7
3月31日
xiaopengzep LV1
3月24日
wanglinddad LV55
3月11日
qq573914838 LV5
3月5日
THyper LV2
3月1日
罗清晨 LV12
2月21日
lovelyy LV11
2月1日
qwe6002 LV9
1月11日
XiaoSong888 LV2
1月10日
lilong007 LV20
2023年12月30日
最近浏览更多
来一杯西瓜冰咩 LV1
5月6日
之额着 LV3
4月23日
getset LV8
4月20日
tassel_2024
4月14日
暂无贡献等级
微信网友_6444139264921600 LV6
4月13日
玖零定制问题修复 LV34
4月4日
wddq123
4月2日
暂无贡献等级
2131234536546 LV7
3月31日
xiaopengzep LV1
3月24日
953558449
3月22日
暂无贡献等级