package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsPhaseLog;
import com.goldenwater.slgc.service.pms.IPmsPhaseLogService;
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/log")
public class PmsPhaseLogController extends BaseController {
    @Autowired
    private IPmsPhaseLogService pmsPhaseLogService;

    /**
     * 查询阶段日志列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsPhaseLog phaseLog) {
        startPage();
        List<PmsPhaseLog> list = pmsPhaseLogService.selectList(phaseLog);
        return getDataTable(list);
    }

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

    /**
     * 新增阶段日志
     */
    @Log(title = "阶段日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsPhaseLog phaseLog) {
        return toAjax(pmsPhaseLogService.insert(phaseLog));
    }

    /**
     * 修改阶段日志
     */
    @Log(title = "阶段日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsPhaseLog phaseLog) {
        return toAjax(pmsPhaseLogService.update(phaseLog));
    }

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