package com.gxwebsoft.open.controller;

import com.gxwebsoft.common.core.utils.MyQrCodeUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.param.UserParam;
import com.gxwebsoft.common.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * 我的资料
 *
 * @author 科技小王子
 * @since 2023-04-24 21:47:57
 */
@Api(tags = "我的资料")
@RestController
@RequestMapping("/api/open/user")
public class OpenUserController extends BaseController {
    @Resource
    private UserService userService;

    @ApiOperation("实时二维码")
    @PostMapping("/myQrCode")
    public ApiResult<?> myQrCode(@RequestBody UserParam userParam) throws IOException {
      // 验证签名
      isCheckSign();
      final String qrCode = MyQrCodeUtil.createQrCode(getLoginUserId(), userParam.getCodeContent());
      return success("操作成功",qrCode);
    }

    @ApiOperation("获取代理用户信息")
    @GetMapping("/agentUser/{id}")
    public ApiResult<User> agentUser(@PathVariable("id") Integer id){
      User user = userService.getById(id);
      return success("操作成功",user);
    }
}
