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.config.ProjectUserConfigParam;
import com.zhongshu.card.server.core.service.config.ProjectUserConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author TRX
 * @date 2024/6/5
 */
@RestController
@RequestMapping("/projectUserConfig")
@Tag(name = "项目用户配置")
public class ProjectUserConfigController {

    @Autowired
    private ProjectUserConfigService projectUserConfigService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "保存小程序用户配置", description = "保存小程序用户配置")
    @RequestMapping(value = "xcxSaveUserConfig", method = {RequestMethod.POST})
    public ResultContent xcxSaveUserConfig(@RequestBody @Valid ProjectUserConfigParam param) {
        return this.projectUserConfigService.xcxSaveUserConfig(param);
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "得到小程序用户配置", description = "得到小程序用户配置")
    @RequestMapping(value = "xcxGetUserConfig", method = {RequestMethod.POST})
    public ResultContent xcxGetUserConfig(@RequestBody @Valid ProjectUserConfigParam param) {
        return this.projectUserConfigService.xcxGetUserConfig(param);
    }

}
