Compare commits
34
Commits
8b62d8e61e
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
619f4f6d64 | ||
|
|
5b1248fdf8 | ||
|
|
b5aa465248 | ||
|
|
5e2e12e670 | ||
|
|
7cd41821c0 | ||
|
|
e129c76471 | ||
|
|
68cae8d169 | ||
|
|
b7cafe76e5 | ||
|
|
7ae5d3e885 | ||
|
|
a57211677d | ||
|
|
1fbe4fc978 | ||
|
|
2cf41efc0f | ||
|
|
953ee66e8f | ||
|
|
38767ae629 | ||
|
|
bd5374ceec | ||
|
|
cb581ee8cc | ||
|
|
e83b4c01fd | ||
|
|
c7205a98d8 | ||
|
|
eac4f4fbea | ||
|
|
96646acd86 | ||
|
|
1b7a3286e5 | ||
|
|
3a325774d8 | ||
|
|
48b68889b0 | ||
|
|
3328ba055b | ||
|
|
2543005f96 | ||
|
|
63adfbd462 | ||
|
|
f351dd3c62 | ||
|
|
62d8608864 | ||
|
|
4bb00d68e1 | ||
|
|
a1c6145fb4 | ||
|
|
8f9049de7c | ||
|
|
20752c97a1 | ||
|
|
8c7e285180 | ||
|
|
ccdd1364f1 |
@@ -0,0 +1,406 @@
|
||||
# NewLife Copilot 协作指令
|
||||
|
||||
本说明适用于新生命团队(NewLife)及其全部开源/衍生项目,规范 Copilot 及类似智能助手在 C#/.NET 项目中的协作行为。
|
||||
|
||||
> 目标:把"每次请求必须携带的通用规则"控制在可接受体积;组件/业务专项流程放在 `.github/instructions/`,按需读取。
|
||||
|
||||
---
|
||||
|
||||
## 1. 核心原则
|
||||
|
||||
| 原则 | 说明 |
|
||||
|------|------|
|
||||
| **提效** | 减少机械样板,聚焦业务/核心算法 |
|
||||
| **一致** | 风格、结构、命名、API 行为稳定 |
|
||||
| **可控** | 限制改动影响面,可审计,兼容友好 |
|
||||
| **可靠** | 先检索再生成,不虚构,不破坏现有合约 |
|
||||
| **主动** | 发现问题主动修复,不回避合理优化 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 适用范围
|
||||
|
||||
- 含 NewLife 组件或衍生的全部 C#/.NET 仓库
|
||||
- 不含纯前端/非 .NET/市场文案
|
||||
- 存在本文件 → 必须遵循
|
||||
|
||||
---
|
||||
|
||||
## 3. 组件专用指令索引(按需加载)
|
||||
|
||||
以下专用指令**仅在相关任务时**才需要读取,避免每次请求都携带大段流程/示例。
|
||||
|
||||
### 3.1 XCode / Cube(数据库 & Web 快速开发)
|
||||
|
||||
当任务涉及以下任一信号时,请**先搜索并检查当前仓库** `.github/instructions/xcode.instructions.md` **是否存在**,若存在则读取并遵循:
|
||||
|
||||
- 需求包含:XCode/Cube/魔方/实体生成/模型 XML/数据类库/数据库 CRUD/Controller 生成/`xcodetool`/`xcode` 命令
|
||||
- 解决方案/项目中出现:`NewLife.XCode` 包引用
|
||||
- 存在:`Model.xml`、`*.xcode.xml`、`*.Data.csproj`(或项目名以 `.Data` 结尾)
|
||||
- 代码出现命名空间/类型:`XCode.*`、`Entity`(XCode 实体基类)、XCode 相关特性/接口
|
||||
- **用户提到修改任意 `.xml` 文件**(如 `member.xml`、`area.xml` 等配置文件),应**主动搜索** `xcode.instructions.md` 判断是否需要引入
|
||||
|
||||
**主动检测策略**:当用户提及 XML 文件修改时,即使未明确提到 XCode 关键字,也应先用 `file_search` 搜索 `xcode.instructions.md`,若存在则读取,以确定该 XML 文件是否属于 XCode/Cube 体系。
|
||||
|
||||
未满足以上条件时,**不要**引入 XCode/Cube 初始化流程,避免干扰其它仓库的常规开发。
|
||||
|
||||
---
|
||||
|
||||
## 4. 工作流
|
||||
|
||||
```
|
||||
需求分类 → 检索 → 评估 → 设计 → 实施 → 验证 → 说明
|
||||
```
|
||||
|
||||
1. **需求分类**:功能/修复/性能/重构/文档
|
||||
2. **检索**:相关类型、目录、方法、已有扩展/工具(**优先复用**)
|
||||
3. **评估**:是否公共 API?是否性能热点?**是否存在潜在问题?**
|
||||
4. **设计**:列出改动点 + 兼容/降级策略
|
||||
5. **实施**:
|
||||
- 完成用户请求的核心任务
|
||||
- **顺带修复**发现的明显缺陷(资源泄漏、空引用、逻辑错误)
|
||||
- **顺带优化**可简化的重复代码
|
||||
- 保留原注释与结构,除非注释本身有误
|
||||
6. **验证**:
|
||||
- 代码变更:必须编译通过;运行相关单元测试(未找到需说明)
|
||||
- 仅文档变更(未修改任何代码文件):可跳过编译与单元测试
|
||||
7. **说明**:变更摘要/影响范围/风险点
|
||||
|
||||
### 4.1 主动优化原则
|
||||
|
||||
当用户请求分析或优化代码时,**应主动**:
|
||||
|
||||
| 类型 | 行动 |
|
||||
|------|------|
|
||||
| **架构梳理** | 梳理代码架构并进行重构,让代码结构更清晰易懂 |
|
||||
| **语法现代化** | 使用最新的 C# 语法来简化代码,提升可读性 |
|
||||
| **缺陷修复** | 资源泄漏、空引用风险、并发问题、逻辑错误 → 直接修复,让代码更健壮 |
|
||||
| **性能优化** | 无用分配、重复计算、可池化资源 → 通过缓存减少耗时的重复计算 |
|
||||
| **代码简化** | 重复代码提取、冗余判断合并、现代语法替换 → 在不影响可读性前提下简化 |
|
||||
| **注释完善** | 补充类、接口、属性、方法头部的注释,以及方法内部重要代码的注释 |
|
||||
| **架构参考** | 参考网络上同类功能的优秀架构,给出架构调整建议 |
|
||||
|
||||
**架构调整策略**:
|
||||
- **改动较小**:直接调整,完成后说明变更内容
|
||||
- **改动较大**:先列出调整方案,询问用户意见,待确认后再修改
|
||||
|
||||
**不应过度保守**:
|
||||
- ❌ 仅添加注释而忽略明显的代码问题
|
||||
- ❌ 发现资源泄漏却不修复
|
||||
- ❌ 看到重复代码却不提取
|
||||
- ❌ 用户要求优化时只做表面工作
|
||||
|
||||
**保持谨慎的场景**:
|
||||
- 公共 API 签名变更 → 需说明兼容性影响
|
||||
- 性能关键路径 → 需有依据或说明推理
|
||||
- 大范围重构 → 需先与用户确认范围
|
||||
|
||||
### 4.2 防御性注释规则
|
||||
|
||||
在旧有代码中,经常可以看到**被注释掉的代码**,这些注释代码前面通常带有说明文字。
|
||||
|
||||
**这些是防御性注释**:
|
||||
- 记录了过去曾经踩过的坑
|
||||
- 目的是告诉后来人不要按照注释代码去写,否则会有问题
|
||||
- **禁止删除此类防御性注释**,用于警示后人
|
||||
|
||||
**识别特征**:
|
||||
```csharp
|
||||
// 曾经尝试过 xxx 方案,但会导致 yyy 问题
|
||||
// var result = DoSomethingWrong();
|
||||
|
||||
// 不要使用 xxx,否则会造成 yyy
|
||||
// await client.SendAsync(data);
|
||||
|
||||
// 这里不能用 xxx,因为 yyy
|
||||
// stream.Flush();
|
||||
```
|
||||
|
||||
**处理原则**:
|
||||
- ✅ 保留这类带说明的注释代码
|
||||
- ✅ 可以补充更详细的说明,解释为什么不能这样做
|
||||
- ❌ 不要删除这类防御性注释
|
||||
- ❌ 不要尝试"恢复"这些被注释的代码
|
||||
|
||||
---
|
||||
|
||||
## 5. 编码规范
|
||||
|
||||
### 5.1 基础规范
|
||||
|
||||
| 项目 | 规范 |
|
||||
|------|------|
|
||||
| 语言版本 | `<LangVersion>latest</LangVersion>`,所有目标框架均使用最新 C# 语法 |
|
||||
| 命名空间 | file-scoped namespace |
|
||||
| 类型名 | **必须**使用 .NET 正式名 `String`/`Int32`/`Boolean` 等,避免 `string`/`int`/`bool` |
|
||||
| 兼容性 | 代码需兼容 .NET 4.5+;**禁止**使用 `ArgumentNullException.ThrowIfNull`,改用 `if (value == null) throw new ArgumentNullException(nameof(value));` |
|
||||
| 单文件 | 每文件一个主要公共类型;较大平台差异使用 `partial` |
|
||||
|
||||
### 5.2 命名规范
|
||||
|
||||
| 成员类型 | 命名规则 | 示例 |
|
||||
|---------|---------|------|
|
||||
| 类型/公共成员 | PascalCase | `UserService`、`GetName()` |
|
||||
| 参数/局部变量 | camelCase | `userName`、`count` |
|
||||
| 私有字段(实例/静态) | `_camelCase` | `_cache`、`_instance` |
|
||||
| 属性/方法(实例/静态) | PascalCase | `Name`、`Default`、`Create()` |
|
||||
| 扩展方法类 | `xxxHelper` 或 `xxxExtensions` | `StringHelper`、`CollectionExtensions` |
|
||||
|
||||
### 5.3 代码风格
|
||||
|
||||
```csharp
|
||||
// ✅ 单行 if:单语句且整行不过长时同行
|
||||
if (value == null) return;
|
||||
if (key == null) throw new ArgumentNullException(nameof(key));
|
||||
|
||||
// ✅ 单行 if:语句较长时另起一行
|
||||
if (value == null)
|
||||
throw new ArgumentNullException(nameof(value), "Value cannot be null");
|
||||
|
||||
// ✅ 多分支单语句:不加花括号
|
||||
if (count > 0)
|
||||
DoSomething();
|
||||
else
|
||||
DoOther();
|
||||
|
||||
// ✅ 循环必须保留花括号(即使单语句)
|
||||
foreach (var item in list)
|
||||
{
|
||||
Process(item);
|
||||
}
|
||||
```
|
||||
|
||||
### 5.4 Region 组织结构
|
||||
|
||||
较长的类使用 `#region` 分段组织,顺序为:`属性` → `静态`(如有)→ `构造` → `方法` → `辅助`(如有)→ `日志`。
|
||||
|
||||
**日志 Region 规则**:
|
||||
- 类代码中如果带有 `ILog Log { get; set; }` 和 `WriteLog` 方法
|
||||
- **必须放在类代码的最后**
|
||||
- **必须用名为"日志"的 region 包裹**
|
||||
- 不要放在"辅助" region 中,应单独作为"日志" region
|
||||
|
||||
### 5.5 现代 C# 语法
|
||||
|
||||
优先使用最新语法(switch 表达式、模式匹配、目标类型 `new`、record 等),即使目标框架是 net45。
|
||||
|
||||
### 5.6 集合表达式
|
||||
|
||||
优先使用集合表达式 `[]` 初始化集合:`List<String> Tags { get; set; } = [];`
|
||||
|
||||
### 5.7 Null 条件运算符
|
||||
|
||||
优先使用 `?.` / `??` 简化空值检查:`span?.AppendTag("test");` `var name = user?.Profile?.Name ?? "";`
|
||||
|
||||
---
|
||||
|
||||
## 6. 多目标框架
|
||||
|
||||
NewLife 支持 `net45` 到 `net10`,常用条件符号:`NETFRAMEWORK`、`NETSTANDARD2_0`、`NETCOREAPP`、`NET5_0_OR_GREATER`、`NET6_0_OR_GREATER`、`NET8_0_OR_GREATER`。
|
||||
|
||||
新增 API 时需评估各框架兼容性,必要时提供降级实现。
|
||||
|
||||
---
|
||||
|
||||
## 7. 文档注释
|
||||
|
||||
| 规则 | 说明 |
|
||||
|------|------|
|
||||
| `<summary>` | **必须同一行闭合**,简短描述方法用途 |
|
||||
| `<param>` | **必须为每个参数添加**,无论方法可见性如何 |
|
||||
| `<returns>` | 有返回值时必须添加 |
|
||||
| `<remarks>` | 复杂方法可增加详细说明(可多行) |
|
||||
| 覆盖范围 | `public`/`protected` 成员必须注释;`private`/`internal` 建议添加 |
|
||||
| `[Obsolete]` | 必须包含迁移建议 |
|
||||
|
||||
**正确示例**:`/// <summary>获取名称</summary>` `/// <param name="id">编号</param>`
|
||||
|
||||
**禁止**:`<summary>` 拆成多行;缺少 `<param>`;有参数但无 param 标签。
|
||||
|
||||
---
|
||||
|
||||
## 8. 异步与性能
|
||||
|
||||
| 规范 | 说明 |
|
||||
|------|------|
|
||||
| 方法命名 | 异步方法后缀 `Async` |
|
||||
| ConfigureAwait | 库内部默认 `ConfigureAwait(false)` |
|
||||
| 高频路径 | 优先对象池/`ArrayPool<T>`/`Span`,避免多余分配 |
|
||||
| 反射/Linq | 仅用于非热点路径;热点使用手写循环/缓存 |
|
||||
| 池化资源 | 明确获取/归还;异常分支不遗失归还 |
|
||||
|
||||
**内置工具优先**:`Pool.StringBuilder`、`Runtime.TickCount64`、`ToInt()`/`ToBoolean()` 等扩展方法。
|
||||
|
||||
---
|
||||
|
||||
## 9. 日志与追踪
|
||||
|
||||
规则:若类包含 `ILog Log` 与 `WriteLog`,必须放在类末尾,并用名为"日志"的 `#region` 包裹;关键过程可使用 `Tracer?.NewSpan()` 埋点。
|
||||
|
||||
---
|
||||
|
||||
## 10. 错误处理
|
||||
|
||||
- **精准异常类型**:`ArgumentNullException`/`InvalidOperationException` 等
|
||||
- **参数校验**:空/越界/格式
|
||||
- **TryXxx 模式**:不用异常作常规分支
|
||||
- **类型转换**:优先使用 `ToInt()`/`ToBoolean()` 等扩展方法
|
||||
- **对外异常**:不暴露内部实现/路径
|
||||
|
||||
---
|
||||
|
||||
## 11. 测试规范
|
||||
|
||||
| 项目 | 规范 |
|
||||
|------|------|
|
||||
| 框架 | xUnit |
|
||||
| 命名 | `{ClassName}Tests` |
|
||||
| 描述 | `[DisplayName("中文描述意图")]` |
|
||||
| IO | 使用临时目录;端口用 0/随机 |
|
||||
| 覆盖 | 正常/边界/异常/并发(必要时) |
|
||||
|
||||
### 测试执行策略
|
||||
|
||||
1. 优先检索 `{ClassName}` 引用,若落入测试项目则运行
|
||||
2. 未命中则查找 `{ClassName}Tests.cs`
|
||||
3. **未发现相关测试需明确说明**,不自动创建测试项目
|
||||
|
||||
---
|
||||
|
||||
## 12. NuGet 发布规范
|
||||
|
||||
| 类型 | 命名规则 | 示例 |
|
||||
|------|---------|------|
|
||||
| 正式版 | `{主版本}.{子版本}.{年}.{月日}` | `11.9.2025.0701` |
|
||||
| 测试版 | `{主版本}.{子版本}.{年}.{月日}-beta{时分}` | `11.9.2025.0701-beta0906` |
|
||||
|
||||
- **正式版**:每月月初发布
|
||||
- **测试版**:提交代码到 GitHub 时自动发布
|
||||
|
||||
---
|
||||
|
||||
## 13. Markdown 文档规范
|
||||
|
||||
| 项目 | 规范 |
|
||||
|------|------|
|
||||
| 文件编码 | **必须** UTF-8,**禁止** GB2312/GBK/UTF-8 BOM |
|
||||
| 默认存放 | 代码库根目录下的 `Doc` 目录 |
|
||||
| 文件命名 | 优先**中文文件名**,简洁描述内容 |
|
||||
|
||||
**注意**:已有文件**必须先读取**再增量修改,**禁止直接覆盖**。
|
||||
|
||||
---
|
||||
|
||||
## 14. Copilot 行为守则
|
||||
|
||||
### 必须
|
||||
|
||||
- 简体中文回复
|
||||
- 输出前检索现有实现,**禁止重复造轮子**
|
||||
- 先列方案再实现
|
||||
- 标记不确定上下文为"需查看文件"
|
||||
- **发现明显缺陷时主动修复**(资源泄漏、空引用、逻辑错误)
|
||||
- **用户要求优化时深入分析**,不做表面工作
|
||||
|
||||
### 鼓励
|
||||
|
||||
- 提取重复代码为公共方法
|
||||
- 简化冗余的条件判断
|
||||
- 使用现代 C# 语法改进可读性
|
||||
- 补充缺失的资源释放逻辑
|
||||
- 修正错误或过时的注释
|
||||
|
||||
### 禁止
|
||||
|
||||
- 虚构 API/文件/类型
|
||||
- 伪造测试结果/性能数据
|
||||
- 擅自删除公共/受保护成员
|
||||
- 擅自删除已有代码注释(除非注释本身错误)
|
||||
- **删除防御性注释**(带说明的注释代码,记录历史踩坑经验)
|
||||
- 仅删除空白行制造"格式优化"提交
|
||||
- 删除循环体的花括号
|
||||
- 将 `<summary>` 拆成多行
|
||||
- 将 `String`/`Int32` 改为 `string`/`int`
|
||||
- 新增外部依赖(除非说明理由并给出权衡)
|
||||
- 在热点路径添加未缓存反射/复杂 Linq
|
||||
- 输出敏感凭据/内部地址
|
||||
- **发现问题却视而不见**
|
||||
- **用户要求优化时仅做注释/测试等表面工作**
|
||||
|
||||
---
|
||||
|
||||
## 15. 变更说明模板
|
||||
|
||||
提交或答复需包含:
|
||||
|
||||
```markdown
|
||||
## 概述
|
||||
做了什么 / 为什么
|
||||
|
||||
## 影响
|
||||
- 公共 API:是/否
|
||||
- 性能影响:无/有(说明)
|
||||
|
||||
## 兼容性
|
||||
降级策略 / 条件编译点
|
||||
|
||||
## 风险
|
||||
潜在回归 / 性能开销
|
||||
|
||||
## 后续
|
||||
是否补测试 / 文档
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 16. 术语说明
|
||||
|
||||
| 术语 | 定义 |
|
||||
|------|------|
|
||||
| **热点路径** | 经性能分析或高频调用栈确认的关键执行段 |
|
||||
| **基线** | 变更前的功能/性能参考数据 |
|
||||
| **顺带修复** | 在完成主任务过程中,修复发现的相关问题 |
|
||||
| **防御性注释** | 被注释掉的代码,前面带有说明,记录历史踩坑经验,用于警示后人 |
|
||||
|
||||
---
|
||||
|
||||
## 17. 代码优化检查清单
|
||||
|
||||
当进行代码优化时,按以下清单逐项检查:
|
||||
|
||||
### 架构与结构
|
||||
- [ ] 代码架构是否清晰?是否需要重构?
|
||||
- [ ] 类的职责是否单一?是否需要拆分?
|
||||
- [ ] 是否有重复代码可以提取为公共方法?
|
||||
- [ ] Region 组织是否符合规范(属性→静态→构造→方法→辅助→日志)?
|
||||
|
||||
### 语法现代化
|
||||
- [ ] 是否可以使用更简洁的 C# 语法?(switch 表达式、模式匹配等)
|
||||
- [ ] 集合初始化是否使用了集合表达式 `[]`?
|
||||
- [ ] 是否可以使用 null 条件运算符 `?.` 简化代码?
|
||||
|
||||
### 健壮性
|
||||
- [ ] 是否存在空引用风险?
|
||||
- [ ] 资源是否正确释放?(IDisposable、流、连接等)
|
||||
- [ ] 异常处理是否完善?
|
||||
- [ ] 并发场景是否线程安全?
|
||||
|
||||
### 性能
|
||||
- [ ] 是否存在可以缓存的重复计算?
|
||||
- [ ] 是否有不必要的对象分配?
|
||||
- [ ] 热点路径是否避免了反射和复杂 Linq?
|
||||
- [ ] 是否使用了对象池/ArrayPool 等池化技术?
|
||||
|
||||
### 注释与文档
|
||||
- [ ] 类、接口是否有 `<summary>` 注释?
|
||||
- [ ] 公共方法是否有完整的参数和返回值注释?
|
||||
- [ ] 方法内重要逻辑是否有注释说明?
|
||||
- [ ] 防御性注释是否保留?
|
||||
|
||||
### 日志
|
||||
- [ ] `ILog Log` 和 `WriteLog` 是否放在类的最后?
|
||||
- [ ] 是否用名为"日志"的 region 包裹?
|
||||
|
||||
---
|
||||
|
||||
(完)
|
||||
@@ -0,0 +1,506 @@
|
||||
# XCode 协作指令
|
||||
|
||||
本指令面向新生命团队(NewLife)开源数据中间件 XCode,帮助 Copilot 在 .NET 项目中正确使用 XCode 进行数据建模和实体操作。
|
||||
|
||||
---
|
||||
|
||||
## 1. XCode 定位与边界
|
||||
|
||||
### 1.1 技术栈定位
|
||||
|
||||
```
|
||||
NewLife.Core(基础库)
|
||||
↓
|
||||
NewLife.XCode(数据中间件)← 本指令
|
||||
↓
|
||||
NewLife.Cube(Web 快速开发框架)→ cube.instructions.md
|
||||
```
|
||||
|
||||
### 1.2 职责边界
|
||||
|
||||
| 层级 | 职责 | 指令文件 |
|
||||
|------|------|---------|
|
||||
| **NewLife.Core** | 基础扩展、日志、缓存、网络等 | `copilot-instructions.md` |
|
||||
| **NewLife.XCode** | 数据建模、ORM、实体增删改查、数据库操作 | 本指令 |
|
||||
| **NewLife.Cube** | Web 管理后台、控制器、视图、权限 | `cube.instructions.md` |
|
||||
|
||||
### 1.3 本指令覆盖范围
|
||||
|
||||
**包含**:
|
||||
- 数据模型设计(Model.xml)
|
||||
- 实体类生成与使用
|
||||
- 数据库 CRUD 操作
|
||||
- 项目初始化与 XCode 接入
|
||||
|
||||
**不包含**(由 cube.instructions.md 负责):
|
||||
- Web 控制器逻辑
|
||||
- 视图与前端交互
|
||||
- 权限管理配置
|
||||
- 魔方区域深度定制
|
||||
|
||||
---
|
||||
|
||||
## 2. 使用场景与快速入口
|
||||
|
||||
### 2.1 场景一:已有项目接入 XCode
|
||||
|
||||
1. 引入 NuGet 包:`dotnet add package NewLife.XCode`
|
||||
2. 创建或编辑 `Model.xml` 进行数据建模
|
||||
3. 执行 `xcode` 命令生成实体类
|
||||
4. 在业务代码中使用实体类进行数据操作
|
||||
|
||||
### 2.2 场景二:从零创建新项目
|
||||
|
||||
1. 安装模板:`dotnet new install NewLife.Templates`
|
||||
2. 创建数据类库:`dotnet new xcode -n {系统名}.Data`
|
||||
3. 创建应用项目:
|
||||
- Web 应用:`dotnet new cube -n {系统名}Web`
|
||||
- 控制台应用:`dotnet new nconsole -n {系统名}App`
|
||||
4. 编辑 `Model.xml` 进行数据建模
|
||||
5. 执行 `xcode` 生成实体类
|
||||
|
||||
### 2.3 核心工作流
|
||||
|
||||
```
|
||||
理解业务需求 → 数据建模(Model.xml) → 生成实体类(xcode) → 编写业务代码
|
||||
```
|
||||
|
||||
**关键点**:无论哪种场景,核心都是 **充分理解业务需求,在 Model.xml 中设计合理的数据表结构**。
|
||||
|
||||
---
|
||||
|
||||
## 3. 环境准备
|
||||
|
||||
### 3.1 前置要求
|
||||
|
||||
```powershell
|
||||
# 检查 .NET SDK(要求 8.0+)
|
||||
dotnet --version
|
||||
|
||||
# 安装全局工具 xcodetool
|
||||
dotnet tool install xcodetool -g
|
||||
```
|
||||
|
||||
### 3.2 模板版本检查
|
||||
|
||||
NewLife.Templates 模板会持续更新,使用前需检查版本:
|
||||
|
||||
```powershell
|
||||
# 查看模板详情
|
||||
dotnet new details NewLife.Templates
|
||||
```
|
||||
|
||||
**判定规则**:输出包含类似 `包版本: 1.1.2025.820-beta1836`
|
||||
- 其中 `1.1.2025.820` 表示 v1.1,发布日期为 2025-08-20
|
||||
- **要求**:发布日期需 > 2025-08-01(即严格晚于 2025-08-01)
|
||||
|
||||
```powershell
|
||||
# 若未安装或版本过旧,执行安装/更新
|
||||
dotnet new install NewLife.Templates
|
||||
```
|
||||
|
||||
> **强约束**:仅当未安装或发布日期 ≤ 2025-08-01 时才执行安装;否则保持现状,避免无谓变更。
|
||||
|
||||
### 3.3 模板说明
|
||||
|
||||
| 模板 | 命令 | 用途 |
|
||||
|------|------|------|
|
||||
| `xcode` | `dotnet new xcode -n Name.Data` | 数据类库项目 |
|
||||
| `cube` | `dotnet new cube -n NameWeb` | Web 管理后台 |
|
||||
| `nconsole` | `dotnet new nconsole -n NameApp` | 控制台应用 |
|
||||
|
||||
---
|
||||
|
||||
## 4. Model.xml 完整参考
|
||||
|
||||
### 4.1 文件结构
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<EntityModel xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xs:schemaLocation="https://newlifex.com https://newlifex.com/Model202509.xsd"
|
||||
xmlns="https://newlifex.com/Model202509.xsd">
|
||||
<Option>
|
||||
<!-- 全局配置 -->
|
||||
</Option>
|
||||
<Tables>
|
||||
<Table>
|
||||
<Columns>
|
||||
<Column />
|
||||
</Columns>
|
||||
<Indexes>
|
||||
<Index />
|
||||
</Indexes>
|
||||
</Table>
|
||||
</Tables>
|
||||
</EntityModel>
|
||||
```
|
||||
|
||||
### 4.2 Option 配置项
|
||||
|
||||
| 配置项 | 说明 | 示例 |
|
||||
|--------|------|------|
|
||||
| `Namespace` | 命名空间 | `Zero.Data` |
|
||||
| `ConnName` | 数据库连接名 | `Zero` |
|
||||
| `Output` | 实体类输出目录 | `.\` |
|
||||
| `BaseClass` | 实体基类 | `Entity` |
|
||||
| `ChineseFileName` | 使用中文文件名 | `True` |
|
||||
| `Nullable` | 生成可空引用类型 | `True` |
|
||||
| `HasIModel` | 实现 IModel 接口 | `True` |
|
||||
| `ModelClass` | 模型类模板 | `{name}Model` |
|
||||
| `ModelsOutput` | 模型类输出目录 | `.\Models\` |
|
||||
| `ModelInterface` | 模型接口模板 | `I{name}` |
|
||||
| `InterfacesOutput` | 接口输出目录 | `.\Interfaces\` |
|
||||
| `NameFormat` | 命名格式 | `Default`/`Upper`/`Lower`/`Underline` |
|
||||
| `DisplayName` | 魔方区域显示名 | `订单管理` |
|
||||
| `CubeOutput` | 魔方控制器输出目录 | `../../Web/Areas/Order` |
|
||||
|
||||
### 4.3 Table 属性
|
||||
|
||||
| 属性 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `Name` | 实体类名 | `User` |
|
||||
| `TableName` | 数据库表名(可选,默认同 Name) | `sys_user` |
|
||||
| `Description` | 表说明 | `用户。用户账号信息` |
|
||||
| `ConnName` | 独立连接名(覆盖全局) | `Log` |
|
||||
| `BaseType` | 基类(支持实体继承) | `EntityBase` |
|
||||
| `InsertOnly` | 仅插入模式(日志表优化) | `True` |
|
||||
| `IsView` | 视图标识 | `True` |
|
||||
|
||||
### 4.4 Column 属性完整参考
|
||||
|
||||
#### 基础属性
|
||||
|
||||
| 属性 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `Name` | 属性名 | `UserName` |
|
||||
| `ColumnName` | 数据库列名(可选) | `user_name` |
|
||||
| `DataType` | 数据类型 | `Int32`/`Int64`/`String`/`DateTime`/`Boolean`/`Double`/`Decimal` |
|
||||
| `Description` | 字段说明 | `用户名。登录账号` |
|
||||
| `Length` | 字符串长度 | `50`/`200`/`-1`(大文本) |
|
||||
| `Precision` | 数值精度 | `18` |
|
||||
| `Scale` | 小数位数 | `2` |
|
||||
|
||||
#### 主键与标识
|
||||
|
||||
| 属性 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `PrimaryKey` | 主键 | `True` |
|
||||
| `Identity` | 自增标识 | `True` |
|
||||
| `Master` | 主字段(业务主要字段) | `True` |
|
||||
|
||||
#### 约束与默认值
|
||||
|
||||
| 属性 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `Nullable` | 允许空 | `False` |
|
||||
| `DefaultValue` | 默认值 | `0`/`''`/`getdate()` |
|
||||
|
||||
#### 映射关系(Map)
|
||||
|
||||
格式:`表名@主键@显示字段@属性名`
|
||||
|
||||
| 格式 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `Table@Id@Name` | 基本映射(三段) | `Role@Id@Name` |
|
||||
| `Table@Id@Name@RoleName` | 指定属性名(四段) | `Role@Id@Name@RoleName` |
|
||||
| `NS.Table@Id@Path@AreaPath` | 完整命名空间 | `XCode.Membership.Area@Id@Path@AreaPath` |
|
||||
|
||||
#### 元素类型(ItemType)
|
||||
|
||||
用于魔方前端渲染和数据验证:
|
||||
|
||||
| ItemType | 说明 |
|
||||
|----------|------|
|
||||
| `image` | 图片上传 |
|
||||
| `file` | 文件上传 |
|
||||
| `mail` | 邮箱格式 |
|
||||
| `mobile` | 手机号格式 |
|
||||
| `url` | URL 链接 |
|
||||
| `TimeSpan` | 时间间隔(秒转可读格式) |
|
||||
| `GMK` | 字节数转 GB/MB/KB |
|
||||
| `html` | HTML 富文本 |
|
||||
| `code` | 代码编辑器 |
|
||||
| `json` | JSON 编辑器 |
|
||||
|
||||
#### 显示选项(ShowIn)
|
||||
|
||||
控制字段在魔方各区域的显示,支持三种语法:
|
||||
|
||||
**语法一:具名列表(推荐)**
|
||||
```
|
||||
ShowIn="List,Search" # List和Search显示
|
||||
ShowIn="-EditForm,-Detail" # 编辑表单和详情隐藏
|
||||
ShowIn="All,-Detail" # 全部显示,详情隐藏
|
||||
ShowIn="None,Search,Add" # 全部隐藏,搜索和添加显示
|
||||
```
|
||||
|
||||
区域别名:`List(L)`、`Detail(D)`、`AddForm(Add/A)`、`EditForm(Edit/E)`、`Search(S)`、`Form(F)`(同时控制 Add 和 Edit)
|
||||
|
||||
**语法二:管道分隔**
|
||||
```
|
||||
ShowIn="Y|Y|N||A" # List=显示|Detail=显示|Add=隐藏|Edit=自动|Search=自动
|
||||
```
|
||||
|
||||
**语法三:5字符掩码**
|
||||
```
|
||||
ShowIn="11110" # 1=显示, 0=隐藏, A/?/-=自动
|
||||
```
|
||||
|
||||
#### 分表字段(DataScale)
|
||||
|
||||
| 值 | 说明 |
|
||||
|----|------|
|
||||
| `time` | 大数据单表的时间字段(用于雪花 ID) |
|
||||
| `timeShard:yyMMdd` | 分表字段,按日期格式分表 |
|
||||
|
||||
#### 其他属性
|
||||
|
||||
| 属性 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `Type` | 枚举类型 | `XCode.Membership.SexKinds` |
|
||||
| `Category` | 表单分组 | `登录信息`/`扩展` |
|
||||
| `Attribute` | 额外特性 | `XmlIgnore, IgnoreDataMember` |
|
||||
| `Model` | 是否包含在模型类中 | `False` |
|
||||
| `RawType` | 原始数据库类型 | `varchar(50)` |
|
||||
|
||||
### 4.5 Index 属性
|
||||
|
||||
| 属性 | 说明 | 示例 |
|
||||
|------|------|------|
|
||||
| `Columns` | 索引列(逗号分隔) | `Name`/`Category,CreateTime` |
|
||||
| `Unique` | 唯一索引 | `True` |
|
||||
|
||||
### 4.6 完整示例
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<EntityModel xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xs:schemaLocation="https://newlifex.com https://newlifex.com/Model202509.xsd"
|
||||
xmlns="https://newlifex.com/Model202509.xsd">
|
||||
<Option>
|
||||
<Namespace>Order.Data</Namespace>
|
||||
<ConnName>Order</ConnName>
|
||||
<Output>.\</Output>
|
||||
<ChineseFileName>True</ChineseFileName>
|
||||
<Nullable>True</Nullable>
|
||||
<HasIModel>True</HasIModel>
|
||||
<DisplayName>订单管理</DisplayName>
|
||||
<CubeOutput>../../OrderWeb/Areas/Order</CubeOutput>
|
||||
</Option>
|
||||
<Tables>
|
||||
<Table Name="Order" Description="订单。电商订单主表">
|
||||
<Columns>
|
||||
<Column Name="Id" DataType="Int64" PrimaryKey="True" DataScale="time" Description="编号" />
|
||||
<Column Name="OrderNo" DataType="String" Master="True" Length="50" Nullable="False" Description="订单号" />
|
||||
<Column Name="UserId" DataType="Int32" Map="User@Id@Name" Description="用户" />
|
||||
<Column Name="Status" DataType="Int32" Type="Order.Data.OrderStatus" Description="状态" />
|
||||
<Column Name="TotalAmount" DataType="Decimal" Precision="18" Scale="2" Description="总金额" />
|
||||
<Column Name="Remark" DataType="String" Length="500" Description="备注" Category="扩展" />
|
||||
<Column Name="CreateUser" DataType="String" Description="创建者" Model="False" Category="扩展" />
|
||||
<Column Name="CreateTime" DataType="DateTime" Nullable="False" Description="创建时间" Category="扩展" />
|
||||
<Column Name="UpdateTime" DataType="DateTime" Description="更新时间" Model="False" Category="扩展" />
|
||||
</Columns>
|
||||
<Indexes>
|
||||
<Index Columns="OrderNo" Unique="True" />
|
||||
<Index Columns="UserId" />
|
||||
<Index Columns="Status,CreateTime" />
|
||||
</Indexes>
|
||||
</Table>
|
||||
</Tables>
|
||||
</EntityModel>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 实体类操作指南
|
||||
|
||||
### 5.1 基础 CRUD
|
||||
|
||||
```csharp
|
||||
// 新增
|
||||
var entity = new User { Name = "test", Password = "123456" };
|
||||
entity.Insert();
|
||||
|
||||
// 查询单个
|
||||
var user = User.FindByKey(1);
|
||||
var user = User.Find(User._.Name == "test");
|
||||
|
||||
// 查询列表
|
||||
var list = User.FindAll();
|
||||
var list = User.FindAll(User._.Status == 1, User._.Id.Desc(), null, 0, 10);
|
||||
|
||||
// 更新
|
||||
user.Name = "newName";
|
||||
user.Update();
|
||||
|
||||
// 删除
|
||||
user.Delete();
|
||||
|
||||
// 保存(自动判断 Insert/Update)
|
||||
entity.Save();
|
||||
```
|
||||
|
||||
### 5.2 高级查询
|
||||
|
||||
```csharp
|
||||
// 分页查询
|
||||
var page = new PageParameter { PageIndex = 1, PageSize = 20 };
|
||||
var list = User.FindAll(User._.Status == 1, page);
|
||||
|
||||
// 条件组合
|
||||
var where = new WhereExpression();
|
||||
where &= User._.Status == 1;
|
||||
where &= User._.CreateTime >= DateTime.Today;
|
||||
if (!key.IsNullOrEmpty()) where &= User._.Name.Contains(key);
|
||||
var list = User.FindAll(where, page);
|
||||
|
||||
// 统计
|
||||
var count = User.FindCount(User._.Status == 1);
|
||||
|
||||
// 查询最大/最小值
|
||||
var maxId = User.FindMax(User._.Id, null);
|
||||
```
|
||||
|
||||
### 5.3 批量操作
|
||||
|
||||
```csharp
|
||||
// 批量插入
|
||||
var list = new List<User>();
|
||||
list.Insert();
|
||||
|
||||
// 批量更新
|
||||
User.Update(User._.Status == 2, User._.Status == 1);
|
||||
|
||||
// 批量删除
|
||||
User.Delete(User._.Status == 0);
|
||||
```
|
||||
|
||||
### 5.4 异步操作
|
||||
|
||||
```csharp
|
||||
var user = await User.FindAsync(User._.Id == 1);
|
||||
var list = await User.FindAllAsync(User._.Status == 1, page);
|
||||
await entity.InsertAsync();
|
||||
await entity.SaveAsync(); // 异步保存,用于日志等高频写入
|
||||
```
|
||||
|
||||
### 5.5 缓存查询
|
||||
|
||||
```csharp
|
||||
// 实体缓存(适用于小表)
|
||||
var list = User.FindAllWithCache();
|
||||
|
||||
// 单对象缓存(按主键)
|
||||
var user = User.FindByKeyWithCache(1);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 多模块项目结构
|
||||
|
||||
对于复杂业务系统,建议按模块组织:
|
||||
|
||||
```
|
||||
Zero.Data/
|
||||
├── Order/ # 订单模块
|
||||
│ ├── Order.xml # 订单模型
|
||||
│ ├── 订单.cs
|
||||
│ └── 订单明细.cs
|
||||
├── Product/ # 商品模块
|
||||
│ ├── Product.xml # 商品模型
|
||||
│ ├── 商品.cs
|
||||
│ └── 分类.cs
|
||||
└── Member/ # 会员模块
|
||||
├── Member.xml # 会员模型
|
||||
└── 会员.cs
|
||||
```
|
||||
|
||||
每个模块目录内有独立的 `*.xml` 模型文件,在各自目录执行 `xcode` 命令生成实体类。
|
||||
|
||||
---
|
||||
|
||||
## 7. xcode 命令参考
|
||||
|
||||
```powershell
|
||||
# 在模型文件所在目录执行(自动查找所有 *.xml)
|
||||
xcode
|
||||
|
||||
# 指定模型文件
|
||||
xcode Model.xml
|
||||
xcode Order.xml
|
||||
```
|
||||
|
||||
**执行效果**:
|
||||
1. 读取 XML 模型文件
|
||||
2. 生成实体类(`*.cs`)
|
||||
3. 生成模型类(如配置了 `ModelClass`)
|
||||
4. 生成接口(如配置了 `ModelInterface`)
|
||||
5. 生成数据字典(`*.htm`)
|
||||
6. 生成魔方控制器(如配置了 `CubeOutput`)
|
||||
|
||||
---
|
||||
|
||||
## 8. 常见问题
|
||||
|
||||
### 8.1 模型文件命名
|
||||
|
||||
- 默认:`Model.xml`
|
||||
- 推荐:`{系统英文名}.xml` 或 `{模块名}.xml`
|
||||
- 复杂项目:每个模块目录一个模型文件
|
||||
|
||||
### 8.2 实体类生成位置
|
||||
|
||||
- 实体类生成在 `xcode` 命令执行目录
|
||||
- 可通过 `Output` 配置项指定输出目录
|
||||
- 魔方控制器通过 `CubeOutput` 指定
|
||||
|
||||
### 8.3 数据库连接
|
||||
|
||||
在应用配置文件中配置连接字符串:
|
||||
|
||||
```json
|
||||
{
|
||||
"ConnectionStrings": {
|
||||
"Order": "Server=.;Database=Order;Uid=sa;Pwd=xxx"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
连接名对应 Model.xml 中的 `ConnName`。
|
||||
|
||||
---
|
||||
|
||||
## 9. 与 Cube 的协作
|
||||
|
||||
当需要生成 Web 管理界面时:
|
||||
|
||||
1. 在 Model.xml 中配置 `CubeOutput` 指向 Web 项目的 Areas 目录
|
||||
2. 配置 `DisplayName` 作为魔方区域名称
|
||||
3. 执行 `xcode` 自动生成控制器
|
||||
4. 深度定制请参考 `cube.instructions.md`
|
||||
|
||||
---
|
||||
|
||||
## 10. Copilot 行为指引
|
||||
|
||||
### 10.1 数据建模时
|
||||
|
||||
1. **充分理解业务**:在设计表结构前,确保理解业务场景和数据关系
|
||||
2. **合理设计主键**:
|
||||
- 普通表:`Int32` 自增主键
|
||||
- 大数据表:`Int64` + `DataScale="time"`(雪花 ID)
|
||||
3. **必要的索引**:为查询条件字段添加索引
|
||||
4. **字段长度**:String 类型必须指定合理的 `Length`
|
||||
|
||||
### 10.2 生成代码时
|
||||
|
||||
1. 确保在正确目录执行 `xcode`
|
||||
2. 生成后检查编译是否通过
|
||||
3. 如需修改生成的代码,应修改 Model.xml 后重新生成
|
||||
|
||||
### 10.3 边界意识
|
||||
|
||||
- 数据模型和实体操作 → 本指令
|
||||
- Web 控制器和界面 → `cube.instructions.md`
|
||||
- 基础编码规范 → `copilot-instructions.md`
|
||||
@@ -309,3 +309,7 @@ COMCMS.Web/wwwroot/userfiles/
|
||||
/COMCMS.Web/UploadTemp
|
||||
/WebTest/wwwroot
|
||||
COMCMS.Web/wwwroot/install.lock
|
||||
|
||||
|
||||
# others
|
||||
.cursorrules
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
|
||||
<PackageReference Include="Senparc.Weixin" Version="6.17.0" />
|
||||
<PackageReference Include="Senparc.Weixin.MP" Version="16.20.3" />
|
||||
<PackageReference Include="NewLife.Core" Version="11.16.2026.601" />
|
||||
<PackageReference Include="Senparc.Weixin" Version="6.23.1" />
|
||||
<PackageReference Include="Senparc.Weixin.MP" Version="16.24.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="NewLife.Core" Version="10.6.2023.1201" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NewLife.Core" Version="11.16.2026.601" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.6" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.6" />
|
||||
<PackageReference Include="SkiaSharp.QrCode" Version="0.6.0" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
|
||||
<PackageReference Include="SkiaSharp" Version="3.119.4" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4" />
|
||||
<PackageReference Include="SkiaSharp.QrCode" Version="0.12.0" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="10.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace COMCMS.Common
|
||||
}
|
||||
|
||||
|
||||
var newImg = originalImage.Resize(new SKSizeI(towidth, toheight), SKFilterQuality.Medium);
|
||||
var newImg = originalImage.Resize(new SKSizeI(towidth, toheight), new SKSamplingOptions(SKFilterMode.Linear, SKMipmapMode.Linear));
|
||||
using var fs = new FileStream(newFileName, FileMode.Create);
|
||||
//判断类型
|
||||
SKEncodedImageFormat imgType = new SKEncodedImageFormat();
|
||||
|
||||
+25
-2
@@ -209,6 +209,10 @@ namespace COMCMS.Common
|
||||
{
|
||||
http = "https://";
|
||||
}
|
||||
if (MyHttpContext.Current.Request.Headers["X-Scheme"].ToString() == "https")//增加判断反向代理
|
||||
{
|
||||
http = "https://";
|
||||
}
|
||||
string port = MyHttpContext.Current.Request.Host.Port.ToString();
|
||||
if (string.IsNullOrEmpty(port) || port == "80" || port == "443")
|
||||
return http + MyHttpContext.Current.Request.Host.Host;
|
||||
@@ -383,7 +387,15 @@ namespace COMCMS.Common
|
||||
{
|
||||
return Regex.IsMatch(StrSource, @"^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为日期+时间型字符串
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsDateTime(string StrSource)
|
||||
{
|
||||
return Regex.IsMatch(StrSource, @"^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))\s([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$");
|
||||
}
|
||||
/// <summary>
|
||||
/// 正则手机型号
|
||||
/// </summary>
|
||||
@@ -753,7 +765,18 @@ namespace COMCMS.Common
|
||||
return false;
|
||||
|
||||
string extname = filename.Substring(filename.LastIndexOf(".") + 1).ToLower();
|
||||
return (extname == "jpg" || extname == "jpeg" || extname == "png" || extname == "bmp" || extname == "gif");
|
||||
|
||||
// 从配置中获取图片扩展名列表
|
||||
string imageExtensions = Configuration["SystemSetting:ImageExtensions"];
|
||||
if (string.IsNullOrEmpty(imageExtensions))
|
||||
{
|
||||
// 如果配置中没有设置,则使用默认值
|
||||
imageExtensions = "jpg,jpeg,png,bmp,gif";
|
||||
}
|
||||
|
||||
// 将扩展名列表分割成数组并检查
|
||||
string[] extensions = imageExtensions.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
return extensions.Contains(extname);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -293,14 +293,13 @@ namespace COMCMS.Common
|
||||
canvas.DrawLine(random.Next(0, width), random.Next(0, height), random.Next(0, width), random.Next(0, height), drawStyle);
|
||||
}
|
||||
// 在图片上写验证码
|
||||
using SKFont textFont = new() { Size = 22 };
|
||||
SKPaint textPaint = new SKPaint
|
||||
{
|
||||
IsAntialias = true,
|
||||
TextAlign = SKTextAlign.Left,
|
||||
Shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(width, height), new SKColor[] { SKColors.Blue, SKColors.DarkRed }, SKShaderTileMode.Clamp),
|
||||
TextSize = 22
|
||||
};
|
||||
canvas.DrawText(text, 4, 24, textPaint);
|
||||
canvas.DrawText(text, 4, 24, SKTextAlign.Left, textFont, textPaint);
|
||||
|
||||
//将文字写到画布上
|
||||
//using (SKPaint drawStyle = new())
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NewLife.XCode" Version="11.10.2023.1201" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="NewLife.XCode" Version="11.27.2026.601" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -75,6 +75,21 @@ namespace COMCMS.Core
|
||||
/// <returns></returns>
|
||||
public static string EchoURL(Product model)
|
||||
{
|
||||
if (model == null)
|
||||
return "javascript:;";
|
||||
|
||||
Category categoty = Category.FindById(model.KId);
|
||||
|
||||
if (categoty != null && !string.IsNullOrEmpty(categoty.FilePath))
|
||||
{
|
||||
string url = $"{categoty.FilePath}/{model.Id}.html";
|
||||
if (!string.IsNullOrEmpty(model.FileName))
|
||||
{
|
||||
url = $"{categoty.FilePath}/{model.FileName}";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
else
|
||||
return $"/product/detail/{model.Id}";
|
||||
}
|
||||
|
||||
@@ -149,5 +164,28 @@ namespace COMCMS.Core
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 生成商品地址
|
||||
/// <summary>
|
||||
/// 生成商品分类地址
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static string EchoCategoryURL(int id)
|
||||
{
|
||||
Category model = Category.FindById(id);
|
||||
return EchoURL(model);
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成商品详情地址
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public static string EchoProductURL(int id)
|
||||
{
|
||||
Product model = Product.FindById(id);
|
||||
return EchoURL(model);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
/// <summary>小程序Session</summary>
|
||||
public partial class WXAppSession : Entity<WXAppSession>
|
||||
{
|
||||
#region 对象操作
|
||||
static WXAppSession()
|
||||
{
|
||||
// 累加字段
|
||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WXAppSession[小程序Session]数据……");
|
||||
|
||||
// var entity = new WXAppSession();
|
||||
// entity.Id = 0;
|
||||
// entity.UId = 0;
|
||||
// entity.IP = "abc";
|
||||
// entity.Key = "abc";
|
||||
// entity.SessionKey = "abc";
|
||||
// entity.OpenId = "abc";
|
||||
// entity.AddTime = DateTime.Now;
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化WXAppSession[小程序Session]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static WXAppSession FindById(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||
|
||||
// 单对象缓存
|
||||
//return Meta.SingleCache[id];
|
||||
|
||||
return Find(_.Id == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
/// <summary>小程序Session</summary>
|
||||
[Serializable]
|
||||
[DataObject]
|
||||
[Description("小程序Session")]
|
||||
[BindTable("WXAppSession", Description = "小程序Session", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||
public partial class WXAppSession : IWXAppSession
|
||||
{
|
||||
#region 属性
|
||||
private Int32 _Id;
|
||||
/// <summary>编号</summary>
|
||||
[DisplayName("编号")]
|
||||
[Description("编号")]
|
||||
[DataObjectField(true, true, false, 0)]
|
||||
[BindColumn("Id", "编号", "int")]
|
||||
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||
|
||||
private Int32 _UId;
|
||||
/// <summary>用户ID</summary>
|
||||
[DisplayName("用户ID")]
|
||||
[Description("用户ID")]
|
||||
[DataObjectField(false, false, false, 0)]
|
||||
[BindColumn("UId", "用户ID", "int")]
|
||||
public Int32 UId { get { return _UId; } set { if (OnPropertyChanging(__.UId, value)) { _UId = value; OnPropertyChanged(__.UId); } } }
|
||||
|
||||
private String _IP;
|
||||
/// <summary>登录IP</summary>
|
||||
[DisplayName("登录IP")]
|
||||
[Description("登录IP")]
|
||||
[DataObjectField(false, false, true, 20)]
|
||||
[BindColumn("IP", "登录IP", "nvarchar(20)")]
|
||||
public String IP { get { return _IP; } set { if (OnPropertyChanging(__.IP, value)) { _IP = value; OnPropertyChanged(__.IP); } } }
|
||||
|
||||
private String _Key;
|
||||
/// <summary>系统生成Key</summary>
|
||||
[DisplayName("系统生成Key")]
|
||||
[Description("系统生成Key")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("Key", "系统生成Key", "nvarchar(50)")]
|
||||
public String Key { get { return _Key; } set { if (OnPropertyChanging(__.Key, value)) { _Key = value; OnPropertyChanged(__.Key); } } }
|
||||
|
||||
private String _SessionKey;
|
||||
/// <summary>微信SessionKey</summary>
|
||||
[DisplayName("微信SessionKey")]
|
||||
[Description("微信SessionKey")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("SessionKey", "微信SessionKey", "nvarchar(50)")]
|
||||
public String SessionKey { get { return _SessionKey; } set { if (OnPropertyChanging(__.SessionKey, value)) { _SessionKey = value; OnPropertyChanged(__.SessionKey); } } }
|
||||
|
||||
private String _OpenId;
|
||||
/// <summary>微信小程序OpenId</summary>
|
||||
[DisplayName("微信小程序OpenId")]
|
||||
[Description("微信小程序OpenId")]
|
||||
[DataObjectField(false, false, true, 50)]
|
||||
[BindColumn("OpenId", "微信小程序OpenId", "nvarchar(50)")]
|
||||
public String OpenId { get { return _OpenId; } set { if (OnPropertyChanging(__.OpenId, value)) { _OpenId = value; OnPropertyChanged(__.OpenId); } } }
|
||||
|
||||
private DateTime _AddTime;
|
||||
/// <summary>添加时间</summary>
|
||||
[DisplayName("添加时间")]
|
||||
[Description("添加时间")]
|
||||
[DataObjectField(false, false, true, 0)]
|
||||
[BindColumn("AddTime", "添加时间", "datetime")]
|
||||
public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
public override Object this[String name]
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case __.Id : return _Id;
|
||||
case __.UId : return _UId;
|
||||
case __.IP : return _IP;
|
||||
case __.Key : return _Key;
|
||||
case __.SessionKey : return _SessionKey;
|
||||
case __.OpenId : return _OpenId;
|
||||
case __.AddTime : return _AddTime;
|
||||
default: return base[name];
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case __.Id : _Id = Convert.ToInt32(value); break;
|
||||
case __.UId : _UId = Convert.ToInt32(value); break;
|
||||
case __.IP : _IP = Convert.ToString(value); break;
|
||||
case __.Key : _Key = Convert.ToString(value); break;
|
||||
case __.SessionKey : _SessionKey = Convert.ToString(value); break;
|
||||
case __.OpenId : _OpenId = Convert.ToString(value); break;
|
||||
case __.AddTime : _AddTime = Convert.ToDateTime(value); break;
|
||||
default: base[name] = value; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段名
|
||||
/// <summary>取得小程序Session字段信息的快捷方式</summary>
|
||||
public partial class _
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public static readonly Field Id = FindByName(__.Id);
|
||||
|
||||
/// <summary>用户ID</summary>
|
||||
public static readonly Field UId = FindByName(__.UId);
|
||||
|
||||
/// <summary>登录IP</summary>
|
||||
public static readonly Field IP = FindByName(__.IP);
|
||||
|
||||
/// <summary>系统生成Key</summary>
|
||||
public static readonly Field Key = FindByName(__.Key);
|
||||
|
||||
/// <summary>微信SessionKey</summary>
|
||||
public static readonly Field SessionKey = FindByName(__.SessionKey);
|
||||
|
||||
/// <summary>微信小程序OpenId</summary>
|
||||
public static readonly Field OpenId = FindByName(__.OpenId);
|
||||
|
||||
/// <summary>添加时间</summary>
|
||||
public static readonly Field AddTime = FindByName(__.AddTime);
|
||||
|
||||
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
||||
}
|
||||
|
||||
/// <summary>取得小程序Session字段名称的快捷方式</summary>
|
||||
public partial class __
|
||||
{
|
||||
/// <summary>编号</summary>
|
||||
public const String Id = "Id";
|
||||
|
||||
/// <summary>用户ID</summary>
|
||||
public const String UId = "UId";
|
||||
|
||||
/// <summary>登录IP</summary>
|
||||
public const String IP = "IP";
|
||||
|
||||
/// <summary>系统生成Key</summary>
|
||||
public const String Key = "Key";
|
||||
|
||||
/// <summary>微信SessionKey</summary>
|
||||
public const String SessionKey = "SessionKey";
|
||||
|
||||
/// <summary>微信小程序OpenId</summary>
|
||||
public const String OpenId = "OpenId";
|
||||
|
||||
/// <summary>添加时间</summary>
|
||||
public const String AddTime = "AddTime";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>小程序Session接口</summary>
|
||||
public partial interface IWXAppSession
|
||||
{
|
||||
#region 属性
|
||||
/// <summary>编号</summary>
|
||||
Int32 Id { get; set; }
|
||||
|
||||
/// <summary>用户ID</summary>
|
||||
Int32 UId { get; set; }
|
||||
|
||||
/// <summary>登录IP</summary>
|
||||
String IP { get; set; }
|
||||
|
||||
/// <summary>系统生成Key</summary>
|
||||
String Key { get; set; }
|
||||
|
||||
/// <summary>微信SessionKey</summary>
|
||||
String SessionKey { get; set; }
|
||||
|
||||
/// <summary>微信小程序OpenId</summary>
|
||||
String OpenId { get; set; }
|
||||
|
||||
/// <summary>添加时间</summary>
|
||||
DateTime AddTime { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 获取/设置 字段值
|
||||
/// <summary>获取/设置 字段值</summary>
|
||||
/// <param name="name">字段名</param>
|
||||
/// <returns></returns>
|
||||
Object this[String name] { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace COMCMS.Core
|
||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Interceptors.Add<TimeInterceptor>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Xml.Serialization;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -198,6 +198,34 @@ namespace COMCMS.Core
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
/// <summary>
|
||||
/// 获取前几条数据
|
||||
/// </summary>
|
||||
/// <param name="kid">栏目id</param>
|
||||
/// <param name="records">条数</param>
|
||||
/// <returns></returns>
|
||||
public static IList<Product> FindTopList(int kid, int records, bool isShowSub = false)
|
||||
{
|
||||
if (!isShowSub)
|
||||
return FindAll(_.KId == kid & _.IsHide == 0, _.Id.Desc(), null, 0, records);
|
||||
else
|
||||
{
|
||||
Expression ex = _.IsHide == 0;
|
||||
List<int> kids = new List<int>();
|
||||
kids.Add(kid);
|
||||
IList<Category> subkinds = Category.FindByParentID(kid);
|
||||
if (subkinds != null && subkinds.Count > 0)
|
||||
{
|
||||
foreach (var item in subkinds)
|
||||
{
|
||||
kids.Add(item.Id);
|
||||
}
|
||||
}
|
||||
ex &= _.KId.In(kids);
|
||||
|
||||
return FindAll(ex, _.Id.Desc(), null, 0, records);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
/// <summary>快餐</summary>
|
||||
public partial class Food : Entity<Food>
|
||||
{
|
||||
#region 对象操作
|
||||
static Food()
|
||||
{
|
||||
// 累加字段
|
||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Price = Math.Round(Price, 6);
|
||||
MarketPrice = Math.Round(MarketPrice, 6);
|
||||
SpecialPrice = Math.Round(SpecialPrice, 6);
|
||||
Fare = Math.Round(Fare, 6);
|
||||
Discount = Math.Round(Discount, 6);
|
||||
//if (!Dirtys[nameof(UpdateTime)]) nameof(UpdateTime) = DateTime.Now;
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Food[快餐]数据……");
|
||||
|
||||
// var entity = new Food();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.BId = 0;
|
||||
// entity.ShopId = 0;
|
||||
// entity.CId = 0;
|
||||
// entity.SupportId = 0;
|
||||
// entity.Title = "abc";
|
||||
// entity.ItemNO = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
// entity.Unit = "abc";
|
||||
// entity.Spec = "abc";
|
||||
// entity.Color = "abc";
|
||||
// entity.Weight = "abc";
|
||||
// entity.Price = 0.0;
|
||||
// entity.MarketPrice = 0.0;
|
||||
// entity.SpecialPrice = 0.0;
|
||||
// entity.Fare = 0.0;
|
||||
// entity.Discount = 0.0;
|
||||
// entity.Material = "abc";
|
||||
// entity.Front = "abc";
|
||||
// entity.Credits = 0;
|
||||
// entity.Stock = 0;
|
||||
// entity.WarnStock = 0;
|
||||
// entity.IsSubProduct = 0;
|
||||
// entity.PPId = 0;
|
||||
// entity.Content = "abc";
|
||||
// entity.Parameters = "abc";
|
||||
// entity.Keyword = "abc";
|
||||
// entity.Description = "abc";
|
||||
// entity.LinkURL = "abc";
|
||||
// entity.TitleColor = "abc";
|
||||
// entity.TemplateFile = "abc";
|
||||
// entity.IsRecommend = 0;
|
||||
// entity.IsHide = 0;
|
||||
// entity.IsLock = 0;
|
||||
// entity.IsDel = 0;
|
||||
// entity.IsTop = 0;
|
||||
// entity.IsBest = 0;
|
||||
// entity.IsComment = 0;
|
||||
// entity.IsMember = 0;
|
||||
// entity.IsNew = 0;
|
||||
// entity.IsSpecial = 0;
|
||||
// entity.IsPromote = 0;
|
||||
// entity.IsHotSales = 0;
|
||||
// entity.IsBreakup = 0;
|
||||
// entity.IsShelves = 0;
|
||||
// entity.IsVerify = 0;
|
||||
// entity.Hits = 0;
|
||||
// entity.IsGift = 0;
|
||||
// entity.IsPart = 0;
|
||||
// entity.Sequence = 0;
|
||||
// entity.CommentCount = 0;
|
||||
// entity.Icon = "abc";
|
||||
// entity.ClassName = "abc";
|
||||
// entity.BannerImg = "abc";
|
||||
// entity.Pic = "abc";
|
||||
// entity.AdsId = 0;
|
||||
// entity.Tags = "abc";
|
||||
// entity.ItemImg = "abc";
|
||||
// entity.Service = "abc";
|
||||
// entity.AuthorId = 0;
|
||||
// entity.AddTime = DateTime.Now;
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Location = "abc";
|
||||
// entity.FilePath = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Food[快餐]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static Food FindById(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||
|
||||
// 单对象缓存
|
||||
//return Meta.SingleCache[id];
|
||||
|
||||
return Find(_.Id == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace COMCMS.Core
|
||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Interceptors.Add<TimeInterceptor>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -1,180 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Xml.Serialization;
|
||||
using NewLife;
|
||||
using NewLife.Data;
|
||||
using NewLife.Log;
|
||||
using NewLife.Model;
|
||||
using NewLife.Reflection;
|
||||
using NewLife.Threading;
|
||||
using NewLife.Web;
|
||||
using XCode;
|
||||
using XCode.Cache;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using XCode.Membership;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
/// <summary>酒店房间</summary>
|
||||
public partial class HotelRoom : Entity<HotelRoom>
|
||||
{
|
||||
#region 对象操作
|
||||
static HotelRoom()
|
||||
{
|
||||
// 累加字段
|
||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
/// <param name="isNew">是否插入</param>
|
||||
public override void Valid(Boolean isNew)
|
||||
{
|
||||
// 如果没有脏数据,则不需要进行任何处理
|
||||
if (!HasDirty) return;
|
||||
|
||||
// 在新插入数据或者修改了指定字段时进行修正
|
||||
// 货币保留6位小数
|
||||
Price = Math.Round(Price, 6);
|
||||
MarketPrice = Math.Round(MarketPrice, 6);
|
||||
SpecialPrice = Math.Round(SpecialPrice, 6);
|
||||
Fare = Math.Round(Fare, 6);
|
||||
Discount = Math.Round(Discount, 6);
|
||||
//if (!Dirtys[nameof(UpdateTime)]) nameof(UpdateTime) = DateTime.Now;
|
||||
}
|
||||
|
||||
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
//protected override void InitData()
|
||||
//{
|
||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||
// if (Meta.Count > 0) return;
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化HotelRoom[酒店房间]数据……");
|
||||
|
||||
// var entity = new HotelRoom();
|
||||
// entity.Id = 0;
|
||||
// entity.KId = 0;
|
||||
// entity.BId = 0;
|
||||
// entity.ShopId = 0;
|
||||
// entity.CId = 0;
|
||||
// entity.SupportId = 0;
|
||||
// entity.Title = "abc";
|
||||
// entity.ItemNO = "abc";
|
||||
// entity.SubTitle = "abc";
|
||||
// entity.Unit = "abc";
|
||||
// entity.Spec = "abc";
|
||||
// entity.Color = "abc";
|
||||
// entity.Weight = "abc";
|
||||
// entity.Price = 0.0;
|
||||
// entity.MarketPrice = 0.0;
|
||||
// entity.SpecialPrice = 0.0;
|
||||
// entity.Fare = 0.0;
|
||||
// entity.Discount = 0.0;
|
||||
// entity.Material = "abc";
|
||||
// entity.Front = "abc";
|
||||
// entity.Credits = 0;
|
||||
// entity.Stock = 0;
|
||||
// entity.WarnStock = 0;
|
||||
// entity.IsSubProduct = 0;
|
||||
// entity.PPId = 0;
|
||||
// entity.Content = "abc";
|
||||
// entity.Parameters = "abc";
|
||||
// entity.Keyword = "abc";
|
||||
// entity.Description = "abc";
|
||||
// entity.LinkURL = "abc";
|
||||
// entity.TitleColor = "abc";
|
||||
// entity.TemplateFile = "abc";
|
||||
// entity.IsRecommend = 0;
|
||||
// entity.IsHide = 0;
|
||||
// entity.IsLock = 0;
|
||||
// entity.IsDel = 0;
|
||||
// entity.IsTop = 0;
|
||||
// entity.IsBest = 0;
|
||||
// entity.IsComment = 0;
|
||||
// entity.IsMember = 0;
|
||||
// entity.IsNew = 0;
|
||||
// entity.IsSpecial = 0;
|
||||
// entity.IsPromote = 0;
|
||||
// entity.IsHotSales = 0;
|
||||
// entity.IsBreakup = 0;
|
||||
// entity.IsShelves = 0;
|
||||
// entity.IsVerify = 0;
|
||||
// entity.Hits = 0;
|
||||
// entity.IsGift = 0;
|
||||
// entity.IsPart = 0;
|
||||
// entity.Sequence = 0;
|
||||
// entity.CommentCount = 0;
|
||||
// entity.Icon = "abc";
|
||||
// entity.ClassName = "abc";
|
||||
// entity.BannerImg = "abc";
|
||||
// entity.Pic = "abc";
|
||||
// entity.AdsId = 0;
|
||||
// entity.Tags = "abc";
|
||||
// entity.ItemImg = "abc";
|
||||
// entity.Service = "abc";
|
||||
// entity.AuthorId = 0;
|
||||
// entity.AddTime = DateTime.Now;
|
||||
// entity.UpdateTime = DateTime.Now;
|
||||
// entity.Location = "abc";
|
||||
// entity.FilePath = "abc";
|
||||
// entity.PriceList = "abc";
|
||||
// entity.Insert();
|
||||
|
||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化HotelRoom[酒店房间]数据!");
|
||||
//}
|
||||
|
||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||
///// <returns></returns>
|
||||
//public override Int32 Insert()
|
||||
//{
|
||||
// return base.Insert();
|
||||
//}
|
||||
|
||||
///// <summary>已重载。在事务保护范围内处理业务,位于Valid之后</summary>
|
||||
///// <returns></returns>
|
||||
//protected override Int32 OnDelete()
|
||||
//{
|
||||
// return base.OnDelete();
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 扩展属性
|
||||
|
||||
#endregion
|
||||
|
||||
#region 扩展查询
|
||||
/// <summary>根据编号查找</summary>
|
||||
/// <param name="id">编号</param>
|
||||
/// <returns>实体对象</returns>
|
||||
public static HotelRoom FindById(Int32 id)
|
||||
{
|
||||
if (id <= 0) return null;
|
||||
|
||||
// 实体缓存
|
||||
if (Meta.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||
|
||||
// 单对象缓存
|
||||
//return Meta.SingleCache[id];
|
||||
|
||||
return Find(_.Id == id);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 高级查询
|
||||
#endregion
|
||||
|
||||
#region 业务操作
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ namespace COMCMS.Core
|
||||
{
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Interceptors.Add<TimeInterceptor>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace COMCMS.Core
|
||||
//df.Add(__.RequestType);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Interceptors.Add<TimeInterceptor>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace COMCMS.Core
|
||||
//df.Add(__.RuleId);
|
||||
|
||||
// 过滤器 UserModule、TimeModule、IPModule
|
||||
Meta.Modules.Add<TimeModule>();
|
||||
Meta.Interceptors.Add<TimeInterceptor>();
|
||||
}
|
||||
|
||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using XCode;
|
||||
using XCode.Configuration;
|
||||
using XCode.DataAccessLayer;
|
||||
using NewLife;
|
||||
|
||||
namespace COMCMS.Core
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web.Views") > -1)
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
@@ -174,7 +174,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web.Views") > -1)
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
@@ -251,7 +251,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
entity.Location = ArticleCategory.GetNewLocation(model.PId);
|
||||
entity.Level = ArticleCategory.GetNewLevel(model.PId);
|
||||
//修改文章的location
|
||||
IList<Article> alist = Article.FindAll(Article._.KId == model.Id, null, null, 0, 0);
|
||||
IList<Article> alist = Article.FindAll(Article._.KId == model.Id, Article._.Id.Desc(), null, 0, 0);
|
||||
if (alist != null && alist.Count > 0)
|
||||
{
|
||||
foreach (var a in alist)
|
||||
@@ -347,7 +347,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//修改所有文章的路径
|
||||
if (idNeedUpdateAllArticleFilePath)
|
||||
{
|
||||
IList<Article> listArticles = Article.FindAll(Article._.KId == entity.Id, null, null, 0, 0);
|
||||
IList<Article> listArticles = Article.FindAll(Article._.KId == entity.Id, Article._.Id.Desc(), null, 0, 0);
|
||||
if(listArticles !=null && listArticles.Count > 0)
|
||||
{
|
||||
foreach (var item in listArticles)
|
||||
|
||||
@@ -53,11 +53,297 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
public IActionResult GetDirList(string subdir)
|
||||
{
|
||||
//string attachPath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
List<DirInfo> list = getAllAttach(subdir);
|
||||
return Json(new { code = 0, message = "success", data = list });
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取指定目录下的文件
|
||||
[HttpPost]
|
||||
[MyAuthorize("viewlist", "attach", "JSON")]
|
||||
public IActionResult GetFileList(string path)
|
||||
{
|
||||
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
string currentPath = basePath;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
currentPath = Path.Combine(basePath, path.TrimStart('/').Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||
}
|
||||
|
||||
if (!Directory.Exists(currentPath))
|
||||
{
|
||||
return Json(new { code = 1, message = "目录不存在" });
|
||||
}
|
||||
|
||||
//Directory.GetDirectories()
|
||||
return Json(tip);
|
||||
List<AttachFileInfo> list = new List<AttachFileInfo>();
|
||||
DirectoryInfo dir = new DirectoryInfo(currentPath);
|
||||
|
||||
// 获取子目录
|
||||
foreach (var d in dir.GetDirectories())
|
||||
{
|
||||
if (d.Name.Equals("_thumbs", StringComparison.OrdinalIgnoreCase)) continue; // 过滤缩略图目录
|
||||
list.Add(new AttachFileInfo
|
||||
{
|
||||
name = d.Name,
|
||||
path = (string.IsNullOrEmpty(path) ? "" : path + "/") + d.Name,
|
||||
updateTime = d.LastWriteTime,
|
||||
isDir = true,
|
||||
type = "folder"
|
||||
});
|
||||
}
|
||||
|
||||
// 获取文件
|
||||
foreach (var f in dir.GetFiles())
|
||||
{
|
||||
string ext = f.Extension.ToLower();
|
||||
string type = "file";
|
||||
if (IsImage(ext)) type = "image";
|
||||
else if (IsVideo(ext)) type = "video";
|
||||
|
||||
list.Add(new AttachFileInfo
|
||||
{
|
||||
name = f.Name,
|
||||
path = (string.IsNullOrEmpty(path) ? "" : path + "/") + f.Name,
|
||||
ext = ext,
|
||||
size = f.Length,
|
||||
updateTime = f.LastWriteTime,
|
||||
isDir = false,
|
||||
type = type
|
||||
});
|
||||
}
|
||||
|
||||
return Json(new { code = 0, message = "success", data = list });
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建文件夹
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "attach", "JSON")]
|
||||
public IActionResult CreateDir(string path, string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name)) return Json(new { code = 1, message = "文件夹名称不能为空" });
|
||||
if (!IsSafeName(name)) return Json(new { code = 1, message = "文件夹名称包含非法字符" });
|
||||
|
||||
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
string currentPath = basePath;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
currentPath = Path.Combine(basePath, path.TrimStart('/').Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||
}
|
||||
|
||||
string newDirPath = Path.Combine(currentPath, name);
|
||||
if (Directory.Exists(newDirPath))
|
||||
{
|
||||
return Json(new { code = 1, message = "文件夹已存在" });
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(newDirPath);
|
||||
return Json(new { code = 0, message = "创建成功" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(new { code = 1, message = "创建失败:" + ex.Message });
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除文件或文件夹
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "attach", "JSON")]
|
||||
public IActionResult DeleteFile(string path, bool isDir)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return Json(new { code = 1, message = "路径不能为空" });
|
||||
|
||||
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
string fullPath = Path.Combine(basePath, path.TrimStart('/').Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||
|
||||
// 安全检查,防止删除基础目录以外的文件
|
||||
if (!Path.GetFullPath(fullPath).StartsWith(Path.GetFullPath(basePath)))
|
||||
{
|
||||
return Json(new { code = 1, message = "非法路径" });
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (isDir)
|
||||
{
|
||||
if (Directory.Exists(fullPath))
|
||||
{
|
||||
Directory.Delete(fullPath, true); // 递归删除
|
||||
return Json(new { code = 0, message = "删除成功" });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (System.IO.File.Exists(fullPath))
|
||||
{
|
||||
System.IO.File.Delete(fullPath);
|
||||
return Json(new { code = 0, message = "删除成功" });
|
||||
}
|
||||
}
|
||||
return Json(new { code = 1, message = "文件或目录不存在" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(new { code = 1, message = "删除失败:" + ex.Message });
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 重命名文件或文件夹
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "attach", "JSON")]
|
||||
public IActionResult RenameFile(string path, string newName, bool isDir)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(newName)) return Json(new { code = 1, message = "参数不能为空" });
|
||||
if (!IsSafeName(newName)) return Json(new { code = 1, message = "新名称包含非法字符" });
|
||||
|
||||
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
string fullPath = Path.Combine(basePath, path.TrimStart('/').Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||
|
||||
// 安全检查
|
||||
if (!Path.GetFullPath(fullPath).StartsWith(Path.GetFullPath(basePath)))
|
||||
{
|
||||
return Json(new { code = 1, message = "非法路径" });
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string parentDir = Path.GetDirectoryName(fullPath);
|
||||
string newFullPath = Path.Combine(parentDir, newName);
|
||||
|
||||
if (isDir)
|
||||
{
|
||||
if (!Directory.Exists(fullPath)) return Json(new { code = 1, message = "原文件夹不存在" });
|
||||
if (Directory.Exists(newFullPath)) return Json(new { code = 1, message = "目标文件夹已存在" });
|
||||
Directory.Move(fullPath, newFullPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!System.IO.File.Exists(fullPath)) return Json(new { code = 1, message = "原文件不存在" });
|
||||
// 保持扩展名一致性检查(可选,这里简单处理,如果newName没有扩展名则加上原扩展名,或者要求用户输入完整文件名)
|
||||
// 假设前端传来的 newName 是完整文件名
|
||||
if (System.IO.File.Exists(newFullPath)) return Json(new { code = 1, message = "目标文件已存在" });
|
||||
System.IO.File.Move(fullPath, newFullPath);
|
||||
}
|
||||
return Json(new { code = 0, message = "重命名成功" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(new { code = 1, message = "重命名失败:" + ex.Message });
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 上传文件
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "attach", "JSON")]
|
||||
public async Task<IActionResult> UploadFile(string path)
|
||||
{
|
||||
// 安全检查:禁止在根目录上传
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return Json(new { code = 1, message = "根目录不允许上传文件,请选择子目录" });
|
||||
}
|
||||
|
||||
var files = Request.Form.Files;
|
||||
if (files == null || files.Count == 0)
|
||||
{
|
||||
return Json(new { code = 1, message = "请选择文件" });
|
||||
}
|
||||
|
||||
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";
|
||||
string currentPath = basePath;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
currentPath = Path.Combine(basePath, path.TrimStart('/').Replace("/", Path.DirectorySeparatorChar.ToString()));
|
||||
}
|
||||
|
||||
// 安全检查:防止目录遍历
|
||||
if (!Path.GetFullPath(currentPath).StartsWith(Path.GetFullPath(basePath)))
|
||||
{
|
||||
return Json(new { code = 1, message = "非法路径" });
|
||||
}
|
||||
|
||||
if (!Directory.Exists(currentPath))
|
||||
{
|
||||
return Json(new { code = 1, message = "目录不存在" });
|
||||
}
|
||||
|
||||
int successCount = 0;
|
||||
string msg = "";
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
string fileName = file.FileName;
|
||||
// 安全检查:文件名
|
||||
if (!IsSafeName(fileName))
|
||||
{
|
||||
msg += $"文件 {fileName} 名称非法; ";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 检查扩展名
|
||||
string ext = Path.GetExtension(fileName).ToLower();
|
||||
string allowedExts = _attachsetting.FileAllowedExtensions + "," + _attachsetting.ImageAllowedExtensions + "," + _attachsetting.MediaAllowedExtensions;
|
||||
if (!allowedExts.ToLower().Split(',').Contains(ext.TrimStart('.')))
|
||||
{
|
||||
msg += $"文件 {fileName} 类型不允许; ";
|
||||
continue;
|
||||
}
|
||||
|
||||
string fullPath = Path.Combine(currentPath, fileName);
|
||||
// 如果文件存在,重命名
|
||||
if (System.IO.File.Exists(fullPath))
|
||||
{
|
||||
string nameNoExt = Path.GetFileNameWithoutExtension(fileName);
|
||||
fileName = $"{nameNoExt}_{Utils.GetOrderNum()}{ext}";
|
||||
fullPath = Path.Combine(currentPath, fileName);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using (var stream = new FileStream(fullPath, FileMode.Create))
|
||||
{
|
||||
await file.CopyToAsync(stream);
|
||||
}
|
||||
successCount++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
msg += $"文件 {fileName} 上传失败: {ex.Message}; ";
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0)
|
||||
{
|
||||
return Json(new { code = 0, message = $"成功上传 {successCount} 个文件. {msg}" });
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json(new { code = 1, message = msg });
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 辅助方法
|
||||
private bool IsImage(string ext)
|
||||
{
|
||||
return new[] { ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".webp" }.Contains(ext);
|
||||
}
|
||||
|
||||
private bool IsVideo(string ext)
|
||||
{
|
||||
return new[] { ".mp4", ".avi", ".mov", ".wmv", ".flv", ".mkv" }.Contains(ext);
|
||||
}
|
||||
|
||||
private bool IsSafeName(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str)) return false;
|
||||
// 允许字母、数字、下划线、中划线、点、中文
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(str, @"^[\u4e00-\u9fa5a-zA-Z0-9_\-\.]+$");
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -76,17 +362,22 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
basePath += subdir.Replace("/", Path.DirectorySeparatorChar.ToString());
|
||||
}
|
||||
|
||||
if (!Directory.Exists(basePath)) return list;
|
||||
|
||||
string[] arrDirs = Directory.GetDirectories(basePath);
|
||||
|
||||
if (arrDirs != null && arrDirs.Length > 0)
|
||||
{
|
||||
foreach (var item in arrDirs)
|
||||
{
|
||||
string nextSubDir = subdir + "/" + item.Substring(item.LastIndexOf(Path.DirectorySeparatorChar)+1);
|
||||
string dirName = item.Substring(item.LastIndexOf(Path.DirectorySeparatorChar) + 1);
|
||||
if (dirName.Equals("_thumbs", StringComparison.OrdinalIgnoreCase)) continue; // 过滤缩略图目录
|
||||
|
||||
string nextSubDir = string.IsNullOrEmpty(subdir) ? dirName : subdir + "/" + dirName;
|
||||
var tpmList = getAllAttach(nextSubDir);
|
||||
list.Add(new DirInfo()
|
||||
{
|
||||
name = item.Substring(item.LastIndexOf(Path.DirectorySeparatorChar)+1),
|
||||
name = dirName,
|
||||
path = nextSubDir,
|
||||
//fullPath = item,
|
||||
subList = tpmList
|
||||
@@ -98,4 +389,22 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class DirInfo
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string path { get; set; }
|
||||
public List<DirInfo> subList { get; set; }
|
||||
}
|
||||
|
||||
public class AttachFileInfo
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string path { get; set; }
|
||||
public string ext { get; set; }
|
||||
public long size { get; set; }
|
||||
public DateTime updateTime { get; set; }
|
||||
public bool isDir { get; set; }
|
||||
public string type { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
#region 后台主界面
|
||||
public IActionResult Main()
|
||||
{
|
||||
string remoteip = Request.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
string remoteip = Utils.GetIP();
|
||||
string host = Request.HttpContext.Request.Host.Host;
|
||||
string port = Request.HttpContext.Connection.RemotePort.ToString();
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
string strUserName = Request.Form["username"];
|
||||
string strPassWord = Request.Form["password"];
|
||||
string code = Request.Form["code"];
|
||||
|
||||
if (strUserName.Length % 8 != 0)
|
||||
{
|
||||
@@ -69,6 +70,21 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Other = "reload";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (Utils.GetSetting("SystemSetting:AdminLoginWithCode") == "1")
|
||||
{
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
tip.Message = "请输入验证码!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (!VerifyCodeHelper.GetSingleObj().VerifyCodeIsOK(code))
|
||||
{
|
||||
tip.Message = "验证码错误!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
|
||||
//解密
|
||||
string username = "";
|
||||
string password = "";
|
||||
|
||||
@@ -502,7 +502,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= Core.Admin._.UserName.Contains(keyword);
|
||||
|
||||
IList<Core.Admin> list = Core.Admin.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
IList<Core.Admin> list = Core.Admin.FindAll(ex, Admin._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
totalCount = Core.Admin.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
}
|
||||
@@ -948,7 +948,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
IList<Member> list = Member.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
IList<Member> list = Member.FindAll(ex, Member._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
totalCount = Member.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= (Order._.Title.Contains(keyword) | Order._.OrderNum.Contains(keyword) | Order._.RealName.Contains(keyword) | Order._.Address.Contains(keyword));
|
||||
|
||||
IList<Order> list = Order.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
IList<Order> list = Order.FindAll(ex, Order._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
long totalCount = Order.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||
@@ -327,7 +327,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= OnlinePayOrder._.Title.Contains(keyword);
|
||||
|
||||
IList<OnlinePayOrder> list = OnlinePayOrder.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
IList<OnlinePayOrder> list = OnlinePayOrder.FindAll(ex, OnlinePayOrder._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
long totalCount = OnlinePayOrder.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||
|
||||
@@ -115,6 +115,85 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
#region 编辑事件详情
|
||||
[HttpGet]
|
||||
[MyAuthorize("add", "eventkey")]
|
||||
public IActionResult EditEventKey(int id)
|
||||
{
|
||||
TargetEvent entity = TargetEvent.Find(TargetEvent._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
Admin.WriteLogActions("查看/编辑事件详情(id:" + entity.Id + ");");
|
||||
return View(entity);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "eventkey","JSON")]
|
||||
public IActionResult EditEventKey(TargetEvent model)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(model.EventKey))
|
||||
{
|
||||
tip.Message = "请填写事件KEY";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(model.EventName))
|
||||
{
|
||||
tip.Message = "请填写事件名称";
|
||||
return Json(tip);
|
||||
}
|
||||
TargetEvent entity = TargetEvent.Find(TargetEvent._.Id == model.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.EventKey != model.EventKey)
|
||||
{
|
||||
if (TargetEvent.FindCount(TargetEvent._.EventKey == model.EventKey, null, null, 0, 0) > 0)
|
||||
{
|
||||
tip.Message = "事件key已经存在,请重新填写一个";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
entity.EventKey = model.EventKey;
|
||||
entity.EventName = model.EventName;
|
||||
entity.Rank = model.Rank;
|
||||
if (string.IsNullOrWhiteSpace(Request.Form["IsDisable"]) || Request.Form["IsDisable"] != "1")
|
||||
entity.IsDisable = 0;
|
||||
else
|
||||
entity.IsDisable = 1;
|
||||
entity.Update();
|
||||
Admin.WriteLogActions("编辑事件详情(id:" + entity.Id + ");");
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑事件权限详情成功";
|
||||
tip.ReturnUrl = "close";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除事件权限
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "eventkey", "JSON")]
|
||||
public JsonResult DelEventKey(int id)
|
||||
{
|
||||
TargetEvent entity = TargetEvent.Find(TargetEvent._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
Admin.WriteLogActions("删除事件详情(" + JsonConvert.SerializeObject(entity) + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除事件权限详情成功";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 后台栏目管理
|
||||
@@ -339,6 +418,27 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "删除后台菜单成功";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//修改栏目是否隐藏
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "adminmenu", "JSON")]
|
||||
public IActionResult DoChangeAdminMenuHide(int id)
|
||||
{
|
||||
AdminMenu entity = AdminMenu.Find(AdminMenu._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.IsHide == 1)
|
||||
entity.IsHide = 0;
|
||||
else
|
||||
entity.IsHide = 1;
|
||||
entity.Update();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "修改菜单隐藏状态成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 系统运行日志
|
||||
@@ -398,7 +498,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
using (Stream stream = fileProvider.GetFileInfo(logname).CreateReadStream())
|
||||
{
|
||||
byte[] buffer = new byte[stream.Length];
|
||||
await stream.ReadAsync(buffer, 0, buffer.Length);
|
||||
await stream.ReadExactlyAsync(buffer);
|
||||
detail.Append(Encoding.Default.GetString(buffer));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,24 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//获取上级栏目
|
||||
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
||||
ViewBag.ListTree = list;
|
||||
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||
List<string> listTpls = new List<string>();
|
||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Product")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
foreach (var type in types)
|
||||
{
|
||||
string viewName = type.Name.Replace("Views_Product_", "") + ".cshtml";
|
||||
listTpls.Add(viewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewBag.ListTpl = listTpls;
|
||||
//获取模板
|
||||
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
||||
//ViewBag.ListTpl = listtpl;
|
||||
@@ -53,6 +71,33 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "商品栏目标题不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.FilePath))
|
||||
{
|
||||
if (!model.FilePath.StartsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径请以/开头!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.FilePath.EndsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径结尾不用加上/";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (model.FilePath.Count(x => x == '/') > 4)
|
||||
{
|
||||
tip.Message = "最多只能四级路径!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 1))
|
||||
{
|
||||
tip.Message = "栏目路径不可用,请重新填写!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
model.Insert();
|
||||
Core.Admin.WriteLogActions("添加商品栏目(id:" + model.Id + ");");
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
@@ -74,9 +119,25 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//获取上级栏目
|
||||
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
||||
ViewBag.ListTree = list;
|
||||
//获取模板
|
||||
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
||||
//ViewBag.ListTpl = listtpl;
|
||||
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||
List<string> listTpls = new List<string>();
|
||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||
foreach (var asmItem in asms)
|
||||
{
|
||||
string fullName = asmItem.GetName().ToString();
|
||||
if (fullName.IndexOf("COMCMS.Web") > -1)
|
||||
{
|
||||
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Product")).ToList();
|
||||
if (types.Count == 0) continue;
|
||||
foreach (var type in types)
|
||||
{
|
||||
string viewName = type.Name.Replace("Views_Product_", "") + ".cshtml";
|
||||
listTpls.Add(viewName);
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewBag.ListTpl = listTpls;
|
||||
|
||||
Core.Admin.WriteLogActions("查看/编辑商品栏目(id:" + id + ")页面;");
|
||||
return View(entity);
|
||||
}
|
||||
@@ -102,6 +163,30 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "系统找不到本记录!";
|
||||
Json(tip);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.FilePath))
|
||||
{
|
||||
if (!model.FilePath.StartsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径请以/开头!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.FilePath.EndsWith("/"))
|
||||
{
|
||||
tip.Message = "栏目路径结尾不用加上/";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (model.FilePath.Count(x => x == '/') > 4)
|
||||
{
|
||||
tip.Message = "最多只能四级路径!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 1))
|
||||
{
|
||||
tip.Message = "栏目路径不可用,请重新填写!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (entity.PId != model.PId)
|
||||
{
|
||||
@@ -147,6 +232,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
entity.KindDomain = model.KindDomain;
|
||||
entity.Rank = model.Rank;
|
||||
entity.Pic = model.Pic;
|
||||
entity.FilePath = model.FilePath;
|
||||
|
||||
|
||||
entity.Save();
|
||||
|
||||
@@ -28,6 +28,14 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
pinyin = pcategory.FilePath+"/";
|
||||
}
|
||||
}
|
||||
else if(t == "category" && pid > 0)
|
||||
{
|
||||
Category pcategory = Category.FindById(pid);
|
||||
if (pcategory != null && !string.IsNullOrEmpty(pcategory.FilePath))
|
||||
{
|
||||
pinyin = pcategory.FilePath + "/";
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
|
||||
@@ -221,9 +221,17 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
||||
string content = "";
|
||||
if (System.IO.File.Exists(file))
|
||||
{
|
||||
try
|
||||
{
|
||||
content = System.IO.File.ReadAllText(file);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
// 如果读取文件失败,继续使用空内容
|
||||
}
|
||||
}
|
||||
ViewBag.content = content;
|
||||
Admin.WriteLogActions("查看Robots.txt;");
|
||||
return View();
|
||||
@@ -233,15 +241,18 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
public IActionResult Robots(string content)
|
||||
{
|
||||
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
||||
if (System.IO.File.Exists(file))
|
||||
try
|
||||
{
|
||||
//写入覆盖
|
||||
System.IO.File.WriteAllText(file, content);
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.IO.File.WriteAllText(file, content);
|
||||
NewLife.Log.XTrace.WriteException(ex);
|
||||
tip.Message = "修改Robots.txt失败:" + ex.Message;
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "修改Robots.txt成功";
|
||||
Admin.WriteLogActions("修改Robots.txt成功;");
|
||||
|
||||
@@ -16,7 +16,6 @@ using System.Drawing;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using NewLife.UserGroup.WebUploader;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
@@ -809,99 +808,6 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
return Content(JsonConvert.SerializeObject(new { status = status, msg = msg, name = name, path = path, thumb = thumb, size = size, ext = ext }), "text/plain");
|
||||
}
|
||||
|
||||
#region 分片上传文件,可断点续传
|
||||
|
||||
/// <summary>
|
||||
/// 保存文件或者分块
|
||||
/// </summary>
|
||||
/// <param name="md5">文件md5</param>
|
||||
/// <param name="chunk">分块号</param>
|
||||
/// <param name="chunks">分块总数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult SaveFile(string md5, int? chunk, int? chunks)
|
||||
{
|
||||
var tempDir = "UploadTemp"; // 缓存文件夹
|
||||
var targetDir = "UploadFile"; // 目标文件夹
|
||||
|
||||
var file = Request.Form.Files[0];
|
||||
|
||||
file.SaveFileOrChunkFile(targetDir, tempDir, md5, chunks, chunk);
|
||||
|
||||
return Json(new
|
||||
{
|
||||
Data = new { md5 = md5, url = Path.Combine("/", targetDir, file.FileName) },
|
||||
Message = "ok",
|
||||
Result = true
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并文件
|
||||
/// </summary>
|
||||
/// <param name="md5">文件md5</param>
|
||||
/// <param name="fileName">文件名</param>
|
||||
/// <param name="chunks">分块数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public IActionResult MergeFile(string md5, string fileName, int chunks)
|
||||
{
|
||||
var tempDir = "UploadTemp";
|
||||
var targetDir = "UploadFile";
|
||||
|
||||
var (res, msg) = tempDir.Merge(targetDir, fileName, md5, chunks);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
return Json(new
|
||||
{
|
||||
Message = msg,
|
||||
Result = false
|
||||
});
|
||||
}
|
||||
|
||||
return Json(new
|
||||
{
|
||||
Data = new { md5 = md5, url = Path.Combine("/", targetDir, fileName) },
|
||||
Message = "ok",
|
||||
Result = true
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查文件或分块是否存在
|
||||
/// </summary>
|
||||
/// <param name="md5">文件md5</param>
|
||||
/// <param name="fileName">文件名</param>
|
||||
/// <param name="chunk">分块号</param>
|
||||
/// <returns></returns>
|
||||
public IActionResult CheckFile(string md5, string fileName, int? chunk)
|
||||
{
|
||||
var tempDir = "UploadTemp";
|
||||
var targetDir = "UploadFile";
|
||||
|
||||
string filePath;
|
||||
|
||||
//分片文件
|
||||
if (chunk != null)
|
||||
{
|
||||
filePath = Path.Combine(tempDir, md5, $"{chunk}.part");
|
||||
}
|
||||
else
|
||||
{
|
||||
filePath = Path.Combine(targetDir, fileName);
|
||||
}
|
||||
|
||||
var exists = System.IO.File.Exists(filePath);
|
||||
|
||||
return Json(new
|
||||
{
|
||||
Data = fileName != null && exists ? (object)new { md5 = md5, url = Path.Combine("/", targetDir, fileName) } : null,
|
||||
Result = exists
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 帮助方法
|
||||
@@ -909,7 +815,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
// 保存为byte[]
|
||||
byte[] byData = new byte[stream.Length];
|
||||
stream.Read(byData, 0, byData.Length);
|
||||
stream.ReadExactly(byData);
|
||||
stream.Dispose();
|
||||
return byData;
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
IList<WeixinRequestRule> list = WeixinRequestRule.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
IList<WeixinRequestRule> list = WeixinRequestRule.FindAll(ex, WeixinRequestRule._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
long totalCount = WeixinRequestRule.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
Admin.WriteLogActions($"查看公众号自定义回复规则({page});");
|
||||
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
@@ -670,7 +670,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
ex &= WeixinRequestRule._.Keywords.Contains(keyword);
|
||||
}
|
||||
}
|
||||
IList<WeixinRequestRule> list = WeixinRequestRule.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
IList<WeixinRequestRule> list = WeixinRequestRule.FindAll(ex, WeixinRequestRule._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
long totalCount = WeixinRequestRule.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
Admin.WriteLogActions($"查看公众号点击事件自定义回复规则({page});");
|
||||
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showDialog('addarticlekind','添加文章栏目','/AdminCP/Article/AddArticleCategory',0,0);">
|
||||
@@ -38,12 +35,12 @@
|
||||
@foreach (var m in Model)
|
||||
{
|
||||
<tr class="treegrid-@m.Id @(m.PId !=0?"treegrid-parent-"+m.PId:"") ">
|
||||
<td>@m.KindName</td>
|
||||
<td><a href="@ViewsHelper.EchoURL(m)" target="_blank" title="新窗口打开栏目">@m.KindName</a></td>
|
||||
<td>
|
||||
@m.Id
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="input-group"><input type="number" class="form-control" id="ac_rank_@(m.Id)" name="ac_rank_@(m.Id)" value="@m.Rank" placeholder="请输入一个数字,越小排越前"><a class="input-group-addon btn btn-primary" title="修改保存" href="javascript:;" onclick="doSaveRank(@(m.Id))"><i class="fa fa-save"></i></a></div>
|
||||
<div class="input-group"><input type="number" class="form-control input-sm" id="ac_rank_@(m.Id)" name="ac_rank_@(m.Id)" value="@m.Rank" placeholder="请输入一个数字,越小排越前"><a class="input-group-addon btn btn-primary" title="修改保存" href="javascript:;" onclick="doSaveRank(@(m.Id))"><i class="fa fa-save"></i></a></div>
|
||||
</td>
|
||||
<td class="text-center">@m.Counts</td>
|
||||
<td class="text-center">
|
||||
|
||||
@@ -9,21 +9,13 @@
|
||||
}
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline" onsubmit="return doSearch(); return false;">
|
||||
<div>
|
||||
<label class="control-label">文章栏目:</label>
|
||||
|
||||
<select class="form-control" name="kid" id="kid">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
文章栏目:<select name="kid" id="kid">
|
||||
<option value="0">所有栏目</option>
|
||||
@foreach (var m in ViewBag.ListKinds)
|
||||
{
|
||||
@@ -40,16 +32,26 @@
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<label class="checkbox-inline i-checks">
|
||||
</li>
|
||||
<li>
|
||||
<label class="checkbox-inline i-checks" for="isshowsub">
|
||||
<input type="checkbox" value="1" name="isshowsub" id="isshowsub" /> 显示下级栏目文章
|
||||
</label>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
@if (AdminUtils.CheckAdminPower("add", "article"))
|
||||
{
|
||||
@@ -151,7 +153,7 @@
|
||||
title: '排序',
|
||||
width: 130,
|
||||
formatter: function (value, row, index) {
|
||||
return '<div class="input-group"><input type="number" class="form-control" id="ac_rank_' + row["id"] + '" name="ac_rank_' + row["id"] + '" value="' + value + '" placeholder="请输入一个数字,越小排越前"><a class="input-group-addon btn btn-primary" title="修改保存" href="javascript:;" onclick="doSaveSequence(' + row["id"] + ')"><i class="fa fa-save"></i></a></div>'
|
||||
return '<div class="input-group"><input type="number" class="form-control input-sm" id="ac_rank_' + row["id"] + '" name="ac_rank_' + row["id"] + '" value="' + value + '" placeholder="请输入一个数字,越小排越前"><a class="input-group-addon btn btn-primary" title="修改保存" href="javascript:;" onclick="doSaveSequence(' + row["id"] + ')"><i class="fa fa-save"></i></a></div>'
|
||||
}
|
||||
}, {
|
||||
field: 'addTime',
|
||||
|
||||
@@ -1,75 +1,673 @@
|
||||
@{
|
||||
@using Newtonsoft.Json
|
||||
@{
|
||||
ViewBag.title = "附件管理";
|
||||
var folderJson = ViewBag.folderJson as string;
|
||||
}
|
||||
<style>
|
||||
/* Grid View Styles */
|
||||
.file-box {
|
||||
float: left;
|
||||
width: 120px;
|
||||
height: 140px;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
margin: 5px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.file-box:hover {
|
||||
background-color: #f8f8f8;
|
||||
border-color: #ddd;
|
||||
box-shadow: 0 0 5px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.file-box.active {
|
||||
background-color: #e8f0fe;
|
||||
border-color: #1c84c6;
|
||||
}
|
||||
|
||||
.file-icon {
|
||||
height: 80px;
|
||||
line-height: 80px;
|
||||
font-size: 48px;
|
||||
color: #666;
|
||||
margin-bottom: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.file-icon img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.file-name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.file-info {
|
||||
font-size: 10px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* List View Styles */
|
||||
.file-list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8px 15px;
|
||||
border-bottom: 1px solid #eee;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.file-list-item:hover {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.file-list-item.active {
|
||||
background-color: #e8f0fe;
|
||||
}
|
||||
|
||||
.file-list-icon {
|
||||
width: 30px;
|
||||
font-size: 20px;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.file-list-icon img {
|
||||
max-width: 100%;
|
||||
max-height: 30px;
|
||||
}
|
||||
|
||||
.file-list-name {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.file-list-info {
|
||||
width: 150px;
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.file-list-date {
|
||||
width: 150px;
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.folder-tree {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.folder-tree ul {
|
||||
list-style: none;
|
||||
padding-left: 20px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.folder-tree li {
|
||||
padding: 2px 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.folder-tree a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
padding: 4px 8px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.folder-tree a:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.folder-tree a.active {
|
||||
background-color: #e8f0fe;
|
||||
color: #1c84c6;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.folder-tree i {
|
||||
margin-right: 5px;
|
||||
color: #f8ac59;
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
background: none;
|
||||
padding: 8px 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* Drag and Drop Overlay */
|
||||
#dropOverlay {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
z-index: 1000;
|
||||
border: 3px dashed #1c84c6;
|
||||
text-align: center;
|
||||
padding-top: 20%;
|
||||
font-size: 24px;
|
||||
color: #1c84c6;
|
||||
}
|
||||
|
||||
.ibox-content {
|
||||
position: relative;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<div class="file-manager">
|
||||
<h5>显示:</h5>
|
||||
<a href="file_manager.html#" class="file-control active">所有</a>
|
||||
<a href="file_manager.html#" class="file-control">文档</a>
|
||||
<a href="file_manager.html#" class="file-control">视频</a>
|
||||
<a href="file_manager.html#" class="file-control">图片</a>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<button class="btn btn-primary btn-block">上传文件</button>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="ibox-title">
|
||||
<h5>文件夹</h5>
|
||||
<ul class="folder-list" style="padding: 0">
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 文件</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 图片</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> Web页面</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 插图</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 电影</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html"><i class="fa fa-folder"></i> 书籍</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h5 class="tag-title">标签</h5>
|
||||
<ul class="tag-list" style="padding: 0">
|
||||
<li>
|
||||
<a href="file_manager.html">爱人</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">工作</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">家庭</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">孩子</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">假期</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">音乐</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">照片</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="file_manager.html">电影</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
<div class="ibox-tools">
|
||||
<a onclick="window.location.reload()"><i class="fa fa-refresh"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content" style="min-height: 600px; overflow-y: auto;">
|
||||
<div id="folderTree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-9">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-primary btn-sm" onclick="uploadFile()"><i class="fa fa-upload"></i> 上传</button>
|
||||
<button class="btn btn-success btn-sm" onclick="createFolder()"><i class="fa fa-plus"></i> 新建文件夹</button>
|
||||
<button class="btn btn-danger btn-sm" onclick="deleteSelected()"><i class="fa fa-trash"></i> 删除</button>
|
||||
<button class="btn btn-warning btn-sm" onclick="renameFile()"><i class="fa fa-pencil"></i> 重命名</button>
|
||||
<button class="btn btn-info btn-sm" onclick="copyLink()"><i class="fa fa-copy"></i> 复制链接</button>
|
||||
<button class="btn btn-default btn-sm" onclick="refreshFiles()"><i class="fa fa-refresh"></i> 刷新</button>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default btn-sm active" id="btnViewGrid" onclick="switchView('grid')" title="缩略图模式"><i class="fa fa-th-large"></i></button>
|
||||
<button type="button" class="btn btn-default btn-sm" id="btnViewList" onclick="switchView('list')" title="列表模式"><i class="fa fa-list"></i></button>
|
||||
</div>
|
||||
<span id="currentPathDisplay" class="text-muted" style="margin-left: 10px;">/</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content" style="min-height: 600px;" id="fileContainer">
|
||||
<div id="dropOverlay">
|
||||
<i class="fa fa-cloud-upload fa-3x"></i><br>
|
||||
松开鼠标上传文件
|
||||
</div>
|
||||
<div id="fileList" class="clearfix">
|
||||
<div class="text-center text-muted" style="padding: 50px;">正在加载...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<input type="file" id="fileInput" multiple style="display:none" onchange="doUpload()" />
|
||||
|
||||
<script>
|
||||
var currentPath = "";
|
||||
var folders = @Html.Raw(string.IsNullOrEmpty(folderJson) ? "[]" : folderJson);
|
||||
var selectedFile = null;
|
||||
var currentView = 'grid'; // 'grid' or 'list'
|
||||
var currentFilesData = []; // Store current files data for view switching
|
||||
|
||||
$(function() {
|
||||
initTree();
|
||||
loadFiles("");
|
||||
|
||||
// 点击空白处取消选择
|
||||
$(document).on('click', function(e) {
|
||||
if (!$(e.target).closest('.file-box').length &&
|
||||
!$(e.target).closest('.file-list-item').length &&
|
||||
!$(e.target).closest('.btn-group').length) {
|
||||
$('.file-box, .file-list-item').removeClass('active');
|
||||
selectedFile = null;
|
||||
}
|
||||
});
|
||||
|
||||
// Drag and Drop Support
|
||||
var $container = $('#fileContainer');
|
||||
var $overlay = $('#dropOverlay');
|
||||
var dragCounter = 0;
|
||||
|
||||
$container.on('dragenter', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
dragCounter++;
|
||||
$overlay.show();
|
||||
});
|
||||
|
||||
$container.on('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$container.on('dragleave', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
dragCounter--;
|
||||
if (dragCounter === 0) {
|
||||
$overlay.hide();
|
||||
}
|
||||
});
|
||||
|
||||
$container.on('drop', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
dragCounter = 0;
|
||||
$overlay.hide();
|
||||
|
||||
var files = e.originalEvent.dataTransfer.files;
|
||||
if (files.length > 0) {
|
||||
handleDroppedFiles(files);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function switchView(view) {
|
||||
currentView = view;
|
||||
if (view === 'grid') {
|
||||
$('#btnViewGrid').addClass('active');
|
||||
$('#btnViewList').removeClass('active');
|
||||
} else {
|
||||
$('#btnViewGrid').removeClass('active');
|
||||
$('#btnViewList').addClass('active');
|
||||
}
|
||||
renderFiles(currentFilesData);
|
||||
}
|
||||
|
||||
function initTree() {
|
||||
var treeData = convertToJsTreeData(folders);
|
||||
// Add root node
|
||||
var rootNode = {
|
||||
"id": "root",
|
||||
"text": "根目录",
|
||||
"state": { "opened": true, "selected": true },
|
||||
"icon": "fa fa-folder-open",
|
||||
"data": { "path": "" },
|
||||
"children": treeData
|
||||
};
|
||||
|
||||
$('#folderTree').jstree({
|
||||
'core': {
|
||||
'data': [rootNode],
|
||||
'check_callback': true
|
||||
},
|
||||
'plugins': ['types', 'wholerow'],
|
||||
'types': {
|
||||
'default': {
|
||||
'icon': 'fa fa-folder'
|
||||
}
|
||||
}
|
||||
}).on('select_node.jstree', function(e, data) {
|
||||
var path = data.node.data.path;
|
||||
currentPath = path;
|
||||
$('#currentPathDisplay').text(path || '/');
|
||||
loadFiles(path);
|
||||
});
|
||||
}
|
||||
|
||||
function convertToJsTreeData(nodes) {
|
||||
var data = [];
|
||||
$.each(nodes, function(i, node) {
|
||||
var item = {
|
||||
"text": node.name,
|
||||
"icon": "fa fa-folder",
|
||||
"data": { "path": node.path },
|
||||
"children": []
|
||||
};
|
||||
if (node.subList && node.subList.length > 0) {
|
||||
item.children = convertToJsTreeData(node.subList);
|
||||
}
|
||||
data.push(item);
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
function loadFiles(path) {
|
||||
$('#fileList').html('<div class="text-center text-muted" style="padding: 50px;"><i class="fa fa-spinner fa-spin"></i> 正在加载...</div>');
|
||||
selectedFile = null;
|
||||
|
||||
$.ajax({
|
||||
url: '/AdminCP/Attach/GetFileList',
|
||||
type: 'POST',
|
||||
data: { path: path },
|
||||
success: function(res) {
|
||||
if (res.code === 0) {
|
||||
currentFilesData = res.data;
|
||||
renderFiles(res.data);
|
||||
} else {
|
||||
layer.msg(res.message, {icon: 2});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
layer.msg('加载失败', {icon: 2});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderFiles(files) {
|
||||
var html = '';
|
||||
if (!files || files.length === 0) {
|
||||
html = '<div class="text-center text-muted" style="padding: 50px;">暂无文件</div>';
|
||||
} else {
|
||||
if (currentView === 'grid') {
|
||||
// Grid View
|
||||
$.each(files, function(i, file) {
|
||||
var icon = '';
|
||||
if (file.isDir) {
|
||||
icon = '<i class="fa fa-folder" style="color: #f8ac59;"></i>';
|
||||
} else if (file.type === 'image') {
|
||||
icon = '<img src="/' + '@(Config.GetSystemConfig().AttachConfigEntity.AttachPatch)/' + file.path + '" />';
|
||||
} else if (file.type === 'video') {
|
||||
icon = '<i class="fa fa-file-video-o" style="color: #23c6c8;"></i>';
|
||||
} else {
|
||||
icon = '<i class="fa fa-file-o"></i>';
|
||||
}
|
||||
|
||||
var safeName = file.name.replace(/'/g, "\\'");
|
||||
var safePath = file.path.replace(/'/g, "\\'");
|
||||
|
||||
html += '<div class="file-box" onclick="selectFile(this, \'' + safePath + '\', ' + file.isDir + ', \'' + safeName + '\')" ondblclick="openFile(\'' + safePath + '\', ' + file.isDir + ')">';
|
||||
html += '<div class="file-icon">' + icon + '</div>';
|
||||
html += '<div class="file-name" title="' + file.name + '">' + file.name + '</div>';
|
||||
if (!file.isDir) {
|
||||
html += '<div class="file-info">' + formatSize(file.size) + '</div>';
|
||||
}
|
||||
html += '</div>';
|
||||
});
|
||||
} else {
|
||||
// List View
|
||||
html += '<div class="file-list-header" style="padding: 8px 15px; border-bottom: 1px solid #ddd; font-weight: bold; color: #666; display: flex;">';
|
||||
html += '<div style="width: 40px;"></div>';
|
||||
html += '<div style="flex: 1;">名称</div>';
|
||||
html += '<div style="width: 150px; text-align: right;">大小</div>';
|
||||
html += '<div style="width: 150px; text-align: right; margin-left: 15px;">修改时间</div>';
|
||||
html += '</div>';
|
||||
|
||||
$.each(files, function(i, file) {
|
||||
var icon = '';
|
||||
if (file.isDir) {
|
||||
icon = '<i class="fa fa-folder" style="color: #f8ac59;"></i>';
|
||||
} else if (file.type === 'image') {
|
||||
icon = '<i class="fa fa-file-image-o" style="color: #1c84c6;"></i>';
|
||||
} else if (file.type === 'video') {
|
||||
icon = '<i class="fa fa-file-video-o" style="color: #23c6c8;"></i>';
|
||||
} else {
|
||||
icon = '<i class="fa fa-file-o"></i>';
|
||||
}
|
||||
|
||||
var safeName = file.name.replace(/'/g, "\\'");
|
||||
var safePath = file.path.replace(/'/g, "\\'");
|
||||
var sizeStr = file.isDir ? '-' : formatSize(file.size);
|
||||
var dateStr = file.updateTime ? file.updateTime.replace('T', ' ').substring(0, 19) : '-';
|
||||
|
||||
html += '<div class="file-list-item" onclick="selectFile(this, \'' + safePath + '\', ' + file.isDir + ', \'' + safeName + '\')" ondblclick="openFile(\'' + safePath + '\', ' + file.isDir + ')">';
|
||||
html += '<div class="file-list-icon">' + icon + '</div>';
|
||||
html += '<div class="file-list-name" title="' + file.name + '">' + file.name + '</div>';
|
||||
html += '<div class="file-list-info">' + sizeStr + '</div>';
|
||||
html += '<div class="file-list-date">' + dateStr + '</div>';
|
||||
html += '</div>';
|
||||
});
|
||||
}
|
||||
}
|
||||
$('#fileList').html(html);
|
||||
}
|
||||
|
||||
function selectFile(el, path, isDir, name) {
|
||||
$('.file-box, .file-list-item').removeClass('active');
|
||||
$(el).addClass('active');
|
||||
selectedFile = { path: path, isDir: isDir, name: name };
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
function openFile(path, isDir) {
|
||||
if (isDir) {
|
||||
currentPath = path;
|
||||
$('#currentPathDisplay').text(path || '/');
|
||||
loadFiles(path);
|
||||
} else {
|
||||
// Preview file?
|
||||
var file = currentFilesData.find(function(f) { return f.path == path; });
|
||||
if (file && file.type === 'image') {
|
||||
var photosData = {
|
||||
"title": "图片预览",
|
||||
"id": 1,
|
||||
"start": 0,
|
||||
"data": []
|
||||
};
|
||||
|
||||
var images = [];
|
||||
$.each(currentFilesData, function(i, f) {
|
||||
if (f.type === 'image') images.push(f);
|
||||
});
|
||||
|
||||
$.each(images, function(i, img) {
|
||||
var src = '/' + '@(Config.GetSystemConfig().AttachConfigEntity.AttachPatch)/' + img.path;
|
||||
photosData.data.push({
|
||||
"alt": img.name,
|
||||
"pid": i,
|
||||
"src": src,
|
||||
"thumb": ""
|
||||
});
|
||||
|
||||
if (img.path === path) {
|
||||
photosData.start = i;
|
||||
}
|
||||
});
|
||||
|
||||
layer.photos({
|
||||
photos: photosData,
|
||||
anim: 5
|
||||
});
|
||||
} else {
|
||||
var url = '/' + '@(Config.GetSystemConfig().AttachConfigEntity.AttachPatch)/' + path;
|
||||
window.open(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createFolder() {
|
||||
layer.prompt({title: '请输入文件夹名称', formType: 0}, function(text, index){
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: '/AdminCP/Attach/CreateDir',
|
||||
type: 'POST',
|
||||
data: { path: currentPath, name: text },
|
||||
success: function(res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg('创建成功', {icon: 1});
|
||||
refreshFiles();
|
||||
setTimeout(function(){ window.location.reload(); }, 1000);
|
||||
} else {
|
||||
layer.msg(res.message, {icon: 2});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function deleteSelected() {
|
||||
if (!selectedFile) {
|
||||
layer.msg('请先选择文件或文件夹', {icon: 0});
|
||||
return;
|
||||
}
|
||||
|
||||
layer.confirm('确定要删除吗?此操作不可恢复!', {icon: 3, title:'提示'}, function(index){
|
||||
$.ajax({
|
||||
url: '/AdminCP/Attach/DeleteFile',
|
||||
type: 'POST',
|
||||
data: { path: selectedFile.path, isDir: selectedFile.isDir },
|
||||
success: function(res) {
|
||||
if (res.code === 0) {
|
||||
layer.msg('删除成功', {icon: 1});
|
||||
refreshFiles();
|
||||
if (selectedFile.isDir) {
|
||||
setTimeout(function(){ window.location.reload(); }, 1000);
|
||||
}
|
||||
selectedFile = null;
|
||||
} else {
|
||||
layer.msg(res.message, {icon: 2});
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
});
|
||||
}
|
||||
|
||||
function renameFile() {
|
||||
if (!selectedFile) {
|
||||
layer.msg('请先选择文件或文件夹', {icon: 0});
|
||||
return;
|
||||
}
|
||||
|
||||
var currentFile = selectedFile;
|
||||
|
||||
layer.prompt({
|
||||
title: '请输入新名称',
|
||||
formType: 0,
|
||||
value: currentFile.name
|
||||
}, function(text, index){
|
||||
layer.close(index);
|
||||
|
||||
if (text === currentFile.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
var loading = layer.load(1, {shade: [0.1,'#fff']});
|
||||
$.ajax({
|
||||
url: '/AdminCP/Attach/RenameFile',
|
||||
type: 'POST',
|
||||
data: { path: currentFile.path, newName: text, isDir: currentFile.isDir },
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code === 0) {
|
||||
layer.msg('重命名成功', {icon: 1});
|
||||
refreshFiles();
|
||||
if (currentFile.isDir) {
|
||||
setTimeout(function(){ window.location.reload(); }, 1000);
|
||||
}
|
||||
selectedFile = null;
|
||||
} else {
|
||||
layer.msg(res.message, {icon: 2});
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
layer.close(loading);
|
||||
layer.msg('请求失败', {icon: 2});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function uploadFile() {
|
||||
if (!checkUploadPermission()) return;
|
||||
$('#fileInput').click();
|
||||
}
|
||||
|
||||
function checkUploadPermission() {
|
||||
if (!currentPath || currentPath === "") {
|
||||
layer.msg('根目录不允许上传文件,请选择子目录', {icon: 0});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function doUpload() {
|
||||
var files = $('#fileInput')[0].files;
|
||||
if (files.length === 0) return;
|
||||
processUpload(files);
|
||||
}
|
||||
|
||||
function handleDroppedFiles(files) {
|
||||
if (!checkUploadPermission()) return;
|
||||
processUpload(files);
|
||||
}
|
||||
|
||||
function processUpload(files) {
|
||||
var formData = new FormData();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
formData.append("files", files[i]);
|
||||
}
|
||||
formData.append("path", currentPath);
|
||||
|
||||
var loading = layer.load(1, {shade: [0.1,'#fff']});
|
||||
|
||||
$.ajax({
|
||||
url: '/AdminCP/Attach/UploadFile',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code === 0) {
|
||||
layer.msg(res.message, {icon: 1});
|
||||
refreshFiles();
|
||||
} else {
|
||||
layer.alert(res.message, {icon: 2});
|
||||
}
|
||||
$('#fileInput').val('');
|
||||
},
|
||||
error: function() {
|
||||
layer.close(loading);
|
||||
layer.msg('上传出错', {icon: 2});
|
||||
$('#fileInput').val('');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refreshFiles() {
|
||||
loadFiles(currentPath);
|
||||
}
|
||||
|
||||
function copyLink() {
|
||||
if (!selectedFile || selectedFile.isDir) {
|
||||
layer.msg('请选择一个文件', {icon: 0});
|
||||
return;
|
||||
}
|
||||
var url = '/' + '@(Config.GetSystemConfig().AttachConfigEntity.AttachPatch)/' + selectedFile.path;
|
||||
var $temp = $("<input>");
|
||||
$("body").append($temp);
|
||||
$temp.val(url).select();
|
||||
document.execCommand("copy");
|
||||
$temp.remove();
|
||||
layer.msg('链接已复制', {icon: 1});
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (bytes === 0) return '0 B';
|
||||
var k = 1024;
|
||||
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i];
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
ViewBag.title = "数据字典管理";
|
||||
}
|
||||
<script src="~/js/vue/vue.min.js"></script>
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="row" id="app">
|
||||
<div class="wrapper wrapper-content " id="app">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-6">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showDialog('adddepartment','添加部门','/AdminCP/Department/AddDepartment',0,0);">
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showAddRow();">
|
||||
|
||||
@@ -3,36 +3,37 @@
|
||||
ViewBag.title = "留言管理";
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline" onsubmit="doSearch(); return false; ">
|
||||
<div>
|
||||
<label class="control-label">留言分类:</label>
|
||||
|
||||
<select class="form-control" name="kid" id="kid">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
留言分类:
|
||||
<select name="kid" id="kid">
|
||||
<option value="0">所有分类</option>
|
||||
@foreach (var m in ViewBag.ListKinds)
|
||||
{
|
||||
<option value="@m.Id">@m.KindName</option>
|
||||
}
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<table id="tb_departments"></table>
|
||||
<div class="ibox float-e-margins">
|
||||
|
||||
<div class="ibox-content">
|
||||
<table id="tb_departments"></table>
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<link href="~/hplus/css/style.css" rel="stylesheet" />
|
||||
<link href="~/hplus/css/font-awesome.min.css" rel="stylesheet" />
|
||||
<link href="~/hplus/css/animate.css" rel="stylesheet" />
|
||||
<link href="~/hplus/js/plugins/metisMenu/metisMenu.min.css" rel="stylesheet" />
|
||||
<script>if (window.top !== window.self) { window.top.location = window.location; }</script>
|
||||
</head>
|
||||
|
||||
@@ -77,7 +78,7 @@
|
||||
{
|
||||
var l2 = Model.FindAll(s => s.PId == m1.Id && s.IsHide != 1);
|
||||
<li>
|
||||
<a href="/AdminCP/@(m1.Link)" id="@m1.MenuKey" @(m1.Link != "#" ? "class=J_menuItem" : "")>
|
||||
<a href="@(m1.Link=="#"?"javascript:;":"/AdminCP/"+m1.Link)" id="@m1.MenuKey" @(m1.Link != "#" ? "class=J_menuItem" : "")>
|
||||
@if (!string.IsNullOrWhiteSpace(m1.ClassName))
|
||||
{
|
||||
<i class="fa @m1.ClassName"></i>
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
<link href="~/hplus/css/style.css" rel="stylesheet" />
|
||||
<link href="~/hplus/css/font-awesome.min.css" rel="stylesheet" />
|
||||
<link href="~/hplus/css/animate.min.css" rel="stylesheet" />
|
||||
<link href="~/hplus/css/login.css" rel="stylesheet" />
|
||||
<link href="~/js/treegrid/jquery.treegrid.css" rel="stylesheet" />
|
||||
<script src="~/js/jquery2.min.js"></script>
|
||||
<script src="~/js/layer/layer.js"></script>
|
||||
@@ -176,7 +175,7 @@
|
||||
<tr>
|
||||
<td class="text-center small">客户端IP地址</td>
|
||||
<td>
|
||||
@ViewBag.remoteip
|
||||
@(Utils.GetIP())
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
<script>var encrypt_key = '@ViewBag.key';</script>
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="middle-box text-center loginscreen animated fadeInDown">
|
||||
<canvas id="canvas-bg"></canvas>
|
||||
<div class="middle-box animated fadeInDown">
|
||||
<div>
|
||||
<div class="text-center m-b-md" style="font-size:64px">
|
||||
COMCMS
|
||||
@@ -35,6 +36,15 @@
|
||||
<div class="form-group">
|
||||
<input type="password" name="password" id="password" class="form-control" placeholder="密码" required="">
|
||||
</div>
|
||||
@if (Utils.GetSetting("SystemSetting:AdminLoginWithCode") == "1")
|
||||
{
|
||||
<div class="form-group input-group">
|
||||
<input type="text" name="code" id="code" class="form-control" placeholder="验证码" required="">
|
||||
<span class="input-group-addon" style="padding:0px;">
|
||||
<img src="~/VerifyCode/MixVerifyCode" onclick="this.src='/VerifyCode/MixVerifyCode?'+Math.random()" style="cursor:pointer;" />
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
<button type="submit" class="btn btn-primary block full-width m-b">登 录</button>
|
||||
<p class="text-muted text-center">
|
||||
COMCMS © 2014-@DateTime.Now.Year
|
||||
@@ -71,6 +81,89 @@
|
||||
};
|
||||
DoAdminLogin("loginForm", rules);
|
||||
});
|
||||
// --- 科技感粒子连线动画特效 (原生JS实现,无需引入额外库) ---
|
||||
(function() {
|
||||
var canvas = document.getElementById('canvas-bg');
|
||||
var ctx = canvas.getContext('2d');
|
||||
var width, height;
|
||||
var particles = [];
|
||||
|
||||
// 特效配置
|
||||
var config = {
|
||||
count: 80, // 粒子数量
|
||||
dist: 160, // 连线距离
|
||||
radius: 2, // 粒子大小
|
||||
color: '26, 179, 148',// 主色调 RGB (#1ab394)
|
||||
speed: 0.8 // 移动速度
|
||||
};
|
||||
|
||||
function resize() {
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
}
|
||||
|
||||
function Particle() {
|
||||
this.x = Math.random() * width;
|
||||
this.y = Math.random() * height;
|
||||
this.vx = (Math.random() - 0.5) * config.speed;
|
||||
this.vy = (Math.random() - 0.5) * config.speed;
|
||||
}
|
||||
|
||||
Particle.prototype.update = function() {
|
||||
this.x += this.vx;
|
||||
this.y += this.vy;
|
||||
if (this.x < 0 || this.x > width) this.vx = -this.vx;
|
||||
if (this.y < 0 || this.y > height) this.vy = -this.vy;
|
||||
};
|
||||
|
||||
Particle.prototype.draw = function() {
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.x, this.y, config.radius, 0, Math.PI * 2);
|
||||
ctx.fillStyle = 'rgba(' + config.color + ', 0.6)';
|
||||
ctx.fill();
|
||||
};
|
||||
|
||||
function init() {
|
||||
resize();
|
||||
particles = [];
|
||||
for (var i = 0; i < config.count; i++) {
|
||||
particles.push(new Particle());
|
||||
}
|
||||
}
|
||||
|
||||
function animate() {
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
|
||||
for (var i = 0; i < particles.length; i++) {
|
||||
var p1 = particles[i];
|
||||
p1.update();
|
||||
p1.draw();
|
||||
|
||||
for (var j = i + 1; j < particles.length; j++) {
|
||||
var p2 = particles[j];
|
||||
var dx = p1.x - p2.x;
|
||||
var dy = p1.y - p2.y;
|
||||
var dist = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (dist < config.dist) {
|
||||
ctx.beginPath();
|
||||
ctx.strokeStyle = 'rgba(' + config.color + ',' + (1 - dist / config.dist) * 0.4 + ')';
|
||||
ctx.lineWidth = 1;
|
||||
ctx.moveTo(p1.x, p1.y);
|
||||
ctx.lineTo(p2.x, p2.y);
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', resize);
|
||||
init();
|
||||
animate();
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -3,30 +3,25 @@
|
||||
ViewBag.title = "后台管理日志";
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline" onsubmit="doSearch(); return false; ">
|
||||
<div>
|
||||
@*<label class="control-label">留言分类:</label>
|
||||
|
||||
<select class="form-control" name="kid" id="kid">
|
||||
<option value="0">所有分类</option>
|
||||
</select>*@
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<table id="tb_departments"></table>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
}
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addadminrole', '添加管理组', '/AdminCP/Member/AddAdminRole', 0, 0)">
|
||||
|
||||
@@ -3,34 +3,36 @@
|
||||
ViewBag.title = "管理员管理";
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline">
|
||||
<div>
|
||||
<label class="control-label">管理组:</label>
|
||||
|
||||
<select class="form-control" name="roleid" id="roleid">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
管理组:
|
||||
<select name="roleid" id="roleid">
|
||||
<option value="0">所有管理组</option>
|
||||
@foreach (var m in ViewBag.RoleList)
|
||||
{
|
||||
<option value="@m.Id">@m.RoleName</option>
|
||||
}
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="用户名关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addadmins', '添加管理员', '/AdminCP/Member/AddAdmin', 0, 0)">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addmemberrole', '添加用户组', '/AdminCP/Member/AddMemberRole', 0, 0)">
|
||||
|
||||
@@ -3,34 +3,36 @@
|
||||
ViewBag.title = "用户管理";
|
||||
}
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline">
|
||||
<div>
|
||||
<label class="control-label">用户组:</label>
|
||||
|
||||
<select class="form-control" name="roleid" id="roleid">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
用户组:
|
||||
<select name="roleid" id="roleid">
|
||||
<option value="0">所有用户组</option>
|
||||
@foreach (var m in ViewBag.RoleList)
|
||||
{
|
||||
<option value="@m.Id">@m.RoleName</option>
|
||||
}
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="用户名关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
|
||||
<div class="ibox-content">
|
||||
@*<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addads', '添加用户', '/AdminCP/Member/AddMember', 0, 0)">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||
|
||||
@@ -4,38 +4,43 @@
|
||||
}
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline" onsubmit="return doSearch();">
|
||||
<div>
|
||||
<label class="control-label">订单状态:</label>
|
||||
<select class="form-control" name="status" id="status">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
订单状态:
|
||||
<select name="status" id="status">
|
||||
<option value="">不限状态</option>
|
||||
<option value="未确认">未确认</option>
|
||||
<option value="已确认">已确认</option>
|
||||
<option value="已完成">已完成</option>
|
||||
</select>
|
||||
<label class="control-label">支付状态:</label>
|
||||
<select class="form-control" name="paystatus" id="paystatus">
|
||||
</li>
|
||||
<li>
|
||||
支付状态:
|
||||
<select name="paystatus" id="paystatus">
|
||||
<option value="">不限状态</option>
|
||||
<option value="未支付">未支付</option>
|
||||
<option value="已支付">已支付</option>
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
<table id="tb_departments"></table>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -4,33 +4,45 @@
|
||||
}
|
||||
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.Title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline" onsubmit="return doSearch();">
|
||||
<div>
|
||||
<label class="control-label">支付类型:</label>
|
||||
<select class="form-control" name="mytype" id="mytype">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
支付类型:
|
||||
<select name="mytype" id="mytype">
|
||||
<option value="0">不限状态</option>
|
||||
<option value="1">商品订单</option>
|
||||
<option value="2">快餐订单</option>
|
||||
<option value="3">酒店预定</option>
|
||||
<option value="99" selected>代理商认证费订单</option>
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
支付状态:
|
||||
<select name="paystatus" id="paystatus">
|
||||
<option value="">不限状态</option>
|
||||
<option value="未支付">未支付</option>
|
||||
<option value="已支付">已支付</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ibox float-e-margins">
|
||||
|
||||
<div class="ibox-content">
|
||||
<table id="tb_departments"></table>
|
||||
|
||||
<script>
|
||||
@@ -54,7 +66,8 @@
|
||||
limit: params.limit, //页面大小
|
||||
page: (params.offset / params.limit) + 1, //页码
|
||||
mytype: $("#mytype").val(),
|
||||
keyword: $("#keyword").val()
|
||||
keyword: $("#keyword").val(),
|
||||
paystatus: $("#paystatus").val()
|
||||
};
|
||||
return temp;
|
||||
}
|
||||
@@ -165,7 +178,7 @@
|
||||
limit: params.limit, //页面大小
|
||||
page: (params.offset / params.limit) + 1, //页码
|
||||
mytype: $("#mytype").val(),
|
||||
departmentname: $("#keyword").val()
|
||||
paystatus: $("#paystatus").val()
|
||||
};
|
||||
return temp;
|
||||
};
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showAddRow();">
|
||||
|
||||
@@ -3,34 +3,36 @@
|
||||
ViewBag.title = "广告管理";
|
||||
}
|
||||
<div class="wrapper wrapper-content ">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline">
|
||||
<div>
|
||||
<label class="control-label">广告分类:</label>
|
||||
|
||||
<select class="form-control" name="kid" id="kid">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
广告分类:
|
||||
<select name="kid" id="kid">
|
||||
<option value="0">所有栏目</option>
|
||||
@foreach (var m in ViewBag.ListKinds)
|
||||
{
|
||||
<option value="@m.Id">@m.KindName</option>
|
||||
}
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addads','添加广告','/AdminCP/Other/AddAds',0,0)">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
}
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="showAddRow();">
|
||||
|
||||
@@ -3,34 +3,36 @@
|
||||
ViewBag.title = "友情链接管理";
|
||||
}
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>@ViewBag.title</h5>
|
||||
<div class="ibox-tools">
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">筛选条件</div>
|
||||
<div class="panel-body">
|
||||
<form id="formSearch" class="form-horizontal form-inline">
|
||||
<div>
|
||||
<label class="control-label">友情链接分类:</label>
|
||||
|
||||
<select class="form-control" name="kid" id="kid">
|
||||
<div class="row">
|
||||
<div class="search-collapse">
|
||||
<form id="formSearch" onsubmit="return doSearch(); return false;">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
友情链接分类:
|
||||
<select name="kid" id="kid">
|
||||
<option value="0">所有分类</option>
|
||||
@foreach (var m in ViewBag.ListKinds)
|
||||
{
|
||||
<option value="@m.Id">@m.KindName</option>
|
||||
}
|
||||
</select>
|
||||
<label class="control-label">关键字:</label>
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword" class="form-control">
|
||||
<button type="button" style="margin-left:50px" id="btn_query" class="btn btn-primary">查询</button>
|
||||
</li>
|
||||
<li>
|
||||
关键字:
|
||||
<input type="text" placeholder="标题关键字" name="keyword" id="keyword">
|
||||
</li>
|
||||
<li>
|
||||
<button type="button" id="btn_query" class="btn btn-primary btn-sm" onclick="doSearch();">查询</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-content">
|
||||
|
||||
<div id="toolbar" class="btn-group">
|
||||
<button id="btn_add" type="button" class="btn btn-outline btn-default" onclick="top.showDialog('addads', '添加友情链接', '/AdminCP/Other/AddLink', 0, 0)">
|
||||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>新增
|
||||
@@ -50,6 +52,21 @@
|
||||
oButtonInit.Init();
|
||||
|
||||
});
|
||||
function doSearch() {
|
||||
var params = $('#tb_departments').bootstrapTable('getOptions');
|
||||
//console.log(params);
|
||||
params.queryParams = function (params) {
|
||||
|
||||
var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
|
||||
limit: params.limit, //页面大小
|
||||
page: (params.offset / params.limit) + 1, //页码
|
||||
kid: $("#kid").val(),
|
||||
keyword: $("#keyword").val(),
|
||||
};
|
||||
return temp;
|
||||
}
|
||||
$('#tb_departments').bootstrapTable('refresh', params);
|
||||
}
|
||||
var TableInit = function () {
|
||||
var oTableInit = new Object();
|
||||
//初始化Table
|
||||
@@ -68,7 +85,7 @@
|
||||
pageNumber: 1, //初始化加载第一页,默认第一页
|
||||
pageSize: 25, //每页的记录行数(*)
|
||||
pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)
|
||||
search: true, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
|
||||
search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
|
||||
strictSearch: true,
|
||||
showColumns: true, //是否显示所有的列
|
||||
showRefresh: true, //是否显示刷新按钮
|
||||
@@ -113,7 +130,7 @@
|
||||
limit: params.limit, //页面大小
|
||||
page: (params.offset / params.limit) + 1, //页码
|
||||
kid:$("#kid").val(),
|
||||
departmentname: $("#keyword").val()
|
||||
keyword: $("#keyword").val()
|
||||
};
|
||||
return temp;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">禁用:</label>
|
||||
<div class="col-sm-8">
|
||||
<label>
|
||||
<label class="checkbox-inline i-checks">
|
||||
<input type="checkbox" value="1" name="IsDisable" id="IsDisable"> 禁用
|
||||
</label>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user