Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
forked from zuohuaijun/Admin.NET
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (4)
Tags (21)
master
next
micros
dev
2.4.0
2.3.1
2.3.0
2.2.2
2.2.1
2.2.0
2.1.1
1.2.0
2.1.0
2.0.3
2.0.2
1.1.1
2.0.1
2.0.0
1.1.0
v1.0.22
v1.0.19
v1.0.18
v1.0.12
v1.0.10
master
Branches (4)
Tags (21)
master
next
micros
dev
2.4.0
2.3.1
2.3.0
2.2.2
2.2.1
2.2.0
2.1.1
1.2.0
2.1.0
2.0.3
2.0.2
1.1.1
2.0.1
2.0.0
1.1.0
v1.0.22
v1.0.19
v1.0.18
v1.0.12
v1.0.10
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (4)
Tags (21)
master
next
micros
dev
2.4.0
2.3.1
2.3.0
2.2.2
2.2.1
2.2.0
2.1.1
1.2.0
2.1.0
2.0.3
2.0.2
1.1.1
2.0.1
2.0.0
1.1.0
v1.0.22
v1.0.19
v1.0.18
v1.0.12
v1.0.10
LowCodeService.cs 9.88 KB
Copy Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
using Furion.DatabaseAccessor;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.Extras.Admin.NET.Entity;
using Furion.Extras.Admin.NET.Service.LowCode.Dto;
using Furion.ViewEngine;
using Microsoft.AspNetCore.Mvc;
using System.Linq.Dynamic.Core;
using Microsoft.EntityFrameworkCore;
using Furion.FriendlyException;
using Mapster;
using Furion.DatabaseAccessor.Extensions;
using Furion.Extras.Admin.NET.Util;
using Furion.Extras.Admin.NET.Util.LowCode.Front.Code;
using Furion.Extras.Admin.NET.Util.LowCode.Front.Interface;
using System.Linq;
using System.Text;
using Furion.Extras.Admin.NET.Service.CodeGen;
namespace Furion.Extras.Admin.NET.Service.LowCode
{
/// <summary>
/// 低代码模块服务
/// </summary>
[ApiDescriptionSettings(Name = "LowCode", Order = 100)]
[Route("api/lowcode")]
public class LowCodeService : ILowCodeService, IDynamicApiController, ITransient
{
private readonly IRepository<SysLowCode> _sysLowCodeRep;
private readonly IRepository<SysLowCodeDataBase> _sysLowCodeDataBaseRep;
private readonly IViewEngine _viewEngine;
private readonly ICodeGenService _codeGenService;
public LowCodeService(IRepository<SysLowCode> sysLowCodeRep,
IRepository<SysLowCodeDataBase> sysLowCodeDataBaseRep,
ICodeGenService codeGenService,
IViewEngine viewEngine)
{
_sysLowCodeRep = sysLowCodeRep;
_sysLowCodeDataBaseRep = sysLowCodeDataBaseRep;
_codeGenService = codeGenService;
_viewEngine = viewEngine;
}
/// <summary>
/// 分页查询
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpGet("page")]
public async Task<PageResult<SysLowCode>> QueryPageList([FromQuery] LowCodePageInput input)
{
var busName = !string.IsNullOrEmpty(input.BusName?.Trim());
var lowCodes = await _sysLowCodeRep.DetachedEntities
.Where((busName, u => EF.Functions.Like(u.BusName, $"%{input.BusName.Trim()}%")))
.ToADPagedListAsync(input.PageNo, input.PageSize);
return lowCodes;
}
/// <summary>
/// 获取模块详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("info/{id}")]
public SysLowCode Info(long id)
{
return _sysLowCodeRep.Where(x => x.Id == id).Include(x => x.Databases).FirstOrDefault();
}
/// <summary>
/// 添加
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpPost("add")]
public async Task Add(AddLowCodeInput input)
{
var isExist = await _sysLowCodeRep.DetachedEntities.AnyAsync(u => u.BusName == input.BusName);
if (isExist)
throw Oops.Oh(ErrorCode.D1600);
var lowCode = input.Adapt<SysLowCode>();
var newLowCode = await lowCode.InsertNowAsync();
}
/// <summary>
/// 删除
/// </summary>
/// <param name="inputs"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpPost("del")]
public async Task Delete(List<DeleteLowCodeInput> inputs)
{
if (inputs == null || inputs.Count < 1) return;
foreach(var u in inputs)
{
await _sysLowCodeRep.DeleteAsync(u.Id);
}
}
/// <summary>
/// 更新
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpPost("edit")]
public async Task Update(UpdateLowCodeInput input)
{
var lowCode = input.Adapt<SysLowCode>();
await lowCode.UpdateAsync();
await _sysLowCodeDataBaseRep.Context.DeleteRangeAsync<SysLowCodeDataBase>(x => x.SysLowCodeId == input.Id);
await _sysLowCodeDataBaseRep.InsertAsync(lowCode.Databases);
}
/// <summary>
/// 对比组件
/// </summary>
/// <param name="contrast"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
[HttpPost("contrast")]
public List<ContrastLowCode_Database> Contrast(ContrastLowCode contrast)
{
List<IFront> fronts = contrast.Controls.ConvertToFront().AllFront();
DataCompareUtil<IFront, ContrastLowCode_Database> dataCompare
= new DataCompareUtil<IFront, ContrastLowCode_Database>(x => x.Key, x => x.Id);
dataCompare.PushCompare(x => x.Key, x => x.Control_Key);
dataCompare.PushCompare(x => x.Label, x => x.Control_Label);
dataCompare.PushCompare(x => x.Model, x => x.Control_Model);
dataCompare.PushCompare(x => x.Type, x => x.Control_Type);
var compare = dataCompare.Compare(fronts, contrast.Databases);
List<ContrastLowCode_Database> list = new List<ContrastLowCode_Database>();
compare.NoContain_2.ForEach(item => {
list.AddRange(item.ReadFront_BindDatabase(_sysLowCodeRep.ProviderName).Select(x => new ContrastLowCode_Database() {
Control_Key = item.Key,
Control_Label = item.Label,
Control_Model = item.Model,
Control_Type = item.Type,
DbParam = x.DbParam,
DbType = x.DbType,
DbTypeName = x.DbType.Name,
FieldName = $"{item.Model}{x.Suffix}",
IsRequired = true,
Id = Guid.NewGuid(),
TableName = String.Empty,
ClassName = string.Empty,
TableDesc = string.Empty
}));
});
return list;
}
/// <summary>
/// 生成ORM模型
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet("runLocal/{id}")]
public bool RunLocal(long id)
{
var info = Info(id);
var list = info.Databases.Select(x => new GenEntity() {
NameSpace = info.NameSpace,
ClassName = x.ClassName,
TableDesc = x.TableDesc,
TableName = x.TableName,
DatabaseName = info.DatabaseName
}).Distinct(new GenEntityComparer()).ToList();
list.ForEach(item =>
{
item.Fields = info.Databases.Where(x => x.ClassName == item.ClassName).Select(x => new GenEntity_Field()
{
ColumnComment = x.Control_Label,
DbParam = x.DbParam,
FieldName = x.FieldName,
IsRequired = x.IsRequired == null ? false : x.IsRequired.Value,
NetType = x.DbTypeName
}).ToList();
});
var templatePathList = GetTemplatePathList();
list.ForEach(item =>
{
var targetPathList = GetTargetPathList(item);
for (var i = 0; i < templatePathList.Count; i++)
{
var tContent = File.ReadAllText(templatePathList[i]);
var tResult = _viewEngine.RunCompileFromCached(tContent, new {
TableName = item.TableName,
NameSpace = item.NameSpace,
Fields = item.Fields.Select(x => new { x.ColumnComment, x.DbParam, x.FieldName, x.IsRequired, x.NetType }).ToList(),
ClassName = item.ClassName,
TableDesc = item.TableDesc,
DatabaseName = item.DatabaseName
});
var dirPath = new DirectoryInfo(targetPathList[i]).Parent.FullName;
if (!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);
File.WriteAllText(targetPathList[i], tResult, Encoding.UTF8);
}
_codeGenService.AddCodeGen(new AddCodeGenInput()
{
LowCodeId = id,
NameSpace = info.NameSpace,
AuthorName = info.AuthorName,
BusName = info.BusName,
ClassName = item.ClassName,
DatabaseName = info.DatabaseName,
GenerateType = info.GenerateType,
MenuApplication = info.MenuApplication,
MenuPid = info.MenuPid,
TableComment = item.TableDesc,
TableName = item.TableName,
TablePrefix = null
}).Wait();
});
return true;
}
private List<string> GetTemplatePathList()
{
var templatePath = App.WebHostEnvironment.WebRootPath + @"\Template\";
return new List<string>()
{
templatePath + "Entity.cs.vm"
};
}
/// <summary>
/// 设置生成文件路径
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private List<string> GetTargetPathList(GenEntity input)
{
var backendPath = new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent.FullName + @"\" + input.NameSpace + @"\Entity\";
var outputPath = backendPath + @"\" + input.ClassName + ".cs";
return new List<string>()
{
outputPath
};
}
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

🔥基于Furion/.NET 5实现的通用管理平台。整合最新技术,模块插件式开发,前后端分离,开箱即用。集成EF Core、多租户、缓存、数据校验、鉴权、事件总线、动态API、通讯、远程请求、任务调度、gRPC等众多黑科技。代码简洁、易扩展,让开发更简单、更通用、更流行!
No labels
Apache-2.0
Use Apache-2.0
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/github-mysync/Admin.NET.git
git@gitee.com:github-mysync/Admin.NET.git
github-mysync
Admin.NET
Admin.NET
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /