package com.dsk.web.controller.business;

import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.core.domain.entity.BusinessFollowRecord;
import com.dsk.common.core.page.TableDataInfo;
import com.dsk.system.domain.business.dto.BusinessIdDto;
import com.dsk.system.domain.business.dto.BusinessListDto;
import com.dsk.system.service.IBusinessFollowRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目跟进记录Controller
 *
 * @author lxl
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/business/record")
public class BusinessFollowRecordController extends BaseController
{
    @Autowired
    private IBusinessFollowRecordService businessFollowRecordService;



    /**
     * 查询关联项目
     */
    @GetMapping("/relate/project/{userId}")
    public AjaxResult selectRelateProject(@PathVariable("userId") Integer userId)
    {
        return success(businessFollowRecordService.selectRelateProject(userId));
    }

    /**
     * 查询关联业主企业
     */
    @GetMapping("/relate/company/{userId}")
    public AjaxResult selectRelateCompany(@PathVariable("userId") Integer userId)
    {
        return success(businessFollowRecordService.selectRelateCompany(userId));
    }

    /**
     * 新增项目跟进记录
     */
//    @PreAuthorize("@ss.hasPermi('system:record:add')")
//    @Log(title = "项目跟进记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusinessFollowRecord businessFollowRecord)
    {
        return toAjax(businessFollowRecordService.insertBusinessFollowRecord(businessFollowRecord));
    }

    /**
     * 分页查询项目跟进记录
     */
//    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessIdDto businessId)
    {
        startPage();
        List<BusinessFollowRecord> list = businessFollowRecordService.selectBusinessFollowRecordList(businessId);
        return getDataTable(list);
    }

    /**
     * 删除项目跟进记录
     */
//    @PreAuthorize("@ss.hasPermi('system:record:remove')")
//    @Log(title = "项目跟进记录", businessType = BusinessType.DELETE)
	@DeleteMapping("remove/{ids}")
    public AjaxResult remove(@PathVariable(value = "ids",required=false) Long[] ids)
    {
        return toAjax(businessFollowRecordService.deleteBusinessFollowRecordByIds(ids));
    }

    /**
     * 分页查询跟进动态
     */
//    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("all/list")
    public TableDataInfo allFollow(BusinessListDto dto)
    {
        startPage();
        List<BusinessFollowRecord> list = businessFollowRecordService.allFollow(dto);
        return getDataTable(list);
    }

//    /**
//     * 导出项目跟进记录列表
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:export')")
//    @Log(title = "项目跟进记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, BusinessFollowRecord businessFollowRecord)
//    {
//        List<BusinessFollowRecord> list = businessFollowRecordService.selectBusinessFollowRecordList(businessFollowRecord);
//        ExcelUtil<BusinessFollowRecord> util = new ExcelUtil<BusinessFollowRecord>(BusinessFollowRecord.class);
//        util.exportExcel(response, list, "项目跟进记录数据");
//    }

//    /**
//     * 获取项目跟进记录详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:query')")
//    @GetMapping(value = "/{id}")
//    public AjaxResult getInfo(@PathVariable("id") Long id)
//    {
//        return success(businessFollowRecordService.selectBusinessFollowRecordById(id));
//    }

//    /**
//     * 修改项目跟进记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:edit')")
//    @Log(title = "项目跟进记录", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody BusinessFollowRecord businessFollowRecord)
//    {
//        return toAjax(businessFollowRecordService.updateBusinessFollowRecord(businessFollowRecord));
//    }

    //    /**
//     * 根据项目id查询项目跟进记录
//     */
//    @PreAuthorize("@ss.hasPermi('system:record:list')")
//    @GetMapping("/list/{businessId}")
//    public TableDataInfo list(@PathVariable("businessId") Integer businessId)
//    {
//        startPage();
//        return getDataTable(businessFollowRecordService.selectBusinessFollowRecordList(businessId));
//    }

}
