package com.fs.wxuser;

import java.util.List;

import com.fs.wxUser.domain.CompanyWxUser;
import com.fs.wxUser.service.ICompanyWxUserService;
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.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 【个微管理】Controller
 *
 * @author fs
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/company/wxuser")
public class CompanyWxUserController extends BaseController
{
    @Autowired
    private ICompanyWxUserService companyWxUserService;

    /**
     * 查询【个微管理】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CompanyWxUser companyWxUser)
    {
        startPage();
        List<CompanyWxUser> list = companyWxUserService.selectCompanyWxUserList(companyWxUser);
        return getDataTable(list);
    }

    /**
     * 导出【个微管理】列表
     */
    @Log(title = "【个微管理】", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyWxUser companyWxUser)
    {
        List<CompanyWxUser> list = companyWxUserService.selectCompanyWxUserList(companyWxUser);
        ExcelUtil<CompanyWxUser> util = new ExcelUtil<CompanyWxUser>(CompanyWxUser.class);
        return util.exportExcel(list, "user");
    }

    /**
     * 获取【个微管理】详细信息
     */
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(companyWxUserService.selectCompanyWxUserByUserId(userId));
    }

    /**
     * 新增【个微管理】
     */
    @Log(title = "【个微管理】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyWxUser companyWxUser)
    {
        return toAjax(companyWxUserService.insertCompanyWxUser(companyWxUser));
    }

    /**
     * 修改【个微管理】
     */
    @Log(title = "【个微管理】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyWxUser companyWxUser)
    {
        return toAjax(companyWxUserService.updateCompanyWxUser(companyWxUser));
    }

    /**
     * 删除【个微管理】
     */
    @Log(title = "【个微管理】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(companyWxUserService.deleteCompanyWxUserByUserIds(userIds));
    }
}
