package com.njcn.user.controller.app;

import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.user.service.IAppRoleService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类的介绍：
 *
 * @author xuyang
 * @version 1.0.0
 * @createTime 2023/6/25 18:30
 */
@Validated
@Slf4j
@RestController
@RequestMapping("/appRole")
@Api(tags = "App角色管理")
@AllArgsConstructor
public class AppRoleController extends BaseController {

    private final IAppRoleService appRoleService;

    /**
     * app用户角色升级
     */
    @PostMapping("/roleUpdate")
    @OperateInfo
    @ApiOperation(value = "角色升级", notes = "角色升级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, paramType = "query"),
            @ApiImplicitParam(name = "referralCode", value = "推荐码", required = true, paramType = "query"),
            @ApiImplicitParam(name = "devCode", value = "设备码", required = true, paramType = "query"),
    })
    public HttpResult<String> roleUpdate(@Param("userId")String userId,@Param("referralCode")String referralCode,@Param("devCode")String devCode) {
        String methodDescribe = getMethodDescribe("roleUpdate");
        appRoleService.roleUpdate(userId,referralCode,devCode);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
    }




}
