package com.dsk.web.controller.business;

import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.system.domain.business.BusinessBacklog;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.service.IBusinessBacklogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 项目工作待办Controller
 *
 * @author lxl
 * @date 2023-05-17
 */
@Api("项目工作待办")
@RestController
@RequestMapping("/business/backlog")
@Slf4j
public class BusinessBacklogController extends BaseController
{
    @Autowired
    private IBusinessBacklogService businessBacklogService;

    /**
     * 分页查询项目工作待办列表
     */
//    @PreAuthorize("@ss.hasPermi('system:backlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessBacklog businessBacklog)
    {
        startPage();
        return getDataTable(businessBacklogService.selectBusinessBacklogList(businessBacklog));
    }

    /**
     * 新增项目工作待办
     */
    @ApiOperation("新增项目工作待办")
//    @PreAuthorize("@ss.hasPermi('system:backlog:add')")
//    @Log(title = "项目工作待办", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusinessBacklog businessBacklog)
    {
        return toAjax(businessBacklogService.insertBusinessBacklog(businessBacklog));
    }

    /**
     * 修改项目工作待办
     */
//    @PreAuthorize("@ss.hasPermi('system:backlog:edit')")
//    @Log(title = "项目工作待办", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusinessBacklog businessBacklog)
    {
        return toAjax(businessBacklogService.updateBusinessBacklog(businessBacklog));
    }

    /**
     * 获取项目工作代办逾期数量
     */
    @GetMapping("/overdue/count/{businessId}")
    public AjaxResult overdueCount(@PathVariable Integer businessId)
    {
        return AjaxResult.success(businessBacklogService.overdueCount(businessId));
    }

//    /**
//     * 导出项目工作待办列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:backlog:export')")
//    @Log(title = "项目工作待办", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BusinessBacklog businessBacklog)
//    {
//        List<BusinessBacklog> list = businessBacklogService.selectBusinessBacklogList(businessBacklog);
//        ExcelUtil<BusinessBacklog> util = new ExcelUtil<BusinessBacklog>(BusinessBacklog.class);
//        util.exportExcel(response, list, "项目工作待办数据");
//    }

//    /**
//     * 获取项目工作待办详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:backlog:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(businessBacklogService.selectBusinessBacklogById(id));
//    }

//    /**
//     * 删除项目工作待办
//     */
//    @PreAuthorize("@ss.hasPermi('system:backlog:remove')")
//    @Log(title = "项目工作待办", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids)
//    {
//        return toAjax(businessBacklogService.deleteBusinessBacklogByIds(ids));
//    }
}
