From e9efc6a76b3aa6ddcae55dcc91c20edbc41f2bc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9E=97=E7=A3=8A?= <2466435919@qq.com>
Date: Sun, 2 Jun 2024 22:10:52 +0800
Subject: [PATCH] web
---
"\346\236\227\347\243\212/2024-05-27.md" | 38 ++++
"\346\236\227\347\243\212/2024-05-28.md" | 25 +++
"\346\236\227\347\243\212/2024-05-30.md" | 0
"\346\236\227\347\243\212/2024-05-31.md" | 244 +++++++++++++++++++++++
4 files changed, 307 insertions(+)
create mode 100644 "\346\236\227\347\243\212/2024-05-27.md"
create mode 100644 "\346\236\227\347\243\212/2024-05-28.md"
create mode 100644 "\346\236\227\347\243\212/2024-05-30.md"
create mode 100644 "\346\236\227\347\243\212/2024-05-31.md"
diff --git "a/\346\236\227\347\243\212/2024-05-27.md" "b/\346\236\227\347\243\212/2024-05-27.md"
new file mode 100644
index 0000000..c51be19
--- /dev/null
+++ "b/\346\236\227\347\243\212/2024-05-27.md"
@@ -0,0 +1,38 @@
+# 笔记
+ SKU(Stock Keeping Unit)
+
+ 定义:SKU是一种唯一的编码或标识符,用于区分不同的产品变种或规格,通常与库存管理和销售跟踪有关。
+
+ 例子:假设你经营一个鞋店。你卖同一款运动鞋,但有不同的颜色和尺码可供选择。
+ 每个不同的颜色和尺码组合都可以分配一个独特的SKU,
+ 例如:
+
+ 黑色,尺码39:SKU001
+
+ 白色,尺码37:SKU002
+
+ 蓝色,尺码38:SKU003
+
+这样,每个SKU代表了特定颜色和尺码的鞋子,使你能够准确追踪库存和销售情况。
+
+ SPU(Single Product Unit)
+
+ 定义:SPU是一种将不同的产品变种或规格汇总为一个单一实体或产品的标识符,通常用于商品分类和在线商店的产品列表中。
+
+ 例子:继续以鞋子店为例,不论鞋子的颜色和尺码如何,同一款运动鞋都被视为一个SPU。这意味着无论你销售多少不同颜色和尺码的鞋子,
+ 它们都属于同一个SPU,例如:
+
+ 型号:ABC123(运动鞋的通用型号) 这样,无论你销售多少不同变种的鞋子,它们都被列为同一款产品的不同变种,
+ 方便顾客在在线商店中浏览和比较。
+
+综上所述,SKU用于管理单个产品的不同变种,而SPU用于将所有这些变种汇总到一个单一的产品实体中,以便于销售和分类。在实际运营中,了解如何正确使用SKU和SPU对于有效管理和销售产品非常重要。
+
+如何更高效的创建SPU和SKU呢?
+
+答案是:填写SPU信息和SKU信息后,同时创建SPU和SKU。
+
+1、录入SPU下所有SKU商品完全相同的商品信息
+
+比如同样是SPU:iphone15,可能下面有多个SKU,但这些SKU有相同的一些信息,比如:SPU编码、商品名称、商品图片、主图视频、商品类目、商品品牌、非销售属性、运费模版、发票信息、商品详情描述等等。
+
+这些完全相同的信息适合录入到SPU中,而不需要再每个SKU中重复录入。
diff --git "a/\346\236\227\347\243\212/2024-05-28.md" "b/\346\236\227\347\243\212/2024-05-28.md"
new file mode 100644
index 0000000..8dfbdac
--- /dev/null
+++ "b/\346\236\227\347\243\212/2024-05-28.md"
@@ -0,0 +1,25 @@
+# 笔记
+
+Serilog 是一个结构化的 C# 日志库。支持从配置初始化,
+
+ Log.Logger = new LoggerConfiguration()
+ .ReadFrom.AppSettings()
+ .CreateLogger();
+
+配置文件如下:
+
+
+
+
+
+Nuget 安装:
+
+Install-Package Serilog
+
+var position = new { Latitude = 25, Longitude = 134 };
+var elapsedMs = 34;
+
+log.Information("Processed {@Position} in {Elapsed:000} ms.", position, elapsedMs);
+
+{"Position": {"Latitude": 25, "Longitude": 134}, "Elapsed": 34}
+
diff --git "a/\346\236\227\347\243\212/2024-05-30.md" "b/\346\236\227\347\243\212/2024-05-30.md"
new file mode 100644
index 0000000..e69de29
diff --git "a/\346\236\227\347\243\212/2024-05-31.md" "b/\346\236\227\347\243\212/2024-05-31.md"
new file mode 100644
index 0000000..9713ac6
--- /dev/null
+++ "b/\346\236\227\347\243\212/2024-05-31.md"
@@ -0,0 +1,244 @@
+创建仓储,服务文件夹,Model层,添加类库
+
+https://img-blog.csdnimg.cn/8773571920434ee898f4933a760f3918.png
+
+安装sqlsugar包
+
+https://img-blog.csdnimg.cn/a3a70ed7501b41898483afb1c71fe138.png
+
+6.贴上代码
+
+IRepository:
+
+namespace IRepository
+{
+ public interface IBaseRepository where TEntity : class, new()
+ {
+ bool Create(TEntity entity);
+ bool Delete(int id);
+ bool Edit(TEntity entity);
+ TEntity Find(int id);
+ List QueryList();
+ }
+}
+
+
+
+IProductRepository:
+
+namespace IRepository
+{
+ public interface IProductRepository: IBaseRepository
+ {
+ //这里写IProductRepository的私有方法
+ }
+}
+
+BaseRepository:
+
+namespace Repository
+{
+ public class BaseRepository :SimpleClient, IBaseRepository where TEntity : class, new()
+ {
+ public BaseRepository(ISqlSugarClient context = null) : base(context)//注意这里要有默认值等于null
+ {
+ base.Context = DbScoped.SugarScope;
+ //创建库,创建表执行一次就可以注释
+ //base.Context.DbMaintenance.CreateDatabase();
+ //base.Context.CodeFirst.InitTables(
+ // typeof(Product)
+ // );
+ }
+ public bool Create(TEntity entity)
+ {
+ return base.Insert(entity);
+ }
+ public bool Delete(int id)
+ {
+ return base.DeleteById(id);
+ }
+ public bool Edit(TEntity entity)
+ {
+ return base.Update(entity);
+ }
+ public TEntity Find(int id)
+ {
+ return base.GetById(id);
+ }
+ public List QueryList()
+ {
+ return base.GetList();
+ }
+ }
+}
+
+
+ProductRepository:
+
+namespace Repository
+{
+ public class ProductRepository: BaseRepository, IProductRepository
+ {
+ //这里写ProductRepository的私有方法
+ }
+}
+
+IBaseService:
+
+namespace IService
+{
+ public interface IBaseService where TEntity : class, new()
+ {
+ bool Create(TEntity entity);
+ bool Delete(int id);
+ bool Edit(TEntity entity);
+ TEntity Find(int id);
+ List QueryList();
+ }
+}
+
+
+IProductService
+
+namespace IService
+{
+ public interface IProductService: IBaseService
+ {
+ //这里写IProductService的私有方法
+ }
+}
+
+
+BaseService:
+
+namespace Service
+{
+ public class BaseService : IBaseService where TEntity : class, new()
+ {
+ protected IBaseRepository _baseRepository;
+ public bool Create(TEntity entity)
+ {
+ return _baseRepository.Create(entity);
+ }
+
+ public bool Delete(int id)
+ {
+ return _baseRepository.Delete(id);
+ }
+
+ public bool Edit(TEntity entity)
+ {
+ return _baseRepository.Edit(entity);
+ }
+
+ public TEntity Find(int id)
+ {
+ return _baseRepository.Find(id);
+ }
+
+ public List QueryList()
+ {
+ return _baseRepository.QueryList();
+ }
+ }
+}
+
+ 1
+ 2
+
+
+ProductService:
+
+namespace Service
+{
+ public class ProductService: BaseService, IProductService
+ {
+ protected readonly IProductRepository _productRepository;
+ public ProductService(IProductRepository productRepository)
+ {
+ this._productRepository = productRepository;
+ this._baseRepository = productRepository;
+ }
+ }
+}
+
+
+
+ProductController 控制器
+
+namespace UniShop.Api.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class ProductController : ControllerBase
+ {
+ private readonly IProductService _productService;
+ public ProductController(IProductService productService)
+ {
+ this._productService = productService;
+ }
+ [HttpGet("GetProduct")]
+ public ActionResult GetProduct()
+ {
+ var data = _productService.QueryList();
+ if(data.Count==0) return ApiResultHelper.Error("请求失败");
+ return ApiResultHelper.Success(data);
+ }
+ }
+}
+
+Startup.cs 注入 ORM:
+
+namespace UniShop.Api
+{
+ public class Startup
+ {
+ public Startup(IConfiguration configuration)
+ {
+ Configuration = configuration;
+ }
+
+ public IConfiguration Configuration { get; }
+
+ // This method gets called by the runtime. Use this method to add services to the container.
+ public void ConfigureServices(IServiceCollection services)
+ {
+
+ services.AddControllers();
+ services.AddSwaggerGen(c =>
+ {
+ c.SwaggerDoc("v1", new OpenApiInfo { Title = "UniShop.Api", Version = "v1" });
+ });
+ //注入 ORM
+ services.AddSqlSugar(new IocConfig()
+ {
+ ConnectionString = this.Configuration.GetConnectionString("sqlConn"),
+ DbType = IocDbType.SqlServer,
+ IsAutoCloseConnection = true//自动释放
+ });
+ services.AddScoped();
+ services.AddScoped();
+ }
+
+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+ if (env.IsDevelopment())
+ {
+ app.UseDeveloperExceptionPage();
+ app.UseSwagger();
+ app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "UniShop.Api v1"));
+ }
+
+ app.UseRouting();
+
+ app.UseAuthorization();
+
+ app.UseEndpoints(endpoints =>
+ {
+ endpoints.MapControllers();
+ });
+ }
+ }
+}
+————————————————
--
Gitee