package com.fs.company.controller.qw;

import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.company.domain.CompanyUser;
import com.fs.company.service.ICompanyUserService;
import com.fs.wx.sop.domain.WxSopUser;
import com.fs.wx.sop.domain.WxSopUserInfo;
import com.fs.wx.sop.service.IWxSopUserService;
import com.fs.wx.sop.service.IWxSopUserInfoService;
import com.fs.wx.sop.service.IWxSopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 个微sop营期Controller
 *
 * @author fs
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/wxSop/sopUserLogsWx")
public class WxSopUserLogsController extends BaseController
{
    @Autowired
    private IWxSopUserService wxSopUserService;

    @Autowired
    private IWxSopUserInfoService wxSopUserInfoService;

    @Autowired
    private IWxSopService wxSopService;

    @Autowired
    private ICompanyUserService companyUserService;


    /**
     * 查询个微sop营期列表
     */
    @PreAuthorize("@ss.hasPermi('qw:sop:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxSopUser wxSopUser)
    {
        startPage();
        List<WxSopUser> list = wxSopUserService.selectWxSopUserList(wxSopUser);

        return getDataTable(list);
    }

    /**
     * 获取个微sop营期详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:sop:list')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        WxSopUser wxSopUser = wxSopUserService.selectWxSopUserById(id);
        return AjaxResult.success(wxSopUser);
    }

    /**
     * 根据SOP ID查询营期列表
     */
    @PreAuthorize("@ss.hasPermi('qw:sop:list')")
    @GetMapping("/listBySopId/{sopId}")
    public TableDataInfo listBySopId(@PathVariable("sopId") Long sopId)
    {
        startPage();
        WxSopUser queryParam = new WxSopUser();
        queryParam.setSopId(sopId);
        List<WxSopUser> list = wxSopUserService.selectWxSopUserList(queryParam);

        return getDataTable(list);
    }

    /**
     * 查询营期详情（客户列表）
     * @param sopUserId 营期ID
     */
    @PreAuthorize("@ss.hasPermi('qw:sop:list')")
    @GetMapping("/detail/{sopUserId}")
    public TableDataInfo detail(@PathVariable("sopUserId") Long sopUserId)
    {
        startPage();
        WxSopUserInfo queryParam = new WxSopUserInfo();
        queryParam.setSopUserId(sopUserId);
        List<WxSopUserInfo> list = wxSopUserInfoService.selectWxSopUserInfoList(queryParam);

        return getDataTable(list);
    }
}
