package com.fs.his.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.his.domain.FsPackageSolarTerm;
import com.fs.his.param.FsPackageSolarTermParam;
import com.fs.his.service.IFsPackageSolarTermService;
import com.fs.his.vo.FsPackageSolarTermVO;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/his/packageSolarTerm")
@AllArgsConstructor
public class FsPackageSolarTermController extends BaseController {

    private final IFsPackageSolarTermService solarTermService;

    @PreAuthorize("@ss.hasPermi('his:packageSolarTerm:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsPackageSolarTermParam param) {
        startPage();
        List<FsPackageSolarTermVO> list = solarTermService.selectFsPackageSolarTermListVO(param);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('his:packageSolarTerm:query')")
    @GetMapping(value = "/{solarTermId}")
    public AjaxResult getInfo(@PathVariable Long solarTermId) {
        return AjaxResult.success(solarTermService.selectFsPackageSolarTermVO(solarTermId));
    }

    @PreAuthorize("@ss.hasPermi('his:packageSolarTerm:add')")
    @Log(title = "套餐包节气", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsPackageSolarTerm param) {
        return toAjax(solarTermService.insertFsPackageSolarTerm(param));
    }

    @PreAuthorize("@ss.hasPermi('his:packageSolarTerm:edit')")
    @Log(title = "套餐包节气", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsPackageSolarTerm param) {
        return toAjax(solarTermService.updateFsPackageSolarTerm(param));
    }

    @PreAuthorize("@ss.hasPermi('his:packageSolarTerm:remove')")
    @Log(title = "套餐包", businessType = BusinessType.DELETE)
    @DeleteMapping("/{solarTermIds}")
    public AjaxResult remove(@PathVariable Long[] solarTermIds) {
        return toAjax(solarTermService.deleteFsPackageSolarTermByIds(solarTermIds));
    }

    @GetMapping("/getOptions")
    public AjaxResult getOptions() {
        return AjaxResult.success(solarTermService.getOptions());
    }
}
