//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.luozhihui.project.controller;

import com.luozhihui.project.common.ApiResponse;
import com.luozhihui.project.entity.Comment;
import com.luozhihui.project.mapper.CommentMapper;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/api"})
@CrossOrigin
public class CommentController {
    @Resource
    CommentMapper commentMapper;

    public CommentController() {
    }

    @CrossOrigin
    @PostMapping({"/comment"})
    public ApiResponse postComment(Comment comment) {
        this.commentMapper.save(comment);
        return new ApiResponse((Object)null, 200, "发布成功");
    }

    @CrossOrigin
    @PostMapping({"/AllComment"})
    public ApiResponse AllComment() {
        try {
            List<Comment> comment = this.commentMapper.FindAllComment();
            return comment != null ? new ApiResponse(comment, 200, "查询成功") : new ApiResponse((Object)null, 404, "未找到");
        } catch (Exception var2) {
            Exception e = var2;
            e.printStackTrace();
            return new ApiResponse((Object)null, 500, "服务器内部错误");
        }
    }
}
