package com.yanzhu.manage.controller;

import com.yanzhu.common.core.utils.poi.ExcelUtil;
import com.yanzhu.common.core.web.controller.BaseController;
import com.yanzhu.common.core.web.domain.AjaxResult;
import com.yanzhu.common.core.web.page.TableDataInfo;
import com.yanzhu.common.log.annotation.Log;
import com.yanzhu.common.log.enums.BusinessType;
import com.yanzhu.common.security.annotation.RequiresPermissions;
import com.yanzhu.manage.domain.BusTrainingVideoUser;
import com.yanzhu.manage.service.IBusTrainingVideoUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * 用户培训视频Controller
 * 
 * @author JiangYuQi
 * @date 2024-08-25
 */
@RestController
@RequestMapping("/busTrainingVideoUser")
public class BusTrainingVideoUserController extends BaseController
{
    @Autowired
    private IBusTrainingVideoUserService busTrainingVideoUserService;

    /**
     * 查询用户培训视频列表
     */
    @RequiresPermissions("manage:busTrainingVideoUser:list")
    @GetMapping("/list")
    public TableDataInfo list(BusTrainingVideoUser busTrainingVideoUser)
    {
        startPage();
        List<BusTrainingVideoUser> list = busTrainingVideoUserService.selectBusTrainingVideoUserList(busTrainingVideoUser);
        return getDataTable(list);
    }

    /**
     * 导出用户培训视频列表
     */
    @RequiresPermissions("manage:busTrainingVideoUser:export")
    @Log(title = "用户培训视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusTrainingVideoUser busTrainingVideoUser)
    {
        List<BusTrainingVideoUser> list = busTrainingVideoUserService.selectBusTrainingVideoUserList(busTrainingVideoUser);
        ExcelUtil<BusTrainingVideoUser> util = new ExcelUtil<BusTrainingVideoUser>(BusTrainingVideoUser.class);
        util.exportExcel(response, list, "用户培训视频数据");
    }

    /**
     * 获取用户培训视频详细信息
     */
    @RequiresPermissions("manage:busTrainingVideoUser:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busTrainingVideoUserService.selectBusTrainingVideoUserById(id));
    }

    /**
     * 新增用户培训视频
     */
    @RequiresPermissions("manage:busTrainingVideoUser:add")
    @Log(title = "用户培训视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusTrainingVideoUser busTrainingVideoUser)
    {
        return toAjax(busTrainingVideoUserService.insertBusTrainingVideoUser(busTrainingVideoUser));
    }

    /**
     * 修改用户培训视频
     */
    @RequiresPermissions("manage:busTrainingVideoUser:edit")
    @Log(title = "用户培训视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusTrainingVideoUser busTrainingVideoUser)
    {
        return toAjax(busTrainingVideoUserService.updateBusTrainingVideoUser(busTrainingVideoUser));
    }

    /**
     * 删除用户培训视频
     */
    @RequiresPermissions("manage:busTrainingVideoUser:remove")
    @Log(title = "用户培训视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busTrainingVideoUserService.deleteBusTrainingVideoUserByIds(ids));
    }
}
