From 71e9a40c079c2349c063259fa45b8fa940ef4523 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Sun, 30 Jul 2023 16:37:08 +0800 Subject: [PATCH 01/59] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=93?= =?UTF-8?q?=E5=8C=85=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 25 +++++++++++++++++++++++++ NuGet.Config | 6 ++++++ README.md | 1 + UserPointManagement.sln | 7 +++++++ 4 files changed, 39 insertions(+) create mode 100644 Dockerfile create mode 100644 NuGet.Config create mode 100644 README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0ff610c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base + +WORKDIR /docker +EXPOSE 5000 + +FROM mcr.microsoft.co/dotnet/sdk:6.0 AS build +WORKDIR /build +COPY . . +RUN dotnet restore src/UserPointManagement.Web/UserPointManagement.Web.csproj --configfile ./NuGet.Config +WORKDIR src/UserPointManagement.Web +RUN dotnet build UserPointManagement.Web.csproj -c Release + +FROM build AS publish +RUN dotnet publish UserPointManagement.Web.csproj -c Release -o /app + +FROM base AS final +WORKDIR /app +COPY --from=publish /app . + +ENV ASPNETCORE_URLS http://*:5000 +ENV TZ Asia/Shanghai + +ENTRYPOINT ["dotnet", "UserPointManagement.Web.dll"] + + diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..19d85b7 --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..793a0ac --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +## 会员积分管理系统 \ No newline at end of file diff --git a/UserPointManagement.sln b/UserPointManagement.sln index 217ae76..e4409cd 100644 --- a/UserPointManagement.sln +++ b/UserPointManagement.sln @@ -18,6 +18,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserPointManagement.Persist EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserPointManagement.Application.Tests", "test\UserPointManagement.Application.Tests\UserPointManagement.Application.Tests.csproj", "{5770D3E5-9B3E-40FC-8209-62F0B4B45BD4}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{08F901D9-600A-4B4D-A942-AD2F61EDFE49}" + ProjectSection(SolutionItems) = preProject + Dockerfile = Dockerfile + README.md = README.md + NuGet.Config = NuGet.Config + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU From 0c2371be7e4aa6842c0b8b0106020e09cf294c8a Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sun, 30 Jul 2023 20:13:59 +0800 Subject: [PATCH 02/59] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DDockerfile?= =?UTF-8?q?=E5=8F=8A=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- src/UserPointManagement.Web/appsettings.Development.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ff610c..b141805 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /docker EXPOSE 5000 -FROM mcr.microsoft.co/dotnet/sdk:6.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /build COPY . . RUN dotnet restore src/UserPointManagement.Web/UserPointManagement.Web.csproj --configfile ./NuGet.Config diff --git a/src/UserPointManagement.Web/appsettings.Development.json b/src/UserPointManagement.Web/appsettings.Development.json index 3071d03..d816066 100644 --- a/src/UserPointManagement.Web/appsettings.Development.json +++ b/src/UserPointManagement.Web/appsettings.Development.json @@ -22,5 +22,6 @@ "MenuRender": true, "MenuHeaderRender": true, "HeaderHeight": 48 - } + }, + "Connection:UserPointManagement": "Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo_dev;" } From f2deb6ccd86a7313b627510e3bf1abe640f98726 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Sun, 30 Jul 2023 20:23:08 +0800 Subject: [PATCH 03/59] =?UTF-8?q?feat:=20=E5=BC=80=E5=8F=91=E8=B7=9F?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserPointManagementDbContextFactory.cs | 2 +- src/UserPointManagement.Web/Program.cs | 11 ++++++++++- .../appsettings.Development.json | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs b/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs index 6edfa7e..9853b76 100644 --- a/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs +++ b/src/UserPointManagement.Persistence/UserPointManagementDbContextFactory.cs @@ -10,7 +10,7 @@ public class UserPointManagementDbContextFactory : IDesignTimeDbContextFactory(); optionsBuilder - .UseNpgsql("Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo;") + .UseNpgsql("Server=67.230.184.225;Port=58007;UserId=postgres;Password=postgres;Database=tiamo_dev;") .UseSnakeCaseNamingConvention(); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); diff --git a/src/UserPointManagement.Web/Program.cs b/src/UserPointManagement.Web/Program.cs index 4851bec..9f39bce 100644 --- a/src/UserPointManagement.Web/Program.cs +++ b/src/UserPointManagement.Web/Program.cs @@ -5,9 +5,12 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using UserPointManagement.Persistence; namespace UserPointManagement.Web { @@ -15,7 +18,13 @@ namespace UserPointManagement.Web { public static void Main(string[] args) { - CreateHostBuilder(args).Build().Run(); + var host = CreateHostBuilder(args).Build(); + using (var serviceScope = host.Services.CreateScope()) + { + var context = serviceScope.ServiceProvider.GetRequiredService(); + context.Database.Migrate(); + } + host.Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => diff --git a/src/UserPointManagement.Web/appsettings.Development.json b/src/UserPointManagement.Web/appsettings.Development.json index d816066..253486c 100644 --- a/src/UserPointManagement.Web/appsettings.Development.json +++ b/src/UserPointManagement.Web/appsettings.Development.json @@ -4,7 +4,8 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information" + "Microsoft.Hosting.Lifetime": "Information", + "Microsoft.EntityFrameworkCore.Database": "Information" } }, "ProSettings": { From a2dece29c888db8d65232463ae6e603c8af01c76 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sun, 30 Jul 2023 21:29:05 +0800 Subject: [PATCH 04/59] =?UTF-8?q?feat:=20=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E5=BF=85=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UserPointManagement.Application/Services/UserService.cs | 2 +- .../Pages/UserManagement/UserManagement.razor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UserPointManagement.Application/Services/UserService.cs b/src/UserPointManagement.Application/Services/UserService.cs index b7978ba..00b86a6 100644 --- a/src/UserPointManagement.Application/Services/UserService.cs +++ b/src/UserPointManagement.Application/Services/UserService.cs @@ -63,7 +63,7 @@ public class UserService : IUserService public async Task CreateUser(User input) { await using var _userPointManagementDbContext = await _dbContextFactory.CreateDbContextAsync(); - if (_userPointManagementDbContext.Users.Any(x => x.Mobile == input.Mobile)) + if (!string.IsNullOrWhiteSpace(input.Mobile) && _userPointManagementDbContext.Users.Any(x => x.Mobile == input.Mobile)) { throw new ArgumentException("手机号不可重复!"); } diff --git a/src/UserPointManagement.Web/Pages/UserManagement/UserManagement.razor b/src/UserPointManagement.Web/Pages/UserManagement/UserManagement.razor index 6ffe8c1..cb41f0f 100644 --- a/src/UserPointManagement.Web/Pages/UserManagement/UserManagement.razor +++ b/src/UserPointManagement.Web/Pages/UserManagement/UserManagement.razor @@ -92,7 +92,7 @@ - + From a2ad57e066502eef297defef5b52b2b476d25e95 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sun, 30 Jul 2023 21:41:49 +0800 Subject: [PATCH 05/59] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E4=B8=AD=E6=89=8B=E6=9C=BA=E5=8F=B7=E5=8F=AF=E4=BB=A5=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/User.cs | 2 +- .../20230730134035_ModifyUser.Designer.cs | 89 +++++++++++++++++++ .../Migrations/20230730134035_ModifyUser.cs | 41 +++++++++ ...erPointManagementDbContextModelSnapshot.cs | 1 - 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs create mode 100644 src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs diff --git a/src/UserPointManagement.Model/Entities/User.cs b/src/UserPointManagement.Model/Entities/User.cs index ca12ba6..6336605 100644 --- a/src/UserPointManagement.Model/Entities/User.cs +++ b/src/UserPointManagement.Model/Entities/User.cs @@ -6,5 +6,5 @@ public class User public string Name { get; set; } - public string Mobile { get; set; } + public string? Mobile { get; set; } } \ No newline at end of file diff --git a/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs new file mode 100644 index 0000000..2721dee --- /dev/null +++ b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.Designer.cs @@ -0,0 +1,89 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using UserPointManagement.Persistence; + +#nullable disable + +namespace UserPointManagement.Persistence.Migrations +{ + [DbContext(typeof(UserPointManagementDbContext))] + [Migration("20230730134035_ModifyUser")] + partial class ModifyUser + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("UserPointManagement.Model.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id") + .HasComment("主键"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Mobile") + .HasMaxLength(30) + .HasColumnType("character varying(30)") + .HasColumnName("mobile") + .HasComment("手机号"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("name") + .HasComment("姓名"); + + b.HasKey("Id") + .HasName("pk_user"); + + b.ToTable("user", (string)null); + }); + + modelBuilder.Entity("UserPointManagement.Model.Entities.UserPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id") + .HasComment("主键"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreateTime") + .HasColumnType("timestamp without time zone") + .HasColumnName("create_time") + .HasComment("新增时间"); + + b.Property("Point") + .HasColumnType("integer") + .HasColumnName("point") + .HasComment("积分"); + + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id") + .HasComment("用户Id"); + + b.HasKey("Id") + .HasName("pk_user_point"); + + b.ToTable("user_point", (string)null); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs new file mode 100644 index 0000000..89f6326 --- /dev/null +++ b/src/UserPointManagement.Persistence/Migrations/20230730134035_ModifyUser.cs @@ -0,0 +1,41 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace UserPointManagement.Persistence.Migrations +{ + public partial class ModifyUser : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "mobile", + table: "user", + type: "character varying(30)", + maxLength: 30, + nullable: true, + comment: "手机号", + oldClrType: typeof(string), + oldType: "character varying(30)", + oldMaxLength: 30, + oldComment: "手机号"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "mobile", + table: "user", + type: "character varying(30)", + maxLength: 30, + nullable: false, + defaultValue: "", + comment: "手机号", + oldClrType: typeof(string), + oldType: "character varying(30)", + oldMaxLength: 30, + oldNullable: true, + oldComment: "手机号"); + } + } +} diff --git a/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs b/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs index ff15431..d3f4674 100644 --- a/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs +++ b/src/UserPointManagement.Persistence/Migrations/UserPointManagementDbContextModelSnapshot.cs @@ -33,7 +33,6 @@ namespace UserPointManagement.Persistence.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Mobile") - .IsRequired() .HasMaxLength(30) .HasColumnType("character varying(30)") .HasColumnName("mobile") From 8d75ec84e06b88027d5ad6aa49b2b150c1147ca4 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Wed, 2 Aug 2023 23:08:16 +0800 Subject: [PATCH 06/59] =?UTF-8?q?feat:=20=E6=B5=8B=E8=AF=95CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 8 ++++++++ UserPointManagement.sln | 1 + 2 files changed, 9 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..646918f --- /dev/null +++ b/.drone.yml @@ -0,0 +1,8 @@ +kind: pipeline # 定义一个管道 +type: docker # 当前管道的类型 +name: test # 当前管道的名称 +steps: # 定义管道的执行步骤 + - name: test # 步骤名称 + image: node:latest # 当前步骤使用的镜像 + commands: # 当前步骤执行的命令 + - echo 测试drone执行 \ No newline at end of file diff --git a/UserPointManagement.sln b/UserPointManagement.sln index e4409cd..e893d5d 100644 --- a/UserPointManagement.sln +++ b/UserPointManagement.sln @@ -23,6 +23,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Dockerfile = Dockerfile README.md = README.md NuGet.Config = NuGet.Config + .drone.yml = .drone.yml EndProjectSection EndProject Global From 9376c4b14ea8f3cf3d2687f17998501648dac67c Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 17:33:47 +0800 Subject: [PATCH 07/59] =?UTF-8?q?feat(CI):=20=E6=B5=8B=E8=AF=95=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=88=B0Nexus3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 32 ++++++++++++++----- .../Services/UserService.cs | 6 ++-- .../UserConfiguration.cs | 4 +-- .../UserPointManagementDbContext.cs | 4 +-- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/.drone.yml b/.drone.yml index 646918f..6a339bb 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,8 +1,24 @@ -kind: pipeline # 定义一个管道 -type: docker # 当前管道的类型 -name: test # 当前管道的名称 -steps: # 定义管道的执行步骤 - - name: test # 步骤名称 - image: node:latest # 当前步骤使用的镜像 - commands: # 当前步骤执行的命令 - - echo 测试drone执行 \ No newline at end of file +kind: pipeline +type: docker +name: deployment +steps: + - name: check + image: alpine + commands: + - ls -la + - ls -la Dockerfile --查看当前文件夹是否包含了Dockerfile + - name: publish + image: plugins/docker + settings: + dockerfile: Dockerfile + tags: latest + # you need insecure: true since we don't have a TLS certificate + insecure: true + registry: 192.168.31.104:8082 + repo: 192.168.31.104:8082/tiamo/user-point-management + # create the docker_username and docker_password secrets in Drone, with Nexus' username & password + secrets: [ drone, dronepw ] + +#trigger: +# branch: +# - master \ No newline at end of file diff --git a/src/UserPointManagement.Application/Services/UserService.cs b/src/UserPointManagement.Application/Services/UserService.cs index 00b86a6..46b4921 100644 --- a/src/UserPointManagement.Application/Services/UserService.cs +++ b/src/UserPointManagement.Application/Services/UserService.cs @@ -37,7 +37,7 @@ public class UserService : IUserService queryable = queryable.Where(x => x.Mobile.Contains(req.Keyword) || x.Name.Contains(req.Keyword), !string.IsNullOrEmpty(req.Keyword)); - + var count = queryable.Count(); var data = await queryable.OrderByDescending(x => x.Id).Paging(req).ToListAsync().ConfigureAwait(false); @@ -63,7 +63,8 @@ public class UserService : IUserService public async Task CreateUser(User input) { await using var _userPointManagementDbContext = await _dbContextFactory.CreateDbContextAsync(); - if (!string.IsNullOrWhiteSpace(input.Mobile) && _userPointManagementDbContext.Users.Any(x => x.Mobile == input.Mobile)) + if (!string.IsNullOrWhiteSpace(input.Mobile) && + _userPointManagementDbContext.Users.Any(x => x.Mobile == input.Mobile)) { throw new ArgumentException("手机号不可重复!"); } @@ -72,6 +73,7 @@ public class UserService : IUserService { throw new ArgumentException("名称不可重复!"); } + _userPointManagementDbContext.Users.Add(input); await _userPointManagementDbContext.SaveChangesAsync().ConfigureAwait(false); } diff --git a/src/UserPointManagement.Persistence/EntityTypeConfigurations/UserConfiguration.cs b/src/UserPointManagement.Persistence/EntityTypeConfigurations/UserConfiguration.cs index 473ad28..31329a3 100644 --- a/src/UserPointManagement.Persistence/EntityTypeConfigurations/UserConfiguration.cs +++ b/src/UserPointManagement.Persistence/EntityTypeConfigurations/UserConfiguration.cs @@ -9,10 +9,10 @@ public class UserConfiguration : IEntityTypeConfiguration public void Configure(EntityTypeBuilder builder) { builder.HasKey(e => e.Id); - + builder.Property(e => e.Id) .HasComment("主键"); - + builder.Property(e => e.Name) .HasComment("姓名") .HasMaxLength(50); diff --git a/src/UserPointManagement.Persistence/UserPointManagementDbContext.cs b/src/UserPointManagement.Persistence/UserPointManagementDbContext.cs index 7b7d34b..1ea298f 100644 --- a/src/UserPointManagement.Persistence/UserPointManagementDbContext.cs +++ b/src/UserPointManagement.Persistence/UserPointManagementDbContext.cs @@ -9,9 +9,9 @@ public class UserPointManagementDbContext : Microsoft.EntityFrameworkCore.DbCont public UserPointManagementDbContext(DbContextOptions options) : base(options) { } - + public virtual DbSet Users { get; set; } - + public virtual DbSet UserPoints { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) From 582d45fbfaaa537fadea5559b41d332f6082f2f9 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 17:44:20 +0800 Subject: [PATCH 08/59] =?UTF-8?q?fix(CI):=20=E4=BF=AE=E5=A4=8D=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=88=A4=E6=96=ADDockerfile=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6a339bb..09054cd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,8 +5,8 @@ steps: - name: check image: alpine commands: - - ls -la - - ls -la Dockerfile --查看当前文件夹是否包含了Dockerfile + - ls -la + - ls -la Dockerfile # 查看当前文件夹是否包含了Dockerfile - name: publish image: plugins/docker settings: From d3525884e80d52273f5d082af0ded69130441fc5 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 18:33:34 +0800 Subject: [PATCH 09/59] =?UTF-8?q?feat(CI):=20=E6=B7=BB=E5=8A=A0=E4=B8=8D?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E5=88=99=E6=8B=89=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 09054cd..df49543 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,6 +10,7 @@ steps: - name: publish image: plugins/docker settings: + pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 dockerfile: Dockerfile tags: latest # you need insecure: true since we don't have a TLS certificate From d0c1e6896ec1d02a992a3e9cdcbca6abb55be603 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 18:39:13 +0800 Subject: [PATCH 10/59] =?UTF-8?q?fix(CI):=20=E6=8B=89=E5=8F=96=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index df49543..3666130 100644 --- a/.drone.yml +++ b/.drone.yml @@ -19,6 +19,7 @@ steps: repo: 192.168.31.104:8082/tiamo/user-point-management # create the docker_username and docker_password secrets in Drone, with Nexus' username & password secrets: [ drone, dronepw ] + storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs #trigger: # branch: From 61a694c3b4eafe5fe8e598f714c3a31edf1861e5 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 18:54:31 +0800 Subject: [PATCH 11/59] =?UTF-8?q?fix(CI):=20=E6=B7=BB=E5=8A=A0=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E6=BA=90=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NuGet.Config | 1 + 1 file changed, 1 insertion(+) diff --git a/NuGet.Config b/NuGet.Config index 19d85b7..a728892 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,5 +2,6 @@ + From 6b33f4fa60d6e31748dfa5bd06a2da76a7c02adb Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 20:35:53 +0800 Subject: [PATCH 12/59] =?UTF-8?q?fix(CI):=20=E6=B7=BB=E5=8A=A0docker=20bui?= =?UTF-8?q?ld=E7=BC=96=E8=AF=91=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 3666130..9d90b31 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,6 +20,7 @@ steps: # create the docker_username and docker_password secrets in Drone, with Nexus' username & password secrets: [ drone, dronepw ] storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs + build_args: --network=host #trigger: # branch: From 451dd07501aa632448d03f671b2bd738e4f65423 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 20:43:24 +0800 Subject: [PATCH 13/59] =?UTF-8?q?fix(CI):=20=E6=B7=BB=E5=8A=A0dns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 9d90b31..14b0ec2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,6 +21,7 @@ steps: secrets: [ drone, dronepw ] storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs build_args: --network=host + custom_dns: 8.8.8.8 #trigger: # branch: From edf7a9a0248d0f571b6cdcd56d62db17c31689b7 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 20:55:44 +0800 Subject: [PATCH 14/59] =?UTF-8?q?fix(CI):=20=E5=B0=9D=E8=AF=95=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 14b0ec2..35b6a67 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,7 @@ steps: # create the docker_username and docker_password secrets in Drone, with Nexus' username & password secrets: [ drone, dronepw ] storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs - build_args: --network=host + build_args: --build-arg HTTP_PROXY=http://192.168.31.254:7890 --build-arg HTTPS_PROXY=http://192.168.31.254:7890 custom_dns: 8.8.8.8 #trigger: From 7173c9e093ebe91b5a6c94b73bb9abcbe7e28892 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 21:02:59 +0800 Subject: [PATCH 15/59] =?UTF-8?q?fix(CI):=20=E8=B0=83=E6=95=B4build=5Fargs?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 35b6a67..1baf964 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,7 +20,9 @@ steps: # create the docker_username and docker_password secrets in Drone, with Nexus' username & password secrets: [ drone, dronepw ] storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs - build_args: --build-arg HTTP_PROXY=http://192.168.31.254:7890 --build-arg HTTPS_PROXY=http://192.168.31.254:7890 + build_args: + HTTP_PROXY=http://192.168.31.254:7890 + HTTPS_PROXY=http://192.168.31.254:7890 custom_dns: 8.8.8.8 #trigger: From 5402ce1d34227799d05af02c9f44ad6e596a1971 Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 21:13:53 +0800 Subject: [PATCH 16/59] =?UTF-8?q?fix(CI):=20=E5=B0=9D=E8=AF=95=E6=8C=82=20?= =?UTF-8?q?docker.sock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.drone.yml b/.drone.yml index 1baf964..fea9047 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,10 @@ kind: pipeline type: docker name: deployment +volumes: + - name: dockersock + host: + path: /var/run/docker.sock steps: - name: check image: alpine @@ -24,6 +28,9 @@ steps: HTTP_PROXY=http://192.168.31.254:7890 HTTPS_PROXY=http://192.168.31.254:7890 custom_dns: 8.8.8.8 + volumes: + - name: dockersock + path: /var/run/docker.sock #trigger: # branch: From a54e88f9d7396876294490fd7eee6bab30cd6c2c Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sat, 5 Aug 2023 21:19:16 +0800 Subject: [PATCH 17/59] =?UTF-8?q?fix(CI):=20=E7=A7=BB=E9=99=A4build=5Fargs?= =?UTF-8?q?=E5=8F=8Acustom=5Fdns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index fea9047..4f6c45f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -24,10 +24,6 @@ steps: # create the docker_username and docker_password secrets in Drone, with Nexus' username & password secrets: [ drone, dronepw ] storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs - build_args: - HTTP_PROXY=http://192.168.31.254:7890 - HTTPS_PROXY=http://192.168.31.254:7890 - custom_dns: 8.8.8.8 volumes: - name: dockersock path: /var/run/docker.sock From e2526d33d095f5f1faec5735e487c2d80aa25d7b Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sun, 6 Aug 2023 00:03:59 +0800 Subject: [PATCH 18/59] =?UTF-8?q?fix(CI):=20=E4=BF=AE=E6=94=B9=E5=B8=90?= =?UTF-8?q?=E5=8F=B7=E5=AF=86=E7=A0=81=E7=99=BB=E5=85=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4f6c45f..5d91f72 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,6 +14,8 @@ steps: - name: publish image: plugins/docker settings: + username: drone + password: dronepw pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 dockerfile: Dockerfile tags: latest @@ -21,8 +23,6 @@ steps: insecure: true registry: 192.168.31.104:8082 repo: 192.168.31.104:8082/tiamo/user-point-management - # create the docker_username and docker_password secrets in Drone, with Nexus' username & password - secrets: [ drone, dronepw ] storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs volumes: - name: dockersock From 3d7fb11a135d4d62df8b7f634f0d3622d0d1a20b Mon Sep 17 00:00:00 2001 From: Yosheng Date: Sun, 6 Aug 2023 00:09:00 +0800 Subject: [PATCH 19/59] =?UTF-8?q?fix(CI):=20=E5=B0=9D=E8=AF=95=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=20storage=5Fdriver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 5d91f72..f74524d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -23,7 +23,6 @@ steps: insecure: true registry: 192.168.31.104:8082 repo: 192.168.31.104:8082/tiamo/user-point-management - storage_driver: vfs #解决群晖btrfs,而docker内用的是vfs volumes: - name: dockersock path: /var/run/docker.sock From e78afba285a0c32381b51c7e7644b7886dac560c Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Sun, 6 Aug 2023 08:29:54 +0800 Subject: [PATCH 20/59] =?UTF-8?q?feat(CI):=20=E6=B7=BB=E5=8A=A0=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E5=8F=82=E6=95=B0=E5=8F=8A=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.drone.yml b/.drone.yml index f74524d..741b132 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,13 +9,15 @@ steps: - name: check image: alpine commands: - - ls -la + - ls -la - ls -la Dockerfile # 查看当前文件夹是否包含了Dockerfile - name: publish image: plugins/docker settings: - username: drone - password: dronepw + username: + from_secret: nexus_username + password: + from_secret: nexus_password pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 dockerfile: Dockerfile tags: latest @@ -26,7 +28,32 @@ steps: volumes: - name: dockersock path: /var/run/docker.sock - + - name: deploy + image: appleboy/drone-ssh + settings: + host: 192.168.31.104 + port: 22 + username: + from_secret: deploy_username + password: + from_secret: deploy_password + command_timeout: 2m + script: + - source /etc/profile + - ls -la + - docker info + - echo $(docker ps -aqf "name=user-point-management") + - docker stop $(docker ps -aqf "name=user-point-management") + - docker rm $(docker ps -aqf "name=user-point-management") + - docker rmi tiamo/user-point-management + - echo 查看是否成功删除tiamo + - docker ps -a + - echo 从harbor拉取docker镜像 + - sudo docker pull 192.168.31.104:8082/tiamo/user-point-management + - sudo docker tag 192.168.31.104:8082/tiamo/user-point-management tiamo/user-point-management:latest + - sudo docker run --name user-point-management -d -p 29029:5000 tiamo/user-point-management + - /usr/local/bin/docker system prune -f + - echo docker容器启动成功 #trigger: # branch: # - master \ No newline at end of file From 3fb73e4c148aa3484ccc3563d1659d186d1c94aa Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 09:21:01 +0800 Subject: [PATCH 21/59] =?UTF-8?q?fix(CI):=20=E5=B0=9D=E8=AF=95=E6=98=8E?= =?UTF-8?q?=E7=A1=AE=E6=8C=87=E5=AE=9Assh=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 741b132..178f656 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,7 +29,7 @@ steps: - name: dockersock path: /var/run/docker.sock - name: deploy - image: appleboy/drone-ssh + image: appleboy/drone-ssh:latest settings: host: 192.168.31.104 port: 22 From 18b8597876d5242887f9e9535faab9794676426b Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 09:35:04 +0800 Subject: [PATCH 22/59] =?UTF-8?q?fix(CI):=20=E6=B7=BB=E5=8A=A0drone-ssh?= =?UTF-8?q?=E4=BD=BF=E7=94=A8dockersock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 178f656..7f60fcd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -29,7 +29,7 @@ steps: - name: dockersock path: /var/run/docker.sock - name: deploy - image: appleboy/drone-ssh:latest + image: appleboy/drone-ssh settings: host: 192.168.31.104 port: 22 @@ -54,6 +54,10 @@ steps: - sudo docker run --name user-point-management -d -p 29029:5000 tiamo/user-point-management - /usr/local/bin/docker system prune -f - echo docker容器启动成功 + volumes: + - name: dockersock + path: /var/run/docker.sock + #trigger: # branch: # - master \ No newline at end of file From 93f213aaed00d2b9646c72cc63c22b09a5bc4202 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 09:49:05 +0800 Subject: [PATCH 23/59] =?UTF-8?q?fix(CI):=20=E8=B0=83=E6=95=B4CI=E9=95=9C?= =?UTF-8?q?=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.drone.yml b/.drone.yml index 7f60fcd..76de6b9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,25 +11,25 @@ steps: commands: - ls -la - ls -la Dockerfile # 查看当前文件夹是否包含了Dockerfile - - name: publish - image: plugins/docker - settings: - username: - from_secret: nexus_username - password: - from_secret: nexus_password - pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 - dockerfile: Dockerfile - tags: latest - # you need insecure: true since we don't have a TLS certificate - insecure: true - registry: 192.168.31.104:8082 - repo: 192.168.31.104:8082/tiamo/user-point-management - volumes: - - name: dockersock - path: /var/run/docker.sock +# - name: publish +# image: plugins/docker +# settings: +# username: +# from_secret: nexus_username +# password: +# from_secret: nexus_password +# pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 +# dockerfile: Dockerfile +# tags: latest +# # you need insecure: true since we don't have a TLS certificate +# insecure: true +# registry: 192.168.31.104:8082 +# repo: 192.168.31.104:8082/tiamo/user-point-management +# volumes: +# - name: dockersock +# path: /var/run/docker.sock - name: deploy - image: appleboy/drone-ssh + image: ghcr.io/appleboy/drone-ssh settings: host: 192.168.31.104 port: 22 From 53d47367b71b985d7aa684f8ec5621380dedf1eb Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 10:03:00 +0800 Subject: [PATCH 24/59] =?UTF-8?q?fix(CI):=20=E8=B0=83=E6=95=B4drone-ssh?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 76de6b9..78feed4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,10 +1,7 @@ kind: pipeline type: docker name: deployment -volumes: - - name: dockersock - host: - path: /var/run/docker.sock + steps: - name: check image: alpine @@ -29,7 +26,8 @@ steps: # - name: dockersock # path: /var/run/docker.sock - name: deploy - image: ghcr.io/appleboy/drone-ssh + pull: if-not-exists + image: appleboy/drone-ssh settings: host: 192.168.31.104 port: 22 @@ -58,6 +56,11 @@ steps: - name: dockersock path: /var/run/docker.sock +volumes: + - name: dockersock + host: + path: /var/run/docker.sock + #trigger: # branch: # - master \ No newline at end of file From 1069c603d913016774e463876a0eecb364f4e45b Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 10:05:43 +0800 Subject: [PATCH 25/59] =?UTF-8?q?fix(CI):=20=E8=B0=83=E6=95=B4drone-ssh?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=8E=E7=A1=AE=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 78feed4..978220c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,7 +27,7 @@ steps: # path: /var/run/docker.sock - name: deploy pull: if-not-exists - image: appleboy/drone-ssh + image: appleboy/drone-ssh:1.7.0 settings: host: 192.168.31.104 port: 22 From 0cb6db86227a0b589b210e9d5e00846504c40dbe Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 10:13:05 +0800 Subject: [PATCH 26/59] =?UTF-8?q?fix(CI):=20=E8=B0=83=E6=95=B4drone-ssh?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/.drone.yml b/.drone.yml index 978220c..dead787 100644 --- a/.drone.yml +++ b/.drone.yml @@ -27,34 +27,31 @@ steps: # path: /var/run/docker.sock - name: deploy pull: if-not-exists - image: appleboy/drone-ssh:1.7.0 - settings: - host: 192.168.31.104 - port: 22 - username: - from_secret: deploy_username - password: - from_secret: deploy_password - command_timeout: 2m - script: - - source /etc/profile - - ls -la - - docker info - - echo $(docker ps -aqf "name=user-point-management") - - docker stop $(docker ps -aqf "name=user-point-management") - - docker rm $(docker ps -aqf "name=user-point-management") - - docker rmi tiamo/user-point-management - - echo 查看是否成功删除tiamo - - docker ps -a - - echo 从harbor拉取docker镜像 - - sudo docker pull 192.168.31.104:8082/tiamo/user-point-management - - sudo docker tag 192.168.31.104:8082/tiamo/user-point-management tiamo/user-point-management:latest - - sudo docker run --name user-point-management -d -p 29029:5000 tiamo/user-point-management - - /usr/local/bin/docker system prune -f - - echo docker容器启动成功 - volumes: - - name: dockersock - path: /var/run/docker.sock + image: appleboy/drone-ssh +# settings: +# host: 192.168.31.104 +# port: 22 +# username: +# from_secret: deploy_username +# password: +# from_secret: deploy_password +# command_timeout: 2m +# script: +# - source /etc/profile +# - ls -la +# - docker info +# - echo $(docker ps -aqf "name=user-point-management") +# - docker stop $(docker ps -aqf "name=user-point-management") +# - docker rm $(docker ps -aqf "name=user-point-management") +# - docker rmi tiamo/user-point-management +# - echo 查看是否成功删除tiamo +# - docker ps -a +# - echo 从harbor拉取docker镜像 +# - sudo docker pull 192.168.31.104:8082/tiamo/user-point-management +# - sudo docker tag 192.168.31.104:8082/tiamo/user-point-management tiamo/user-point-management:latest +# - sudo docker run --name user-point-management -d -p 29029:5000 tiamo/user-point-management +# - /usr/local/bin/docker system prune -f +# - echo docker容器启动成功 volumes: - name: dockersock From a0b1bb7aceb63237951c72e329eee7da1f9316c9 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 14 Aug 2023 10:17:38 +0800 Subject: [PATCH 27/59] =?UTF-8?q?fix(CI):=20=E8=B0=83=E6=95=B4drone-ssh?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AE=98=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.drone.yml b/.drone.yml index dead787..276b5c0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,6 +28,17 @@ steps: - name: deploy pull: if-not-exists image: appleboy/drone-ssh + settings: + host: + - example1.com + - example2.com + username: ubuntu + password: + from_secret: ssh_password + port: 22 + command_timeout: 2m + script: + - echo "Hello World" # settings: # host: 192.168.31.104 # port: 22 From bb1a33824cb2f39837465a041a5f199d46621b1e Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Wed, 23 Aug 2023 20:39:44 +0800 Subject: [PATCH 28/59] =?UTF-8?q?fix(CI):=20=E4=BF=AE=E6=94=B9=E5=8F=AA?= =?UTF-8?q?=E6=9C=89master=E5=8F=AF=E4=BB=A5=E8=A7=A6=E5=8F=91=E5=B9=B6?= =?UTF-8?q?=E6=B3=A8=E9=87=8Adeploy=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 53 +++++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 32 deletions(-) diff --git a/.drone.yml b/.drone.yml index 276b5c0..9bce1f3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,37 +8,26 @@ steps: commands: - ls -la - ls -la Dockerfile # 查看当前文件夹是否包含了Dockerfile -# - name: publish -# image: plugins/docker -# settings: -# username: -# from_secret: nexus_username -# password: -# from_secret: nexus_password -# pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 -# dockerfile: Dockerfile -# tags: latest -# # you need insecure: true since we don't have a TLS certificate -# insecure: true -# registry: 192.168.31.104:8082 -# repo: 192.168.31.104:8082/tiamo/user-point-management -# volumes: -# - name: dockersock -# path: /var/run/docker.sock - - name: deploy - pull: if-not-exists - image: appleboy/drone-ssh + - name: publish + image: plugins/docker settings: - host: - - example1.com - - example2.com - username: ubuntu + username: + from_secret: nexus_username password: - from_secret: ssh_password - port: 22 - command_timeout: 2m - script: - - echo "Hello World" + from_secret: nexus_password + pull: if-not-exists # 如果镜像不存在则拉取,免去每次都要重新下载 + dockerfile: Dockerfile + tags: latest + # you need insecure: true since we don't have a TLS certificate + insecure: true + registry: 192.168.31.104:8082 + repo: 192.168.31.104:8082/tiamo/user-point-management + volumes: + - name: dockersock + path: /var/run/docker.sock +# - name: deploy +# pull: if-not-exists +# image: appleboy/drone-ssh # settings: # host: 192.168.31.104 # port: 22 @@ -69,6 +58,6 @@ volumes: host: path: /var/run/docker.sock -#trigger: -# branch: -# - master \ No newline at end of file +trigger: + branch: + - master \ No newline at end of file From ab9cd9f5b55f77b5f904a2f894147baafd3f0e25 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Thu, 24 Aug 2023 10:07:44 +0800 Subject: [PATCH 29/59] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0API=20Controlle?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/UserController.cs | 31 +++++++++++++++++++ src/UserPointManagement.Web/Startup.cs | 29 ++++++++++++++++- .../UserPointManagement.Web.csproj | 1 + 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 src/UserPointManagement.Web/Controllers/UserController.cs diff --git a/src/UserPointManagement.Web/Controllers/UserController.cs b/src/UserPointManagement.Web/Controllers/UserController.cs new file mode 100644 index 0000000..3d37dab --- /dev/null +++ b/src/UserPointManagement.Web/Controllers/UserController.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using UserPointManagement.Application.Services; +using UserPointManagement.Model; +using UserPointManagement.Model.Dtos.User; +using UserPointManagement.Model.Entities; + +namespace UserPointManagement.Web.Controllers; + +[ApiController] +[Route("api/[controller]")] +public class UserController : ControllerBase +{ + private readonly IUserService _userService; + + public UserController(IUserService userService) + { + _userService = userService; + } + + /// + /// 获取用户 + /// + /// + /// + [HttpGet] + public async Task> GetUsers([FromQuery]GetUserDto req) + { + return await _userService.GetUsers(req).ConfigureAwait(false); + } +} \ No newline at end of file diff --git a/src/UserPointManagement.Web/Startup.cs b/src/UserPointManagement.Web/Startup.cs index 4271cda..c614071 100644 --- a/src/UserPointManagement.Web/Startup.cs +++ b/src/UserPointManagement.Web/Startup.cs @@ -1,4 +1,6 @@ using System; +using System.IO; +using System.Linq; using System.Net.Http; using AntDesign.ProLayout; using Microsoft.AspNetCore.Builder; @@ -26,6 +28,19 @@ namespace UserPointManagement.Web // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { + services.AddControllers(options => + { + }); + services.AddEndpointsApiExplorer(); + services.AddSwaggerGen(options => + { + Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.xml").ToList().ForEach(file => + { + options.IncludeXmlComments(file, true); + }); + }); + services.AddRouting(options => options.LowercaseUrls = true); + services.AddRazorPages(); services.AddServerSideBlazor(); services.AddAntDesign(); @@ -46,6 +61,7 @@ namespace UserPointManagement.Web AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -54,6 +70,16 @@ namespace UserPointManagement.Web if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseSwagger(o => + { + // o.RouteTemplate = $"/api/swagger/{{documentName}}/swagger.json"; + }); + app.UseSwaggerUI(c => + { + // c.RoutePrefix = $"/api/swagger"; + // c.SwaggerEndpoint($"/api/swagger/v1/swagger.json", + // "UserPointManagement.Api API V1"); + }); } else { @@ -66,9 +92,10 @@ namespace UserPointManagement.Web app.UseStaticFiles(); app.UseRouting(); - + app.UseEndpoints(endpoints => { + endpoints.MapControllers(); endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); diff --git a/src/UserPointManagement.Web/UserPointManagement.Web.csproj b/src/UserPointManagement.Web/UserPointManagement.Web.csproj index 92e8682..4b31866 100644 --- a/src/UserPointManagement.Web/UserPointManagement.Web.csproj +++ b/src/UserPointManagement.Web/UserPointManagement.Web.csproj @@ -9,6 +9,7 @@ + From 32ea7191ee6d37ebc709477b66ece449057147dc Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Sun, 27 Aug 2023 17:36:10 +0800 Subject: [PATCH 30/59] =?UTF-8?q?feat:=20Controller=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0api=E8=B7=AF=E7=94=B1=E5=89=8D=E5=9D=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/User/GetUserDto.cs | 2 +- .../Controllers/UserController.cs | 2 +- .../MvcOptionsExtensions.cs | 45 +++++++++++++++++++ src/UserPointManagement.Web/Startup.cs | 3 +- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/UserPointManagement.Web/MvcOptionsExtensions.cs diff --git a/src/UserPointManagement.Model/Dtos/User/GetUserDto.cs b/src/UserPointManagement.Model/Dtos/User/GetUserDto.cs index f263408..b0c866c 100644 --- a/src/UserPointManagement.Model/Dtos/User/GetUserDto.cs +++ b/src/UserPointManagement.Model/Dtos/User/GetUserDto.cs @@ -2,5 +2,5 @@ public class GetUserDto : PageBase { - public string Keyword { get; set; } + public string? Keyword { get; set; } } \ No newline at end of file diff --git a/src/UserPointManagement.Web/Controllers/UserController.cs b/src/UserPointManagement.Web/Controllers/UserController.cs index 3d37dab..e6296f6 100644 --- a/src/UserPointManagement.Web/Controllers/UserController.cs +++ b/src/UserPointManagement.Web/Controllers/UserController.cs @@ -8,7 +8,7 @@ using UserPointManagement.Model.Entities; namespace UserPointManagement.Web.Controllers; [ApiController] -[Route("api/[controller]")] +[Route("[controller]")] public class UserController : ControllerBase { private readonly IUserService _userService; diff --git a/src/UserPointManagement.Web/MvcOptionsExtensions.cs b/src/UserPointManagement.Web/MvcOptionsExtensions.cs new file mode 100644 index 0000000..72e4d8e --- /dev/null +++ b/src/UserPointManagement.Web/MvcOptionsExtensions.cs @@ -0,0 +1,45 @@ +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Mvc.Routing; + +namespace UserPointManagement.Web; + +public static class MvcOptionsExtensions +{ + private static void UseGeneralRoutePrefix(this MvcOptions opts, IRouteTemplateProvider routeAttribute) + { + opts.Conventions.Add(new RoutePrefixConvention(routeAttribute)); + } + + public static void UseGeneralRoutePrefix(this MvcOptions opts, string + prefix) + { + opts.UseGeneralRoutePrefix(new RouteAttribute(prefix)); + } +} + +public class RoutePrefixConvention : IApplicationModelConvention +{ + private readonly AttributeRouteModel _routePrefix; + + public RoutePrefixConvention(IRouteTemplateProvider route) + { + _routePrefix = new AttributeRouteModel(route); + } + + public void Apply(ApplicationModel application) + { + foreach (var selector in application.Controllers.SelectMany(c => c.Selectors)) + { + if (selector.AttributeRouteModel != null) + { + selector.AttributeRouteModel = AttributeRouteModel.CombineAttributeRouteModel(_routePrefix, selector.AttributeRouteModel); + } + else + { + selector.AttributeRouteModel = _routePrefix; + } + } + } +} \ No newline at end of file diff --git a/src/UserPointManagement.Web/Startup.cs b/src/UserPointManagement.Web/Startup.cs index c614071..6e09fd3 100644 --- a/src/UserPointManagement.Web/Startup.cs +++ b/src/UserPointManagement.Web/Startup.cs @@ -30,6 +30,7 @@ namespace UserPointManagement.Web { services.AddControllers(options => { + options.UseGeneralRoutePrefix("/api"); }); services.AddEndpointsApiExplorer(); services.AddSwaggerGen(options => @@ -92,7 +93,7 @@ namespace UserPointManagement.Web app.UseStaticFiles(); app.UseRouting(); - + app.UseEndpoints(endpoints => { endpoints.MapControllers(); From 20158c37d6689158d65c883d9c534f9e747c9489 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Sun, 27 Aug 2023 23:08:45 +0800 Subject: [PATCH 31/59] =?UTF-8?q?feat:=20=E4=BF=AE=E8=AF=A5=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=98=8E=E7=BB=86=E5=B1=95=E7=A4=BA=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=9F=E8=AE=A1=E9=9A=90=E8=97=8F=E6=98=8E?= =?UTF-8?q?=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/UserPointService.cs | 33 +++++++++++++------ .../Dtos/UserPoint/UserPointDto.cs | 2 -- .../Dtos/UserPoint/UserPointInfoDto.cs | 12 +++++++ .../UserPointDetail/UserPointDetail.razor | 12 ++----- .../UserPointDetail/UserPointDetail.razor.cs | 2 +- 5 files changed, 38 insertions(+), 23 deletions(-) create mode 100644 src/UserPointManagement.Model/Dtos/UserPoint/UserPointInfoDto.cs diff --git a/src/UserPointManagement.Application/Services/UserPointService.cs b/src/UserPointManagement.Application/Services/UserPointService.cs index 21489c5..7e23d9f 100644 --- a/src/UserPointManagement.Application/Services/UserPointService.cs +++ b/src/UserPointManagement.Application/Services/UserPointService.cs @@ -8,7 +8,7 @@ namespace UserPointManagement.Application.Services; public interface IUserPointService { - Task> GetUserPoints(GetUserPointDto req); + Task> GetUserPoints(GetUserPointDto req); Task CreateUserPoint(CreateUserPointDto input); @@ -24,26 +24,39 @@ public class UserPointService : IUserPointService _dbContextFactory = dbContextFactory; } - public async Task> GetUserPoints(GetUserPointDto req) + public async Task> GetUserPoints(GetUserPointDto req) { await using var _userPointManagementDbContext = await _dbContextFactory.CreateDbContextAsync(); - var queryable = from userPoint in _userPointManagementDbContext.UserPoints - join user in _userPointManagementDbContext.Users on userPoint.UserId equals user.Id + + var queryable = _userPointManagementDbContext.Users + .Where(x => x.Id == req.UserId, req.UserId.HasValue); + + // 分页筛选只能针对用户 + var users = await queryable.OrderByDescending(x => x.Id).Paging(req).ToListAsync(); + + // 查出用户底下积分明细 + var userPoints = await (from userPoint in _userPointManagementDbContext.UserPoints + where users.Select(x => x.Id).Contains(userPoint.UserId) select new UserPointDto() { UserPointId = userPoint.Id, - UserId = user.Id, - Name = user.Name, + UserId = userPoint.UserId, Point = userPoint.Point, CreateTime = userPoint.CreateTime - }; + }).ToListAsync(); - queryable = queryable.Where(x => x.UserId == req.UserId, req.UserId.HasValue); + var data = userPoints.GroupBy(x => x.UserId) + .Select(x => new UserPointInfoDto() + { + UserId = x.Key, + Name = users.First(p => p.Id == x.Key).Name, + TotalPoint = x.Sum(p => p.Point), + Items = x.ToList() + }).ToList(); var count = queryable.Count(); - var data = await queryable.OrderByDescending(x => x.CreateTime).Paging(req).ToListAsync().ConfigureAwait(false); - return new PageResultDto() + return new PageResultDto() { Items = data, TotalCount = count diff --git a/src/UserPointManagement.Model/Dtos/UserPoint/UserPointDto.cs b/src/UserPointManagement.Model/Dtos/UserPoint/UserPointDto.cs index b1479b6..282260a 100644 --- a/src/UserPointManagement.Model/Dtos/UserPoint/UserPointDto.cs +++ b/src/UserPointManagement.Model/Dtos/UserPoint/UserPointDto.cs @@ -6,8 +6,6 @@ public class UserPointDto public int UserId { get; set; } - public string Name { get; set; } - public int Point { get; set; } public DateTime CreateTime { get; set; } diff --git a/src/UserPointManagement.Model/Dtos/UserPoint/UserPointInfoDto.cs b/src/UserPointManagement.Model/Dtos/UserPoint/UserPointInfoDto.cs new file mode 100644 index 0000000..d35c4a0 --- /dev/null +++ b/src/UserPointManagement.Model/Dtos/UserPoint/UserPointInfoDto.cs @@ -0,0 +1,12 @@ +namespace UserPointManagement.Model.Dtos.UserPoint; + +public class UserPointInfoDto +{ + public int UserId { get; set; } + + public string Name { get; set; } + + public int TotalPoint { get; set; } + + public List Items { get; set; } +} \ No newline at end of file diff --git a/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor b/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor index 4c5c626..db976cc 100644 --- a/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor +++ b/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor @@ -36,7 +36,7 @@ - - - - - - - - - - +
diff --git a/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor.cs b/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor.cs index 5d5cc79..142e8be 100644 --- a/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor.cs +++ b/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor.cs @@ -15,7 +15,7 @@ public class UserPointDetailBase : ComponentBase [Inject] private IUserService UserService { get; set; } [Inject] private MessageService MessageService { get; set; } - protected List _userPoints; + protected List _userPoints; protected List _users; protected int _pageIndex = 1; protected int _pageSize = 20; From 4d3b25c5e4728e84d4cdca3e7830e466e43aacd3 Mon Sep 17 00:00:00 2001 From: zhangyousheng Date: Mon, 28 Aug 2023 22:24:51 +0800 Subject: [PATCH 32/59] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=98=8E=E7=BB=86=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserPointDetail/UserPointDetail.razor | 43 ++++++++++++++++--- .../UserPointDetail/UserPointDetail.razor.cs | 10 +++++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor b/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor index db976cc..60ab9d9 100644 --- a/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor +++ b/src/UserPointManagement.Web/Pages/UserPointDetail/UserPointDetail.razor @@ -41,10 +41,31 @@ Loading="_loading" PageIndex="@_pageIndex" PageSize="@_pageSize" + OnExpand="OnRowExpand" OnPageIndexChange="OnPageIndexChanged" OnPageSizeChange="OnPageSizeChange"> - - + + + + + + + + + + + + + + + + + + + + +
+
@@ -60,7 +81,7 @@ @ref="@_form">