package com.storlead.system.controller;

import com.storlead.framework.common.result.Result;
import com.storlead.wecom.pojo.vo.SystemWechatConfigEntity;
import com.storlead.wecom.service.SystemWechatConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 企业微信secret配置 前端控制器
 * </p>
 *
 * @author chenkq
 * @since 2022-07-20
 */
@RestController
@RequestMapping("/sys/wechat/config")
@Api(tags = "平台中心 - 系统: 企业微信配置")
public class SystemWechatConfigApiController {

    @Resource
    private SystemWechatConfigService systemWechatConfigService;

    @PostMapping(value = "/save")
    @ApiOperation(value = "保存企业微信参数配置", notes = "配置系统基础设置")
    public Result saveSetting(SystemWechatConfigEntity entity) {
        systemWechatConfigService.saveOrUpdate(entity);
        return Result.ok();
    }

    @PostMapping(value = "/get")
    @ApiOperation(value = "保存企业微信参数配置")
    public Result<?> getSetting() {
        SystemWechatConfigEntity setting = systemWechatConfigService.getOne(null);
        return Result.result(setting);
    }
}
