package org.dromara.main.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.main.domain.bo.CsTicketBo;
import org.dromara.main.domain.vo.CsTicketVo;
import org.dromara.main.service.ICsTicketService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/main/ticket")
public class CsTicketController extends BaseController {
    private final ICsTicketService ticketService;
    /** 查询客服工单列表 */
    @SaCheckPermission("main:ticket:list")
    @GetMapping("/list")
    public TableDataInfo<CsTicketVo> list(CsTicketBo bo, PageQuery pageQuery) {
        return ticketService.queryPageList(bo, pageQuery);
    }
    /** 获取客服工单详细信息 */
    @SaCheckPermission("main:ticket:query")
    @GetMapping("/{id}")
    public R<CsTicketVo> getInfo(@PathVariable String id) {
        return R.ok(ticketService.queryById(id));
    }
    /** 处理工单 */
    @SaCheckPermission("main:ticket:edit")
    @Log(title = "处理工单", businessType = BusinessType.UPDATE)
    @PutMapping("/process")
    public R<Void> process(@RequestBody CsTicketBo bo) {
        return toAjax(ticketService.handleTicket(bo));
    }
}
