package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsPhaseTask;
import com.goldenwater.slgc.service.pms.IPmsPhaseTaskService;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.enums.BusinessType;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@RestController
@Validated
@RequestMapping("/pms/phase/task")
public class PmsPhaseTaskController extends BaseController {
    @Autowired
    private IPmsPhaseTaskService pmsPhaseTaskService;

    /**
     * 查询阶段任务列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsPhaseTask phaseTask) {
        startPage();
        List<PmsPhaseTask> list = pmsPhaseTaskService.selectList(phaseTask);
        return getDataTable(list);
    }

    /**
     * 获取阶段任务详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(pmsPhaseTaskService.selectById(id));
    }

    /**
     * 新增阶段任务
     */
    @Log(title = "阶段任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsPhaseTask phaseTask) {
        return toAjax(pmsPhaseTaskService.insert(phaseTask));
    }

    /**
     * 修改阶段任务
     */
    @Log(title = "阶段任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsPhaseTask phaseTask) {
        return toAjax(pmsPhaseTaskService.update(phaseTask));
    }

    /**
     * 删除阶段任务
     */
    @Log(title = "阶段任务", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pmsPhaseTaskService.deleteByIds(ids));
    }
}
