CommentsController.java 2.68 KB
package com.cnlive.shenhe.controller;

import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.bean.SessionUser;
import com.cnlive.shenhe.serviceImpl.CommentsServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;


@Controller
@RequestMapping("/comments")
public class CommentsController {
    @Autowired
    AuditPass Pass;
    @Autowired
    CommentsServiceImpl commentsService;



    /**
     * 评论修改状态接口
     * @param json
     * @return
     */
    @PostMapping("/shenheComment")
    @ResponseBody
    public ResponseBean shenheInfo(@RequestBody JSONObject json,Integer id,HttpSession session){
        Pass.commentPass(json);
        SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
        String userId = sessionUser.getUserId();
        int i = commentsService.updateComment(json,id,userId);
        if(i==0){
            return  new ResponseBean(ErrorEnum.ERROR);
        }else {
            return new ResponseBean(ErrorEnum.SUCCESS);
        }
    }

    /**
     * 评论列表页
     * @param activity_id
     * @param content
     * @param is_hot
     * @param start_date
     * @param end_date
     * @param state
     * @param auditor
     * @param page
     * @param pageSize
     * @param orderByClause
     * @return
     */
    @RequestMapping("/page")
    @ResponseBody
    public Object getListComments(String activity_id, String content, Integer is_hot, String start_date, String end_date, Integer state, String auditor, Integer page, Integer pageSize, String orderByClause, HttpSession session){
        SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
        Integer spid = sessionUser.getSpid();
        if(CommonUtils.isNull(page))page=1;
        if(CommonUtils.isNull(pageSize))pageSize=10;
        return  commentsService.getListComments(activity_id,content,is_hot,start_date,end_date,state,auditor,page,pageSize,orderByClause,spid);
    }

    /**
     * 评论查看接口
     * @param id
     * @return
     */
    @RequestMapping("/details")
    @ResponseBody
    public Object getDetailsComments(Integer id){
        return  commentsService.getDetailsComment(id);
    }
}