package com.storlead.centre.system;

import com.storlead.framework.web.assemble.Result;
import com.storlead.wx.pojo.vo.SystemWechatConfigEntity;
import com.storlead.wx.service.SystemWechatConfigService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 企业微信secret配置 前端控制器
 * </p>
 *
 * @author chenkq
 * @since 2022-07-20
 */
@RestController
@RequestMapping("/sys/wechat/config")
public class SystemWechatConfigApiController {

    @Autowired
    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.ok(setting);
    }
}
