package com.fs.company.controller.qw;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.qw.domain.QwSession;
import com.fs.qw.service.IQwSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 企微会话Controller
 *
 * @author fs
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/qw/qwSession")
public class QwSessionController extends BaseController
{
    @Autowired
    private IQwSessionService qwSessionService;

    /**
     * 查询企微会话列表
     */
    @PreAuthorize("@ss.hasPermi('qw:qwSession:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwSession qwSession)
    {
        startPage();
        List<QwSession> list = qwSessionService.selectQwSessionList(qwSession);
        return getDataTable(list);
    }

    /**
     * 导出企微会话列表
     */
    @PreAuthorize("@ss.hasPermi('qw:qwSession:export')")
    @Log(title = "企微会话", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwSession qwSession)
    {
        List<QwSession> list = qwSessionService.selectQwSessionList(qwSession);
        ExcelUtil<QwSession> util = new ExcelUtil<QwSession>(QwSession.class);
        return util.exportExcel(list, "企微会话数据");
    }

    /**
     * 获取企微会话详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:qwSession:query')")
    @GetMapping(value = "/{sessionId}")
    public AjaxResult getInfo(@PathVariable("sessionId") Long sessionId)
    {
        return AjaxResult.success(qwSessionService.selectQwSessionBySessionId(sessionId));
    }

    /**
     * 新增企微会话
     */
    @PreAuthorize("@ss.hasPermi('qw:qwSession:add')")
    @Log(title = "企微会话", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwSession qwSession)
    {
        return toAjax(qwSessionService.insertQwSession(qwSession));
    }

    /**
     * 修改企微会话
     */
    @PreAuthorize("@ss.hasPermi('qw:qwSession:edit')")
    @Log(title = "企微会话", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwSession qwSession)
    {
        return toAjax(qwSessionService.updateQwSession(qwSession));
    }

    /**
     * 删除企微会话
     */
    @PreAuthorize("@ss.hasPermi('qw:qwSession:remove')")
    @Log(title = "企微会话", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sessionIds}")
    public AjaxResult remove(@PathVariable Long[] sessionIds)
    {
        return toAjax(qwSessionService.deleteQwSessionBySessionIds(sessionIds));
    }
}
