package com.ruoyi.web.controller.api;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.TSysAppUserService;
import com.ruoyi.system.utils.wx.model.WeixinProperties;
import com.ruoyi.system.utils.wx.tools.WxAppletTools;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
/**
*
* 微信小程序登录 前端控制器
*
*
* @author xiaochen
* @since 2024-08-06
*/
@Slf4j
@RestController
@RequestMapping("/wxLogin")
public class WxLoginController {
@Autowired
private WeixinProperties wxConfig;
@Autowired
private RestTemplate wxRestTemplate;
@Resource
private RedisService redisService;
@Resource
private TSysAppUserService sysAppUserService;
@Resource
private TokenService tokenService;
@Autowired
private SysLoginService loginService;
// /**
// * 账号密码登录
// *
// * @param loginBody 登录信息
// * @return 结果
// */
// @ApiOperation(value = "账号密码登录",notes = "管理员账号密码登录")
// @PostMapping("/login")
// public AjaxResult login(@RequestBody LoginBody loginBody)
// {
// AjaxResult ajax = AjaxResult.success();
// // 生成令牌
// LoginUser loginUser = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
// loginBody.getUuid());
// ajax.put(Constants.TOKEN, tokenService.createToken(loginUser));
// List roles = loginUser.getUser().getRoles();
// if(CollectionUtils.isEmpty(roles)){
// return AjaxResult.error("请关联角色!");
// }
// if(roles.get(0).getStatus() == 1){
// return AjaxResult.error("该账号角色已被禁用!");
// }
// return ajax;
// }
//
// @ApiOperation(value = "通过code获得openid,获取用户信息",tags = {"微信小程序登录"})
// @PostMapping("/openIdByJsCode")
// public R