| | |
| | | /*********************************************************************** |
| | | * Project: CoreCms |
| | | * ProjectName: 核心内容管理系统 |
| | | * Web: https://www.corecms.net |
| | | * Author: 大灰灰 |
| | | * Email: jianweie@163.com |
| | | * CreateTime: 2021/1/31 21:45:10 |
| | | * Project: baifenBinfa |
| | | * ProjectName: 百分兵法管理系统 |
| | | * Web: http://chuanyin.com |
| | | * Author: |
| | | * Email: |
| | | * CreateTime: 202403/02 |
| | | * Description: 暂无 |
| | | ***********************************************************************/ |
| | | |
| | | using System; |
| | | using System.CodeDom; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Threading.Tasks; |
| | | using AutoMapper; |
| | | using Chuanyin.Attribute; |
| | | using CoreCms.Net.Configuration; |
| | | using CoreCms.Net.IRepository.UnitOfWork; |
| | | using CoreCms.Net.IServices; |
| | | using CoreCms.Net.Loging; |
| | | using CoreCms.Net.Model.Entities.Distribution; |
| | | using CoreCms.Net.Model.ViewModels.Basics; |
| | | using CoreCms.Net.Model.ViewModels.UI; |
| | | using CoreCms.Net.Repository.UnitOfWork; |
| | | using CoreCms.Net.Utility.Helper; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Hosting; |
| | |
| | | private readonly IWebHostEnvironment _webHostEnvironment; |
| | | |
| | | private readonly IMapper _mapper; |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | |
| | | _codeGeneratorServices = codeGeneratorServices; |
| | | _mapper = mapper; |
| | | _webHostEnvironment = webHostEnvironment; |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region 生成或者更新数据库 |
| | | /// <summary> |
| | | /// 创建和更新数据库 |
| | | /// </summary> |
| | | /// <param name="tableName"></param> |
| | | /// <param name="fileType"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [Description("创建新表")] |
| | | public IActionResult CreateAndUpdateDatabase([FromServices] IUnitOfWork work) |
| | | { |
| | | var jm = new AdminUiCallBack(); |
| | | try |
| | | { |
| | | Type[]? types = AssemblyHelper.DbCodeFirstModes("CoreCms.Net.Model",thisAttribute: typeof(SqlCodeFirstAttribute)); |
| | | |
| | | |
| | | work.GetDbClient().CodeFirst.InitTables(types??new Type[] { }); |
| | | jm.code = 0; |
| | | |
| | | jm.msg = "创建成功"; |
| | | return new JsonResult(jm); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | jm.msg = e.Message + ":-----" + e.StackTrace; |
| | | return new JsonResult(jm); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |