package com.zhongshu.card.server.core.controller.config;

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.model.base.IDParam;
import com.zhongshu.card.client.model.config.CommonConfigParam;
import com.zhongshu.card.client.model.config.CommonConfigSearch;
import com.zhongshu.card.client.model.devices.*;
import com.zhongshu.card.client.service.school.DeviceInfoService;
import com.zhongshu.card.server.core.service.config.CommonConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author TRX
 * @date 2024/6/5
 */
@RestController
@RequestMapping("/commonConfig")
@Tag(name = "用户关联个性化设置")
public class CommonCofigController {

    @Autowired
    private CommonConfigService commonConfigService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "支付统计页面--保存", description = "支付统计页面--保存")
    @RequestMapping(value = "savePayPanelConfig", method = {RequestMethod.POST})
    public ResultContent savePayPanelConfig(@RequestBody @Valid CommonConfigParam param) {
        param.setKey("payPanel");
        return this.commonConfigService.saveUserConfig(param);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "支付统计页面--得到", description = "支付统计页面--得到")
    @RequestMapping(value = "getPayPanelConfig", method = {RequestMethod.POST})
    public ResultContent getPayPanelConfig(@RequestBody @Valid CommonConfigSearch param) {
        param.setKey("payPanel");
        return this.commonConfigService.getUserConfig(param);
    }

}
