Initial_commit_SecMPS_v2

This commit is contained in:
2026-05-15 23:22:48 +08:00
commit 23ea4fe05f
13830 changed files with 298675 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.EFDbContext;
using Microsoft.AspNetCore.Authorization;
namespace VolPro.WebApi.Controllers
{
[AllowAnonymous]
public class ApiHomeController : Controller
{
public IActionResult Index()
{
return new RedirectResult("/swagger/");
}
}
}

View File

@@ -0,0 +1,73 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core.Configuration;
using VolPro.Core.Filters;
using VolPro.Core.ManageUser;
namespace VolPro.WebApi.Controllers
{
[Route("api/app")]
public class AppController : Controller
{
[AllowAnonymous]
[Route("checkLogin"), HttpGet]
public IActionResult CheckLogin()
{
return Content(UserContext.Current.UserId > 0 ? "1" : "0");
}
[AllowAnonymous]
/// <summary>
/// 安卓检查更新
/// </summary>
/// <param name="home"></param>
/// <returns></returns>
[Route("getAndroidVersion"), HttpGet]
public IActionResult GetAndroidVersion(bool home)
{
var section = AppSetting.GetSection("android");
if (section==null)
{
return Json(new { });
}
var data = new
{
status = true,
version = section["version"],
url = section["url"],
desc = section["desc"]
};
return Json(data);
}
/// <summary>
/// IOS检查更新
/// </summary>
/// <param name="home"></param>
/// <returns></returns>
[AllowAnonymous]
[Route("getIOSVersion"), HttpGet]
public IActionResult GetIOSVersion(bool home)
{
var section = AppSetting.GetSection("ios");
if (section == null)
{
return Json(new { });
}
var data = new
{
status = true,
version = section["version"],
url = section["url"],
desc = section["desc"]
};
return Json(data);
}
}
}

View File

@@ -0,0 +1,217 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VolPro.Core;
using VolPro.Core.CacheManager;
using VolPro.Core.Configuration;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Extensions;
using VolPro.Core.ManageUser;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
namespace VolPro.WebApi.Controllers.Auth
{
[Route("api/auth")]
[Route("api/dataview/auth")]
public class AuthController : VolController
{
private ICacheService _cache;
private ISys_UserRepository _userRepository;
private readonly ISys_MenuService _menuService;
public AuthController(ICacheService cache, ISys_UserRepository userRepository, ISys_MenuService menuService)
{
_cache = cache;
_menuService = menuService;
_userRepository = userRepository;
}
/// <summary>
/// 获取token
/// </summary>
/// <param name="parmas"></param>
/// <returns></returns>
[HttpPost, Route("getAccessToken")]
[ApiExplorerSettings(IgnoreApi = true)]
public IActionResult GetAccessToken(string parmas)
{
var token = JwtHelper.IssueJwt(new UserInfo { User_Id = UserContext.Current.UserId }, 5);
token = token.EncryptDES(AppSetting.Secret.JWT);
return Json(new { token });
}
private new IActionResult Error(string message)
{
return Json(new { status = false, message });
}
/// <summary>
/// 通过token登录
/// </summary>
/// <param name="parmas"></param>
/// <returns></returns>
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost, Route("validationToken"), AllowAnonymous]
public async Task<IActionResult> ValidationToken([FromBody] AccessInfo access)
{
if (access == null || string.IsNullOrEmpty(access.Token))
{
return Error("token无效".Translator());
}
try
{
string token = access.Token.DecryptDES(AppSetting.Secret.JWT);
var tokenHandler = new JwtSecurityTokenHandler();
var validationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(AppSetting.Secret.JWT)),
ValidateIssuer = false,
ValidateAudience = false
};
try
{
var principal = tokenHandler.ValidateToken(token, validationParameters, out SecurityToken validatedToken);
var userInfo = new UserInfo() { User_Id = principal.Claims.Where(x => x.Type == JwtRegisteredClaimNames.Jti).Select(s => s.Value).FirstOrDefault().GetInt() };
if (userInfo == null || userInfo.User_Id <= 0)
{
return Error("token无效或用户信息无效");
}
var user = await _userRepository.FindAsIQueryable(x => x.User_Id == userInfo.User_Id).FirstOrDefaultAsync();
if (user == null || user.User_Id <= 0)
{
return Error("token无效或用户信息无效");
}
int expir = AppSetting.ExpMinutes;
string accessToken = null;
if (AppSetting.FileAuth)
{
expir = expir + 30;
string dt = DateTime.Now.AddMinutes(expir).ToString("yyyy-MM-dd HH:mm");
accessToken = $"{user.User_Id}_{dt}".EncryptDES(AppSetting.Secret.User);
_cache.Add(accessToken, dt, expir);
}
token = JwtHelper.IssueJwt(new UserInfo()
{
User_Id = user.User_Id,
UserName = user.UserName,
Role_Id = user.Role_Id ?? 0
});
var data = new { status = true, token, userName = user.UserTrueName, img = user.HeadImageUrl };
return Json(data);
}
catch (SecurityTokenInvalidSignatureException)
{
return Error("JWT 签名无效,可能被篡改");
}
catch (SecurityTokenExpiredException)
{
return Error("JWT 已过期");
}
catch (SecurityTokenException)
{
return Error("JWT 校验失败");
}
}
catch (Exception ex)
{
Console.WriteLine($"解析token异常:{ex.Message + ex.StackTrace}");
return Error("token无效".Translator());
}
}
[HttpPost, Route("getDataViewAccessToken")]
public IActionResult GetDataViewAccessToken(string parmas)
{
int userId = UserContext.Current.UserId;
string guid = Guid.NewGuid().ToString();
_cache.Add(guid, userId.ToString(), 180);
return Content(guid);
}
[HttpPost, Route("getDataViewLoginToken"), AllowAnonymous]
public async Task<IActionResult> GetDataViewLoginToken(string key)
{
string value = _cache.Get(key ?? "");
if (string.IsNullOrEmpty(value))
{
return Json(new
{
stataus = false,
msg = "key无效"
});
}
// _cache.Remove(key);
int userId = value.GetInt();
var user = await _userRepository.FindAsIQueryable(x => x.User_Id == userId).FirstOrDefaultAsync();
if (user == null)
{
return Json(new
{
stataus = false,
msg = "未找到用户信息"
});
}
string token = JwtHelper.IssueJwt(new UserInfo()
{
User_Id = user.User_Id,
UserName = user.UserName,
Role_Id = user.Role_Id ?? 0
}, 43200);
var menu = _menuService.GetUserMenuList(UserContext.Current.GetUserInfo(user.User_Id).RoleIds)
.Where(x => x.LinkType == 4 && (x.Enable == null || x.Enable == 1))
.Select(s => new { s.MenuName, s.Url }).ToList();
////_userRepository.Update(user, x => x.Token, true);
//UserContext.Current.LogOut(user.User_Id);
var service = UserContext.Current.UserDbService.Select(s => new { id = s.DbServiceId, name = s.DbServiceName })
.ToList();
return Json(new
{
msg = "操作成功",
status = true,
code = 200,
data = new
{
userinfo = new
{
id = "0",
username = user.UserTrueName,// "admin",
nickname = user.UserTrueName
},
menu,
service,
token = new
{
tokenName = "Authorization",
tokenValue = $"Bearer {token}",
isLogin = true,
loginId = "1",
loginType = "login",
tokenTimeout = 2592000 * 600,
sessionTimeout = 2592000 * 600,
tokenSessionTimeout = 2591893,
tokenActivityTimeout = -1,
loginDevice = "default-device"
}
}
});
}
}
public class AccessInfo
{
public string Token { get; set; }
}
}

View File

@@ -0,0 +1,149 @@
using VolPro.Builder.IServices;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using VolPro.Core.Filters;
using VolPro.Entity.DomainModels;
using VolPro.Core.Utilities;
using System.Linq;
using VolPro.Core.Extensions;
using static System.Runtime.InteropServices.Marshalling.IIUnknownCacheStrategy;
using VolPro.Builder.IRepositories;
using Microsoft.EntityFrameworkCore;
namespace VolPro.WebApi.Controllers.Builder
{
[JWTAuthorize]
[Route("/api/Builder")]
public class BuilderController : Controller
{
private ISys_TableInfoService Service;
private ISys_TableInfoRepository _repository;
public BuilderController(ISys_TableInfoService service, ISys_TableInfoRepository repository)
{
Service = service;
_repository = repository;
}
[HttpPost]
[Route("GetTableTree")]
//[ApiActionPermission(ActionRolePermission.SuperAdmin)]
public async Task<ActionResult> GetTableTree()
{
try
{
(string, string) builderInfo = await Service.GetTableTree();
return Json(new { list = builderInfo.Item1, nameSpace = builderInfo.Item2 });
}
catch (Exception ex)
{
return Json(new { list = ex.Message + ex.StackTrace + ex.Source, nameSpace = ex.InnerException?.Message });
}
}
[Route("CreateVuePage")]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
[HttpPost]
public ActionResult CreateVuePage([FromBody] Sys_TableInfo sysTableInfo, string vuePath, int tableId, string table)
{
return Content(Service.CreateVuePage(sysTableInfo, vuePath, tableId, table));
}
[Route("loadOptions")]
[HttpPost]
public ActionResult CreateVuePage(int tableId, string table)
{
var res = Service.CreateVuePage(null, null, tableId, table);
return Json(new { status = res.Contains("fun"), content = res });
}
[Route("CreateModel")]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
[HttpPost]
public ActionResult CreateEntityModel([FromBody] Sys_TableInfo tableInfo)
{
return Content(Service.CreateEntityModel(tableInfo));
}
[Route("Save")]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
[HttpPost]
public ActionResult SaveEidt([FromBody] Sys_TableInfo tableInfo)
{
return Json(Service.SaveEidt(tableInfo));
}
[Route("CreateServices")]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
[HttpPost]
public ActionResult CreateServices(string tableName, string nameSpace, string foldername, bool? partial, bool? api)
{
return Content(Service.CreateServices(tableName, nameSpace, foldername, false, true));
}
[Route("LoadTableInfo")]
[HttpPost]
public ActionResult LoadTable([FromBody] Sys_TableInfo sysTableInfo, int parentId, string tableName, string columnCNName, string nameSpace, string foldername, int table_Id, bool isTreeLoad, string dbServer, bool gengeneric)
{
tableName = (tableName ?? "").Replace("", ",");
if (isTreeLoad || !tableName.Contains(','))
{
return Json(Service.LoadTable(sysTableInfo, parentId, tableName, columnCNName, nameSpace, foldername, table_Id, isTreeLoad, dbServer));
}
var tables = tableName.Split(",").Distinct();
foreach (var table in tables)
{
var res = Service.LoadTable(sysTableInfo, parentId, table, table, nameSpace, foldername, 0, false, dbServer);
//无代码不生成实际文件
if (!gengeneric)
{
WebResponseContent webResponse = res as WebResponseContent;
if (webResponse == null || !webResponse.Status)
{
Console.WriteLine(res.Serialize());
}
var tableInfo = webResponse.Data as Sys_TableInfo;
string message = Service.CreateEntityModel(tableInfo);
Console.WriteLine($"表[{table}]生成实体类:{message}");
message = Service.CreateServices(table, nameSpace, foldername, false, true);
Console.WriteLine($"表[{table}]生成业务类:{message}");
}
}
return Json(new { status = false, message = "批量生成完成,请刷新页面后配置查询、编辑信息再点击生成页面" });
}
[Route("delTree")]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
[HttpPost]
public async Task<ActionResult> DelTree(int table_Id)
{
return Json(await Service.DelTree(table_Id));
}
[Route("syncTable")]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
[HttpPost]
public async Task<ActionResult> SyncTable(string tableName)
{
return Json(await Service.SyncTable(tableName));
}
[Route("getDyTable")]
[HttpPost]
public async Task<ActionResult> GetDyTable()
{
var data = await _repository.FindAsIQueryable(x => x.DyPage == 1 || x.DyScript != null)
.Select(s => new { table = s.TableName, dyPage = s.DyPage == 1, dyScript = s.DyScript != null })
.ToListAsync();
return Json(data);
}
[Route("getDyScript")]
[HttpPost]
public async Task<ActionResult> GetDyScript(string table)
{
var data = await _repository.FindAsIQueryable(x => x.TableName == table)
.Select(s => s.DyScript)
.FirstAsync();
return Json(new { data });
}
}
}

View File

@@ -0,0 +1,114 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Builder.IServices;
using VolPro.Builder.Services;
using VolPro.Core.Configuration;
using VolPro.Core.Const;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.DBManager;
using VolPro.Core.Extensions;
using VolPro.Core.Infrastructure;
using VolPro.Core.ManageUser;
namespace VolPro.WebApi.Controllers.Builder;
[ApiController]
[Route("api/db/[controller]")]
public class TableController : VolController
{
private readonly ITableService _tableService;
public TableController(ITableService tableService)
{
_tableService = tableService;
}
private static string[] actions = new string[] { "GetDbService", "GetAllTables", "GetTableInfo", "TableExists" };
public override void OnActionExecuting(ActionExecutingContext context)
{
string actionName= ((ControllerActionDescriptor)context.ActionDescriptor).ActionName;
if (actions.Contains(actionName))
{
base.OnActionExecuting(context);
return;
}
var value = AppSetting.GetSettingString("DbTable").GetInt();
if (value != 1)
{
context.Result = Json(new { status = false, message = "后台[appsettings.json]需要开启创建表属性才可以使用" });
return;
}
if (UserContext.Current.IsSuperAdmin)
{
base.OnActionExecuting(context);
return;
}
context.Result = Json(new { status = false, message = "普通帐号没有权限操作" });
return;
}
[HttpPost("getDbService")]
[ApiExplorerSettings(IgnoreApi = true)]
public ActionResult GetDbService(string dbService)
{
var dic = DictionaryManager.GetDictionary("dbServer");
var data = dic.Sys_DictionaryList.Select(s =>
new
{
key = s.DicValue,
value = s.DicName,
dbType = DbRelativeCache.GetDbType(dic.DBServer)?? DBType.Name
});
return Json(data);
}
[HttpPost("getAllTables")]
[ApiExplorerSettings(IgnoreApi = true)]
public async Task<ActionResult<List<string>>> GetAllTables(string dbService)
{
var tables = await _tableService.GetAllTablesAsync(dbService);
return Json(tables);
}
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost, Route("getTableInfo")]
public async Task<ActionResult<TableInfoDto>> GetTableInfo(string tableName, string dbService)
{
var tableInfo = await _tableService.GetTableInfoAsync(dbService, tableName);
if (tableInfo == null)
{
return NotFound($"Table '{tableName}' not found.");
}
return Ok(tableInfo);
}
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost("createTable")]
public async Task<ActionResult> CreateTable([FromBody] CreateTableRequest request, string dbService)
{
var res = await _tableService.CreateTableAsync(dbService, request);
return Json(res);
}
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost("updateTable")]
public async Task<ActionResult> UpdateTable([FromBody] UpdateTableRequest request, string tableName, string dbService)
{
var res = await _tableService.UpdateTableAsync(dbService, request);
return Json(res);
}
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost, Route("deleteTable")]
public async Task<ActionResult> DeleteTable(string tableName, string dbService)
{
var res = await _tableService.DeleteTableAsync(dbService, tableName);
return Json(res);
}
[HttpPost("exists")]
public async Task<ActionResult<bool>> TableExists(string tableName, string dbService)
{
var exists = await _tableService.TableExistsAsync(dbService, tableName);
return Ok(exists);
}
}

View File

@@ -0,0 +1,72 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using VolPro.Core.Controllers.Basic;
using System.Linq;
using VolPro.Entity.DomainModels;
namespace VolPro.WebApi.Controllers.Dashboard
{
/// <summary>
/// 工作台自定义接口(测试)
/// </summary>
[Route("api/dashboard")]
public class DashboardController : VolController
{
public DashboardController()
{
}
/// <summary>
/// 获取柱状图的数据
/// </summary>
/// <returns></returns>
[HttpGet, HttpPost, Route("getBarData")]
public IActionResult GetBarData([FromBody] List<SearchParameters> filters, DateTime? date1, DateTime? date2, string filterType)
{
var data = Enumerable.Range(0, 12)
.Select(i => new
{
= DateTime.Today.AddMonths(i * -1).ToString("yyyy.MM"),
= new Random().Next(1000, 9999),
= new Random().Next(1000, 9999)
})
.ToArray();
return Json(data);
}
/// <summary>
/// 获取栅格01的数据
/// </summary>
/// <returns></returns>
[HttpGet, HttpPost, Route("getGridData")]
public IActionResult GetGridData([FromBody] List<SearchParameters> filters, DateTime? date1, DateTime? date2, string filterType)
{
var data = new List<object>() {
new { name="待处理事项",value=new Random().Next(1000,9999)},
new {name="已处理事项",value=2300},
new {name="待回复消息",value=2400},
new {name="已回复消息",value=1500},
new {name="待审批事项",value=1800},
new {name="已审批事项",value=1200},
new {name="数量总计",value=9000}
};
return Json(data);
}
[HttpGet, HttpPost, Route("getGridData2")]
public IActionResult GetGridData2([FromBody] List<SearchParameters> filters, DateTime? date1, DateTime? date2, string filterType)
{
var data = new List<int>() {
100,200,300,400,500,600,700,800,900
};
return Json(new
{
value = 9990,
unit = "箱",
bottom = new string[] { "text1:1000", "text2:2000" },
data
});
}
}
}

View File

@@ -0,0 +1,240 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.DBManager;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.Filters;
using VolPro.Core.ManageUser;
using VolPro.Core.Utilities;
using VolPro.Entity.AttributeManager;
using VolPro.Entity.DomainModels;
namespace VolPro.WebApi.Controllers.DataView
{
[Route("api/dataview/project")]
[PermissionTable(Name = nameof(DataViewProjects))]
public class DataViewProjectController : VolController
{
private readonly IHttpContextAccessor _httpContextAccessor;
public DataViewProjectController(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
[Route("list"), HttpGet]
public async Task<IActionResult> GetList(int page = 1, int limit = 12)
{
var query = DBServerProvider.DbContext.Set<DataViewProjects>().Where(x => x.IsDel == 0);
var data = await query.OrderByDescending(x => x.OrderNo)
.ThenByDescending(x => x.CreateDate)
.TakePage(page, limit)
.ToListAsync();
return Json(new
{
code = 200,
msg = "获取成功",
count = await query.CountAsync(),
data = data
});
}
[Route("create"), HttpPost]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public IActionResult Create([FromBody] DataViewProjects data)
{
var id = new IdWorker();
data.Id = id.NextId();
return Success("获取成功", data);
}
[Route("getData"), HttpGet]
public async Task<IActionResult> GetData(long projectId)
{
var data = await DBServerProvider.DbContext.Set<DataViewProjects>().Where(x => x.Id == projectId).FirstOrDefaultAsync();
if (data == null)
{
return Success();
}
return Success("获取成功", data);
}
/// <summary>
/// 保存
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
[Route("save/data"), HttpPost]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public IActionResult SaveData(IFormCollection formdata)
{
DataViewProjects data = new DataViewProjects();
data.Id = Convert.ToInt64(formdata["projectId"]);
data.Content = formdata["Content"];
return UpdateData(data, x => new { x.Content });
}
/// <summary>
/// 编辑项目名称
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
[Route("edit"), HttpPost]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public IActionResult Edit([FromBody] DataViewProjects data)
{
data = HttpContext.GetRequestParameters().DeserializeObject<DataViewProjects>();
return UpdateData(data, x => new { x.ProjectName });
}
[Route("publish"), HttpPost, HttpPut]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public IActionResult Publish([FromBody] DataViewProjects data)
{
data = HttpContext.GetRequestParameters().DeserializeObject<DataViewProjects>();
return UpdateData(data, x => new { x.State });
}
private static object dataviewLockObject = new object();
private IActionResult UpdateData(DataViewProjects data, Expression<Func<DataViewProjects, object>> updateField)
{
lock (dataviewLockObject)
{
var dbContext = DBServerProvider.DbContext.Set<DataViewProjects>();
var dataView = dbContext.Where(x => x.Id == data.Id).FirstOrDefault();
if (dataView != null)
{
var arr = updateField.GetExpressionToArray();
//foreach (var field in arr)
//{
// DBServerProvider.DbContext.Entry<DataViewProjects>(data).Property(field).IsModified = true;
//}
DBServerProvider.DbContext.Update(data, arr);
}
else
{
data.IsDel = 0;
data.SetCreateDefaultVal();
data.DbServiceId = UserContext.CurrentServiceId;
DBServerProvider.DbContext.Add(data);
}
DBServerProvider.DbContext.SaveChanges();
}
return Success();
}
[Route("upload"), HttpPost]
public IActionResult Upload(List<IFormFile> fileInput)
{
string fullPath = "dataView".MapPath(true);
try
{
if (!Directory.Exists(fullPath)) Directory.CreateDirectory(fullPath);
for (int i = 0; i < fileInput.Count; i++)
{
string fileName = fileInput[i].FileName;
string id = fileInput[i].FileName.Split("_")[0];
using (var stream = new FileStream(fullPath + "\\" + fileName, FileMode.Create))
{
fileInput[i].CopyTo(stream);
}
DataViewProjects data = new DataViewProjects()
{
Id = Convert.ToInt64(id),
IndexImage = "dataView\\" + fileName
};
UpdateData(data, x => new { x.IndexImage });
}
return Json(new
{
code = 200,
msg = "ok",
data = new { fileurl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/dataView/{ fileInput[0].FileName}" }
});
}
catch (Exception ex)
{
return Success(ex.Message);
}
}
/// <summary>
/// 编辑项目名称
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
[Route("delete"), HttpDelete,HttpGet,HttpPost]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update | ActionPermissionOptions.Delete)]
public IActionResult Delete(long ids)
{
DataViewProjects dataView = new DataViewProjects() { Id = ids, IsDel = 1 };
DBServerProvider.DbContext.Update(dataView,x=>new { x.IsDel });
DBServerProvider.DbContext.SaveChanges();
return Success("删除成功");
}
[Route("updateOrderNo"), HttpPost]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public IActionResult UpdateOrderNo([FromBody] DataViewProjects data)
{
data = HttpContext.GetRequestParameters().DeserializeObject<DataViewProjects>();
UpdateData(data, x => new { x.OrderNo, x.ProjectName });
return Success("修改成功");
}
[Route("copy"), HttpPost]
[ApiActionPermission(ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public async Task<IActionResult> Copy([FromBody] DataViewProjects data)
{
data = HttpContext.GetRequestParameters().DeserializeObject<DataViewProjects>();
long dataId= data.Id;
data = await DBServerProvider.DbContext.Set<DataViewProjects>().Where(x => x.Id == data.Id).FirstOrDefaultAsync();
if (data==null)
{
string msg = $"未查到id数据{dataId}";
Console.WriteLine(msg);
return Success(msg);
}
var id = new IdWorker();
data.Id = id.NextId();
data.ProjectName = data.ProjectName + "副本";
data.SetCreateDefaultVal();
DBServerProvider.DbContext.Add(data);
DBServerProvider.DbContext.SaveChanges();
return Success("修改成功");
}
private new IActionResult Success(string msg = "ok")
{
return Json(new
{
code = 200,
msg = msg
});
}
private new IActionResult Success(string msg, object data)
{
return Json(new
{
code = 200,
msg = msg,
data = data
});
}
}
}

View File

@@ -0,0 +1,177 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Hosting;
using System;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core;
using VolPro.Core.Configuration;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.ManageUser;
using VolPro.Core.ObjectActionValidator;
using VolPro.Core.Services;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
using VolPro.Sys.IServices;
namespace VolPro.WebApi.Controllers.DataView
{
[Route("api/dataview/sys")]
public class DataViewSysController : VolController
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_UserRepository _userRepository;
private readonly ISys_MenuService _menuService;
private readonly IMemoryCache _memoryCache;
public DataViewSysController(IHttpContextAccessor httpContextAccessor,
ISys_UserRepository userRepository,
ISys_MenuService menuService,
IMemoryCache memoryCache)
{
_httpContextAccessor = httpContextAccessor;
_userRepository = userRepository;
_memoryCache = memoryCache;
_menuService = menuService;
}
[Route("login"), HttpPost, AllowAnonymous]
[ObjectModelValidatorFilter(ValidatorModel.Login)]
public async Task<IActionResult> Login([FromBody] LoginInfo loginInfo)
{
WebResponseContent webResponse = new WebResponseContent();
string msg = string.Empty;
string cacheCode = (_memoryCache.Get(loginInfo.UUID) ?? "").ToString();
if (string.IsNullOrEmpty(cacheCode))
{
return Error("验证码已失效".Translator());
}
if (cacheCode.ToLower() != loginInfo.VerificationCode.ToLower())
{
_memoryCache.Remove(loginInfo.UUID);
return Error("验证码不正确".Translator());
}
try
{
var user = await _userRepository.FindAsIQueryable(x => x.UserName == loginInfo.UserName)
.FirstOrDefaultAsync();
if (user == null || loginInfo.Password.Trim().EncryptDES(AppSetting.Secret.User) != (user.UserPwd ?? ""))
return Error("账号或密码不正确");
string token = JwtHelper.IssueJwt(new UserInfo()
{
User_Id = user.User_Id,
UserName = user.UserName,
Role_Id = user.Role_Id ?? 0
}, 43200);
user.Token = token;
webResponse.Data = new { token, userName = user.UserTrueName, img = user.HeadImageUrl };
_userRepository.Update(user, x => x.Token, true);
UserContext.Current.LogOut(user.User_Id);
loginInfo.Password = string.Empty;
var menu = _menuService.GetUserMenuList(UserContext.Current.GetUserInfo(user.User_Id).RoleIds)
.Where(x => x.LinkType == 4 && (x.Enable == null || x.Enable == 1))
.Select(s => new { s.MenuName, s.Url }).ToList();
// return webResponse.OK(ResponseType.LoginSuccess);
return Json(new
{
msg = "操作成功",
code = 200,
data = new
{
userinfo = new
{
id = "0",
username = user.UserTrueName,// "admin",
// password = "21232f297a57a5a743894a0e4a801fc3",
nickname = user.UserTrueName
},
token = new
{
tokenName = "Authorization",
tokenValue = $"Bearer {token}",
isLogin = true,
loginId = "1",
loginType = "login",
tokenTimeout = 2592000 * 600,
sessionTimeout = 2592000 * 600,
tokenSessionTimeout = 2591893,
tokenActivityTimeout = -1,
loginDevice = "default-device"
},
menu = menu
}
});
}
catch (Exception ex)
{
msg = ex.Message + ex.StackTrace;
if (HttpContext.GetService<Microsoft.AspNetCore.Hosting.IWebHostEnvironment>().IsDevelopment())
{
throw new Exception(ex.Message + ex.StackTrace);
}
return Error(msg);
}
finally
{
_memoryCache.Remove(loginInfo.UUID);
Logger.Info(LoggerType.Login, loginInfo.Serialize(), webResponse.Message, msg);
}
//return Json(data);
}
/// <summary>
/// 2020.06.15增加登陆验证码
/// </summary>
/// <returns></returns>
[HttpGet, Route("getVierificationCode"), AllowAnonymous]
public IActionResult GetVierificationCode()
{
string code = VierificationCode.RandomText();
var data = new
{
img = VierificationCode.CreateBase64Imgage(code),
uuid = Guid.NewGuid()
};
_memoryCache.Set(data.uuid.ToString(), code, new TimeSpan(0, 5, 0));
return Json(new { code = 200, data = data });
}
[Route("logout"), HttpGet, AllowAnonymous]
public IActionResult LogOut()
{
return Json(new { code = 200, msg = "ok" });
}
[HttpGet, Route("getOssInfo"), AllowAnonymous]
public IActionResult GetOssInfo()
{
return Json(new
{
bucketName = "dataview",
bucketURL = ""
});
}
private new IActionResult Error(string msg = "error")
{
return Json(new
{
code = 0,
msg = msg
});
}
}
}

View File

@@ -0,0 +1,44 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.Utilities;
using VolPro.Entity.AttributeManager;
using VolPro.Entity.DomainModels;
using VolPro.Sys.IRepositories;
namespace VolPro.WebApi.Controllers.DataView
{
/// <summary>
/// 所有接口路由都要以api/dataview开头
/// </summary>
[Route("api/dataview/test")]
public class DataViewTestController : VolController
{
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ISys_UserRepository _userRepository;
public DataViewTestController(IHttpContextAccessor httpContextAccessor, ISys_UserRepository userRepository)
{
_httpContextAccessor = httpContextAccessor;
_userRepository = userRepository;
}
[Route("Text1"), HttpGet,HttpPost]
public async Task<IActionResult> Text1()
{
await Task.CompletedTask;
return Json(new { value=DateTime.Now});
}
[Route("data1"), HttpGet]
public async Task<IActionResult> Data1()
{
await Task.CompletedTask;
return Json(new { });
}
}
}

View File

@@ -0,0 +1,99 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core.CacheManager;
using VolPro.Core.Configuration;
using VolPro.Core.DBManager;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Extensions;
using VolPro.Core.Filters;
using VolPro.Core.ManageUser;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
namespace VolPro.WebApi.Controllers
{
[JWTAuthorize, ApiController]
[Route("api/db")]
public class DbManagerController : Controller
{
[Route("exectue"), HttpPost]
[ApiExplorerSettings(IgnoreApi = true)]
[ApiActionPermission(ActionRolePermission.SuperAdmin)]
public ActionResult Exectue([FromBody] TextInfo info)
{
if (!AppSetting.UseDynamicShareDB)
{
return Content($"只有动态分库才能执行脚本");
}
List<Task> tasks = new List<Task>();
ConcurrentBag<string> result = new ConcurrentBag<string>();
var list = DbCache.GetList().Select(s => new
{
DbServiceId = s.DbServiceId.ToString(),
s.DatabaseName,
DbServiceName = s.DbServiceName,
ConnectionString = DbCache.GetConnectionString(s)
}).ToList();
if (list.Count == 0)
{
return Content($"没有配置数据库");
}
var db = DbCache.GetList().First().Serialize().DeserializeObject<Sys_DbService>();
db.DatabaseName = "DB_Empty";
//如果数据库都不在同一台服务器上每个服务器都要有一个DB_Empty数据库,这里也应该也要根据ip去重循环待完
string emptyDb = "EmptyDbContext";
if (list.Count > 0)
{
list.Add(new
{
list[0].DbServiceId,
db.DatabaseName,
DbServiceName = "空数据库",
ConnectionString = DbCache.GetConnectionString(db, db.DatabaseName)
});
}
int errorCount = 0;
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
string text = $"{(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"))},实例:{item.DbServiceName},数据库:{item.DatabaseName},";
try
{
SqlSugar.IAdo ado = DbManger.GetServiceDb((Guid)item.DbServiceId.GetGuid()).Ado;
ado.CommandTimeOut = 60 * 20;
ado.ExecuteCommand(info.Text, new { });
text = text + "执行成功";
}
catch (Exception ex)
{
errorCount++;
text = text + "执行失败," + ex.Message + ex.StackTrace;
}
result.Add(text);
}
result.Add($" --------{(DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss"))}({UserContext.Current.UserTrueName})------------ ");
result.Add($"执行sql({UserContext.Current.UserTrueName}){info.Text}");
result.Add("==========================================");
result.Add("\r\n");
FileHelper.WriteFile("DbLogger//DbExecute".MapPath(), DateTime.Now.ToString("yyyy-MM-dd") + ".txt", string.Join("\r\n", result), true);
return Content($"执行成功:{list.Count - errorCount}个,失败:{errorCount}个");
}
}
public class TextInfo
{
public string Text { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_CatalogController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_Catalog")]
[PermissionTable(Name = "Demo_Catalog")]
public partial class Demo_CatalogController : ApiBaseController<IDemo_CatalogService>
{
public Demo_CatalogController(IDemo_CatalogService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_CustomerController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_Customer")]
[PermissionTable(Name = "Demo_Customer")]
public partial class Demo_CustomerController : ApiBaseController<IDemo_CustomerService>
{
public Demo_CustomerController(IDemo_CustomerService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_GoodsController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_Goods")]
[PermissionTable(Name = "Demo_Goods")]
public partial class Demo_GoodsController : ApiBaseController<IDemo_GoodsService>
{
public Demo_GoodsController(IDemo_GoodsService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_OrderController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_Order")]
[PermissionTable(Name = "Demo_Order")]
public partial class Demo_OrderController : ApiBaseController<IDemo_OrderService>
{
public Demo_OrderController(IDemo_OrderService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_OrderListController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_OrderList")]
[PermissionTable(Name = "Demo_OrderList")]
public partial class Demo_OrderListController : ApiBaseController<IDemo_OrderListService>
{
public Demo_OrderListController(IDemo_OrderListService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_ProductColorController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_ProductColor")]
[PermissionTable(Name = "Demo_ProductColor")]
public partial class Demo_ProductColorController : ApiBaseController<IDemo_ProductColorService>
{
public Demo_ProductColorController(IDemo_ProductColorService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_ProductController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_Product")]
[PermissionTable(Name = "Demo_Product")]
public partial class Demo_ProductController : ApiBaseController<IDemo_ProductService>
{
public Demo_ProductController(IDemo_ProductService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹Demo_ProductSizeController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/Demo_ProductSize")]
[PermissionTable(Name = "Demo_ProductSize")]
public partial class Demo_ProductSizeController : ApiBaseController<IDemo_ProductSizeService>
{
public Demo_ProductSizeController(IDemo_ProductSizeService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,132 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_Catalog",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.Filters;
using VolPro.DbTest.Repositories;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using SqlSugar;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_CatalogController
{
private readonly IDemo_CatalogService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public Demo_CatalogController(
IDemo_CatalogService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
/// <summary>
/// 商品信息tree页面获取左边的tree的所有商品分类
/// </summary>
/// <returns></returns>
[Route("getList"), HttpGet]
public async Task<IActionResult> GetList()
{
var data = await Demo_CatalogRepository.Instance.FindAsIQueryable(x => true)
.Select(s => new
{
id = s.CatalogId,
s.ParentId,
name = s.CatalogName
})
.ToListAsync();
return Json(data);
}
public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
{
//没有查询条件显示所有一级节点数据
if (loadData.Value.GetInt() == 1)
{
return GetCatalogRootData(loadData);
}
//有查询条件使用框架默认的查询方法
return base.GetPageData(loadData);
}
/// treetable 获取根节点数据
/// </summary>
/// <returns></returns>
[HttpPost, Route("getCatalogRootData")]
[ApiActionPermission(ActionPermissionOptions.Search)]
public ActionResult GetCatalogRootData([FromBody] PageDataOptions options)
{
//页面加载(一级)根节点数据条件x => x.ParentId==null,自己根据需要设置
var query = Demo_CatalogRepository.Instance.FindAsIQueryable(x => x.ParentId == null);
var rows = query.TakeOrderByPage(options.Page, options.Rows)
.OrderBy(x => x.CatalogName).Select(s => new
{
s.CatalogId,
s.CatalogName,
s.CatalogCode,
s.ParentId,
s.Img,
s.Enable,
s.Remark,
s.CreateID,
s.Creator,
s.CreateDate,
s.ModifyID,
s.Modifier,
s.ModifyDate,
hasChildren = true
}).ToList();
return JsonNormal(new { total = query.Count(), rows });
}
/// <summary>
///treetable 获取子节点数据
/// </summary>
/// <returns></returns>
[HttpPost, Route("getChildrenData")]
[ApiActionPermission(ActionPermissionOptions.Search)]
public async Task<ActionResult> GetChildrenData(Guid catalogId)
{
//点击节点时,加载子节点数据
var roleRepository = Demo_CatalogRepository.Instance.FindAsIQueryable(x => 1 == 1);
var rows = await roleRepository.Where(x => x.ParentId == catalogId)
.Select(s => new
{
s.CatalogId,
s.CatalogName,
s.CatalogCode,
s.ParentId,
s.Img,
s.Enable,
s.Remark,
s.CreateID,
s.Creator,
s.CreateDate,
s.ModifyID,
s.Modifier,
s.ModifyDate,
hasChildren = SqlFunc.Subqueryable<Demo_Catalog>().Where(x => x.ParentId == s.CatalogId).Any()
}).ToListAsync();
return JsonNormal(new { rows });
}
}
}

View File

@@ -0,0 +1,72 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_Customer",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
using VolPro.DbTest.IRepositories;
using System.Linq;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_CustomerController
{
private readonly IDemo_CustomerService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IDemo_CustomerRepository _repository;
[ActivatorUtilitiesConstructor]
public Demo_CustomerController(
IDemo_CustomerService service,
IHttpContextAccessor httpContextAccessor,
IDemo_CustomerRepository repository
)
: base(service)
{
_service = service;
_repository = repository;
_httpContextAccessor = httpContextAccessor;
}
//可以定义接口权限
//[ApiActionPermission(ActionPermissionOptions.Search)]
[Route("search"), HttpPost]
public async Task<IActionResult> Search([FromBody] PageDataOptions loadData)
{
//loadData.Value是前端loadBefore方法设置的value值(输入框搜索的值)
string value = loadData.Value?.ToString()?.Trim();
//生成多个字段or查询条件
var query = _repository.WhereIF(!string.IsNullOrEmpty(value), x => x.Customer.Contains(value) || x.Remark.Contains(value));
//返回数据数据必须包括rows与total属性
var data = new
{
rows = await query.OrderByDescending(x => x.Customer)
.TakePage(loadData.Page, loadData.Rows)
//返回的字段注意与前端配置的字段一致
.Select(s => new
{
s.Customer_Id,
s.Customer,
s.Province,
s.DetailAddress,
s.PhoneNo,
s.Remark
}).ToListAsync(),
//返回总行数
total = await query.CountAsync()
};
//注意前后端字段配置的大小写一致
return JsonNormal(data);
}
}
}

View File

@@ -0,0 +1,88 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_Goods",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
using VolPro.DbTest.IRepositories;
using System.Linq;
using VolPro.Core.Extensions;
using Microsoft.EntityFrameworkCore;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_GoodsController
{
private readonly IDemo_GoodsService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IDemo_GoodsRepository _repository;
[ActivatorUtilitiesConstructor]
public Demo_GoodsController(
IDemo_GoodsService service,
IHttpContextAccessor httpContextAccessor,
IDemo_GoodsRepository repository
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
_repository = repository;
}
/// <summary>
/// 订单管理页面的明细表table搜索功能
/// </summary>
/// <param name="loadData"></param>
/// <returns></returns>
//可以定义接口权限
//[ApiActionPermission(ActionPermissionOptions.Search)]
[Route("search"), HttpPost]
public async Task<IActionResult> Search([FromBody] PageDataOptions loadData)
{
//loadData.Value是前端loadBefore方法设置的value值(输入框搜索的值)
string value = loadData.Value?.ToString()?.Trim();
//生成多个字段or查询条件
var query = _repository.WhereIF(!string.IsNullOrEmpty(value), x => x.GoodsName.Contains(value) || x.GoodsCode.Contains(value));
//返回数据数据必须包括rows与total属性
var data = new
{
rows = await query.OrderByDescending(x => x.GoodsName)
.TakePage(loadData.Page, loadData.Rows)
//返回的字段注意与前端配置的字段一致
.Select(s => new
{
s.GoodsId,
s.GoodsName,
s.GoodsCode,
s.Price,
s.Remark
}).ToListAsync(),
//返回总行数
total = await query.CountAsync()
};
//注意前后端字段配置的大小写一致
return JsonNormal(data);
}
[Route("updateStatus"), HttpGet]
public IActionResult UpdateStatus(Guid goodsId, int enable)
{
Demo_Goods goods = new Demo_Goods()
{
GoodsId = goodsId,
Enable = enable
};
_repository.Update(goods, x => new { x.Enable }, true);
return Content("修改成功");
}
}
}

View File

@@ -0,0 +1,119 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_Order",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
using VolPro.Core.Enums;
using VolPro.Core.Filters;
using VolPro.DbTest.IRepositories;
using Microsoft.EntityFrameworkCore;
using VolPro.Core.Extensions;
using System.Linq;
using SqlSugar;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_OrderController
{
private readonly IDemo_OrderService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IDemo_GoodsService _goodsService;//商品信息业务类
private readonly IDemo_OrderListRepository _orderListRepository;
private readonly IDemo_OrderRepository _orderRepository;
[ActivatorUtilitiesConstructor]
public Demo_OrderController(
IDemo_OrderService service,
IHttpContextAccessor httpContextAccessor,
IDemo_GoodsService goodsService,
IDemo_OrderListRepository orderListRepository,
IDemo_OrderRepository orderRepository
)
: base(service)
{
_service = service;
_orderRepository = orderRepository;
_goodsService = goodsService;
_orderListRepository = orderListRepository;
_httpContextAccessor = httpContextAccessor;
}
public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
{
return base.GetPageData(loadData);
}
[HttpGet, Route("test1")]
public IActionResult Test1()
{
return Content("test1");
}
//批量选择获取明商品数据
[Route("getGoods"), HttpPost]
public IActionResult GetGoods([FromBody] PageDataOptions loadData)
{
//调用商品信息的查询方法
var gridData = _goodsService.GetPageData(loadData);
return JsonNormal(gridData);
}
/// <summary>
/// 获取订单明细数据
/// </summary>
/// <param name="Order_Id"></param>
/// <returns></returns>
[Route("getDetailRows"), HttpGet]
public async Task<IActionResult> GetDetailRows(Guid Order_Id)
{
var rows = await _orderListRepository.FindAsIQueryable(x => x.Order_Id == Order_Id)
.ToListAsync();
return JsonNormal(rows);
}
/// <summary>
/// 获取订单明细数据
/// </summary>
/// <param name="Order_Id"></param>
/// <returns></returns>
[Route("getTotal"), HttpGet]
public async Task<IActionResult> GetTotal()
{
//获取汇总
var total = await _orderRepository.FindAsIQueryable(x => true)
.Select(x => new
{
orderType = -1,
count = SqlFunc.AggregateCount(x),
qty = SqlFunc.AggregateSum(x.TotalQty),
totalPrice = SqlFunc.AggregateSum(x.TotalPrice)
}).FirstAsync();
//获取每个订单类型数据
var data = await _orderRepository.FindAsIQueryable(x => true)
.Select(x => new
{
orderType = x.OrderType,
count = SqlFunc.AggregateCount(x),
qty = SqlFunc.AggregateSum(x.TotalQty),
totalPrice = SqlFunc.AggregateSum(x.TotalPrice)
}).ToListAsync();
List<object> list = new List<object>() { total };
list.AddRange(data);
return Json(list);
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_OrderList",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_OrderListController
{
private readonly IDemo_OrderListService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public Demo_OrderListController(
IDemo_OrderListService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_ProductColor",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_ProductColorController
{
private readonly IDemo_ProductColorService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public Demo_ProductColorController(
IDemo_ProductColorService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,54 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_Product",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
using VolPro.Core.Filters;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_ProductController
{
private readonly IDemo_ProductService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public Demo_ProductController(
IDemo_ProductService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
[ApiActionPermission()]
public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
{
return base.GetPageData(loadData);
}
[ApiActionPermission()]
public override ActionResult Add([FromBody] SaveModel saveModel)
{
return base.Add(saveModel);
}
[ApiActionPermission()]
public override ActionResult Update([FromBody] SaveModel saveModel)
{
return base.Update(saveModel);
}
[ApiActionPermission()]
public override ActionResult Del([FromBody] object[] keys)
{
return base.Del(keys);
}
}
}

View File

@@ -0,0 +1,55 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("Demo_ProductSize",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
using VolPro.Core.Filters;
namespace VolPro.DbTest.Controllers
{
public partial class Demo_ProductSizeController
{
private readonly IDemo_ProductSizeService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public Demo_ProductSizeController(
IDemo_ProductSizeService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
[ApiActionPermission()]
public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
{
return base.GetPageData(loadData);
}
[ApiActionPermission()]
public override ActionResult Add([FromBody] SaveModel saveModel)
{
return base.Add(saveModel);
}
[ApiActionPermission()]
public override ActionResult Update([FromBody] SaveModel saveModel)
{
return base.Update(saveModel);
}
[ApiActionPermission()]
public override ActionResult Del([FromBody] object[] keys)
{
return base.Del(keys);
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("TestDb",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
public partial class TestDbController
{
private readonly ITestDbService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public TestDbController(
ITestDbService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("TestService",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
public partial class TestServiceController
{
private readonly ITestServiceService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public TestServiceController(
ITestServiceService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹TestDbController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/TestDb")]
[PermissionTable(Name = "TestDb")]
public partial class TestDbController : ApiBaseController<ITestDbService>
{
public TestDbController(ITestDbService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹TestServiceController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.DbTest.IServices;
namespace VolPro.DbTest.Controllers
{
[Route("api/TestService")]
[PermissionTable(Name = "TestService")]
public partial class TestServiceController : ApiBaseController<ITestServiceService>
{
public TestServiceController(ITestServiceService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,244 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Threading.Tasks;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.Filters;
using VolPro.Core.Generic;
using VolPro.Core.Middleware;
using VolPro.Core.Utilities;
using VolPro.Entity.DomainModels;
namespace VolPro.WebApi.Controllers.Generic
{
[Route("api/generic")]
public class GenericController : GenericBaseController
{
private readonly IGenericDbProviderFactory _dbProviderFactory;
public GenericController(IGenericDbProviderFactory dbProviderFactory)
{
_dbProviderFactory = dbProviderFactory;
}
[ActionLog("查询")]
[HttpPost, Route("getPageData")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Search)]
public virtual async Task<IActionResult> GetPageData([FromBody] PageDataOptions loadData)
{
return await GetPageDataAsync(loadData);
}
[ActionLog("查询")]
[HttpPost, Route("getPageDataAsync")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Search)]
public virtual async Task<IActionResult> GetPageDataAsync([FromBody] PageDataOptions loadData)
{
var response = await _dbProviderFactory.Provider.GetPageDataAsync(loadData);
return JsonNormal(response);
}
/// <summary>
/// 获取明细grid分页数据
/// </summary>
/// <param name="loadData"></param>
/// <returns></returns>
[ActionLog("明细查询")]
[HttpPost, Route("getDetailPage")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Search)]
public virtual async Task<IActionResult> GetDetailPage([FromBody] PageDataOptions loadData)
{
return await GetDetailPageAsync(loadData);
}
/// <summary>
/// 获取明细grid分页数据
/// </summary>
/// <param name="loadData"></param>
/// <returns></returns>
[ActionLog("明细查询")]
[HttpPost, Route("getDetailPageAsync")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Search)]
public virtual async Task<IActionResult> GetDetailPageAsync([FromBody] PageDataOptions loadData)
{
var response = await _dbProviderFactory.Provider.GetDetailPageAsync(loadData);
return JsonNormal(response);
}
/// <summary>
/// 新增支持主子表
/// </summary>
/// <param name="saveDataModel"></param>
/// <returns></returns>
[ActionLog("新建")]
[HttpPost, Route("add")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Add)]
public virtual async Task<IActionResult> Add([FromBody] SaveModel saveModel)
{
return await AddAsync(saveModel);
}
[ActionLog("新建")]
[HttpPost, Route("addAsync")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Add)]
public virtual async Task<IActionResult> AddAsync([FromBody] SaveModel saveModel)
{
var response = await _dbProviderFactory.Provider.AddAsync(saveModel);
return Json(response);
}
/// <summary>
/// 新增支持主子表
/// </summary>
/// <param name="saveDataModel"></param>
/// <returns></returns>
[ActionLog("新建")]
[HttpPost, Route("update")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Update)]
public virtual async Task<IActionResult> Update([FromBody] SaveModel saveModel)
{
return await UpdateAsync(saveModel);
}
[ActionLog("新建")]
[HttpPost, Route("updateAsync")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Update)]
public virtual async Task<IActionResult> UpdateAsync([FromBody] SaveModel saveModel)
{
var response = await _dbProviderFactory.Provider.UpdateAsync(saveModel);
return Json(response);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="saveDataModel"></param>
/// <returns></returns>
[ActionLog("删除")]
[HttpPost, Route("del")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Delete)]
public virtual async Task<IActionResult> Del([FromBody] SaveModel saveModel)
{
return await DelAsync(saveModel);
}
[ActionLog("删除")]
[HttpPost, Route("delAsync")]
[ApiExplorerSettings(IgnoreApi = true), ActionPermission(ActionPermissionOptions.Delete)]
public virtual async Task<IActionResult> DelAsync([FromBody] SaveModel saveModel)
{
var response = await _dbProviderFactory.Provider.DelAsync(saveModel.DelKeys);
return Json(response);
}
/// <summary>
/// 上传文件
/// </summary>
/// <param name="fileInput"></param>
/// <returns></returns>
[ActionLog("上传文件")]
[HttpPost, Route("upload")]
[ApiActionPermission(ActionPermissionOptions.Upload | ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<IActionResult> Upload(IEnumerable<IFormFile> fileInput)
{
return await UploadAsync(fileInput);
}
[HttpPost, Route("uploadAsync")]
[ApiActionPermission(ActionPermissionOptions.Upload | ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<IActionResult> UploadAsync(IEnumerable<IFormFile> fileInput)
{
var response = await _dbProviderFactory.Provider.UploadAsync(fileInput.ToList());
return Json(response);
}
/// <summary>
/// 下载导入Excel模板
/// </summary>
/// <returns></returns>
[ActionLog("下载导入Excel模板")]
[HttpGet, Route("downLoadTemplate")]
[ApiActionPermission(ActionPermissionOptions.Import)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual IActionResult DownLoadTemplate()
{
return DownLoadTemplateAsync();
}
[ActionLog("下载导入Excel模板")]
[HttpGet, Route("downLoadTemplateAsync")]
[ApiActionPermission(ActionPermissionOptions.Import)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual IActionResult DownLoadTemplateAsync()
{
byte[] bytes = _dbProviderFactory.Provider.DownLoadTemplateAsync();
return File(bytes, MediaTypeNames.Application.Octet, "file.xlsx");
}
/// <summary>
/// 导入表数据Excel
/// </summary>
/// <param name="fileInput"></param>
/// <returns></returns>
[ActionLog("导入Excel")]
[HttpPost, Route("Import")]
[ApiActionPermission(ActionPermissionOptions.Import)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<IActionResult> Import(List<IFormFile> fileInput)
{
return await ImportAsync(fileInput);
}
[ActionLog("导入Excel")]
[HttpPost, Route("importAsync")]
[ApiActionPermission(ActionPermissionOptions.Import)]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<IActionResult> ImportAsync(List<IFormFile> fileInput)
{
var res = await _dbProviderFactory.Provider.ImportAsync(fileInput);
return Json(res);
}
/// <summary>
/// 导出文件,返回日期+文件名
/// </summary>
/// <param name="loadData"></param>
/// <returns></returns>
[ActionLog("导出Excel")]
[ApiActionPermission(ActionPermissionOptions.Export)]
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost, Route("Export")]
public virtual async Task<IActionResult> Export([FromBody] PageDataOptions loadData)
{
return await ExportAsync(loadData);
}
[ActionLog("导出Excel")]
[ApiActionPermission(ActionPermissionOptions.Export)]
[ApiExplorerSettings(IgnoreApi = true)]
[HttpPost, Route("exportAsync")]
public virtual async Task<IActionResult> ExportAsync([FromBody] PageDataOptions loadData)
{
byte[] bytes = await _dbProviderFactory.Provider.ExportAsync(loadData);
return File(bytes, MediaTypeNames.Application.Octet, "export.xlsx");
}
[ApiActionPermission(ActionPermissionOptions.Audit)]
[HttpPost, Route("Audit")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<ActionResult> Audit([FromBody] object[] id, int? auditStatus, string auditReason)
{
return await AuditAsync(id, auditStatus, auditReason);
}
[ApiActionPermission(ActionPermissionOptions.Audit)]
[HttpPost, Route("Audit")]
[ApiExplorerSettings(IgnoreApi = true)]
public virtual async Task<ActionResult> AuditAsync([FromBody] object[] id, int? auditStatus, string auditReason)
{
var res = await _dbProviderFactory.Provider.AuditAsync(id, auditStatus, auditReason);
return Json(res);
}
}
}

View File

@@ -0,0 +1,98 @@
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VolPro.Core.CacheManager;
using VolPro.Core.Extensions;
using VolPro.Core.ManageUser;
using VolPro.Sys.IServices;
namespace VolPro.WebApi.Controllers.Hubs
{
/// <summary>
/// https://docs.microsoft.com/zh-cn/aspnet/core/signalr/introduction?view=aspnetcore-3.1
/// https://docs.microsoft.com/zh-cn/aspnet/core/signalr/javascript-client?view=aspnetcore-6.0&tabs=visual-studio
/// </summary>
public class HomePageMessageHub : Hub
{
private readonly ICacheService _cacheService;
//public static ConcurrentDictionary<string, string> UserCache.ConnectionIds = new ConcurrentDictionary<string, string>();
/// <summary>
/// 构造 注入
/// </summary>
public HomePageMessageHub(ICacheService cacheService)
{
_cacheService = cacheService;
}
/// <summary>
/// 建立连接时异步触发
/// </summary>
/// <returns></returns>
public override async Task OnConnectedAsync()
{
//Console.WriteLine($"建立连接{Context.ConnectionId}");
UserCache.Add(Context);
//添加到一个组下
//await Groups.AddToGroupAsync(Context.ConnectionId, "SignalR Users");
//发送上线消息
//await Clients.All.SendAsync("ReceiveHomePageMessage", 1, new { title = "系统消息", content = $"{Context.ConnectionId} 上线" });
await base.OnConnectedAsync();
}
/// <summary>
/// 离开连接时异步触发
/// </summary>
/// <param name="ex"></param>
/// <returns></returns>
public override async Task OnDisconnectedAsync(Exception ex)
{
//Console.WriteLine($"断开连接{Context.ConnectionId}");
//从组中删除
// await Groups.RemoveFromGroupAsync(Context.ConnectionId, "SignalR Users");
//可自行调用下线业务处理方法...
await UserOffline();
//发送下线消息
// await Clients.All.SendAsync("ReceiveHomePageMessage", 4, new { title = "系统消息", content = $"{Context.ConnectionId} 离线" });
await base.OnDisconnectedAsync(ex);
}
/// <summary>
/// 发送给指定的人
/// </summary>
/// <param name="username">BW_Core_System_user表的登陆帐号</param>
/// <param name="message">发送的消息</param>
/// <returns></returns>
public async Task<bool> SendHomeMessage(string username, string title, string message)
{
await Clients.Clients(UserCache.GetCnnectionIds(username)).SendAsync("ReceiveHomePageMessage", new
{
// username,
title,
message,
date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss")
});
return true;
}
/// <summary>
/// 断开连接
/// </summary>
/// <returns></returns>
public async Task<bool> UserOffline()
{
UserCache.Remove(Context);
await Task.CompletedTask;
return true;
}
}
}

View File

@@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using System;
using System.Threading.Tasks;
using VolPro.Core;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.Enums;
using VolPro.Core.Extensions;
using VolPro.Core.Filters;
using VolPro.Entity.DomainModels;
namespace VolPro.WebApi.Controllers.Hubs
{
[Route("api/signalRUser")]
public class SignalRUserController : VolController
{
IHubContext<HomePageMessageHub> _hubClients;
public SignalRUserController(IHubContext<HomePageMessageHub> hubClients)
{
_hubClients = hubClients;
}
/// <summary>
/// 强制下线
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
[HttpGet, Route("loginout")]
[ApiActionPermission((nameof(Sys_User)), ActionPermissionOptions.Add | ActionPermissionOptions.Update)]
public async Task<IActionResult> Loginout(string userName)
{
await _hubClients.Clients.Clients(UserCache.GetCnnectionIds(userName)).SendAsync("ReceiveHomePageMessage", new
{
msg = "您已被强制下线,即将自动退出登录...".Translator(),
code = "-1",
value="logout",
date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:sss")
});
return Content("操作成功".Translator());
}
}
}

View File

@@ -0,0 +1,63 @@
using Microsoft.AspNetCore.SignalR;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace VolPro.WebApi.Controllers.Hubs
{
public static class UserCache
{
public static ConcurrentDictionary<string, string> ConnectionIds = new ConcurrentDictionary<string, string>();
public static ConcurrentDictionary<string, int> Online = new ConcurrentDictionary<string, int>();
/// <summary>
/// 根据用户名获取所有的客户端
/// </summary>
/// <param name="username"></param>
/// <returns></returns>
public static IEnumerable<string> GetCnnectionIds(string username)
{
foreach (var item in ConnectionIds)
{
if (item.Value == username)
{
yield return item.Key;
}
}
}
public static int GetOnline(string username)
{
if (Online.TryGetValue(username, out int val))
{
return val;
}
return 0;
}
public static void Add(HubCallerContext context)
{
string userName = context.GetHttpContext().Request.Query["userName"].ToString();
if (string.IsNullOrEmpty(userName))
{
return;
}
Online[userName] = 1;
ConnectionIds[context.ConnectionId] = userName;
}
public static void Remove(HubCallerContext context)
{
var cid = context.ConnectionId;
//移除缓存
if (ConnectionIds.TryRemove(cid, out string value))
{
Online[value] = 0;
}
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_Bom_DetailController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_Bom_Detail")]
[PermissionTable(Name = "MES_Bom_Detail")]
public partial class MES_Bom_DetailController : ApiBaseController<IMES_Bom_DetailService>
{
public MES_Bom_DetailController(IMES_Bom_DetailService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_Bom_MainController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_Bom_Main")]
[PermissionTable(Name = "MES_Bom_Main")]
public partial class MES_Bom_MainController : ApiBaseController<IMES_Bom_MainService>
{
public MES_Bom_MainController(IMES_Bom_MainService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_CustomerController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_Customer")]
[PermissionTable(Name = "MES_Customer")]
public partial class MES_CustomerController : ApiBaseController<IMES_CustomerService>
{
public MES_CustomerController(IMES_CustomerService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_DefectiveProductDisposalRecordController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_DefectiveProductDisposalRecord")]
[PermissionTable(Name = "MES_DefectiveProductDisposalRecord")]
public partial class MES_DefectiveProductDisposalRecordController : ApiBaseController<IMES_DefectiveProductDisposalRecordService>
{
public MES_DefectiveProductDisposalRecordController(IMES_DefectiveProductDisposalRecordService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_DefectiveProductRecordController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_DefectiveProductRecord")]
[PermissionTable(Name = "MES_DefectiveProductRecord")]
public partial class MES_DefectiveProductRecordController : ApiBaseController<IMES_DefectiveProductRecordService>
{
public MES_DefectiveProductRecordController(IMES_DefectiveProductRecordService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_EquipmentFaultRecordController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_EquipmentFaultRecord")]
[PermissionTable(Name = "MES_EquipmentFaultRecord")]
public partial class MES_EquipmentFaultRecordController : ApiBaseController<IMES_EquipmentFaultRecordService>
{
public MES_EquipmentFaultRecordController(IMES_EquipmentFaultRecordService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_EquipmentMaintenanceController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_EquipmentMaintenance")]
[PermissionTable(Name = "MES_EquipmentMaintenance")]
public partial class MES_EquipmentMaintenanceController : ApiBaseController<IMES_EquipmentMaintenanceService>
{
public MES_EquipmentMaintenanceController(IMES_EquipmentMaintenanceService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_EquipmentManagementController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_EquipmentManagement")]
[PermissionTable(Name = "MES_EquipmentManagement")]
public partial class MES_EquipmentManagementController : ApiBaseController<IMES_EquipmentManagementService>
{
public MES_EquipmentManagementController(IMES_EquipmentManagementService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_EquipmentRepairController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_EquipmentRepair")]
[PermissionTable(Name = "MES_EquipmentRepair")]
public partial class MES_EquipmentRepairController : ApiBaseController<IMES_EquipmentRepairService>
{
public MES_EquipmentRepairController(IMES_EquipmentRepairService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_InventoryManagementController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_InventoryManagement")]
[PermissionTable(Name = "MES_InventoryManagement")]
public partial class MES_InventoryManagementController : ApiBaseController<IMES_InventoryManagementService>
{
public MES_InventoryManagementController(IMES_InventoryManagementService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_LocationManagementController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_LocationManagement")]
[PermissionTable(Name = "MES_LocationManagement")]
public partial class MES_LocationManagementController : ApiBaseController<IMES_LocationManagementService>
{
public MES_LocationManagementController(IMES_LocationManagementService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_MaterialCatalogController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_MaterialCatalog")]
[PermissionTable(Name = "MES_MaterialCatalog")]
public partial class MES_MaterialCatalogController : ApiBaseController<IMES_MaterialCatalogService>
{
public MES_MaterialCatalogController(IMES_MaterialCatalogService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_MaterialController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_Material")]
[PermissionTable(Name = "MES_Material")]
public partial class MES_MaterialController : ApiBaseController<IMES_MaterialService>
{
public MES_MaterialController(IMES_MaterialService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProcessController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_Process")]
[PermissionTable(Name = "MES_Process")]
public partial class MES_ProcessController : ApiBaseController<IMES_ProcessService>
{
public MES_ProcessController(IMES_ProcessService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProcessReportController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProcessReport")]
[PermissionTable(Name = "MES_ProcessReport")]
public partial class MES_ProcessReportController : ApiBaseController<IMES_ProcessReportService>
{
public MES_ProcessReportController(IMES_ProcessReportService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProcessRouteController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProcessRoute")]
[PermissionTable(Name = "MES_ProcessRoute")]
public partial class MES_ProcessRouteController : ApiBaseController<IMES_ProcessRouteService>
{
public MES_ProcessRouteController(IMES_ProcessRouteService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductInboundController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductInbound")]
[PermissionTable(Name = "MES_ProductInbound")]
public partial class MES_ProductInboundController : ApiBaseController<IMES_ProductInboundService>
{
public MES_ProductInboundController(IMES_ProductInboundService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductOutboundController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductOutbound")]
[PermissionTable(Name = "MES_ProductOutbound")]
public partial class MES_ProductOutboundController : ApiBaseController<IMES_ProductOutboundService>
{
public MES_ProductOutboundController(IMES_ProductOutboundService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionLineController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionLine")]
[PermissionTable(Name = "MES_ProductionLine")]
public partial class MES_ProductionLineController : ApiBaseController<IMES_ProductionLineService>
{
public MES_ProductionLineController(IMES_ProductionLineService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionLineDeviceController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionLineDevice")]
[PermissionTable(Name = "MES_ProductionLineDevice")]
public partial class MES_ProductionLineDeviceController : ApiBaseController<IMES_ProductionLineDeviceService>
{
public MES_ProductionLineDeviceController(IMES_ProductionLineDeviceService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionOrderController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionOrder")]
[PermissionTable(Name = "MES_ProductionOrder")]
public partial class MES_ProductionOrderController : ApiBaseController<IMES_ProductionOrderService>
{
public MES_ProductionOrderController(IMES_ProductionOrderService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionPlanChangeRecordController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionPlanChangeRecord")]
[PermissionTable(Name = "MES_ProductionPlanChangeRecord")]
public partial class MES_ProductionPlanChangeRecordController : ApiBaseController<IMES_ProductionPlanChangeRecordService>
{
public MES_ProductionPlanChangeRecordController(IMES_ProductionPlanChangeRecordService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionPlanDetailController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionPlanDetail")]
[PermissionTable(Name = "MES_ProductionPlanDetail")]
public partial class MES_ProductionPlanDetailController : ApiBaseController<IMES_ProductionPlanDetailService>
{
public MES_ProductionPlanDetailController(IMES_ProductionPlanDetailService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionReportingController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionReporting")]
[PermissionTable(Name = "MES_ProductionReporting")]
public partial class MES_ProductionReportingController : ApiBaseController<IMES_ProductionReportingService>
{
public MES_ProductionReportingController(IMES_ProductionReportingService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_ProductionReportingDetailController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_ProductionReportingDetail")]
[PermissionTable(Name = "MES_ProductionReportingDetail")]
public partial class MES_ProductionReportingDetailController : ApiBaseController<IMES_ProductionReportingDetailService>
{
public MES_ProductionReportingDetailController(IMES_ProductionReportingDetailService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_QualityInspectionPlanController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_QualityInspectionPlan")]
[PermissionTable(Name = "MES_QualityInspectionPlan")]
public partial class MES_QualityInspectionPlanController : ApiBaseController<IMES_QualityInspectionPlanService>
{
public MES_QualityInspectionPlanController(IMES_QualityInspectionPlanService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_QualityInspectionPlanDetailController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_QualityInspectionPlanDetail")]
[PermissionTable(Name = "MES_QualityInspectionPlanDetail")]
public partial class MES_QualityInspectionPlanDetailController : ApiBaseController<IMES_QualityInspectionPlanDetailService>
{
public MES_QualityInspectionPlanDetailController(IMES_QualityInspectionPlanDetailService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_QualityInspectionRecordController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_QualityInspectionRecord")]
[PermissionTable(Name = "MES_QualityInspectionRecord")]
public partial class MES_QualityInspectionRecordController : ApiBaseController<IMES_QualityInspectionRecordService>
{
public MES_QualityInspectionRecordController(IMES_QualityInspectionRecordService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_SchedulingPlanController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_SchedulingPlan")]
[PermissionTable(Name = "MES_SchedulingPlan")]
public partial class MES_SchedulingPlanController : ApiBaseController<IMES_SchedulingPlanService>
{
public MES_SchedulingPlanController(IMES_SchedulingPlanService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_SupplierController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_Supplier")]
[PermissionTable(Name = "MES_Supplier")]
public partial class MES_SupplierController : ApiBaseController<IMES_SupplierService>
{
public MES_SupplierController(IMES_SupplierService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,21 @@
/*
*代码由框架生成,任何更改都可能导致被代码生成器覆盖
*如果要增加方法请在当前目录下Partial文件夹MES_WarehouseManagementController编写
*/
using Microsoft.AspNetCore.Mvc;
using VolPro.Core.Controllers.Basic;
using VolPro.Entity.AttributeManager;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
[Route("api/MES_WarehouseManagement")]
[PermissionTable(Name = "MES_WarehouseManagement")]
public partial class MES_WarehouseManagementController : ApiBaseController<IMES_WarehouseManagementService>
{
public MES_WarehouseManagementController(IMES_WarehouseManagementService service)
: base(service)
{
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_Bom_Detail",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_Bom_DetailController
{
private readonly IMES_Bom_DetailService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_Bom_DetailController(
IMES_Bom_DetailService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_Bom_Main",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_Bom_MainController
{
private readonly IMES_Bom_MainService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_Bom_MainController(
IMES_Bom_MainService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_Customer",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_CustomerController
{
private readonly IMES_CustomerService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_CustomerController(
IMES_CustomerService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_DefectiveProductDisposalRecord",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_DefectiveProductDisposalRecordController
{
private readonly IMES_DefectiveProductDisposalRecordService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_DefectiveProductDisposalRecordController(
IMES_DefectiveProductDisposalRecordService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_DefectiveProductRecord",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_DefectiveProductRecordController
{
private readonly IMES_DefectiveProductRecordService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_DefectiveProductRecordController(
IMES_DefectiveProductRecordService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_EquipmentFaultRecord",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_EquipmentFaultRecordController
{
private readonly IMES_EquipmentFaultRecordService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_EquipmentFaultRecordController(
IMES_EquipmentFaultRecordService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_EquipmentMaintenance",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_EquipmentMaintenanceController
{
private readonly IMES_EquipmentMaintenanceService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_EquipmentMaintenanceController(
IMES_EquipmentMaintenanceService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_EquipmentManagement",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_EquipmentManagementController
{
private readonly IMES_EquipmentManagementService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_EquipmentManagementController(
IMES_EquipmentManagementService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_EquipmentRepair",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_EquipmentRepairController
{
private readonly IMES_EquipmentRepairService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_EquipmentRepairController(
IMES_EquipmentRepairService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_InventoryManagement",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_InventoryManagementController
{
private readonly IMES_InventoryManagementService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_InventoryManagementController(
IMES_InventoryManagementService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_LocationManagement",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_LocationManagementController
{
private readonly IMES_LocationManagementService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_LocationManagementController(
IMES_LocationManagementService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,60 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_MaterialCatalog",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
using VolPro.DbTest.Repositories;
using VolPro.MES.IRepositories;
using VolPro.Core.BaseProvider;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace VolPro.MES.Controllers
{
public partial class MES_MaterialCatalogController
{
private readonly IMES_MaterialCatalogService _service;//访问业务代码
private readonly IMES_MaterialCatalogRepository _repository;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_MaterialCatalogController(
IMES_MaterialCatalogService service,
IMES_MaterialCatalogRepository repository,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_repository= repository;
_httpContextAccessor = httpContextAccessor;
}
/// <summary>
/// 商品信息tree页面获取左边的tree的所有商品分类
/// </summary>
/// <returns></returns>
[Route("getList"), HttpGet]
public async Task<IActionResult> GetList()
{
var data = await _repository.FindAsIQueryable(x => true)
.Select(s => new
{
id = s.CatalogID,
s.ParentId,
name = s.CatalogName
})
.ToListAsync();
return Json(data);
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_Material",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_MaterialController
{
private readonly IMES_MaterialService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_MaterialController(
IMES_MaterialService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_Process",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProcessController
{
private readonly IMES_ProcessService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProcessController(
IMES_ProcessService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProcessReport",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProcessReportController
{
private readonly IMES_ProcessReportService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProcessReportController(
IMES_ProcessReportService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProcessRoute",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProcessRouteController
{
private readonly IMES_ProcessRouteService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProcessRouteController(
IMES_ProcessRouteService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductInbound",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductInboundController
{
private readonly IMES_ProductInboundService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductInboundController(
IMES_ProductInboundService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductOutbound",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductOutboundController
{
private readonly IMES_ProductOutboundService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductOutboundController(
IMES_ProductOutboundService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionLine",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionLineController
{
private readonly IMES_ProductionLineService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionLineController(
IMES_ProductionLineService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionLineDevice",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionLineDeviceController
{
private readonly IMES_ProductionLineDeviceService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionLineDeviceController(
IMES_ProductionLineDeviceService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionOrder",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionOrderController
{
private readonly IMES_ProductionOrderService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionOrderController(
IMES_ProductionOrderService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionPlanChangeRecord",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionPlanChangeRecordController
{
private readonly IMES_ProductionPlanChangeRecordService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionPlanChangeRecordController(
IMES_ProductionPlanChangeRecordService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionPlanDetail",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionPlanDetailController
{
private readonly IMES_ProductionPlanDetailService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionPlanDetailController(
IMES_ProductionPlanDetailService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionReporting",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionReportingController
{
private readonly IMES_ProductionReportingService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionReportingController(
IMES_ProductionReportingService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_ProductionReportingDetail",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_ProductionReportingDetailController
{
private readonly IMES_ProductionReportingDetailService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_ProductionReportingDetailController(
IMES_ProductionReportingDetailService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_QualityInspectionPlan",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_QualityInspectionPlanController
{
private readonly IMES_QualityInspectionPlanService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_QualityInspectionPlanController(
IMES_QualityInspectionPlanService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_QualityInspectionPlanDetail",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_QualityInspectionPlanDetailController
{
private readonly IMES_QualityInspectionPlanDetailService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_QualityInspectionPlanDetailController(
IMES_QualityInspectionPlanDetailService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_QualityInspectionRecord",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_QualityInspectionRecordController
{
private readonly IMES_QualityInspectionRecordService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_QualityInspectionRecordController(
IMES_QualityInspectionRecordService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_SchedulingPlan",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_SchedulingPlanController
{
private readonly IMES_SchedulingPlanService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_SchedulingPlanController(
IMES_SchedulingPlanService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_Supplier",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_SupplierController
{
private readonly IMES_SupplierService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_SupplierController(
IMES_SupplierService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,33 @@
/*
*接口编写处...
*如果接口需要做Action的权限验证请在Action上使用属性
*如: [ApiActionPermission("MES_WarehouseManagement",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VolPro.Entity.DomainModels;
using VolPro.MES.IServices;
namespace VolPro.MES.Controllers
{
public partial class MES_WarehouseManagementController
{
private readonly IMES_WarehouseManagementService _service;//访问业务代码
private readonly IHttpContextAccessor _httpContextAccessor;
[ActivatorUtilitiesConstructor]
public MES_WarehouseManagementController(
IMES_WarehouseManagementService service,
IHttpContextAccessor httpContextAccessor
)
: base(service)
{
_service = service;
_httpContextAccessor = httpContextAccessor;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace VolPro.WebApi.Controllers.MqDataHandle
{
/// <summary>
/// 数据处理
/// </summary>
public class DataHandle
{
/// <summary>
/// 构造 可注入service服务执行db
/// </summary>
public DataHandle()
{
}
/// <summary>
/// 报警数据处理
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
internal static bool AlarmData(string data)
{
//dapper入库或其他业务操作
return true;
}
}
}

View File

@@ -0,0 +1,110 @@
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VolPro.Core.Filters;
using VolPro.Core.ObjectActionValidator;
using VolPro.Entity.DomainModels;
namespace VolPro.WebApi.Controllers
{
/// <summary>
///1、普通参数校验只需要标识属性[ObjectGeneralValidatorFilter(ValidatorGeneral.xxx,ValidatorGeneral.xxx)]
///需要在ValidatorGeneral枚举中添加枚举值(参数名)并在UseMethodsGeneralParameters方法中注入进去即可在任何地方重复使用
///
/// 2、model校验只需要标识属性[ObjectModelValidatorFilter(ValidatorModel.xxx)]
/// 需要在ValidatorModel枚举中添加枚举值(参数名)
/// 并在UseMethodsModelParameters方法中注入进去(注入时可以指定需要验证的字段)即可在任何地方重复使用
/// --如果其他方法使用的是同一个model但验证的字段不同在ValidatorModel重新添加一个枚举值
/// --并在UseMethodsModelParameters方法注入,添加新的指定字段即可
/// </summary>
[JWTAuthorize, ApiController]
[Route("validatorExample")]
public class ObjectActionValidatorExampleController: Controller
{
public ObjectActionValidatorExampleController()
{
}
/// <summary>
/// 验证UserName与PhoneNo为必填
/// </summary>
/// <param name="userName"></param>
/// <param name="phoneNo"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("test1")]
[ObjectGeneralValidatorFilter(ValidatorGeneral.UserName,ValidatorGeneral.PhoneNo)]
public IActionResult Test1(string userName,string phoneNo)
{
return Json("参数验证通过");
}
/// <summary>
/// 验证PhoneNo为必填
/// </summary>
/// <param name="userName"></param>
/// <param name="phoneNo"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("test2")]
[ObjectGeneralValidatorFilter(ValidatorGeneral.PhoneNo)]
public IActionResult Test2(string userName, string phoneNo)
{
return Json("参数验证通过");
}
/// <summary>
/// 验证字符长度与值大小
/// </summary>
/// <param name="userName"></param>
/// <param name="phoneNo"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("test3")]
[ObjectGeneralValidatorFilter(ValidatorGeneral.Local, ValidatorGeneral.Qty)]
public IActionResult Test3(string local, string qty)
{
return Json("参数验证通过");
}
/// <summary>
/// Login配置的规则用户名与密码必填
/// </summary>
/// <param name="loginInfo"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("Test4")]
[ObjectModelValidatorFilter(ValidatorModel.Login)]
public IActionResult Test4([FromBody]LoginInfo loginInfo)
{
return Json("参数验证通过");
}
/// <summary>
/// LoginOnlyPassWord配置的规则密码必填
/// </summary>
/// <param name="loginInfo"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("Test5")]
[ObjectModelValidatorFilter(ValidatorModel.LoginOnlyPassWord)]
public IActionResult Test5([FromBody]LoginInfo loginInfo)
{
return Json("参数验证通过");
}
/// <summary>
/// 同时验证实体LoginInfo与单个参数phoneNo
/// Login配置的规则用户名与密码必填,手机号必填
/// </summary>
/// <param name="loginInfo"></param>
/// <returns></returns>
[HttpPost, HttpGet, Route("Test6")]
[ObjectModelValidatorFilter(ValidatorModel.Login)]
[ObjectGeneralValidatorFilter(ValidatorGeneral.PhoneNo)]
public IActionResult Test6([FromBody]LoginInfo loginInfo, string phoneNo)
{
return Json("参数验证通过");
}
}
}

View File

@@ -0,0 +1,79 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
using VolPro.Core.Controllers.Basic;
using VolPro.Core.PerformanceMonitor;
namespace VolPro.WebApi.Controllers.PerformanceMonitor
{
[Route("api/Monitor")]
[ApiController]
public class MonitorController : VolController
{
private readonly IPerformanceMonitorService _monitorService;
private readonly ILogger<MonitorController> _logger;
public MonitorController(
IPerformanceMonitorService monitorService,
ILogger<MonitorController> logger)
{
_monitorService = monitorService;
_logger = logger;
}
/// <summary>
/// 获取当前性能指标
/// </summary>
[HttpGet("current")]
public async Task<IActionResult> GetCurrentMetrics()
{
try
{
var metrics = await _monitorService.GetCurrentMetricsAsync(HttpContext.RequestAborted);
return Ok(new { success = true, data = metrics, message = "获取成功" });
}
catch (Exception ex)
{
_logger.LogError(ex, "获取当前性能指标失败");
return StatusCode(500, new { success = false, message = "获取性能指标失败" });
}
}
/// <summary>
/// 获取历史性能数据
/// </summary>
/// <param name="from">开始时间</param>
/// <param name="to">结束时间</param>
[HttpGet("history")]
public async Task<IActionResult> GetHistoricalData(
[FromQuery] DateTime from,
[FromQuery] DateTime to)
{
try
{
//// 验证时间范围
//if (from >= to)
//{
// return BadRequest(new { success = false, message = "开始时间必须早于结束时间" });
//}
//// 限制查询范围最多7天
//if ((to - from).TotalDays > 7)
//{
// return BadRequest(new { success = false, message = "查询时间范围不能超过7天" });
//}
var data = await _monitorService.GetHistoricalMetricsAsync(from, to);
return Ok(new { success = true, data = data, message = "获取成功" });
}
catch (Exception ex)
{
_logger.LogError(ex, "获取历史数据失败");
return StatusCode(500, new { success = false, message = "获取历史数据失败" });
}
}
}
}

View File

@@ -0,0 +1,300 @@
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using VolPro.Core.Controllers.Basic;
using VolPro.Sys.IRepositories;
using System.Linq;
using VolPro.Core.DbSqlSugar;
using VolPro.Core.Extensions;
using System.IO;
namespace VolPro.WebApi.Controllers
{
[Route("api/report")]
public class ReportController : ReportBaseController
{
private ISys_ReportOptionsRepository _optionsRepository { get; set; }
public ReportController(ISys_ReportOptionsRepository optionsRepository)
{
_optionsRepository = optionsRepository;
}
public override IActionResult GetTemplateData(string code)
{
//base.DbContext;
//base.ReportOptions;
return base.GetTemplateData(code);
}
/// <summary>
/// 根据报表code自定义返回数据
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
protected override object GetData(string code)
{
object data = null;
//这里只是测试直接写死的数据实际数据源请在报表模板页面中维护SQL或者使用DbContext自定义查询
switch (code)
{
case "16700053455897600":
data = Get16700053455897600();
break;
case "16700431661089792":
data = Get16700431661089792();
break;
default:
break;
}
return data;
}
private object Get16700053455897600()
{
return new
{
Table = new[]
{
new
{
OrderID = 10248,
CustomerId = "VINET",
CompanyName = "Vins et aliments",
OrderDate = "1996/7/4 0:00:00",
Freight = 32,
ProductID = 11,
ProductName = "Chai",
UnitPrice = 14,
Quantity = 12,
Discount = 0,
Amount = 168,
DiscountAmt = 0,
NetAmount = 168
},
new
{
OrderID = 10248,
CustomerId = "VINET",
CompanyName = "Vins et aliments",
OrderDate = "1996/7/4 0:00:00",
Freight = 32,
ProductID = 42,
ProductName = "Singaporean Hokkien Fried Mee",
UnitPrice = 10,
Quantity = 10,
Discount = 0,
Amount = 100,
DiscountAmt = 0,
NetAmount = 100
},
new
{
OrderID = 10249,
CustomerId = "TOMSP",
CompanyName = "Toms Spezialit?ten",
OrderDate = "1996/7/5 0:00:00",
Freight = 12,
ProductID = 14,
ProductName = "Aniseed Syrup",
UnitPrice = 19,
Quantity = 9,
Discount = 0,
Amount = 171,
DiscountAmt = 0,
NetAmount = 171
}
}
};
}
private object Get16700431661089792()
{
return new
{
Table = new[] {
new
{
CustomerID = "HUNGC",
CompanyName = "五金机械",
ContactName = "苏先生",
ContactTitle = "销售代表",
Address = "德昌路甲 29 号",
City = "大连",
Region = "东北",
PostalCode = "564576",
Country = "中国",
Phone = "(053) 5556874",
Fax = "(053) 5552376"
},
new
{
CustomerID = "CENTC",
CompanyName = "三捷实业",
ContactName = "王先生",
ContactTitle = "市场经理",
Address = "英雄山路 84 号",
City = "大连",
Region = "东北",
PostalCode = "130083",
Country = "中国",
Phone = "(061) 15553392",
Fax = "(061) 15557293"
},
new
{
CustomerID = "CACTU",
CompanyName = "威航货运有限公司",
ContactName = "刘先生",
ContactTitle = "销售代理",
Address = "经七纬二路 13 号",
City = "大连",
Region = "东北",
PostalCode = "120412",
Country = "中国",
Phone = "(061) 11355555",
Fax = "(061) 11354892"
},
new
{
CustomerID = "BLONP",
CompanyName = "国皓",
ContactName = "黄雅玲",
ContactTitle = "市场经理",
Address = "广发北路 10 号",
City = "大连",
Region = "东北",
PostalCode = "565479",
Country = "中国",
Phone = "(0671) 88601531",
Fax = "(0671) 88601532"
},
new
{
CustomerID = "MEREP",
CompanyName = "华科",
ContactName = "吴小姐",
ContactTitle = "市场助理",
Address = "和光北路 952 号",
City = "大连",
Region = "东北",
PostalCode = "280235",
Country = "中国",
Phone = "(0514) 5558054",
Fax = "(0514) 5558055"
},
new
{
CustomerID = "CENTC",
CompanyName = "三捷实业",
ContactName = "王先生",
ContactTitle = "市场经理",
Address = "英雄山路 84 号",
City = "大连",
Region = "东北",
PostalCode = "130083",
Country = "中国",
Phone = "(061) 15553392",
Fax = "(061) 15557293"
},
new
{
CustomerID = "CACTU",
CompanyName = "威航货运有限公司",
ContactName = "刘先生",
ContactTitle = "销售代理",
Address = "经七纬二路 13 号",
City = "大连",
Region = "东北",
PostalCode = "120412",
Country = "中国",
Phone = "(061) 11355555",
Fax = "(061) 11354892"
},
new
{
CustomerID = "BLONP",
CompanyName = "国皓",
ContactName = "黄雅玲",
ContactTitle = "市场经理",
Address = "广发北路 10 号",
City = "大连",
Region = "东北",
PostalCode = "565479",
Country = "中国",
Phone = "(0671) 88601531",
Fax = "(0671) 88601532"
},
new
{
CustomerID = "MEREP",
CompanyName = "华科",
ContactName = "吴小姐",
ContactTitle = "市场助理",
Address = "和光北路 952 号",
City = "大连",
Region = "东北",
PostalCode = "280235",
Country = "中国",
Phone = "(0514) 5558054",
Fax = "(0514) 5558055"
},
new
{
CustomerID = "CENTC",
CompanyName = "三捷实业",
ContactName = "王先生",
ContactTitle = "市场经理",
Address = "英雄山路 84 号",
City = "大连",
Region = "东北",
PostalCode = "130083",
Country = "中国",
Phone = "(061) 15553392",
Fax = "(061) 15557293"
},
new
{
CustomerID = "CACTU",
CompanyName = "威航货运有限公司",
ContactName = "刘先生",
ContactTitle = "销售代理",
Address = "经七纬二路 13 号",
City = "大连",
Region = "东北",
PostalCode = "120412",
Country = "中国",
Phone = "(061) 11355555",
Fax = "(061) 11354892"
},
new
{
CustomerID = "BLONP",
CompanyName = "国皓",
ContactName = "黄雅玲",
ContactTitle = "市场经理",
Address = "广发北路 10 号",
City = "大连",
Region = "东北",
PostalCode = "565479",
Country = "中国",
Phone = "(0671) 88601531",
Fax = "(0671) 88601532"
},
new
{
CustomerID = "MEREP",
CompanyName = "华科",
ContactName = "吴小姐",
ContactTitle = "市场助理",
Address = "和光北路 952 号",
City = "大连",
Region = "东北",
PostalCode = "280235",
Country = "中国",
Phone = "(0514) 5558054",
Fax = "(0514) 5558055"
}
}
};
}
}
}

Some files were not shown because too many files have changed in this diff Show More