using Infrastructure.Attribute; using Infrastructure.Extensions; using Infrastructure.Model; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ZR.Model.System.Generate; using ZR.Service.System.IService; namespace ZR.Service.System { /// /// 代码生成表 /// [AppService(ServiceType = typeof(IGenTableService), ServiceLifetime = LifeTime.Transient)] public class GenTableService : BaseService, IGenTableService { /// /// 删除表 /// /// /// public int DeleteGenTable(GenTable table) { return Db.Deleteable().Where(f => f.TableName == table.TableName).ExecuteCommand(); } /// /// 获取表信息 /// /// /// public GenTable GetGenTableInfo(long tableId) { return GetId(tableId); } /// /// 查询代码生成表信息 /// /// /// /// public PagedInfo GetGenTables(GenTable genTable, Model.PagerInfo pagerInfo) { var predicate = Expressionable.Create(); predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName)); return GetPages(predicate.ToExpression(), pagerInfo); } /// /// 插入代码生成表 /// /// /// public int InsertGenTable(GenTable table) { var db = Db; DeleteGenTable(table); return db.Insertable(table).ExecuteReturnIdentity(); } /// /// 获取表数据 /// /// /// public List SelectDbTableListByNamess(string[] tableNames) { throw new NotImplementedException(); } } /// /// 代码生成表列 /// [AppService(ServiceType = typeof(IGenTableColumnService), ServiceLifetime = LifeTime.Transient)] public class GenTableColumnService : BaseService, IGenTableColumnService { /// /// 删除表字段 /// /// /// public int DeleteGenTableColumn(long tableId) { return Db.Deleteable().Where(f => f.TableId == tableId).ExecuteCommand(); } /// /// 获取表所有字段 /// /// /// public List GenTableColumns(long tableId) { return GetAll().OrderBy(x => x.Sort).ToList(); } /// /// 插入表字段 /// /// /// public int InsertGenTableColumn(List tableColumn) { return Db.Insertable(tableColumn).ExecuteCommand(); } } }