qin
2025-03-19 342b10ed5f4ebbccf2d2868d211fbe91cf3e8d5d
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
using Yw.DAL.SQLite;
 
namespace PBS.DAL.SQLite
{
    /// <summary>
    /// 模型模板
    ///</summary> 
    public class ModelTemplate : BaseDAL_Paras_Flags_TagName_Sorter_UseStatus<PBS.Entity.ModelTemplate>, IModelTemplate
    {
        /// <summary>
        ///
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return PBS.ConfigHelper.SQLiteConnectionConfig; }
        }
 
 
 
        /// <summary>
        /// 通过 GroupID 获取
        /// </summary>
        public List<PBS.Entity.ModelTemplate> GetByGroupID(long GroupID)
        {
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<PBS.Entity.ModelTemplate>()
                    .Where(x => x.GroupID == GroupID).ToList();
            }
        }
 
        /// <summary>
        /// 通过 GroupIds 获取
        /// </summary>
        public List<PBS.Entity.ModelTemplate> GetByGroupIds(List<long> GroupIds)
        {
            if (GroupIds == null || !GroupIds.Any())
            {
                return default;
            }
            using (var db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Queryable<PBS.Entity.ModelTemplate>()
                    .Where(x => GroupIds.Contains(x.GroupID)).ToList();
            }
        }
 
        /// <summary>
        /// 更新 GroupID
        /// </summary>
        public bool UpdateGroupID(long ID, long GroupID)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<PBS.Entity.ModelTemplate>()
                    .SetColumns(x => x.GroupID == GroupID)
                    .Where(x => x.ID == ID)
                    .ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 批量更新 GroupID
        /// </summary>
        public bool UpdateGroupIds(List<(long ID, long GroupID)> list)
        {
            if (list == null || list.Count < 1)
                return false;
            using (var db = new SqlSugarClient(this.ConnectionConfig))
            {
                var entityList = list.Select(x => new PBS.Entity.ModelTemplate() { ID = x.ID, GroupID = x.GroupID }).ToList();
                return db.Updateable(entityList)
                    .UpdateColumns(nameof(PBS.Entity.ModelTemplate.GroupID))
                    .ExecuteCommandHasChange();
            }
        }
 
 
    }
}