113 lines
3.3 KiB
C#
113 lines
3.3 KiB
C#
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using MyCode.Project.Domain.Message.Response.User;
|
|
using MyCode.Project.Infrastructure.Constant;
|
|
using MyCode.Project.WebApi.Controllers;
|
|
using MyCode.Project.Domain.Config;
|
|
using MyCode.Project.Services;
|
|
using MyCode.Project.Infrastructure.Common;
|
|
using MyCode.Project.Domain.Message.Request.User;
|
|
using MyCode.Project.Infrastructure.Enumeration;
|
|
using MyCode.Project.Domain.Message.Act.User;
|
|
using MyCode.Project.Domain.Message.Response.Goods;
|
|
using MyCode.Project.Domain.Model;
|
|
using MyCode.Project.Domain.Message.Response.Common;
|
|
using MyCode.Project.Domain.Businesses.BillKeeping;
|
|
using MyCode.Project.Domain.Message.Response.Member;
|
|
|
|
namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 授权token相关
|
|
/// </summary>
|
|
public class TokenController : BaseWechatController
|
|
{
|
|
private ITokenService _tokenService;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="tokenService"></param>
|
|
public TokenController(ITokenService tokenService)
|
|
{
|
|
_tokenService = tokenService;
|
|
}
|
|
|
|
#region GetToken(根据微信授权获取手机号,并登录选中角色,返回Token)
|
|
/// <summary>
|
|
/// 根据小程序的code获得用户的token等信息
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[AllowAnonymous]
|
|
public string GetToken(GetTokenRequest request)
|
|
{
|
|
return _tokenService.GetToken(request);
|
|
}
|
|
#endregion
|
|
|
|
#region SaveCode(根据JsCode识别是否能获取token,返回Token或者要求登录)
|
|
/// <summary>
|
|
/// 根据JsCode识别是否能获取token,返回Token或者要求登录
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[AllowAnonymous]
|
|
public string SaveCode(SaveCodeRequest request)
|
|
{
|
|
return _tokenService.SaveCode(request);
|
|
}
|
|
#endregion
|
|
|
|
#region SaveWxInfo(保存用户微信信息)
|
|
/// <summary>
|
|
/// 获取用户微信信息
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[AllowAnonymous]
|
|
public void SaveWxInfo(SaveWxInfoRequest request)
|
|
{
|
|
_tokenService.SaveWxInfo(request);
|
|
}
|
|
#endregion
|
|
|
|
#region GetRoleTypeList(登录时的可选角色列表)
|
|
/// <summary>
|
|
/// 登录时的可选角色列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public List<NameValue> GetRoleTypeList()
|
|
{
|
|
return _tokenService.GetRoleTypeList();
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region ClearLoginStatus(清除所有测试账号登录状态)
|
|
/// <summary>
|
|
/// 清除所有测试账号登录状态
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[AllowAnonymous]
|
|
public void ClearLoginStatus()
|
|
{
|
|
_tokenService.ClearLoginStatus();
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|