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);
    }


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

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

    //------------------用户在项目的完成 必要性的配置 start -----------------

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "得到当前用户在项目的 使用必要配置情况", description = "得到当前用户在项目的 使用必要配置情况")
    @RequestMapping(value = "getCurrentUserProjectConfigs", method = {RequestMethod.GET})
    public ResultContent getCurrentUserProjectConfigs() {
        return this.projectUserConfigService.getCurrentUserProjectConfigs();
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "标记完成绑定卡片", description = "标记完成绑定卡片")
    @RequestMapping(value = "markFinishBindCard", method = {RequestMethod.GET})
    public ResultContent markFinishBindCard() {
        return this.projectUserConfigService.markFinishBindCard();
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "标记完成开通无感支付", description = "标记完成开通无感支付")
    @RequestMapping(value = "markOpenUnPay", method = {RequestMethod.GET})
    public ResultContent markOpenUnPay() {
        return this.projectUserConfigService.markOpenUnPay();
    }

}
