package com.ruoyi.cms.controller.app;

import com.ruoyi.cms.domain.Job;
import com.ruoyi.cms.domain.Notice;
import com.ruoyi.cms.service.IAppNoticeService;
import com.ruoyi.common.annotation.BussinessLog;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/notice")
@Api(tags = "移动端:消息")
public class AppNoticeInfoController extends BaseController {

    @Autowired
    private IAppNoticeService appNoticeService;
    @ApiOperation("消息列表")
    @GetMapping("/info")
    public AjaxResult listNotRead(@RequestParam(required = false) Integer isRead)
    {
        List<Notice> appNoticeVO = appNoticeService.listNotRead(isRead);
        return AjaxResult.success(appNoticeVO);
    }
    @ApiOperation("推荐岗位列表")
    @GetMapping("/recommend")
    public TableDataInfo recommend(@RequestParam(required = false)String jobTitle)
    {
        startPage();
        List<Job> list = appNoticeService.recommend(jobTitle);
        return getDataTable(list);
    }
    @ApiOperation("系统通知已读")
    @PostMapping("/read/sysNotice")
    @BussinessLog(title = "系统通知标记已读")
    public AjaxResult sysNotice(@RequestParam String id)
    {
        appNoticeService.sysNotice(id);
        return AjaxResult.success();
    }
    @ApiOperation("岗位推荐、招聘会已读")
    @PostMapping("/read")
    @BussinessLog(title = "岗位推荐、招聘会已读标记已读")
    public AjaxResult read(@RequestParam String id)
    {
        appNoticeService.read(id);
        return AjaxResult.success();
    }
    @ApiOperation("系统通知列表")
    @GetMapping("/sysNotice")
    public TableDataInfo sysNoticeList()
    {
        startPage();
        List<Notice> list = appNoticeService.sysNoticeList();
        return getDataTable(list);
    }
}
