feat:调整登录接口逻辑
parent
9c8cd9c151
commit
704ca53bc0
|
|
@ -1,15 +1,20 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Autofac.Core;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using MySqlX.XDevAPI.Common;
|
||||||
using New_College.AuthHelper.OverWrite;
|
using New_College.AuthHelper.OverWrite;
|
||||||
using New_College.IServices;
|
using New_College.IServices;
|
||||||
using New_College.Model;
|
using New_College.Model;
|
||||||
|
using New_College.Model.Models;
|
||||||
using New_College.Model.Request;
|
using New_College.Model.Request;
|
||||||
using New_College.Model.ViewModels;
|
using New_College.Model.ViewModels;
|
||||||
|
using Org.BouncyCastle.Asn1.Ocsp;
|
||||||
|
|
||||||
namespace New_College.Api.Controllers.Front
|
namespace New_College.Api.Controllers.Front
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +37,7 @@ namespace New_College.Api.Controllers.Front
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public MessageModel<CustomerInfoResult> GetWeixinAuthinfo(WeixinLogin login)
|
public MessageModel<CustomerInfoResult> GetWxOpenId(WeixinLogin login)
|
||||||
{
|
{
|
||||||
var response = new CustomerInfoResult();
|
var response = new CustomerInfoResult();
|
||||||
try
|
try
|
||||||
|
|
@ -82,7 +87,28 @@ namespace New_College.Api.Controllers.Front
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[DisplayName("获取微信用户电话号码")]
|
||||||
|
public async Task<MessageModel<string>> GetWxPhone(DecryptUserPhoneRequest request)
|
||||||
|
{
|
||||||
|
var accessToken = _services.access_Token();
|
||||||
|
var reqUserPhoneNumber = new WxaBusinessGetUserPhoneNumberRequest()
|
||||||
|
{
|
||||||
|
code = request.code,
|
||||||
|
access_Token = accessToken.access_token,
|
||||||
|
};
|
||||||
|
var repUserPhoneNumber = _services.WxaBusinessGetUserPhoneNumber(reqUserPhoneNumber);
|
||||||
|
var customerinfo = (await _services.Query(e => e.OpenId == request.openId)).FirstOrDefault();
|
||||||
|
customerinfo.Phone = repUserPhoneNumber.phone_info.phoneNumber;
|
||||||
|
var result = repUserPhoneNumber.errcode == 0 ? await _services.Update(customerinfo) : false;
|
||||||
|
return new MessageModel<string>()
|
||||||
|
{
|
||||||
|
msg = result ? "修改成功" : "保存失败",
|
||||||
|
response = repUserPhoneNumber.phone_info.phoneNumber,
|
||||||
|
success = result ? true : false,
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@
|
||||||
<None Update="Dockerfile">
|
<None Update="Dockerfile">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="start.sh">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:New_College.Api.Controllers.Front.CustomerController.GetWeixinAuthinfo(New_College.Model.WeixinLogin)">
|
<member name="M:New_College.Api.Controllers.Front.CustomerController.GetWxOpenId(New_College.Model.WeixinLogin)">
|
||||||
<summary>
|
<summary>
|
||||||
获取微信openid
|
获取微信openid
|
||||||
</summary>
|
</summary>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"Weixin": {
|
"Weixin": {
|
||||||
"Appid": "wx6d433f70416c37d4",
|
"Appid": "wx05e75004e657527c",
|
||||||
"Secret": "d7cb43cd2546f04f87c04d6ffd5fa9be",
|
"Secret": "9383aa5517e1d6bf23404dce9c86b0f1",
|
||||||
//MCHID
|
//MCHID
|
||||||
"MCHID": "1600580140",
|
"MCHID": "1614987630",
|
||||||
//MCHKey
|
//MCHKey
|
||||||
"KEY": "sa6328ahwqiuyoa923zaswq7ed021mns",
|
"KEY": "brapuk6fon0wachiMlth2t3lb4a0h7ji",
|
||||||
//NotifyUrl
|
//NotifyUrl
|
||||||
"NotifyUrl": "http://*:8082/api/WeixinPay/PayNotify"
|
"NotifyUrl": "http://*:8082/api/WeixinPay/PayNotify"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
echo "newcollage-api..."
|
||||||
|
sleep 3
|
||||||
|
docker stop newcollage-api
|
||||||
|
sleep 2
|
||||||
|
docker rm newcollage-api
|
||||||
|
|
||||||
|
docker rmi newcollage-api
|
||||||
|
echo ""
|
||||||
|
echo "newcollage-api packing..."
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
docker build -t newcollage-api .
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "newcollage-api running..."
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
-p 8083:8083 \
|
||||||
|
--name newcollage-api \
|
||||||
|
-d newcollage-api
|
||||||
|
|
@ -3,7 +3,9 @@ using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using Essensoft.AspNetCore.Payment.Alipay.Domain;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NPOI.SS.Formula.Functions;
|
||||||
|
|
||||||
namespace New_College.Common
|
namespace New_College.Common
|
||||||
{
|
{
|
||||||
|
|
@ -16,7 +18,7 @@ namespace New_College.Common
|
||||||
/// <param name="secret"></param>
|
/// <param name="secret"></param>
|
||||||
/// <param name="code"></param>
|
/// <param name="code"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T AuthCode2Session<T>(string appid, string secret, string code) where T :new()
|
public static T AuthCode2Session<T>(string appid, string secret, string code) where T : new()
|
||||||
{
|
{
|
||||||
var authinfo = new T();
|
var authinfo = new T();
|
||||||
try
|
try
|
||||||
|
|
@ -42,6 +44,68 @@ namespace New_College.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取AccessToken
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="appid"></param>
|
||||||
|
/// <param name="secret"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T GetAccessToken<T>(string appid, string secret) where T : new()
|
||||||
|
{
|
||||||
|
|
||||||
|
var authinfo = new T();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
string requestUri = string.Format("https://api.weixin.qq.com/cgi-bin/token?appid={0}&secret={1}&grant_type=client_credential", appid, secret);
|
||||||
|
var httpClientHandler = new HttpClientHandler
|
||||||
|
{
|
||||||
|
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
|
||||||
|
};
|
||||||
|
|
||||||
|
using (HttpClient httpClient = new HttpClient(httpClientHandler))
|
||||||
|
{
|
||||||
|
var responseStr = httpClient.GetAsync(requestUri).Result.Content.ReadAsStringAsync().Result;
|
||||||
|
var obj = JsonConvert.DeserializeObject<T>(responseStr);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T WxaBusinessGetUserPhoneNumber<T>(string access_token, string code) where T : new()
|
||||||
|
{
|
||||||
|
var authinfo = new T();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string requestUri = string.Format("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={0}", access_token);
|
||||||
|
var httpClientHandler = new HttpClientHandler
|
||||||
|
{
|
||||||
|
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
|
||||||
|
};
|
||||||
|
|
||||||
|
using (HttpClient httpClient = new HttpClient(httpClientHandler))
|
||||||
|
{
|
||||||
|
var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(new WxaBusinessModel() { code = code }), Encoding.UTF8, "application/json");
|
||||||
|
var responseStr = httpClient.PostAsync(requestUri, content).Result.Content.ReadAsStringAsync().Result;
|
||||||
|
var obj = JsonConvert.DeserializeObject<T>(responseStr);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class WxaBusinessModel
|
||||||
|
{
|
||||||
|
public string code { get; set; }
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 统一下单
|
* 统一下单
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@ namespace New_College.IServices
|
||||||
|
|
||||||
|
|
||||||
Weixinauthinfo AuthCode2Session(string Code);
|
Weixinauthinfo AuthCode2Session(string Code);
|
||||||
|
|
||||||
|
Access_Token access_Token();
|
||||||
|
|
||||||
|
WxaBusinessGetUserPhoneNumberResponse WxaBusinessGetUserPhoneNumber(WxaBusinessGetUserPhoneNumberRequest request);
|
||||||
string GetWeixinPhone(GetPhoneInfo phoneInfo);
|
string GetWeixinPhone(GetPhoneInfo phoneInfo);
|
||||||
|
|
||||||
Task<Tuple<bool, CustomerInfoResult>> Logined(LoginQuery query);
|
Task<Tuple<bool, CustomerInfoResult>> Logined(LoginQuery query);
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,12 @@ namespace New_College.Model.Request
|
||||||
|
|
||||||
public string AreaName { get; set; }
|
public string AreaName { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class DecryptUserPhoneRequest
|
||||||
|
{
|
||||||
|
public string openId { get; set; }
|
||||||
|
public string code { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,48 @@ namespace New_College.Model
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class Access_Token
|
||||||
|
{
|
||||||
|
public string access_token { get; set; }
|
||||||
|
|
||||||
|
public int expires_in { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class WxaBusinessGetUserPhoneNumberResponse
|
||||||
|
{
|
||||||
|
public int errcode { get; set; }
|
||||||
|
public string errmsg { get; set; }
|
||||||
|
public Phone_Info phone_info { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WxaBusinessGetUserPhoneNumberRequest
|
||||||
|
{
|
||||||
|
public string access_Token { get; set; }
|
||||||
|
|
||||||
|
public string code { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class Phone_Info
|
||||||
|
{
|
||||||
|
public string phoneNumber { get; set; }
|
||||||
|
public string purePhoneNumber { get; set; }
|
||||||
|
public int countryCode { get; set; }
|
||||||
|
public Watermark watermark { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Watermark
|
||||||
|
{
|
||||||
|
public int timestamp { get; set; }
|
||||||
|
public string appid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class GetPhoneInfo
|
public class GetPhoneInfo
|
||||||
{
|
{
|
||||||
public string encryptedData { get; set; }
|
public string encryptedData { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ namespace New_College.Services
|
||||||
{
|
{
|
||||||
var majorcategories = (await d_MajorCategoryRepository.Query(x => x.Type == query.SchoolLevel && x.IsDelete == false)).Select(x => new uniMajorSelect() { Id = x.Id, Name = x.Name }); ;
|
var majorcategories = (await d_MajorCategoryRepository.Query(x => x.Type == query.SchoolLevel && x.IsDelete == false)).Select(x => new uniMajorSelect() { Id = x.Id, Name = x.Name }); ;
|
||||||
var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId });
|
var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId });
|
||||||
var majorinfo = (await d_MajorRepository.Query(x => x.IsDelete == false)).Select(s => new uniMajorSelect() { Id = s.CategoryClass_Id, Name = s.Name }).ToList();
|
var majorinfo = (await d_MajorRepository.Query(x => x.IsDelete == false&&x.Type!=3)).Select(s => new uniMajorSelect() { Id = s.CategoryClass_Id, Name = s.Name }).ToList();
|
||||||
List<uniMajorInfoResult> list = new List<uniMajorInfoResult>() { };
|
List<uniMajorInfoResult> list = new List<uniMajorInfoResult>() { };
|
||||||
foreach (var item in majorcategories)
|
foreach (var item in majorcategories)
|
||||||
{
|
{
|
||||||
|
|
@ -565,7 +565,7 @@ namespace New_College.Services
|
||||||
{
|
{
|
||||||
var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId });
|
var majorclasses = (await d_MajorClassRepository.Query(x => x.IsDelete == false)).Select(x => new uniMajorClassSelect() { Id = x.Id, Name = x.Name, TradeId = x.TradeId });
|
||||||
var nowmajorname = majorclasses.Where(x => x.Id == query.categoryclassid).Select(x => x.Name)?.FirstOrDefault();
|
var nowmajorname = majorclasses.Where(x => x.Id == query.categoryclassid).Select(x => x.Name)?.FirstOrDefault();
|
||||||
var newmajorinfo = await d_MajorRepository.Query(x => x.IsDelete == false && x.CategoryClass_Id == query.categoryclassid);
|
var newmajorinfo = await d_MajorRepository.Query(x => x.IsDelete == false && x.CategoryClass_Id == query.categoryclassid && x.Type != 3);
|
||||||
info = newmajorinfo.Where(x => x.Name != nowmajorname).Select(x => new uniMajorInfo() { Id = x.Id, Name = x.MajorName }).ToList();
|
info = newmajorinfo.Where(x => x.Name != nowmajorname).Select(x => new uniMajorInfo() { Id = x.Id, Name = x.MajorName }).ToList();
|
||||||
}
|
}
|
||||||
return new MessageModel<List<uniMajorInfo>>()
|
return new MessageModel<List<uniMajorInfo>>()
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,24 @@ namespace New_College.Services
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取accesstoken
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Access_Token access_Token()
|
||||||
|
{
|
||||||
|
return WeixinHelper.GetAccessToken<Access_Token>(WeixinConfig.Appid, WeixinConfig.Secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public WxaBusinessGetUserPhoneNumberResponse WxaBusinessGetUserPhoneNumber(WxaBusinessGetUserPhoneNumberRequest request)
|
||||||
|
{
|
||||||
|
return WeixinHelper.WxaBusinessGetUserPhoneNumber<WxaBusinessGetUserPhoneNumberResponse>(request.access_Token, request.code);
|
||||||
|
}
|
||||||
public string GetWeixinPhone(GetPhoneInfo phoneInfo)
|
public string GetWeixinPhone(GetPhoneInfo phoneInfo)
|
||||||
{
|
{
|
||||||
string phone = string.Empty;
|
string phone = string.Empty;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue