Commit 74f323a0 authored by 黄奎's avatar 黄奎

新增接口

parent ae96b6c1
using Edu.Common.Enum;
using System;
using VT.FW.DB;
namespace Edu.Model.Entity.System
{
/// <summary>
/// 地区实体类
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Destination
{
/// <summary>
/// 主键编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 父级编号
/// </summary>
public int ParentID { get; set; }
/// <summary>
/// 等级(1-国家,2-省份,3-城市,4-区县)
/// </summary>
public int CodeLevel { get; set; }
/// <summary>
/// 状态
/// </summary>
public DateStateEnum Status { get; set; }
}
}
......@@ -57,11 +57,6 @@ namespace Edu.Model.Entity.User
/// </summary>
public int AreaId { get; set; }
/// <summary>
/// 学生登录密码
/// </summary>
public string StuPwd { get; set; }
/// <summary>
/// 集团编号
/// </summary>
......@@ -96,5 +91,10 @@ namespace Edu.Model.Entity.User
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 是否禁用(0-禁用,1-启用)
/// </summary>
public int IsDisable { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.System
{
/// <summary>
/// 省市区树形实体类
/// </summary>
public class AreaTree_ViewModel
{
/// <summary>
/// 主键编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 父级编号
/// </summary>
public int ParentID { get; set; }
/// <summary>
/// 子项列表
/// </summary>
public List<AreaTree_ViewModel> ChildList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Edu.Model.ViewModel.System
{
/// <summary>
/// 地区视图实体类
/// </summary>
public class RB_Destination_ViewModel : Model.Entity.System.RB_Destination
{
/// <summary>
/// 多个地名【逗号分割】
/// </summary>
public string NameStr { get; set; }
/// <summary>
/// 多个编号【逗号分割】
/// </summary>
public string Ids { get; set; }
}
}
......@@ -10,5 +10,40 @@ namespace Edu.Model.ViewModel.User
[Serializable]
public class RB_Student_ViewModel : Model.Entity.User.RB_Student
{
/// <summary>
/// 创建人姓名
/// </summary>
public string CreateByName { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public string CreateTimeStr { get { return Common.ConvertHelper.FormatTime(this.CreateTime); } }
/// <summary>
/// 修改人姓名
/// </summary>
public string UpdateByName { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public string UpdateTimeStr { get { return Common.ConvertHelper.FormatTime(this.UpdateTime); } }
/// <summary>
/// 禁用、启用字符串
/// </summary>
public string IsDisableStr
{
get
{
string str = "启用";
if (this.IsDisable == 0)
{
str = "禁用";
}
return str;
}
}
}
}
\ No newline at end of file
using Edu.Model.ViewModel.System;
using Edu.Repository.System;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace Edu.Module.System
{
/// <summary>
/// 地区处理类
/// </summary>
public class DestinationModule
{
/// <summary>
/// 地区仓储层对象
/// </summary>
private readonly RB_DestinationRepository destinationRepository = new RB_DestinationRepository();
/// <summary>
/// 省市区树形列表
/// </summary>
/// <returns></returns>
public List<AreaTree_ViewModel> GetAreaTree()
{
List<AreaTree_ViewModel> treeList = new List<AreaTree_ViewModel>();
var list = destinationRepository.GetDestinationListRepository(new RB_Destination_ViewModel() { });
if (list != null && list.Count > 0)
{
var firstList = list.Where(qitem => qitem.CodeLevel == 2).ToList();
if (firstList != null && firstList.Count > 0)
{
foreach (var fItem in firstList)
{
AreaTree_ViewModel fModel = new AreaTree_ViewModel()
{
ID = fItem.ID,
Name = fItem.Name,
ParentID = fItem.ParentID,
ChildList = new List<AreaTree_ViewModel>()
};
var secondList = list.Where(qitem => qitem.CodeLevel == 3 && qitem.ParentID == fItem.ID).ToList();
if (secondList != null && secondList.Count > 0)
{
foreach (var sItem in secondList)
{
AreaTree_ViewModel sModel = new AreaTree_ViewModel()
{
ID = sItem.ID,
Name = sItem.Name,
ParentID = sItem.ParentID,
ChildList = new List<AreaTree_ViewModel>()
};
var thirdList= list.Where(qitem => qitem.CodeLevel == 4 && qitem.ParentID == sItem.ID).ToList();
if (thirdList != null && thirdList.Count > 0)
{
foreach (var tItem in thirdList)
{
sModel.ChildList.Add(new AreaTree_ViewModel()
{
ID = tItem.ID,
Name = tItem.Name,
ParentID = tItem.ParentID,
ChildList = new List<AreaTree_ViewModel>()
});
}
}
fModel.ChildList.Add(sModel);
}
}
treeList.Add(fModel);
}
}
}
return treeList;
}
}
}
\ No newline at end of file
......@@ -98,5 +98,22 @@ namespace Edu.Module.User
flag = studentRepository.Update(fileds, new WhereHelper(nameof(RB_Student_ViewModel.StuId), StuId));
return flag;
}
/// <summary>
/// 更新学员【禁用、启用】
/// </summary>
/// <param name="StuId"></param>
/// <param name="IsDisable">0-禁用,1-启用</param>
/// <returns></returns>
public bool UpdateStudentIsDisableModule(object StuId,int IsDisable)
{
bool flag;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Student_ViewModel.IsDisable), IsDisable},
};
flag = studentRepository.Update(fileds, new WhereHelper(nameof(RB_Student_ViewModel.StuId), StuId));
return flag;
}
}
}
using Edu.Model.Entity.System;
using Edu.Model.ViewModel.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Edu.Repository.System
{
/// <summary>
/// 地区仓储层
/// </summary>
public class RB_DestinationRepository:BaseRepository<Model.Entity.System.RB_Destination>
{
/// <summary>
/// 获取所有的地区数据列表
/// </summary>
/// <returns></returns>
public List<RB_Destination_ViewModel> GetDestinationListRepository(RB_Destination_ViewModel query)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM rb_destination WHERE 1=1 ");
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_ViewModel.Status), (int)Common.Enum.DateStateEnum.Normal);
if (query != null)
{
if (query.CodeLevel > 0)
{
sb.AppendFormat(" AND {0}={1}", nameof(RB_Destination_ViewModel.CodeLevel),query.CodeLevel);
}
if (query.ParentID > 0)
{
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_ViewModel.ParentID), query.ParentID);
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
sb.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Destination_ViewModel.Name), query.Name.Trim());
}
if (!string.IsNullOrWhiteSpace(query.NameStr))
{
sb.AppendFormat(" AND {0} in({1})", nameof(RB_Destination_ViewModel.Name), query.NameStr);
}
if (query.ID > 0)
{
sb.AppendFormat(" AND {0} in({1})", nameof(RB_Destination_ViewModel.ID), query.ID);
}
if (!string.IsNullOrWhiteSpace(query.Ids))
{
sb.AppendFormat(" AND {0} in({1})", nameof(RB_Destination_ViewModel.ID), query.Ids);
}
}
return Get<RB_Destination_ViewModel>(sb.ToString()).ToList();
}
}
}
\ No newline at end of file
......@@ -83,9 +83,12 @@ FROM rb_student AS t LEFT JOIN rb_group AS g ON t.Group_Id=g.GId
LEFT JOIN rb_school AS s ON t.School_Id=s.SId
WHERE 1=1
");
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.Status), (int)DateStateEnum.Normal);
if (query != null)
{
if (query.Status >= 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.Status), (int)query.Status);
}
if (query.Group_Id > 0)
{
builder.AppendFormat(" AND t.{0}={1} ", nameof(RB_Student_ViewModel.Group_Id), query.Group_Id);
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Edu.Common.API;
using Edu.Common.Plugin;
using Edu.Model.ViewModel.System;
using Edu.Module.System;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Edu.WebApi.Controllers.Public
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class PublicController : BaseController
{
/// <summary>
/// 省市区处理类对象
/// </summary>
private readonly DestinationModule destinationModule = new DestinationModule();
/// <summary>
/// 菜单处理类对象
/// </summary>
private readonly MenuModule menuModule = new MenuModule();
/// <summary>
/// 角色处理类对象
/// </summary>
private readonly RoleModule roleModule = new RoleModule();
#region 省市区
/// <summary>
/// 获取省市区树形列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAreaTree()
{
var list = destinationModule.GetAreaTree();
return ApiResult.Success(data: list);
}
#endregion
#region 菜单管理
/// <summary>
/// 获取菜单分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMenuPageList()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Menu_ViewModel>(RequestParm.Msg.ToString());
var list = menuModule.GetMenuPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取菜单列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMenuList()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Menu_ViewModel>(RequestParm.Msg.ToString());
var list = menuModule.GetMenuListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 获取树形菜单列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetTreeMenu()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Menu_ViewModel>(RequestParm.Msg.ToString());
var list = menuModule.GetTreeMenuModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 添加修改菜单
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetMenu()
{
var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Menu_ViewModel>(RequestParm.Msg.ToString());
extModel.CreateTime = DateTime.Now;
bool flag = menuModule.SetMenuModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取菜单实体
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMenu()
{
var MenuId = base.ParmJObj.GetInt("MenuId", 0);
var extModel = menuModule.GetMenuModule(MenuId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 修改菜单状态
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveStudent()
{
var MenuId = base.ParmJObj.GetInt("MenuId", 0);
int Status = base.ParmJObj.GetInt("Status", 0);
var flag = menuModule.SetMenuStatusModule(MenuId, Status);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
#region 角色管理
/// <summary>
/// 获取角色分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetRolePageList()
{
var pageModel = Common.Plugin.JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Role_ViewModel>(RequestParm.Msg.ToString());
var list = roleModule.GetRolePageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取角色列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetRoleList()
{
var query = Common.Plugin.JsonHelper.DeserializeObject<RB_Role_ViewModel>(RequestParm.Msg.ToString());
var list = roleModule.GetRoleListModule(query);
return ApiResult.Success(data: list);
}
/// <summary>
/// 添加修改角色
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetRole()
{
var extModel = Common.Plugin.JsonHelper.DeserializeObject<RB_Role_ViewModel>(RequestParm.Msg.ToString());
extModel.CreateDate = DateTime.Now;
extModel.CreateBy = base.UserInfo.Id;
bool flag = roleModule.SetRoleModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取角色实体
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetRole()
{
var RoleId = base.ParmJObj.GetInt("RoleId", 0);
var extModel = roleModule.GetRoleModule(RoleId);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 删除角色
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RemoveRole()
{
var RoleId = base.ParmJObj.GetInt("RoleId", 0);
var flag = roleModule.RemoveRoleModule(RoleId);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Edu.AOP;
using Edu.Cache.User;
using Edu.Common.API;
......@@ -9,11 +6,8 @@ using Edu.Common.Plugin;
using Edu.Model.ViewModel.User;
using Edu.Module.User;
using Edu.WebApi.Filter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace Edu.WebApi.Controllers.User
{
......@@ -434,9 +428,20 @@ namespace Edu.WebApi.Controllers.User
query.Group_Id = base.UserInfo.Group_Id;
query.School_Id = base.UserInfo.School_Id;
var list = studentModule.GetStudentPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
foreach (var item in list)
{
if (item.CreateBy > 0)
{
item.CreateByName = UserReidsCache.GetUserLoginInfo(item.CreateBy)?.AccountName ?? "";
}
if (item.UpdateBy > 0)
{
item.UpdateByName = UserReidsCache.GetUserLoginInfo(item.UpdateBy)?.AccountName ?? "";
}
}
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: list);
return ApiResult.Success(data: pageModel);
}
/// <summary>
......@@ -465,6 +470,8 @@ namespace Edu.WebApi.Controllers.User
extModel.CreateTime = DateTime.Now;
extModel.UpdateBy = base.UserInfo.Id;
extModel.UpdateTime = DateTime.Now;
extModel.Group_Id = base.UserInfo.Group_Id;
extModel.IsDisable = 1;
bool flag = studentModule.SetStudentModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......@@ -492,6 +499,20 @@ namespace Edu.WebApi.Controllers.User
var flag = studentModule.RemoveStudentModule(StuId);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 更新学生禁用或启用
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult UpdateStudentIsDisable()
{
var StuId = base.ParmJObj.GetInt("StuId", 0);
int IsDisable = base.ParmJObj.GetInt("IsDisable", 0);
var flag = studentModule.UpdateStudentIsDisableModule(StuId, IsDisable);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
#endregion
#region 管理者管理
......
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