package com.hssx.pcbms.controller;


import com.hssx.pcbms.entity.NewsNotice;
import com.hssx.pcbms.entity.Score;
import com.hssx.pcbms.service.NewsNoticeService;
import com.hssx.pcbms.util.HttpRespMsg;
import com.hssx.pcbms.util.PageUtil;
import io.swagger.annotations.ApiOperation;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 吴涛涛
 * @since 2019-11-06
 */
@Controller
@RequestMapping("/newsnotice")
public class NewsNoticeController {
    @Autowired
    private NewsNoticeService newsNoticeService;

    /**
     * 获取消息列表
     * 参数：
     *      uid:用户id,pageNum:当前页，pageSize：每页多少条
     * @return
     */
    @ApiOperation(value = "获取消息列表", notes = "获取消息列表")
    @RequestMapping("/getNewsList")
    @ResponseBody
    public HttpRespMsg getNewsList(Integer uid, PageUtil page) {
        HttpRespMsg msg = new HttpRespMsg();
        try {
            msg = newsNoticeService.getNewsList(uid,page);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return msg;
    }

    /**
     * 获取未读消息数量
     * 参数：
     *      uid:用户id
     * @return
     */
    @ApiOperation(value = "获取消息列表", notes = "获取消息列表")
    @RequestMapping("/getNoReadNewsCount")
    @ResponseBody
    public HttpRespMsg getNoReadNewsCount(Integer uid) {
        HttpRespMsg msg = new HttpRespMsg();
        try {
            msg = newsNoticeService.getNoReadNewsCount(uid);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return msg;
    }

}

