Пример #1
0
 public String get() {
   try {
     Title title = titleService.findById(model.getTitleId());
     TitleVO titleVO = PO2VO(title);
     JSONprint(JSONSupport.json(titleVO));
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Пример #2
0
 public void searchTitle() {
   List<Userpost> userposts = userPostService.findByTitle("%" + matchInfo + "%", matchCount);
   List<UserpostVO> userpostVOs = new ArrayList<UserpostVO>();
   MyBeanUtils.copyList(userpostVOs, userposts, UserpostVO.class);
   Json json = new Json();
   json.setObj(userpostVOs);
   json.setSuccess(true);
   try {
     JSONprint(JSONSupport.json(json));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #3
0
 public void add() {
   model.setUser(getCurrentUser());
   model.setPosttype(postTypeService.findById(posttypeId));
   model.setPostlabel(labelService.findById(postlabelId));
   model.setPostTime(new Timestamp(System.currentTimeMillis()));
   model.setReplyTime(model.getPostTime());
   userPostService.save(model);
   Json json = new Json();
   json.setSuccess(true);
   json.setMsg(model.getPostId() + "");
   try {
     JSONprint(JSONSupport.json(json));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #4
0
 /**
  * 获取数据
  *
  * @return
  */
 @SuppressWarnings("unchecked")
 public String getData() {
   try {
     if (model.getTitleName().equals("undefined")) {
       model.setTitleName("");
     }
     titles = titleService.findTitlePage(currentPage, 10, model.getTitleName());
     List<Title> list = (List<Title>) titles.getRecordList();
     List<TitleVO> titleVOs = new ArrayList<TitleVO>();
     for (Title title : list) {
       titleVOs.add(PO2VO(title));
     }
     titles.setRecordList(titleVOs);
     JSONprint(JSONSupport.json(titles));
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Пример #5
0
 // 回复
 public void answer() {
   Reply reply = new Reply();
   // test user
   User user = getCurrentUser();
   reply.setUser(user);
   if (questionId != null) {
     Userpost question = userPostService.findById(questionId); // 用户
     question.setReplyNumber(
         question.getReplyNumber() == null ? 1 : question.getReplyNumber() + 1);
     reply.setUserpost(question);
   }
   if (replyContext.matches("回复  .+: ?(.*)")) {
     replyContext = replyContext.replaceAll("回复  .+: ?(.*)", "$1");
   }
   reply.setReplyContext(replyContext);
   reply.setReplyNumber(0);
   // 用户回帖数加1
   Userinfo userinfo = reply.getUser().getUserinfo();
   userinfo.setReplyNumber(userinfo.getReplyNumber() == null ? 1 : userinfo.getReplyNumber() + 1);
   if (replyFatherId != null) {
     reply.setReply(replyService.findById(replyFatherId));
   }
   reply.setReplyTime(new Timestamp(System.currentTimeMillis()));
   reply.setStatus(0); // 有新回复
   replyService.save(reply);
   ReplyVO replyVO = new ReplyVO();
   MyBeanUtils.copy(replyVO, reply);
   if (reply.getReply() != null) {
     replyVO.setUserName(reply.getReply().getUser().getUserName());
   }
   UserVO userVO = new UserVO();
   MyBeanUtils.copy(userVO, reply.getUser());
   replyVO.setUserVO(userVO);
   Json json = new Json();
   json.setSuccess(true);
   json.setObj(replyVO);
   try {
     JSONprint(JSONSupport.json(json));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }