package com.sf.index.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.sf.common.annotation.Log;
import com.sf.common.core.controller.BaseController;
import com.sf.common.core.domain.AjaxResult;
import com.sf.common.enums.BusinessType;
import com.sf.index.domain.ApplyListInfo;
import com.sf.index.service.IApplyListInfoService;
import com.sf.common.utils.poi.ExcelUtil;
import com.sf.common.core.page.TableDataInfo;

/**
 * 应用列Controller
 * 
 * @author ztzh
 * @date 2024-04-11
 */
@RestController
@RequestMapping("/index/list")
public class ApplyListInfoController extends BaseController
{
    @Autowired
    private IApplyListInfoService applyListInfoService;

    /**
     * 查询应用列列表
     */
    @PreAuthorize("@ss.hasPermi('index:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplyListInfo applyListInfo)
    {
        startPage();
        List<ApplyListInfo> list = applyListInfoService.selectApplyListInfoList(applyListInfo);
        return getDataTable(list);
    }

    /**
     * 导出应用列列表
     */
    @PreAuthorize("@ss.hasPermi('index:list:export')")
    @Log(title = "应用列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplyListInfo applyListInfo)
    {
        List<ApplyListInfo> list = applyListInfoService.selectApplyListInfoList(applyListInfo);
        ExcelUtil<ApplyListInfo> util = new ExcelUtil<ApplyListInfo>(ApplyListInfo.class);
        util.exportExcel(response, list, "应用列数据");
    }

    /**
     * 获取应用列详细信息
     */
    @PreAuthorize("@ss.hasPermi('index:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(applyListInfoService.selectApplyListInfoById(id));
    }

    /**
     * 新增应用列
     */
    @PreAuthorize("@ss.hasPermi('index:list:add')")
    @Log(title = "应用列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplyListInfo applyListInfo)
    {
        return toAjax(applyListInfoService.insertApplyListInfo(applyListInfo));
    }

    /**
     * 修改应用列
     */
    @PreAuthorize("@ss.hasPermi('index:list:edit')")
    @Log(title = "应用列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplyListInfo applyListInfo)
    {
        return toAjax(applyListInfoService.updateApplyListInfo(applyListInfo));
    }

    /**
     * 删除应用列
     */
    @PreAuthorize("@ss.hasPermi('index:list:remove')")
    @Log(title = "应用列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(applyListInfoService.deleteApplyListInfoByIds(ids));
    }
}
