68be41e7a2
# 项目概述 个人浏览器首页导航应用,支持书签分类管理、搜索引擎快捷搜索、 必应每日壁纸轮播、前后端分离部署,适配 1Panel 服务器(Docker 模式)。 # 技术栈 - 前端:Vue 3 + TypeScript + Vite + Pinia + Capacitor(Android 打包) - 后端:.NET 8 + SqlSugar(多数据库) + SQLite/MySQL + Swashbuckle - 部署:1Panel 应用商店自定义应用(Docker Compose 模式) # 项目结构 - backend/ .NET 8 API 后端(8 个 Controller + 15 个 Service) - frontend/ Vue 3 前端(19 个组件 + 9 个 API 模块 + 5 个 Store) - docker/ Docker 部署文件(后端镜像 + Nginx 反代) - docs/ 部署手册(1Panel 实战版) - scripts/ E2E 测试脚本 # 已实现功能 - 书签管理:增删改查 + 树形分类 + 拖拽排序 + 主色自适应 - 搜索引擎:8 个内置引擎 + 自定义引擎 + favicon 自动抓取 - 必应壁纸:每日轮播 + 多分辨率自动选择 + 1.6MP 质量优先 - 全局设置:主题/行为/数据/工具 4 分类 + 跨设备同步 - 文件上传:图标/书签/通用(容器持久化 + 跨域 URL 拼接) - 同步:基于变更日志的设备间数据同步 - 跨域部署:前后端分离 + runtime config.json 无需重新编译 # 进度记录 - 已完成 P0~P52 共 53 个开发节点(详细见 说明文档.md) - 当前版本:v1.0 部署就绪 # 部署文档 - README.md:项目说明 + 快速开始 - 说明文档.md:完整开发进度(中文) - docs/DEPLOY.md:1Panel 部署手册(Docker 模式)
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using System.Linq.Expressions;
|
|
using MyHomePage.Api.Infrastructure.Database;
|
|
using SqlSugar;
|
|
|
|
namespace MyHomePage.Api.Repositories;
|
|
|
|
/// <summary>通用仓储接口:覆盖最常用的 CRUD 能力。</summary>
|
|
/// <typeparam name="T">实体类型</typeparam>
|
|
public interface IBaseRepository<T> where T : class, new()
|
|
{
|
|
Task<T?> GetByIdAsync(int id);
|
|
Task<List<T>> ListAsync(Expression<Func<T, bool>>? where = null);
|
|
Task<int> InsertAsync(T entity);
|
|
Task<int> UpdateAsync(T entity);
|
|
Task<int> DeleteAsync(int id);
|
|
}
|
|
|
|
/// <summary>通用仓储实现:直接包装 SqlSugar 客户端。</summary>
|
|
public class BaseRepository<T> : IBaseRepository<T> where T : class, new()
|
|
{
|
|
protected readonly ISqlSugarClient Db;
|
|
|
|
public BaseRepository(SqlSugarContext ctx)
|
|
{
|
|
Db = ctx.Db;
|
|
}
|
|
|
|
public Task<T?> GetByIdAsync(int id) =>
|
|
Db.Queryable<T>().InSingleAsync(id);
|
|
|
|
public Task<List<T>> ListAsync(Expression<Func<T, bool>>? where = null) =>
|
|
where is null
|
|
? Db.Queryable<T>().ToListAsync()
|
|
: Db.Queryable<T>().Where(where).ToListAsync();
|
|
|
|
public Task<int> InsertAsync(T entity) =>
|
|
Db.Insertable(entity).ExecuteReturnIdentityAsync();
|
|
|
|
public Task<int> UpdateAsync(T entity) =>
|
|
Db.Updateable(entity).ExecuteCommandAsync();
|
|
|
|
public Task<int> DeleteAsync(int id) =>
|
|
Db.Deleteable<T>().In(id).ExecuteCommandAsync();
|
|
}
|