From af218c8825d396855feb924334f8c62bba9d5987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Thu, 1 Feb 2024 11:20:13 +0800 Subject: [PATCH] feat:bug fixed --- .../Controllers/Front/CustomerController.cs | 5 +- New_College.Api/New_College.Model.xml | 5 + New_College.Api/appsettings.Development.json | 9 +- New_College.Api/appsettings.json | 9 +- New_College.IServices/ICasdoorUserServices.cs | 13 + New_College.Model/Models/CasDoorUsers.cs | 339 ++++++++++++++++++ .../BASE/CasdoorUserRepository.cs | 38 ++ .../BASE/ICasdoorUserRepository.cs | 21 ++ New_College.Services/CasdoorUserServices.cs | 26 ++ .../V_CustomerInfoServices.cs | 40 +-- 10 files changed, 473 insertions(+), 32 deletions(-) create mode 100644 New_College.IServices/ICasdoorUserServices.cs create mode 100644 New_College.Model/Models/CasDoorUsers.cs create mode 100644 New_College.Repository/BASE/CasdoorUserRepository.cs create mode 100644 New_College.Repository/BASE/ICasdoorUserRepository.cs create mode 100644 New_College.Services/CasdoorUserServices.cs diff --git a/New_College.Api/Controllers/Front/CustomerController.cs b/New_College.Api/Controllers/Front/CustomerController.cs index 30d7474..23c40d2 100644 --- a/New_College.Api/Controllers/Front/CustomerController.cs +++ b/New_College.Api/Controllers/Front/CustomerController.cs @@ -25,10 +25,12 @@ namespace New_College.Api.Controllers.Front { private readonly IV_CustomerInfoServices _services; private readonly ID_UserSettingBaseServices _userSetting; - public CustomerController(IV_CustomerInfoServices IV_CustomerInfoServices, ID_UserSettingBaseServices userSetting) + private readonly ICasdoorUserServices _casdoorUserServices; + public CustomerController(IV_CustomerInfoServices IV_CustomerInfoServices, ID_UserSettingBaseServices userSetting, ICasdoorUserServices casdoorUserServices) { _services = IV_CustomerInfoServices; _userSetting = userSetting; + _casdoorUserServices = casdoorUserServices; } @@ -97,6 +99,7 @@ namespace New_College.Api.Controllers.Front var newmodel = single.FirstOrDefault(); newmodel.IsDelete = true; var update = await _services.Update(newmodel); + await _casdoorUserServices.AccontCancel(login.openId); return new MessageModel() { success = true, diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index 6e9ee08..7e83ba7 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -160,6 +160,11 @@ 逻辑删除 + + + + + 招生简章 diff --git a/New_College.Api/appsettings.Development.json b/New_College.Api/appsettings.Development.json index b411168..fe42b2f 100644 --- a/New_College.Api/appsettings.Development.json +++ b/New_College.Api/appsettings.Development.json @@ -58,7 +58,7 @@ // 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6 "MainDB": "WMBLOG_MYSQL", //当前项目的主库,所对应的连接字符串的Enabled必须为true - "MutiDBEnabled": false, //是否开启多库模式 + "MutiDBEnabled": true, //是否开启多库模式 "CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer "DBS": [ /* @@ -99,6 +99,13 @@ "HitRate": 20, "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=volunteerapp; Uid=ycymedu; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" }, + { + "ConnId": "MYSQL_CasDoor", + "DBType": 0, + "Enabled": true, + "HitRate": 20, + "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=casdoor; Uid=ycymedu; Pwd=Vs..127134" + }, { "ConnId": "WMBLOG_ORACLE", "DBType": 3, diff --git a/New_College.Api/appsettings.json b/New_College.Api/appsettings.json index b032a01..ff63e33 100644 --- a/New_College.Api/appsettings.json +++ b/New_College.Api/appsettings.json @@ -58,7 +58,7 @@ // 具体配置看视频:https://www.bilibili.com/video/BV1BJ411B7mn?p=6 "MainDB": "WMBLOG_MYSQL", //当前项目的主库,所对应的连接字符串的Enabled必须为true - "MutiDBEnabled": false, //是否开启多库模式 + "MutiDBEnabled": true, //是否开启多库模式 "CQRSEnabled": false, //是否开启读写分离模式,必须是单库模式,且数据库类型一致,比如都是SqlServer "DBS": [ /* @@ -99,6 +99,13 @@ "HitRate": 20, "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=volunteerapp; Uid=ycymedu; Pwd=Vs..127134;CharSet=utf8mb4" }, + { + "ConnId": "MYSQL_CasDoor", + "DBType": 0, + "Enabled": true, + "HitRate": 20, + "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=casdoor; Uid=ycymedu; Pwd=Vs..127134" + }, { "ConnId": "WMBLOG_ORACLE", "DBType": 3, diff --git a/New_College.IServices/ICasdoorUserServices.cs b/New_College.IServices/ICasdoorUserServices.cs new file mode 100644 index 0000000..c1f7bbc --- /dev/null +++ b/New_College.IServices/ICasdoorUserServices.cs @@ -0,0 +1,13 @@ +using New_College.IServices.BASE; +using New_College.Model.Models; +using System.Threading.Tasks; +namespace New_College.IServices +{ + /// + /// IuserServices + /// + public interface ICasdoorUserServices : IBaseServices + { + Task AccontCancel(string openId); + } +} \ No newline at end of file diff --git a/New_College.Model/Models/CasDoorUsers.cs b/New_College.Model/Models/CasDoorUsers.cs new file mode 100644 index 0000000..1244216 --- /dev/null +++ b/New_College.Model/Models/CasDoorUsers.cs @@ -0,0 +1,339 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + + +namespace New_College.Model.Models +{ + /// + /// + /// + [SugarTable("user", "MYSQL_CasDoor")] + public class CasdoorUser + { + public CasdoorUser() + { + } + + [SugarColumn(IsPrimaryKey = true)] + public string owner { get; set; } + + [SugarColumn(IsPrimaryKey = true)] + public string name { get; set; } + + [SugarColumn(Length = 100)] + public string created_time { get; set; } + + [SugarColumn(Length = 100)] + public string updated_time { get; set; } + + [SugarColumn(Length = 100)] + public string id { get; set; } + + [SugarColumn(Length = 100)] + public string external_id { get; set; } + + [SugarColumn(Length = 100)] + public string type { get; set; } + + [SugarColumn(Length = 100)] + public string password { get; set; } + [SugarColumn(Length = 100)] + + public string password_salt { get; set; } + + [SugarColumn(Length = 100)] + public string password_type { get; set; } + + [SugarColumn(Length = 100)] + public string display_name { get; set; } + + [SugarColumn(Length = 100)] + public string first_name { get; set; } + + [SugarColumn(Length = 100)] + public string last_name { get; set; } + + [SugarColumn(Length = 500)] + public string avatar { get; set; } + [SugarColumn(Length = 100)] + public string avatar_type { get; set; } + + [SugarColumn(Length = 500)] + public string permanent_avatar { get; set; } + + + [SugarColumn(Length = 100)] + + public string email { get; set; } + + [SugarColumn(Length = 100)] + public byte? email_verified { get; set; } + + [SugarColumn(Length = 100)] + public string phone { get; set; } + + [SugarColumn(Length = 100)] + public string country_code { get; set; } + + [SugarColumn(Length = 100)] + public string region { get; set; } + + [SugarColumn(Length = 100)] + public string location { get; set; } + + [SugarColumn(ColumnDataType = "text", Length = int.MaxValue, IsNullable = true)] + public string address { get; set; } + + [SugarColumn(Length = 100)] + public string affiliation { get; set; } + + [SugarColumn(Length = 100)] + public string title { get; set; } + + [SugarColumn(Length = 100)] + public string id_card_type { get; set; } + + [SugarColumn(Length = 100)] + public string id_card { get; set; } + + [SugarColumn(Length = 100)] + public string homepage { get; set; } + + [SugarColumn(Length = 100)] + public string bio { get; set; } + + [SugarColumn(Length = 100)] + public string tag { get; set; } + + [SugarColumn(Length = 100)] + public string language { get; set; } + + [SugarColumn(Length = 100)] + public string gender { get; set; } + + [SugarColumn(Length = 100)] + public string birthday { get; set; } + + [SugarColumn(Length = 100)] + public string education { get; set; } + + + public int? score { get; set; } + + public int? karma { get; set; } + + public int? ranking { get; set; } + + public byte? is_default_avatar { get; set; } + + public byte? is_online { get; set; } + + public byte? is_admin { get; set; } + + public byte? is_forbidden { get; set; } + + public byte? is_deleted { get; set; } + + [SugarColumn(Length = 100)] + public string signup_application { get; set; } + + [SugarColumn(Length = 100)] + public string hash { get; set; } + + [SugarColumn(Length = 100)] + public string pre_hash { get; set; } + + [SugarColumn(Length = 100)] + public string access_key { get; set; } + [SugarColumn(Length = 100)] + public string access_secret { get; set; } + [SugarColumn(Length = 100)] + public string created_ip { get; set; } + [SugarColumn(Length = 100)] + public string last_signin_time { get; set; } + [SugarColumn(Length = 100)] + public string last_signin_ip { get; set; } + [SugarColumn(Length = 100)] + public string github { get; set; } + [SugarColumn(Length = 100)] + public string google { get; set; } + [SugarColumn(Length = 100)] + public string qq { get; set; } + [SugarColumn(Length = 100)] + public string wechat { get; set; } + [SugarColumn(Length = 100)] + public string facebook { get; set; } + [SugarColumn(Length = 100)] + public string dingtalk { get; set; } + [SugarColumn(Length = 100)] + public string weibo { get; set; } + [SugarColumn(Length = 100)] + public string gitee { get; set; } + [SugarColumn(Length = 100)] + public string linkedin { get; set; } + [SugarColumn(Length = 100)] + public string wecom { get; set; } + [SugarColumn(Length = 100)] + public string lark { get; set; } + [SugarColumn(Length = 100)] + public string gitlab { get; set; } + [SugarColumn(Length = 100)] + public string adfs { get; set; } + [SugarColumn(Length = 100)] + public string baidu { get; set; } + [SugarColumn(Length = 100)] + public string alipay { get; set; } + [SugarColumn(Length = 100)] + public string casdoor { get; set; } + [SugarColumn(Length = 100)] + public string infoflow { get; set; } + [SugarColumn(Length = 100)] + public string apple { get; set; } + [SugarColumn(Length = 100)] + public string azuread { get; set; } + [SugarColumn(Length = 100)] + public string slack { get; set; } + [SugarColumn(Length = 100)] + public string steam { get; set; } + [SugarColumn(Length = 100)] + public string bilibili { get; set; } + [SugarColumn(Length = 100)] + public string okta { get; set; } + [SugarColumn(Length = 100)] + public string douyin { get; set; } + [SugarColumn(Length = 100)] + public string line { get; set; } + [SugarColumn(Length = 100)] + public string amazon { get; set; } + [SugarColumn(Length = 100)] + public string auth0 { get; set; } + [SugarColumn(Length = 100)] + public string battlenet { get; set; } + [SugarColumn(Length = 100)] + public string bitbucket { get; set; } + [SugarColumn(Length = 100)] + public string box { get; set; } + [SugarColumn(Length = 100)] + public string cloudfoundry { get; set; } + [SugarColumn(Length = 100)] + public string dailymotion { get; set; } + [SugarColumn(Length = 100)] + public string deezer { get; set; } + [SugarColumn(Length = 100)] + public string digitalocean { get; set; } + [SugarColumn(Length = 100)] + public string discord { get; set; } + [SugarColumn(Length = 100)] + public string dropbox { get; set; } + [SugarColumn(Length = 100)] + public string eveonline { get; set; } + [SugarColumn(Length = 100)] + public string fitbit { get; set; } + [SugarColumn(Length = 100)] + public string gitea { get; set; } + [SugarColumn(Length = 100)] + public string heroku { get; set; } + [SugarColumn(Length = 100)] + public string influxcloud { get; set; } + [SugarColumn(Length = 100)] + public string instagram { get; set; } + [SugarColumn(Length = 100)] + public string intercom { get; set; } + [SugarColumn(Length = 100)] + public string kakao { get; set; } + [SugarColumn(Length = 100)] + public string lastfm { get; set; } + [SugarColumn(Length = 100)] + public string mailru { get; set; } + [SugarColumn(Length = 100)] + public string meetup { get; set; } + [SugarColumn(Length = 100)] + public string microsoftonline { get; set; } + [SugarColumn(Length = 100)] + public string naver { get; set; } + [SugarColumn(Length = 100)] + public string nextcloud { get; set; } + [SugarColumn(Length = 100)] + public string onedrive { get; set; } + [SugarColumn(Length = 100)] + public string oura { get; set; } + [SugarColumn(Length = 100)] + public string patreon { get; set; } + [SugarColumn(Length = 100)] + public string paypal { get; set; } + [SugarColumn(Length = 100)] + public string salesforce { get; set; } + [SugarColumn(Length = 100)] + public string shopify { get; set; } + [SugarColumn(Length = 100)] + public string soundcloud { get; set; } + [SugarColumn(Length = 100)] + public string spotify { get; set; } + [SugarColumn(Length = 100)] + public string strava { get; set; } + [SugarColumn(Length = 100)] + public string stripe { get; set; } + [SugarColumn(Length = 100)] + public string tiktok { get; set; } + [SugarColumn(Length = 100)] + public string tumblr { get; set; } + [SugarColumn(Length = 100)] + public string twitch { get; set; } + [SugarColumn(Length = 100)] + public string twitter { get; set; } + [SugarColumn(Length = 100)] + public string typetalk { get; set; } + [SugarColumn(Length = 100)] + public string uber { get; set; } + [SugarColumn(Length = 100)] + public string vk { get; set; } + [SugarColumn(Length = 100)] + public string wepay { get; set; } + [SugarColumn(Length = 100)] + public string xero { get; set; } + [SugarColumn(Length = 100)] + public string yahoo { get; set; } + [SugarColumn(Length = 100)] + public string yammer { get; set; } + [SugarColumn(Length = 100)] + public string yandex { get; set; } + [SugarColumn(Length = 100)] + public string zoom { get; set; } + [SugarColumn(Length = 100)] + public string metamask { get; set; } + [SugarColumn(Length = 100)] + public string web3onboard { get; set; } + [SugarColumn(Length = 100)] + public string custom { get; set; } + + //public byte[] webauthnCredentials { get; set; } + [SugarColumn(Length = 100)] + public string preferred_mfa_type { get; set; } + [SugarColumn(Length = 1000)] + public string recovery_codes { get; set; } + [SugarColumn(Length = 100)] + public string totp_secret { get; set; } + + public byte? mfa_phone_enabled { get; set; } + + public byte? mfa_email_enabled { get; set; } + [SugarColumn(Length = 100)] + public string ldap { get; set; } + [SugarColumn(Length = 100)] + public string properties { get; set; } + [SugarColumn(Length = 100)] + public string roles { get; set; } + [SugarColumn(Length = 100)] + public string permissions { get; set; } + [SugarColumn(Length = 1000)] + public string groups { get; set; } + [SugarColumn(Length = 100)] + public string last_signin_wrong_time { get; set; } + + public int? signin_wrong_times { get; set; } + + //public byte[] managedAccounts { get; set; } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/CasdoorUserRepository.cs b/New_College.Repository/BASE/CasdoorUserRepository.cs new file mode 100644 index 0000000..f5c070c --- /dev/null +++ b/New_College.Repository/BASE/CasdoorUserRepository.cs @@ -0,0 +1,38 @@ +using New_College.IRepository; +using New_College.IRepository.UnitOfWork; +using New_College.Model.Models; +using New_College.Model.ViewModels; +using New_College.Repository.Base; +using System.Linq; +using System.Threading.Tasks; + +namespace New_College.Repository.MYSQL_CasDoor +{ + /// + /// userRepository + /// + public class CasdoorUserRepository : BaseRepository, ICasdoorUserRepository + { + public CasdoorUserRepository(IUnitOfWork unitOfWork) : base(unitOfWork) + { + } + + /// + /// + /// + /// + /// + public async Task AccountCancel(string id) + { + var status = false; + var query = await this.Query(e => e.id == id); + if (query != null && query.Count > 0) + { + var isdelete = query.FirstOrDefault(); + isdelete.is_deleted = 1; + status = await this.Update(isdelete); + } + return status; + } + } +} \ No newline at end of file diff --git a/New_College.Repository/BASE/ICasdoorUserRepository.cs b/New_College.Repository/BASE/ICasdoorUserRepository.cs new file mode 100644 index 0000000..9b29573 --- /dev/null +++ b/New_College.Repository/BASE/ICasdoorUserRepository.cs @@ -0,0 +1,21 @@ + +using New_College.IRepository.Base; +using New_College.Model.Models; +using System.Threading.Tasks; + +namespace New_College.IRepository +{ + /// + /// IuserRepository + /// + public interface ICasdoorUserRepository : IBaseRepository + { + + /// + /// 注销账户 + /// + /// + /// + Task AccountCancel(string id); + } +} \ No newline at end of file diff --git a/New_College.Services/CasdoorUserServices.cs b/New_College.Services/CasdoorUserServices.cs new file mode 100644 index 0000000..a91cf64 --- /dev/null +++ b/New_College.Services/CasdoorUserServices.cs @@ -0,0 +1,26 @@ +using New_College.Services.BASE; +using New_College.IRepository.Base; +using New_College.IServices; +using New_College.Model.Models; +using System.Threading.Tasks; +using New_College.IRepository; + +namespace New_College.Services +{ + public class CasdoorUserServices : BaseServices, ICasdoorUserServices + { + private readonly IBaseRepository _dal; + private readonly ICasdoorUserRepository _userRepository; + public CasdoorUserServices(IBaseRepository dal, ICasdoorUserRepository casdoorUserRepository) + { + this._dal = dal; + base.BaseDal = dal; + _userRepository = casdoorUserRepository; + } + + public async Task AccontCancel(string openId) + { + return await _userRepository.AccountCancel(openId); + } + } +} \ No newline at end of file diff --git a/New_College.Services/V_CustomerInfoServices.cs b/New_College.Services/V_CustomerInfoServices.cs index fa6817f..f505cc6 100644 --- a/New_College.Services/V_CustomerInfoServices.cs +++ b/New_College.Services/V_CustomerInfoServices.cs @@ -26,11 +26,13 @@ namespace New_College.Services { private readonly IBaseRepository _dal; private readonly IT_BatchlineRepository t_BatchlineRepository; - public V_CustomerInfoServices(IBaseRepository dal, IT_BatchlineRepository t_Batchline) + private readonly ICasdoorUserRepository _casdoorUserRepository; + public V_CustomerInfoServices(IBaseRepository dal, IT_BatchlineRepository t_Batchline, ICasdoorUserRepository casdoorUserRepository) { this._dal = dal; base.BaseDal = dal; t_BatchlineRepository = t_Batchline; + _casdoorUserRepository = casdoorUserRepository; } @@ -38,28 +40,16 @@ namespace New_College.Services /// 同步修改密码 /// /// - private void UpdateCasdoorPwd(CasDoorUpdatePwdDto query) + private async void UpdateCasdoorPwd(CasDoorUpdatePwdDto query) { try { - if (!string.IsNullOrWhiteSpace(query.service_token)) + var list = await _casdoorUserRepository.Query(e => e.id == query.openId); + if (list != null && list.Count() > 0) { - var headers = new System.Collections.Generic.Dictionary - { - { "Authorization", string.Format("Bearer {0}", query.service_token) } - }; - var dics = new Dictionary(); - dics.Add("id", query.openId); - var userinfo = CasdoorHttpHelper.Http_Get("/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("api/update-user", headers, new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(dto), Encoding.UTF8, "application/json")); - //DingHookHelper.DingTalkHookMessage("Updateset-password", JsonConvert.SerializeObject(anyinfo)); + var updatemodels = list.FirstOrDefault(); + updatemodels.password = query.newPassword; + await _casdoorUserRepository.Update(updatemodels); } } catch (Exception ex) @@ -94,14 +84,6 @@ namespace New_College.Services var salt = RadomHelper.RandCode(6); info.UserPwd = MD5Helper.MD5Encrypt16(query.UserPwd + salt); } - - //if (!string.IsNullOrWhiteSpace(query.UserCode)) - //{ - - // info.UserCode = query.UserCode; - //} - - var result = await _dal.Update(info); return new CustomerInfoResult() { @@ -282,7 +264,7 @@ namespace New_College.Services public async Task> GetCustomerInfoById(IdQuery query) { var info = await _dal.QueryById(query.Id); - if (info == null) + if (info == null || info.IsDelete) return new MessageModel() { success = false, msg = "获取失败,用户信息为空" }; var years = info.Year > 2023 ? 2023 : info.Year; var batchlist = await t_BatchlineRepository.Query(c => c.Year == years && c.AreaName == info.AreaName && c.Type_name == "综合"); @@ -412,7 +394,7 @@ namespace New_College.Services public async Task> Logined(LoginQuery query) { - var userinfo = (await _dal.Query(w => w.OpenId == query.openId)).ToList().FirstOrDefault(); + var userinfo = (await _dal.Query(w => w.OpenId == query.openId && w.IsDelete == false)).ToList().FirstOrDefault(); if (userinfo != null) { return new Tuple(true, new CustomerInfoResult()