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.ProProjectInfoSetting;
import com.yanzhu.manage.service.IProProjectInfoSettingService;
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("/proProjectInfoSetting")
public class ProProjectInfoSettingController extends BaseController
{
    @Autowired
    private IProProjectInfoSettingService proProjectInfoSettingService;

    /**
     * 查询项目设置列表
     */
    @RequiresPermissions("manage:proProjectInfoSetting:list")
    @GetMapping("/list")
    public TableDataInfo list(ProProjectInfoSetting proProjectInfoSetting)
    {
        startPage();
        List<ProProjectInfoSetting> list = proProjectInfoSettingService.selectProProjectInfoSettingList(proProjectInfoSetting);
        return getDataTable(list);
    }

    /**
     * 导出项目设置列表
     */
    @RequiresPermissions("manage:proProjectInfoSetting:export")
    @Log(title = "项目设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProProjectInfoSetting proProjectInfoSetting)
    {
        List<ProProjectInfoSetting> list = proProjectInfoSettingService.selectProProjectInfoSettingList(proProjectInfoSetting);
        ExcelUtil<ProProjectInfoSetting> util = new ExcelUtil<ProProjectInfoSetting>(ProProjectInfoSetting.class);
        util.exportExcel(response, list, "项目设置数据");
    }

    /**
     * 获取项目设置详细信息
     */
    @RequiresPermissions("manage:proProjectInfoSetting:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(proProjectInfoSettingService.selectProProjectInfoSettingById(id));
    }

    /**
     * 新增项目设置
     */
    @RequiresPermissions("manage:proProjectInfoSetting:add")
    @Log(title = "项目设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProProjectInfoSetting proProjectInfoSetting)
    {
        return toAjax(proProjectInfoSettingService.insertProProjectInfoSetting(proProjectInfoSetting));
    }

    /**
     * 修改项目设置
     */
    @RequiresPermissions("manage:proProjectInfoSetting:edit")
    @Log(title = "项目设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProProjectInfoSetting proProjectInfoSetting)
    {
        return toAjax(proProjectInfoSettingService.updateProProjectInfoSetting(proProjectInfoSetting));
    }

    /**
     * 删除项目设置
     */
    @RequiresPermissions("manage:proProjectInfoSetting:remove")
    @Log(title = "项目设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(proProjectInfoSettingService.deleteProProjectInfoSettingByIds(ids));
    }
}
