mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2026-01-09 18:04:33 +08:00
feat: 增加低代码功能
This commit is contained in:
74
OpenAuth.App/LowcodeAppService/LowcodeAppService.cs
Normal file
74
OpenAuth.App/LowcodeAppService/LowcodeAppService.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
using SqlSugar;
|
||||
|
||||
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class LowcodeAppService : SqlSugarBaseApp<LowcodeApp>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
public async Task<TableData> Load(QueryLowcodeAppListReq request)
|
||||
{
|
||||
var loginContext = _auth.GetCurrentUser();
|
||||
if (loginContext == null)
|
||||
{
|
||||
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
|
||||
}
|
||||
|
||||
var result = new TableData();
|
||||
var objs = GetDataPrivilege("u");
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
{
|
||||
objs = objs.Where(u => u.Name.Contains(request.key));
|
||||
}
|
||||
|
||||
|
||||
|
||||
result.data = objs.OrderBy(u => u.Id)
|
||||
.Skip((request.page - 1) * request.limit)
|
||||
.Take(request.limit).ToList();
|
||||
result.count = await objs.CountAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Add(AddOrUpdateLowcodeAppReq req)
|
||||
{
|
||||
var obj = req.MapTo<LowcodeApp>();
|
||||
obj.Id = Guid.NewGuid().ToString();
|
||||
//todo: 根据业务需要调整字段
|
||||
obj.Createtime = DateTime.Now;
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
obj.Createuserid = user.Id;
|
||||
obj.Createusername = user.Name;
|
||||
Repository.Insert(obj);
|
||||
}
|
||||
|
||||
public void Update(AddOrUpdateLowcodeAppReq obj)
|
||||
{
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
Repository.Update(u => new LowcodeApp
|
||||
{
|
||||
//todo: 根据业务需要调整字段
|
||||
Updatetime = DateTime.Now,
|
||||
Updateuserid = user.Id,
|
||||
Updateusername = user.Name
|
||||
},u => u.Id == obj.Id);
|
||||
|
||||
}
|
||||
|
||||
public LowcodeAppService(ISqlSugarClient client, IAuth auth) : base(client, auth)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// This code was generated by a CodeSmith Template.
|
||||
//
|
||||
// DO NOT MODIFY contents of this file. Changes to this
|
||||
// file will be lost if the code is regenerated.
|
||||
// Author:Yubao Li
|
||||
//------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.App.Request
|
||||
{
|
||||
/// <summary>
|
||||
///低代码平台应用管理
|
||||
/// </summary>
|
||||
|
||||
public class AddOrUpdateLowcodeAppReq
|
||||
{
|
||||
/// <summary>
|
||||
///创建用户名
|
||||
/// </summary>
|
||||
public string Createusername { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///创建时间
|
||||
/// </summary>
|
||||
public DateTime Createtime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///状态:0=开发中,1=已发布,2=已下线
|
||||
/// </summary>
|
||||
public bool Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///更新用户ID
|
||||
/// </summary>
|
||||
public string Updateuserid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用ID
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///创建用户ID
|
||||
/// </summary>
|
||||
public string Createuserid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///租户ID
|
||||
/// </summary>
|
||||
public string Tenantid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///更新用户名
|
||||
/// </summary>
|
||||
public string Updateusername { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///更新时间
|
||||
/// </summary>
|
||||
public DateTime? Updatetime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用图标
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace OpenAuth.App.Request
|
||||
{
|
||||
public class QueryLowcodeAppListReq : PageReq
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
104
OpenAuth.Repository/Domain/LowcodeApp.cs
Normal file
104
OpenAuth.Repository/Domain/LowcodeApp.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// This code was generated by a CodeSmith Template.
|
||||
//
|
||||
// DO NOT MODIFY contents of this file. Changes to this
|
||||
// file will be lost if the code is regenerated.
|
||||
// Author:Yubao Li
|
||||
//------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
/// <summary>
|
||||
///低代码平台应用管理
|
||||
/// </summary>
|
||||
[Table("LowcodeApp")]
|
||||
public class LowcodeApp : StringEntity
|
||||
{
|
||||
public LowcodeApp()
|
||||
{
|
||||
this.Createusername="";
|
||||
this.Createtime=DateTime.Now;
|
||||
this.Description="";
|
||||
this.Status=false;
|
||||
this.Name="";
|
||||
this.Updateuserid="";
|
||||
this.Createuserid="";
|
||||
this.Tenantid="";
|
||||
this.Updateusername="";
|
||||
this.Updatetime=DateTime.Now;
|
||||
this.Icon="";
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///创建用户名
|
||||
/// </summary>
|
||||
[Description("创建用户名")]
|
||||
public string Createusername { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///创建时间
|
||||
/// </summary>
|
||||
[Description("创建时间")]
|
||||
public DateTime Createtime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用描述
|
||||
/// </summary>
|
||||
[Description("应用描述")]
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///状态:0=开发中,1=已发布,2=已下线
|
||||
/// </summary>
|
||||
[Description("状态:0=开发中,1=已发布,2=已下线")]
|
||||
public bool Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用名称
|
||||
/// </summary>
|
||||
[Description("应用名称")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///更新用户ID
|
||||
/// </summary>
|
||||
[Description("更新用户ID")]
|
||||
public string Updateuserid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///创建用户ID
|
||||
/// </summary>
|
||||
[Description("创建用户ID")]
|
||||
public string Createuserid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///租户ID
|
||||
/// </summary>
|
||||
[Description("租户ID")]
|
||||
public string Tenantid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///更新用户名
|
||||
/// </summary>
|
||||
[Description("更新用户名")]
|
||||
public string Updateusername { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///更新时间
|
||||
/// </summary>
|
||||
[Description("更新时间")]
|
||||
public DateTime? Updatetime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///应用图标
|
||||
/// </summary>
|
||||
[Description("应用图标")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
113
OpenAuth.WebApi/Controllers/LowcodeAppsController.cs
Normal file
113
OpenAuth.WebApi/Controllers/LowcodeAppsController.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.Request;
|
||||
using OpenAuth.App.Response;
|
||||
using OpenAuth.Repository.Domain;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 低代码平台接口
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = "低代码平台接口_LowcodeApps")]
|
||||
public class LowcodeAppsController : ControllerBase
|
||||
{
|
||||
private readonly LowcodeAppService _app;
|
||||
|
||||
//获取详情
|
||||
[HttpGet]
|
||||
public Response<LowcodeApp> Get(string id)
|
||||
{
|
||||
var result = new Response<LowcodeApp>();
|
||||
try
|
||||
{
|
||||
result.Result = _app.Get(id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//添加
|
||||
[HttpPost]
|
||||
public Response Add([FromBody]AddOrUpdateLowcodeAppReq obj)
|
||||
{
|
||||
var result = new Response();
|
||||
try
|
||||
{
|
||||
_app.Add(obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//修改
|
||||
[HttpPost]
|
||||
public Response Update([FromBody]AddOrUpdateLowcodeAppReq obj)
|
||||
{
|
||||
var result = new Response();
|
||||
try
|
||||
{
|
||||
_app.Update(obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public async Task<TableData> Load([FromQuery]QueryLowcodeAppListReq request)
|
||||
{
|
||||
return await _app.Load(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public Response Delete([FromBody]string[] ids)
|
||||
{
|
||||
var result = new Response();
|
||||
try
|
||||
{
|
||||
_app.Delete(ids);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result.Code = 500;
|
||||
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public LowcodeAppsController(LowcodeAppService app)
|
||||
{
|
||||
_app = app;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user