首页>代码>基于SSM的酒店管理系统的设计与实现(分前后台)>/hotel-management-system/src/main/java/cn/edu/glut/jiudian/controller/CommentController.java
package cn.edu.glut.jiudian.controller;

import cn.edu.glut.jiudian.entity.Comment;
import cn.edu.glut.jiudian.service.CommentService;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;

/**
 * @author stone(huangshizhang) at 2019-06-11 15:59
 */
@Controller
public class CommentController {

    @Autowired
    private CommentService commentService;

    private  List<Comment> commentList = null;


    private  List<Comment> geRoomComment = null;

    @RequestMapping("roomCommentList")
    @ResponseBody
    public Object roomCommentList(@RequestParam("roomId") String roomId){
        commentList = commentService.getRoomComment(roomId);

        //HashMap<String, List<Comment>> res = new HashMap<>();
        //res.put("commentList", commentList);
        return "1";
    }

    @RequestMapping("geRoomComment")
    @ResponseBody
    public Object geRoomComment(@RequestParam("roomId") String roomId){
        geRoomComment = commentService.getRoomComment(roomId);

        //HashMap<String, List<Comment>> res = new HashMap<>();
        //res.put("commentList", commentList);
        return "1";
    }

    @RequestMapping("comment_management.html")
    public ModelAndView commentManagement(){
        ModelAndView mav = new ModelAndView("comment_management");
        mav.addObject("commentList", geRoomComment);
        return mav;
    }

    @RequestMapping("room_comment.html")
    public ModelAndView modalRoomComment(){
        ModelAndView mav = new ModelAndView("room_comment");
        mav.addObject("commentList", commentList);
        return mav;
    }

    @RequestMapping("addRoomComment")
    @ResponseBody
    public Object addRoomComment(Comment comment){

        comment.setReleaseTime(new java.sql.Date(new java.util.Date().getTime()));

        HashMap<String, String> res = new HashMap<>();
        if (commentService.addComment(comment)) {
            res.put("stateCode", "1");
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }

    @RequestMapping("write_comment.html")
    public ModelAndView writeComment(){
        return new ModelAndView("write_comment");
    }

    @RequestMapping("deleteComment")
    @ResponseBody
    public Object deleteComment(@RequestParam("serNum") Integer serNum, @RequestParam("roomId") String roomId){

        Comment comment = new Comment();

        comment.setSerNum(serNum);
        comment.setContent("");

        HashMap<String, List<Comment>> res = new HashMap<>();
        if (commentService.updateByPrimaryKey(comment)) {
            List<Comment> commentList1 = commentService.getRoomComment(roomId);
            res.put("commentList", commentList1);
            return res;
        } else {
            return false;
        }
    }
}
最近下载更多
唐唐丶  LV34 2月17日
_nrxsh  LV12 2024年7月3日
樱花味小然子  LV5 2024年6月21日
ewan007  LV30 2024年5月21日
wanglinddad  LV55 2024年5月10日
Boss绝  LV9 2024年4月16日
mzqnxyh  LV2 2024年4月12日
wbw123  LV5 2024年4月2日
微信网友_6927932988952576  LV12 2024年3月30日
qiang123  LV8 2024年3月2日
最近浏览更多
zq1685  LV4 前天
武诗雨  LV1 6月4日
Anonly  LV2 5月26日
gggggg343434  LV1 5月24日
SX520886  LV6 4月24日
shuaiqi 4月22日
暂无贡献等级
luhong  LV4 3月31日
漫步的南瓜  LV1 3月28日
暂无贡献等级
docnnxxy688 3月22日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友