bug fixed

develop
old易 2024-01-31 22:04:21 +08:00
parent 9928c79eaa
commit 7b6e1a3a74
11 changed files with 335 additions and 35 deletions

View File

@ -44,7 +44,7 @@ namespace New_College.Controllers
var response = new CasDoorToken();
string jwtStr = string.Empty;
bool suc = false;
var getaccesstoken = CasdoorHttpHelper.Http_Post<CasdoorGetTokenResponse>("api/login/oauth/access_token", new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(new CasdoorRequest() { code = code, grant_type = "authorization_code", client_id = CasdoorConfig.ClientId, client_secret = CasdoorConfig.ClientSecret }), Encoding.UTF8, "application/json"));//获取access_token
var getaccesstoken = CasdoorHttpHelper.Http_Post<CasdoorGetTokenResponse>("api/login/oauth/access_token",null, new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(new CasdoorRequest() { code = code, grant_type = "authorization_code", client_id = CasdoorConfig.ClientId, client_secret = CasdoorConfig.ClientSecret }), Encoding.UTF8, "application/json"));//获取access_token
var headers = new System.Collections.Generic.Dictionary<string, string>
{
{ "Authorization", string.Format("Bearer {0}", getaccesstoken.access_token) }

View File

@ -4130,6 +4130,11 @@
用户Id
</summary>
</member>
<member name="P:New_College.Model.ViewModels.UpdateCustomerQuery.service_token">
<summary>
服务端key
</summary>
</member>
<member name="P:New_College.Model.ViewModels.UpdateCustomerQuery.UserPwd">
<summary>
不传就不修改密码

View File

@ -212,8 +212,8 @@
"OrganizationName": "六纬生涯",
"ApplicationName": "六纬生涯",
"ApplicationType": "webapi",
"ClientId": "776d639918192c449537",
"ClientSecret": "d556f0692052a2df56614282dd86895b04783262",
"ClientId": "18766cebe28086f3e676",
"ClientSecret": "f11e7ccfa8562e37f973126697c3714015bd0337",
"CallbackPath": "http://test.sso.ycymedu.com/login/oauth/authorize?client_id=4c6d761417dbbdd665be&response_type=code&redirect_uri=http://192.168.100.129:8081/Home/FirstPage&scope=read&state=casdoor",
"RequireHttpsMetadata": false
},

View File

@ -19,7 +19,7 @@ namespace New_College.Common
/// <param name="inter"></param>
/// <param name="content"></param>
/// <returns></returns>
public static T Http_Post<T>(string inter, HttpContent content) where T : new()
public static T Http_Post<T>(string inter, Dictionary<string, string> headers, HttpContent content) where T : new()
{
var authinfo = new T();
try
@ -31,6 +31,12 @@ namespace New_College.Common
};
using (HttpClient httpClient = new HttpClient(httpClientHandler))
{
//httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
if (headers != null && headers.Any())
{
httpClient.DefaultRequestHeaders.Add(headers.FirstOrDefault().Key, headers.FirstOrDefault().Value);
}
// var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(new CasdoorRefeshToken() { refresh_token = refresh_token, scope = "built-in", grant_type = "authorization_code", client_id = CasdoorConfig.ClientId, client_secret = CasdoorConfig.ClientSecret }), Encoding.UTF8, "application/json");
var responseStr = httpClient.PostAsync(requestUri, content).Result.Content.ReadAsStringAsync().Result;
var obj = JsonConvert.DeserializeObject<T>(responseStr);
@ -51,7 +57,7 @@ namespace New_College.Common
/// <param name="inter"></param>
/// <param name="param"></param>
/// <returns></returns>
public static T Http_Get<T>(string inter, Dictionary<string, string> headers, Dictionary<string,string> dic) where T : new()
public static T Http_Get<T>(string inter, Dictionary<string, string> headers, Dictionary<string, string> dic) where T : new()
{
var authinfo = new T();
@ -60,7 +66,7 @@ namespace New_College.Common
string result = "";
StringBuilder builder = new StringBuilder();
builder.Append(CasdoorConfig.Endpoint);
builder.Append(inter);
builder.Append(inter);
if (dic.Count > 0)
{
builder.Append("?");
@ -74,7 +80,7 @@ namespace New_College.Common
}
}
var httpClientHandler = new HttpClientHandler
var httpClientHandler = new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true,
};

View File

@ -13,25 +13,27 @@ namespace New_College.Common
/// </summary>
/// <param name="Nature"></param>
/// <returns></returns>
public static List<string> NatureNames(List<int> Nature)
public static List<string> NatureNames(string Nature)
{
var str = new List<string>();
if (Nature == null)
return str;
Nature.ForEach(a =>
var Naturesp = Nature.Split(',').ToList();
Naturesp.ForEach(a =>
{
switch (a)
{
case 0:
case "0":
str.Add("公办");
break;
case 1:
case "1":
str.Add("民办");
break;
case 2:
case "2":
str.Add("中外合作");
break;
case 3:
case "3":
str.Add("港澳台");
break;
}

View File

@ -24,6 +24,11 @@ namespace New_College.Model.ViewModels
public class UpdateCustomerQuery
{
/// <summary>
/// 服务端key
/// </summary>
public string service_token { get; set; }
public int Id { get; set; }
public string Phone { get; set; }

View File

@ -1,4 +1,5 @@
using SqlSugar;
using NPOI.POIFS.Storage;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
@ -72,7 +73,9 @@ namespace New_College.Model.ViewModels
/// <summary>
/// 办学性质 0、公办1、民办2中外合作,3 港澳台
/// </summary>
public List<int> Nature { get; set; }
public string Nature { get; set; }
public string Ascription { get; set; }
/// <summary>
///大学类型 综合,理工类,医学类...

View File

@ -26,7 +26,14 @@ namespace New_College.Model.ViewModels
public string code { get; set; }
}
public class CasDoorUpdatePwdDto
{
public string openId { get; set; }
public string newPassword { get; set; }
public string service_token { get; set; }
}
public class CasdoorRefeshToken
{

View File

@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace New_College.Model.ViewModels
{
public class ThridUserRequestDto
{
public string id { get; set; }
public ThridUsersDto body { get; set; }
}
public class ThridUsersDto
{
public string accessKey { get; set; }
public string accessSecret { get; set; }
public string[] address { get; set; }
public string adfs { get; set; }
public string affiliation { get; set; }
public string alipay { get; set; }
public string amazon { get; set; }
public string apple { get; set; }
public string auth0 { get; set; }
public string avatar { get; set; }
public string avatarType { get; set; }
public string azuread { get; set; }
public string azureadb2c { get; set; }
public string baidu { get; set; }
public string battlenet { get; set; }
public string bilibili { get; set; }
public string bio { get; set; }
public string birthday { get; set; }
public string bitbucket { get; set; }
public string box { get; set; }
public string casdoor { get; set; }
public string cloudfoundry { get; set; }
public string countryCode { get; set; }
public string createdIp { get; set; }
public string createdTime { get; set; }
public string custom { get; set; }
public string dailymotion { get; set; }
public string deezer { get; set; }
public string digitalocean { get; set; }
public string dingtalk { get; set; }
public string discord { get; set; }
public string displayName { get; set; }
public string deletedTime { get; set; }
public string douyin { get; set; }
public string dropbox { get; set; }
public string education { get; set; }
public string email { get; set; }
public bool emailVerified { get; set; }
public string eveonline { get; set; }
public string externalId { get; set; }
public string facebook { get; set; }
public string firstName { get; set; }
public string fitbit { get; set; }
public string gender { get; set; }
public string gitea { get; set; }
public string gitee { get; set; }
public string github { get; set; }
public string gitlab { get; set; }
public string google { get; set; }
public string[] groups { get; set; }
public string hash { get; set; }
public string heroku { get; set; }
public string homepage { get; set; }
public string id { get; set; }
public string idCard { get; set; }
public string idCardType { get; set; }
public string influxcloud { get; set; }
public string infoflow { get; set; }
public string instagram { get; set; }
public string intercom { get; set; }
public bool isAdmin { get; set; }
public bool isDefaultAvatar { get; set; }
public bool isDeleted { get; set; }
public bool isForbidden { get; set; }
public bool isOnline { get; set; }
public string kakao { get; set; }
public int karma { get; set; }
public string language { get; set; }
public string lark { get; set; }
public string lastName { get; set; }
public string lastSigninIp { get; set; }
public string lastSigninTime { get; set; }
public string lastSigninWrongTime { get; set; }
public string lastfm { get; set; }
public string ldap { get; set; }
public string line { get; set; }
public string linkedin { get; set; }
public string location { get; set; }
public string mailru { get; set; }
public Managedaccount[] managedAccounts { get; set; }
public string meetup { get; set; }
public string metamask { get; set; }
public bool mfaEmailEnabled { get; set; }
public bool mfaPhoneEnabled { get; set; }
public string microsoftonline { get; set; }
public Multifactorauth[] multiFactorAuths { get; set; }
public string name { get; set; }
public string naver { get; set; }
public string nextcloud { get; set; }
public string okta { get; set; }
public string onedrive { get; set; }
public string oura { get; set; }
public string owner { get; set; }
public string password { get; set; }
public string passwordSalt { get; set; }
public string passwordType { get; set; }
public string patreon { get; set; }
public string paypal { get; set; }
public string permanentAvatar { get; set; }
public Permission[] permissions { get; set; }
public string phone { get; set; }
public string preHash { get; set; }
public string preferredMfaType { get; set; }
public ThridProperties properties { get; set; }
public string qq { get; set; }
public int ranking { get; set; }
public string[] recoveryCodes { get; set; }
public string region { get; set; }
public Role[] roles { get; set; }
public string salesforce { get; set; }
public int score { get; set; }
public string shopify { get; set; }
public int signinWrongTimes { get; set; }
public string signupApplication { get; set; }
public string slack { get; set; }
public string soundcloud { get; set; }
public string spotify { get; set; }
public string steam { get; set; }
public string strava { get; set; }
public string stripe { get; set; }
public string tag { get; set; }
public string tiktok { get; set; }
public string title { get; set; }
public string totpSecret { get; set; }
public string tumblr { get; set; }
public string twitch { get; set; }
public string twitter { get; set; }
public string type { get; set; }
public string typetalk { get; set; }
public string uber { get; set; }
public string updatedTime { get; set; }
public string vk { get; set; }
public string web3onboard { get; set; }
public Webauthncredential[] webauthnCredentials { get; set; }
public string wechat { get; set; }
public string wecom { get; set; }
public string weibo { get; set; }
public string wepay { get; set; }
public string xero { get; set; }
public string yahoo { get; set; }
public string yammer { get; set; }
public string yandex { get; set; }
public string zoom { get; set; }
}
public class ThridProperties
{
public string additionalProp1 { get; set; }
public string additionalProp2 { get; set; }
public string additionalProp3 { get; set; }
}
public class Managedaccount
{
public string application { get; set; }
public string password { get; set; }
public string signinUrl { get; set; }
public string username { get; set; }
}
public class Multifactorauth
{
public string countryCode { get; set; }
public bool enabled { get; set; }
public bool isPreferred { get; set; }
public string mfaType { get; set; }
public string[] recoveryCodes { get; set; }
public string secret { get; set; }
public string url { get; set; }
}
public class Permission
{
public string[] actions { get; set; }
public string adapter { get; set; }
public string approveTime { get; set; }
public string approver { get; set; }
public string createdTime { get; set; }
public string description { get; set; }
public string displayName { get; set; }
public string[] domains { get; set; }
public string effect { get; set; }
public string[] groups { get; set; }
public bool isEnabled { get; set; }
public string model { get; set; }
public string name { get; set; }
public string owner { get; set; }
public string resourceType { get; set; }
public string[] resources { get; set; }
public string[] roles { get; set; }
public string state { get; set; }
public string submitter { get; set; }
public string[] users { get; set; }
}
public class Role
{
public string createdTime { get; set; }
public string description { get; set; }
public string displayName { get; set; }
public string[] domains { get; set; }
public string[] groups { get; set; }
public bool isEnabled { get; set; }
public string name { get; set; }
public string owner { get; set; }
public string[] roles { get; set; }
public string[] users { get; set; }
}
public class Webauthncredential
{
}
}

View File

@ -65,7 +65,7 @@ namespace New_College.Services
int startscore = request.Score - 25;
int endscore = request.Score + 15;
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
var Nature = NatureHelper.NatureNames(request.Nature);
var natureNames = NatureHelper.NatureNames(request.Nature);
Expression<Func<TbSNeedDataInfoPerviewViewDto, bool>> expression = Expressionable.Create<TbSNeedDataInfoPerviewViewDto>()
.And(c => c.Location == request.Location)
.AndIF(!string.IsNullOrWhiteSpace(request.Major), c => SqlFunc.Contains(c.MajorName, request.Major))
@ -75,7 +75,7 @@ namespace New_College.Services
.AndIF(request._211.HasValue && request._211 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "211"))
.AndIF(request._985.HasValue && request._985 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "985"))
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
//.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => c.Nature == request.Nature)
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => SqlFunc.ContainsArray(natureNames, c.Nature))
.AndIF(request.EndScore > endscore || request.StartScore < startscore, c => SqlFunc.Between(c._23SchoolScore, request.StartScore, request.EndScore))
.ToExpression();
var querylist = (await t_TbSNeedDataInfoPev.Query(expression)).Select(c => new TbSNeedDataInfoPerviewViewDto()
@ -162,7 +162,7 @@ namespace New_College.Services
/// <returns></returns>
public async Task<AIGOPageModel<AIGOResponse>> GetAIGoList(OneSubmitGoRequest request)
{
var Nature = NatureHelper.NatureNames(request.Nature);
var NatureNames = NatureHelper.NatureNames(request.Nature);
request.PageSize = request.PageSize > 50 ? 50 : request.PageSize;
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
var pagemodel = new AIGOPageModel<AIGOResponse>();
@ -185,7 +185,9 @@ namespace New_College.Services
.AndIF(request._211.HasValue && request._211 == 1, c => c._211 == "是")
.AndIF(request._985.HasValue && request._985 == 1, c => c._985 == "是")
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
.AndIF(request.Nature != null && request.Nature.Count() > 0, c => SqlFunc.ContainsArray(Nature, request.Nature))
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => SqlFunc.ContainsArray(NatureNames, c.Nature))
// .AndIF(!string.IsNullOrWhiteSpace(request.Ascription), c => SqlFunc.Contains(request.Ascription, c.Ascription))
//暂缺军校此字段数据
.ToExpression();
//var query = await _qualificationLineRepository.QueryPage(expression, request.PageIndex, request.PageSize, " LowScoreRank desc ");
var query = await _qualificationLineRepository.QueryPage(expression, request.PageIndex, request.PageSize, " LowScoreRank desc ");
@ -205,7 +207,7 @@ namespace New_College.Services
.AndIF(request._211.HasValue && request._211 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "211"))
.AndIF(request._985.HasValue && request._985 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "985"))
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
.AndIF(request.Nature != null && request.Nature.Count() > 0, c => SqlFunc.ContainsArray(Nature, request.Nature))
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => SqlFunc.ContainsArray(NatureNames, c.Nature))
.AndIF(universityarry.Any(), c => SqlFunc.ContainsArray(universityarry, c.UniversityName))
.AndIF(request.EndScore > endscore || request.StartScore < startscore, c => SqlFunc.Between(c._23Score, request.StartScore, request.EndScore))
.ToExpression();
@ -305,33 +307,27 @@ namespace New_College.Services
/// <returns></returns>
public async Task<PageModel<OneSubmitGoResponse>> GetPlanMajorList(OneSubmitGoRequest request)
{
var pagemodel = new PageModel<OneSubmitGoResponse>();
var Nature = NatureHelper.NatureNames(request.Nature);
var NatureNames = NatureHelper.NatureNames(request.Nature);
request.PageSize = request.PageSize < 100 ? 100 : request.PageSize;
//request.PageSize = 150;//山东省
request.Year = request.Year > 2023 ? 2023 : request.Year;
var claim = request.SubjectClaim.Split(",", StringSplitOptions.RemoveEmptyEntries).ToList();
Expression<Func<T_TbSNeedDataInfo, bool>> expression3 = Expressionable.Create<T_TbSNeedDataInfo>()
.And(c => c.Location == request.Location)
.AndIF(!string.IsNullOrWhiteSpace(request.SubjectClaim), c => SqlFunc.Contains(c._24subject, claim[0]) || SqlFunc.Contains(c._24subject, claim[1]) || SqlFunc.Contains(c._24subject, claim[2]) || c._24subject == "不限")
.AndIF(!string.IsNullOrWhiteSpace(request.Major), c => SqlFunc.Contains(c.MajorName, request.Major))
//.AndIF(!string.IsNullOrWhiteSpace(request.BatchName), c => c.BatchName.Equals(request.BatchName))
.AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province, c.Province))
//.And(c => c.Years == request.Year)
.AndIF(!string.IsNullOrWhiteSpace(request.Province), c => SqlFunc.Contains(request.Province, c.Province))
//.AndIF(!string.IsNullOrWhiteSpace(request.SchoolType), c => c.SchoolType == request.SchoolType)
.AndIF(request.Score > 0, c => SqlFunc.Between(c._23Score, request.Score - 25, request.Score + 15))
.AndIF(request.Syl.HasValue && request.Syl == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "双一流"))
.AndIF(request._211.HasValue && request._211 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "211"))
.AndIF(request._985.HasValue && request._985 == 1, c => SqlFunc.Contains(c.LnstitutionalLevel, "985"))
.AndIF(!string.IsNullOrWhiteSpace(request.Ownership), c => c.Ownership == request.Ownership)
.AndIF(request.Nature != null && request.Nature.Count() > 0, c => SqlFunc.ContainsArray(Nature, request.Nature))
.AndIF(!string.IsNullOrWhiteSpace(request.Nature), c => SqlFunc.ContainsArray(NatureNames, c.Nature))
//.AndIF(request. > 0, c => SqlFunc.Between(c.LowScore, request.Score, request.Score)) 位次区间
.ToExpression();
var querylist = await this.sNeedDataInfoServices.Query(expression3);
var universitymaps = (await _UniversityServices.Query(c => c.IsDelete == false)).Select(c => new D_University()
{
Id = c.Id,
@ -386,7 +382,7 @@ namespace New_College.Services
},
}
}).ToList();
////冲稳保比例--待定
//冲稳保比例--待定
var newlist = responselist.Where(c => c.Type == 2).OrderByDescending(c => c.SubjectClam).OrderByDescending(c => c.LowScore).Take(25).ToList();
newlist.AddRange(responselist.Where(c => c.Type == 1).OrderByDescending(c => c.SubjectClam).OrderByDescending(c => c.LowScore).Take(45).ToList());
newlist.AddRange(responselist.Where(c => c.Type == 0).OrderByDescending(c => c.SubjectClam).OrderByDescending(c => c.LowScore).Take(30).ToList());

View File

@ -15,6 +15,10 @@ using New_College.Model;
using LinqKit;
using New_College.Model.Request;
using New_College.IRepository;
using NPOI.SS.Formula.Functions;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
namespace New_College.Services
{
@ -30,7 +34,40 @@ namespace New_College.Services
}
/// <summary>
/// 同步修改密码
/// </summary>
/// <param name="query"></param>
private void UpdateCasdoorPwd(CasDoorUpdatePwdDto query)
{
try
{
if (!string.IsNullOrWhiteSpace(query.service_token))
{
var headers = new System.Collections.Generic.Dictionary<string, string>
{
{ "Authorization", string.Format("Bearer {0}", query.service_token) }
};
var dics = new Dictionary<string, string>();
dics.Add("id", query.openId);
var userinfo = CasdoorHttpHelper.Http_Get<dynamic>("/api/get-user", headers, dics);
userinfo.password = query.newPassword;
var dto = new ThridUserRequestDto()
{
body = userinfo,
id = query.openId
};
//DingHookHelper.DingTalkHookMessage("Updaterequest", request);
var anyinfo = CasdoorHttpHelper.Http_Post<dynamic>("api/update-user", headers, new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json"));
//DingHookHelper.DingTalkHookMessage("Updateset-password", JsonConvert.SerializeObject(anyinfo));
}
}
catch (Exception ex)
{
DingHookHelper.DingTalkHookMessage("UpdateCasdoorPwd", ex.Message);
}
//获取access_token
}
/// <summary>
/// 修改用户信息
/// </summary>
@ -45,17 +82,24 @@ namespace New_College.Services
//info.Phone = query.Phone;
info.Gender = query.Gender;
info.AvatarUrl = query.AvatarUrl;
DingHookHelper.DingTalkHookMessage("CasDoorUpdate", query.service_token);
UpdateCasdoorPwd(new CasDoorUpdatePwdDto()
{
newPassword = query.UserPwd,
openId = info.OpenId,
service_token = query.service_token
});
if (!string.IsNullOrWhiteSpace(query.UserPwd))
{
var salt = RadomHelper.RandCode(6);
info.UserPwd = MD5Helper.MD5Encrypt16(query.UserPwd + salt);
}
if (!string.IsNullOrWhiteSpace(query.UserCode))
{
//if (!string.IsNullOrWhiteSpace(query.UserCode))
//{
info.UserCode = query.UserCode;
}
// info.UserCode = query.UserCode;
//}
var result = await _dal.Update(info);