package com.game.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.game.common.annotation.Log;
import com.game.common.core.controller.BaseController;
import com.game.common.core.domain.AjaxResult;
import com.game.common.enums.BusinessType;
import com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.game.business.domain.AppUser;
import com.game.business.service.IAppUserService;
import com.game.common.utils.poi.ExcelUtil;
import com.game.common.core.page.TableDataInfo;

/**
 * app用户Controller
 * 
 * @author game
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/business/user")
@Api(value = "AppUserController", description = "app用户接口", tags = {"app用户"})
public class AppUserController extends BaseController
{
    @Autowired
    private IAppUserService appUserService;

    /**
     * 查询app用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:user:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询app用户列表", notes = "获取app用户列表")
    public TableDataInfo list(AppUser appUser)
    {
        startPage();
        List<AppUser> list = appUserService.selectAppUserList(appUser);
        return getDataTable(list);
    }

    /**
     * 导出app用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:user:export')")
    @Log(title = "app用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出app用户列表", notes = "导出app用户列表")
    public void export(HttpServletResponse response, AppUser appUser)
    {
        List<AppUser> list = appUserService.selectAppUserList(appUser);
        ExcelUtil<AppUser> util = new ExcelUtil<AppUser>(AppUser.class);
        util.exportExcel(response, list, "app用户数据");
    }

    /**
     * 获取app用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:user:query')")
    @GetMapping(value = "/{userid}")
    @ApiOperation(value = "获取app用户详细信息", notes = "获取app用户详细信息")
    public AjaxResult getInfo(@PathVariable("userid") Long userid)
    {
        return success(appUserService.selectAppUserByUserid(userid));
    }

    /**
     * 新增app用户
     */
    @PreAuthorize("@ss.hasPermi('business:user:add')")
    @Log(title = "app用户", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增app用户", notes = "新增app用户")
    @PostMapping
    public AjaxResult add(@RequestBody AppUser appUser)
    {
        return toAjax(appUserService.insertAppUser(appUser));
    }

    /**
     * 修改app用户
     */
    @PreAuthorize("@ss.hasPermi('business:user:edit')")
    @Log(title = "app用户", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改app用户", notes = "修改app用户")
    @PutMapping
    public AjaxResult edit(@RequestBody AppUser appUser)
    {
        return toAjax(appUserService.updateAppUser(appUser));
    }

    /**
     * 删除app用户
     */
    @PreAuthorize("@ss.hasPermi('business:user:remove')")
    @Log(title = "app用户", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除app用户", notes = "删除app用户")
	@DeleteMapping("/{userids}")
    public AjaxResult remove(@PathVariable Long[] userids)
    {
        return toAjax(appUserService.deleteAppUserByUserids(userids));
    }
}
