package com.ruoyi.project.system.controller;

import java.util.Date;
import java.util.List;

import com.ruoyi.project.common.domain.TCommonfile;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysUserNotice;
import com.ruoyi.project.system.service.ISysUserNoticeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户通知关联Controller
 *
 * @author ruoyi
 * @date 2021-10-15
 */
@RestController
@RequestMapping("/system/userNotice")
public class SysUserNoticeController extends BaseController
{
    @Autowired
    private ISysUserNoticeService sysUserNoticeService;

    /**
     * 查询用户通知关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:userNotice:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysUserNotice sysUserNotice)
    {
        startPage();
        List<SysUserNotice> list = sysUserNoticeService.selectSysUserNoticeList(sysUserNotice);
        return getDataTable(list);
    }

    /**
     * 导出用户通知关联列表
     */
    /*@PreAuthorize("@ss.hasPermi('system:userNotice:export')")
    @Log(title = "用户通知关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysUserNotice sysUserNotice)
    {
        List<SysUserNotice> list = sysUserNoticeService.selectSysUserNoticeList(sysUserNotice);
        ExcelUtil<SysUserNotice> util = new ExcelUtil<SysUserNotice>(SysUserNotice.class);
        return util.exportExcel(list, "userNotice");
    }*/

    /**
     * 获取用户通知关联详细信息
     */
    /*@PreAuthorize("@ss.hasPermi('system:userNotice:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(sysUserNoticeService.selectSysUserNoticeById(userId));
    }*/

    /**
     * 新增用户通知关联
     */
    @Log(title = "用户通知关联", businessType = BusinessType.INSERT)
    @GetMapping(value = "/insertReadHis/{noticeId}")
    public AjaxResult add(@PathVariable Long noticeId)
    {
        SysUserNotice sysUserNotice = new SysUserNotice();
        sysUserNotice.setNoticeId(noticeId);
        sysUserNotice.setUserId(this.getUserId());
        sysUserNotice.setCreateTime(new Date());
        return toAjax(sysUserNoticeService.insertSysUserNotice(sysUserNotice));
    }

    /**
     * 修改用户通知关联
     */
    /*@PreAuthorize("@ss.hasPermi('system:userNotice:edit')")
    @Log(title = "用户通知关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserNotice sysUserNotice)
    {
        return toAjax(sysUserNoticeService.updateSysUserNotice(sysUserNotice));
    }*/

    /**
     * 删除用户通知关联
     */
    /*@PreAuthorize("@ss.hasPermi('system:userNotice:remove')")
    @Log(title = "用户通知关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysUserNoticeService.deleteSysUserNoticeByIds(userIds));
    }*/

//    /**
//     * 查询通用附件列表
//     */
//    @GetMapping("/allFileList")
//    public List<SysUserNotice> allFileList(SysUserNotice sysUserNotice)
//    {
//        List<SysUserNotice> list = sysUserNoticeService.selectAllFileList(sysUserNotice);
//        return list;
//    }
}
