package com.dsk.biz.controller;

import com.dsk.biz.domain.BusinessBacklog;
import com.dsk.biz.domain.bo.BusinessBacklogListDto;
import com.dsk.biz.domain.vo.BusinessBacklogListVo;
import com.dsk.biz.service.IBusinessBacklogService;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.domain.PageQuery;
import com.dsk.common.core.domain.R;
import com.dsk.common.core.page.TableDataInfo;
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
 */
@RestController
@RequestMapping("/business/backlog")
@Slf4j
public class BusinessBacklogController extends BaseController
{
    @Autowired
    private IBusinessBacklogService businessBacklogService;

    /**
     * 分页查询项目工作待办列表
     */
//    @PreAuthorize("@ss.hasPermi('system:backlog:list')")
    @GetMapping("/list")
    public TableDataInfo<BusinessBacklogListVo> list(BusinessBacklogListDto dto, PageQuery pageQuery)
    {
        return businessBacklogService.selectBusinessBacklogList(dto, pageQuery);
    }

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

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

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