package com.fs.company.controller.wx.controller;

import java.util.List;
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.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.wx.sop.domain.WxSopUser;
import com.fs.wx.sop.service.IWxSopUserService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 个微营期Controller
 * 
 * @author 吴树波
 * @date 2026-02-24
 */
@RestController
@RequestMapping("/wx/wxSopUser")
public class WxSopUserController extends BaseController
{
    @Autowired
    private IWxSopUserService wxSopUserService;

    /**
     * 查询个微营期列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WxSopUser wxSopUser)
    {
        startPage();
        List<WxSopUser> list = wxSopUserService.selectWxSopUserList(wxSopUser);
        return getDataTable(list);
    }

    /**
     * 导出个微营期列表
     */
    @Log(title = "个微营期", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WxSopUser wxSopUser)
    {
        List<WxSopUser> list = wxSopUserService.selectWxSopUserList(wxSopUser);
        ExcelUtil<WxSopUser> util = new ExcelUtil<WxSopUser>(WxSopUser.class);
        return util.exportExcel(list, "个微营期数据");
    }

    /**
     * 获取个微营期详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wxSopUserService.selectWxSopUserById(id));
    }

    /**
     * 新增个微营期
     */
    @Log(title = "个微营期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxSopUser wxSopUser)
    {
        return toAjax(wxSopUserService.insertWxSopUser(wxSopUser));
    }

    /**
     * 修改个微营期
     */
    @Log(title = "个微营期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxSopUser wxSopUser)
    {
        return toAjax(wxSopUserService.updateWxSopUser(wxSopUser));
    }

    /**
     * 删除个微营期
     */
    @Log(title = "个微营期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxSopUserService.deleteWxSopUserByIds(ids));
    }
}
