完善登录页面
@@ -277,27 +277,27 @@
|
||||
文件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.#ctor(Yi.Framework.Interface.IUserService,Microsoft.Extensions.Hosting.IHostEnvironment)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.#ctor(Yi.Framework.Interface.IFileService,Microsoft.Extensions.Hosting.IHostEnvironment)">
|
||||
<summary>
|
||||
使用本地存储,未进行数据库记录
|
||||
文件上传下载
|
||||
</summary>
|
||||
<param name="iUserService"></param>
|
||||
<param name="iFileService"></param>
|
||||
<param name="env"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Get(System.String,System.String)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Get(System.Int64)">
|
||||
<summary>
|
||||
文件下载
|
||||
文件下载,只需用文件code即可
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<param name="fileName"></param>
|
||||
<param name="code"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Upload(System.String,Microsoft.AspNetCore.Http.IFormFile)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Upload(System.String,Microsoft.AspNetCore.Http.IFormFileCollection,System.String)">
|
||||
<summary>
|
||||
文件上传
|
||||
多文件上传,type可空,默认上传至File文件夹下,swagger返回雪花id精度是有问题的
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<param name="file"></param>
|
||||
<param name="type">文件类型,可空</param>
|
||||
<param name="file">多文件表单</param>
|
||||
<param name="remark">描述</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.LogController.Add">
|
||||
|
||||
@@ -2,15 +2,18 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.WebCore;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
@@ -22,40 +25,41 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
[ApiController]
|
||||
public class FileController : ControllerBase
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
private IFileService _iFileService;
|
||||
private readonly IHostEnvironment _env;
|
||||
|
||||
/// <summary>
|
||||
/// 使用本地存储,未进行数据库记录
|
||||
/// 文件上传下载
|
||||
/// </summary>
|
||||
/// <param name="iUserService"></param>
|
||||
/// <param name="iFileService"></param>
|
||||
/// <param name="env"></param>
|
||||
public FileController(IUserService iUserService, IHostEnvironment env)
|
||||
public FileController(IFileService iFileService, IHostEnvironment env)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
_iFileService = iFileService;
|
||||
_env = env;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件下载
|
||||
/// 文件下载,只需用文件code即可
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/file/{type}/{fileName}")]
|
||||
[Route("/api/file/{code}")]
|
||||
[HttpGet]
|
||||
public IActionResult Get(string type, string fileName)
|
||||
public async Task<IActionResult> Get(long code)
|
||||
{
|
||||
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type.ToLower());
|
||||
if (!Enum.IsDefined(typeof(PathEnum), type))
|
||||
var file = await _iFileService._repository.GetByIdAsync(code);
|
||||
if (file is null)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
try
|
||||
{
|
||||
var path = Path.Combine($"wwwroot/{type}", fileName);
|
||||
//路径为: 文件路径/文件id+文件扩展名
|
||||
var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString()+ Path.GetExtension(file.FileName));
|
||||
var stream = System.IO.File.OpenRead(path);
|
||||
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(fileName);
|
||||
return new FileStreamResult(stream, MimeType);
|
||||
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName);
|
||||
return File(stream, MimeType, file.FileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -64,28 +68,63 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件上传
|
||||
/// 多文件上传,type可空,默认上传至File文件夹下,swagger返回雪花id精度是有问题的
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="type">文件类型,可空</param>
|
||||
/// <param name="file">多文件表单</param>
|
||||
/// <param name="remark">描述</param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/Upload/{type}")]
|
||||
[Route("/api/file/Upload/{type?}")]
|
||||
[HttpPost]
|
||||
public async Task<Result> Upload(string type,IFormFile file)
|
||||
public async Task<Result> Upload([FromRoute] string? type, [FromForm] IFormFileCollection file,[FromQuery] string? remark)
|
||||
{
|
||||
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type.ToLower());
|
||||
if (!Enum.IsDefined(typeof(PathEnum), type))
|
||||
if (type is null)
|
||||
{
|
||||
return Result.Error("上传失败!文件类型不存在!");
|
||||
type = PathEnum.File.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type!.ToLower());
|
||||
if (!Enum.IsDefined(typeof(PathEnum), type))
|
||||
{
|
||||
//后续类型可从字典表中获取
|
||||
return Result.Error("上传失败!文件类型不支持!");
|
||||
}
|
||||
}
|
||||
|
||||
if (file.Count() == 0)
|
||||
{
|
||||
return Result.Error("未选择文件");
|
||||
}
|
||||
//批量插入
|
||||
List<FileEntity> datas = new();
|
||||
|
||||
//返回的codes
|
||||
List<long> codes = new();
|
||||
try
|
||||
{
|
||||
string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
|
||||
using (var stream = new FileStream(Path.Combine($"wwwroot/{type}", filename), FileMode.CreateNew, FileAccess.Write))
|
||||
foreach (var f in file)
|
||||
{
|
||||
await file.CopyToAsync(stream);
|
||||
FileEntity data = new();
|
||||
data.Id = SnowFlakeSingle.Instance.NextId();
|
||||
data.FileSize = ((decimal)f.Length) / 1024;
|
||||
data.FileName = f.FileName;
|
||||
data.FileType = Common.Helper.MimeHelper.GetMimeMapping(f.FileName);
|
||||
data.FilePath = type;
|
||||
data.Remark = remark;
|
||||
data.IsDeleted = false;
|
||||
|
||||
//落盘文件,文件名为雪花id+自己的扩展名
|
||||
string filename = data.Id.ToString() + Path.GetExtension(f.FileName);
|
||||
using (var stream = new FileStream(Path.Combine($"{PathConst.wwwroot}/{type}", filename), FileMode.CreateNew, FileAccess.Write))
|
||||
{
|
||||
await f.CopyToAsync(stream);
|
||||
}
|
||||
//将文件信息添加到数据库
|
||||
datas.Add(data);
|
||||
codes.Add(data.Id);
|
||||
}
|
||||
return Result.Success().SetData(filename);
|
||||
return Result.Success().SetData(codes).SetStatus(await _iFileService._repository.InsertRangeAsync(datas));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
|
After Width: | Height: | Size: 320 KiB |
@@ -0,0 +1,60 @@
|
||||
全套CI持续集成流程
|
||||
1、用户在cf-site前端文本框输入必要信息
|
||||
|
||||
2、cf-site前端调用git-cli接口
|
||||
|
||||
3、检测用户是否存在,如果不存在就创建git用户
|
||||
|
||||
4、创建对应仓库并附上对应组织关系
|
||||
|
||||
5、创建仓库附上dev,test,main等分支
|
||||
|
||||
6、给git用户附上对应权限
|
||||
|
||||
7、本地服务器git秘钥进行存储
|
||||
|
||||
8、 进入临时代码文件夹: cd 临时文件
|
||||
|
||||
9、克隆远程空仓库:git clone git@gitlab.hymson.com.cn:root/test1.git
|
||||
|
||||
10、进入仓库项目目录:cd 进入项目
|
||||
|
||||
11、选择分支:git switch -c dev
|
||||
|
||||
12、远程调用cf-cli脚手架将模板文件cli生成
|
||||
|
||||
13、解压模板文件并将文件以特定格式移动到特定位置
|
||||
|
||||
14、本地上载全部更新:git add .
|
||||
|
||||
15、添加上传描述:git commit -m "building"
|
||||
|
||||
16、更新远程仓库git push -u origin main
|
||||
|
||||
17、删除临时文件夹
|
||||
|
||||
18、返回前端仓库地址
|
||||
|
||||
全套CD持续部署流程
|
||||
1、密钥连接jenkins
|
||||
|
||||
2、远程调用cf-cli Job模板生文件
|
||||
|
||||
3、cf-cli 根据ci的流程返回的参数来Job生成模板
|
||||
|
||||
4、修改仓库url
|
||||
|
||||
5、修改job的name
|
||||
|
||||
6、修改job的启动项目文件
|
||||
|
||||
7、创建Cd jenkins job在对应视图中
|
||||
|
||||
8、上传特定job
|
||||
|
||||
9、触发job
|
||||
|
||||
10、浏览线上网址
|
||||
|
||||
|
||||
CI合并CD,最终返回 仓库地址+线上地址 、 Consul服务注册发现地址,确认服务存活状态
|
||||
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
@@ -0,0 +1,9 @@
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Interface
|
||||
{
|
||||
public partial interface IFileService:IBaseService<FileEntity>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SqlSugar;
|
||||
namespace Yi.Framework.Model.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件表
|
||||
///</summary>
|
||||
[SugarTable("File")]
|
||||
public partial class FileEntity:IBaseModelEntity
|
||||
{
|
||||
public FileEntity()
|
||||
{
|
||||
this.CreateTime = DateTime.Now;
|
||||
}
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(ColumnName="Id" ,IsPrimaryKey = true )]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 文件类型
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="FileType" )]
|
||||
public string FileType { get; set; }
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="FileSize" )]
|
||||
public decimal? FileSize { get; set; }
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="FileName" )]
|
||||
public string FileName { get; set; }
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="FilePath" )]
|
||||
public string FilePath { get; set; }
|
||||
/// <summary>
|
||||
/// 创建者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CreateUser" )]
|
||||
public long? CreateUser { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="CreateTime" )]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 修改者
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ModifyUser" )]
|
||||
public long? ModifyUser { get; set; }
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="ModifyTime" )]
|
||||
public DateTime? ModifyTime { get; set; }
|
||||
/// <summary>
|
||||
/// 是否删除
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="IsDeleted" )]
|
||||
public bool? IsDeleted { get; set; }
|
||||
/// <summary>
|
||||
/// 租户Id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="TenantId" )]
|
||||
public long? TenantId { get; set; }
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="OrderNum" )]
|
||||
public int? OrderNum { get; set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName="Remark" )]
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using SqlSugar;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
|
||||
namespace Yi.Framework.Service
|
||||
{
|
||||
public partial class FileService : BaseService<FileEntity>, IFileService
|
||||
{
|
||||
public FileService(IRepository<FileEntity> repository) : base(repository)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||