package com.fs.app.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.project.domain.ProjectTaskType;
import com.fs.project.service.IProjectTaskTypeService;
import com.fs.project.vo.QueryAllDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 项目任务类型Controller
 *
 * @author fs
 * @date 2025-12-30
 */
@RestController
@RequestMapping("/project/type")
public class ProjectTaskTypeController extends BaseController
{
    @Autowired
    private IProjectTaskTypeService projectTaskTypeService;

    /**
     * 查询项目任务类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ProjectTaskType projectTaskType)
    {
        startPage();
        List<ProjectTaskType> list = projectTaskTypeService.selectProjectTaskTypeList(projectTaskType);
        return getDataTable(list);
    }

    @GetMapping("/queryAllData")
    public AjaxResult queryAllData(QueryAllDataVO queryAllDataVO)
    {
        List<ProjectTaskType> list = projectTaskTypeService.queryAllData(queryAllDataVO);
        return AjaxResult.success(list);
    }


    /**
     * 导出项目任务类型列表
     */
    @GetMapping("/export")
    public AjaxResult export(ProjectTaskType projectTaskType)
    {
        List<ProjectTaskType> list = projectTaskTypeService.selectProjectTaskTypeList(projectTaskType);
        ExcelUtil<ProjectTaskType> util = new ExcelUtil<ProjectTaskType>(ProjectTaskType.class);
        return util.exportExcel(list, "项目任务类型数据");
    }

    /**
     * 获取项目任务类型详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(projectTaskTypeService.selectProjectTaskTypeById(id));
    }

    /**
     * 新增项目任务类型
     */
    @PostMapping
    public AjaxResult add(@RequestBody ProjectTaskType projectTaskType)
    {
        return toAjax(projectTaskTypeService.insertProjectTaskType(projectTaskType));
    }

    /**
     * 修改项目任务类型
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectTaskType projectTaskType)
    {
        return toAjax(projectTaskTypeService.updateProjectTaskType(projectTaskType));
    }

    /**
     * 删除项目任务类型
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectTaskTypeService.deleteProjectTaskTypeByIds(ids));
    }




    @GetMapping("/selectProjectOptionsByDept")
    public AjaxResult optionsByDept(@RequestParam Long deptId,
                                    @RequestParam(required = false) String projectName) {
        return AjaxResult.success(projectTaskTypeService.selectProjectOptionsByDept(deptId, projectName));
    }



}
