Commit 4e70c537 authored by 黄奎's avatar 黄奎

用户登录新增校区验证

parent db738349
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend; using EduSpider.Model.Extend;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VTX.FW.Config; using VTX.FW.Config;
using VTX.FW.DB; using VTX.FW.DB;
...@@ -25,5 +21,12 @@ namespace EduSpider.Repository ...@@ -25,5 +21,12 @@ namespace EduSpider.Repository
int GetMaxStuTeaId(int type); int GetMaxStuTeaId(int type);
public List<rb_account_hk_Extend> GetAccountList(rb_account_hk_Extend demodel); public List<rb_account_hk_Extend> GetAccountList(rb_account_hk_Extend demodel);
/// <summary>
/// 获取教师信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<EmployeeInfo> GetEmployeeListRepository(EmployeeInfo query);
} }
} }
...@@ -23,5 +23,12 @@ namespace EduSpider.IServices ...@@ -23,5 +23,12 @@ namespace EduSpider.IServices
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
public bool UpdatePassword(rb_account_hk_Extend model); public bool UpdatePassword(rb_account_hk_Extend model);
/// <summary>
/// 获取员工信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<EmployeeInfo> GetEmployeeList(EmployeeInfo query);
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EduSpider.Model.Extend
{
/// <summary>
/// 员工信息
/// </summary>
public class EmployeeInfo
{
/// <summary>
/// 校区编号
/// </summary>
public int School_Id { get; set; }
/// <summary>
/// 员工姓名
/// </summary>
public string EmployeeName { get; set; }
/// <summary>
/// 员工电话
/// </summary>
public string EmployeeTel { get; set; }
}
}
...@@ -80,5 +80,35 @@ INNER JOIN rb_student_hk s on a.Id =s.StudId and a.AccountType =2 ...@@ -80,5 +80,35 @@ INNER JOIN rb_student_hk s on a.Id =s.StudId and a.AccountType =2
var obj = ExecuteScalar(sql); var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj); return obj == null ? 0 : Convert.ToInt32(obj);
} }
/// <summary>
/// 获取教师信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<EmployeeInfo> GetEmployeeListRepository(EmployeeInfo query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.* FROM
(
SELECT A.School_Id,A.TeacherName AS EmployeeName,A.TeacherTel AS EmployeeTel
FROM rb_teacher AS A
UNION ALL
SELECT A.School_Id,A.MName AS EmployeeName,A.MTel AS EmployeeTel
FROM rb_manager AS A
) AS A
WHERE 1=1
");
if (!string.IsNullOrEmpty(query.EmployeeName) || !string.IsNullOrEmpty(query.EmployeeTel))
{
builder.AppendFormat(" AND (A.EmployeeName='{0}' OR A.EmployeeTel='{1}') ", query.EmployeeName.Trim(), query.EmployeeTel.Trim());
return Get<EmployeeInfo>(builder.ToString()).ToList();
}
else
{
return new List<EmployeeInfo>();
}
}
} }
} }
...@@ -81,5 +81,15 @@ namespace EduSpider.Services ...@@ -81,5 +81,15 @@ namespace EduSpider.Services
}; };
return accountRepository.Update(keyValues, wheres); return accountRepository.Update(keyValues, wheres);
} }
/// <summary>
/// 获取员工信息列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<EmployeeInfo> GetEmployeeList(EmployeeInfo query)
{
return accountRepository.GetEmployeeListRepository(query);
}
} }
} }
...@@ -89,6 +89,14 @@ namespace EduSpider.WebApi.Controllers ...@@ -89,6 +89,14 @@ namespace EduSpider.WebApi.Controllers
return ApiResult.Failed(message: $"此账号【{ account }】已禁用", new { Error = 2 }); return ApiResult.Failed(message: $"此账号【{ account }】已禁用", new { Error = 2 });
} }
if (model.AccountType == Utility.Enum.AccountTypeEnum.Teacher)
{
var empModel = AccountService.GetEmployeeList(new EmployeeInfo() { EmployeeName = model.AccountName, EmployeeTel = model.Account })?.FirstOrDefault();
if (empModel != null && empModel.School_Id != 1)
{
return ApiResult.Failed(message: $"此账号【{ account }】未开通小程序功能!", new { Error = 2 });
}
}
#region 获取进阶思维小程序端token #region 获取进阶思维小程序端token
BaseUserInfo UserInfo = new() { BaseUserId = model.UniqueId }; BaseUserInfo UserInfo = new() { BaseUserId = model.UniqueId };
string token = JwtHelper.CreateToken(UserInfo, Config.JwtSecretKey, Config.JwtExpirTime); string token = JwtHelper.CreateToken(UserInfo, Config.JwtSecretKey, Config.JwtExpirTime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment