package com.yiboshi.science.rest.v1;

import com.yiboshi.arch.base.ResponseDataModel;
import com.yiboshi.science.config.security.SecurityUserHolder;
import com.yiboshi.science.config.security.loginUser;
import com.yiboshi.science.entity.ComPerson;
import com.yiboshi.science.entity.SystemSet;
import com.yiboshi.science.param.dto.SystemSetDTO;
import com.yiboshi.science.param.query.SystemSetQueryVO;
import com.yiboshi.science.rest.BaseController;
import com.yiboshi.science.service.SystemSetService;
import com.yiboshi.science.utils.StringUtil;
import com.yiboshi.science.utils.SystemSetKey;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 功能：配置表 接口
 * @author lkl
 * @version 2021-08-26
 */
@Api(tags = "system-set",description = "配置表")
@RestController
@RequestMapping("/v1/science-admin/system-set")
public class SystemSetController extends BaseController<SystemSetService,SystemSetQueryVO, SystemSetDTO, SystemSet> {

    @Autowired
    private SystemSetService systemSetService;
    @ApiOperation(value = "获取系统配置", httpMethod = "GET", notes = "获取系统配置")
    @RequestMapping(value = "/getSystemSet")
    @GetMapping
    public ResponseDataModel<Map<String, Object>> getSystemSet() {
        Map<String, Object> data = new HashMap<String, Object>(5) {
            {
                put("SMSApiUrl", systemSetService.getByKey(SystemSetKey.SMSApiUrl));
                put("loginType", systemSetService.getByKey(SystemSetKey.LoginType));
                put("projType", systemSetService.getByKey(SystemSetKey.SysProjectType));
            }
        };
        return ResponseDataModel.ok(data);
    }

    @ApiOperation(value = "1.02", httpMethod = "POST", notes = "项目分配")
    @RequestMapping("/save")
    @PostMapping
    public ResponseDataModel<String> save(@RequestBody Map<String, Object> map) {
        return ResponseDataModel.ok(systemSetService.save(map));
    }
}