微信小程序仿知乎实现评论留言功能(2)

package com.melon.haul.web; import java.sql.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import net.sf.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.melon.haul.dto.DataUtil; import com.melon.haul.dto.GetLocation; import com.melon.haul.dto.Result; import com.melon.haul.entity.Comment; import com.melon.haul.entity.District; import com.melon.haul.entity.Source; import com.melon.haul.service.CommentService; import com.melon.haul.service.DistrictService; import com.melon.haul.service.SourceService; @Controller @WebAppConfiguration @RequestMapping("/Comment") public class CommentController { private Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private CommentService commentService; @RequestMapping(value = "/getComments", method = RequestMethod.POST) private @ResponseBody List<Comment> getComments(@RequestParam("sourceId") int sourceId, @RequestParam("limited") int limited,@RequestParam("offset") int offset) { logger.info("getComments"); List<Comment> list = new ArrayList<Comment>(); try{ list = commentService.getComment(sourceId, limited, offset); }catch(Exception e){ } return list; } @RequestMapping(value = "/insertComment", method = RequestMethod.POST) private @ResponseBody Result<Map<String,String>>insertComment(@RequestParam("sourceId") String sourceId, @RequestParam("comment") String comment,@RequestParam("userId") int userId, @RequestParam("userName") String userName,@RequestParam("replyCommentId") String replyCommentId, @RequestParam("replyUserName") String replyUserName,@RequestParam("userPhoto")String userPhoto) { logger.info("insertComment"); Map<String, String> resultMap = new HashMap<String, String>(); try{ Integer rCId = -1; if(!replyCommentId.equals("")) rCId = Integer.parseInt(replyCommentId); commentService.insertComment(Integer.parseInt(sourceId), comment, userId,userName,rCId,replyUserName,userPhoto); resultMap.put("msg", "insertComment success"); }catch(Exception e){ System.out.print(e); resultMap.put("msg", "insertComment error"); } return new Result<Map<String, String>>(true, resultMap); } @RequestMapping(value = "/deleteComment", method = RequestMethod.POST) private @ResponseBody Result<Map<String,String>>deleteComment(@RequestParam("commentId") String commentId) { logger.info("deleteComment"); Map<String, String> resultMap = new HashMap<String, String>(); try{ commentService.deleteComment(commentId); resultMap.put("msg", "deleteComment success"); }catch(Exception e){ System.out.print(e); resultMap.put("msg", "deleteComment error"); } return new Result<Map<String, String>>(true, resultMap); } }

公共CSS(app.wxss)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/fdc58d5f1a882ba55c2f8cf50a964bcb.html