using Infrastructure.Attribute; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ZR.Model.System.Generate; namespace ZR.Repository.System { [AppService(ServiceLifetime = LifeTime.Transient)] public class GenTableRepository : BaseRepository { } [AppService(ServiceLifetime = LifeTime.Transient)] public class GenTableColumnRepository : BaseRepository { /// /// 根据表id批量删除表字段 /// /// /// public int DeleteGenTableColumn(long[] tableId) { return Context.Deleteable().Where(f => tableId.Contains(f.TableId)).ExecuteCommand(); } /// /// 根据表名删除字段 /// /// /// public int DeleteGenTableColumnByTableName(string tableName) { return Context.Deleteable().Where(f => f.TableName == tableName).ExecuteCommand(); } /// /// 获取表所有字段 /// /// /// public List GenTableColumns(long tableId) { return Context.Queryable().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList(); } /// /// 插入表字段 /// /// /// public int InsertGenTableColumn(List tableColumn) { return Context.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand(); } /// /// 批量更新表字段 /// /// /// public int UpdateGenTableColumn(List tableColumn) { foreach (var item in tableColumn) { Context.Updateable() .Where(f => f.TableId == item.TableId) .SetColumns(it => new GenTableColumn() { ColumnComment = item.ColumnComment, CsharpField = item.CsharpField, CsharpType = item.CsharpType, IsQuery = item.IsQuery, IsEdit = item.IsEdit, IsInsert = item.IsInsert, IsList = item.IsList, QueryType = item.QueryType, HtmlType = item.HtmlType, IsRequired = item.IsRequired, Sort = item.Sort, Update_time = DateTime.Now, DictType = item.DictType }) .Where(f => f.ColumnId == item.ColumnId) .ExecuteCommand(); } return 1; } } }