package com.yunfeiyun.agmp.fms.controller;

import java.util.List;

import com.yunfeiyun.agmp.fms.domain.reqvo.FmsPolicyReqVo;
import com.yunfeiyun.agmp.fms.domain.resvo.FmsPolicyListResVo;
import com.yunfeiyun.agmp.fms.domain.vo.FmsPolicyVo;
import com.yunfeiyun.agmp.fms.service.IFmsPolicyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunfeiyun.agmp.common.annotation.Log;
import com.yunfeiyun.agmp.common.core.controller.BaseController;
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
import com.yunfeiyun.agmp.common.enums.BusinessType;
import com.yunfeiyun.agmp.common.core.page.TableDataInfo;

/**
 * 决策Controller
 * 
 * @author 杨晓辉
 * @date 2023-06-05
 */
@RestController
@RequestMapping("/fms/policy")
public class FmsPolicyController extends BaseController
{
    @Autowired
    private IFmsPolicyService fmsPolicyService;

    /**
     * 查询决策列表
     */
    @PreAuthorize("@ss.hasPermi('fms:policy:list')")
    @GetMapping("/list")
    public TableDataInfo list(FmsPolicyReqVo fmsPolicyReqVo)
    {
        startPage();
        List<FmsPolicyListResVo> list = fmsPolicyService.selectFmsPolicyList(fmsPolicyReqVo);
        return getDataTable(list);
    }

    /**
     * 获取决策详细信息
     */
    @PreAuthorize("@ss.hasPermi('fms:policy:info')")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(@RequestParam("decisionId") String decisionId)
    {
        return success(fmsPolicyService.selectFmsPolicyByDecisionId(decisionId));
    }

    /**
     * 新增决策
     */
    @PreAuthorize("@ss.hasPermi('fms:policy:add')")
    @Log(title = "决策", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FmsPolicyVo fmsPolicyVo)
    {
        return toAjax(fmsPolicyService.insertFmsPolicy(fmsPolicyVo));
    }

    /**
     * 修改决策
     */
    @PreAuthorize("@ss.hasPermi('fms:policy:edit')")
    @Log(title = "决策", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FmsPolicyVo fmsPolicyVo)
    {
        return toAjax(fmsPolicyService.updateFmsPolicy(fmsPolicyVo));
    }

    /**
     * 删除决策
     */
    @PreAuthorize("@ss.hasPermi('fms:policy:delete')")
    @Log(title = "决策", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete")
    public AjaxResult remove(@RequestParam("decisionId") String decisionId)
    {
        return toAjax(fmsPolicyService.deleteFmsPolicyByDecisionId(decisionId));
    }
}
