package com.purui.prims.headless.server.rest;

import com.purui.prims.headless.api.pojo.request.SysParameterReq;
import com.purui.prims.headless.api.pojo.response.SysParameterResp;
import com.purui.prims.headless.server.service.SysParameterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统参数
 *
 * @author charlie
 * @date 2024/6/25
 */
@RestController
@RequestMapping({"/api/semantic/parameter"})
@Api(tags = "参数设置")
public class SysParameterController {

    @Autowired
    private SysParameterService sysParameterService;

    @ApiOperation(value = "新建/修改参数")
    @PostMapping
    public boolean save(SysParameterReq sysParameterReq) {
        return sysParameterService.save(sysParameterReq);
    }

    @GetMapping("/getParameter/{id}")
    public SysParameterResp getParameter(@PathVariable int id) {
        return sysParameterService.get(id);
    }

    @ApiOperation(value = "参数列表")
    @GetMapping("/list")
    public List<SysParameterResp> getParameterList() {
        return sysParameterService.getParameterList();
    }
}
