parent
a199ca000b
commit
1a3b3d8e80
|
|
@ -0,0 +1,119 @@
|
|||
using Infrastructure;
|
||||
using OpenAuth.App.BaseApp.Base;
|
||||
using OpenAuth.App.Interface;
|
||||
using OpenAuth.App.ServiceApp.GoView.Request;
|
||||
using OpenAuth.App.ServiceApp.GoView.Response;
|
||||
using OpenAuth.Repository;
|
||||
using OpenAuth.Repository.Domain.GoView;
|
||||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.GoView;
|
||||
|
||||
public class GoViewProjectApp : SqlSugarBaseApp<GoviewProject, SugarDbContext>
|
||||
{
|
||||
public GoViewProjectApp(ISugarUnitOfWork<SugarDbContext> unitWork, ISimpleClient<GoviewProject> repository,
|
||||
IAuth auth) : base(unitWork, repository, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<AjaxResult> DeleteProject(string ids)
|
||||
{
|
||||
var idArray = ids.Split(",");
|
||||
var flag = await Repository.DeleteByIdsAsync(idArray);
|
||||
return flag ? AjaxResult.Success("删除成功") : AjaxResult.Error("删除失败");
|
||||
}
|
||||
|
||||
public async Task<AjaxResult> UpdateProject(GoviewProject project)
|
||||
{
|
||||
var flag = await Repository.AsUpdateable(project).IgnoreNullColumns().ExecuteCommandAsync();
|
||||
return flag > 0 ? AjaxResult.Success("修改成功") : AjaxResult.Error("修改失败");
|
||||
}
|
||||
|
||||
public async Task<AjaxResult> Create(GoviewProject project)
|
||||
{
|
||||
project.State = -1;
|
||||
project.CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
var userId = _auth.GetUserId();
|
||||
project.CreateUserId = userId;
|
||||
project.Id = Guid.NewGuid().ToString();
|
||||
var flag = await Repository.InsertAsync(project);
|
||||
return flag ? AjaxResult.Success("创建成功") : AjaxResult.Error("创建失败");
|
||||
}
|
||||
|
||||
public async Task<AjaxResult> Publish(GoViewProjectRequest req)
|
||||
{
|
||||
var prj = new GoviewProject
|
||||
{
|
||||
Id = req.Id,
|
||||
State = req.State
|
||||
};
|
||||
var flag = await Repository.AsUpdateable(prj).IgnoreNullColumns().ExecuteCommandAsync() > 0;
|
||||
return flag ? AjaxResult.Success("操作成功") : AjaxResult.Error("操作失败");
|
||||
}
|
||||
|
||||
public async Task<ResultTable> List(GoViewProjectPage page)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var list = await Repository.AsQueryable()
|
||||
.ToPageListAsync(page.page, page.limit, total);
|
||||
|
||||
return new ResultTable()
|
||||
{
|
||||
Code = 200,
|
||||
Msg = "获取成功",
|
||||
Count = total,
|
||||
Data = list
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<AjaxResult> GetData(string projectId)
|
||||
{
|
||||
var prj = await Repository.AsQueryable().SingleAsync(a => a.Id == projectId);
|
||||
if (prj == null)
|
||||
{
|
||||
return AjaxResult.Error("项目不存在");
|
||||
}
|
||||
|
||||
var vo = prj.MapTo<ProjectResponse>();
|
||||
var data = await Repository.ChangeRepository<SugarRepositiry<GoviewProjectData>>().AsQueryable()
|
||||
.SingleAsync(a => a.ProjectId == projectId);
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
vo.Content = data.Content;
|
||||
}
|
||||
|
||||
return AjaxResult.SuccessData(200, vo);
|
||||
}
|
||||
|
||||
public async Task<AjaxResult> SaveData(GoviewProjectData data)
|
||||
{
|
||||
// 更新还是保存,
|
||||
var project = await Repository.AsQueryable().SingleAsync(a => a.Id == data.ProjectId);
|
||||
if (project == null)
|
||||
{
|
||||
throw new Exception("项目不存在");
|
||||
}
|
||||
|
||||
var prjData = await Repository
|
||||
.ChangeRepository<SugarRepositiry<GoviewProjectData>>()
|
||||
.AsQueryable()
|
||||
.SingleAsync(a => a.ProjectId == data.ProjectId);
|
||||
bool flag;
|
||||
if (prjData == null)
|
||||
{
|
||||
data.Id = Guid.NewGuid().ToString();
|
||||
flag = await Repository.ChangeRepository<SugarRepositiry<GoviewProjectData>>().InsertAsync(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = await Repository
|
||||
.ChangeRepository<SugarRepositiry<GoviewProjectData>>()
|
||||
.AsUpdateable(data)
|
||||
.IgnoreNullColumns()
|
||||
.ExecuteCommandAsync() > 0;
|
||||
}
|
||||
|
||||
return flag ? AjaxResult.Success("数据保存成功") : AjaxResult.Error("数据保存失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using OpenAuth.App.Request;
|
||||
|
||||
namespace OpenAuth.App.ServiceApp.GoView.Request;
|
||||
|
||||
public class GoViewProjectPage : PageReq
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
namespace OpenAuth.App.ServiceApp.GoView.Request;
|
||||
|
||||
public class GoViewProjectRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int State { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
namespace OpenAuth.App.ServiceApp.GoView.Response;
|
||||
|
||||
public class AjaxResult : Dictionary<string, object>
|
||||
{
|
||||
/**
|
||||
* 初始化一个新创建的 Message 对象
|
||||
*/
|
||||
public AjaxResult()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult Error()
|
||||
{
|
||||
return Error(500, "操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param msg 内容
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult Error(string msg)
|
||||
{
|
||||
return Error(500, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param code 错误码
|
||||
* @param msg 内容
|
||||
* @return 错误消息
|
||||
*/
|
||||
public static AjaxResult Error(int code, string msg)
|
||||
{
|
||||
AjaxResult json = new AjaxResult();
|
||||
json["code"] = code;
|
||||
json["msg"] = msg;
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param msg 内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult Success(string msg)
|
||||
{
|
||||
AjaxResult json = new AjaxResult();
|
||||
json["msg"] = msg;
|
||||
json["code"] = 200;
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @return 成功消息
|
||||
*/
|
||||
public static AjaxResult Success()
|
||||
{
|
||||
return Success("操作成功");
|
||||
}
|
||||
|
||||
public static AjaxResult SuccessData(int code, object value)
|
||||
{
|
||||
AjaxResult json = new AjaxResult();
|
||||
json["code"] = code;
|
||||
json["data"] = value;
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回成功消息
|
||||
*
|
||||
* @param key 键值
|
||||
* @param value 内容
|
||||
* @return 成功消息
|
||||
*/
|
||||
public new AjaxResult Put(string key, object value)
|
||||
{
|
||||
base[key] = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
namespace OpenAuth.App.ServiceApp.GoView.Response;
|
||||
|
||||
public class ProjectResponse
|
||||
{
|
||||
private string _id;
|
||||
private string _projectName;
|
||||
private int? _state;
|
||||
private string _createTime;
|
||||
private string _createUserId;
|
||||
private int? _isDelete;
|
||||
private string _indexImage;
|
||||
private string _remarks;
|
||||
private string _content;
|
||||
|
||||
public string Id
|
||||
{
|
||||
get { return _id; }
|
||||
set { _id = value; }
|
||||
}
|
||||
|
||||
public string ProjectName
|
||||
{
|
||||
get { return _projectName; }
|
||||
set { _projectName = value; }
|
||||
}
|
||||
|
||||
public int? State
|
||||
{
|
||||
get { return _state; }
|
||||
set { _state = value; }
|
||||
}
|
||||
|
||||
public string CreateTime
|
||||
{
|
||||
get { return _createTime; }
|
||||
set { _createTime = value; }
|
||||
}
|
||||
|
||||
public string CreateUserId
|
||||
{
|
||||
get { return _createUserId; }
|
||||
set { _createUserId = value; }
|
||||
}
|
||||
|
||||
public int? IsDelete
|
||||
{
|
||||
get { return _isDelete; }
|
||||
set { _isDelete = value; }
|
||||
}
|
||||
|
||||
public string IndexImage
|
||||
{
|
||||
get { return _indexImage; }
|
||||
set { _indexImage = value; }
|
||||
}
|
||||
|
||||
public string Remarks
|
||||
{
|
||||
get { return _remarks; }
|
||||
set { _remarks = value; }
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get { return _content; }
|
||||
set { _content = value; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
namespace OpenAuth.App.ServiceApp.GoView.Response;
|
||||
|
||||
public class ResultTable
|
||||
{
|
||||
/**
|
||||
* 状态码
|
||||
* */
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 提示消息
|
||||
* */
|
||||
private string msg;
|
||||
|
||||
/**
|
||||
* 消息总量
|
||||
* */
|
||||
private long count;
|
||||
|
||||
/**
|
||||
* 数据对象
|
||||
* */
|
||||
private object data;
|
||||
|
||||
public int Code
|
||||
{
|
||||
get { return code; }
|
||||
set { code = value; }
|
||||
}
|
||||
|
||||
public string Msg
|
||||
{
|
||||
get { return msg; }
|
||||
set { msg = value; }
|
||||
}
|
||||
|
||||
public long Count
|
||||
{
|
||||
get { return count; }
|
||||
set { count = value; }
|
||||
}
|
||||
|
||||
public object Data
|
||||
{
|
||||
get { return data; }
|
||||
set { data = value; }
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建
|
||||
* */
|
||||
public static ResultTable PageTable(long count, object data)
|
||||
{
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.Data = data;
|
||||
resultTable.Code = 0;
|
||||
resultTable.Count = count;
|
||||
if (data != null)
|
||||
{
|
||||
resultTable.Msg = "获取成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
resultTable.Msg = "获取失败";
|
||||
}
|
||||
|
||||
return resultTable;
|
||||
}
|
||||
|
||||
public static ResultTable DataTable(object data)
|
||||
{
|
||||
ResultTable resultTable = new ResultTable();
|
||||
resultTable.Data = data;
|
||||
resultTable.Code = 0;
|
||||
if (data != null)
|
||||
{
|
||||
resultTable.Msg = "获取成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
resultTable.Msg = "获取失败";
|
||||
}
|
||||
|
||||
return resultTable;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.Repository.Domain.GoView;
|
||||
|
||||
/// <summary>
|
||||
/// 项目模型类
|
||||
/// </summary>
|
||||
[SugarTable("t_goview_project")]
|
||||
public class GoviewProject
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, ColumnName = "id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "project_name")]
|
||||
public string ProjectName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目状态 -1 1
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "state")]
|
||||
public int? State { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable = true, ColumnName = "create_time")]
|
||||
public string CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "create_user_id")]
|
||||
public string CreateUserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// -1-未删除 1-删除
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_delete")]
|
||||
public int? IsDelete { get; set; }
|
||||
[SugarColumn(ColumnName = "index_image")]
|
||||
public string IndexImage { get; set; }
|
||||
[SugarColumn(ColumnName = "remarks")]
|
||||
public string Remarks { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using SqlSugar;
|
||||
|
||||
namespace OpenAuth.Repository.Domain.GoView;
|
||||
|
||||
/// <summary>
|
||||
/// 项目数据模型类
|
||||
/// </summary>
|
||||
[SugarTable("t_goview_project_data")]
|
||||
public class GoviewProjectData
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true,ColumnName = "id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "project_id")]
|
||||
public string ProjectId { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable = true, ColumnName = "create_time")]
|
||||
public string CreateTime { get; set; }
|
||||
|
||||
// 创建人
|
||||
[SugarColumn(ColumnName = "create_user_id")]
|
||||
public string CreateUserId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "content")] public string Content { get; set; }
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||
using OpenAuth.App.ServiceApp.LayerManagerApp;
|
||||
using OpenAuth.App.ServiceApp.LayerManagerApp.Request;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceController;
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance;
|
||||
|
||||
/// <summary>
|
||||
/// 图层
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
using Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OpenAuth.App.ServiceApp.GoView;
|
||||
using OpenAuth.App.ServiceApp.GoView.Request;
|
||||
using OpenAuth.App.ServiceApp.GoView.Response;
|
||||
using OpenAuth.Repository.Domain.GoView;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView;
|
||||
|
||||
/// <summary>
|
||||
/// go view 接口
|
||||
/// </summary>
|
||||
[Route("api/goview/project")]
|
||||
[ApiController]
|
||||
public class GoViewProjectController : ControllerBase
|
||||
{
|
||||
private readonly GoViewProjectApp _app;
|
||||
|
||||
public GoViewProjectController(GoViewProjectApp goView)
|
||||
{
|
||||
_app = goView;
|
||||
}
|
||||
|
||||
// 文件上传
|
||||
[HttpPost("uploadFile")]
|
||||
public async Task<Response<bool>> UploadFile(IFormFile file)
|
||||
{
|
||||
return null;
|
||||
//return await _app.UploadFile(file);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增项目
|
||||
/// </summary>
|
||||
/// <param name="project"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("create")]
|
||||
public async Task<AjaxResult> Create(GoviewProject project)
|
||||
{
|
||||
return await _app.Create(project);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除项目
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("delete")]
|
||||
public async Task<AjaxResult> DeleteProject(string ids)
|
||||
{
|
||||
return await _app.DeleteProject(ids);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改项目
|
||||
/// </summary>
|
||||
/// <param name="project"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("edit")]
|
||||
public async Task<AjaxResult> UpdateProject(GoviewProject project)
|
||||
{
|
||||
return await _app.UpdateProject(project);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取项目list集合
|
||||
/// </summary>
|
||||
/// <param name="page"></param>
|
||||
/// <param name="limit"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public async Task<ResultTable> List([FromQuery] GoViewProjectPage page)
|
||||
{
|
||||
return await _app.List(page);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改发布状态(发布,取消发布)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("publish")]
|
||||
public async Task<AjaxResult> Publish(GoViewProjectRequest req)
|
||||
{
|
||||
return await _app.Publish(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取项目数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getData")]
|
||||
public async Task<AjaxResult> GetData(string projectId)
|
||||
{
|
||||
return await _app.GetData(projectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存项目数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save/data")]
|
||||
public async Task<AjaxResult> SaveData(GoviewProjectData data)
|
||||
{
|
||||
return await _app.SaveData(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace OpenAuth.WebApi.Controllers.ServiceControllers.GoView
|
||||
{
|
||||
public class ProjectsController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ namespace OpenAuth.WebApi
|
|||
//UtilMethods.GetNativeSql(sql, pars);
|
||||
|
||||
//获取无参数化SQL 影响性能只适合调试
|
||||
//Console.WriteLine(UtilMethods.GetSqlString(DbType.PostgreSQL, sql, pars));
|
||||
Console.WriteLine(UtilMethods.GetSqlString(DbType.PostgreSQL, sql, pars));
|
||||
//Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
//LogHelper.LogInformation(sql + "\r\n" +db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
//Console.WriteLine();
|
||||
|
|
|
|||
Loading…
Reference in New Issue