package com.dsk.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.dsk.common.core.domain.entity.BusinessFollowRecord;
import com.dsk.system.domain.BusinessIdDto;
import com.dsk.system.service.IBusinessFollowRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dsk.common.annotation.Log;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.enums.BusinessType;
import com.dsk.common.utils.poi.ExcelUtil;
import com.dsk.common.core.page.TableDataInfo;

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

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

    /**
     * 新增项目跟进记录
     */
//    @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(@RequestBody(required=false) 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: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));
//    }

}
