package com.storlead.system.controller;


import com.storlead.framework.common.result.Result;
import com.storlead.system.pojo.entity.SystemPersonalizeSettingEntity;
import com.storlead.system.service.SystemPersonalizeSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import javax.annotation.Resource;
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>
 * 系统个性化设置 前端控制器
 * </p>
 *
 * @author chenkq
 * @since 2022-07-20
 */
@RestController
@RequestMapping("/sys/personalize/setting")
@Api(tags = "平台中心 - 系统: 个性化设置")
public class SystemPersonalizeSettingApiController {

    @Resource
    private SystemPersonalizeSettingService personalizeSettingService;


    @PostMapping(value = "/save")
    @ApiOperation(value = "配置系统基础设置", notes = "配置系统基础设置")
    @ApiResponses({
            @ApiResponse(code = 200, message = "", response = SystemPersonalizeSettingEntity.class)
    })
    public Result saveSetting(SystemPersonalizeSettingEntity entity) {
         personalizeSettingService.saveOrUpdate(entity);
         return Result.ok();
    }

    @PostMapping(value = "/get")
    @ApiOperation(value = "获取系统基础设置", notes = "获取系统基础设置")
    @ApiResponses({
            @ApiResponse(code = 200, message = "", response = SystemPersonalizeSettingEntity.class)
    })
    public Result<?> getSetting() {
        SystemPersonalizeSettingEntity setting = personalizeSettingService.getOne(null);
        return Result.result(setting);
    }
}
