移动系统liao
2025-05-01 a247547df86f0fad8f03aebb91de68d3f2bc7918
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
using cylsg.Core.Attributes;
using cylsg.Core;
 
namespace cylsg.Application;
 
/// <summary>
/// 系统服务接口
/// </summary>
public class SystemAppService : IDynamicApiController
{
    private readonly ISystemService _systemService;
    private ISqlSugarClient _sqlSugarClient;
    public SystemAppService(ISystemService systemService,ISqlSugarClient sqlSugarClient)
    {
        _systemService = systemService;
        _sqlSugarClient = sqlSugarClient;
    }
 
 
    /// <summary>
    /// 创建系统
    /// </summary>
    /// <returns></returns>
    public string codefirst()
    {
 
      
            try
            {
                //_ez.GetDb().AsTenant().ChangeDatabase(ConfigId);
                _sqlSugarClient.DbMaintenance.CreateDatabase();
                Type[]? types = DbCoreUntil.DbCodeFirstModes("cylsg.Model", thisAttribute: typeof(CoderFirstAttribute));
 
 
                _sqlSugarClient.CodeFirst.SetStringDefaultLength(512).InitTables(types ?? new Type[] { });
 
                return "创建成功";
            }
            catch (Exception e)
            {
 
                return $"创建失败,报错: {e.Message},-----详情:{e.StackTrace}";
 
            }
        
    }
}