package com.zbf.web.controller.system;

import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zbf.common.annotation.Log;
import com.zbf.common.core.controller.BaseController;
import com.zbf.common.core.domain.AjaxResult;
import com.zbf.common.core.page.TableDataInfo;
import com.zbf.common.enums.BusinessType;
import com.zbf.common.utils.poi.ExcelUtil;
import com.zbf.system.domain.TCallNoticeOrder;
import com.zbf.system.service.ITCallNoticeOrderService;
import com.zbf.web.controller.section.EnhanceDataList;

/**
 * 【请填写功能名称】Controller
 *
 * @author tony
 * @date 2024-07-30
 */
@RestController
@RequestMapping("/system/callNoticeOrder")
public class TCallNoticeOrderController extends BaseController
{
    @Autowired
    private ITCallNoticeOrderService tCallNoticeOrderService;

/**
 * 查询【请填写功能名称】列表
 */
@PreAuthorize("@ss.hasPermi('system:order:list')")
@GetMapping("/list")
    public TableDataInfo list(TCallNoticeOrder tCallNoticeOrder)
    {
        startPage();
        List<TCallNoticeOrder> list = tCallNoticeOrderService.selectTCallNoticeOrderList(tCallNoticeOrder);
        return getDataTable(list);
    }

    
   /**
    * 查询通知单消息列表
    */
    @GetMapping("/selectList")
    @EnhanceDataList(entityType = TCallNoticeOrder.class)
    public AjaxResult selectList(TCallNoticeOrder tCallNoticeOrder)
    {
        List<TCallNoticeOrder> list = tCallNoticeOrderService.selectTCallNoticeOrderList(tCallNoticeOrder);
        List<TCallNoticeOrder> collect = list.stream().filter(c -> c.getTaskType().equals("0")).collect(Collectors.toList());
        return success(collect);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:order:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCallNoticeOrder tCallNoticeOrder)
    {
        List<TCallNoticeOrder> list = tCallNoticeOrderService.selectTCallNoticeOrderList(tCallNoticeOrder);
        ExcelUtil<TCallNoticeOrder> util = new ExcelUtil<TCallNoticeOrder>(TCallNoticeOrder.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tCallNoticeOrderService.selectTCallNoticeOrderById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:order:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCallNoticeOrder tCallNoticeOrder)
    {
        return toAjax(tCallNoticeOrderService.insertTCallNoticeOrder(tCallNoticeOrder));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:order:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCallNoticeOrder tCallNoticeOrder)
    {
        return toAjax(tCallNoticeOrderService.updateTCallNoticeOrder(tCallNoticeOrder));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:order:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tCallNoticeOrderService.deleteTCallNoticeOrderByIds(ids));
    }

    /**
     * 启用
     */
    @PreAuthorize("@ss.hasPermi('system:order:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @DeleteMapping("/disable/{ids}")
    public AjaxResult disable(@PathVariable String[] ids)
    {
        return toAjax(tCallNoticeOrderService.disabledTCallNoticeOrderByIds(ids));
    }

    /**
     * 禁用
     */
    @PreAuthorize("@ss.hasPermi('system:order:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @DeleteMapping("/enable/{ids}")
    public AjaxResult enable(@PathVariable String[] ids)
    {
        return toAjax(tCallNoticeOrderService.enableTCallNoticeOrderByIds(ids));
    }

    /**
     * 修改状态
     */
    @PreAuthorize("@ss.hasPermi('system:order:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody TCallNoticeOrder tCallNoticeOrder) {
        return toAjax(tCallNoticeOrderService.updateStatus(tCallNoticeOrder));
    }
}

