package com.huatek.busi.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.huatek.busi.entity.GlobalSettingItem;
import com.huatek.busi.service.IGlobalSettingItemService;
import com.huatek.busi.vo.GlobalSettingItemVo;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = {"全局配置项管理接口"})
@RestController
@RequestMapping("/api/globalSettingItem")
public class GlobalSettingItemController {

    @Reference(check = false)
    IGlobalSettingItemService globalSettingItemService;

    @ApiOperation(value = "显示配置项参数",httpMethod="POST", notes= "显示配置项参数", produces = "application/json;charset=utf-8", response= Map.class)
    @PostMapping(value = "/list", produces = { "application/json;charset=utf-8" })
    public Map<String, Object> findOne(){
        GlobalSettingItem globalSettingItem = globalSettingItemService.findOne();
        return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "BUSINESS.QUERY.SUCCESS", globalSettingItem);
    }

    @ApiOperation(value = "新增或更新配置项参数",httpMethod="POST", notes= "新增或更新配置项参数", produces = "application/json;charset=utf-8", response= Map.class)
    @PostMapping(value = "/saveOrUpdate", produces = { "application/json;charset=utf-8" })
    public Map<String, Object> saveOrUpdate(@RequestHeader("token") String token, @RequestBody GlobalSettingItemVo globalSettingItemVo){
        return globalSettingItemService.saveOrUpdate(token, globalSettingItemVo);
    }
}
