package com.dsk.biz.controller;

import com.dsk.biz.domain.BusinessFollowRecord;
import com.dsk.biz.domain.bo.BusinessIdDto;
import com.dsk.biz.domain.bo.BusinessListDto;
import com.dsk.biz.domain.vo.BusinessListVo;
import com.dsk.biz.service.IBusinessFollowRecordService;
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 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 R<List<BusinessListVo>> selectRelateProject(@PathVariable("userId") Long userId)
    {
        return R.ok(businessFollowRecordService.selectRelateProject(userId));
    }

    /**
     * 查询关联业主企业
     */
    @GetMapping("/relate/company/{userId}")
    public R<List<String>> selectRelateCompany(@PathVariable("userId") Long userId)
    {
        return R.ok(businessFollowRecordService.selectRelateCompany(userId));
    }

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

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

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

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


}
