package com.srs.web.controller.stureg;

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.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.stureg.domain.SrsDormSelect;
import com.srs.stureg.service.ISrsDormSelectService;
import com.srs.common.utils.poi.ExcelUtil;
import com.srs.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author srs
 * @date 2023-07-24
 */
@RestController
@RequestMapping("/system/select")
public class SrsDormSelectController extends BaseController
{
    @Autowired
    private ISrsDormSelectService srsDormSelectService;

    /**
     * 查询【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:select:list')")
    @GetMapping("/list")
    public TableDataInfo list(SrsDormSelect srsDormSelect)
    {
        startPage();
        List<SrsDormSelect> list = srsDormSelectService.selectSrsDormSelectList(srsDormSelect);
        return getDataTable(list);
    }

    /**
     * 根据登录账号查询可选宿舍
     * @param srsDormSelect
     * @return
     */

    @GetMapping("/list/dorm")
    public TableDataInfo lists(SrsDormSelect srsDormSelect)
    {
        startPage();
        List<SrsDormSelect> list = srsDormSelectService.selectSrsDormSelectBystuNo(getUsername());
        return getDataTable(list);
    }


    /**
     * 导出【请填写功能名称】列表
     */
//    @PreAuthorize("@ss.hasPermi('system:select:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SrsDormSelect srsDormSelect)
    {
        List<SrsDormSelect> list = srsDormSelectService.selectSrsDormSelectList(srsDormSelect);
        ExcelUtil<SrsDormSelect> util = new ExcelUtil<SrsDormSelect>(SrsDormSelect.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:select:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(srsDormSelectService.selectSrsDormSelectById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:select:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrsDormSelect srsDormSelect)
    {
        return toAjax(srsDormSelectService.insertSrsDormSelect(srsDormSelect));
    }

    /**
     * 修改【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:select:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SrsDormSelect srsDormSelect)
    {
        return toAjax(srsDormSelectService.updateSrsDormSelect(srsDormSelect));
    }

    /**
     * 删除【请填写功能名称】
     */
//    @PreAuthorize("@ss.hasPermi('system:select:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(srsDormSelectService.deleteSrsDormSelectByIds(ids));
    }
}
