package com.fs.app.controller;

import java.util.List;

import com.fs.app.annotation.Login;
import com.fs.common.core.domain.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.company.domain.CompanyCompanyFsuser;
import com.fs.company.service.ICompanyCompanyFsuserService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 销售绑定用户(一个用户绑定唯一一个销售)Controller
 *
 * @author fs
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/app/companyCompanyFsUser")
public class CompanyCompanyFsuserController extends AppBaseController
{
    @Autowired
    private ICompanyCompanyFsuserService companyCompanyFsuserService;

    /**
     * 查询销售绑定用户列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CompanyCompanyFsuser companyCompanyFsuser)
    {
        startPage();
        List<CompanyCompanyFsuser> list = companyCompanyFsuserService.selectCompanyCompanyUserList(companyCompanyFsuser);
        return getDataTable(list);
    }

    /**
     * 获取销售绑定用户
     */
    @Login
    @GetMapping(value = "/getInfoByUserId")
    public R getInfoByUserId()
    {
        String userId = getUserId();
        if (userId == null){
            return R.error("请先登录");
        }
        return companyCompanyFsuserService.getInfoByUserId(userId);
    }


    /**
     * 新增销售绑定用户
     */
    @Login
    @GetMapping("/bind/{companyUserId}")
    public R bind(@PathVariable("companyUserId") Long companyUserId)
    {
        String userId = getUserId();
        if (userId == null){
            return R.error("请先登录!");
        }
        return companyCompanyFsuserService.bind(companyUserId,userId);
    }



}
