package com.ruoyi.web.controller.brewery;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.domain.entity.WyBreweryUser;
import com.ruoyi.brewery.service.IWyBreweryUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 品牌方用户信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-22
 */
@Api(tags = "品牌方用户信息")
@RestController
@RequestMapping("/system/brewery/user")
public class WyBreweryUserController extends BaseController
{
    @Autowired
    private IWyBreweryUserService wyBreweryUserService;

    /**
     * 查询品牌方用户信息列表
     */
    @ApiOperation("查询品牌方用户信息列表")
    @PreAuthorize("@ss.hasPermi('brewery:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBreweryUser wyBreweryUser)
    {
        startPage();
        List<WyBreweryUser> list = wyBreweryUserService.selectWyBreweryUserList(wyBreweryUser);
        return getDataTable(list);
    }

    /**
     * 导出品牌方用户信息列表
     */
    @ApiOperation("导出品牌方用户信息列表")
    @PreAuthorize("@ss.hasPermi('brewery:user:export')")
    @Log(title = "品牌方用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBreweryUser wyBreweryUser)
    {
        List<WyBreweryUser> list = wyBreweryUserService.selectWyBreweryUserList(wyBreweryUser);
        ExcelUtil<WyBreweryUser> util = new ExcelUtil<WyBreweryUser>(WyBreweryUser.class);
        util.exportExcel(response, list, "品牌方用户信息数据");
    }

    /**
     * 获取品牌方用户信息详细信息
     */
    @ApiOperation("获取品牌方用户信息详细信息")
    @PreAuthorize("@ss.hasPermi('brewery:user:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(wyBreweryUserService.selectWyBreweryUserByUserId(userId));
    }

    /**
     * 新增品牌方用户信息
     */
    @ApiOperation("新增品牌方用户信息")
    @PreAuthorize("@ss.hasPermi('brewery:user:add')")
    @Log(title = "品牌方用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBreweryUser wyBreweryUser)
    {
        return toAjax(wyBreweryUserService.insertWyBreweryUser(wyBreweryUser));
    }

    /**
     * 修改品牌方用户信息
     */
    @ApiOperation("修改品牌方用户信息")
    @PreAuthorize("@ss.hasPermi('brewery:user:edit')")
    @Log(title = "品牌方用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBreweryUser wyBreweryUser)
    {
        return toAjax(wyBreweryUserService.updateWyBreweryUser(wyBreweryUser));
    }

    /**
     * 删除品牌方用户信息
     */
    @ApiOperation("删除品牌方用户信息")
    @PreAuthorize("@ss.hasPermi('brewery:user:remove')")
    @Log(title = "品牌方用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(wyBreweryUserService.deleteWyBreweryUserByUserIds(userIds));
    }
}
