Compare commits
101
Commits
831e4666f7
...
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 | ||
|
|
8b62d8e61e | ||
|
|
ef0d81d917 | ||
|
|
815b3af928 | ||
|
|
9014ee0190 | ||
|
|
f0f1e3d7b6 | ||
|
|
02db388433 | ||
|
|
dcca21b710 | ||
|
|
1be54104cf | ||
|
|
a3c33b165d | ||
|
|
bea352a482 | ||
|
|
349a1ec280 | ||
|
|
7c1b590ad3 | ||
|
|
b5c0de58d6 | ||
|
|
ae6ede6fa2 | ||
|
|
184ec9c253 | ||
|
|
1fd5b311da | ||
|
|
4932b4fca1 | ||
|
|
1f566e0538 | ||
|
|
e16879b7f6 | ||
|
|
0db8317869 | ||
|
|
a9bdec611c | ||
|
|
372265d89a | ||
|
|
7ed117d054 | ||
|
|
cfd8f02ef4 | ||
|
|
7f796a5b18 | ||
|
|
bfe720fcd1 | ||
|
|
b74d90b4bd | ||
|
|
8d1b5f3679 | ||
|
|
3b50120a5c | ||
|
|
ab40520cda | ||
|
|
c6b0efc887 | ||
|
|
5743c82783 | ||
|
|
00cf820925 | ||
|
|
c4d2e37c04 | ||
|
|
77b11016e3 | ||
|
|
10232885e0 | ||
|
|
22098d7a19 | ||
|
|
36fbe99831 | ||
|
|
b92d40b623 | ||
|
|
e5f89bc563 | ||
|
|
e5e73d50bc | ||
|
|
8461f9230e | ||
|
|
f32e0d4857 | ||
|
|
4d658ca4ab | ||
|
|
64b017c1da | ||
|
|
23a9399b43 | ||
|
|
643ef876a0 | ||
|
|
1642536afd | ||
|
|
64c155d4f2 | ||
|
|
b6109fa259 | ||
|
|
1e8fc3c79f | ||
|
|
8722d14d0f | ||
|
|
06109e672b | ||
|
|
712a7620d6 | ||
|
|
429138f3a5 | ||
|
|
ef6d9100ea | ||
|
|
acf28e8b6f | ||
|
|
f28c84f3bb | ||
|
|
4ca3cf3610 | ||
|
|
6aea54c771 | ||
|
|
e740282650 | ||
|
|
9fc5162230 | ||
|
|
4552e40bfa | ||
|
|
fed29cf5ce | ||
|
|
edc0c5932b | ||
|
|
0473bf94a1 | ||
|
|
7b549fc6c5 |
@@ -0,0 +1,25 @@
|
|||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
@@ -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`
|
||||||
@@ -308,3 +308,8 @@ COMCMS.Web/wwwroot/userfiles/
|
|||||||
/COMCMS.Web/UploadFile
|
/COMCMS.Web/UploadFile
|
||||||
/COMCMS.Web/UploadTemp
|
/COMCMS.Web/UploadTemp
|
||||||
/WebTest/wwwroot
|
/WebTest/wwwroot
|
||||||
|
COMCMS.Web/wwwroot/install.lock
|
||||||
|
|
||||||
|
|
||||||
|
# others
|
||||||
|
.cursorrules
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Weixin\" />
|
<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>
|
||||||
|
<ProjectReference Include="..\COMCMS.Common\COMCMS.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\COMCMS.Core\COMCMS.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,961 @@
|
|||||||
|
using COMCMS.Common;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using Senparc.CO2NET.Utilities;
|
||||||
|
using Senparc.NeuChar.Entities;
|
||||||
|
using Senparc.Weixin.MP;
|
||||||
|
using Senparc.Weixin.MP.Containers;
|
||||||
|
using Senparc.Weixin.MP.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace COMCMS.API.Weixin.Common
|
||||||
|
{
|
||||||
|
public class MessageFunction
|
||||||
|
{
|
||||||
|
Config siteConfig = Config.GetSystemConfig();
|
||||||
|
|
||||||
|
#region 处理关注/取消/默认回复方法===========================
|
||||||
|
/// <summary>
|
||||||
|
/// 定阅事件的统一处理
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase EventSubscribe(int type, RequestMessageEventBase requestMessage)
|
||||||
|
{
|
||||||
|
int accountId = GetAccountId(); //取得公众账户ID
|
||||||
|
string EventName = "";
|
||||||
|
|
||||||
|
if (requestMessage.Event.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
EventName = requestMessage.Event.ToString();
|
||||||
|
}
|
||||||
|
//else if (requestMessage.EventKey != null)
|
||||||
|
//{
|
||||||
|
// EventName += requestMessage.EventKey.ToString();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
if (!ExistsOriginalId(accountId, requestMessage.ToUserName))
|
||||||
|
{
|
||||||
|
//验证接收方是否为我们系统配置的帐号,即验证微帐号与微信原始帐号id是否一致,如果不一致,说明【1】配置错误,【2】数据来源有问题
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "none", "未取到关键词对应的数据", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "none",
|
||||||
|
ReponseContent = "未取到关键词对应的数据",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
|
||||||
|
|
||||||
|
return GetResponseMessageTxtByContent(requestMessage, "验证微帐号与微信原始帐号id不一致,可能原因【1】系统配置错误,【2】非法的数据来源", accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int responseType = 0, ruleId = 0;
|
||||||
|
//int ruleId = new BLL.weixin_request_rule().GetRuleIdAndResponseType(accountId, "request_type=" + type, out responseType);
|
||||||
|
WeixinRequestRule rule = WeixinRequestRule.Find(WeixinRequestRule._.RequestType == type);
|
||||||
|
|
||||||
|
if (rule != null)
|
||||||
|
{
|
||||||
|
responseType = rule.ResponseType;
|
||||||
|
ruleId = rule.Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ruleId <= 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "none", "未取到关键词对应的数据", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "none",
|
||||||
|
ReponseContent = "未取到关键词对应的数据",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IResponseMessageBase reponseMessage = null;
|
||||||
|
switch (responseType)
|
||||||
|
{
|
||||||
|
case (int)WeixinRequestRule.XResponseType.Text:
|
||||||
|
//发送纯文字
|
||||||
|
reponseMessage = GetResponseMessageTxt(requestMessage, rule.Id, accountId);
|
||||||
|
break;
|
||||||
|
case (int)WeixinRequestRule.XResponseType.Image:
|
||||||
|
//发送多图文
|
||||||
|
reponseMessage = GetResponseMessageNews(requestMessage, rule.Id, accountId);
|
||||||
|
break;
|
||||||
|
case (int)WeixinRequestRule.XResponseType.Voice:
|
||||||
|
//发送语音
|
||||||
|
reponseMessage = GetResponseMessageeMusic(requestMessage, rule.Id, accountId);
|
||||||
|
break;
|
||||||
|
case (int)WeixinRequestRule.XResponseType.SingleImage:
|
||||||
|
reponseMessage = GetResponseMessageSingleImage(requestMessage, rule.Id, accountId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return reponseMessage;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 请求为文本的处理=====================================
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageTxt(RequestMessageText requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
//responseMessage.Content = new BLL.weixin_request_content().GetContent(ruleId);
|
||||||
|
WeixinRequestContent ctx = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (ctx != null)
|
||||||
|
{
|
||||||
|
responseMessage.Content = ctx.Content;
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "text",
|
||||||
|
ReponseContent = responseMessage.Content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", responseMessage.Content, requestMessage.ToUserName);
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageTxtByContent(RequestMessageText requestMessage, string content, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
responseMessage.Content = content;
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "text",
|
||||||
|
ReponseContent = "文字请求,推送纯粹文字,内容为:" + content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", "文字请求,推送纯粹文字,内容为:" + content, requestMessage.ToUserName);
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理语音请求
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageeMusic(RequestMessageText requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
//string EventName = "";
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageMusic>(requestMessage);
|
||||||
|
//Model.weixin_request_content model = new BLL.weixin_request_content().GetModel(ruleId);
|
||||||
|
WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "music",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (model.MediaURL.Contains("http://"))
|
||||||
|
{
|
||||||
|
responseMessage.Music.MusicUrl = model.MediaURL;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
responseMessage.Music.MusicUrl = Utils.GetServerUrl() + model.MediaURL;
|
||||||
|
}
|
||||||
|
responseMessage.Music.Title = model.Title;
|
||||||
|
responseMessage.Music.Description = model.Content;
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "音乐链接:" + model.media_url + "|标题:" + model.title + "|描述:" + model.content, requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "music",
|
||||||
|
ReponseContent = "音乐链接:" + model.MediaURL + "|标题:" + model.Title + "|描述:" + model.Content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送多图文
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageNews(RequestMessageText requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageNews>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
|
||||||
|
Senparc.NeuChar.Entities.Article article;
|
||||||
|
List<Senparc.NeuChar.Entities.Article> artList = new List<Senparc.NeuChar.Entities.Article>();
|
||||||
|
IList<WeixinRequestContent> twList = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == ruleId, null, null, 0, 10);
|
||||||
|
foreach (WeixinRequestContent modelt in twList)
|
||||||
|
{
|
||||||
|
article = new Senparc.NeuChar.Entities.Article();
|
||||||
|
article.Title = modelt.Title;
|
||||||
|
article.Description = modelt.Content;
|
||||||
|
article.Url = GetWXApiUrl(modelt.LinkUrl, token, openid);
|
||||||
|
if (string.IsNullOrEmpty(modelt.ImgURL))
|
||||||
|
article.PicUrl = string.Empty;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (modelt.ImgURL.Contains("http://"))
|
||||||
|
{
|
||||||
|
article.PicUrl = modelt.ImgURL;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
article.PicUrl = Utils.GetServerUrl() + "/" + modelt.ImgURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
artList.Add(article);
|
||||||
|
}
|
||||||
|
if (artList.Count == 0)
|
||||||
|
{
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "txtpic",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "-1", requestMessage.ToUserName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "txtpic",
|
||||||
|
ReponseContent = "这次发了" + artList.Count + "条图文",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName);
|
||||||
|
}
|
||||||
|
responseMessage.Articles.AddRange(artList);
|
||||||
|
|
||||||
|
//Article article;
|
||||||
|
//List<Article> artList = new List<Article>();
|
||||||
|
//IList<Model.weixin_request_content> twList = new BLL.weixin_request_content().GetModelList(10, ruleId, string.Empty);
|
||||||
|
//foreach (Model.weixin_request_content modelt in twList)
|
||||||
|
//{
|
||||||
|
// article = new Article();
|
||||||
|
// article.Title = modelt.title;
|
||||||
|
// article.Description = modelt.content;
|
||||||
|
// article.Url = GetWXApiUrl(modelt.link_url, token, openid);
|
||||||
|
// if (string.IsNullOrEmpty(modelt.img_url))
|
||||||
|
// {
|
||||||
|
// article.PicUrl = string.Empty;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (modelt.img_url.Contains("http://"))
|
||||||
|
// {
|
||||||
|
// article.PicUrl = modelt.img_url;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// //因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
// article.PicUrl = siteConfig.weburl + "/" + siteConfig.webpath.Replace("/", "") + modelt.img_url;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// artList.Add(article);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (artList.Count == 0)
|
||||||
|
//{
|
||||||
|
// new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "-1", requestMessage.ToUserName);
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName);
|
||||||
|
//}
|
||||||
|
//responseMessage.Articles.AddRange(artList);
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 请求为图片的处理=====================================
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageTxt(RequestMessageImage requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
//responseMessage.Content = new BLL.weixin_request_content().GetContent(ruleId);
|
||||||
|
WeixinRequestContent ctx = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (ctx != null)
|
||||||
|
{
|
||||||
|
responseMessage.Content = ctx.Content;
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.PicUrl,
|
||||||
|
ResponseType = "text",
|
||||||
|
ReponseContent = responseMessage.Content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageTxtByContent(RequestMessageImage requestMessage, string content, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
responseMessage.Content = content;
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.PicUrl,
|
||||||
|
ResponseType = "text",
|
||||||
|
ReponseContent = "文字请求,推送纯粹文字,内容为:" + content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "text", "文字请求,推送纯粹文字,内容为:" + content, requestMessage.ToUserName);
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理语音请求
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageeMusic(RequestMessageImage requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
//string EventName = "";
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageMusic>(requestMessage);
|
||||||
|
//Model.weixin_request_content model = new BLL.weixin_request_content().GetModel(ruleId);
|
||||||
|
WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.PicUrl,
|
||||||
|
ResponseType = "music",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (model.MediaURL.Contains("http://"))
|
||||||
|
{
|
||||||
|
responseMessage.Music.MusicUrl = model.MediaURL;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
responseMessage.Music.MusicUrl = Utils.GetServerUrl() + model.MediaURL;
|
||||||
|
}
|
||||||
|
responseMessage.Music.Title = model.Title;
|
||||||
|
responseMessage.Music.Description = model.Content;
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "音乐链接:" + model.media_url + "|标题:" + model.title + "|描述:" + model.content, requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.PicUrl,
|
||||||
|
ResponseType = "music",
|
||||||
|
ReponseContent = "音乐链接:" + model.MediaURL + "|标题:" + model.Title + "|描述:" + model.Content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送多图文
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageNews(RequestMessageImage requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageNews>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
|
||||||
|
Senparc.NeuChar.Entities.Article article;
|
||||||
|
List<Senparc.NeuChar.Entities.Article> artList = new List<Senparc.NeuChar.Entities.Article>();
|
||||||
|
IList<WeixinRequestContent> twList = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == ruleId, null, null, 0, 10);
|
||||||
|
foreach (WeixinRequestContent modelt in twList)
|
||||||
|
{
|
||||||
|
article = new Senparc.NeuChar.Entities.Article();
|
||||||
|
article.Title = modelt.Title;
|
||||||
|
article.Description = modelt.Content;
|
||||||
|
article.Url = GetWXApiUrl(modelt.LinkUrl, token, openid);
|
||||||
|
if (string.IsNullOrEmpty(modelt.ImgURL))
|
||||||
|
article.PicUrl = string.Empty;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (modelt.ImgURL.Contains("http://"))
|
||||||
|
{
|
||||||
|
article.PicUrl = modelt.ImgURL;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
article.PicUrl = Utils.GetServerUrl() + "/" + modelt.ImgURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
artList.Add(article);
|
||||||
|
}
|
||||||
|
if (artList.Count == 0)
|
||||||
|
{
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.PicUrl,
|
||||||
|
ResponseType = "txtpic",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "-1", requestMessage.ToUserName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.PicUrl,
|
||||||
|
ResponseType = "txtpic",
|
||||||
|
ReponseContent = "这次发了" + artList.Count + "条图文",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), requestMessage.Content, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName);
|
||||||
|
}
|
||||||
|
responseMessage.Articles.AddRange(artList);
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送单张图片
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageSingleImagesContent(RequestMessageText requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageImage>(requestMessage);
|
||||||
|
string EventName = "";
|
||||||
|
var locationService = new LocationService();
|
||||||
|
NewLife.Log.XTrace.WriteLine("相应单图片回复");
|
||||||
|
WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
NewLife.Log.XTrace.WriteLine("没找到单图片回复规则");
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "image",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.MediaURL))
|
||||||
|
{
|
||||||
|
//如果没有mediaid 则先上传
|
||||||
|
string imgUrl = "~/wwwroot" + model.ImgURL;
|
||||||
|
var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(siteConfig.AppId, UploadMediaFileType.image,
|
||||||
|
ServerUtility.ContentRootMapPath(imgUrl));
|
||||||
|
//NewLife.Log.XTrace.WriteLine("准备上传素材,imgurl:" + imgurl);
|
||||||
|
|
||||||
|
//var accessToken = AccessTokenContainer.TryGetAccessToken(siteConfig.AppId, siteConfig.AppSecret);// AccessTokenContainer.TryGetAccessToken(official.AppId, official.AppSecret, false);
|
||||||
|
//上传图片素材 imgurl 必须是本地绝对路径。。。。
|
||||||
|
//var upresult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadForeverMedia(accessToken, imgurl);
|
||||||
|
model.MediaURL = uploadResult.media_id;
|
||||||
|
model.Update();
|
||||||
|
NewLife.Log.XTrace.WriteLine("上传素材,返回mediaid:" + uploadResult.media_id);
|
||||||
|
}
|
||||||
|
Image img = new Image();
|
||||||
|
img.MediaId = model.MediaURL;
|
||||||
|
responseMessage.CreateTime = DateTime.Now;
|
||||||
|
responseMessage.Image = img;
|
||||||
|
|
||||||
|
NewLife.Log.XTrace.WriteLine("回复单图片,mediaid" + img.MediaId + ";回复用户openid:" + responseMessage.FromUserName);
|
||||||
|
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "image",
|
||||||
|
ReponseContent = "图片:" + model.MediaURL + "|标题:" + model.Title,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 请求为事件的处理=====================================
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageTxt(RequestMessageEventBase requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
WeixinRequestContent rct = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
responseMessage.Content = rct != null ? rct.Content : "";// new BLL.weixin_request_content().GetContent(ruleId);
|
||||||
|
|
||||||
|
NewLife.Log.XTrace.WriteLine("文本自动关注回复:" + ruleId + "||" + responseMessage.Content);
|
||||||
|
|
||||||
|
string EventName = "";
|
||||||
|
if (requestMessage.Event.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
EventName = requestMessage.Event.ToString();
|
||||||
|
}
|
||||||
|
//else if (requestMessage.EventKey != null)
|
||||||
|
//{
|
||||||
|
// EventName += requestMessage.EventKey.ToString();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "text", responseMessage.Content, requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "text",
|
||||||
|
ReponseContent = responseMessage.Content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageTxtByContent(RequestMessageEventBase requestMessage, string content, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
var locationService = new LocationService();
|
||||||
|
responseMessage.Content = content;
|
||||||
|
string EventName = "";
|
||||||
|
if (requestMessage.Event.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
EventName = requestMessage.Event.ToString();
|
||||||
|
}
|
||||||
|
//else if (requestMessage.EventKey != null)
|
||||||
|
//{
|
||||||
|
// EventName += requestMessage.EventKey.ToString();
|
||||||
|
//}
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "text", "事件:推送纯粹的文字,内容为:" + content, requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "text",
|
||||||
|
ReponseContent = "事件:推送纯粹的文字,内容为:" + content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送纯文字
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageSingleImage(RequestMessageEventBase requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageImage>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
|
||||||
|
NewLife.Log.XTrace.WriteLine("相应单图片回复");
|
||||||
|
WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
NewLife.Log.XTrace.WriteLine("没找到单图片回复规则");
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = "关注自动回复",
|
||||||
|
ResponseType = "image",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.MediaURL))
|
||||||
|
{
|
||||||
|
string imgUrl = "~/wwwroot" + model.ImgURL;
|
||||||
|
var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(siteConfig.AppId, UploadMediaFileType.image,
|
||||||
|
ServerUtility.ContentRootMapPath(imgUrl));
|
||||||
|
|
||||||
|
model.MediaURL = uploadResult.media_id;
|
||||||
|
model.Update();
|
||||||
|
NewLife.Log.XTrace.WriteLine("上传素材,返回mediaid:" + uploadResult.media_id);
|
||||||
|
}
|
||||||
|
Image img = new Image();
|
||||||
|
img.MediaId = model.MediaURL;
|
||||||
|
responseMessage.CreateTime = DateTime.Now;
|
||||||
|
responseMessage.Image = img;
|
||||||
|
|
||||||
|
NewLife.Log.XTrace.WriteLine("回复单图片,mediaid" + img.MediaId + ";回复用户openid:" + responseMessage.FromUserName);
|
||||||
|
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = "关注自动回复",
|
||||||
|
ResponseType = "image",
|
||||||
|
ReponseContent = "图片:" + model.MediaURL + "|标题:" + model.Title,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送单张图片
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageSingleImagesContent(RequestMessageEventBase requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageImage>(requestMessage);
|
||||||
|
string EventName = "";
|
||||||
|
var locationService = new LocationService();
|
||||||
|
NewLife.Log.XTrace.WriteLine("相应单图片回复");
|
||||||
|
WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
NewLife.Log.XTrace.WriteLine("没找到单图片回复规则");
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "image",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.MediaURL))
|
||||||
|
{
|
||||||
|
//如果没有mediaid 则先上传
|
||||||
|
string imgUrl = "~/wwwroot" + model.ImgURL;
|
||||||
|
var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(siteConfig.AppId, UploadMediaFileType.image,
|
||||||
|
ServerUtility.ContentRootMapPath(imgUrl));
|
||||||
|
model.MediaURL = uploadResult.media_id;
|
||||||
|
model.Update();
|
||||||
|
NewLife.Log.XTrace.WriteLine("上传素材,返回mediaid:" + uploadResult.media_id);
|
||||||
|
}
|
||||||
|
Image img = new Image();
|
||||||
|
img.MediaId = model.MediaURL;
|
||||||
|
responseMessage.CreateTime = DateTime.Now;
|
||||||
|
responseMessage.Image = img;
|
||||||
|
|
||||||
|
NewLife.Log.XTrace.WriteLine("回复单图片,mediaid" + img.MediaId + ";回复用户openid:" + responseMessage.FromUserName);
|
||||||
|
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "image",
|
||||||
|
ReponseContent = "图片:" + model.MediaURL + "|标题:" + model.Title,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理语音请求
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageeMusic(RequestMessageEventBase requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageMusic>(requestMessage);
|
||||||
|
string EventName = "";
|
||||||
|
if (requestMessage.Event.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
EventName = requestMessage.Event.ToString();
|
||||||
|
}
|
||||||
|
//else if (requestMessage.EventKey != null)
|
||||||
|
//{
|
||||||
|
// EventName += requestMessage.EventKey.ToString();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//Model.weixin_request_content model = new BLL.weixin_request_content().GetModel(ruleId);
|
||||||
|
WeixinRequestContent model = WeixinRequestContent.Find(WeixinRequestContent._.RuleId == ruleId);
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "music",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (model.MediaURL.Contains("http://"))
|
||||||
|
{
|
||||||
|
responseMessage.Music.MusicUrl = model.MediaURL;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
responseMessage.Music.MusicUrl = Utils.GetServerUrl() + model.MediaURL;
|
||||||
|
}
|
||||||
|
responseMessage.Music.Title = model.Title;
|
||||||
|
responseMessage.Music.Description = model.Content;
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "music", "音乐链接:" + model.media_url + "|标题:" + model.title + "|描述:" + model.content, requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "music",
|
||||||
|
ReponseContent = "音乐链接:" + model.MediaURL + "|标题:" + model.Title + "|描述:" + model.Content,
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送多图文
|
||||||
|
/// </summary>
|
||||||
|
public IResponseMessageBase GetResponseMessageNews(RequestMessageEventBase requestMessage, int ruleId, int accountId)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageNews>(requestMessage);
|
||||||
|
string openid = requestMessage.FromUserName;
|
||||||
|
string token = ConvertDateTimeInt(DateTime.Now).ToString();
|
||||||
|
|
||||||
|
Senparc.NeuChar.Entities.Article article;
|
||||||
|
List<Senparc.NeuChar.Entities.Article> artList = new List<Senparc.NeuChar.Entities.Article>();
|
||||||
|
//IList<Model.weixin_request_content> twList = new BLL.weixin_request_content().GetModelList(10, ruleId, string.Empty);
|
||||||
|
IList<WeixinRequestContent> twList = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == ruleId, null, null, 0, 10);
|
||||||
|
foreach (WeixinRequestContent modelt in twList)
|
||||||
|
{
|
||||||
|
article = new Senparc.NeuChar.Entities.Article();
|
||||||
|
article.Title = modelt.Title;
|
||||||
|
article.Description = modelt.Content;
|
||||||
|
article.Url = GetWXApiUrl(modelt.LinkUrl, token, openid);
|
||||||
|
if (string.IsNullOrEmpty(modelt.ImgURL))
|
||||||
|
{
|
||||||
|
article.PicUrl = string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (modelt.ImgURL.Contains("http://"))
|
||||||
|
{
|
||||||
|
article.PicUrl = modelt.ImgURL;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//因为安装目录是以/开头,所以去掉,以免出现双斜杆
|
||||||
|
article.PicUrl = Utils.GetServerUrl() + modelt.ImgURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
artList.Add(article);
|
||||||
|
}
|
||||||
|
|
||||||
|
string EventName = "";
|
||||||
|
if (requestMessage.Event.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
EventName = requestMessage.Event.ToString();
|
||||||
|
}
|
||||||
|
//else if (requestMessage.EventKey != null)
|
||||||
|
//{
|
||||||
|
// EventName += requestMessage.EventKey.ToString();
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (artList.Count == 0)
|
||||||
|
{
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "txtpic", "-1", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "txtpic",
|
||||||
|
ReponseContent = "-1",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//new BLL.weixin_response_content().Add(accountId, requestMessage.FromUserName, requestMessage.MsgType.ToString(), EventName, "txtpic", "这次发了" + artList.Count + "条图文", requestMessage.ToUserName);
|
||||||
|
WeixinResponseContent entity = new WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = EventName,
|
||||||
|
ResponseType = "txtpic",
|
||||||
|
ReponseContent = "这次发了" + artList.Count + "条图文",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
}
|
||||||
|
responseMessage.Articles.AddRange(artList);
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取验证公众账户ID===================================
|
||||||
|
/// <summary>
|
||||||
|
/// 获取公众账户的ID
|
||||||
|
/// </summary>
|
||||||
|
public int GetAccountId()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(MyHttpContext.Current.Request.Query["uid"]))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int tmpInt = 0;
|
||||||
|
if (!int.TryParse(MyHttpContext.Current.Request.Query["uid"].ToString(), out tmpInt))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int uid = int.Parse(MyHttpContext.Current.Request.Query["uid"].ToString());
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证公众账户原始ID是否一致
|
||||||
|
/// </summary>
|
||||||
|
public bool ExistsOriginalId(int accountId, string originalId)
|
||||||
|
{
|
||||||
|
//if(siteConfig.WexinAccount == )
|
||||||
|
//if (WechatOfficial.FindCount(WechatOfficial._.Id == accountId & WechatOfficial._.OriginalId == originalId, null, null, 0, 0) > 0)
|
||||||
|
//{
|
||||||
|
// return true;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
return true;
|
||||||
|
//return new BLL.weixin_account().ExistsOriginalId(accountId, originalId);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 常用的方法封装=======================================
|
||||||
|
/// <summary>
|
||||||
|
/// 拼接微信URL地址参数
|
||||||
|
/// </summary>
|
||||||
|
public string GetWXApiUrl(string url, string token, string openid)
|
||||||
|
{
|
||||||
|
if (url.Contains("?"))
|
||||||
|
{
|
||||||
|
return url + "&token=" + token + "&openid=" + openid;
|
||||||
|
}
|
||||||
|
return url + "?token=" + token + "&openid=" + openid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置微信url地址的后缀
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetWxUrlSuffix()
|
||||||
|
{
|
||||||
|
return "wxref=mp.weixin.qq.com";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DateTime时间格式转换为Unix时间戳格式
|
||||||
|
/// </summary>
|
||||||
|
public long ConvertDateTimeInt(System.DateTime time)
|
||||||
|
{
|
||||||
|
//long intResult = 0;
|
||||||
|
|
||||||
|
//System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
|
||||||
|
//intResult = (long)(time - startTime).TotalSeconds;
|
||||||
|
return long.Parse(Utils.GetTimeStamp());
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using Senparc.NeuChar.Context;
|
||||||
|
using Senparc.NeuChar.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Senparc.Weixin.MP.Entities;
|
||||||
|
using Senparc.Weixin.MP.MessageContexts;
|
||||||
|
|
||||||
|
namespace COMCMS.API.Weixin.CustomMessageHandler
|
||||||
|
{
|
||||||
|
public class CustomMessageContext : DefaultMpMessageContext
|
||||||
|
{
|
||||||
|
public CustomMessageContext()
|
||||||
|
{
|
||||||
|
base.MessageContextRemoved += CustomMessageContext_MessageContextRemoved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当上下文过期,被移除时触发的时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
void CustomMessageContext_MessageContextRemoved(object sender, WeixinContextRemovedEventArgs<IRequestMessageBase, IResponseMessageBase> e)
|
||||||
|
{
|
||||||
|
/* 注意,这个事件不是实时触发的(当然你也可以专门写一个线程监控)
|
||||||
|
* 为了提高效率,根据WeixinContext中的算法,这里的过期消息会在过期后下一条请求执行之前被清除
|
||||||
|
*/
|
||||||
|
|
||||||
|
var messageContext = e.MessageContext as CustomMessageContext;
|
||||||
|
if (messageContext == null)
|
||||||
|
{
|
||||||
|
return;//如果是正常的调用,messageContext不会为null
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO:这里根据需要执行消息过期时候的逻辑,下面的代码仅供参考
|
||||||
|
|
||||||
|
//Log.InfoFormat("{0}的消息上下文已过期",e.OpenId);
|
||||||
|
//api.SendMessage(e.OpenId, "由于长时间未搭理客服,您的客服状态已退出!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,398 @@
|
|||||||
|
using Senparc.Weixin.MP.MessageHandlers;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using System.IO;
|
||||||
|
using Senparc.Weixin.MP.Entities.Request;
|
||||||
|
using Senparc.Weixin.MP.Entities;
|
||||||
|
using Senparc.NeuChar.Entities;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Senparc.NeuChar.Entities.Request;
|
||||||
|
using System.Linq;
|
||||||
|
using Senparc.Weixin.MP.AdvancedAPIs;
|
||||||
|
using Senparc.CO2NET.Utilities;
|
||||||
|
using Senparc.Weixin.MP;
|
||||||
|
using NewLife.Log;
|
||||||
|
using Senparc.NeuChar.Helpers;
|
||||||
|
|
||||||
|
namespace COMCMS.API.Weixin.CustomMessageHandler
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义MessageHandler
|
||||||
|
/// 把MessageHandler作为基类,重写对应请求的处理方法
|
||||||
|
/// </summary>
|
||||||
|
public partial class CustomMessageHandler : MessageHandler<CustomMessageContext> /*如果不需要自定义,可以直接使用:
|
||||||
|
MessageHandler<DefaultMpMessageContext> */
|
||||||
|
{
|
||||||
|
private Config cfg = Config.GetSystemConfig();
|
||||||
|
/// <summary>
|
||||||
|
/// 模板消息集合(Key:checkCode,Value:OpenId)
|
||||||
|
/// 注意:这里只做测试,只适用于单服务器
|
||||||
|
/// </summary>
|
||||||
|
public static Dictionary<string, string> TemplateMessageCollection = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
private string appId = "";
|
||||||
|
/// <summary>
|
||||||
|
/// 为中间件提供生成当前类的委托
|
||||||
|
/// </summary>
|
||||||
|
public static Func<Stream, PostModel, int, CustomMessageHandler> GenerateMessageHandler = (stream, postModel, maxRecordCount)
|
||||||
|
=> new CustomMessageHandler(stream, postModel, maxRecordCount, false /* 是否只允许处理加密消息,以提高安全性 */);
|
||||||
|
public CustomMessageHandler(Stream inputStream, PostModel postModel, int maxRecordCount = 0, bool onlyAllowEcryptMessage = false)
|
||||||
|
: base(inputStream, postModel, maxRecordCount, onlyAllowEcryptMessage)
|
||||||
|
{
|
||||||
|
//这里设置仅用于测试,实际开发可以在外部更全局的地方设置,
|
||||||
|
//比如MessageHandler<MessageContext>.GlobalGlobalMessageContext.ExpireMinutes = 3。
|
||||||
|
GlobalMessageContext.ExpireMinutes = 3;
|
||||||
|
|
||||||
|
//OnlyAllowEcryptMessage = true;//是否只允许接收加密消息,默认为 false
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(postModel.AppId))
|
||||||
|
{
|
||||||
|
appId = postModel.AppId;//通过第三方开放平台发送过来的请求
|
||||||
|
}
|
||||||
|
else
|
||||||
|
appId = cfg.AppId;
|
||||||
|
|
||||||
|
//在指定条件下,不使用消息去重
|
||||||
|
base.OmitRepeatedMessageFunc = requestMessage =>
|
||||||
|
{
|
||||||
|
var textRequestMessage = requestMessage as RequestMessageText;
|
||||||
|
if (textRequestMessage != null && textRequestMessage.Content == "容错")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IResponseMessageBase DefaultResponseMessage(IRequestMessageBase requestMessage)
|
||||||
|
{
|
||||||
|
/* 所有没有被处理的消息会默认返回这里的结果,
|
||||||
|
* 因此,如果想把整个微信请求委托出去(例如需要使用分布式或从其他服务器获取请求),
|
||||||
|
* 只需要在这里统一发出委托请求,如:
|
||||||
|
* var responseMessage = MessageAgent.RequestResponseMessage(agentUrl, agentToken, RequestDocument.ToString());
|
||||||
|
* return responseMessage;
|
||||||
|
*/
|
||||||
|
|
||||||
|
var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "这条消息来自DefaultResponseMessage。";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理文字请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage">请求消息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnTextRequestAsync(RequestMessageText requestMessage)
|
||||||
|
{
|
||||||
|
var defaultResponseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
IResponseMessageBase IR = null;
|
||||||
|
Common.MessageFunction cmfun = new Common.MessageFunction();
|
||||||
|
int ruleId = 0;
|
||||||
|
|
||||||
|
var requestHandler = await requestMessage.StartHandler().Default(async () =>
|
||||||
|
{
|
||||||
|
string keywords = requestMessage.Content;
|
||||||
|
if (!string.IsNullOrEmpty(keywords)) keywords = keywords.Trim();
|
||||||
|
|
||||||
|
var currentMessageContext = await base.GetCurrentMessageContext();
|
||||||
|
|
||||||
|
//先精确匹配,再模糊匹配
|
||||||
|
Core.WeixinRequestRule rule = Core.WeixinRequestRule.Find(Core.WeixinRequestRule._.Keywords == keywords & Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.Text);
|
||||||
|
|
||||||
|
if (rule == null)
|
||||||
|
{
|
||||||
|
//模糊匹配
|
||||||
|
IList<Core.WeixinRequestRule> listRule = Core.WeixinRequestRule.FindAll(Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.Text & Core.WeixinRequestRule._.IsLikeQuery == 1, null, null, 0, 0);
|
||||||
|
if (listRule != null && listRule.Count > 0)
|
||||||
|
{
|
||||||
|
int lenKeyword = keywords.Length;
|
||||||
|
foreach (var item in listRule)
|
||||||
|
{
|
||||||
|
if (lenKeyword >= item.Keywords.Length && keywords.IndexOf(item.Keywords) >= 0)
|
||||||
|
{
|
||||||
|
rule = item;//规则
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rule == null)
|
||||||
|
{
|
||||||
|
Core.WeixinRequestRule notFindKeywordRule = Core.WeixinRequestRule.Find(Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.NotFindKeyword);
|
||||||
|
if (notFindKeywordRule == null)
|
||||||
|
{
|
||||||
|
//找不到规则
|
||||||
|
Core.WeixinResponseContent entity = new Core.WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = "none",
|
||||||
|
ReponseContent = "未取到关键词对应的数据",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
return cmfun.GetResponseMessageTxtByContent(requestMessage, "未找到匹配的关键词", 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ruleId = notFindKeywordRule.Id;
|
||||||
|
switch (notFindKeywordRule.ResponseType)
|
||||||
|
{
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.Text:
|
||||||
|
//发送纯文字
|
||||||
|
IR = cmfun.GetResponseMessageTxt(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.Image:
|
||||||
|
//发送多图文
|
||||||
|
IR = cmfun.GetResponseMessageNews(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.Voice:
|
||||||
|
//发送语音
|
||||||
|
IR = cmfun.GetResponseMessageeMusic(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.SingleImage:
|
||||||
|
IR = cmfun.GetResponseMessageSingleImagesContent(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return IR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Core.WeixinResponseContent model = new Core.WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.Content,
|
||||||
|
ResponseType = Core.WeixinResponseContent.GetResponseType((int)requestMessage.MsgType),
|
||||||
|
ReponseContent = requestMessage.ToString(),
|
||||||
|
XmlContent = string.Empty
|
||||||
|
};
|
||||||
|
model.Insert();
|
||||||
|
|
||||||
|
|
||||||
|
return IR;
|
||||||
|
});
|
||||||
|
|
||||||
|
return requestHandler.GetResponseMessage() as IResponseMessageBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理位置请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnLocationRequestAsync(RequestMessageLocation requestMessage)
|
||||||
|
{
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
var locationService = new LocationService();
|
||||||
|
var responseMessage = locationService.GetResponseMessage(requestMessage as RequestMessageLocation);
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override async Task<IResponseMessageBase> OnShortVideoRequestAsync(RequestMessageShortVideo requestMessage)
|
||||||
|
{
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "您刚才发送的是小视频";
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理图片请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnImageRequestAsync(RequestMessageImage requestMessage)
|
||||||
|
{
|
||||||
|
//一隔一返回News或Image格式
|
||||||
|
if (base.GlobalMessageContext.GetMessageContext(requestMessage).RequestMessages.Count() % 2 == 0)
|
||||||
|
{
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageNews>();
|
||||||
|
|
||||||
|
responseMessage.Articles.Add(new Senparc.NeuChar.Entities.Article()
|
||||||
|
{
|
||||||
|
Title = "您刚才发送了图片信息",
|
||||||
|
Description = "您发送的图片将会显示在边上",
|
||||||
|
PicUrl = requestMessage.PicUrl,
|
||||||
|
Url = "https://sdk.weixin.senparc.com"
|
||||||
|
});
|
||||||
|
responseMessage.Articles.Add(new Senparc.NeuChar.Entities.Article()
|
||||||
|
{
|
||||||
|
Title = "第二条",
|
||||||
|
Description = "第二条带连接的内容",
|
||||||
|
PicUrl = requestMessage.PicUrl,
|
||||||
|
Url = "https://sdk.weixin.senparc.com"
|
||||||
|
});
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
//return responseMessage;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageImage>();
|
||||||
|
responseMessage.Image.MediaId = requestMessage.MediaId;
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
//return responseMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理语音请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnVoiceRequestAsync(RequestMessageVoice requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageMusic>();
|
||||||
|
//上传缩略图
|
||||||
|
//var accessToken = Containers.AccessTokenContainer.TryGetAccessToken(appId, appSecret);
|
||||||
|
var uploadResult = Senparc.Weixin.MP.AdvancedAPIs.MediaApi.UploadTemporaryMedia(appId, UploadMediaFileType.image,
|
||||||
|
ServerUtility.ContentRootMapPath("~/Images/Logo.jpg"));
|
||||||
|
|
||||||
|
//设置音乐信息
|
||||||
|
responseMessage.Music.Title = "天籁之音";
|
||||||
|
responseMessage.Music.Description = "播放您上传的语音";
|
||||||
|
responseMessage.Music.MusicUrl = "https://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
|
||||||
|
responseMessage.Music.HQMusicUrl = "https://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
|
||||||
|
responseMessage.Music.ThumbMediaId = uploadResult.media_id;
|
||||||
|
|
||||||
|
//推送一条客服消息
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CustomApi.SendText(appId, OpenId, "本次上传的音频MediaId:" + requestMessage.MediaId);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 处理视频请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnVideoRequestAsync(RequestMessageVideo requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "您发送了一条视频信息,ID:" + requestMessage.MediaId;
|
||||||
|
|
||||||
|
#region 上传素材并推送到客户端
|
||||||
|
|
||||||
|
//Task.Factory.StartNew(async () =>
|
||||||
|
//{
|
||||||
|
// //上传素材
|
||||||
|
// var dir = ServerUtility.ContentRootMapPath("~/App_Data/TempVideo/");
|
||||||
|
// var file = await MediaApi.GetAsync(appId, requestMessage.MediaId, dir);
|
||||||
|
// var uploadResult = await MediaApi.UploadTemporaryMediaAsync(appId, UploadMediaFileType.video, file, 50000);
|
||||||
|
// await CustomApi.SendVideoAsync(appId, base.WeixinOpenId, uploadResult.media_id, "这是您刚才发送的视频", "这是一条视频消息");
|
||||||
|
//}).ContinueWith(async task =>
|
||||||
|
//{
|
||||||
|
// if (task.Exception != null)
|
||||||
|
// {
|
||||||
|
// WeixinTrace.Log("OnVideoRequest()储存Video过程发生错误:", task.Exception.Message);
|
||||||
|
|
||||||
|
|
||||||
|
// var msg = string.Format("上传素材出错:{0}\r\n{1}",
|
||||||
|
// task.Exception.Message,
|
||||||
|
// task.Exception.InnerException != null
|
||||||
|
// ? task.Exception.InnerException.Message
|
||||||
|
// : null);
|
||||||
|
// await CustomApi.SendTextAsync(appId, base.WeixinOpenId, msg);
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理链接消息请求
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnLinkRequestAsync(RequestMessageLink requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
responseMessage.Content = string.Format(@"您发送了一条连接信息:
|
||||||
|
Title:{0}
|
||||||
|
Description:{1}
|
||||||
|
Url:{2}", requestMessage.Title, requestMessage.Description, requestMessage.Url);
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<IResponseMessageBase> OnFileRequestAsync(RequestMessageFile requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = requestMessage.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = string.Format(@"您发送了一个文件:
|
||||||
|
文件名:{0}
|
||||||
|
说明:{1}
|
||||||
|
大小:{2}
|
||||||
|
MD5:{3}", requestMessage.Title, requestMessage.Description, requestMessage.FileTotalLen, requestMessage.FileMd5);
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理事件请求(这个方法一般不用重写,这里仅作为示例出现。除非需要在判断具体Event类型以外对Event信息进行统一操作
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override async Task<IResponseMessageBase> OnEventRequestAsync(IRequestMessageEventBase requestMessage)
|
||||||
|
{
|
||||||
|
var eventResponseMessage = await base.OnEventRequestAsync(requestMessage);//对于Event下属分类的重写方法,见:CustomerMessageHandler_Events.cs
|
||||||
|
//TODO: 对Event信息进行统一操作
|
||||||
|
return eventResponseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task<IResponseMessageBase> OnUnknownTypeRequestAsync(RequestMessageUnknownType requestMessage)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 此方法用于应急处理SDK没有提供的消息类型,
|
||||||
|
* 原始XML可以通过requestMessage.RequestDocument(或this.RequestDocument)获取到。
|
||||||
|
* 如果不重写此方法,遇到未知的请求类型将会抛出异常(v14.8.3 之前的版本就是这么做的)
|
||||||
|
*/
|
||||||
|
var msgType = Senparc.NeuChar.Helpers.MsgTypeHelper.GetRequestMsgTypeString(requestMessage.RequestDocument);
|
||||||
|
var responseMessage = this.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "未知消息类型:" + msgType;
|
||||||
|
XTrace.WriteLine("未知请求消息类型", requestMessage.RequestDocument.ToString());
|
||||||
|
//WeixinTrace.SendCustomLog("未知请求消息类型", requestMessage.RequestDocument.ToString());//记录到日志中
|
||||||
|
|
||||||
|
return await Task.Run(() =>
|
||||||
|
{
|
||||||
|
return responseMessage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,306 @@
|
|||||||
|
using COMCMS.API.Weixin.Download;
|
||||||
|
using NewLife.Configuration;
|
||||||
|
using Senparc.NeuChar.Entities;
|
||||||
|
using Senparc.Weixin.MP.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace COMCMS.API.Weixin.CustomMessageHandler
|
||||||
|
{
|
||||||
|
public partial class CustomMessageHandler
|
||||||
|
{
|
||||||
|
public string GetDownloadInfo(CodeRecord codeRecord)
|
||||||
|
{
|
||||||
|
return string.Format(@"您已通过二维码验证,浏览器即将开始下载 Senparc.Weixin SDK 帮助文档。
|
||||||
|
当前选择的版本:v{0}({1})
|
||||||
|
|
||||||
|
我们期待您的意见和建议,客服热线:400-031-8816。
|
||||||
|
|
||||||
|
感谢您对盛派网络的支持!
|
||||||
|
|
||||||
|
© {2} Senparc", codeRecord.Version, codeRecord.IsWebVersion ? "网页版" : ".chm文档版", DateTime.Now.Year);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IResponseMessageBase OnTextOrEventRequest(RequestMessageText requestMessage)
|
||||||
|
{
|
||||||
|
// 预处理文字或事件类型请求。
|
||||||
|
// 这个请求是一个比较特殊的请求,通常用于统一处理来自文字或菜单按钮的同一个执行逻辑,
|
||||||
|
// 会在执行OnTextRequest或OnEventRequest之前触发,具有以下一些特征:
|
||||||
|
// 1、如果返回null,则继续执行OnTextRequest或OnEventRequest
|
||||||
|
// 2、如果返回不为null,则终止执行OnTextRequest或OnEventRequest,返回最终ResponseMessage
|
||||||
|
// 3、如果是事件,则会将RequestMessageEvent自动转为RequestMessageText类型,其中RequestMessageText.Content就是RequestMessageEvent.EventKey
|
||||||
|
|
||||||
|
if (requestMessage.Content == "OneClick")
|
||||||
|
{
|
||||||
|
var strongResponseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||||
|
strongResponseMessage.Content = "您点击了底部按钮。\r\n为了测试微信软件换行bug的应对措施,这里做了一个——\r\n换行";
|
||||||
|
return strongResponseMessage;
|
||||||
|
}
|
||||||
|
return null;//返回null,则继续执行OnTextRequest或OnEventRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string GetWXApiUrl(string url, string token, string openid)
|
||||||
|
{
|
||||||
|
if (url.Contains("?"))
|
||||||
|
{
|
||||||
|
return url + "&token=" + token + "&openid=" + openid;
|
||||||
|
}
|
||||||
|
return url + "?token=" + token + "&openid=" + openid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 点击事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Click requestMessage)
|
||||||
|
{
|
||||||
|
//菜单点击,需要跟创建菜单时的Key匹配
|
||||||
|
IResponseMessageBase IR = null;
|
||||||
|
Common.MessageFunction cmfun = new Common.MessageFunction();
|
||||||
|
int responseType = 0, ruleId = 0;
|
||||||
|
|
||||||
|
string keywords = requestMessage.EventKey; //事件key
|
||||||
|
|
||||||
|
//先精确匹配,再模糊匹配
|
||||||
|
Core.WeixinRequestRule rule = Core.WeixinRequestRule.Find(Core.WeixinRequestRule._.Keywords == keywords & Core.WeixinRequestRule._.RequestType == (int)Core.WeixinRequestRule.XRequestType.CustomMenu);
|
||||||
|
|
||||||
|
if (rule == null)
|
||||||
|
{
|
||||||
|
//找不到规则
|
||||||
|
Core.WeixinResponseContent entity = new Core.WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.EventKey,
|
||||||
|
ResponseType = "none",
|
||||||
|
ReponseContent = "未取到相应的事件规则",
|
||||||
|
XmlContent = requestMessage.ToUserName
|
||||||
|
};
|
||||||
|
entity.Insert();
|
||||||
|
return cmfun.GetResponseMessageTxtByContent(requestMessage, "未取到相应的事件规则", 0);
|
||||||
|
}
|
||||||
|
responseType = rule.ResponseType;
|
||||||
|
ruleId = rule.Id;
|
||||||
|
switch (responseType)
|
||||||
|
{
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.Text:
|
||||||
|
//发送纯文字
|
||||||
|
IR = cmfun.GetResponseMessageTxt(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.Image:
|
||||||
|
//发送多图文
|
||||||
|
IR = cmfun.GetResponseMessageNews(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.Voice:
|
||||||
|
//发送语音
|
||||||
|
IR = cmfun.GetResponseMessageeMusic(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
case (int)Core.WeixinRequestRule.XResponseType.SingleImage:
|
||||||
|
IR = cmfun.GetResponseMessageSingleImagesContent(requestMessage, ruleId, 0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Core.WeixinResponseContent model = new Core.WeixinResponseContent()
|
||||||
|
{
|
||||||
|
OpenId = requestMessage.FromUserName,
|
||||||
|
RequestType = requestMessage.MsgType.ToString(),
|
||||||
|
RequestContent = requestMessage.EventKey,
|
||||||
|
ResponseType = Core.WeixinResponseContent.GetResponseType((int)requestMessage.MsgType),
|
||||||
|
ReponseContent = requestMessage.ToString(),
|
||||||
|
XmlContent = string.Empty
|
||||||
|
};
|
||||||
|
model.Insert();
|
||||||
|
|
||||||
|
return IR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 进入事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_EnterRequest(RequestMessageEvent_Enter requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageText>(requestMessage);
|
||||||
|
responseMessage.Content = "您刚才发送了ENTER事件请求。";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 位置事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_LocationRequest(RequestMessageEvent_Location requestMessage)
|
||||||
|
{
|
||||||
|
//这里是微信客户端(通过微信服务器)自动发送过来的位置信息
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "这里写什么都无所谓,比如:上帝爱你!";
|
||||||
|
return responseMessage;//这里也可以返回null(需要注意写日志时候null的问题)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过二维码扫描关注扫描事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_ScanRequest(RequestMessageEvent_Scan requestMessage)
|
||||||
|
{
|
||||||
|
//通过扫描关注
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||||
|
|
||||||
|
//下载文档
|
||||||
|
if (!string.IsNullOrEmpty(requestMessage.EventKey))
|
||||||
|
{
|
||||||
|
//这里可以写扫码逻辑
|
||||||
|
}
|
||||||
|
|
||||||
|
responseMessage.Content = responseMessage.Content ?? string.Format("通过扫描二维码进入,场景值:{0}", requestMessage.EventKey);
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打开网页事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_ViewRequest(RequestMessageEvent_View requestMessage)
|
||||||
|
{
|
||||||
|
//说明:这条消息只作为接收,下面的responseMessage到达不了客户端,类似OnEvent_UnsubscribeRequest
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "您点击了view按钮,将打开网页:" + requestMessage.EventKey;
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 群发完成事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_MassSendJobFinishRequest(RequestMessageEvent_MassSendJobFinish requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "接收到了群发完成的信息。";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订阅(关注)事件
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_SubscribeRequest(RequestMessageEvent_Subscribe requestMessage)
|
||||||
|
{
|
||||||
|
return new Common.MessageFunction().EventSubscribe(6, requestMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退订
|
||||||
|
/// 实际上用户无法收到非订阅账号的消息,所以这里可以随便写。
|
||||||
|
/// unsubscribe事件的意义在于及时删除网站应用中已经记录的OpenID绑定,消除冗余数据。并且关注用户流失的情况。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_UnsubscribeRequest(RequestMessageEvent_Unsubscribe requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "有空再来";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事件之扫码推事件(scancode_push)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_ScancodePushRequest(RequestMessageEvent_Scancode_Push requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "事件之扫码推事件";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事件之扫码推事件且弹出“消息接收中”提示框(scancode_waitmsg)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_ScancodeWaitmsgRequest(RequestMessageEvent_Scancode_Waitmsg requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "事件之扫码推事件且弹出“消息接收中”提示框";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事件之弹出拍照或者相册发图(pic_photo_or_album)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_PicPhotoOrAlbumRequest(RequestMessageEvent_Pic_Photo_Or_Album requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "事件之弹出拍照或者相册发图";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事件之弹出系统拍照发图(pic_sysphoto)
|
||||||
|
/// 实际测试时发现微信并没有推送RequestMessageEvent_Pic_Sysphoto消息,只能接收到用户在微信中发送的图片消息。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_PicSysphotoRequest(RequestMessageEvent_Pic_Sysphoto requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "事件之弹出系统拍照发图";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事件之弹出微信相册发图器(pic_weixin)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_PicWeixinRequest(RequestMessageEvent_Pic_Weixin requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "事件之弹出微信相册发图器";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事件之弹出地理位置选择器(location_select)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestMessage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override IResponseMessageBase OnEvent_LocationSelectRequest(RequestMessageEvent_Location_Select requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = base.CreateResponseMessage<ResponseMessageText>();
|
||||||
|
responseMessage.Content = "事件之弹出地理位置选择器";
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 微信认证事件推送
|
||||||
|
|
||||||
|
public override IResponseMessageBase OnEvent_QualificationVerifySuccessRequest(RequestMessageEvent_QualificationVerifySuccess requestMessage)
|
||||||
|
{
|
||||||
|
//以下方法可以强制定义返回的字符串值
|
||||||
|
//TextResponseMessage = "your content";
|
||||||
|
//return null;
|
||||||
|
|
||||||
|
return new SuccessResponseMessage();//返回"success"字符串
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Senparc.Weixin.MP.AdvancedAPIs.QrCode;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace COMCMS.API.Weixin.Download
|
||||||
|
{
|
||||||
|
public class CodeRecord
|
||||||
|
{
|
||||||
|
public string Key { get; set; }
|
||||||
|
public int QrCodeId { get; set; }
|
||||||
|
public CreateQrCodeResult QrCodeTicket { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
|
public bool Used { get; set; }
|
||||||
|
public bool AllowDownload { get; set; }
|
||||||
|
public bool IsWebVersion { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using Senparc.CO2NET.Helpers;
|
||||||
|
using Senparc.CO2NET.Helpers.BaiduMap;
|
||||||
|
using Senparc.CO2NET.Helpers.GoogleMap;
|
||||||
|
using Senparc.NeuChar.Entities;
|
||||||
|
using Senparc.Weixin.MP.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace COMCMS.API.Weixin
|
||||||
|
{
|
||||||
|
public class LocationService
|
||||||
|
{
|
||||||
|
public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
|
||||||
|
{
|
||||||
|
var responseMessage = ResponseMessageBase.CreateFromRequestMessage<ResponseMessageNews>(requestMessage);
|
||||||
|
|
||||||
|
#region 百度地图
|
||||||
|
|
||||||
|
{
|
||||||
|
var markersList = new List<BaiduMarkers>();
|
||||||
|
markersList.Add(new BaiduMarkers()
|
||||||
|
{
|
||||||
|
Longitude = requestMessage.Location_X,
|
||||||
|
Latitude = requestMessage.Location_Y,
|
||||||
|
Color = "red",
|
||||||
|
Label = "S",
|
||||||
|
Size = BaiduMarkerSize.m
|
||||||
|
});
|
||||||
|
|
||||||
|
var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y, 1, 6, markersList);
|
||||||
|
responseMessage.Articles.Add(new Article()
|
||||||
|
{
|
||||||
|
Description = string.Format("【来自百度地图】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
|
||||||
|
requestMessage.Location_X, requestMessage.Location_Y,
|
||||||
|
requestMessage.Scale, requestMessage.Label),
|
||||||
|
PicUrl = mapUrl,
|
||||||
|
Title = "定位地点周边地图",
|
||||||
|
Url = mapUrl
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region GoogleMap
|
||||||
|
|
||||||
|
{
|
||||||
|
var markersList = new List<GoogleMapMarkers>();
|
||||||
|
markersList.Add(new GoogleMapMarkers()
|
||||||
|
{
|
||||||
|
X = requestMessage.Location_X,
|
||||||
|
Y = requestMessage.Location_Y,
|
||||||
|
Color = "red",
|
||||||
|
Label = "S",
|
||||||
|
Size = GoogleMapMarkerSize.Default,
|
||||||
|
});
|
||||||
|
var mapSize = "480x600";
|
||||||
|
var mapUrl = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
|
||||||
|
markersList, mapSize);
|
||||||
|
responseMessage.Articles.Add(new Article()
|
||||||
|
{
|
||||||
|
Description = string.Format("【来自GoogleMap】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
|
||||||
|
requestMessage.Location_X, requestMessage.Location_Y,
|
||||||
|
requestMessage.Scale, requestMessage.Label),
|
||||||
|
PicUrl = mapUrl,
|
||||||
|
Title = "定位地点周边地图",
|
||||||
|
Url = mapUrl
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
responseMessage.Articles.Add(new Article()
|
||||||
|
{
|
||||||
|
Title = "微信公众平台SDK 官网链接",
|
||||||
|
Description = "Senparc.Weixin.MK SDK地址",
|
||||||
|
PicUrl = "https://sdk.weixin.senparc.com/images/logo.jpg",
|
||||||
|
Url = "https://sdk.weixin.senparc.com"
|
||||||
|
});
|
||||||
|
|
||||||
|
return responseMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
-15
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -23,15 +25,18 @@ namespace COMCMS.Common
|
|||||||
encryptKey = GetSubString(encryptKey, 0, 32, "");
|
encryptKey = GetSubString(encryptKey, 0, 32, "");
|
||||||
encryptKey = encryptKey.PadRight(32, ' ');
|
encryptKey = encryptKey.PadRight(32, ' ');
|
||||||
|
|
||||||
RijndaelManaged rijndaelProvider = new RijndaelManaged();
|
|
||||||
rijndaelProvider.Key = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 32));
|
|
||||||
rijndaelProvider.IV = Keys;
|
|
||||||
ICryptoTransform rijndaelEncrypt = rijndaelProvider.CreateEncryptor();
|
|
||||||
|
|
||||||
byte[] inputData = Encoding.UTF8.GetBytes(encryptString);
|
byte[] inputData = Encoding.UTF8.GetBytes(encryptString);
|
||||||
byte[] encryptedData = rijndaelEncrypt.TransformFinalBlock(inputData, 0, inputData.Length);
|
|
||||||
|
|
||||||
return Convert.ToBase64String(encryptedData);
|
using Aes aes = Aes.Create();
|
||||||
|
aes.Key = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 32));
|
||||||
|
aes.IV = Keys;
|
||||||
|
|
||||||
|
using MemoryStream ms = new MemoryStream();
|
||||||
|
using CryptoStream cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write);
|
||||||
|
|
||||||
|
cs.Write(inputData, 0, inputData.Length);
|
||||||
|
cs.FlushFinalBlock();
|
||||||
|
return Convert.ToBase64String(ms.ToArray());
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解密
|
/// 解密
|
||||||
@@ -46,15 +51,20 @@ namespace COMCMS.Common
|
|||||||
decryptKey = GetSubString(decryptKey, 0, 32, "");
|
decryptKey = GetSubString(decryptKey, 0, 32, "");
|
||||||
decryptKey = decryptKey.PadRight(32, ' ');
|
decryptKey = decryptKey.PadRight(32, ' ');
|
||||||
|
|
||||||
RijndaelManaged rijndaelProvider = new RijndaelManaged();
|
|
||||||
rijndaelProvider.Key = Encoding.UTF8.GetBytes(decryptKey);
|
|
||||||
rijndaelProvider.IV = Keys;
|
|
||||||
ICryptoTransform rijndaelDecrypt = rijndaelProvider.CreateDecryptor();
|
|
||||||
|
|
||||||
byte[] inputData = Convert.FromBase64String(decryptString);
|
byte[] inputData = Convert.FromBase64String(decryptString);
|
||||||
byte[] decryptedData = rijndaelDecrypt.TransformFinalBlock(inputData, 0, inputData.Length);
|
|
||||||
|
|
||||||
return Encoding.UTF8.GetString(decryptedData);
|
using Aes aes = Aes.Create();
|
||||||
|
aes.Key = Encoding.UTF8.GetBytes(decryptKey);
|
||||||
|
aes.IV = Keys;
|
||||||
|
|
||||||
|
using MemoryStream ms = new MemoryStream();
|
||||||
|
using CryptoStream cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Write);
|
||||||
|
|
||||||
|
cs.Write(inputData, 0, inputData.Length);
|
||||||
|
cs.FlushFinalBlock();
|
||||||
|
|
||||||
|
|
||||||
|
return Encoding.UTF8.GetString(ms.ToArray());
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
|
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||||
<PackageReference Include="NewLife.Core" Version="8.3.2019.822" />
|
<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="PinYinConverterCore" Version="1.0.2" />
|
||||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
|
<PackageReference Include="SkiaSharp" Version="3.119.4" />
|
||||||
<PackageReference Include="ZKWeb.System.Drawing" Version="4.0.1" />
|
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="3.119.4" />
|
||||||
</ItemGroup>
|
<PackageReference Include="SkiaSharp.QrCode" Version="0.12.0" />
|
||||||
|
<PackageReference Include="System.Configuration.ConfigurationManager" Version="10.0.9" />
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.AspNetCore.Authentication.Cookies">
|
|
||||||
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Cookies.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ namespace COMCMS.Common
|
|||||||
{
|
{
|
||||||
Expires = DateTime.Now.AddMinutes(expires),
|
Expires = DateTime.Now.AddMinutes(expires),
|
||||||
Path = "/",
|
Path = "/",
|
||||||
HttpOnly = true
|
HttpOnly = true,
|
||||||
|
SameSite = SameSiteMode.Lax
|
||||||
};
|
};
|
||||||
MyHttpContext.Current.Response.Cookies.Append(strName, strValue, op);//用户名
|
MyHttpContext.Current.Response.Cookies.Append(strName, strValue, op);//用户名
|
||||||
}
|
}
|
||||||
@@ -56,7 +57,14 @@ namespace COMCMS.Common
|
|||||||
/// <param name="strKey"></param>
|
/// <param name="strKey"></param>
|
||||||
public static void ClearCookies(string strKey)
|
public static void ClearCookies(string strKey)
|
||||||
{
|
{
|
||||||
MyHttpContext.Current.Response.Cookies.Delete(strKey);
|
CookieOptions op = new CookieOptions
|
||||||
|
{
|
||||||
|
Expires = DateTime.Now.AddMinutes(-1),
|
||||||
|
Path = "/",
|
||||||
|
HttpOnly = true,
|
||||||
|
SameSite = SameSiteMode.Lax
|
||||||
|
};
|
||||||
|
MyHttpContext.Current.Response.Cookies.Delete(strKey, op);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,22 +38,16 @@ namespace COMCMS.Common
|
|||||||
StringBuilder strPage = new StringBuilder();
|
StringBuilder strPage = new StringBuilder();
|
||||||
string pageLink = "";// url + "?id=" + HttpContext.Current.Request.QueryString["id"] + "&page={0}";
|
string pageLink = "";// url + "?id=" + HttpContext.Current.Request.QueryString["id"] + "&page={0}";
|
||||||
string strQueryString = MyHttpContext.Current.Request.QueryString.ToString().ToLower();
|
string strQueryString = MyHttpContext.Current.Request.QueryString.ToString().ToLower();
|
||||||
if (isRewrite != 5)
|
if (isRewrite != 5 && isRewrite != 99)
|
||||||
url = url.ToLower();
|
url = url.ToLower();
|
||||||
pageLink = url + "?" + strQueryString;
|
pageLink = url + "?" + strQueryString;
|
||||||
string currPage = MyHttpContext.Current.Request.Query["page"];
|
string currPage = MyHttpContext.Current.Request.Query["page"];
|
||||||
string id = MyHttpContext.Current.Request.Query["id"];
|
string id = MyHttpContext.Current.Request.Query["id"];
|
||||||
|
|
||||||
if (isRewrite == 5)
|
if (isRewrite == 5)
|
||||||
{
|
{
|
||||||
url = $"/{filepath}/index.html";
|
url = $"/{filepath}/index.html";
|
||||||
}
|
}
|
||||||
if (url == "memberdownloads.aspx" && isRewrite == 2)
|
|
||||||
{
|
|
||||||
string t = MyHttpContext.Current.Request.Query["t"];
|
|
||||||
if (string.IsNullOrEmpty(t) || !Utils.IsInt(t))
|
|
||||||
t = "1";
|
|
||||||
url = string.Format("memberdownloads-{0}.aspx", t);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (isRewrite)
|
switch (isRewrite)
|
||||||
{
|
{
|
||||||
@@ -71,8 +65,15 @@ namespace COMCMS.Common
|
|||||||
pageLink = url.Replace(".", "-{0}.");
|
pageLink = url.Replace(".", "-{0}.");
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
if(url.EndsWith(".html") || url.EndsWith(".aspx"))
|
||||||
|
{
|
||||||
url = url.Replace(".aspx", ".html");//避免设置错之后出现问题
|
url = url.Replace(".aspx", ".html");//避免设置错之后出现问题
|
||||||
pageLink = url.Replace(".", "-{0}.");
|
pageLink = url.Replace(".", "-{0}.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pageLink = url + "?page={0}";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
pageLink = url.Replace(".", "-{0}.");
|
pageLink = url.Replace(".", "-{0}.");
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.DrawingCore.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.DrawingCore.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.DrawingCore;
|
using System.Drawing;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
|
using SkiaSharp;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Security.Policy;
|
||||||
|
|
||||||
namespace COMCMS.Common
|
namespace COMCMS.Common
|
||||||
{
|
{
|
||||||
@@ -22,11 +26,11 @@ namespace COMCMS.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 程序绝对目录
|
/// 程序绝对目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string _ContentRootPath = DI.ServiceProvider.GetService<IHostingEnvironment>().ContentRootPath;
|
private static string _ContentRootPath = Environment.CurrentDirectory;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 静态文件
|
/// 静态文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string _WebRootPath = DI.ServiceProvider.GetService<IHostingEnvironment>().WebRootPath;
|
private static string _WebRootPath = _ContentRootPath + DirectorySeparatorChar + "wwwroot" + DirectorySeparatorChar;
|
||||||
|
|
||||||
#region 方式
|
#region 方式
|
||||||
public enum CutMode
|
public enum CutMode
|
||||||
@@ -61,7 +65,8 @@ namespace COMCMS.Common
|
|||||||
/// <param name="mode">生成缩略图的方式</param>
|
/// <param name="mode">生成缩略图的方式</param>
|
||||||
public static void MakeThumbnailImage(string fileName, string newFileName, int width, int height, CutMode mode)
|
public static void MakeThumbnailImage(string fileName, string newFileName, int width, int height, CutMode mode)
|
||||||
{
|
{
|
||||||
Image originalImage = Image.FromFile(fileName);
|
//Image originalImage = Image.FromFile(fileName);
|
||||||
|
var originalImage = SKBitmap.Decode(fileName);
|
||||||
int towidth = width;
|
int towidth = width;
|
||||||
int toheight = height;
|
int toheight = height;
|
||||||
|
|
||||||
@@ -114,91 +119,70 @@ namespace COMCMS.Common
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//新建一个bmp图片
|
|
||||||
Bitmap b = new Bitmap(towidth, toheight);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//新建一个画板
|
|
||||||
Graphics g = Graphics.FromImage(b);
|
|
||||||
//设置高质量插值法
|
|
||||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
||||||
//设置高质量,低速度呈现平滑程度
|
|
||||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
|
||||||
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
|
||||||
//清空画布并以透明背景色填充
|
|
||||||
g.Clear(Color.White);
|
|
||||||
//g.Clear(Color.Transparent);
|
|
||||||
//在指定位置并且按指定大小绘制原图片的指定部分
|
|
||||||
g.DrawImage(originalImage, new Rectangle(0, 0, towidth, toheight), new Rectangle(x, y, ow, oh), GraphicsUnit.Pixel);
|
|
||||||
|
|
||||||
SaveImage(b, newFileName, GetCodecInfo("image/" + GetFormat(newFileName).ToString().ToLower()));
|
var newImg = originalImage.Resize(new SKSizeI(towidth, toheight), new SKSamplingOptions(SKFilterMode.Linear, SKMipmapMode.Linear));
|
||||||
}
|
using var fs = new FileStream(newFileName, FileMode.Create);
|
||||||
catch (System.Exception e)
|
//判断类型
|
||||||
|
SKEncodedImageFormat imgType = new SKEncodedImageFormat();
|
||||||
|
string sFullExtension = Utils.GetFileExtName(fileName).ToLower();//扩展名
|
||||||
|
switch (sFullExtension)
|
||||||
{
|
{
|
||||||
throw e;
|
case ".jpg":
|
||||||
}
|
case ".jpeg":
|
||||||
finally
|
imgType = SKEncodedImageFormat.Jpeg;
|
||||||
{
|
break;
|
||||||
originalImage.Dispose();
|
case ".png":
|
||||||
b.Dispose();
|
imgType = SKEncodedImageFormat.Png;
|
||||||
|
break;
|
||||||
|
case ".gif":
|
||||||
|
imgType = SKEncodedImageFormat.Gif;
|
||||||
|
break;
|
||||||
|
case ".webp":
|
||||||
|
imgType = SKEncodedImageFormat.Webp;
|
||||||
|
break;
|
||||||
|
case ".bmp":
|
||||||
|
imgType = SKEncodedImageFormat.Bmp;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
imgType = SKEncodedImageFormat.Png;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
newImg.Encode(fs, imgType, 100);
|
||||||
|
fs.Flush();
|
||||||
|
|
||||||
|
//新建一个bmp图片
|
||||||
|
//Bitmap b = new Bitmap(towidth, toheight);
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// //新建一个画板
|
||||||
|
// Graphics g = Graphics.FromImage(b);
|
||||||
|
// //设置高质量插值法
|
||||||
|
// g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
// //设置高质量,低速度呈现平滑程度
|
||||||
|
// g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||||
|
// g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
|
// //清空画布并以透明背景色填充
|
||||||
|
// g.Clear(Color.White);
|
||||||
|
// //g.Clear(Color.Transparent);
|
||||||
|
// //在指定位置并且按指定大小绘制原图片的指定部分
|
||||||
|
// g.DrawImage(originalImage, new Rectangle(0, 0, towidth, toheight), new Rectangle(x, y, ow, oh), GraphicsUnit.Pixel);
|
||||||
|
|
||||||
|
// SaveImage(b, newFileName, GetCodecInfo("image/" + GetFormat(newFileName).ToString().ToLower()));
|
||||||
|
//}
|
||||||
|
//catch (System.Exception e)
|
||||||
|
//{
|
||||||
|
// throw e;
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// originalImage.Dispose();
|
||||||
|
// b.Dispose();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region 帮助方法
|
#region 帮助方法
|
||||||
/// <summary>
|
|
||||||
/// 保存图片
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="image">Image 对象</param>
|
|
||||||
/// <param name="savePath">保存路径</param>
|
|
||||||
/// <param name="ici">指定格式的编解码参数</param>
|
|
||||||
private static void SaveImage(Image image, string savePath, ImageCodecInfo ici)
|
|
||||||
{
|
|
||||||
//设置 原图片 对象的 EncoderParameters 对象
|
|
||||||
EncoderParameters parameters = new EncoderParameters(1);
|
|
||||||
parameters.Param[0] = new EncoderParameter(System.DrawingCore.Imaging.Encoder.Quality, ((long)100));
|
|
||||||
image.Save(savePath, ici, parameters);
|
|
||||||
parameters.Dispose();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 获取图像编码解码器的所有相关信息
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="mimeType">包含编码解码器的多用途网际邮件扩充协议 (MIME) 类型的字符串</param>
|
|
||||||
/// <returns>返回图像编码解码器的所有相关信息</returns>
|
|
||||||
private static ImageCodecInfo GetCodecInfo(string mimeType)
|
|
||||||
{
|
|
||||||
ImageCodecInfo[] CodecInfo = ImageCodecInfo.GetImageEncoders();
|
|
||||||
foreach (ImageCodecInfo ici in CodecInfo)
|
|
||||||
{
|
|
||||||
if (ici.MimeType == mimeType)
|
|
||||||
return ici;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 得到图片格式
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">文件名称</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static ImageFormat GetFormat(string name)
|
|
||||||
{
|
|
||||||
string ext = name.Substring(name.LastIndexOf(".") + 1);
|
|
||||||
switch (ext.ToLower())
|
|
||||||
{
|
|
||||||
case "jpg":
|
|
||||||
case "jpeg":
|
|
||||||
return ImageFormat.Jpeg;
|
|
||||||
case "bmp":
|
|
||||||
return ImageFormat.Bmp;
|
|
||||||
case "png":
|
|
||||||
return ImageFormat.Png;
|
|
||||||
case "gif":
|
|
||||||
return ImageFormat.Gif;
|
|
||||||
default:
|
|
||||||
return ImageFormat.Jpeg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 内容远程保存图片
|
#region 内容远程保存图片
|
||||||
@@ -212,8 +196,8 @@ namespace COMCMS.Common
|
|||||||
string recontent = content;
|
string recontent = content;
|
||||||
if (string.IsNullOrEmpty(content))
|
if (string.IsNullOrEmpty(content))
|
||||||
return "";
|
return "";
|
||||||
WebClient client = new WebClient();
|
//WebClient client = new WebClient();
|
||||||
|
var _httpClient = new HttpClient();
|
||||||
Regex reg = new Regex("IMG[^>]*?src\\s*=\\s*(?:\"(?<1>[^\"]*)\"|'(?<1>[^\']*)')", RegexOptions.IgnoreCase);
|
Regex reg = new Regex("IMG[^>]*?src\\s*=\\s*(?:\"(?<1>[^\"]*)\"|'(?<1>[^\']*)')", RegexOptions.IgnoreCase);
|
||||||
MatchCollection m = reg.Matches(content);
|
MatchCollection m = reg.Matches(content);
|
||||||
foreach (Match math in m)
|
foreach (Match math in m)
|
||||||
@@ -231,7 +215,7 @@ namespace COMCMS.Common
|
|||||||
else if (imgsrc.EndsWith("jpeg")) ext = "jpeg";
|
else if (imgsrc.EndsWith("jpeg")) ext = "jpeg";
|
||||||
else if (imgsrc.EndsWith("bmp")) ext = "bmp";
|
else if (imgsrc.EndsWith("bmp")) ext = "bmp";
|
||||||
string strNewImgName = Utils.GetOrderNum() + "." + ext;
|
string strNewImgName = Utils.GetOrderNum() + "." + ext;
|
||||||
string savepath = $"{_WebRootPath}\\userfiles\\images\\auto\\{DateTime.Now.Year.ToString()}\\{DateTime.Now.ToString("MM")}";//
|
string savepath = $"{_WebRootPath}{DirectorySeparatorChar}userfiles{DirectorySeparatorChar}images{DirectorySeparatorChar}auto{DirectorySeparatorChar}{DateTime.Now.Year.ToString()}\\{DateTime.Now.ToString("MM")}";//
|
||||||
string imgNewSrc = $"/userfiles/images/auto/{DateTime.Now.Year.ToString()}/{DateTime.Now.ToString("MM")}/{strNewImgName}";//保存后路径
|
string imgNewSrc = $"/userfiles/images/auto/{DateTime.Now.Year.ToString()}/{DateTime.Now.ToString("MM")}/{strNewImgName}";//保存后路径
|
||||||
//判断路径
|
//判断路径
|
||||||
if (!Directory.Exists(savepath))
|
if (!Directory.Exists(savepath))
|
||||||
@@ -239,8 +223,13 @@ namespace COMCMS.Common
|
|||||||
string fullpath = Path.Combine(savepath, strNewImgName);//图片
|
string fullpath = Path.Combine(savepath, strNewImgName);//图片
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
System.IO.FileStream fs;
|
||||||
|
byte[] urlContents = _httpClient.GetByteArrayAsync(imgUrl).Result;
|
||||||
|
fs = new System.IO.FileStream(fullpath, FileMode.CreateNew);
|
||||||
|
fs.Write(urlContents, 0, urlContents.Length);
|
||||||
//保存图片
|
//保存图片
|
||||||
client.DownloadFile(imgUrl, fullpath);
|
//client.DownloadFile(imgUrl, fullpath);
|
||||||
|
//_httpClient
|
||||||
recontent = recontent.Replace(imgUrl, imgNewSrc);
|
recontent = recontent.Replace(imgUrl, imgNewSrc);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
+336
-108
@@ -12,6 +12,9 @@ using Microsoft.Extensions.Configuration.Json;
|
|||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using NewLife.Caching;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
namespace COMCMS.Common
|
namespace COMCMS.Common
|
||||||
{
|
{
|
||||||
@@ -63,7 +66,18 @@ namespace COMCMS.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 与小程序验签的盐值
|
/// 与小程序验签的盐值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string SIGNSALT = "comcms";// ConfigurationManager.AppSettings["SignSalt"];
|
public static string SIGNSALT
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string strPrefixKey = Configuration["SystemSetting:SignSalt"];
|
||||||
|
if (string.IsNullOrEmpty(strPrefixKey))
|
||||||
|
{
|
||||||
|
strPrefixKey = "comcms";
|
||||||
|
}
|
||||||
|
return strPrefixKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -104,6 +118,11 @@ namespace COMCMS.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Home=99
|
Home=99
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内存缓存
|
||||||
|
/// </summary>
|
||||||
|
public static ICache MemoryCahce { get; set; } = Cache.Default;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 验证部分
|
#region 验证部分
|
||||||
@@ -138,6 +157,15 @@ namespace COMCMS.Common
|
|||||||
//A-Z, a-z, 0-9, -, /, =
|
//A-Z, a-z, 0-9, -, /, =
|
||||||
return Regex.IsMatch(str, @"[A-Za-z0-9-\/]");
|
return Regex.IsMatch(str, @"[A-Za-z0-9-\/]");
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 判断静态化文件名是否正确
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool ChekHTMLFileNameIsOK(string filename)
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(filename, @"^(?!index\b)[a-zA-Z0-9-]+(\.html)$");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证对象是否为货币格式
|
/// 验证对象是否为货币格式
|
||||||
@@ -181,6 +209,10 @@ namespace COMCMS.Common
|
|||||||
{
|
{
|
||||||
http = "https://";
|
http = "https://";
|
||||||
}
|
}
|
||||||
|
if (MyHttpContext.Current.Request.Headers["X-Scheme"].ToString() == "https")//增加判断反向代理
|
||||||
|
{
|
||||||
|
http = "https://";
|
||||||
|
}
|
||||||
string port = MyHttpContext.Current.Request.Host.Port.ToString();
|
string port = MyHttpContext.Current.Request.Host.Port.ToString();
|
||||||
if (string.IsNullOrEmpty(port) || port == "80" || port == "443")
|
if (string.IsNullOrEmpty(port) || port == "80" || port == "443")
|
||||||
return http + MyHttpContext.Current.Request.Host.Host;
|
return http + MyHttpContext.Current.Request.Host.Host;
|
||||||
@@ -217,7 +249,7 @@ namespace COMCMS.Common
|
|||||||
{
|
{
|
||||||
if (str.Length != 11)
|
if (str.Length != 11)
|
||||||
return false;
|
return false;
|
||||||
return Regex.IsMatch(str, @"^1[3|4|5|7|8|9][0-9]\d{4,8}$");
|
return Regex.IsMatch(str, @"^1[3|4|5|6|7|8|9][0-9]\d{4,8}$");
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为ip
|
/// 是否为ip
|
||||||
@@ -345,6 +377,213 @@ namespace COMCMS.Common
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否为日期型字符串
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="StrSource">日期字符串(2008-05-08)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsDate(string StrSource)
|
||||||
|
{
|
||||||
|
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>
|
||||||
|
private static readonly Regex RegexMobile =
|
||||||
|
new Regex(@"(iemobile|iphone|ipod|android|nokia|sonyericsson|blackberry|samsung|sec\-|windows ce|motorola|mot\-|up.b|midp\-)",
|
||||||
|
RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||||
|
/// <summary>
|
||||||
|
/// 通过UserAgent 判断是否是移动端
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userAgent"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsMobileRequest(string userAgent)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(userAgent) && RegexMobile.IsMatch(userAgent))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户浏览器
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userAgent"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetBrowser(string userAgent)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(userAgent))
|
||||||
|
{
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
userAgent = userAgent.ToLower();
|
||||||
|
|
||||||
|
if (userAgent.Contains("opera/ucweb"))
|
||||||
|
{ return "UC Opera"; }
|
||||||
|
else if (userAgent.Contains("openwave/ ucweb"))
|
||||||
|
{ return "UCOpenwave"; }
|
||||||
|
else if (userAgent.Contains("microMessenger"))
|
||||||
|
{ return "微信浏览器"; }
|
||||||
|
else if (userAgent.Contains("ucweb"))
|
||||||
|
{ return "UC"; }
|
||||||
|
else if (userAgent.Contains("360se"))
|
||||||
|
{ return "360"; }
|
||||||
|
else if (userAgent.Contains("metasr"))
|
||||||
|
{ return "搜狗"; }
|
||||||
|
else if (userAgent.Contains("maxthon"))
|
||||||
|
{ return "遨游"; }
|
||||||
|
else if (userAgent.Contains("the world"))
|
||||||
|
{ return "世界之窗"; }
|
||||||
|
else if (userAgent.Contains("tencenttraveler") || userAgent.Contains("qqbrowser"))
|
||||||
|
{ return "腾讯"; }
|
||||||
|
else if (userAgent.Contains("edge"))
|
||||||
|
{ return "Edge"; }
|
||||||
|
else if (userAgent.Contains("edg"))
|
||||||
|
{ return "Microsoft Edge"; }
|
||||||
|
else if (userAgent.Contains("chrome"))
|
||||||
|
{ return "Chrome"; }
|
||||||
|
else if (userAgent.Contains("safari"))
|
||||||
|
{ return "safari"; }
|
||||||
|
else if (userAgent.Contains("firefox"))
|
||||||
|
{ return "Firefox"; }
|
||||||
|
else if (userAgent.Contains("opera"))
|
||||||
|
{ return "Opera"; }
|
||||||
|
else if (userAgent.Contains("msie"))
|
||||||
|
{ return "IE"; }
|
||||||
|
else
|
||||||
|
{ return "未知"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取客户端操作系统版本
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetOSName(string userAgent)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(userAgent))
|
||||||
|
{
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
userAgent = userAgent.ToLower();
|
||||||
|
|
||||||
|
if (userAgent.Contains("android"))
|
||||||
|
{ return "Android"; }
|
||||||
|
else if (userAgent.Contains("mac os x"))
|
||||||
|
{ return "ios"; }
|
||||||
|
else if (userAgent.Contains("windows phone"))
|
||||||
|
{ return "Windows Phone"; }
|
||||||
|
else if (userAgent.Contains("nt 11.0"))
|
||||||
|
{ return "Windows 11"; }
|
||||||
|
else if (userAgent.Contains("nt 10.0"))
|
||||||
|
{ return "Windows 10"; }
|
||||||
|
else if (userAgent.Contains("NT 6.3"))
|
||||||
|
{ return "Windows8.1"; }
|
||||||
|
else if (userAgent.Contains("NT 6.2"))
|
||||||
|
{ return "Windows8"; }
|
||||||
|
else if (userAgent.Contains("nt 6.1"))
|
||||||
|
{ return "Windows 7"; }
|
||||||
|
else if (userAgent.Contains("nt 6.0"))
|
||||||
|
{ return "Windows Vista/Server 2008"; }
|
||||||
|
else if (userAgent.Contains("nt 5.2"))
|
||||||
|
{ return "Windows Server 2003"; }
|
||||||
|
else if (userAgent.Contains("nt 5.1"))
|
||||||
|
{ return "Windows XP"; }
|
||||||
|
else if (userAgent.Contains("nt 5"))
|
||||||
|
{ return "Windows 2000"; }
|
||||||
|
else if (userAgent.Contains("nt 4"))
|
||||||
|
{ return "Windows NT4"; }
|
||||||
|
else if (userAgent.Contains("me"))
|
||||||
|
{ return "Windows Me"; }
|
||||||
|
else if (userAgent.Contains("98"))
|
||||||
|
{ return "Windows 98"; }
|
||||||
|
else if (userAgent.Contains("95"))
|
||||||
|
{ return "Windows 95"; }
|
||||||
|
else if (userAgent.Contains("mac"))
|
||||||
|
{ return "Mac"; }
|
||||||
|
else if (userAgent.Contains("unix"))
|
||||||
|
{ return "UNIX"; }
|
||||||
|
else if (userAgent.Contains("linux"))
|
||||||
|
{ return "Linux"; }
|
||||||
|
else if (userAgent.Contains("sunos"))
|
||||||
|
{ return "SunOS"; }
|
||||||
|
|
||||||
|
return "未知";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证密码强度
|
||||||
|
/// 0:6位无要求
|
||||||
|
/// 1:至少八个字符,至少一个字母和一个数字
|
||||||
|
/// 2:至少八个字符,至少一个字母,一个数字和一个特殊字符
|
||||||
|
/// 3:最少八个字符,至少一个大写字母,一个小写字母和一个数字
|
||||||
|
/// 4:至少八个字符,至少一个大写字母,一个小写字母,一个数字和一个特殊字符
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="password">密码</param>
|
||||||
|
/// <param name="t">验证强度</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool CheckPasswordStrength(string password,int t)
|
||||||
|
{
|
||||||
|
if(t == 0)
|
||||||
|
{
|
||||||
|
if (password.Length < 6)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(t== 1) // 至少八个字符,至少一个字母和一个数字
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(password, @"^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,20}$");
|
||||||
|
}
|
||||||
|
else if(t== 2)//至少八个字符,至少一个字母,一个数字和一个特殊字符
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(password, @"^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,20}$");
|
||||||
|
}
|
||||||
|
else if (t ==3)//最少八个字符,至少一个大写字母,一个小写字母和一个数字
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(password, @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,20}$");
|
||||||
|
}
|
||||||
|
else //至少八个字符,至少一个大写字母,一个小写字母,一个数字和一个特殊字符
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(password, @"^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,20}$");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取密码强度提示
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="t"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetPasswordStrengthTip(int t)
|
||||||
|
{
|
||||||
|
if (t == 0)
|
||||||
|
{
|
||||||
|
return "至少六个字符";
|
||||||
|
}
|
||||||
|
else if (t == 1) // 至少八个字符,至少一个字母和一个数字
|
||||||
|
{
|
||||||
|
return "至少八个字符,至少一个字母和一个数字";
|
||||||
|
}
|
||||||
|
else if (t == 2)//至少八个字符,至少一个字母,一个数字和一个特殊字符
|
||||||
|
{
|
||||||
|
return "至少八个字符,至少一个字母,一个数字和一个特殊字符";
|
||||||
|
}
|
||||||
|
else if (t == 3)//最少八个字符,至少一个大写字母,一个小写字母和一个数字
|
||||||
|
{
|
||||||
|
return "最少八个字符,至少一个大写字母,一个小写字母和一个数字";
|
||||||
|
}
|
||||||
|
else //至少八个字符,至少一个大写字母,一个小写字母,一个数字和一个特殊字符
|
||||||
|
{
|
||||||
|
return "至少八个字符,至少一个大写字母,一个小写字母,一个数字和一个特殊字符";
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取部分
|
#region 获取部分
|
||||||
@@ -526,7 +765,18 @@ namespace COMCMS.Common
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
string extname = filename.Substring(filename.LastIndexOf(".") + 1).ToLower();
|
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>
|
/// <summary>
|
||||||
@@ -731,6 +981,14 @@ namespace COMCMS.Common
|
|||||||
string xForwardedForAddress = MyHttpContext.Current.Request.Headers["X-Forwarded-For"];
|
string xForwardedForAddress = MyHttpContext.Current.Request.Headers["X-Forwarded-For"];
|
||||||
if (!string.IsNullOrEmpty(userHostAddress) && !string.IsNullOrEmpty(xForwardedForAddress) && userHostAddress != xForwardedForAddress)
|
if (!string.IsNullOrEmpty(userHostAddress) && !string.IsNullOrEmpty(xForwardedForAddress) && userHostAddress != xForwardedForAddress)
|
||||||
{
|
{
|
||||||
|
if (xForwardedForAddress.IndexOf(",") > -1)
|
||||||
|
{
|
||||||
|
string[] arrIP = xForwardedForAddress.Split(new string[] { "," }, StringSplitOptions.None);
|
||||||
|
if (arrIP.Length > 1)
|
||||||
|
{
|
||||||
|
return arrIP[0].Trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
return xForwardedForAddress;
|
return xForwardedForAddress;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(userHostAddress) && Utils.IsIP(userHostAddress))
|
if (!string.IsNullOrEmpty(userHostAddress) && Utils.IsIP(userHostAddress))
|
||||||
@@ -820,6 +1078,53 @@ namespace COMCMS.Common
|
|||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前系统运行平台
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetOSPlatform()
|
||||||
|
{
|
||||||
|
string osPlatform = "Unknown";
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
osPlatform = "Windows";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
osPlatform = "Linux";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
osPlatform = "OSX";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
|
||||||
|
{
|
||||||
|
osPlatform = "FreeBSD";
|
||||||
|
}
|
||||||
|
|
||||||
|
return osPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IP转换成为long的地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ip"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static long GetLongIP(string ip)
|
||||||
|
{
|
||||||
|
if (!IsIP(ip))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
string[] s = ip.Split('.');
|
||||||
|
long l0 = long.Parse(s[0]) << 24;
|
||||||
|
long l1 = long.Parse(s[1]) << 16;
|
||||||
|
long l2 = long.Parse(s[2]) << 8;
|
||||||
|
long l3 = long.Parse(s[3]);
|
||||||
|
|
||||||
|
return l0 + l1 + l2 + l3;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 处理部分
|
#region 处理部分
|
||||||
@@ -933,125 +1238,48 @@ namespace COMCMS.Common
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string HttpGet(string url)
|
public static string HttpGet(string url)
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
|
//使用webclient http get
|
||||||
request.Method = "GET";
|
|
||||||
//request.ContentType = "application/x-www-form-urlencoded";
|
|
||||||
request.Accept = "*/*";
|
|
||||||
request.Proxy = null;
|
|
||||||
request.Timeout = 15000;
|
|
||||||
request.AllowAutoRedirect = false;
|
|
||||||
|
|
||||||
WebResponse response = null;
|
|
||||||
string responseStr = null;
|
string responseStr = null;
|
||||||
|
using (HttpClient client = new HttpClient())
|
||||||
try
|
|
||||||
{
|
{
|
||||||
response = request.GetResponse();
|
var re = client.GetAsync(url).Result;
|
||||||
|
if (re.IsSuccessStatusCode)
|
||||||
if (response != null)
|
|
||||||
{
|
{
|
||||||
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
|
responseStr = re.Content.ReadAsStringAsync().Result;
|
||||||
responseStr = reader.ReadToEnd();
|
|
||||||
reader.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
NewLife.Log.XTrace.WriteException(ex);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
request = null;
|
|
||||||
response = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return responseStr;
|
return responseStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 后台发送POST请求
|
/// 将对象转换为Int32类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="url">服务器地址</param>
|
/// <param name="str">要转换的字符串</param>
|
||||||
/// <param name="data">发送的数据</param>
|
/// <param name="defValue">缺省值</param>
|
||||||
/// <returns></returns>
|
/// <returns>转换后的int类型结果</returns>
|
||||||
public static Stream HttpPost(string url, string data)
|
public static int StrToInt(string str, int defValue)
|
||||||
{
|
{
|
||||||
try
|
if (string.IsNullOrEmpty(str) || str.Trim().Length >= 11 || !Regex.IsMatch(str.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$"))
|
||||||
{
|
return defValue;
|
||||||
//创建post请求
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
||||||
request.Method = "POST";
|
|
||||||
request.ContentType = "application/json;charset=UTF-8";
|
|
||||||
byte[] payload = Encoding.UTF8.GetBytes(data);
|
|
||||||
request.ContentLength = payload.Length;
|
|
||||||
|
|
||||||
|
int rv;
|
||||||
|
if (Int32.TryParse(str, out rv))
|
||||||
|
return rv;
|
||||||
|
|
||||||
//发送post的请求
|
return Convert.ToInt32(StrToFloat(str, defValue));
|
||||||
Stream writer = request.GetRequestStream();
|
|
||||||
writer.Write(payload, 0, payload.Length);
|
|
||||||
writer.Close();
|
|
||||||
|
|
||||||
//接受返回来的数据
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
return stream;
|
|
||||||
//StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
|
||||||
//string value = reader.ReadToEnd();
|
|
||||||
|
|
||||||
//reader.Close();
|
|
||||||
//stream.Close();
|
|
||||||
//response.Close();
|
|
||||||
|
|
||||||
//return value;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
/// <summary>
|
||||||
|
/// string型转换为float型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strValue">要转换的字符串</param>
|
||||||
|
/// <param name="defValue">缺省值</param>
|
||||||
|
/// <returns>转换后的int类型结果</returns>
|
||||||
|
public static float StrToFloat(object strValue, float defValue)
|
||||||
{
|
{
|
||||||
NewLife.Log.XTrace.WriteException(ex);
|
if ((strValue == null))
|
||||||
return null;
|
return defValue;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
return StrToFloat(strValue.ToString(), defValue);
|
||||||
/// 后台发送POST请求
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="url">服务器地址</param>
|
|
||||||
/// <param name="data">发送的数据</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string HttpPostAndReturnString(string url, string data)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//创建post请求
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
||||||
request.Method = "POST";
|
|
||||||
request.ContentType = "application/json;charset=UTF-8";
|
|
||||||
byte[] payload = Encoding.UTF8.GetBytes(data);
|
|
||||||
request.ContentLength = payload.Length;
|
|
||||||
|
|
||||||
|
|
||||||
//发送post的请求
|
|
||||||
Stream writer = request.GetRequestStream();
|
|
||||||
writer.Write(payload, 0, payload.Length);
|
|
||||||
writer.Close();
|
|
||||||
|
|
||||||
//接受返回来的数据
|
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
||||||
Stream stream = response.GetResponseStream();
|
|
||||||
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
|
|
||||||
string value = reader.ReadToEnd();
|
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
stream.Close();
|
|
||||||
response.Close();
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
NewLife.Log.XTrace.WriteException(ex);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,369 @@
|
|||||||
|
using NewLife.Caching;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using NewLife.Log;
|
||||||
|
using SkiaSharp;
|
||||||
|
using NewLife.Security;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
|
namespace COMCMS.Common
|
||||||
|
{
|
||||||
|
public sealed class VerifyCodeHelper
|
||||||
|
{
|
||||||
|
#region 单例模式
|
||||||
|
//Session Key
|
||||||
|
public readonly string SESSION_KEY = "comcms_verifycode";
|
||||||
|
//创建私有化静态obj锁
|
||||||
|
private static readonly object _ObjLock = new object();
|
||||||
|
//创建私有静态字段,接收类的实例化对象
|
||||||
|
private static VerifyCodeHelper _VerifyCodeHelper = null;
|
||||||
|
//构造函数私有化
|
||||||
|
private VerifyCodeHelper() { }
|
||||||
|
//创建单利对象资源并返回
|
||||||
|
public static VerifyCodeHelper GetSingleObj()
|
||||||
|
{
|
||||||
|
if (_VerifyCodeHelper == null)
|
||||||
|
{
|
||||||
|
lock (_ObjLock)
|
||||||
|
{
|
||||||
|
if (_VerifyCodeHelper == null)
|
||||||
|
_VerifyCodeHelper = new VerifyCodeHelper();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _VerifyCodeHelper;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 生产验证码
|
||||||
|
public enum VerifyCodeType { NumberVerifyCode, AbcVerifyCode, MixVerifyCode };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1.数字验证码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="length"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private string CreateNumberVerifyCode(int length)
|
||||||
|
{
|
||||||
|
int[] randMembers = new int[length];
|
||||||
|
int[] validateNums = new int[length];
|
||||||
|
string validateNumberStr = "";
|
||||||
|
//生成起始序列值
|
||||||
|
int seekSeek = unchecked((int)DateTime.Now.Ticks);
|
||||||
|
Random seekRand = new Random(seekSeek);
|
||||||
|
int beginSeek = seekRand.Next(0, Int32.MaxValue - length * 10000);
|
||||||
|
int[] seeks = new int[length];
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
beginSeek += 10000;
|
||||||
|
seeks[i] = beginSeek;
|
||||||
|
}
|
||||||
|
//生成随机数字
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
Random rand = new Random(seeks[i]);
|
||||||
|
int pownum = 1 * (int)Math.Pow(10, length);
|
||||||
|
randMembers[i] = rand.Next(pownum, Int32.MaxValue);
|
||||||
|
}
|
||||||
|
//抽取随机数字
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
string numStr = randMembers[i].ToString();
|
||||||
|
int numLength = numStr.Length;
|
||||||
|
Random rand = new Random();
|
||||||
|
int numPosition = rand.Next(0, numLength - 1);
|
||||||
|
validateNums[i] = Int32.Parse(numStr.Substring(numPosition, 1));
|
||||||
|
}
|
||||||
|
//生成验证码
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
validateNumberStr += validateNums[i].ToString();
|
||||||
|
}
|
||||||
|
return validateNumberStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 2.字母验证码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="length">字符长度</param>
|
||||||
|
/// <returns>验证码字符</returns>
|
||||||
|
private string CreateAbcVerifyCode(int length)
|
||||||
|
{
|
||||||
|
char[] verification = new char[length];
|
||||||
|
char[] dictionary = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
|
||||||
|
};
|
||||||
|
Random random = new Random();
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
verification[i] = dictionary[random.Next(dictionary.Length - 1)];
|
||||||
|
}
|
||||||
|
return new string(verification);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 3.混合验证码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="length">字符长度</param>
|
||||||
|
/// <returns>验证码字符</returns>
|
||||||
|
private string CreateMixVerifyCode(int length)
|
||||||
|
{
|
||||||
|
char[] verification = new char[length];
|
||||||
|
char[] dictionary = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||||
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
|
||||||
|
};
|
||||||
|
Random random = new Random();
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
verification[i] = dictionary[random.Next(dictionary.Length - 1)];
|
||||||
|
}
|
||||||
|
return new string(verification);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产生验证码(随机产生4-6位)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type">验证码类型:数字,字符,符合</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string CreateVerifyCode(VerifyCodeType type)
|
||||||
|
{
|
||||||
|
string verifyCode = string.Empty;
|
||||||
|
Random random = new Random();
|
||||||
|
int length = random.Next(4, 6);
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case VerifyCodeType.NumberVerifyCode:
|
||||||
|
verifyCode = GetSingleObj().CreateNumberVerifyCode(length);
|
||||||
|
break;
|
||||||
|
case VerifyCodeType.AbcVerifyCode:
|
||||||
|
verifyCode = GetSingleObj().CreateAbcVerifyCode(length);
|
||||||
|
break;
|
||||||
|
case VerifyCodeType.MixVerifyCode:
|
||||||
|
verifyCode = GetSingleObj().CreateMixVerifyCode(length);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//2019-03-02 增加存入缓存
|
||||||
|
//var ic = new MemoryCache();
|
||||||
|
//ic.Set<string>("code_" + verifyCode, verifyCode, 120);//2分钟自动过期
|
||||||
|
//2019-03-04 增加Redis缓存
|
||||||
|
Utils.MemoryCahce.Set<string>("code_" + verifyCode, verifyCode, 120);
|
||||||
|
|
||||||
|
return verifyCode;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 验证码图片
|
||||||
|
///// <summary>
|
||||||
|
///// 验证码图片 => Bitmap
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="verifyCode">验证码</param>
|
||||||
|
///// <param name="width">宽</param>
|
||||||
|
///// <param name="height">高</param>
|
||||||
|
///// <returns>Bitmap</returns>
|
||||||
|
//public Bitmap CreateBitmapByImgVerifyCode(string verifyCode, int width, int height)
|
||||||
|
//{
|
||||||
|
// Font font = new Font("Arial", 14, (FontStyle.Bold | FontStyle.Italic));
|
||||||
|
// Brush brush;
|
||||||
|
// Bitmap bitmap = new Bitmap(width, height);
|
||||||
|
// Graphics g = Graphics.FromImage(bitmap);
|
||||||
|
// SizeF totalSizeF = g.MeasureString(verifyCode, font);
|
||||||
|
// SizeF curCharSizeF;
|
||||||
|
// PointF startPointF = new PointF(0, (height - totalSizeF.Height) / 2);
|
||||||
|
// Random random = new Random(); //随机数产生器
|
||||||
|
// g.Clear(Color.White); //清空图片背景色
|
||||||
|
// for (int i = 0; i < verifyCode.Length; i++)
|
||||||
|
// {
|
||||||
|
// brush = new LinearGradientBrush(new Point(0, 0), new Point(1, 1), Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));
|
||||||
|
// g.DrawString(verifyCode[i].ToString(), font, brush, startPointF);
|
||||||
|
// curCharSizeF = g.MeasureString(verifyCode[i].ToString(), font);
|
||||||
|
// startPointF.X += curCharSizeF.Width;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //画图片的干扰线
|
||||||
|
// for (int i = 0; i < 10; i++)
|
||||||
|
// {
|
||||||
|
// int x1 = random.Next(bitmap.Width);
|
||||||
|
// int x2 = random.Next(bitmap.Width);
|
||||||
|
// int y1 = random.Next(bitmap.Height);
|
||||||
|
// int y2 = random.Next(bitmap.Height);
|
||||||
|
// g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //画图片的前景干扰点
|
||||||
|
// for (int i = 0; i < 100; i++)
|
||||||
|
// {
|
||||||
|
// int x = random.Next(bitmap.Width);
|
||||||
|
// int y = random.Next(bitmap.Height);
|
||||||
|
// bitmap.SetPixel(x, y, Color.FromArgb(random.Next()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// g.DrawRectangle(new Pen(Color.Silver), 0, 0, bitmap.Width - 1, bitmap.Height - 1); //画图片的边框线
|
||||||
|
// g.Dispose();
|
||||||
|
// return bitmap;
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 验证码图片 => byte[]
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="verifyCode">验证码</param>
|
||||||
|
///// <param name="width">宽</param>
|
||||||
|
///// <param name="height">高</param>
|
||||||
|
///// <returns>byte[]</returns>
|
||||||
|
//public byte[] CreateByteByImgVerifyCode(string verifyCode, int width, int height)
|
||||||
|
//{
|
||||||
|
// Font font = new Font("Arial", 14, (FontStyle.Bold | FontStyle.Italic));
|
||||||
|
// Brush brush;
|
||||||
|
// Bitmap bitmap = new Bitmap(width, height);
|
||||||
|
// Graphics g = Graphics.FromImage(bitmap);
|
||||||
|
// SizeF totalSizeF = g.MeasureString(verifyCode, font);
|
||||||
|
// SizeF curCharSizeF;
|
||||||
|
// PointF startPointF = new PointF(0, (height - totalSizeF.Height) / 2);
|
||||||
|
// Random random = new Random(); //随机数产生器
|
||||||
|
// g.Clear(Color.White); //清空图片背景色
|
||||||
|
// for (int i = 0; i < verifyCode.Length; i++)
|
||||||
|
// {
|
||||||
|
// brush = new LinearGradientBrush(new Point(0, 0), new Point(1, 1), Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)), Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));
|
||||||
|
// g.DrawString(verifyCode[i].ToString(), font, brush, startPointF);
|
||||||
|
// curCharSizeF = g.MeasureString(verifyCode[i].ToString(), font);
|
||||||
|
// startPointF.X += curCharSizeF.Width;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //画图片的干扰线
|
||||||
|
// for (int i = 0; i < 10; i++)
|
||||||
|
// {
|
||||||
|
// int x1 = random.Next(bitmap.Width);
|
||||||
|
// int x2 = random.Next(bitmap.Width);
|
||||||
|
// int y1 = random.Next(bitmap.Height);
|
||||||
|
// int y2 = random.Next(bitmap.Height);
|
||||||
|
// g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //画图片的前景干扰点
|
||||||
|
// for (int i = 0; i < 100; i++)
|
||||||
|
// {
|
||||||
|
// int x = random.Next(bitmap.Width);
|
||||||
|
// int y = random.Next(bitmap.Height);
|
||||||
|
// bitmap.SetPixel(x, y, Color.FromArgb(random.Next()));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// g.DrawRectangle(new Pen(Color.Silver), 0, 0, bitmap.Width - 1, bitmap.Height - 1); //画图片的边框线
|
||||||
|
// g.Dispose();
|
||||||
|
|
||||||
|
// //保存图片数据
|
||||||
|
// MemoryStream stream = new MemoryStream();
|
||||||
|
// bitmap.Save(stream, ImageFormat.Jpeg);
|
||||||
|
// //输出图片流
|
||||||
|
// return stream.ToArray();
|
||||||
|
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 图片验证码
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
/// <param name="width"></param>
|
||||||
|
/// <param name="height"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public byte[] GetVerifyCode(string text, int width, int height)
|
||||||
|
{
|
||||||
|
|
||||||
|
Random random = new();
|
||||||
|
|
||||||
|
//创建bitmap位图
|
||||||
|
using SKBitmap image = new(width, height, SKColorType.Bgra8888, SKAlphaType.Premul);
|
||||||
|
//创建画笔
|
||||||
|
using SKCanvas canvas = new(image);
|
||||||
|
//填充背景颜色为白色
|
||||||
|
canvas.DrawColor(SKColors.White);
|
||||||
|
|
||||||
|
//画图片的背景噪音线
|
||||||
|
for (int i = 0; i < (width * height * 0.015); i++)
|
||||||
|
{
|
||||||
|
using SKPaint drawStyle = new();
|
||||||
|
drawStyle.Color = new(Convert.ToUInt32(random.Next(Int32.MaxValue)));
|
||||||
|
|
||||||
|
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,
|
||||||
|
Shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(width, height), new SKColor[] { SKColors.Blue, SKColors.DarkRed }, SKShaderTileMode.Clamp),
|
||||||
|
};
|
||||||
|
canvas.DrawText(text, 4, 24, SKTextAlign.Left, textFont, textPaint);
|
||||||
|
|
||||||
|
//将文字写到画布上
|
||||||
|
//using (SKPaint drawStyle = new())
|
||||||
|
//{
|
||||||
|
// drawStyle.Color = SKColors.Red;
|
||||||
|
// drawStyle.TextSize = height;
|
||||||
|
// drawStyle.StrokeWidth = 1;
|
||||||
|
|
||||||
|
// float emHeight = height - (float)height * (float)0.14;
|
||||||
|
// float emWidth = ((float)width / text.Length) - ((float)width * (float)0.13);
|
||||||
|
|
||||||
|
// canvas.DrawText(text, emWidth, emHeight, drawStyle);
|
||||||
|
//}
|
||||||
|
for (int i = 0; i < 5; i++)
|
||||||
|
{
|
||||||
|
canvas.DrawLine(new SKPoint(random.Next(width), random.Next(height)), new SKPoint(random.Next(width), random.Next(height)), new SKPaint() { Color = SKColor.FromHsv(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在图片上随机画100个随机颜色点
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
canvas.DrawPoint(new SKPoint(random.Next(width), random.Next(height)), SKColor.FromHsv(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//画图片的前景噪音点
|
||||||
|
//for (int i = 0; i < (width * height * 0.6); i++)
|
||||||
|
//{
|
||||||
|
// image.SetPixel(random.Next(0, width), random.Next(0, height), new SKColor(Convert.ToUInt32(random.Next(Int32.MaxValue))));
|
||||||
|
//}
|
||||||
|
|
||||||
|
using var img = SKImage.FromBitmap(image);
|
||||||
|
using SKData p = img.Encode(SKEncodedImageFormat.Png, 100);
|
||||||
|
return p.ToArray();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 验证验证码
|
||||||
|
/// <summary>
|
||||||
|
/// 验证验证码是否成功
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool VerifyCodeIsOK(string code)
|
||||||
|
{
|
||||||
|
string vc = SessionHelper.GetSession(SESSION_KEY)?.ToString();
|
||||||
|
//2019-03-02 增加缓存判断
|
||||||
|
if (string.IsNullOrEmpty(vc))
|
||||||
|
{
|
||||||
|
//如果Session为空,则使用缓存判断
|
||||||
|
//var ic = new MemoryCache();
|
||||||
|
//vc = ic.Get<string>("code_" + code);
|
||||||
|
//var ic = Utils.RedisCahce;//Redis.Create(Utils.RedisServer, Utils.RedisIndex);
|
||||||
|
vc = Utils.MemoryCahce.Get<string>("code_" + code);// ic.Get<string>("code_" + code);
|
||||||
|
//XTrace.WriteLine($"从缓存中获取验证码:code_{code}:{vc}");
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(vc) && !string.IsNullOrEmpty(code))
|
||||||
|
{
|
||||||
|
if (vc.ToUpper() == code.ToUpper())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
using System;
|
using SkiaSharp;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.DrawingCore;
|
using System.Drawing;
|
||||||
using System.DrawingCore.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
namespace COMCMS.Common
|
namespace COMCMS.Common
|
||||||
{
|
{
|
||||||
@@ -11,51 +14,30 @@ namespace COMCMS.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WatermarkHelper
|
public class WatermarkHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
#region 加图片水印
|
#region 加图片水印
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加图片水印
|
/// 加图片水印
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <p
|
||||||
/// <param name="filename">文件名</param>
|
/// <param name="filename">文件名</param>
|
||||||
/// <param name="watermarkFilename">水印文件名</param>
|
/// <param name="watermarkFilename">水印文件名</param>
|
||||||
/// <param name="watermarkStatus">图片水印位置</param>
|
/// <param name="watermarkStatus">图片水印位置</param>
|
||||||
public static void AddImageSignPic(Image img, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
|
public static void AddImageSignPic(string copyfullpath, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
|
||||||
{
|
{
|
||||||
Graphics g = Graphics.FromImage(img);
|
var img = SKBitmap.Decode(copyfullpath);
|
||||||
|
using SKCanvas canvas = new(img);
|
||||||
|
|
||||||
//设置高质量插值法
|
//设置高质量插值法
|
||||||
//g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
|
//g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
|
||||||
//设置高质量,低速度呈现平滑程度
|
//设置高质量,低速度呈现平滑程度
|
||||||
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||||
System.DrawingCore.Image watermark = new Bitmap(watermarkFilename);
|
var watermarkBitmap = SKBitmap.Decode(watermarkFilename);
|
||||||
|
SKImage watermark = SKImage.FromBitmap(watermarkBitmap);
|
||||||
|
|
||||||
if (watermark.Height >= img.Height || watermark.Width >= img.Width)
|
if (watermark.Height >= img.Height || watermark.Width >= img.Width)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImageAttributes imageAttributes = new ImageAttributes();
|
|
||||||
ColorMap colorMap = new ColorMap();
|
|
||||||
|
|
||||||
colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
|
|
||||||
colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
|
|
||||||
ColorMap[] remapTable = { colorMap };
|
|
||||||
|
|
||||||
imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
|
|
||||||
|
|
||||||
float transparency = 0.5F;
|
|
||||||
if (watermarkTransparency >= 1 && watermarkTransparency <= 10)
|
|
||||||
transparency = (watermarkTransparency / 10.0F);
|
|
||||||
|
|
||||||
|
|
||||||
float[][] colorMatrixElements = {
|
|
||||||
new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
|
|
||||||
new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
|
|
||||||
new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
|
|
||||||
new float[] {0.0f, 0.0f, 0.0f, transparency, 0.0f},
|
|
||||||
new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
|
|
||||||
};
|
|
||||||
|
|
||||||
ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
|
|
||||||
|
|
||||||
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
|
||||||
|
|
||||||
int xpos = 0;
|
int xpos = 0;
|
||||||
int ypos = 0;
|
int ypos = 0;
|
||||||
|
|
||||||
@@ -98,124 +80,74 @@ namespace COMCMS.Common
|
|||||||
ypos = (int)((img.Height * (float).99) - watermark.Height);
|
ypos = (int)((img.Height * (float).99) - watermark.Height);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
SKPoint point = new SKPoint()
|
||||||
g.DrawImage(watermark, new Rectangle(xpos, ypos, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, GraphicsUnit.Pixel, imageAttributes);
|
|
||||||
|
|
||||||
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
|
|
||||||
ImageCodecInfo ici = null;
|
|
||||||
foreach (ImageCodecInfo codec in codecs)
|
|
||||||
{
|
{
|
||||||
if (codec.MimeType.IndexOf("jpeg") > -1)
|
X = xpos,
|
||||||
ici = codec;
|
Y = ypos
|
||||||
|
};
|
||||||
|
|
||||||
|
canvas.DrawImage(watermark, point);
|
||||||
|
|
||||||
|
//var newImg = SKImage.fo originalImage.Resize(new SKSizeI(towidth, toheight), SKFilterQuality.Medium);
|
||||||
|
//canvas.
|
||||||
|
using var fs = new FileStream(filename, FileMode.Create);
|
||||||
|
SKEncodedImageFormat imgType = new SKEncodedImageFormat();
|
||||||
|
string sFullExtension = Utils.GetFileExtName(filename).ToLower();//扩展名
|
||||||
|
switch (sFullExtension)
|
||||||
|
{
|
||||||
|
case ".jpg":
|
||||||
|
case ".jpeg":
|
||||||
|
imgType = SKEncodedImageFormat.Jpeg;
|
||||||
|
break;
|
||||||
|
case ".png":
|
||||||
|
imgType = SKEncodedImageFormat.Png;
|
||||||
|
break;
|
||||||
|
case ".gif":
|
||||||
|
imgType = SKEncodedImageFormat.Gif;
|
||||||
|
break;
|
||||||
|
case ".webp":
|
||||||
|
imgType = SKEncodedImageFormat.Webp;
|
||||||
|
break;
|
||||||
|
case ".bmp":
|
||||||
|
imgType = SKEncodedImageFormat.Bmp;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
imgType = SKEncodedImageFormat.Png;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
EncoderParameters encoderParams = new EncoderParameters();
|
img.Encode(fs, imgType, 100);
|
||||||
long[] qualityParam = new long[1];
|
fs.Flush();
|
||||||
if (quality < 0 || quality > 100)
|
|
||||||
quality = 80;
|
|
||||||
|
|
||||||
qualityParam[0] = quality;
|
|
||||||
|
|
||||||
EncoderParameter encoderParam = new EncoderParameter(System.DrawingCore.Imaging.Encoder.Quality, qualityParam);
|
////g.DrawImage(watermark, new Rectangle(xpos, ypos, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, GraphicsUnit.Pixel, imageAttributes);
|
||||||
encoderParams.Param[0] = encoderParam;
|
|
||||||
|
|
||||||
if (ici != null)
|
//ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
|
||||||
img.Save(filename, ici, encoderParams);
|
//ImageCodecInfo ici = null;
|
||||||
else
|
//foreach (ImageCodecInfo codec in codecs)
|
||||||
img.Save(filename);
|
//{
|
||||||
|
// if (codec.MimeType.IndexOf("jpeg") > -1)
|
||||||
|
// ici = codec;
|
||||||
|
//}
|
||||||
|
//EncoderParameters encoderParams = new EncoderParameters();
|
||||||
|
//long[] qualityParam = new long[1];
|
||||||
|
//if (quality < 0 || quality > 100)
|
||||||
|
// quality = 80;
|
||||||
|
|
||||||
|
//qualityParam[0] = quality;
|
||||||
|
|
||||||
|
//EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam);
|
||||||
|
//encoderParams.Param[0] = encoderParam;
|
||||||
|
|
||||||
|
//if (ici != null)
|
||||||
|
// img.Save(filename, ici, encoderParams);
|
||||||
|
//else
|
||||||
|
// img.Save(filename);
|
||||||
|
|
||||||
g.Dispose();
|
|
||||||
img.Dispose();
|
img.Dispose();
|
||||||
watermark.Dispose();
|
watermark.Dispose();
|
||||||
imageAttributes.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 增加文字水印
|
|
||||||
/// <summary>
|
|
||||||
/// 增加图片文字水印
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="filename">文件名</param>
|
|
||||||
/// <param name="watermarkText">水印文字</param>
|
|
||||||
/// <param name="watermarkStatus">图片水印位置</param>
|
|
||||||
public static void AddImageSignText(System.DrawingCore.Image img, string filename, string watermarkText, int watermarkStatus, int quality, string fontname, int fontsize)
|
|
||||||
{
|
|
||||||
Graphics g = Graphics.FromImage(img);
|
|
||||||
Font drawFont = new Font(fontname, fontsize, FontStyle.Regular, GraphicsUnit.Pixel);
|
|
||||||
SizeF crSize;
|
|
||||||
crSize = g.MeasureString(watermarkText, drawFont);
|
|
||||||
|
|
||||||
float xpos = 0;
|
|
||||||
float ypos = 0;
|
|
||||||
|
|
||||||
switch (watermarkStatus)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
xpos = (float)img.Width * (float).01;
|
|
||||||
ypos = (float)img.Height * (float).01;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
xpos = ((float)img.Width * (float).50) - (crSize.Width / 2);
|
|
||||||
ypos = (float)img.Height * (float).01;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
xpos = ((float)img.Width * (float).99) - crSize.Width;
|
|
||||||
ypos = (float)img.Height * (float).01;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
xpos = (float)img.Width * (float).01;
|
|
||||||
ypos = ((float)img.Height * (float).50) - (crSize.Height / 2);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
xpos = ((float)img.Width * (float).50) - (crSize.Width / 2);
|
|
||||||
ypos = ((float)img.Height * (float).50) - (crSize.Height / 2);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
xpos = ((float)img.Width * (float).99) - crSize.Width;
|
|
||||||
ypos = ((float)img.Height * (float).50) - (crSize.Height / 2);
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
xpos = (float)img.Width * (float).01;
|
|
||||||
ypos = ((float)img.Height * (float).99) - crSize.Height;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
xpos = ((float)img.Width * (float).50) - (crSize.Width / 2);
|
|
||||||
ypos = ((float)img.Height * (float).99) - crSize.Height;
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
xpos = ((float)img.Width * (float).99) - crSize.Width;
|
|
||||||
ypos = ((float)img.Height * (float).99) - crSize.Height;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
g.DrawString(watermarkText, drawFont, new SolidBrush(Color.White), xpos + 1, ypos + 1);
|
|
||||||
g.DrawString(watermarkText, drawFont, new SolidBrush(Color.Black), xpos, ypos);
|
|
||||||
|
|
||||||
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
|
|
||||||
ImageCodecInfo ici = null;
|
|
||||||
foreach (ImageCodecInfo codec in codecs)
|
|
||||||
{
|
|
||||||
if (codec.MimeType.IndexOf("jpeg") > -1)
|
|
||||||
ici = codec;
|
|
||||||
}
|
|
||||||
EncoderParameters encoderParams = new EncoderParameters();
|
|
||||||
long[] qualityParam = new long[1];
|
|
||||||
if (quality < 0 || quality > 100)
|
|
||||||
quality = 80;
|
|
||||||
|
|
||||||
qualityParam[0] = quality;
|
|
||||||
|
|
||||||
EncoderParameter encoderParam = new EncoderParameter(System.DrawingCore.Imaging.Encoder.Quality, qualityParam);
|
|
||||||
encoderParams.Param[0] = encoderParam;
|
|
||||||
|
|
||||||
if (ici != null)
|
|
||||||
img.Save(filename, ici, encoderParams);
|
|
||||||
else
|
|
||||||
img.Save(filename);
|
|
||||||
|
|
||||||
g.Dispose();
|
|
||||||
img.Dispose();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,9 +150,25 @@ namespace COMCMS.Core
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 高级查询
|
#region 高级查询
|
||||||
|
/// <summary>
|
||||||
|
/// 通过FileName查找
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <param name="kid"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Article FindByFileName(string filename,int kid=0)
|
||||||
|
{
|
||||||
|
var where = _.FileName == filename;
|
||||||
|
if (kid > 0) where &= _.KId == kid;
|
||||||
|
return Find(where);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 业务操作
|
#region 业务操作
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取上一条记录/前一条记录
|
/// 获取上一条记录/前一条记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -212,6 +228,36 @@ namespace COMCMS.Core
|
|||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取前几条文章
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="kid">栏目id</param>
|
||||||
|
/// <param name="records">条数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IList<Article> 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<ArticleCategory> subkinds = ArticleCategory.FindByParentID(kid);
|
||||||
|
if (subkinds != null && subkinds.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var item in subkinds)
|
||||||
|
{
|
||||||
|
kids.Add(item.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ex &= Article._.KId.In(kids);
|
||||||
|
|
||||||
|
return FindAll(ex, _.Id.Desc(), null, 0, records);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+111
-91
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
@@ -20,288 +21,296 @@ namespace COMCMS.Core
|
|||||||
[DisplayName("编号")]
|
[DisplayName("编号")]
|
||||||
[Description("编号")]
|
[Description("编号")]
|
||||||
[DataObjectField(true, true, false, 0)]
|
[DataObjectField(true, true, false, 0)]
|
||||||
[BindColumn("Id", "编号", "int")]
|
[BindColumn("Id", "编号", "")]
|
||||||
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
private Int32 _KId;
|
private Int32 _KId;
|
||||||
/// <summary>栏目ID</summary>
|
/// <summary>栏目ID</summary>
|
||||||
[DisplayName("栏目ID")]
|
[DisplayName("栏目ID")]
|
||||||
[Description("栏目ID")]
|
[Description("栏目ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("KId", "栏目ID", "int")]
|
[BindColumn("KId", "栏目ID", "")]
|
||||||
public Int32 KId { get { return _KId; } set { if (OnPropertyChanging(__.KId, value)) { _KId = value; OnPropertyChanged(__.KId); } } }
|
public Int32 KId { get => _KId; set { if (OnPropertyChanging(__.KId, value)) { _KId = value; OnPropertyChanged(__.KId); } } }
|
||||||
|
|
||||||
private String _Title;
|
private String _Title;
|
||||||
/// <summary>标题</summary>
|
/// <summary>标题</summary>
|
||||||
[DisplayName("标题")]
|
[DisplayName("标题")]
|
||||||
[Description("标题")]
|
[Description("标题")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Title", "标题", "nvarchar(250)", Master = true)]
|
[BindColumn("Title", "标题", "", Master = true)]
|
||||||
public String Title { get { return _Title; } set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } }
|
public String Title { get => _Title; set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } }
|
||||||
|
|
||||||
private String _SubTitle;
|
private String _SubTitle;
|
||||||
/// <summary>副标题</summary>
|
/// <summary>副标题</summary>
|
||||||
[DisplayName("副标题")]
|
[DisplayName("副标题")]
|
||||||
[Description("副标题")]
|
[Description("副标题")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("SubTitle", "副标题", "nvarchar(250)")]
|
[BindColumn("SubTitle", "副标题", "")]
|
||||||
public String SubTitle { get { return _SubTitle; } set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } }
|
public String SubTitle { get => _SubTitle; set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } }
|
||||||
|
|
||||||
private String _Content;
|
private String _Content;
|
||||||
/// <summary>内容</summary>
|
/// <summary>内容</summary>
|
||||||
[DisplayName("内容")]
|
[DisplayName("内容")]
|
||||||
[Description("内容")]
|
[Description("内容")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("Content", "内容", "ntext")]
|
[BindColumn("Content", "内容", "")]
|
||||||
public String Content { get { return _Content; } set { if (OnPropertyChanging(__.Content, value)) { _Content = value; OnPropertyChanged(__.Content); } } }
|
public String Content { get => _Content; set { if (OnPropertyChanging(__.Content, value)) { _Content = value; OnPropertyChanged(__.Content); } } }
|
||||||
|
|
||||||
private String _Keyword;
|
private String _Keyword;
|
||||||
/// <summary>描述</summary>
|
/// <summary>描述</summary>
|
||||||
[DisplayName("描述")]
|
[DisplayName("描述")]
|
||||||
[Description("描述")]
|
[Description("描述")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Keyword", "描述", "nvarchar(250)")]
|
[BindColumn("Keyword", "描述", "")]
|
||||||
public String Keyword { get { return _Keyword; } set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } }
|
public String Keyword { get => _Keyword; set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } }
|
||||||
|
|
||||||
private String _Description;
|
private String _Description;
|
||||||
/// <summary>介绍</summary>
|
/// <summary>介绍</summary>
|
||||||
[DisplayName("介绍")]
|
[DisplayName("介绍")]
|
||||||
[Description("介绍")]
|
[Description("介绍")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Description", "介绍", "nvarchar(250)")]
|
[BindColumn("Description", "介绍", "")]
|
||||||
public String Description { get { return _Description; } set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
public String Description { get => _Description; set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
||||||
|
|
||||||
private String _LinkURL;
|
private String _LinkURL;
|
||||||
/// <summary>跳转链接</summary>
|
/// <summary>跳转链接</summary>
|
||||||
[DisplayName("跳转链接")]
|
[DisplayName("跳转链接")]
|
||||||
[Description("跳转链接")]
|
[Description("跳转链接")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("LinkURL", "跳转链接", "nvarchar(250)")]
|
[BindColumn("LinkURL", "跳转链接", "")]
|
||||||
public String LinkURL { get { return _LinkURL; } set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } }
|
public String LinkURL { get => _LinkURL; set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } }
|
||||||
|
|
||||||
private String _TitleColor;
|
private String _TitleColor;
|
||||||
/// <summary>类别名称颜色</summary>
|
/// <summary>类别名称颜色</summary>
|
||||||
[DisplayName("类别名称颜色")]
|
[DisplayName("类别名称颜色")]
|
||||||
[Description("类别名称颜色")]
|
[Description("类别名称颜色")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("TitleColor", "类别名称颜色", "nvarchar(50)")]
|
[BindColumn("TitleColor", "类别名称颜色", "")]
|
||||||
public String TitleColor { get { return _TitleColor; } set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } }
|
public String TitleColor { get => _TitleColor; set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } }
|
||||||
|
|
||||||
private String _TemplateFile;
|
private String _TemplateFile;
|
||||||
/// <summary>模板</summary>
|
/// <summary>模板</summary>
|
||||||
[DisplayName("模板")]
|
[DisplayName("模板")]
|
||||||
[Description("模板")]
|
[Description("模板")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("TemplateFile", "模板", "nvarchar(250)")]
|
[BindColumn("TemplateFile", "模板", "")]
|
||||||
public String TemplateFile { get { return _TemplateFile; } set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } }
|
public String TemplateFile { get => _TemplateFile; set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } }
|
||||||
|
|
||||||
private Int32 _IsRecommend;
|
private Int32 _IsRecommend;
|
||||||
/// <summary>是否推荐</summary>
|
/// <summary>是否推荐</summary>
|
||||||
[DisplayName("是否推荐")]
|
[DisplayName("是否推荐")]
|
||||||
[Description("是否推荐")]
|
[Description("是否推荐")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsRecommend", "是否推荐", "int")]
|
[BindColumn("IsRecommend", "是否推荐", "")]
|
||||||
public Int32 IsRecommend { get { return _IsRecommend; } set { if (OnPropertyChanging(__.IsRecommend, value)) { _IsRecommend = value; OnPropertyChanged(__.IsRecommend); } } }
|
public Int32 IsRecommend { get => _IsRecommend; set { if (OnPropertyChanging(__.IsRecommend, value)) { _IsRecommend = value; OnPropertyChanged(__.IsRecommend); } } }
|
||||||
|
|
||||||
private Int32 _IsNew;
|
private Int32 _IsNew;
|
||||||
/// <summary>是否最新</summary>
|
/// <summary>是否最新</summary>
|
||||||
[DisplayName("是否最新")]
|
[DisplayName("是否最新")]
|
||||||
[Description("是否最新")]
|
[Description("是否最新")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsNew", "是否最新", "int")]
|
[BindColumn("IsNew", "是否最新", "")]
|
||||||
public Int32 IsNew { get { return _IsNew; } set { if (OnPropertyChanging(__.IsNew, value)) { _IsNew = value; OnPropertyChanged(__.IsNew); } } }
|
public Int32 IsNew { get => _IsNew; set { if (OnPropertyChanging(__.IsNew, value)) { _IsNew = value; OnPropertyChanged(__.IsNew); } } }
|
||||||
|
|
||||||
private Int32 _IsBest;
|
private Int32 _IsBest;
|
||||||
/// <summary>是否推荐</summary>
|
/// <summary>是否推荐</summary>
|
||||||
[DisplayName("是否推荐")]
|
[DisplayName("是否推荐")]
|
||||||
[Description("是否推荐")]
|
[Description("是否推荐")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsBest", "是否推荐", "int")]
|
[BindColumn("IsBest", "是否推荐", "")]
|
||||||
public Int32 IsBest { get { return _IsBest; } set { if (OnPropertyChanging(__.IsBest, value)) { _IsBest = value; OnPropertyChanged(__.IsBest); } } }
|
public Int32 IsBest { get => _IsBest; set { if (OnPropertyChanging(__.IsBest, value)) { _IsBest = value; OnPropertyChanged(__.IsBest); } } }
|
||||||
|
|
||||||
private Int32 _IsHide;
|
private Int32 _IsHide;
|
||||||
/// <summary>是否隐藏</summary>
|
/// <summary>是否隐藏</summary>
|
||||||
[DisplayName("是否隐藏")]
|
[DisplayName("是否隐藏")]
|
||||||
[Description("是否隐藏")]
|
[Description("是否隐藏")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsHide", "是否隐藏", "int")]
|
[BindColumn("IsHide", "是否隐藏", "")]
|
||||||
public Int32 IsHide { get { return _IsHide; } set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } }
|
public Int32 IsHide { get => _IsHide; set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } }
|
||||||
|
|
||||||
private Int32 _IsLock;
|
private Int32 _IsLock;
|
||||||
/// <summary>是否锁定,不允许删除</summary>
|
/// <summary>是否锁定,不允许删除</summary>
|
||||||
[DisplayName("是否锁定")]
|
[DisplayName("是否锁定")]
|
||||||
[Description("是否锁定,不允许删除")]
|
[Description("是否锁定,不允许删除")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsLock", "是否锁定,不允许删除", "int")]
|
[BindColumn("IsLock", "是否锁定,不允许删除", "")]
|
||||||
public Int32 IsLock { get { return _IsLock; } set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } }
|
public Int32 IsLock { get => _IsLock; set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } }
|
||||||
|
|
||||||
private Int32 _IsDel;
|
private Int32 _IsDel;
|
||||||
/// <summary>是否删除,已经删除到回收站</summary>
|
/// <summary>是否删除,已经删除到回收站</summary>
|
||||||
[DisplayName("是否删除")]
|
[DisplayName("是否删除")]
|
||||||
[Description("是否删除,已经删除到回收站")]
|
[Description("是否删除,已经删除到回收站")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsDel", "是否删除,已经删除到回收站", "int")]
|
[BindColumn("IsDel", "是否删除,已经删除到回收站", "")]
|
||||||
public Int32 IsDel { get { return _IsDel; } set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } }
|
public Int32 IsDel { get => _IsDel; set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } }
|
||||||
|
|
||||||
private Int32 _IsTop;
|
private Int32 _IsTop;
|
||||||
/// <summary>是否置顶</summary>
|
/// <summary>是否置顶</summary>
|
||||||
[DisplayName("是否置顶")]
|
[DisplayName("是否置顶")]
|
||||||
[Description("是否置顶")]
|
[Description("是否置顶")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsTop", "是否置顶", "int")]
|
[BindColumn("IsTop", "是否置顶", "")]
|
||||||
public Int32 IsTop { get { return _IsTop; } set { if (OnPropertyChanging(__.IsTop, value)) { _IsTop = value; OnPropertyChanged(__.IsTop); } } }
|
public Int32 IsTop { get => _IsTop; set { if (OnPropertyChanging(__.IsTop, value)) { _IsTop = value; OnPropertyChanged(__.IsTop); } } }
|
||||||
|
|
||||||
private Int32 _IsComment;
|
private Int32 _IsComment;
|
||||||
/// <summary>是否允许评论</summary>
|
/// <summary>是否允许评论</summary>
|
||||||
[DisplayName("是否允许评论")]
|
[DisplayName("是否允许评论")]
|
||||||
[Description("是否允许评论")]
|
[Description("是否允许评论")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsComment", "是否允许评论", "int")]
|
[BindColumn("IsComment", "是否允许评论", "")]
|
||||||
public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } }
|
public Int32 IsComment { get => _IsComment; set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } }
|
||||||
|
|
||||||
private Int32 _IsMember;
|
private Int32 _IsMember;
|
||||||
/// <summary>是否会员栏目</summary>
|
/// <summary>是否会员栏目</summary>
|
||||||
[DisplayName("是否会员栏目")]
|
[DisplayName("是否会员栏目")]
|
||||||
[Description("是否会员栏目")]
|
[Description("是否会员栏目")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsMember", "是否会员栏目", "int")]
|
[BindColumn("IsMember", "是否会员栏目", "")]
|
||||||
public Int32 IsMember { get { return _IsMember; } set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } }
|
public Int32 IsMember { get => _IsMember; set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } }
|
||||||
|
|
||||||
private Int32 _Hits;
|
private Int32 _Hits;
|
||||||
/// <summary>点击数量</summary>
|
/// <summary>点击数量</summary>
|
||||||
[DisplayName("点击数量")]
|
[DisplayName("点击数量")]
|
||||||
[Description("点击数量")]
|
[Description("点击数量")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Hits", "点击数量", "int")]
|
[BindColumn("Hits", "点击数量", "")]
|
||||||
public Int32 Hits { get { return _Hits; } set { if (OnPropertyChanging(__.Hits, value)) { _Hits = value; OnPropertyChanged(__.Hits); } } }
|
public Int32 Hits { get => _Hits; set { if (OnPropertyChanging(__.Hits, value)) { _Hits = value; OnPropertyChanged(__.Hits); } } }
|
||||||
|
|
||||||
private Int32 _Sequence;
|
private Int32 _Sequence;
|
||||||
/// <summary>排序</summary>
|
/// <summary>排序</summary>
|
||||||
[DisplayName("排序")]
|
[DisplayName("排序")]
|
||||||
[Description("排序")]
|
[Description("排序")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Sequence", "排序", "int")]
|
[BindColumn("Sequence", "排序", "")]
|
||||||
public Int32 Sequence { get { return _Sequence; } set { if (OnPropertyChanging(__.Sequence, value)) { _Sequence = value; OnPropertyChanged(__.Sequence); } } }
|
public Int32 Sequence { get => _Sequence; set { if (OnPropertyChanging(__.Sequence, value)) { _Sequence = value; OnPropertyChanged(__.Sequence); } } }
|
||||||
|
|
||||||
private Int32 _CommentCount;
|
private Int32 _CommentCount;
|
||||||
/// <summary>评论数量</summary>
|
/// <summary>评论数量</summary>
|
||||||
[DisplayName("评论数量")]
|
[DisplayName("评论数量")]
|
||||||
[Description("评论数量")]
|
[Description("评论数量")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("CommentCount", "评论数量", "int")]
|
[BindColumn("CommentCount", "评论数量", "")]
|
||||||
public Int32 CommentCount { get { return _CommentCount; } set { if (OnPropertyChanging(__.CommentCount, value)) { _CommentCount = value; OnPropertyChanged(__.CommentCount); } } }
|
public Int32 CommentCount { get => _CommentCount; set { if (OnPropertyChanging(__.CommentCount, value)) { _CommentCount = value; OnPropertyChanged(__.CommentCount); } } }
|
||||||
|
|
||||||
private String _Icon;
|
private String _Icon;
|
||||||
/// <summary>图标</summary>
|
/// <summary>图标</summary>
|
||||||
[DisplayName("图标")]
|
[DisplayName("图标")]
|
||||||
[Description("图标")]
|
[Description("图标")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("Icon", "图标", "nvarchar(100)")]
|
[BindColumn("Icon", "图标", "")]
|
||||||
public String Icon { get { return _Icon; } set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } }
|
public String Icon { get => _Icon; set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } }
|
||||||
|
|
||||||
private String _ClassName;
|
private String _ClassName;
|
||||||
/// <summary>样式名称</summary>
|
/// <summary>样式名称</summary>
|
||||||
[DisplayName("样式名称")]
|
[DisplayName("样式名称")]
|
||||||
[Description("样式名称")]
|
[Description("样式名称")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("ClassName", "样式名称", "nvarchar(50)")]
|
[BindColumn("ClassName", "样式名称", "")]
|
||||||
public String ClassName { get { return _ClassName; } set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } }
|
public String ClassName { get => _ClassName; set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } }
|
||||||
|
|
||||||
private String _BannerImg;
|
private String _BannerImg;
|
||||||
/// <summary>banner图片</summary>
|
/// <summary>banner图片</summary>
|
||||||
[DisplayName("banner图片")]
|
[DisplayName("banner图片")]
|
||||||
[Description("banner图片")]
|
[Description("banner图片")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("BannerImg", "banner图片", "nvarchar(250)")]
|
[BindColumn("BannerImg", "banner图片", "")]
|
||||||
public String BannerImg { get { return _BannerImg; } set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } }
|
public String BannerImg { get => _BannerImg; set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } }
|
||||||
|
|
||||||
private String _Pic;
|
private String _Pic;
|
||||||
/// <summary>图片</summary>
|
/// <summary>图片</summary>
|
||||||
[DisplayName("图片")]
|
[DisplayName("图片")]
|
||||||
[Description("图片")]
|
[Description("图片")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Pic", "图片", "nvarchar(250)")]
|
[BindColumn("Pic", "图片", "")]
|
||||||
public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } }
|
public String Pic { get => _Pic; set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } }
|
||||||
|
|
||||||
private Int32 _AdsId;
|
private Int32 _AdsId;
|
||||||
/// <summary>广告ID</summary>
|
/// <summary>广告ID</summary>
|
||||||
[DisplayName("广告ID")]
|
[DisplayName("广告ID")]
|
||||||
[Description("广告ID")]
|
[Description("广告ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("AdsId", "广告ID", "int")]
|
[BindColumn("AdsId", "广告ID", "")]
|
||||||
public Int32 AdsId { get { return _AdsId; } set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } }
|
public Int32 AdsId { get => _AdsId; set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } }
|
||||||
|
|
||||||
private String _Tags;
|
private String _Tags;
|
||||||
/// <summary>TAG</summary>
|
/// <summary>TAG</summary>
|
||||||
[DisplayName("TAG")]
|
[DisplayName("TAG")]
|
||||||
[Description("TAG")]
|
[Description("TAG")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Tags", "TAG", "nvarchar(250)")]
|
[BindColumn("Tags", "TAG", "")]
|
||||||
public String Tags { get { return _Tags; } set { if (OnPropertyChanging(__.Tags, value)) { _Tags = value; OnPropertyChanged(__.Tags); } } }
|
public String Tags { get => _Tags; set { if (OnPropertyChanging(__.Tags, value)) { _Tags = value; OnPropertyChanged(__.Tags); } } }
|
||||||
|
|
||||||
private String _Origin;
|
private String _Origin;
|
||||||
/// <summary>来源</summary>
|
/// <summary>来源</summary>
|
||||||
[DisplayName("来源")]
|
[DisplayName("来源")]
|
||||||
[Description("来源")]
|
[Description("来源")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Origin", "来源", "nvarchar(250)")]
|
[BindColumn("Origin", "来源", "")]
|
||||||
public String Origin { get { return _Origin; } set { if (OnPropertyChanging(__.Origin, value)) { _Origin = value; OnPropertyChanged(__.Origin); } } }
|
public String Origin { get => _Origin; set { if (OnPropertyChanging(__.Origin, value)) { _Origin = value; OnPropertyChanged(__.Origin); } } }
|
||||||
|
|
||||||
private String _OriginURL;
|
private String _OriginURL;
|
||||||
/// <summary>来源地址</summary>
|
/// <summary>来源地址</summary>
|
||||||
[DisplayName("来源地址")]
|
[DisplayName("来源地址")]
|
||||||
[Description("来源地址")]
|
[Description("来源地址")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("OriginURL", "来源地址", "nvarchar(250)")]
|
[BindColumn("OriginURL", "来源地址", "")]
|
||||||
public String OriginURL { get { return _OriginURL; } set { if (OnPropertyChanging(__.OriginURL, value)) { _OriginURL = value; OnPropertyChanged(__.OriginURL); } } }
|
public String OriginURL { get => _OriginURL; set { if (OnPropertyChanging(__.OriginURL, value)) { _OriginURL = value; OnPropertyChanged(__.OriginURL); } } }
|
||||||
|
|
||||||
private String _ItemImg;
|
private String _ItemImg;
|
||||||
/// <summary>更多图片</summary>
|
/// <summary>更多图片</summary>
|
||||||
[DisplayName("更多图片")]
|
[DisplayName("更多图片")]
|
||||||
[Description("更多图片")]
|
[Description("更多图片")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("ItemImg", "更多图片", "ntext")]
|
[BindColumn("ItemImg", "更多图片", "")]
|
||||||
public String ItemImg { get { return _ItemImg; } set { if (OnPropertyChanging(__.ItemImg, value)) { _ItemImg = value; OnPropertyChanged(__.ItemImg); } } }
|
public String ItemImg { get => _ItemImg; set { if (OnPropertyChanging(__.ItemImg, value)) { _ItemImg = value; OnPropertyChanged(__.ItemImg); } } }
|
||||||
|
|
||||||
private Int32 _AuthorId;
|
private Int32 _AuthorId;
|
||||||
/// <summary>添加管理员ID</summary>
|
/// <summary>添加管理员ID</summary>
|
||||||
[DisplayName("添加管理员ID")]
|
[DisplayName("添加管理员ID")]
|
||||||
[Description("添加管理员ID")]
|
[Description("添加管理员ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("AuthorId", "添加管理员ID", "int")]
|
[BindColumn("AuthorId", "添加管理员ID", "")]
|
||||||
public Int32 AuthorId { get { return _AuthorId; } set { if (OnPropertyChanging(__.AuthorId, value)) { _AuthorId = value; OnPropertyChanged(__.AuthorId); } } }
|
public Int32 AuthorId { get => _AuthorId; set { if (OnPropertyChanging(__.AuthorId, value)) { _AuthorId = value; OnPropertyChanged(__.AuthorId); } } }
|
||||||
|
|
||||||
private DateTime _AddTime;
|
private DateTime _AddTime;
|
||||||
/// <summary>添加时间</summary>
|
/// <summary>添加时间</summary>
|
||||||
[DisplayName("添加时间")]
|
[DisplayName("添加时间")]
|
||||||
[Description("添加时间")]
|
[Description("添加时间")]
|
||||||
[DataObjectField(false, false, true, 0)]
|
[DataObjectField(false, false, true, 0)]
|
||||||
[BindColumn("AddTime", "添加时间", "datetime")]
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
public DateTime AddTime { get => _AddTime; set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
||||||
|
|
||||||
private DateTime _UpdateTime;
|
private DateTime _UpdateTime;
|
||||||
/// <summary>时间</summary>
|
/// <summary>时间</summary>
|
||||||
[DisplayName("时间")]
|
[DisplayName("时间")]
|
||||||
[Description("时间")]
|
[Description("时间")]
|
||||||
[DataObjectField(false, false, true, 0)]
|
[DataObjectField(false, false, true, 0)]
|
||||||
[BindColumn("UpdateTime", "时间", "datetime")]
|
[BindColumn("UpdateTime", "时间", "")]
|
||||||
public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
||||||
|
|
||||||
private String _Location;
|
private String _Location;
|
||||||
/// <summary>路径</summary>
|
/// <summary>路径</summary>
|
||||||
[DisplayName("路径")]
|
[DisplayName("路径")]
|
||||||
[Description("路径")]
|
[Description("路径")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("Location", "路径", "nvarchar(100)")]
|
[BindColumn("Location", "路径", "")]
|
||||||
public String Location { get { return _Location; } set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } }
|
public String Location { get => _Location; set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } }
|
||||||
|
|
||||||
private String _FilePath;
|
private String _FilePath;
|
||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
[DisplayName("存放目录")]
|
[DisplayName("存放目录")]
|
||||||
[Description("存放目录")]
|
[Description("存放目录")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("FilePath", "存放目录", "nvarchar(100)")]
|
[BindColumn("FilePath", "存放目录", "")]
|
||||||
public String FilePath { get { return _FilePath; } set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } }
|
public String FilePath { get => _FilePath; set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } }
|
||||||
|
|
||||||
|
private String _FileName;
|
||||||
|
/// <summary>文件名称</summary>
|
||||||
|
[DisplayName("文件名称")]
|
||||||
|
[Description("文件名称")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("FileName", "文件名称", "")]
|
||||||
|
public String FileName { get => _FileName; set { if (OnPropertyChanging(__.FileName, value)) { _FileName = value; OnPropertyChanged(__.FileName); } } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
#region 获取/设置 字段值
|
||||||
@@ -350,6 +359,7 @@ namespace COMCMS.Core
|
|||||||
case __.UpdateTime: return _UpdateTime;
|
case __.UpdateTime: return _UpdateTime;
|
||||||
case __.Location: return _Location;
|
case __.Location: return _Location;
|
||||||
case __.FilePath: return _FilePath;
|
case __.FilePath: return _FilePath;
|
||||||
|
case __.FileName: return _FileName;
|
||||||
default: return base[name];
|
default: return base[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -357,8 +367,8 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case __.Id : _Id = Convert.ToInt32(value); break;
|
case __.Id: _Id = value.ToInt(); break;
|
||||||
case __.KId : _KId = Convert.ToInt32(value); break;
|
case __.KId: _KId = value.ToInt(); break;
|
||||||
case __.Title: _Title = Convert.ToString(value); break;
|
case __.Title: _Title = Convert.ToString(value); break;
|
||||||
case __.SubTitle: _SubTitle = Convert.ToString(value); break;
|
case __.SubTitle: _SubTitle = Convert.ToString(value); break;
|
||||||
case __.Content: _Content = Convert.ToString(value); break;
|
case __.Content: _Content = Convert.ToString(value); break;
|
||||||
@@ -367,32 +377,33 @@ namespace COMCMS.Core
|
|||||||
case __.LinkURL: _LinkURL = Convert.ToString(value); break;
|
case __.LinkURL: _LinkURL = Convert.ToString(value); break;
|
||||||
case __.TitleColor: _TitleColor = Convert.ToString(value); break;
|
case __.TitleColor: _TitleColor = Convert.ToString(value); break;
|
||||||
case __.TemplateFile: _TemplateFile = Convert.ToString(value); break;
|
case __.TemplateFile: _TemplateFile = Convert.ToString(value); break;
|
||||||
case __.IsRecommend : _IsRecommend = Convert.ToInt32(value); break;
|
case __.IsRecommend: _IsRecommend = value.ToInt(); break;
|
||||||
case __.IsNew : _IsNew = Convert.ToInt32(value); break;
|
case __.IsNew: _IsNew = value.ToInt(); break;
|
||||||
case __.IsBest : _IsBest = Convert.ToInt32(value); break;
|
case __.IsBest: _IsBest = value.ToInt(); break;
|
||||||
case __.IsHide : _IsHide = Convert.ToInt32(value); break;
|
case __.IsHide: _IsHide = value.ToInt(); break;
|
||||||
case __.IsLock : _IsLock = Convert.ToInt32(value); break;
|
case __.IsLock: _IsLock = value.ToInt(); break;
|
||||||
case __.IsDel : _IsDel = Convert.ToInt32(value); break;
|
case __.IsDel: _IsDel = value.ToInt(); break;
|
||||||
case __.IsTop : _IsTop = Convert.ToInt32(value); break;
|
case __.IsTop: _IsTop = value.ToInt(); break;
|
||||||
case __.IsComment : _IsComment = Convert.ToInt32(value); break;
|
case __.IsComment: _IsComment = value.ToInt(); break;
|
||||||
case __.IsMember : _IsMember = Convert.ToInt32(value); break;
|
case __.IsMember: _IsMember = value.ToInt(); break;
|
||||||
case __.Hits : _Hits = Convert.ToInt32(value); break;
|
case __.Hits: _Hits = value.ToInt(); break;
|
||||||
case __.Sequence : _Sequence = Convert.ToInt32(value); break;
|
case __.Sequence: _Sequence = value.ToInt(); break;
|
||||||
case __.CommentCount : _CommentCount = Convert.ToInt32(value); break;
|
case __.CommentCount: _CommentCount = value.ToInt(); break;
|
||||||
case __.Icon: _Icon = Convert.ToString(value); break;
|
case __.Icon: _Icon = Convert.ToString(value); break;
|
||||||
case __.ClassName: _ClassName = Convert.ToString(value); break;
|
case __.ClassName: _ClassName = Convert.ToString(value); break;
|
||||||
case __.BannerImg: _BannerImg = Convert.ToString(value); break;
|
case __.BannerImg: _BannerImg = Convert.ToString(value); break;
|
||||||
case __.Pic: _Pic = Convert.ToString(value); break;
|
case __.Pic: _Pic = Convert.ToString(value); break;
|
||||||
case __.AdsId : _AdsId = Convert.ToInt32(value); break;
|
case __.AdsId: _AdsId = value.ToInt(); break;
|
||||||
case __.Tags: _Tags = Convert.ToString(value); break;
|
case __.Tags: _Tags = Convert.ToString(value); break;
|
||||||
case __.Origin: _Origin = Convert.ToString(value); break;
|
case __.Origin: _Origin = Convert.ToString(value); break;
|
||||||
case __.OriginURL: _OriginURL = Convert.ToString(value); break;
|
case __.OriginURL: _OriginURL = Convert.ToString(value); break;
|
||||||
case __.ItemImg: _ItemImg = Convert.ToString(value); break;
|
case __.ItemImg: _ItemImg = Convert.ToString(value); break;
|
||||||
case __.AuthorId : _AuthorId = Convert.ToInt32(value); break;
|
case __.AuthorId: _AuthorId = value.ToInt(); break;
|
||||||
case __.AddTime : _AddTime = Convert.ToDateTime(value); break;
|
case __.AddTime: _AddTime = value.ToDateTime(); break;
|
||||||
case __.UpdateTime : _UpdateTime = Convert.ToDateTime(value); break;
|
case __.UpdateTime: _UpdateTime = value.ToDateTime(); break;
|
||||||
case __.Location: _Location = Convert.ToString(value); break;
|
case __.Location: _Location = Convert.ToString(value); break;
|
||||||
case __.FilePath: _FilePath = Convert.ToString(value); break;
|
case __.FilePath: _FilePath = Convert.ToString(value); break;
|
||||||
|
case __.FileName: _FileName = Convert.ToString(value); break;
|
||||||
default: base[name] = value; break;
|
default: base[name] = value; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -511,7 +522,10 @@ namespace COMCMS.Core
|
|||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
public static readonly Field FilePath = FindByName(__.FilePath);
|
public static readonly Field FilePath = FindByName(__.FilePath);
|
||||||
|
|
||||||
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
/// <summary>文件名称</summary>
|
||||||
|
public static readonly Field FileName = FindByName(__.FileName);
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>取得文章字段名称的快捷方式</summary>
|
/// <summary>取得文章字段名称的快捷方式</summary>
|
||||||
@@ -624,6 +638,9 @@ namespace COMCMS.Core
|
|||||||
|
|
||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
public const String FilePath = "FilePath";
|
public const String FilePath = "FilePath";
|
||||||
|
|
||||||
|
/// <summary>文件名称</summary>
|
||||||
|
public const String FileName = "FileName";
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -739,6 +756,9 @@ namespace COMCMS.Core
|
|||||||
|
|
||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
String FilePath { get; set; }
|
String FilePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>文件名称</summary>
|
||||||
|
String FileName { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
#region 获取/设置 字段值
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
|
using COMCMS.Common;
|
||||||
using NewLife;
|
using NewLife;
|
||||||
using NewLife.Data;
|
using NewLife.Data;
|
||||||
using NewLife.Log;
|
using NewLife.Log;
|
||||||
@@ -359,7 +360,7 @@ namespace COMCMS.Core
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
re += " > " + string.Format(tpl, "/article/index/" + model.Id, model.KindName);
|
re += " > " + string.Format(tpl, ViewsHelper.EchoURL(Utils.CMSType.ArticleCategory, kid), model.KindName);
|
||||||
if (model.PId != 0)
|
if (model.PId != 0)
|
||||||
{
|
{
|
||||||
re = GetNav(model.PId) + re;
|
re = GetNav(model.PId) + re;
|
||||||
|
|||||||
+150
-239
@@ -1,9 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Xml.Serialization;
|
||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
@@ -12,7 +16,7 @@ namespace COMCMS.Core
|
|||||||
[DataObject]
|
[DataObject]
|
||||||
[Description("文章栏目")]
|
[Description("文章栏目")]
|
||||||
[BindTable("ArticleCategory", Description = "文章栏目", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
[BindTable("ArticleCategory", Description = "文章栏目", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
public partial class ArticleCategory : IArticleCategory
|
public partial class ArticleCategory
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
private Int32 _Id;
|
private Int32 _Id;
|
||||||
@@ -21,7 +25,7 @@ namespace COMCMS.Core
|
|||||||
[Description("编号")]
|
[Description("编号")]
|
||||||
[DataObjectField(true, true, false, 0)]
|
[DataObjectField(true, true, false, 0)]
|
||||||
[BindColumn("Id", "编号", "")]
|
[BindColumn("Id", "编号", "")]
|
||||||
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||||
|
|
||||||
private String _KindName;
|
private String _KindName;
|
||||||
/// <summary>栏目名称</summary>
|
/// <summary>栏目名称</summary>
|
||||||
@@ -29,7 +33,7 @@ namespace COMCMS.Core
|
|||||||
[Description("栏目名称")]
|
[Description("栏目名称")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("KindName", "栏目名称", "")]
|
[BindColumn("KindName", "栏目名称", "")]
|
||||||
public String KindName { get { return _KindName; } set { if (OnPropertyChanging(__.KindName, value)) { _KindName = value; OnPropertyChanged(__.KindName); } } }
|
public String KindName { get => _KindName; set { if (OnPropertyChanging("KindName", value)) { _KindName = value; OnPropertyChanged("KindName"); } } }
|
||||||
|
|
||||||
private String _SubTitle;
|
private String _SubTitle;
|
||||||
/// <summary>栏目副标题</summary>
|
/// <summary>栏目副标题</summary>
|
||||||
@@ -37,7 +41,7 @@ namespace COMCMS.Core
|
|||||||
[Description("栏目副标题")]
|
[Description("栏目副标题")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("SubTitle", "栏目副标题", "")]
|
[BindColumn("SubTitle", "栏目副标题", "")]
|
||||||
public String SubTitle { get { return _SubTitle; } set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } }
|
public String SubTitle { get => _SubTitle; set { if (OnPropertyChanging("SubTitle", value)) { _SubTitle = value; OnPropertyChanged("SubTitle"); } } }
|
||||||
|
|
||||||
private String _KindTitle;
|
private String _KindTitle;
|
||||||
/// <summary>栏目标题,填写则在浏览器替换此标题</summary>
|
/// <summary>栏目标题,填写则在浏览器替换此标题</summary>
|
||||||
@@ -45,7 +49,7 @@ namespace COMCMS.Core
|
|||||||
[Description("栏目标题,填写则在浏览器替换此标题")]
|
[Description("栏目标题,填写则在浏览器替换此标题")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "")]
|
[BindColumn("KindTitle", "栏目标题,填写则在浏览器替换此标题", "")]
|
||||||
public String KindTitle { get { return _KindTitle; } set { if (OnPropertyChanging(__.KindTitle, value)) { _KindTitle = value; OnPropertyChanged(__.KindTitle); } } }
|
public String KindTitle { get => _KindTitle; set { if (OnPropertyChanging("KindTitle", value)) { _KindTitle = value; OnPropertyChanged("KindTitle"); } } }
|
||||||
|
|
||||||
private String _Keyword;
|
private String _Keyword;
|
||||||
/// <summary>描述</summary>
|
/// <summary>描述</summary>
|
||||||
@@ -53,7 +57,7 @@ namespace COMCMS.Core
|
|||||||
[Description("描述")]
|
[Description("描述")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Keyword", "描述", "")]
|
[BindColumn("Keyword", "描述", "")]
|
||||||
public String Keyword { get { return _Keyword; } set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } }
|
public String Keyword { get => _Keyword; set { if (OnPropertyChanging("Keyword", value)) { _Keyword = value; OnPropertyChanged("Keyword"); } } }
|
||||||
|
|
||||||
private String _Description;
|
private String _Description;
|
||||||
/// <summary>介绍</summary>
|
/// <summary>介绍</summary>
|
||||||
@@ -61,7 +65,7 @@ namespace COMCMS.Core
|
|||||||
[Description("介绍")]
|
[Description("介绍")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Description", "介绍", "")]
|
[BindColumn("Description", "介绍", "")]
|
||||||
public String Description { get { return _Description; } set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
public String Description { get => _Description; set { if (OnPropertyChanging("Description", value)) { _Description = value; OnPropertyChanged("Description"); } } }
|
||||||
|
|
||||||
private String _LinkURL;
|
private String _LinkURL;
|
||||||
/// <summary>跳转链接</summary>
|
/// <summary>跳转链接</summary>
|
||||||
@@ -69,7 +73,7 @@ namespace COMCMS.Core
|
|||||||
[Description("跳转链接")]
|
[Description("跳转链接")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("LinkURL", "跳转链接", "")]
|
[BindColumn("LinkURL", "跳转链接", "")]
|
||||||
public String LinkURL { get { return _LinkURL; } set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } }
|
public String LinkURL { get => _LinkURL; set { if (OnPropertyChanging("LinkURL", value)) { _LinkURL = value; OnPropertyChanged("LinkURL"); } } }
|
||||||
|
|
||||||
private String _TitleColor;
|
private String _TitleColor;
|
||||||
/// <summary>类别名称颜色</summary>
|
/// <summary>类别名称颜色</summary>
|
||||||
@@ -77,7 +81,7 @@ namespace COMCMS.Core
|
|||||||
[Description("类别名称颜色")]
|
[Description("类别名称颜色")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("TitleColor", "类别名称颜色", "")]
|
[BindColumn("TitleColor", "类别名称颜色", "")]
|
||||||
public String TitleColor { get { return _TitleColor; } set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } }
|
public String TitleColor { get => _TitleColor; set { if (OnPropertyChanging("TitleColor", value)) { _TitleColor = value; OnPropertyChanged("TitleColor"); } } }
|
||||||
|
|
||||||
private String _TemplateFile;
|
private String _TemplateFile;
|
||||||
/// <summary>模板</summary>
|
/// <summary>模板</summary>
|
||||||
@@ -85,7 +89,7 @@ namespace COMCMS.Core
|
|||||||
[Description("模板")]
|
[Description("模板")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("TemplateFile", "模板", "")]
|
[BindColumn("TemplateFile", "模板", "")]
|
||||||
public String TemplateFile { get { return _TemplateFile; } set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } }
|
public String TemplateFile { get => _TemplateFile; set { if (OnPropertyChanging("TemplateFile", value)) { _TemplateFile = value; OnPropertyChanged("TemplateFile"); } } }
|
||||||
|
|
||||||
private String _DetailTemplateFile;
|
private String _DetailTemplateFile;
|
||||||
/// <summary>详情模板</summary>
|
/// <summary>详情模板</summary>
|
||||||
@@ -93,7 +97,7 @@ namespace COMCMS.Core
|
|||||||
[Description("详情模板")]
|
[Description("详情模板")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("DetailTemplateFile", "详情模板", "")]
|
[BindColumn("DetailTemplateFile", "详情模板", "")]
|
||||||
public String DetailTemplateFile { get { return _DetailTemplateFile; } set { if (OnPropertyChanging(__.DetailTemplateFile, value)) { _DetailTemplateFile = value; OnPropertyChanged(__.DetailTemplateFile); } } }
|
public String DetailTemplateFile { get => _DetailTemplateFile; set { if (OnPropertyChanging("DetailTemplateFile", value)) { _DetailTemplateFile = value; OnPropertyChanged("DetailTemplateFile"); } } }
|
||||||
|
|
||||||
private String _KindDomain;
|
private String _KindDomain;
|
||||||
/// <summary>类别域名(保留)</summary>
|
/// <summary>类别域名(保留)</summary>
|
||||||
@@ -101,7 +105,7 @@ namespace COMCMS.Core
|
|||||||
[Description("类别域名(保留)")]
|
[Description("类别域名(保留)")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("KindDomain", "类别域名(保留)", "")]
|
[BindColumn("KindDomain", "类别域名(保留)", "")]
|
||||||
public String KindDomain { get { return _KindDomain; } set { if (OnPropertyChanging(__.KindDomain, value)) { _KindDomain = value; OnPropertyChanged(__.KindDomain); } } }
|
public String KindDomain { get => _KindDomain; set { if (OnPropertyChanging("KindDomain", value)) { _KindDomain = value; OnPropertyChanged("KindDomain"); } } }
|
||||||
|
|
||||||
private Int32 _IsList;
|
private Int32 _IsList;
|
||||||
/// <summary>是否为列表页面</summary>
|
/// <summary>是否为列表页面</summary>
|
||||||
@@ -109,7 +113,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否为列表页面")]
|
[Description("是否为列表页面")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsList", "是否为列表页面", "")]
|
[BindColumn("IsList", "是否为列表页面", "")]
|
||||||
public Int32 IsList { get { return _IsList; } set { if (OnPropertyChanging(__.IsList, value)) { _IsList = value; OnPropertyChanged(__.IsList); } } }
|
public Int32 IsList { get => _IsList; set { if (OnPropertyChanging("IsList", value)) { _IsList = value; OnPropertyChanged("IsList"); } } }
|
||||||
|
|
||||||
private Int32 _PageSize;
|
private Int32 _PageSize;
|
||||||
/// <summary>每页显示数量</summary>
|
/// <summary>每页显示数量</summary>
|
||||||
@@ -117,7 +121,7 @@ namespace COMCMS.Core
|
|||||||
[Description("每页显示数量")]
|
[Description("每页显示数量")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("PageSize", "每页显示数量", "")]
|
[BindColumn("PageSize", "每页显示数量", "")]
|
||||||
public Int32 PageSize { get { return _PageSize; } set { if (OnPropertyChanging(__.PageSize, value)) { _PageSize = value; OnPropertyChanged(__.PageSize); } } }
|
public Int32 PageSize { get => _PageSize; set { if (OnPropertyChanging("PageSize", value)) { _PageSize = value; OnPropertyChanged("PageSize"); } } }
|
||||||
|
|
||||||
private Int32 _PId;
|
private Int32 _PId;
|
||||||
/// <summary>上级ID</summary>
|
/// <summary>上级ID</summary>
|
||||||
@@ -125,7 +129,7 @@ namespace COMCMS.Core
|
|||||||
[Description("上级ID")]
|
[Description("上级ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("PId", "上级ID", "")]
|
[BindColumn("PId", "上级ID", "")]
|
||||||
public Int32 PId { get { return _PId; } set { if (OnPropertyChanging(__.PId, value)) { _PId = value; OnPropertyChanged(__.PId); } } }
|
public Int32 PId { get => _PId; set { if (OnPropertyChanging("PId", value)) { _PId = value; OnPropertyChanged("PId"); } } }
|
||||||
|
|
||||||
private Int32 _Level;
|
private Int32 _Level;
|
||||||
/// <summary>级别</summary>
|
/// <summary>级别</summary>
|
||||||
@@ -133,7 +137,7 @@ namespace COMCMS.Core
|
|||||||
[Description("级别")]
|
[Description("级别")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Level", "级别", "")]
|
[BindColumn("Level", "级别", "")]
|
||||||
public Int32 Level { get { return _Level; } set { if (OnPropertyChanging(__.Level, value)) { _Level = value; OnPropertyChanged(__.Level); } } }
|
public Int32 Level { get => _Level; set { if (OnPropertyChanging("Level", value)) { _Level = value; OnPropertyChanged("Level"); } } }
|
||||||
|
|
||||||
private String _Location;
|
private String _Location;
|
||||||
/// <summary>路径</summary>
|
/// <summary>路径</summary>
|
||||||
@@ -141,7 +145,7 @@ namespace COMCMS.Core
|
|||||||
[Description("路径")]
|
[Description("路径")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("Location", "路径", "")]
|
[BindColumn("Location", "路径", "")]
|
||||||
public String Location { get { return _Location; } set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } }
|
public String Location { get => _Location; set { if (OnPropertyChanging("Location", value)) { _Location = value; OnPropertyChanged("Location"); } } }
|
||||||
|
|
||||||
private Int32 _IsHide;
|
private Int32 _IsHide;
|
||||||
/// <summary>是否隐藏</summary>
|
/// <summary>是否隐藏</summary>
|
||||||
@@ -149,7 +153,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否隐藏")]
|
[Description("是否隐藏")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsHide", "是否隐藏", "")]
|
[BindColumn("IsHide", "是否隐藏", "")]
|
||||||
public Int32 IsHide { get { return _IsHide; } set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } }
|
public Int32 IsHide { get => _IsHide; set { if (OnPropertyChanging("IsHide", value)) { _IsHide = value; OnPropertyChanged("IsHide"); } } }
|
||||||
|
|
||||||
private Int32 _IsLock;
|
private Int32 _IsLock;
|
||||||
/// <summary>是否锁定,不允许删除</summary>
|
/// <summary>是否锁定,不允许删除</summary>
|
||||||
@@ -157,7 +161,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否锁定,不允许删除")]
|
[Description("是否锁定,不允许删除")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsLock", "是否锁定,不允许删除", "")]
|
[BindColumn("IsLock", "是否锁定,不允许删除", "")]
|
||||||
public Int32 IsLock { get { return _IsLock; } set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } }
|
public Int32 IsLock { get => _IsLock; set { if (OnPropertyChanging("IsLock", value)) { _IsLock = value; OnPropertyChanged("IsLock"); } } }
|
||||||
|
|
||||||
private Int32 _IsDel;
|
private Int32 _IsDel;
|
||||||
/// <summary>是否删除,已经删除到回收站</summary>
|
/// <summary>是否删除,已经删除到回收站</summary>
|
||||||
@@ -165,7 +169,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否删除,已经删除到回收站")]
|
[Description("是否删除,已经删除到回收站")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsDel", "是否删除,已经删除到回收站", "")]
|
[BindColumn("IsDel", "是否删除,已经删除到回收站", "")]
|
||||||
public Int32 IsDel { get { return _IsDel; } set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } }
|
public Int32 IsDel { get => _IsDel; set { if (OnPropertyChanging("IsDel", value)) { _IsDel = value; OnPropertyChanged("IsDel"); } } }
|
||||||
|
|
||||||
private Int32 _IsComment;
|
private Int32 _IsComment;
|
||||||
/// <summary>是否允许评论</summary>
|
/// <summary>是否允许评论</summary>
|
||||||
@@ -173,7 +177,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否允许评论")]
|
[Description("是否允许评论")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsComment", "是否允许评论", "")]
|
[BindColumn("IsComment", "是否允许评论", "")]
|
||||||
public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } }
|
public Int32 IsComment { get => _IsComment; set { if (OnPropertyChanging("IsComment", value)) { _IsComment = value; OnPropertyChanged("IsComment"); } } }
|
||||||
|
|
||||||
private Int32 _IsMember;
|
private Int32 _IsMember;
|
||||||
/// <summary>是否会员栏目</summary>
|
/// <summary>是否会员栏目</summary>
|
||||||
@@ -181,7 +185,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否会员栏目")]
|
[Description("是否会员栏目")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsMember", "是否会员栏目", "")]
|
[BindColumn("IsMember", "是否会员栏目", "")]
|
||||||
public Int32 IsMember { get { return _IsMember; } set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } }
|
public Int32 IsMember { get => _IsMember; set { if (OnPropertyChanging("IsMember", value)) { _IsMember = value; OnPropertyChanged("IsMember"); } } }
|
||||||
|
|
||||||
private Int32 _IsShowSubDetail;
|
private Int32 _IsShowSubDetail;
|
||||||
/// <summary>是否显示下级栏目内容</summary>
|
/// <summary>是否显示下级栏目内容</summary>
|
||||||
@@ -189,7 +193,7 @@ namespace COMCMS.Core
|
|||||||
[Description("是否显示下级栏目内容")]
|
[Description("是否显示下级栏目内容")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "")]
|
[BindColumn("IsShowSubDetail", "是否显示下级栏目内容", "")]
|
||||||
public Int32 IsShowSubDetail { get { return _IsShowSubDetail; } set { if (OnPropertyChanging(__.IsShowSubDetail, value)) { _IsShowSubDetail = value; OnPropertyChanged(__.IsShowSubDetail); } } }
|
public Int32 IsShowSubDetail { get => _IsShowSubDetail; set { if (OnPropertyChanging("IsShowSubDetail", value)) { _IsShowSubDetail = value; OnPropertyChanged("IsShowSubDetail"); } } }
|
||||||
|
|
||||||
private Int32 _CatalogId;
|
private Int32 _CatalogId;
|
||||||
/// <summary>模型ID</summary>
|
/// <summary>模型ID</summary>
|
||||||
@@ -197,7 +201,7 @@ namespace COMCMS.Core
|
|||||||
[Description("模型ID")]
|
[Description("模型ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("CatalogId", "模型ID", "")]
|
[BindColumn("CatalogId", "模型ID", "")]
|
||||||
public Int32 CatalogId { get { return _CatalogId; } set { if (OnPropertyChanging(__.CatalogId, value)) { _CatalogId = value; OnPropertyChanged(__.CatalogId); } } }
|
public Int32 CatalogId { get => _CatalogId; set { if (OnPropertyChanging("CatalogId", value)) { _CatalogId = value; OnPropertyChanged("CatalogId"); } } }
|
||||||
|
|
||||||
private Int32 _Counts;
|
private Int32 _Counts;
|
||||||
/// <summary>详情数量,缓存</summary>
|
/// <summary>详情数量,缓存</summary>
|
||||||
@@ -205,7 +209,7 @@ namespace COMCMS.Core
|
|||||||
[Description("详情数量,缓存")]
|
[Description("详情数量,缓存")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Counts", "详情数量,缓存", "")]
|
[BindColumn("Counts", "详情数量,缓存", "")]
|
||||||
public Int32 Counts { get { return _Counts; } set { if (OnPropertyChanging(__.Counts, value)) { _Counts = value; OnPropertyChanged(__.Counts); } } }
|
public Int32 Counts { get => _Counts; set { if (OnPropertyChanging("Counts", value)) { _Counts = value; OnPropertyChanged("Counts"); } } }
|
||||||
|
|
||||||
private Int32 _Rank;
|
private Int32 _Rank;
|
||||||
/// <summary>排序</summary>
|
/// <summary>排序</summary>
|
||||||
@@ -213,7 +217,7 @@ namespace COMCMS.Core
|
|||||||
[Description("排序")]
|
[Description("排序")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Rank", "排序", "")]
|
[BindColumn("Rank", "排序", "")]
|
||||||
public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } }
|
public Int32 Rank { get => _Rank; set { if (OnPropertyChanging("Rank", value)) { _Rank = value; OnPropertyChanged("Rank"); } } }
|
||||||
|
|
||||||
private String _Icon;
|
private String _Icon;
|
||||||
/// <summary>图标</summary>
|
/// <summary>图标</summary>
|
||||||
@@ -221,7 +225,7 @@ namespace COMCMS.Core
|
|||||||
[Description("图标")]
|
[Description("图标")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("Icon", "图标", "")]
|
[BindColumn("Icon", "图标", "")]
|
||||||
public String Icon { get { return _Icon; } set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } }
|
public String Icon { get => _Icon; set { if (OnPropertyChanging("Icon", value)) { _Icon = value; OnPropertyChanged("Icon"); } } }
|
||||||
|
|
||||||
private String _ClassName;
|
private String _ClassName;
|
||||||
/// <summary>样式名称</summary>
|
/// <summary>样式名称</summary>
|
||||||
@@ -229,7 +233,7 @@ namespace COMCMS.Core
|
|||||||
[Description("样式名称")]
|
[Description("样式名称")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("ClassName", "样式名称", "")]
|
[BindColumn("ClassName", "样式名称", "")]
|
||||||
public String ClassName { get { return _ClassName; } set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } }
|
public String ClassName { get => _ClassName; set { if (OnPropertyChanging("ClassName", value)) { _ClassName = value; OnPropertyChanged("ClassName"); } } }
|
||||||
|
|
||||||
private String _BannerImg;
|
private String _BannerImg;
|
||||||
/// <summary>banner图片</summary>
|
/// <summary>banner图片</summary>
|
||||||
@@ -237,7 +241,7 @@ namespace COMCMS.Core
|
|||||||
[Description("banner图片")]
|
[Description("banner图片")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("BannerImg", "banner图片", "")]
|
[BindColumn("BannerImg", "banner图片", "")]
|
||||||
public String BannerImg { get { return _BannerImg; } set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } }
|
public String BannerImg { get => _BannerImg; set { if (OnPropertyChanging("BannerImg", value)) { _BannerImg = value; OnPropertyChanged("BannerImg"); } } }
|
||||||
|
|
||||||
private String _KindInfo;
|
private String _KindInfo;
|
||||||
/// <summary>栏目详细介绍</summary>
|
/// <summary>栏目详细介绍</summary>
|
||||||
@@ -245,7 +249,7 @@ namespace COMCMS.Core
|
|||||||
[Description("栏目详细介绍")]
|
[Description("栏目详细介绍")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("KindInfo", "栏目详细介绍", "")]
|
[BindColumn("KindInfo", "栏目详细介绍", "")]
|
||||||
public String KindInfo { get { return _KindInfo; } set { if (OnPropertyChanging(__.KindInfo, value)) { _KindInfo = value; OnPropertyChanged(__.KindInfo); } } }
|
public String KindInfo { get => _KindInfo; set { if (OnPropertyChanging("KindInfo", value)) { _KindInfo = value; OnPropertyChanged("KindInfo"); } } }
|
||||||
|
|
||||||
private String _Pic;
|
private String _Pic;
|
||||||
/// <summary>图片</summary>
|
/// <summary>图片</summary>
|
||||||
@@ -253,7 +257,7 @@ namespace COMCMS.Core
|
|||||||
[Description("图片")]
|
[Description("图片")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Pic", "图片", "")]
|
[BindColumn("Pic", "图片", "")]
|
||||||
public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } }
|
public String Pic { get => _Pic; set { if (OnPropertyChanging("Pic", value)) { _Pic = value; OnPropertyChanged("Pic"); } } }
|
||||||
|
|
||||||
private Int32 _AdsId;
|
private Int32 _AdsId;
|
||||||
/// <summary>广告ID</summary>
|
/// <summary>广告ID</summary>
|
||||||
@@ -261,7 +265,7 @@ namespace COMCMS.Core
|
|||||||
[Description("广告ID")]
|
[Description("广告ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("AdsId", "广告ID", "")]
|
[BindColumn("AdsId", "广告ID", "")]
|
||||||
public Int32 AdsId { get { return _AdsId; } set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } }
|
public Int32 AdsId { get => _AdsId; set { if (OnPropertyChanging("AdsId", value)) { _AdsId = value; OnPropertyChanged("AdsId"); } } }
|
||||||
|
|
||||||
private String _FilePath;
|
private String _FilePath;
|
||||||
/// <summary>目录路径</summary>
|
/// <summary>目录路径</summary>
|
||||||
@@ -269,7 +273,15 @@ namespace COMCMS.Core
|
|||||||
[Description("目录路径")]
|
[Description("目录路径")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("FilePath", "目录路径", "")]
|
[BindColumn("FilePath", "目录路径", "")]
|
||||||
public String FilePath { get { return _FilePath; } set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } }
|
public String FilePath { get => _FilePath; set { if (OnPropertyChanging("FilePath", value)) { _FilePath = value; OnPropertyChanged("FilePath"); } } }
|
||||||
|
|
||||||
|
private String _AllowIp;
|
||||||
|
/// <summary>IP地址限制。每一行一条记录,可以用“-”分割</summary>
|
||||||
|
[DisplayName("IP地址限制")]
|
||||||
|
[Description("IP地址限制。每一行一条记录,可以用“-”分割")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("AllowIp", "IP地址限制。每一行一条记录,可以用“-”分割", "")]
|
||||||
|
public String AllowIp { get => _AllowIp; set { if (OnPropertyChanging("AllowIp", value)) { _AllowIp = value; OnPropertyChanged("AllowIp"); } } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
#region 获取/设置 字段值
|
||||||
@@ -282,38 +294,39 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case __.Id : return _Id;
|
case "Id": return _Id;
|
||||||
case __.KindName : return _KindName;
|
case "KindName": return _KindName;
|
||||||
case __.SubTitle : return _SubTitle;
|
case "SubTitle": return _SubTitle;
|
||||||
case __.KindTitle : return _KindTitle;
|
case "KindTitle": return _KindTitle;
|
||||||
case __.Keyword : return _Keyword;
|
case "Keyword": return _Keyword;
|
||||||
case __.Description : return _Description;
|
case "Description": return _Description;
|
||||||
case __.LinkURL : return _LinkURL;
|
case "LinkURL": return _LinkURL;
|
||||||
case __.TitleColor : return _TitleColor;
|
case "TitleColor": return _TitleColor;
|
||||||
case __.TemplateFile : return _TemplateFile;
|
case "TemplateFile": return _TemplateFile;
|
||||||
case __.DetailTemplateFile : return _DetailTemplateFile;
|
case "DetailTemplateFile": return _DetailTemplateFile;
|
||||||
case __.KindDomain : return _KindDomain;
|
case "KindDomain": return _KindDomain;
|
||||||
case __.IsList : return _IsList;
|
case "IsList": return _IsList;
|
||||||
case __.PageSize : return _PageSize;
|
case "PageSize": return _PageSize;
|
||||||
case __.PId : return _PId;
|
case "PId": return _PId;
|
||||||
case __.Level : return _Level;
|
case "Level": return _Level;
|
||||||
case __.Location : return _Location;
|
case "Location": return _Location;
|
||||||
case __.IsHide : return _IsHide;
|
case "IsHide": return _IsHide;
|
||||||
case __.IsLock : return _IsLock;
|
case "IsLock": return _IsLock;
|
||||||
case __.IsDel : return _IsDel;
|
case "IsDel": return _IsDel;
|
||||||
case __.IsComment : return _IsComment;
|
case "IsComment": return _IsComment;
|
||||||
case __.IsMember : return _IsMember;
|
case "IsMember": return _IsMember;
|
||||||
case __.IsShowSubDetail : return _IsShowSubDetail;
|
case "IsShowSubDetail": return _IsShowSubDetail;
|
||||||
case __.CatalogId : return _CatalogId;
|
case "CatalogId": return _CatalogId;
|
||||||
case __.Counts : return _Counts;
|
case "Counts": return _Counts;
|
||||||
case __.Rank : return _Rank;
|
case "Rank": return _Rank;
|
||||||
case __.Icon : return _Icon;
|
case "Icon": return _Icon;
|
||||||
case __.ClassName : return _ClassName;
|
case "ClassName": return _ClassName;
|
||||||
case __.BannerImg : return _BannerImg;
|
case "BannerImg": return _BannerImg;
|
||||||
case __.KindInfo : return _KindInfo;
|
case "KindInfo": return _KindInfo;
|
||||||
case __.Pic : return _Pic;
|
case "Pic": return _Pic;
|
||||||
case __.AdsId : return _AdsId;
|
case "AdsId": return _AdsId;
|
||||||
case __.FilePath : return _FilePath;
|
case "FilePath": return _FilePath;
|
||||||
|
case "AllowIp": return _AllowIp;
|
||||||
default: return base[name];
|
default: return base[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,38 +334,39 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case __.Id : _Id = value.ToInt(); break;
|
case "Id": _Id = value.ToInt(); break;
|
||||||
case __.KindName : _KindName = Convert.ToString(value); break;
|
case "KindName": _KindName = Convert.ToString(value); break;
|
||||||
case __.SubTitle : _SubTitle = Convert.ToString(value); break;
|
case "SubTitle": _SubTitle = Convert.ToString(value); break;
|
||||||
case __.KindTitle : _KindTitle = Convert.ToString(value); break;
|
case "KindTitle": _KindTitle = Convert.ToString(value); break;
|
||||||
case __.Keyword : _Keyword = Convert.ToString(value); break;
|
case "Keyword": _Keyword = Convert.ToString(value); break;
|
||||||
case __.Description : _Description = Convert.ToString(value); break;
|
case "Description": _Description = Convert.ToString(value); break;
|
||||||
case __.LinkURL : _LinkURL = Convert.ToString(value); break;
|
case "LinkURL": _LinkURL = Convert.ToString(value); break;
|
||||||
case __.TitleColor : _TitleColor = Convert.ToString(value); break;
|
case "TitleColor": _TitleColor = Convert.ToString(value); break;
|
||||||
case __.TemplateFile : _TemplateFile = Convert.ToString(value); break;
|
case "TemplateFile": _TemplateFile = Convert.ToString(value); break;
|
||||||
case __.DetailTemplateFile : _DetailTemplateFile = Convert.ToString(value); break;
|
case "DetailTemplateFile": _DetailTemplateFile = Convert.ToString(value); break;
|
||||||
case __.KindDomain : _KindDomain = Convert.ToString(value); break;
|
case "KindDomain": _KindDomain = Convert.ToString(value); break;
|
||||||
case __.IsList : _IsList = value.ToInt(); break;
|
case "IsList": _IsList = value.ToInt(); break;
|
||||||
case __.PageSize : _PageSize = value.ToInt(); break;
|
case "PageSize": _PageSize = value.ToInt(); break;
|
||||||
case __.PId : _PId = value.ToInt(); break;
|
case "PId": _PId = value.ToInt(); break;
|
||||||
case __.Level : _Level = value.ToInt(); break;
|
case "Level": _Level = value.ToInt(); break;
|
||||||
case __.Location : _Location = Convert.ToString(value); break;
|
case "Location": _Location = Convert.ToString(value); break;
|
||||||
case __.IsHide : _IsHide = value.ToInt(); break;
|
case "IsHide": _IsHide = value.ToInt(); break;
|
||||||
case __.IsLock : _IsLock = value.ToInt(); break;
|
case "IsLock": _IsLock = value.ToInt(); break;
|
||||||
case __.IsDel : _IsDel = value.ToInt(); break;
|
case "IsDel": _IsDel = value.ToInt(); break;
|
||||||
case __.IsComment : _IsComment = value.ToInt(); break;
|
case "IsComment": _IsComment = value.ToInt(); break;
|
||||||
case __.IsMember : _IsMember = value.ToInt(); break;
|
case "IsMember": _IsMember = value.ToInt(); break;
|
||||||
case __.IsShowSubDetail : _IsShowSubDetail = value.ToInt(); break;
|
case "IsShowSubDetail": _IsShowSubDetail = value.ToInt(); break;
|
||||||
case __.CatalogId : _CatalogId = value.ToInt(); break;
|
case "CatalogId": _CatalogId = value.ToInt(); break;
|
||||||
case __.Counts : _Counts = value.ToInt(); break;
|
case "Counts": _Counts = value.ToInt(); break;
|
||||||
case __.Rank : _Rank = value.ToInt(); break;
|
case "Rank": _Rank = value.ToInt(); break;
|
||||||
case __.Icon : _Icon = Convert.ToString(value); break;
|
case "Icon": _Icon = Convert.ToString(value); break;
|
||||||
case __.ClassName : _ClassName = Convert.ToString(value); break;
|
case "ClassName": _ClassName = Convert.ToString(value); break;
|
||||||
case __.BannerImg : _BannerImg = Convert.ToString(value); break;
|
case "BannerImg": _BannerImg = Convert.ToString(value); break;
|
||||||
case __.KindInfo : _KindInfo = Convert.ToString(value); break;
|
case "KindInfo": _KindInfo = Convert.ToString(value); break;
|
||||||
case __.Pic : _Pic = Convert.ToString(value); break;
|
case "Pic": _Pic = Convert.ToString(value); break;
|
||||||
case __.AdsId : _AdsId = value.ToInt(); break;
|
case "AdsId": _AdsId = value.ToInt(); break;
|
||||||
case __.FilePath : _FilePath = Convert.ToString(value); break;
|
case "FilePath": _FilePath = Convert.ToString(value); break;
|
||||||
|
case "AllowIp": _AllowIp = Convert.ToString(value); break;
|
||||||
default: base[name] = value; break;
|
default: base[name] = value; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,102 +378,105 @@ namespace COMCMS.Core
|
|||||||
public partial class _
|
public partial class _
|
||||||
{
|
{
|
||||||
/// <summary>编号</summary>
|
/// <summary>编号</summary>
|
||||||
public static readonly Field Id = FindByName(__.Id);
|
public static readonly Field Id = FindByName("Id");
|
||||||
|
|
||||||
/// <summary>栏目名称</summary>
|
/// <summary>栏目名称</summary>
|
||||||
public static readonly Field KindName = FindByName(__.KindName);
|
public static readonly Field KindName = FindByName("KindName");
|
||||||
|
|
||||||
/// <summary>栏目副标题</summary>
|
/// <summary>栏目副标题</summary>
|
||||||
public static readonly Field SubTitle = FindByName(__.SubTitle);
|
public static readonly Field SubTitle = FindByName("SubTitle");
|
||||||
|
|
||||||
/// <summary>栏目标题,填写则在浏览器替换此标题</summary>
|
/// <summary>栏目标题,填写则在浏览器替换此标题</summary>
|
||||||
public static readonly Field KindTitle = FindByName(__.KindTitle);
|
public static readonly Field KindTitle = FindByName("KindTitle");
|
||||||
|
|
||||||
/// <summary>描述</summary>
|
/// <summary>描述</summary>
|
||||||
public static readonly Field Keyword = FindByName(__.Keyword);
|
public static readonly Field Keyword = FindByName("Keyword");
|
||||||
|
|
||||||
/// <summary>介绍</summary>
|
/// <summary>介绍</summary>
|
||||||
public static readonly Field Description = FindByName(__.Description);
|
public static readonly Field Description = FindByName("Description");
|
||||||
|
|
||||||
/// <summary>跳转链接</summary>
|
/// <summary>跳转链接</summary>
|
||||||
public static readonly Field LinkURL = FindByName(__.LinkURL);
|
public static readonly Field LinkURL = FindByName("LinkURL");
|
||||||
|
|
||||||
/// <summary>类别名称颜色</summary>
|
/// <summary>类别名称颜色</summary>
|
||||||
public static readonly Field TitleColor = FindByName(__.TitleColor);
|
public static readonly Field TitleColor = FindByName("TitleColor");
|
||||||
|
|
||||||
/// <summary>模板</summary>
|
/// <summary>模板</summary>
|
||||||
public static readonly Field TemplateFile = FindByName(__.TemplateFile);
|
public static readonly Field TemplateFile = FindByName("TemplateFile");
|
||||||
|
|
||||||
/// <summary>详情模板</summary>
|
/// <summary>详情模板</summary>
|
||||||
public static readonly Field DetailTemplateFile = FindByName(__.DetailTemplateFile);
|
public static readonly Field DetailTemplateFile = FindByName("DetailTemplateFile");
|
||||||
|
|
||||||
/// <summary>类别域名(保留)</summary>
|
/// <summary>类别域名(保留)</summary>
|
||||||
public static readonly Field KindDomain = FindByName(__.KindDomain);
|
public static readonly Field KindDomain = FindByName("KindDomain");
|
||||||
|
|
||||||
/// <summary>是否为列表页面</summary>
|
/// <summary>是否为列表页面</summary>
|
||||||
public static readonly Field IsList = FindByName(__.IsList);
|
public static readonly Field IsList = FindByName("IsList");
|
||||||
|
|
||||||
/// <summary>每页显示数量</summary>
|
/// <summary>每页显示数量</summary>
|
||||||
public static readonly Field PageSize = FindByName(__.PageSize);
|
public static readonly Field PageSize = FindByName("PageSize");
|
||||||
|
|
||||||
/// <summary>上级ID</summary>
|
/// <summary>上级ID</summary>
|
||||||
public static readonly Field PId = FindByName(__.PId);
|
public static readonly Field PId = FindByName("PId");
|
||||||
|
|
||||||
/// <summary>级别</summary>
|
/// <summary>级别</summary>
|
||||||
public static readonly Field Level = FindByName(__.Level);
|
public static readonly Field Level = FindByName("Level");
|
||||||
|
|
||||||
/// <summary>路径</summary>
|
/// <summary>路径</summary>
|
||||||
public static readonly Field Location = FindByName(__.Location);
|
public static readonly Field Location = FindByName("Location");
|
||||||
|
|
||||||
/// <summary>是否隐藏</summary>
|
/// <summary>是否隐藏</summary>
|
||||||
public static readonly Field IsHide = FindByName(__.IsHide);
|
public static readonly Field IsHide = FindByName("IsHide");
|
||||||
|
|
||||||
/// <summary>是否锁定,不允许删除</summary>
|
/// <summary>是否锁定,不允许删除</summary>
|
||||||
public static readonly Field IsLock = FindByName(__.IsLock);
|
public static readonly Field IsLock = FindByName("IsLock");
|
||||||
|
|
||||||
/// <summary>是否删除,已经删除到回收站</summary>
|
/// <summary>是否删除,已经删除到回收站</summary>
|
||||||
public static readonly Field IsDel = FindByName(__.IsDel);
|
public static readonly Field IsDel = FindByName("IsDel");
|
||||||
|
|
||||||
/// <summary>是否允许评论</summary>
|
/// <summary>是否允许评论</summary>
|
||||||
public static readonly Field IsComment = FindByName(__.IsComment);
|
public static readonly Field IsComment = FindByName("IsComment");
|
||||||
|
|
||||||
/// <summary>是否会员栏目</summary>
|
/// <summary>是否会员栏目</summary>
|
||||||
public static readonly Field IsMember = FindByName(__.IsMember);
|
public static readonly Field IsMember = FindByName("IsMember");
|
||||||
|
|
||||||
/// <summary>是否显示下级栏目内容</summary>
|
/// <summary>是否显示下级栏目内容</summary>
|
||||||
public static readonly Field IsShowSubDetail = FindByName(__.IsShowSubDetail);
|
public static readonly Field IsShowSubDetail = FindByName("IsShowSubDetail");
|
||||||
|
|
||||||
/// <summary>模型ID</summary>
|
/// <summary>模型ID</summary>
|
||||||
public static readonly Field CatalogId = FindByName(__.CatalogId);
|
public static readonly Field CatalogId = FindByName("CatalogId");
|
||||||
|
|
||||||
/// <summary>详情数量,缓存</summary>
|
/// <summary>详情数量,缓存</summary>
|
||||||
public static readonly Field Counts = FindByName(__.Counts);
|
public static readonly Field Counts = FindByName("Counts");
|
||||||
|
|
||||||
/// <summary>排序</summary>
|
/// <summary>排序</summary>
|
||||||
public static readonly Field Rank = FindByName(__.Rank);
|
public static readonly Field Rank = FindByName("Rank");
|
||||||
|
|
||||||
/// <summary>图标</summary>
|
/// <summary>图标</summary>
|
||||||
public static readonly Field Icon = FindByName(__.Icon);
|
public static readonly Field Icon = FindByName("Icon");
|
||||||
|
|
||||||
/// <summary>样式名称</summary>
|
/// <summary>样式名称</summary>
|
||||||
public static readonly Field ClassName = FindByName(__.ClassName);
|
public static readonly Field ClassName = FindByName("ClassName");
|
||||||
|
|
||||||
/// <summary>banner图片</summary>
|
/// <summary>banner图片</summary>
|
||||||
public static readonly Field BannerImg = FindByName(__.BannerImg);
|
public static readonly Field BannerImg = FindByName("BannerImg");
|
||||||
|
|
||||||
/// <summary>栏目详细介绍</summary>
|
/// <summary>栏目详细介绍</summary>
|
||||||
public static readonly Field KindInfo = FindByName(__.KindInfo);
|
public static readonly Field KindInfo = FindByName("KindInfo");
|
||||||
|
|
||||||
/// <summary>图片</summary>
|
/// <summary>图片</summary>
|
||||||
public static readonly Field Pic = FindByName(__.Pic);
|
public static readonly Field Pic = FindByName("Pic");
|
||||||
|
|
||||||
/// <summary>广告ID</summary>
|
/// <summary>广告ID</summary>
|
||||||
public static readonly Field AdsId = FindByName(__.AdsId);
|
public static readonly Field AdsId = FindByName("AdsId");
|
||||||
|
|
||||||
/// <summary>目录路径</summary>
|
/// <summary>目录路径</summary>
|
||||||
public static readonly Field FilePath = FindByName(__.FilePath);
|
public static readonly Field FilePath = FindByName("FilePath");
|
||||||
|
|
||||||
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
/// <summary>IP地址限制。每一行一条记录,可以用“-”分割</summary>
|
||||||
|
public static readonly Field AllowIp = FindByName("AllowIp");
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>取得文章栏目字段名称的快捷方式</summary>
|
/// <summary>取得文章栏目字段名称的快捷方式</summary>
|
||||||
@@ -560,116 +577,10 @@ namespace COMCMS.Core
|
|||||||
|
|
||||||
/// <summary>目录路径</summary>
|
/// <summary>目录路径</summary>
|
||||||
public const String FilePath = "FilePath";
|
public const String FilePath = "FilePath";
|
||||||
|
|
||||||
|
/// <summary>IP地址限制。每一行一条记录,可以用“-”分割</summary>
|
||||||
|
public const String AllowIp = "AllowIp";
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>文章栏目接口</summary>
|
|
||||||
public partial interface IArticleCategory
|
|
||||||
{
|
|
||||||
#region 属性
|
|
||||||
/// <summary>编号</summary>
|
|
||||||
Int32 Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>栏目名称</summary>
|
|
||||||
String KindName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>栏目副标题</summary>
|
|
||||||
String SubTitle { get; set; }
|
|
||||||
|
|
||||||
/// <summary>栏目标题,填写则在浏览器替换此标题</summary>
|
|
||||||
String KindTitle { get; set; }
|
|
||||||
|
|
||||||
/// <summary>描述</summary>
|
|
||||||
String Keyword { get; set; }
|
|
||||||
|
|
||||||
/// <summary>介绍</summary>
|
|
||||||
String Description { get; set; }
|
|
||||||
|
|
||||||
/// <summary>跳转链接</summary>
|
|
||||||
String LinkURL { get; set; }
|
|
||||||
|
|
||||||
/// <summary>类别名称颜色</summary>
|
|
||||||
String TitleColor { get; set; }
|
|
||||||
|
|
||||||
/// <summary>模板</summary>
|
|
||||||
String TemplateFile { get; set; }
|
|
||||||
|
|
||||||
/// <summary>详情模板</summary>
|
|
||||||
String DetailTemplateFile { get; set; }
|
|
||||||
|
|
||||||
/// <summary>类别域名(保留)</summary>
|
|
||||||
String KindDomain { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否为列表页面</summary>
|
|
||||||
Int32 IsList { get; set; }
|
|
||||||
|
|
||||||
/// <summary>每页显示数量</summary>
|
|
||||||
Int32 PageSize { get; set; }
|
|
||||||
|
|
||||||
/// <summary>上级ID</summary>
|
|
||||||
Int32 PId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>级别</summary>
|
|
||||||
Int32 Level { get; set; }
|
|
||||||
|
|
||||||
/// <summary>路径</summary>
|
|
||||||
String Location { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否隐藏</summary>
|
|
||||||
Int32 IsHide { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否锁定,不允许删除</summary>
|
|
||||||
Int32 IsLock { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否删除,已经删除到回收站</summary>
|
|
||||||
Int32 IsDel { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否允许评论</summary>
|
|
||||||
Int32 IsComment { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否会员栏目</summary>
|
|
||||||
Int32 IsMember { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否显示下级栏目内容</summary>
|
|
||||||
Int32 IsShowSubDetail { get; set; }
|
|
||||||
|
|
||||||
/// <summary>模型ID</summary>
|
|
||||||
Int32 CatalogId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>详情数量,缓存</summary>
|
|
||||||
Int32 Counts { get; set; }
|
|
||||||
|
|
||||||
/// <summary>排序</summary>
|
|
||||||
Int32 Rank { get; set; }
|
|
||||||
|
|
||||||
/// <summary>图标</summary>
|
|
||||||
String Icon { get; set; }
|
|
||||||
|
|
||||||
/// <summary>样式名称</summary>
|
|
||||||
String ClassName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>banner图片</summary>
|
|
||||||
String BannerImg { get; set; }
|
|
||||||
|
|
||||||
/// <summary>栏目详细介绍</summary>
|
|
||||||
String KindInfo { get; set; }
|
|
||||||
|
|
||||||
/// <summary>图片</summary>
|
|
||||||
String Pic { get; set; }
|
|
||||||
|
|
||||||
/// <summary>广告ID</summary>
|
|
||||||
Int32 AdsId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>目录路径</summary>
|
|
||||||
String FilePath { get; set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
|
||||||
/// <summary>获取/设置 字段值</summary>
|
|
||||||
/// <param name="name">字段名</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Object this[String name] { get; set; }
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="NewLife.XCode" Version="9.14.2019.822" />
|
<PackageReference Include="NewLife.XCode" Version="11.27.2026.601" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\COMCMS.Common\COMCMS.Common.csproj" />
|
<ProjectReference Include="..\COMCMS.Common\COMCMS.Common.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.AspNetCore.Authentication.Cookies">
|
|
||||||
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.authentication.cookies\2.1.1\lib\netstandard2.0\Microsoft.AspNetCore.Authentication.Cookies.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,327 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
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;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>Tag标签</summary>
|
||||||
|
public partial class Tags : Entity<Tags>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static Tags()
|
||||||
|
{
|
||||||
|
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||||
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
|
//df.Add(nameof(Counts));
|
||||||
|
|
||||||
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
|
/// <param name="isNew">是否插入</param>
|
||||||
|
public override void Valid(Boolean isNew)
|
||||||
|
{
|
||||||
|
// 如果没有脏数据,则不需要进行任何处理
|
||||||
|
if (!HasDirty) return;
|
||||||
|
|
||||||
|
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||||
|
base.Valid(isNew);
|
||||||
|
|
||||||
|
// 在新插入数据或者修改了指定字段时进行修正
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||||
|
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
//protected override void InitData()
|
||||||
|
//{
|
||||||
|
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||||
|
// if (Meta.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Tags[Tag标签]数据……");
|
||||||
|
|
||||||
|
// var entity = new Tags();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.TagName = "abc";
|
||||||
|
// entity.Keywords = "abc";
|
||||||
|
// entity.Description = "abc";
|
||||||
|
// entity.Counts = 0;
|
||||||
|
// entity.Hits = 0;
|
||||||
|
// entity.IsTop = 0;
|
||||||
|
// entity.AddTime = DateTime.Now;
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Tags[Tag标签]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 Tags FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>根据Tag标签名称查找</summary>
|
||||||
|
/// <param name="tagName">Tag标签名称</param>
|
||||||
|
/// <returns>实体列表</returns>
|
||||||
|
public static IList<Tags> FindAllByTagName(String tagName)
|
||||||
|
{
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TagName == tagName);
|
||||||
|
|
||||||
|
return FindAll(_.TagName == tagName);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
/// <summary>高级查询</summary>
|
||||||
|
/// <param name="tagName">Tag标签名称</param>
|
||||||
|
/// <param name="key">关键字</param>
|
||||||
|
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||||
|
/// <returns>实体列表</returns>
|
||||||
|
public static IList<Tags> Search(String tagName, String key, PageParameter page)
|
||||||
|
{
|
||||||
|
var exp = new WhereExpression();
|
||||||
|
|
||||||
|
if (!tagName.IsNullOrEmpty()) exp &= _.TagName == tagName;
|
||||||
|
if (!key.IsNullOrEmpty()) exp &= _.Keywords.Contains(key) | _.Description.Contains(key);
|
||||||
|
|
||||||
|
return FindAll(exp, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select Count(Id) as Id,TagName From Tags Where CreateTime>'2020-01-24 00:00:00' Group By TagName Order By Id Desc limit 20
|
||||||
|
static readonly FieldCache<Tags> _TagNameCache = new FieldCache<Tags>(nameof(TagName))
|
||||||
|
{
|
||||||
|
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>获取Tag标签名称列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IDictionary<String, String> GetTagNameList() => _TagNameCache.FindAllName();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
/// <summary>
|
||||||
|
/// 添加新的TAG标签
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="listtag">标签,原始,用“,”隔开的字符串</param>
|
||||||
|
/// <param name="xtypeid">类型</param>
|
||||||
|
/// <param name="rid">目标ID,文章ID,商品ID等...</param>
|
||||||
|
/// <param name="tagtitle">目标标题,文章标题,商品标题等(缓存用的)</param>
|
||||||
|
public static void InsertTags(string listtag, Utils.CMSType xtypeid, int rid, string tagtitle)
|
||||||
|
{
|
||||||
|
//流程:分割TAG,遍历标签;判断是否存在;插入。
|
||||||
|
//1、分割标签
|
||||||
|
if (!string.IsNullOrEmpty(listtag))
|
||||||
|
{
|
||||||
|
string[] arrtags = listtag.Split(new string[] { "," }, StringSplitOptions.None);
|
||||||
|
if (arrtags != null && arrtags.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (string s in arrtags)
|
||||||
|
{
|
||||||
|
//2、单个标签处理
|
||||||
|
if (!string.IsNullOrEmpty(s) && Utils.GetStringLength(s.Trim()) < 100)
|
||||||
|
{
|
||||||
|
TagsDetail tagsDetail = new TagsDetail();
|
||||||
|
Tags tmptag = new Tags();
|
||||||
|
|
||||||
|
//判断是否存在这个标签
|
||||||
|
if (FindCount(_.TagName == s.Trim(), null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tmptag = Find(_.TagName == s.Trim()); //GetModel(s.Trim());
|
||||||
|
tmptag.Counts = tmptag.Counts + 1;
|
||||||
|
tmptag.Update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmptag = new Tags()
|
||||||
|
{
|
||||||
|
AddTime = DateTime.Now,
|
||||||
|
Counts = 1,
|
||||||
|
Description = "",
|
||||||
|
Hits = 0,
|
||||||
|
IsTop = 0,
|
||||||
|
Keywords = "",
|
||||||
|
TagName = s.Trim(),
|
||||||
|
};
|
||||||
|
tmptag.Insert();
|
||||||
|
}
|
||||||
|
tagsDetail.RId = rid;
|
||||||
|
tagsDetail.TypeId = xtypeid.ToInt();
|
||||||
|
tagsDetail.TagName = s.Trim();
|
||||||
|
tagsDetail.TagsId = tmptag.Id;
|
||||||
|
tagsDetail.Title = tagtitle;
|
||||||
|
tagsDetail.Hits = 0;
|
||||||
|
tagsDetail.AddTime = DateTime.Now;
|
||||||
|
tagsDetail.Insert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 编辑标签
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑Tag标签
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="listtag">标签,原始,用“,”隔开的字符串</param>
|
||||||
|
/// <param name="xtypeid">类型</param>
|
||||||
|
/// <param name="rid">目标ID,文章ID,商品ID等...</param>
|
||||||
|
/// <param name="tagtitle">目标标题,文章标题,商品标题等(缓存用的)</param>
|
||||||
|
public static void ModifyTags(string listtag, Utils.CMSType xtypeid, int rid, string tagtitle)
|
||||||
|
{
|
||||||
|
IList<TagsDetail> listdetail = TagsDetail.FindAll(TagsDetail._.RId == rid & TagsDetail._.TypeId == (int)xtypeid, null, null, 0, 0);
|
||||||
|
if (!string.IsNullOrEmpty(listtag))
|
||||||
|
{
|
||||||
|
string[] arrtags = listtag.Split(new string[] { "," }, StringSplitOptions.None);
|
||||||
|
if (arrtags != null && arrtags.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (string s in arrtags)
|
||||||
|
{
|
||||||
|
//2、单个标签处理 只有 添加或者 删除。没有修改的
|
||||||
|
if (!string.IsNullOrEmpty(s) && Utils.GetStringLength(s.Trim()) < 100)
|
||||||
|
{
|
||||||
|
//判断是否存在
|
||||||
|
var td = listdetail.Find(x => x.TagName == s.Trim());
|
||||||
|
if(td == null)
|
||||||
|
{
|
||||||
|
TagsDetail tagsDetail = new TagsDetail();
|
||||||
|
Tags tmptag = new Tags();
|
||||||
|
|
||||||
|
//判断是否存在这个标签
|
||||||
|
if (FindCount(_.TagName == s.Trim(), null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tmptag = Find(_.TagName == s.Trim()); //GetModel(s.Trim());
|
||||||
|
tmptag.Counts = tmptag.Counts + 1;
|
||||||
|
tmptag.Update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmptag = new Tags()
|
||||||
|
{
|
||||||
|
AddTime = DateTime.Now,
|
||||||
|
Counts = 1,
|
||||||
|
Description = "",
|
||||||
|
Hits = 0,
|
||||||
|
IsTop = 0,
|
||||||
|
Keywords = "",
|
||||||
|
TagName = s.Trim(),
|
||||||
|
};
|
||||||
|
tmptag.Insert();
|
||||||
|
}
|
||||||
|
tagsDetail.RId = rid;
|
||||||
|
tagsDetail.TypeId = xtypeid.ToInt();
|
||||||
|
tagsDetail.TagName = s.Trim();
|
||||||
|
tagsDetail.TagsId = tmptag.Id;
|
||||||
|
tagsDetail.Title = tagtitle;
|
||||||
|
tagsDetail.Hits = 0;
|
||||||
|
tagsDetail.AddTime = DateTime.Now;
|
||||||
|
tagsDetail.Insert();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listdetail.Remove(td);
|
||||||
|
|
||||||
|
var tmptag = Find(_.TagName == s.Trim());
|
||||||
|
if(tmptag != null)
|
||||||
|
{
|
||||||
|
long counts = TagsDetail.FindCount(TagsDetail._.TagName == s.Trim(), null, null, 0, 0);
|
||||||
|
if (counts == 0)
|
||||||
|
tmptag.Delete();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmptag.Counts = (int)counts;
|
||||||
|
tmptag.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 删除标签
|
||||||
|
/// <summary>
|
||||||
|
/// 删除标签
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="listtag">标签集合</param>
|
||||||
|
public static void DeleteTag(string listtag, Utils.CMSType xtypeid, int rid)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(listtag))
|
||||||
|
{
|
||||||
|
|
||||||
|
string[] arrtags = listtag.Split(new string[] { "," }, StringSplitOptions.None);
|
||||||
|
if (arrtags != null && arrtags.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var s in arrtags)
|
||||||
|
{
|
||||||
|
var tmp = TagsDetail.Find(TagsDetail._.TypeId == xtypeid.ToInt() & TagsDetail._.TagName == s.Trim() & TagsDetail._.RId == rid);
|
||||||
|
if (tmp != null)
|
||||||
|
{
|
||||||
|
tmp.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>Tag标签</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("Tag标签")]
|
||||||
|
[BindIndex("IX_Tags_TagName", false, "TagName")]
|
||||||
|
[BindTable("Tags", Description = "Tag标签", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class Tags
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||||
|
|
||||||
|
private String _TagName;
|
||||||
|
/// <summary>Tag标签名称</summary>
|
||||||
|
[DisplayName("Tag标签名称")]
|
||||||
|
[Description("Tag标签名称")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("TagName", "Tag标签名称", "")]
|
||||||
|
public String TagName { get => _TagName; set { if (OnPropertyChanging("TagName", value)) { _TagName = value; OnPropertyChanged("TagName"); } } }
|
||||||
|
|
||||||
|
private String _Keywords;
|
||||||
|
/// <summary>标签关键词</summary>
|
||||||
|
[DisplayName("标签关键词")]
|
||||||
|
[Description("标签关键词")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("Keywords", "标签关键词", "")]
|
||||||
|
public String Keywords { get => _Keywords; set { if (OnPropertyChanging("Keywords", value)) { _Keywords = value; OnPropertyChanged("Keywords"); } } }
|
||||||
|
|
||||||
|
private String _Description;
|
||||||
|
/// <summary>标签描述</summary>
|
||||||
|
[DisplayName("标签描述")]
|
||||||
|
[Description("标签描述")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("Description", "标签描述", "")]
|
||||||
|
public String Description { get => _Description; set { if (OnPropertyChanging("Description", value)) { _Description = value; OnPropertyChanged("Description"); } } }
|
||||||
|
|
||||||
|
private Int32 _Counts;
|
||||||
|
/// <summary>数量</summary>
|
||||||
|
[DisplayName("数量")]
|
||||||
|
[Description("数量")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Counts", "数量", "")]
|
||||||
|
public Int32 Counts { get => _Counts; set { if (OnPropertyChanging("Counts", value)) { _Counts = value; OnPropertyChanged("Counts"); } } }
|
||||||
|
|
||||||
|
private Int32 _Hits;
|
||||||
|
/// <summary>点击量</summary>
|
||||||
|
[DisplayName("点击量")]
|
||||||
|
[Description("点击量")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Hits", "点击量", "")]
|
||||||
|
public Int32 Hits { get => _Hits; set { if (OnPropertyChanging("Hits", value)) { _Hits = value; OnPropertyChanged("Hits"); } } }
|
||||||
|
|
||||||
|
private Int32 _IsTop;
|
||||||
|
/// <summary>置顶否</summary>
|
||||||
|
[DisplayName("置顶否")]
|
||||||
|
[Description("置顶否")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("IsTop", "置顶否", "")]
|
||||||
|
public Int32 IsTop { get => _IsTop; set { if (OnPropertyChanging("IsTop", value)) { _IsTop = value; OnPropertyChanged("IsTop"); } } }
|
||||||
|
|
||||||
|
private DateTime _AddTime;
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
[DisplayName("添加时间")]
|
||||||
|
[Description("添加时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
|
public DateTime AddTime { get => _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 "TagName": return _TagName;
|
||||||
|
case "Keywords": return _Keywords;
|
||||||
|
case "Description": return _Description;
|
||||||
|
case "Counts": return _Counts;
|
||||||
|
case "Hits": return _Hits;
|
||||||
|
case "IsTop": return _IsTop;
|
||||||
|
case "AddTime": return _AddTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "Id": _Id = value.ToInt(); break;
|
||||||
|
case "TagName": _TagName = Convert.ToString(value); break;
|
||||||
|
case "Keywords": _Keywords = Convert.ToString(value); break;
|
||||||
|
case "Description": _Description = Convert.ToString(value); break;
|
||||||
|
case "Counts": _Counts = value.ToInt(); break;
|
||||||
|
case "Hits": _Hits = value.ToInt(); break;
|
||||||
|
case "IsTop": _IsTop = value.ToInt(); break;
|
||||||
|
case "AddTime": _AddTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得Tag标签字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName("Id");
|
||||||
|
|
||||||
|
/// <summary>Tag标签名称</summary>
|
||||||
|
public static readonly Field TagName = FindByName("TagName");
|
||||||
|
|
||||||
|
/// <summary>标签关键词</summary>
|
||||||
|
public static readonly Field Keywords = FindByName("Keywords");
|
||||||
|
|
||||||
|
/// <summary>标签描述</summary>
|
||||||
|
public static readonly Field Description = FindByName("Description");
|
||||||
|
|
||||||
|
/// <summary>数量</summary>
|
||||||
|
public static readonly Field Counts = FindByName("Counts");
|
||||||
|
|
||||||
|
/// <summary>点击量</summary>
|
||||||
|
public static readonly Field Hits = FindByName("Hits");
|
||||||
|
|
||||||
|
/// <summary>置顶否</summary>
|
||||||
|
public static readonly Field IsTop = FindByName("IsTop");
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public static readonly Field AddTime = FindByName("AddTime");
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得Tag标签字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>Tag标签名称</summary>
|
||||||
|
public const String TagName = "TagName";
|
||||||
|
|
||||||
|
/// <summary>标签关键词</summary>
|
||||||
|
public const String Keywords = "Keywords";
|
||||||
|
|
||||||
|
/// <summary>标签描述</summary>
|
||||||
|
public const String Description = "Description";
|
||||||
|
|
||||||
|
/// <summary>数量</summary>
|
||||||
|
public const String Counts = "Counts";
|
||||||
|
|
||||||
|
/// <summary>点击量</summary>
|
||||||
|
public const String Hits = "Hits";
|
||||||
|
|
||||||
|
/// <summary>置顶否</summary>
|
||||||
|
public const String IsTop = "IsTop";
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public const String AddTime = "AddTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
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>Tag标签详情</summary>
|
||||||
|
public partial class TagsDetail : Entity<TagsDetail>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static TagsDetail()
|
||||||
|
{
|
||||||
|
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||||
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
|
//df.Add(nameof(TagsId));
|
||||||
|
|
||||||
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>验证并修补数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
|
/// <param name="isNew">是否插入</param>
|
||||||
|
public override void Valid(Boolean isNew)
|
||||||
|
{
|
||||||
|
// 如果没有脏数据,则不需要进行任何处理
|
||||||
|
if (!HasDirty) return;
|
||||||
|
|
||||||
|
// 建议先调用基类方法,基类方法会做一些统一处理
|
||||||
|
base.Valid(isNew);
|
||||||
|
|
||||||
|
// 在新插入数据或者修改了指定字段时进行修正
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||||
|
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
//protected override void InitData()
|
||||||
|
//{
|
||||||
|
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||||
|
// if (Meta.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化TagsDetail[Tag标签详情]数据……");
|
||||||
|
|
||||||
|
// var entity = new TagsDetail();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.TagsId = 0;
|
||||||
|
// entity.TagName = "abc";
|
||||||
|
// entity.TypeId = 0;
|
||||||
|
// entity.Title = "abc";
|
||||||
|
// entity.Hits = 0;
|
||||||
|
// entity.RId = 0;
|
||||||
|
// entity.AddTime = DateTime.Now;
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化TagsDetail[Tag标签详情]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 TagsDetail FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>根据类型查找</summary>
|
||||||
|
/// <param name="typeId">类型</param>
|
||||||
|
/// <returns>实体列表</returns>
|
||||||
|
public static IList<TagsDetail> FindAllByTypeId(Int32 typeId)
|
||||||
|
{
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.FindAll(e => e.TypeId == typeId);
|
||||||
|
|
||||||
|
return FindAll(_.TypeId == typeId);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
/// <summary>高级查询</summary>
|
||||||
|
/// <param name="typeId">类型</param>
|
||||||
|
/// <param name="key">关键字</param>
|
||||||
|
/// <param name="page">分页参数信息。可携带统计和数据权限扩展查询等信息</param>
|
||||||
|
/// <returns>实体列表</returns>
|
||||||
|
public static IList<TagsDetail> Search(Int32 typeId, String key, PageParameter page)
|
||||||
|
{
|
||||||
|
var exp = new WhereExpression();
|
||||||
|
|
||||||
|
if (typeId >= 0) exp &= _.TypeId == typeId;
|
||||||
|
if (!key.IsNullOrEmpty()) exp &= _.TagName.Contains(key) | _.Title.Contains(key);
|
||||||
|
|
||||||
|
return FindAll(exp, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select Count(Id) as Id,Category From TagsDetail Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||||
|
//static readonly FieldCache<TagsDetail> _CategoryCache = new FieldCache<TagsDetail>(nameof(Category))
|
||||||
|
//{
|
||||||
|
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||||
|
//};
|
||||||
|
|
||||||
|
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>Tag标签详情</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("Tag标签详情")]
|
||||||
|
[BindIndex("IX_TagsDetail_TypeId", false, "TypeId")]
|
||||||
|
[BindTable("TagsDetail", Description = "Tag标签详情", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class TagsDetail
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||||
|
|
||||||
|
private Int32 _TagsId;
|
||||||
|
/// <summary>所属标签ID</summary>
|
||||||
|
[DisplayName("所属标签ID")]
|
||||||
|
[Description("所属标签ID")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("TagsId", "所属标签ID", "")]
|
||||||
|
public Int32 TagsId { get => _TagsId; set { if (OnPropertyChanging("TagsId", value)) { _TagsId = value; OnPropertyChanged("TagsId"); } } }
|
||||||
|
|
||||||
|
private String _TagName;
|
||||||
|
/// <summary>Tag标签名称</summary>
|
||||||
|
[DisplayName("Tag标签名称")]
|
||||||
|
[Description("Tag标签名称")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("TagName", "Tag标签名称", "")]
|
||||||
|
public String TagName { get => _TagName; set { if (OnPropertyChanging("TagName", value)) { _TagName = value; OnPropertyChanged("TagName"); } } }
|
||||||
|
|
||||||
|
private Int32 _TypeId;
|
||||||
|
/// <summary>类型</summary>
|
||||||
|
[DisplayName("类型")]
|
||||||
|
[Description("类型")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("TypeId", "类型", "")]
|
||||||
|
public Int32 TypeId { get => _TypeId; set { if (OnPropertyChanging("TypeId", value)) { _TypeId = value; OnPropertyChanged("TypeId"); } } }
|
||||||
|
|
||||||
|
private String _Title;
|
||||||
|
/// <summary>标题</summary>
|
||||||
|
[DisplayName("标题")]
|
||||||
|
[Description("标题")]
|
||||||
|
[DataObjectField(false, false, true, 255)]
|
||||||
|
[BindColumn("Title", "标题", "", Master = true)]
|
||||||
|
public String Title { get => _Title; set { if (OnPropertyChanging("Title", value)) { _Title = value; OnPropertyChanged("Title"); } } }
|
||||||
|
|
||||||
|
private Int32 _Hits;
|
||||||
|
/// <summary>点击量</summary>
|
||||||
|
[DisplayName("点击量")]
|
||||||
|
[Description("点击量")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Hits", "点击量", "")]
|
||||||
|
public Int32 Hits { get => _Hits; set { if (OnPropertyChanging("Hits", value)) { _Hits = value; OnPropertyChanged("Hits"); } } }
|
||||||
|
|
||||||
|
private Int32 _RId;
|
||||||
|
/// <summary>目标Id</summary>
|
||||||
|
[DisplayName("目标Id")]
|
||||||
|
[Description("目标Id")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("RId", "目标Id", "")]
|
||||||
|
public Int32 RId { get => _RId; set { if (OnPropertyChanging("RId", value)) { _RId = value; OnPropertyChanged("RId"); } } }
|
||||||
|
|
||||||
|
private DateTime _AddTime;
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
[DisplayName("添加时间")]
|
||||||
|
[Description("添加时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
|
public DateTime AddTime { get => _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 "TagsId": return _TagsId;
|
||||||
|
case "TagName": return _TagName;
|
||||||
|
case "TypeId": return _TypeId;
|
||||||
|
case "Title": return _Title;
|
||||||
|
case "Hits": return _Hits;
|
||||||
|
case "RId": return _RId;
|
||||||
|
case "AddTime": return _AddTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "Id": _Id = value.ToInt(); break;
|
||||||
|
case "TagsId": _TagsId = value.ToInt(); break;
|
||||||
|
case "TagName": _TagName = Convert.ToString(value); break;
|
||||||
|
case "TypeId": _TypeId = value.ToInt(); break;
|
||||||
|
case "Title": _Title = Convert.ToString(value); break;
|
||||||
|
case "Hits": _Hits = value.ToInt(); break;
|
||||||
|
case "RId": _RId = value.ToInt(); break;
|
||||||
|
case "AddTime": _AddTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得Tag标签详情字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName("Id");
|
||||||
|
|
||||||
|
/// <summary>所属标签ID</summary>
|
||||||
|
public static readonly Field TagsId = FindByName("TagsId");
|
||||||
|
|
||||||
|
/// <summary>Tag标签名称</summary>
|
||||||
|
public static readonly Field TagName = FindByName("TagName");
|
||||||
|
|
||||||
|
/// <summary>类型</summary>
|
||||||
|
public static readonly Field TypeId = FindByName("TypeId");
|
||||||
|
|
||||||
|
/// <summary>标题</summary>
|
||||||
|
public static readonly Field Title = FindByName("Title");
|
||||||
|
|
||||||
|
/// <summary>点击量</summary>
|
||||||
|
public static readonly Field Hits = FindByName("Hits");
|
||||||
|
|
||||||
|
/// <summary>目标Id</summary>
|
||||||
|
public static readonly Field RId = FindByName("RId");
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public static readonly Field AddTime = FindByName("AddTime");
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得Tag标签详情字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>所属标签ID</summary>
|
||||||
|
public const String TagsId = "TagsId";
|
||||||
|
|
||||||
|
/// <summary>Tag标签名称</summary>
|
||||||
|
public const String TagName = "TagName";
|
||||||
|
|
||||||
|
/// <summary>类型</summary>
|
||||||
|
public const String TypeId = "TypeId";
|
||||||
|
|
||||||
|
/// <summary>标题</summary>
|
||||||
|
public const String Title = "Title";
|
||||||
|
|
||||||
|
/// <summary>点击量</summary>
|
||||||
|
public const String Hits = "Hits";
|
||||||
|
|
||||||
|
/// <summary>目标Id</summary>
|
||||||
|
public const String RId = "RId";
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public const String AddTime = "AddTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using XCode;
|
||||||
|
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 识图方法
|
||||||
|
/// </summary>
|
||||||
|
public class ViewsHelper
|
||||||
|
{
|
||||||
|
#region 获取分类链接
|
||||||
|
/// <summary>
|
||||||
|
/// 文章分类
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EchoURL(ArticleCategory model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return "javascript:;";
|
||||||
|
if (!string.IsNullOrEmpty(model.FilePath))
|
||||||
|
return model.FilePath + "/index.html";
|
||||||
|
else
|
||||||
|
return $"/article/index/{model.Id}";
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 商品分类
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EchoURL(Category model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return "javascript:;";
|
||||||
|
if (!string.IsNullOrEmpty(model.FilePath))
|
||||||
|
return model.FilePath + "/index.html";
|
||||||
|
else
|
||||||
|
return $"/product/index/{model.Id}";
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 生成文章详情地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EchoURL(Article model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return "javascript:;";
|
||||||
|
|
||||||
|
ArticleCategory categoty = ArticleCategory.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 $"/article/detail/{model.Id}";
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 商品
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <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}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ctype"></param>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EchoURL(Utils.CMSType ctype, int id)
|
||||||
|
{
|
||||||
|
string url = "/";
|
||||||
|
switch (ctype)
|
||||||
|
{
|
||||||
|
case Utils.CMSType.ArticleCategory:
|
||||||
|
ArticleCategory ac = ArticleCategory.FindById(id);
|
||||||
|
url = EchoURL(ac);
|
||||||
|
break;
|
||||||
|
case Utils.CMSType.ProductCategory:
|
||||||
|
Category pc = Category.FindById(id);
|
||||||
|
url = EchoURL(pc);
|
||||||
|
break;
|
||||||
|
case Utils.CMSType.Article:
|
||||||
|
Article a = Article.FindById(id);
|
||||||
|
url = EchoURL(a);
|
||||||
|
break;
|
||||||
|
case Utils.CMSType.Product:
|
||||||
|
Product p = Product.FindById(id);
|
||||||
|
url = EchoURL(p);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
url = "/";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 生成详情地址
|
||||||
|
/// <summary>
|
||||||
|
/// 生成文章详情地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EchoArticleURL(Article model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
return "javascript:;";
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(model.ArticleKind.FilePath))
|
||||||
|
{
|
||||||
|
string url = $"{model.ArticleKind.FilePath}/{model.Id}.html";
|
||||||
|
if (!string.IsNullOrEmpty(model.FileName))
|
||||||
|
{
|
||||||
|
url = $"{model.ArticleKind.FilePath}/{model.FileName}";
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return $"/article/detail/{model.Id}";
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 生成文章详情地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string EchoArticleURL(int id)
|
||||||
|
{
|
||||||
|
Article model = Article.FindById(id);
|
||||||
|
return EchoArticleURL(model);
|
||||||
|
}
|
||||||
|
#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;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
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;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,149 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
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 DataDictionary : Entity<DataDictionary>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static DataDictionary()
|
||||||
|
{
|
||||||
|
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||||
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
|
//df.Add(__.Rank);
|
||||||
|
|
||||||
|
// 过滤器 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.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化DataDictionary[数据字典]数据……");
|
||||||
|
|
||||||
|
// var entity = new DataDictionary();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.Key = "abc";
|
||||||
|
// entity.Description = "abc";
|
||||||
|
// entity.Rank = 0;
|
||||||
|
// entity.AddTime = DateTime.Now;
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化DataDictionary[数据字典]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 DataDictionary FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
|
||||||
|
// Select Count(Id) as Id,Category From DataDictionary Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||||
|
//static readonly FieldCache<DataDictionary> _CategoryCache = new FieldCache<DataDictionary>(_.Category)
|
||||||
|
//{
|
||||||
|
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||||
|
//};
|
||||||
|
|
||||||
|
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据字典到Select控件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dictKey">字典key</param>
|
||||||
|
/// <param name="selectedVal">选中值</param>
|
||||||
|
/// <param name="id">下拉表单的Id和Name</param>
|
||||||
|
/// <param name="className">样式名称</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static String GetDataDictSelect(string dictKey,string selectedVal,string id,string className= "form-control")
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append($"<select name=\"{id}\" id=\"{id}\" class=\"{className}\">");
|
||||||
|
|
||||||
|
var entity = DataDictionary.Find(DataDictionary._.Key == dictKey);
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
IList<DataDictionaryDetail> list = DataDictionaryDetail.FindAll(DataDictionaryDetail._.DataDictionaryId == entity.Id, DataDictionaryDetail._.Rank.Asc().And(DataDictionaryDetail._.Id.Desc()), null, 0, 0);
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
string selected = item.Val == selectedVal ? "selected=\"selected\"" : "";
|
||||||
|
sb.Append($"<option value=\"{item.Val}\" {selected} >{item.Title}</option>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.Append("</select>");
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>数据字典</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("数据字典")]
|
||||||
|
[BindTable("DataDictionary", Description = "数据字典", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class DataDictionary : IDataDictionary
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
|
private String _Key;
|
||||||
|
/// <summary>字典key</summary>
|
||||||
|
[DisplayName("字典key")]
|
||||||
|
[Description("字典key")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("Key", "字典key", "")]
|
||||||
|
public String Key { get => _Key; set { if (OnPropertyChanging(__.Key, value)) { _Key = value; OnPropertyChanged(__.Key); } } }
|
||||||
|
|
||||||
|
private String _Description;
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
[DisplayName("字典介绍")]
|
||||||
|
[Description("字典介绍")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("Description", "字典介绍", "")]
|
||||||
|
public String Description { get => _Description; set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
||||||
|
|
||||||
|
private Int32 _Rank;
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
[DisplayName("排序")]
|
||||||
|
[Description("排序")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Rank", "排序", "")]
|
||||||
|
public Int32 Rank { get => _Rank; set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } }
|
||||||
|
|
||||||
|
private DateTime _AddTime;
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
[DisplayName("添加时间")]
|
||||||
|
[Description("添加时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
|
public DateTime AddTime { get => _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 __.Key: return _Key;
|
||||||
|
case __.Description: return _Description;
|
||||||
|
case __.Rank: return _Rank;
|
||||||
|
case __.AddTime: return _AddTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id: _Id = value.ToInt(); break;
|
||||||
|
case __.Key: _Key = Convert.ToString(value); break;
|
||||||
|
case __.Description: _Description = Convert.ToString(value); break;
|
||||||
|
case __.Rank: _Rank = value.ToInt(); break;
|
||||||
|
case __.AddTime: _AddTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得数据字典字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName(__.Id);
|
||||||
|
|
||||||
|
/// <summary>字典key</summary>
|
||||||
|
public static readonly Field Key = FindByName(__.Key);
|
||||||
|
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
public static readonly Field Description = FindByName(__.Description);
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public static readonly Field Rank = FindByName(__.Rank);
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public static readonly Field AddTime = FindByName(__.AddTime);
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得数据字典字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>字典key</summary>
|
||||||
|
public const String Key = "Key";
|
||||||
|
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
public const String Description = "Description";
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public const String Rank = "Rank";
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public const String AddTime = "AddTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>数据字典接口</summary>
|
||||||
|
public partial interface IDataDictionary
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
Int32 Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>字典key</summary>
|
||||||
|
String Key { get; set; }
|
||||||
|
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
String Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
Int32 Rank { 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
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 DataDictionaryDetail : Entity<DataDictionaryDetail>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static DataDictionaryDetail()
|
||||||
|
{
|
||||||
|
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||||
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
|
//df.Add(__.DataDictionaryId);
|
||||||
|
|
||||||
|
// 过滤器 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.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化DataDictionaryDetail[数据字典详情]数据……");
|
||||||
|
|
||||||
|
// var entity = new DataDictionaryDetail();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.DataDictionaryId = 0;
|
||||||
|
// entity.Val = "abc";
|
||||||
|
// entity.Title = "abc";
|
||||||
|
// entity.Description = "abc";
|
||||||
|
// entity.Rank = 0;
|
||||||
|
// entity.IsDefault = 0;
|
||||||
|
// entity.AddTime = DateTime.Now;
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化DataDictionaryDetail[数据字典详情]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 扩展属性
|
||||||
|
///// <summary>字典ID</summary>
|
||||||
|
//[XmlIgnore, IgnoreDataMember]
|
||||||
|
////[ScriptIgnore]
|
||||||
|
//public DataDictionary DataDictionary => Extends.Get(nameof(DataDictionary), k => DataDictionary.FindById(DataDictionaryId));
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 扩展查询
|
||||||
|
/// <summary>根据编号查找</summary>
|
||||||
|
/// <param name="id">编号</param>
|
||||||
|
/// <returns>实体对象</returns>
|
||||||
|
public static DataDictionaryDetail FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
|
||||||
|
// Select Count(Id) as Id,Category From DataDictionaryDetail Where CreateTime>'2020-01-24 00:00:00' Group By Category Order By Id Desc limit 20
|
||||||
|
//static readonly FieldCache<DataDictionaryDetail> _CategoryCache = new FieldCache<DataDictionaryDetail>(_.Category)
|
||||||
|
//{
|
||||||
|
//Where = _.CreateTime > DateTime.Today.AddDays(-30) & Expression.Empty
|
||||||
|
//};
|
||||||
|
|
||||||
|
///// <summary>获取类别列表,字段缓存10分钟,分组统计数据最多的前20种,用于魔方前台下拉选择</summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public static IDictionary<String, String> GetCategoryList() => _CategoryCache.FindAllName();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>数据字典详情</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("数据字典详情")]
|
||||||
|
[BindTable("DataDictionaryDetail", Description = "数据字典详情", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class DataDictionaryDetail : IDataDictionaryDetail
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
|
private Int32 _DataDictionaryId;
|
||||||
|
/// <summary>字典ID</summary>
|
||||||
|
[DisplayName("字典ID")]
|
||||||
|
[Description("字典ID")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("DataDictionaryId", "字典ID", "")]
|
||||||
|
public Int32 DataDictionaryId { get => _DataDictionaryId; set { if (OnPropertyChanging(__.DataDictionaryId, value)) { _DataDictionaryId = value; OnPropertyChanged(__.DataDictionaryId); } } }
|
||||||
|
|
||||||
|
private String _Val;
|
||||||
|
/// <summary>字典值</summary>
|
||||||
|
[DisplayName("字典值")]
|
||||||
|
[Description("字典值")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("Val", "字典值", "")]
|
||||||
|
public String Val { get => _Val; set { if (OnPropertyChanging(__.Val, value)) { _Val = value; OnPropertyChanged(__.Val); } } }
|
||||||
|
|
||||||
|
private String _Title;
|
||||||
|
/// <summary>字典标签</summary>
|
||||||
|
[DisplayName("字典标签")]
|
||||||
|
[Description("字典标签")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("Title", "字典标签", "", Master = true)]
|
||||||
|
public String Title { get => _Title; set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } }
|
||||||
|
|
||||||
|
private String _Description;
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
[DisplayName("字典介绍")]
|
||||||
|
[Description("字典介绍")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("Description", "字典介绍", "")]
|
||||||
|
public String Description { get => _Description; set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
||||||
|
|
||||||
|
private Int32 _Rank;
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
[DisplayName("排序")]
|
||||||
|
[Description("排序")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Rank", "排序", "")]
|
||||||
|
public Int32 Rank { get => _Rank; set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } }
|
||||||
|
|
||||||
|
private Int32 _IsDefault;
|
||||||
|
/// <summary>是否默认值</summary>
|
||||||
|
[DisplayName("是否默认值")]
|
||||||
|
[Description("是否默认值")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("IsDefault", "是否默认值", "")]
|
||||||
|
public Int32 IsDefault { get => _IsDefault; set { if (OnPropertyChanging(__.IsDefault, value)) { _IsDefault = value; OnPropertyChanged(__.IsDefault); } } }
|
||||||
|
|
||||||
|
private DateTime _AddTime;
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
[DisplayName("添加时间")]
|
||||||
|
[Description("添加时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
|
public DateTime AddTime { get => _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 __.DataDictionaryId: return _DataDictionaryId;
|
||||||
|
case __.Val: return _Val;
|
||||||
|
case __.Title: return _Title;
|
||||||
|
case __.Description: return _Description;
|
||||||
|
case __.Rank: return _Rank;
|
||||||
|
case __.IsDefault: return _IsDefault;
|
||||||
|
case __.AddTime: return _AddTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id: _Id = value.ToInt(); break;
|
||||||
|
case __.DataDictionaryId: _DataDictionaryId = value.ToInt(); break;
|
||||||
|
case __.Val: _Val = Convert.ToString(value); break;
|
||||||
|
case __.Title: _Title = Convert.ToString(value); break;
|
||||||
|
case __.Description: _Description = Convert.ToString(value); break;
|
||||||
|
case __.Rank: _Rank = value.ToInt(); break;
|
||||||
|
case __.IsDefault: _IsDefault = value.ToInt(); break;
|
||||||
|
case __.AddTime: _AddTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得数据字典详情字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName(__.Id);
|
||||||
|
|
||||||
|
/// <summary>字典ID</summary>
|
||||||
|
public static readonly Field DataDictionaryId = FindByName(__.DataDictionaryId);
|
||||||
|
|
||||||
|
/// <summary>字典值</summary>
|
||||||
|
public static readonly Field Val = FindByName(__.Val);
|
||||||
|
|
||||||
|
/// <summary>字典标签</summary>
|
||||||
|
public static readonly Field Title = FindByName(__.Title);
|
||||||
|
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
public static readonly Field Description = FindByName(__.Description);
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public static readonly Field Rank = FindByName(__.Rank);
|
||||||
|
|
||||||
|
/// <summary>是否默认值</summary>
|
||||||
|
public static readonly Field IsDefault = FindByName(__.IsDefault);
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public static readonly Field AddTime = FindByName(__.AddTime);
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得数据字典详情字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>字典ID</summary>
|
||||||
|
public const String DataDictionaryId = "DataDictionaryId";
|
||||||
|
|
||||||
|
/// <summary>字典值</summary>
|
||||||
|
public const String Val = "Val";
|
||||||
|
|
||||||
|
/// <summary>字典标签</summary>
|
||||||
|
public const String Title = "Title";
|
||||||
|
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
public const String Description = "Description";
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public const String Rank = "Rank";
|
||||||
|
|
||||||
|
/// <summary>是否默认值</summary>
|
||||||
|
public const String IsDefault = "IsDefault";
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public const String AddTime = "AddTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>数据字典详情接口</summary>
|
||||||
|
public partial interface IDataDictionaryDetail
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
Int32 Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>字典ID</summary>
|
||||||
|
Int32 DataDictionaryId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>字典值</summary>
|
||||||
|
String Val { get; set; }
|
||||||
|
|
||||||
|
/// <summary>字典标签</summary>
|
||||||
|
String Title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>字典介绍</summary>
|
||||||
|
String Description { get; set; }
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
Int32 Rank { get; set; }
|
||||||
|
|
||||||
|
/// <summary>是否默认值</summary>
|
||||||
|
Int32 IsDefault { 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;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace COMCMS.Core
|
|||||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||||
|
|
||||||
// 过滤器 UserModule、TimeModule、IPModule
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
Meta.Modules.Add<TimeModule>();
|
Meta.Interceptors.Add<TimeInterceptor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,29 +46,29 @@ namespace COMCMS.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
/// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
protected override void InitData()
|
//protected override void InitData()
|
||||||
{
|
//{
|
||||||
// InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||||
if (Meta.Count > 0) return;
|
// if (Meta.Count > 0) return;
|
||||||
|
|
||||||
if (XTrace.Debug) XTrace.WriteLine("开始初始化TargetEvent[目标事件]数据……");
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化TargetEvent[目标事件]数据……");
|
||||||
IList<TargetEvent> list = new List<TargetEvent>();
|
// IList<TargetEvent> list = new List<TargetEvent>();
|
||||||
list.Add(new TargetEvent() { EventKey = "add", EventName = "添加", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "add", EventName = "添加", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "edit", EventName = "修改", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "edit", EventName = "修改", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "del", EventName = "删除", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "del", EventName = "删除", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "view", EventName = "查看", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "view", EventName = "查看", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "viewlist", EventName = "查看列表", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "viewlist", EventName = "查看列表", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "import", EventName = "导入", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "import", EventName = "导入", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "export", EventName = "导出", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "export", EventName = "导出", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "filter", EventName = "搜索", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "filter", EventName = "搜索", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "batch", EventName = "批量操作", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "batch", EventName = "批量操作", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "recycle", EventName = "回收站", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "recycle", EventName = "回收站", IsDisable = 0, Rank = 0 });
|
||||||
list.Add(new TargetEvent() { EventKey = "confirm", EventName = "确认", IsDisable = 0, Rank = 0 });
|
// list.Add(new TargetEvent() { EventKey = "confirm", EventName = "确认", IsDisable = 0, Rank = 0 });
|
||||||
list.Insert(true);
|
// list.Insert(true);
|
||||||
|
|
||||||
if (XTrace.Debug) XTrace.WriteLine("完成初始化TargetEvent[目标事件]数据!");
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化TargetEvent[目标事件]数据!");
|
||||||
}
|
//}
|
||||||
|
|
||||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||||
///// <returns></returns>
|
///// <returns></returns>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
+28
-25
@@ -184,8 +184,8 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
if (IsAdminLogin())
|
if (IsAdminLogin())
|
||||||
{
|
{
|
||||||
//return Find(_.UserName == SessionHelper.GetSession(sessionAdminNameKey).ToString());
|
return Find(_.UserName == SessionHelper.GetSession(sessionAdminNameKey).ToString());
|
||||||
return Find(_.UserName == AuthenticationHelper.GetClaim(sessionAdminNameKey));
|
//return Find(_.UserName == AuthenticationHelper.GetClaim(sessionAdminNameKey));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -241,8 +241,8 @@ namespace COMCMS.Core
|
|||||||
//写入Session 和 Cookies
|
//写入Session 和 Cookies
|
||||||
//SessionHelper.WriteSession("rtadminguid", GUID.ToString());
|
//SessionHelper.WriteSession("rtadminguid", GUID.ToString());
|
||||||
//CookiesHelper.WriteCookie("rtadminguid", GUID.ToString(), 120);
|
//CookiesHelper.WriteCookie("rtadminguid", GUID.ToString(), 120);
|
||||||
//SetAdminInfo(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt);
|
SetAdminInfo(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt);
|
||||||
SetAdminInfoAsync(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt).Wait();
|
//SetAdminInfoAsync(entity.UserName, entity.PassWord, entity.Id, 0, "", GUID.ToString(), entity.Salt).Wait();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -255,22 +255,22 @@ namespace COMCMS.Core
|
|||||||
/// <returns>是否登录</returns>
|
/// <returns>是否登录</returns>
|
||||||
public static bool IsAdminLogin()
|
public static bool IsAdminLogin()
|
||||||
{
|
{
|
||||||
//string adminName = SessionHelper.GetSession(sessionAdminNameKey).ToString();//用户名
|
string adminName = SessionHelper.GetSession(sessionAdminNameKey).ToString();//用户名
|
||||||
//string adminID = SessionHelper.GetSession(sessionAdminIDKey).ToString();//ID
|
string adminID = SessionHelper.GetSession(sessionAdminIDKey).ToString();//ID
|
||||||
string adminName = AuthenticationHelper.GetClaim(sessionAdminNameKey);//用户名
|
//string adminName = AuthenticationHelper.GetClaim(sessionAdminNameKey);//用户名
|
||||||
string adminID = AuthenticationHelper.GetClaim(sessionAdminIDKey);//ID
|
//string adminID = AuthenticationHelper.GetClaim(sessionAdminIDKey);//ID
|
||||||
|
|
||||||
//如果Session失效,则用Cookies判断
|
//如果Session失效,则用Cookies判断
|
||||||
if (string.IsNullOrEmpty(adminName) || string.IsNullOrEmpty(adminID))
|
if (string.IsNullOrEmpty(adminName) || string.IsNullOrEmpty(adminID))
|
||||||
{
|
{
|
||||||
//string cooAdminName = CookiesHelper.GetCookie(cookiesAdminNameKey);//用户名
|
string cooAdminName = CookiesHelper.GetCookie(cookiesAdminNameKey);//用户名
|
||||||
//string cooAdminID = CookiesHelper.GetCookie(cookiesAdminIDKey);//ID
|
string cooAdminID = CookiesHelper.GetCookie(cookiesAdminIDKey);//ID
|
||||||
//string cooLoginInfo = CookiesHelper.GetCookie(cookiesAdminInfoKey);//信息
|
string cooLoginInfo = CookiesHelper.GetCookie(cookiesAdminInfoKey);//信息
|
||||||
//string cooAdminLogID = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID
|
string cooAdminLogID = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID
|
||||||
string cooAdminName = AuthenticationHelper.GetClaim(cookiesAdminNameKey);//用户名
|
//string cooAdminName = AuthenticationHelper.GetClaim(cookiesAdminNameKey);//用户名
|
||||||
string cooAdminID = AuthenticationHelper.GetClaim(cookiesAdminIDKey);//ID
|
//string cooAdminID = AuthenticationHelper.GetClaim(cookiesAdminIDKey);//ID
|
||||||
string cooLoginInfo = AuthenticationHelper.GetClaim(cookiesAdminInfoKey);//信息
|
//string cooLoginInfo = AuthenticationHelper.GetClaim(cookiesAdminInfoKey);//信息
|
||||||
string cooAdminLogID = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID
|
//string cooAdminLogID = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(cooAdminID) || string.IsNullOrEmpty(cooAdminName) || string.IsNullOrEmpty(cooLoginInfo) || string.IsNullOrEmpty(cooAdminLogID))
|
if (string.IsNullOrEmpty(cooAdminID) || string.IsNullOrEmpty(cooAdminName) || string.IsNullOrEmpty(cooLoginInfo) || string.IsNullOrEmpty(cooAdminLogID))
|
||||||
{
|
{
|
||||||
@@ -298,16 +298,16 @@ namespace COMCMS.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
//重新写入Session 和 Cookies
|
//重新写入Session 和 Cookies
|
||||||
//SetAdminInfo(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt);
|
SetAdminInfo(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt);
|
||||||
|
|
||||||
SetAdminInfoAsync(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt).Wait();
|
//SetAdminInfoAsync(model.UserName, model.PassWord, model.Id, 0, "", cooAdminLogID, model.Salt).Wait();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//ClearInfo();//清除信息
|
ClearInfo();//清除信息
|
||||||
ClearInfoAsync().Wait();
|
//ClearInfoAsync().Wait();
|
||||||
return false;//信息错误
|
return false;//信息错误
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,19 +412,22 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
if (IsAdminLogin())
|
if (IsAdminLogin())
|
||||||
{
|
{
|
||||||
//string adminLogId = SessionHelper.GetSession(sessionAdminLogIDKey).ToString();
|
string adminLogId = SessionHelper.GetSession(sessionAdminLogIDKey).ToString();
|
||||||
string adminLogId = AuthenticationHelper.GetClaim(sessionAdminLogIDKey);
|
//string adminLogId = AuthenticationHelper.GetClaim(sessionAdminLogIDKey);
|
||||||
if (string.IsNullOrEmpty(adminLogId))
|
if (string.IsNullOrEmpty(adminLogId))
|
||||||
{
|
{
|
||||||
//adminLogId = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID
|
adminLogId = CookiesHelper.GetCookie(cookiesAdminLogIDKey);//日志GUID
|
||||||
adminLogId = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID
|
//adminLogId = AuthenticationHelper.GetClaim(cookiesAdminLogIDKey);//日志GUID
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(adminLogId))
|
if (!string.IsNullOrEmpty(adminLogId))
|
||||||
{
|
{
|
||||||
AdminLog log = AdminLog.FindByGUID(adminLogId);
|
AdminLog log = AdminLog.FindByGUID(adminLogId);
|
||||||
if (log != null)
|
if (log != null)
|
||||||
{
|
{
|
||||||
log.Actions = log.Actions + $"|||{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}: {action}";
|
if (string.IsNullOrEmpty(log.Actions))
|
||||||
|
log.Actions = $"{DateTime.Now:yyyy-MM-dd HH:mm}: {action}";
|
||||||
|
else
|
||||||
|
log.Actions = log.Actions + $"|||{DateTime.Now:yyyy-MM-dd HH:mm}: {action}";
|
||||||
log.LastUpdateTime = DateTime.Now;
|
log.LastUpdateTime = DateTime.Now;
|
||||||
log.Update();
|
log.Update();
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
+125
-103
@@ -1,9 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Xml.Serialization;
|
||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
@@ -12,7 +16,7 @@ namespace COMCMS.Core
|
|||||||
[DataObject]
|
[DataObject]
|
||||||
[Description("管理角色")]
|
[Description("管理角色")]
|
||||||
[BindTable("AdminRoles", Description = "管理角色", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
[BindTable("AdminRoles", Description = "管理角色", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
public partial class AdminRoles : IAdminRoles
|
public partial class AdminRoles
|
||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
private Int32 _Id;
|
private Int32 _Id;
|
||||||
@@ -20,88 +24,120 @@ namespace COMCMS.Core
|
|||||||
[DisplayName("编号")]
|
[DisplayName("编号")]
|
||||||
[Description("编号")]
|
[Description("编号")]
|
||||||
[DataObjectField(true, true, false, 0)]
|
[DataObjectField(true, true, false, 0)]
|
||||||
[BindColumn("Id", "编号", "int")]
|
[BindColumn("Id", "编号", "")]
|
||||||
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||||
|
|
||||||
private Int32 _RoleType;
|
private Int32 _RoleType;
|
||||||
/// <summary>角色类型</summary>
|
/// <summary>角色类型</summary>
|
||||||
[DisplayName("角色类型")]
|
[DisplayName("角色类型")]
|
||||||
[Description("角色类型")]
|
[Description("角色类型")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("RoleType", "角色类型", "int")]
|
[BindColumn("RoleType", "角色类型", "")]
|
||||||
public Int32 RoleType { get { return _RoleType; } set { if (OnPropertyChanging(__.RoleType, value)) { _RoleType = value; OnPropertyChanged(__.RoleType); } } }
|
public Int32 RoleType { get => _RoleType; set { if (OnPropertyChanging("RoleType", value)) { _RoleType = value; OnPropertyChanged("RoleType"); } } }
|
||||||
|
|
||||||
private String _RoleName;
|
private String _RoleName;
|
||||||
/// <summary>角色名称</summary>
|
/// <summary>角色名称</summary>
|
||||||
[DisplayName("角色名称")]
|
[DisplayName("角色名称")]
|
||||||
[Description("角色名称")]
|
[Description("角色名称")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("RoleName", "角色名称", "nvarchar(50)", Master = true)]
|
[BindColumn("RoleName", "角色名称", "", Master = true)]
|
||||||
public String RoleName { get { return _RoleName; } set { if (OnPropertyChanging(__.RoleName, value)) { _RoleName = value; OnPropertyChanged(__.RoleName); } } }
|
public String RoleName { get => _RoleName; set { if (OnPropertyChanging("RoleName", value)) { _RoleName = value; OnPropertyChanged("RoleName"); } } }
|
||||||
|
|
||||||
private String _RoleDescription;
|
private String _RoleDescription;
|
||||||
/// <summary>角色简单介绍</summary>
|
/// <summary>角色简单介绍</summary>
|
||||||
[DisplayName("角色简单介绍")]
|
[DisplayName("角色简单介绍")]
|
||||||
[Description("角色简单介绍")]
|
[Description("角色简单介绍")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("RoleDescription", "角色简单介绍", "nvarchar(250)", Master = true)]
|
[BindColumn("RoleDescription", "角色简单介绍", "", Master = true)]
|
||||||
public String RoleDescription { get { return _RoleDescription; } set { if (OnPropertyChanging(__.RoleDescription, value)) { _RoleDescription = value; OnPropertyChanged(__.RoleDescription); } } }
|
public String RoleDescription { get => _RoleDescription; set { if (OnPropertyChanging("RoleDescription", value)) { _RoleDescription = value; OnPropertyChanged("RoleDescription"); } } }
|
||||||
|
|
||||||
private Int32 _IsSuperAdmin;
|
private Int32 _IsSuperAdmin;
|
||||||
/// <summary>是否是超级管理员</summary>
|
/// <summary>是否是超级管理员</summary>
|
||||||
[DisplayName("是否是超级管理员")]
|
[DisplayName("是否是超级管理员")]
|
||||||
[Description("是否是超级管理员")]
|
[Description("是否是超级管理员")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsSuperAdmin", "是否是超级管理员", "int")]
|
[BindColumn("IsSuperAdmin", "是否是超级管理员", "")]
|
||||||
public Int32 IsSuperAdmin { get { return _IsSuperAdmin; } set { if (OnPropertyChanging(__.IsSuperAdmin, value)) { _IsSuperAdmin = value; OnPropertyChanged(__.IsSuperAdmin); } } }
|
public Int32 IsSuperAdmin { get => _IsSuperAdmin; set { if (OnPropertyChanging("IsSuperAdmin", value)) { _IsSuperAdmin = value; OnPropertyChanged("IsSuperAdmin"); } } }
|
||||||
|
|
||||||
private Int32 _Stars;
|
private Int32 _Stars;
|
||||||
/// <summary>星级</summary>
|
/// <summary>星级</summary>
|
||||||
[DisplayName("星级")]
|
[DisplayName("星级")]
|
||||||
[Description("星级")]
|
[Description("星级")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Stars", "星级", "int")]
|
[BindColumn("Stars", "星级", "")]
|
||||||
public Int32 Stars { get { return _Stars; } set { if (OnPropertyChanging(__.Stars, value)) { _Stars = value; OnPropertyChanged(__.Stars); } } }
|
public Int32 Stars { get => _Stars; set { if (OnPropertyChanging("Stars", value)) { _Stars = value; OnPropertyChanged("Stars"); } } }
|
||||||
|
|
||||||
private Int32 _NotAllowDel;
|
private Int32 _NotAllowDel;
|
||||||
/// <summary>是否不允许删除</summary>
|
/// <summary>是否不允许删除</summary>
|
||||||
[DisplayName("是否不允许删除")]
|
[DisplayName("是否不允许删除")]
|
||||||
[Description("是否不允许删除")]
|
[Description("是否不允许删除")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("NotAllowDel", "是否不允许删除", "int")]
|
[BindColumn("NotAllowDel", "是否不允许删除", "")]
|
||||||
public Int32 NotAllowDel { get { return _NotAllowDel; } set { if (OnPropertyChanging(__.NotAllowDel, value)) { _NotAllowDel = value; OnPropertyChanged(__.NotAllowDel); } } }
|
public Int32 NotAllowDel { get => _NotAllowDel; set { if (OnPropertyChanging("NotAllowDel", value)) { _NotAllowDel = value; OnPropertyChanged("NotAllowDel"); } } }
|
||||||
|
|
||||||
private Int32 _Rank;
|
private Int32 _Rank;
|
||||||
/// <summary>排序</summary>
|
/// <summary>排序</summary>
|
||||||
[DisplayName("排序")]
|
[DisplayName("排序")]
|
||||||
[Description("排序")]
|
[Description("排序")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Rank", "排序", "int")]
|
[BindColumn("Rank", "排序", "")]
|
||||||
public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } }
|
public Int32 Rank { get => _Rank; set { if (OnPropertyChanging("Rank", value)) { _Rank = value; OnPropertyChanged("Rank"); } } }
|
||||||
|
|
||||||
private String _Color;
|
private String _Color;
|
||||||
/// <summary>颜色</summary>
|
/// <summary>颜色</summary>
|
||||||
[DisplayName("颜色")]
|
[DisplayName("颜色")]
|
||||||
[Description("颜色")]
|
[Description("颜色")]
|
||||||
[DataObjectField(false, false, true, 20)]
|
[DataObjectField(false, false, true, 20)]
|
||||||
[BindColumn("Color", "颜色", "nvarchar(20)", Master = true)]
|
[BindColumn("Color", "颜色", "", Master = true)]
|
||||||
public String Color { get { return _Color; } set { if (OnPropertyChanging(__.Color, value)) { _Color = value; OnPropertyChanged(__.Color); } } }
|
public String Color { get => _Color; set { if (OnPropertyChanging("Color", value)) { _Color = value; OnPropertyChanged("Color"); } } }
|
||||||
|
|
||||||
private String _Menus;
|
private String _Menus;
|
||||||
/// <summary>管理菜单</summary>
|
/// <summary>管理菜单</summary>
|
||||||
[DisplayName("管理菜单")]
|
[DisplayName("管理菜单")]
|
||||||
[Description("管理菜单")]
|
[Description("管理菜单")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("Menus", "管理菜单", "ntext", Master = true)]
|
[BindColumn("Menus", "管理菜单", "", Master = true)]
|
||||||
public String Menus { get { return _Menus; } set { if (OnPropertyChanging(__.Menus, value)) { _Menus = value; OnPropertyChanged(__.Menus); } } }
|
public String Menus { get => _Menus; set { if (OnPropertyChanging("Menus", value)) { _Menus = value; OnPropertyChanged("Menus"); } } }
|
||||||
|
|
||||||
private String _Powers;
|
private String _Powers;
|
||||||
/// <summary>权限</summary>
|
/// <summary>权限</summary>
|
||||||
[DisplayName("权限")]
|
[DisplayName("权限")]
|
||||||
[Description("权限")]
|
[Description("权限")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("Powers", "权限", "ntext", Master = true)]
|
[BindColumn("Powers", "权限", "", Master = true)]
|
||||||
public String Powers { get { return _Powers; } set { if (OnPropertyChanging(__.Powers, value)) { _Powers = value; OnPropertyChanged(__.Powers); } } }
|
public String Powers { get => _Powers; set { if (OnPropertyChanging("Powers", value)) { _Powers = value; OnPropertyChanged("Powers"); } } }
|
||||||
|
|
||||||
|
private String _AuthorizedArticleCagegory;
|
||||||
|
/// <summary>已授权文章栏目</summary>
|
||||||
|
[DisplayName("已授权文章栏目")]
|
||||||
|
[Description("已授权文章栏目")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("AuthorizedArticleCagegory", "已授权文章栏目", "", Master = true)]
|
||||||
|
public String AuthorizedArticleCagegory { get => _AuthorizedArticleCagegory; set { if (OnPropertyChanging("AuthorizedArticleCagegory", value)) { _AuthorizedArticleCagegory = value; OnPropertyChanged("AuthorizedArticleCagegory"); } } }
|
||||||
|
|
||||||
|
private String _AuthorizedCagegory;
|
||||||
|
/// <summary>已授权商品栏目</summary>
|
||||||
|
[DisplayName("已授权商品栏目")]
|
||||||
|
[Description("已授权商品栏目")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("AuthorizedCagegory", "已授权商品栏目", "", Master = true)]
|
||||||
|
public String AuthorizedCagegory { get => _AuthorizedCagegory; set { if (OnPropertyChanging("AuthorizedCagegory", value)) { _AuthorizedCagegory = value; OnPropertyChanged("AuthorizedCagegory"); } } }
|
||||||
|
|
||||||
|
private Int32 _OnlyEditMyselfArticle;
|
||||||
|
/// <summary>是否只允许编辑自己的文章</summary>
|
||||||
|
[DisplayName("是否只允许编辑自己的文章")]
|
||||||
|
[Description("是否只允许编辑自己的文章")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("OnlyEditMyselfArticle", "是否只允许编辑自己的文章", "")]
|
||||||
|
public Int32 OnlyEditMyselfArticle { get => _OnlyEditMyselfArticle; set { if (OnPropertyChanging("OnlyEditMyselfArticle", value)) { _OnlyEditMyselfArticle = value; OnPropertyChanged("OnlyEditMyselfArticle"); } } }
|
||||||
|
|
||||||
|
private Int32 _OnlyEditMyselfProduct;
|
||||||
|
/// <summary>是否只允许编辑自己的产品</summary>
|
||||||
|
[DisplayName("是否只允许编辑自己的产品")]
|
||||||
|
[Description("是否只允许编辑自己的产品")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("OnlyEditMyselfProduct", "是否只允许编辑自己的产品", "")]
|
||||||
|
public Int32 OnlyEditMyselfProduct { get => _OnlyEditMyselfProduct; set { if (OnPropertyChanging("OnlyEditMyselfProduct", value)) { _OnlyEditMyselfProduct = value; OnPropertyChanged("OnlyEditMyselfProduct"); } } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
#region 获取/设置 字段值
|
||||||
@@ -114,17 +150,21 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case __.Id : return _Id;
|
case "Id": return _Id;
|
||||||
case __.RoleType : return _RoleType;
|
case "RoleType": return _RoleType;
|
||||||
case __.RoleName : return _RoleName;
|
case "RoleName": return _RoleName;
|
||||||
case __.RoleDescription : return _RoleDescription;
|
case "RoleDescription": return _RoleDescription;
|
||||||
case __.IsSuperAdmin : return _IsSuperAdmin;
|
case "IsSuperAdmin": return _IsSuperAdmin;
|
||||||
case __.Stars : return _Stars;
|
case "Stars": return _Stars;
|
||||||
case __.NotAllowDel : return _NotAllowDel;
|
case "NotAllowDel": return _NotAllowDel;
|
||||||
case __.Rank : return _Rank;
|
case "Rank": return _Rank;
|
||||||
case __.Color : return _Color;
|
case "Color": return _Color;
|
||||||
case __.Menus : return _Menus;
|
case "Menus": return _Menus;
|
||||||
case __.Powers : return _Powers;
|
case "Powers": return _Powers;
|
||||||
|
case "AuthorizedArticleCagegory": return _AuthorizedArticleCagegory;
|
||||||
|
case "AuthorizedCagegory": return _AuthorizedCagegory;
|
||||||
|
case "OnlyEditMyselfArticle": return _OnlyEditMyselfArticle;
|
||||||
|
case "OnlyEditMyselfProduct": return _OnlyEditMyselfProduct;
|
||||||
default: return base[name];
|
default: return base[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,17 +172,21 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case __.Id : _Id = Convert.ToInt32(value); break;
|
case "Id": _Id = value.ToInt(); break;
|
||||||
case __.RoleType : _RoleType = Convert.ToInt32(value); break;
|
case "RoleType": _RoleType = value.ToInt(); break;
|
||||||
case __.RoleName : _RoleName = Convert.ToString(value); break;
|
case "RoleName": _RoleName = Convert.ToString(value); break;
|
||||||
case __.RoleDescription : _RoleDescription = Convert.ToString(value); break;
|
case "RoleDescription": _RoleDescription = Convert.ToString(value); break;
|
||||||
case __.IsSuperAdmin : _IsSuperAdmin = Convert.ToInt32(value); break;
|
case "IsSuperAdmin": _IsSuperAdmin = value.ToInt(); break;
|
||||||
case __.Stars : _Stars = Convert.ToInt32(value); break;
|
case "Stars": _Stars = value.ToInt(); break;
|
||||||
case __.NotAllowDel : _NotAllowDel = Convert.ToInt32(value); break;
|
case "NotAllowDel": _NotAllowDel = value.ToInt(); break;
|
||||||
case __.Rank : _Rank = Convert.ToInt32(value); break;
|
case "Rank": _Rank = value.ToInt(); break;
|
||||||
case __.Color : _Color = Convert.ToString(value); break;
|
case "Color": _Color = Convert.ToString(value); break;
|
||||||
case __.Menus : _Menus = Convert.ToString(value); break;
|
case "Menus": _Menus = Convert.ToString(value); break;
|
||||||
case __.Powers : _Powers = Convert.ToString(value); break;
|
case "Powers": _Powers = Convert.ToString(value); break;
|
||||||
|
case "AuthorizedArticleCagegory": _AuthorizedArticleCagegory = Convert.ToString(value); break;
|
||||||
|
case "AuthorizedCagegory": _AuthorizedCagegory = Convert.ToString(value); break;
|
||||||
|
case "OnlyEditMyselfArticle": _OnlyEditMyselfArticle = value.ToInt(); break;
|
||||||
|
case "OnlyEditMyselfProduct": _OnlyEditMyselfProduct = value.ToInt(); break;
|
||||||
default: base[name] = value; break;
|
default: base[name] = value; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,39 +198,51 @@ namespace COMCMS.Core
|
|||||||
public partial class _
|
public partial class _
|
||||||
{
|
{
|
||||||
/// <summary>编号</summary>
|
/// <summary>编号</summary>
|
||||||
public static readonly Field Id = FindByName(__.Id);
|
public static readonly Field Id = FindByName("Id");
|
||||||
|
|
||||||
/// <summary>角色类型</summary>
|
/// <summary>角色类型</summary>
|
||||||
public static readonly Field RoleType = FindByName(__.RoleType);
|
public static readonly Field RoleType = FindByName("RoleType");
|
||||||
|
|
||||||
/// <summary>角色名称</summary>
|
/// <summary>角色名称</summary>
|
||||||
public static readonly Field RoleName = FindByName(__.RoleName);
|
public static readonly Field RoleName = FindByName("RoleName");
|
||||||
|
|
||||||
/// <summary>角色简单介绍</summary>
|
/// <summary>角色简单介绍</summary>
|
||||||
public static readonly Field RoleDescription = FindByName(__.RoleDescription);
|
public static readonly Field RoleDescription = FindByName("RoleDescription");
|
||||||
|
|
||||||
/// <summary>是否是超级管理员</summary>
|
/// <summary>是否是超级管理员</summary>
|
||||||
public static readonly Field IsSuperAdmin = FindByName(__.IsSuperAdmin);
|
public static readonly Field IsSuperAdmin = FindByName("IsSuperAdmin");
|
||||||
|
|
||||||
/// <summary>星级</summary>
|
/// <summary>星级</summary>
|
||||||
public static readonly Field Stars = FindByName(__.Stars);
|
public static readonly Field Stars = FindByName("Stars");
|
||||||
|
|
||||||
/// <summary>是否不允许删除</summary>
|
/// <summary>是否不允许删除</summary>
|
||||||
public static readonly Field NotAllowDel = FindByName(__.NotAllowDel);
|
public static readonly Field NotAllowDel = FindByName("NotAllowDel");
|
||||||
|
|
||||||
/// <summary>排序</summary>
|
/// <summary>排序</summary>
|
||||||
public static readonly Field Rank = FindByName(__.Rank);
|
public static readonly Field Rank = FindByName("Rank");
|
||||||
|
|
||||||
/// <summary>颜色</summary>
|
/// <summary>颜色</summary>
|
||||||
public static readonly Field Color = FindByName(__.Color);
|
public static readonly Field Color = FindByName("Color");
|
||||||
|
|
||||||
/// <summary>管理菜单</summary>
|
/// <summary>管理菜单</summary>
|
||||||
public static readonly Field Menus = FindByName(__.Menus);
|
public static readonly Field Menus = FindByName("Menus");
|
||||||
|
|
||||||
/// <summary>权限</summary>
|
/// <summary>权限</summary>
|
||||||
public static readonly Field Powers = FindByName(__.Powers);
|
public static readonly Field Powers = FindByName("Powers");
|
||||||
|
|
||||||
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
/// <summary>已授权文章栏目</summary>
|
||||||
|
public static readonly Field AuthorizedArticleCagegory = FindByName("AuthorizedArticleCagegory");
|
||||||
|
|
||||||
|
/// <summary>已授权商品栏目</summary>
|
||||||
|
public static readonly Field AuthorizedCagegory = FindByName("AuthorizedCagegory");
|
||||||
|
|
||||||
|
/// <summary>是否只允许编辑自己的文章</summary>
|
||||||
|
public static readonly Field OnlyEditMyselfArticle = FindByName("OnlyEditMyselfArticle");
|
||||||
|
|
||||||
|
/// <summary>是否只允许编辑自己的产品</summary>
|
||||||
|
public static readonly Field OnlyEditMyselfProduct = FindByName("OnlyEditMyselfProduct");
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>取得管理角色字段名称的快捷方式</summary>
|
/// <summary>取得管理角色字段名称的快捷方式</summary>
|
||||||
@@ -224,53 +280,19 @@ namespace COMCMS.Core
|
|||||||
|
|
||||||
/// <summary>权限</summary>
|
/// <summary>权限</summary>
|
||||||
public const String Powers = "Powers";
|
public const String Powers = "Powers";
|
||||||
|
|
||||||
|
/// <summary>已授权文章栏目</summary>
|
||||||
|
public const String AuthorizedArticleCagegory = "AuthorizedArticleCagegory";
|
||||||
|
|
||||||
|
/// <summary>已授权商品栏目</summary>
|
||||||
|
public const String AuthorizedCagegory = "AuthorizedCagegory";
|
||||||
|
|
||||||
|
/// <summary>是否只允许编辑自己的文章</summary>
|
||||||
|
public const String OnlyEditMyselfArticle = "OnlyEditMyselfArticle";
|
||||||
|
|
||||||
|
/// <summary>是否只允许编辑自己的产品</summary>
|
||||||
|
public const String OnlyEditMyselfProduct = "OnlyEditMyselfProduct";
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>管理角色接口</summary>
|
|
||||||
public partial interface IAdminRoles
|
|
||||||
{
|
|
||||||
#region 属性
|
|
||||||
/// <summary>编号</summary>
|
|
||||||
Int32 Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>角色类型</summary>
|
|
||||||
Int32 RoleType { get; set; }
|
|
||||||
|
|
||||||
/// <summary>角色名称</summary>
|
|
||||||
String RoleName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>角色简单介绍</summary>
|
|
||||||
String RoleDescription { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否是超级管理员</summary>
|
|
||||||
Int32 IsSuperAdmin { get; set; }
|
|
||||||
|
|
||||||
/// <summary>星级</summary>
|
|
||||||
Int32 Stars { get; set; }
|
|
||||||
|
|
||||||
/// <summary>是否不允许删除</summary>
|
|
||||||
Int32 NotAllowDel { get; set; }
|
|
||||||
|
|
||||||
/// <summary>排序</summary>
|
|
||||||
Int32 Rank { get; set; }
|
|
||||||
|
|
||||||
/// <summary>颜色</summary>
|
|
||||||
String Color { get; set; }
|
|
||||||
|
|
||||||
/// <summary>管理菜单</summary>
|
|
||||||
String Menus { get; set; }
|
|
||||||
|
|
||||||
/// <summary>权限</summary>
|
|
||||||
String Powers { 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;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,250 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
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 Department : Entity<Department>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static Department()
|
||||||
|
{
|
||||||
|
// 累加字段,生成 Update xx Set Count=Count+1234 Where xxx
|
||||||
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
|
//df.Add(nameof(PId));
|
||||||
|
|
||||||
|
// 过滤器 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.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化Department[部门]数据……");
|
||||||
|
|
||||||
|
// var entity = new Department();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.DepartmentName = "abc";
|
||||||
|
// entity.PId = 0;
|
||||||
|
// entity.Level = 0;
|
||||||
|
// entity.Location = "abc";
|
||||||
|
// entity.DepartmentDescription = "abc";
|
||||||
|
// entity.Pic = "abc";
|
||||||
|
// entity.Rank = 0;
|
||||||
|
// entity.IsNotAllowDel = 0;
|
||||||
|
// entity.Powers = "abc";
|
||||||
|
// entity.IsDel = 0;
|
||||||
|
// entity.Tel = "abc";
|
||||||
|
// entity.Fax = "abc";
|
||||||
|
// entity.Email = "abc";
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化Department[部门]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 Department FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据父ID查询所有子项
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ID">父ID</param>
|
||||||
|
/// <returns>所有子栏目,按Rank正序排列</returns>
|
||||||
|
[DataObjectMethod(DataObjectMethodType.Select)]
|
||||||
|
public static IList<Department> FindByParentID(Int32 ID)
|
||||||
|
{
|
||||||
|
|
||||||
|
IList<Department> list = Meta.Cache.Entities.Where(x => x.PId == ID && x.IsDel==0).OrderBy(x => x.Id).OrderBy(x => x.Rank).ToList();
|
||||||
|
if (list == null || list.Count < 1) return null;
|
||||||
|
|
||||||
|
//list.Sort(_.Rank, true);
|
||||||
|
//list.OrderBy(x => x.Rank);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有子栏目(递归)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ID">栏目ID</param>
|
||||||
|
/// <returns>所有子栏目</returns>
|
||||||
|
public static IList<Department> FindAllSubKinds(Int32 ID)
|
||||||
|
{
|
||||||
|
List<Department> alllist = new List<Department>();
|
||||||
|
IList<Department> list = FindByParentID(ID);
|
||||||
|
if (list != null && list.Count > 0)
|
||||||
|
{
|
||||||
|
alllist.AddRange(list);
|
||||||
|
foreach (Department ak in list)
|
||||||
|
{
|
||||||
|
if (Department.FindByParentID(ak.Id) != null)
|
||||||
|
{
|
||||||
|
alllist.AddRange(FindAllSubKinds(ak.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return alllist;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取路径
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="PId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static String GetNewLocation(int PId)
|
||||||
|
{
|
||||||
|
if (PId == 0)
|
||||||
|
return "0,";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pa = FindById(PId);
|
||||||
|
if (pa != null)
|
||||||
|
{
|
||||||
|
return GetNewLocation(pa.PId) + pa.Id + ",";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pa.Id + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取Level
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="PId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int GetNewLevel(int PId)
|
||||||
|
{
|
||||||
|
if (PId == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pa = FindById(PId);
|
||||||
|
if (pa != null)
|
||||||
|
{
|
||||||
|
return GetNewLevel(pa.PId) + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pa.Level + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
/// <summary>
|
||||||
|
/// 获取树
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pid">上级ID,0为全部</param>
|
||||||
|
/// <param name="maxLevel">最大级别0为1级类别;-1为所有下级</param>
|
||||||
|
/// <param name="isIndentation">是否缩进</param>
|
||||||
|
/// <param name="showhide">是否显示隐藏菜单</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IList<Department> GetListTree(int pid, int maxLevel, bool isIndentation, bool showhide = true)
|
||||||
|
{
|
||||||
|
List<Department> listTree = new List<Department>();
|
||||||
|
IList<Department> list = FindByParentID(pid);
|
||||||
|
if (list != null && list.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (Department p in list)
|
||||||
|
{
|
||||||
|
if (!showhide && p.IsDel == 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listTree.Add(p.CloneEntity());
|
||||||
|
if ((maxLevel == -1 || p.Level < maxLevel) && Department.FindCount(_.PId == p.Id, null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
IList<Department> listtmp = GetListTree(p.Id, maxLevel, false);
|
||||||
|
foreach (Department a in listtmp)
|
||||||
|
{
|
||||||
|
if (!showhide && a.IsDel == 1) continue;//如果不显示隐藏,跳过
|
||||||
|
Department tmpa = a.CloneEntity();
|
||||||
|
if (a.Level > 0 && isIndentation)
|
||||||
|
{
|
||||||
|
tmpa.DepartmentName = new string(' ', tmpa.Level * 2) + tmpa.DepartmentName;
|
||||||
|
}
|
||||||
|
listTree.Add(tmpa);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return listTree;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,337 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Web.Script.Serialization;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>部门</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("部门")]
|
||||||
|
[BindTable("Department", Description = "部门", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class Department : IDepartment
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging("Id", value)) { _Id = value; OnPropertyChanged("Id"); } } }
|
||||||
|
|
||||||
|
private String _DepartmentName;
|
||||||
|
/// <summary>部门名称</summary>
|
||||||
|
[DisplayName("部门名称")]
|
||||||
|
[Description("部门名称")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("DepartmentName", "部门名称", "")]
|
||||||
|
public String DepartmentName { get => _DepartmentName; set { if (OnPropertyChanging("DepartmentName", value)) { _DepartmentName = value; OnPropertyChanged("DepartmentName"); } } }
|
||||||
|
|
||||||
|
private Int32 _PId;
|
||||||
|
/// <summary>上级部门ID</summary>
|
||||||
|
[DisplayName("上级部门ID")]
|
||||||
|
[Description("上级部门ID")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("PId", "上级部门ID", "")]
|
||||||
|
public Int32 PId { get => _PId; set { if (OnPropertyChanging("PId", value)) { _PId = value; OnPropertyChanged("PId"); } } }
|
||||||
|
|
||||||
|
private Int32 _Level;
|
||||||
|
/// <summary>级别</summary>
|
||||||
|
[DisplayName("级别")]
|
||||||
|
[Description("级别")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Level", "级别", "")]
|
||||||
|
public Int32 Level { get => _Level; set { if (OnPropertyChanging("Level", value)) { _Level = value; OnPropertyChanged("Level"); } } }
|
||||||
|
|
||||||
|
private String _Location;
|
||||||
|
/// <summary>路径</summary>
|
||||||
|
[DisplayName("路径")]
|
||||||
|
[Description("路径")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("Location", "路径", "")]
|
||||||
|
public String Location { get => _Location; set { if (OnPropertyChanging("Location", value)) { _Location = value; OnPropertyChanged("Location"); } } }
|
||||||
|
|
||||||
|
private String _DepartmentDescription;
|
||||||
|
/// <summary>部门说明</summary>
|
||||||
|
[DisplayName("部门说明")]
|
||||||
|
[Description("部门说明")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("DepartmentDescription", "部门说明", "")]
|
||||||
|
public String DepartmentDescription { get => _DepartmentDescription; set { if (OnPropertyChanging("DepartmentDescription", value)) { _DepartmentDescription = value; OnPropertyChanged("DepartmentDescription"); } } }
|
||||||
|
|
||||||
|
private String _Pic;
|
||||||
|
/// <summary>部门图片</summary>
|
||||||
|
[DisplayName("部门图片")]
|
||||||
|
[Description("部门图片")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("Pic", "部门图片", "")]
|
||||||
|
public String Pic { get => _Pic; set { if (OnPropertyChanging("Pic", value)) { _Pic = value; OnPropertyChanged("Pic"); } } }
|
||||||
|
|
||||||
|
private Int32 _Rank;
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
[DisplayName("排序")]
|
||||||
|
[Description("排序")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Rank", "排序", "")]
|
||||||
|
public Int32 Rank { get => _Rank; set { if (OnPropertyChanging("Rank", value)) { _Rank = value; OnPropertyChanged("Rank"); } } }
|
||||||
|
|
||||||
|
private Int32 _IsNotAllowDel;
|
||||||
|
/// <summary>是否不允许删除</summary>
|
||||||
|
[DisplayName("是否不允许删除")]
|
||||||
|
[Description("是否不允许删除")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("IsNotAllowDel", "是否不允许删除", "")]
|
||||||
|
public Int32 IsNotAllowDel { get => _IsNotAllowDel; set { if (OnPropertyChanging("IsNotAllowDel", value)) { _IsNotAllowDel = value; OnPropertyChanged("IsNotAllowDel"); } } }
|
||||||
|
|
||||||
|
private String _Powers;
|
||||||
|
/// <summary>部门权限</summary>
|
||||||
|
[DisplayName("部门权限")]
|
||||||
|
[Description("部门权限")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("Powers", "部门权限", "", Master = true)]
|
||||||
|
public String Powers { get => _Powers; set { if (OnPropertyChanging("Powers", value)) { _Powers = value; OnPropertyChanged("Powers"); } } }
|
||||||
|
|
||||||
|
private Int32 _IsDel;
|
||||||
|
/// <summary>是否删除</summary>
|
||||||
|
[DisplayName("是否删除")]
|
||||||
|
[Description("是否删除")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("IsDel", "是否删除", "")]
|
||||||
|
public Int32 IsDel { get => _IsDel; set { if (OnPropertyChanging("IsDel", value)) { _IsDel = value; OnPropertyChanged("IsDel"); } } }
|
||||||
|
|
||||||
|
private String _Tel;
|
||||||
|
/// <summary>联系电话</summary>
|
||||||
|
[DisplayName("联系电话")]
|
||||||
|
[Description("联系电话")]
|
||||||
|
[DataObjectField(false, false, true, 30)]
|
||||||
|
[BindColumn("Tel", "联系电话", "")]
|
||||||
|
public String Tel { get => _Tel; set { if (OnPropertyChanging("Tel", value)) { _Tel = value; OnPropertyChanged("Tel"); } } }
|
||||||
|
|
||||||
|
private String _Fax;
|
||||||
|
/// <summary>传真</summary>
|
||||||
|
[DisplayName("传真")]
|
||||||
|
[Description("传真")]
|
||||||
|
[DataObjectField(false, false, true, 30)]
|
||||||
|
[BindColumn("Fax", "传真", "")]
|
||||||
|
public String Fax { get => _Fax; set { if (OnPropertyChanging("Fax", value)) { _Fax = value; OnPropertyChanged("Fax"); } } }
|
||||||
|
|
||||||
|
private String _Email;
|
||||||
|
/// <summary>邮件</summary>
|
||||||
|
[DisplayName("邮件")]
|
||||||
|
[Description("邮件")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("Email", "邮件", "")]
|
||||||
|
public String Email { get => _Email; set { if (OnPropertyChanging("Email", value)) { _Email = value; OnPropertyChanged("Email"); } } }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取/设置 字段值
|
||||||
|
/// <summary>获取/设置 字段值</summary>
|
||||||
|
/// <param name="name">字段名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override Object this[String name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "Id": return _Id;
|
||||||
|
case "DepartmentName": return _DepartmentName;
|
||||||
|
case "PId": return _PId;
|
||||||
|
case "Level": return _Level;
|
||||||
|
case "Location": return _Location;
|
||||||
|
case "DepartmentDescription": return _DepartmentDescription;
|
||||||
|
case "Pic": return _Pic;
|
||||||
|
case "Rank": return _Rank;
|
||||||
|
case "IsNotAllowDel": return _IsNotAllowDel;
|
||||||
|
case "Powers": return _Powers;
|
||||||
|
case "IsDel": return _IsDel;
|
||||||
|
case "Tel": return _Tel;
|
||||||
|
case "Fax": return _Fax;
|
||||||
|
case "Email": return _Email;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "Id": _Id = value.ToInt(); break;
|
||||||
|
case "DepartmentName": _DepartmentName = Convert.ToString(value); break;
|
||||||
|
case "PId": _PId = value.ToInt(); break;
|
||||||
|
case "Level": _Level = value.ToInt(); break;
|
||||||
|
case "Location": _Location = Convert.ToString(value); break;
|
||||||
|
case "DepartmentDescription": _DepartmentDescription = Convert.ToString(value); break;
|
||||||
|
case "Pic": _Pic = Convert.ToString(value); break;
|
||||||
|
case "Rank": _Rank = value.ToInt(); break;
|
||||||
|
case "IsNotAllowDel": _IsNotAllowDel = value.ToInt(); break;
|
||||||
|
case "Powers": _Powers = Convert.ToString(value); break;
|
||||||
|
case "IsDel": _IsDel = value.ToInt(); break;
|
||||||
|
case "Tel": _Tel = Convert.ToString(value); break;
|
||||||
|
case "Fax": _Fax = Convert.ToString(value); break;
|
||||||
|
case "Email": _Email = Convert.ToString(value); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得部门字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName("Id");
|
||||||
|
|
||||||
|
/// <summary>部门名称</summary>
|
||||||
|
public static readonly Field DepartmentName = FindByName("DepartmentName");
|
||||||
|
|
||||||
|
/// <summary>上级部门ID</summary>
|
||||||
|
public static readonly Field PId = FindByName("PId");
|
||||||
|
|
||||||
|
/// <summary>级别</summary>
|
||||||
|
public static readonly Field Level = FindByName("Level");
|
||||||
|
|
||||||
|
/// <summary>路径</summary>
|
||||||
|
public static readonly Field Location = FindByName("Location");
|
||||||
|
|
||||||
|
/// <summary>部门说明</summary>
|
||||||
|
public static readonly Field DepartmentDescription = FindByName("DepartmentDescription");
|
||||||
|
|
||||||
|
/// <summary>部门图片</summary>
|
||||||
|
public static readonly Field Pic = FindByName("Pic");
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public static readonly Field Rank = FindByName("Rank");
|
||||||
|
|
||||||
|
/// <summary>是否不允许删除</summary>
|
||||||
|
public static readonly Field IsNotAllowDel = FindByName("IsNotAllowDel");
|
||||||
|
|
||||||
|
/// <summary>部门权限</summary>
|
||||||
|
public static readonly Field Powers = FindByName("Powers");
|
||||||
|
|
||||||
|
/// <summary>是否删除</summary>
|
||||||
|
public static readonly Field IsDel = FindByName("IsDel");
|
||||||
|
|
||||||
|
/// <summary>联系电话</summary>
|
||||||
|
public static readonly Field Tel = FindByName("Tel");
|
||||||
|
|
||||||
|
/// <summary>传真</summary>
|
||||||
|
public static readonly Field Fax = FindByName("Fax");
|
||||||
|
|
||||||
|
/// <summary>邮件</summary>
|
||||||
|
public static readonly Field Email = FindByName("Email");
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得部门字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>部门名称</summary>
|
||||||
|
public const String DepartmentName = "DepartmentName";
|
||||||
|
|
||||||
|
/// <summary>上级部门ID</summary>
|
||||||
|
public const String PId = "PId";
|
||||||
|
|
||||||
|
/// <summary>级别</summary>
|
||||||
|
public const String Level = "Level";
|
||||||
|
|
||||||
|
/// <summary>路径</summary>
|
||||||
|
public const String Location = "Location";
|
||||||
|
|
||||||
|
/// <summary>部门说明</summary>
|
||||||
|
public const String DepartmentDescription = "DepartmentDescription";
|
||||||
|
|
||||||
|
/// <summary>部门图片</summary>
|
||||||
|
public const String Pic = "Pic";
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public const String Rank = "Rank";
|
||||||
|
|
||||||
|
/// <summary>是否不允许删除</summary>
|
||||||
|
public const String IsNotAllowDel = "IsNotAllowDel";
|
||||||
|
|
||||||
|
/// <summary>部门权限</summary>
|
||||||
|
public const String Powers = "Powers";
|
||||||
|
|
||||||
|
/// <summary>是否删除</summary>
|
||||||
|
public const String IsDel = "IsDel";
|
||||||
|
|
||||||
|
/// <summary>联系电话</summary>
|
||||||
|
public const String Tel = "Tel";
|
||||||
|
|
||||||
|
/// <summary>传真</summary>
|
||||||
|
public const String Fax = "Fax";
|
||||||
|
|
||||||
|
/// <summary>邮件</summary>
|
||||||
|
public const String Email = "Email";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>部门接口</summary>
|
||||||
|
public partial interface IDepartment
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
Int32 Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>部门名称</summary>
|
||||||
|
String DepartmentName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>上级部门ID</summary>
|
||||||
|
Int32 PId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>级别</summary>
|
||||||
|
Int32 Level { get; set; }
|
||||||
|
|
||||||
|
/// <summary>路径</summary>
|
||||||
|
String Location { get; set; }
|
||||||
|
|
||||||
|
/// <summary>部门说明</summary>
|
||||||
|
String DepartmentDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>部门图片</summary>
|
||||||
|
String Pic { get; set; }
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
Int32 Rank { get; set; }
|
||||||
|
|
||||||
|
/// <summary>是否不允许删除</summary>
|
||||||
|
Int32 IsNotAllowDel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>部门权限</summary>
|
||||||
|
String Powers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>是否删除</summary>
|
||||||
|
Int32 IsDel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>联系电话</summary>
|
||||||
|
String Tel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>传真</summary>
|
||||||
|
String Fax { get; set; }
|
||||||
|
|
||||||
|
/// <summary>邮件</summary>
|
||||||
|
String Email { 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;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -183,9 +183,49 @@ namespace COMCMS.Core
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 高级查询
|
#region 高级查询
|
||||||
|
/// <summary>
|
||||||
|
/// 通过FileName查找
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filename"></param>
|
||||||
|
/// <param name="kid"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Product FindByFileName(string filename, int kid = 0)
|
||||||
|
{
|
||||||
|
var where = _.FileName == filename;
|
||||||
|
if (kid > 0) where &= _.KId == kid;
|
||||||
|
return Find(where);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 业务操作
|
#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
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+186
-166
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
@@ -20,520 +21,528 @@ namespace COMCMS.Core
|
|||||||
[DisplayName("编号")]
|
[DisplayName("编号")]
|
||||||
[Description("编号")]
|
[Description("编号")]
|
||||||
[DataObjectField(true, true, false, 0)]
|
[DataObjectField(true, true, false, 0)]
|
||||||
[BindColumn("Id", "编号", "int")]
|
[BindColumn("Id", "编号", "")]
|
||||||
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
public Int32 Id { get => _Id; set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
private Int32 _KId;
|
private Int32 _KId;
|
||||||
/// <summary>栏目ID</summary>
|
/// <summary>栏目ID</summary>
|
||||||
[DisplayName("栏目ID")]
|
[DisplayName("栏目ID")]
|
||||||
[Description("栏目ID")]
|
[Description("栏目ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("KId", "栏目ID", "int")]
|
[BindColumn("KId", "栏目ID", "")]
|
||||||
public Int32 KId { get { return _KId; } set { if (OnPropertyChanging(__.KId, value)) { _KId = value; OnPropertyChanged(__.KId); } } }
|
public Int32 KId { get => _KId; set { if (OnPropertyChanging(__.KId, value)) { _KId = value; OnPropertyChanged(__.KId); } } }
|
||||||
|
|
||||||
private Int32 _BId;
|
private Int32 _BId;
|
||||||
/// <summary>品牌ID</summary>
|
/// <summary>品牌ID</summary>
|
||||||
[DisplayName("品牌ID")]
|
[DisplayName("品牌ID")]
|
||||||
[Description("品牌ID")]
|
[Description("品牌ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("BId", "品牌ID", "int")]
|
[BindColumn("BId", "品牌ID", "")]
|
||||||
public Int32 BId { get { return _BId; } set { if (OnPropertyChanging(__.BId, value)) { _BId = value; OnPropertyChanged(__.BId); } } }
|
public Int32 BId { get => _BId; set { if (OnPropertyChanging(__.BId, value)) { _BId = value; OnPropertyChanged(__.BId); } } }
|
||||||
|
|
||||||
private Int32 _ShopId;
|
private Int32 _ShopId;
|
||||||
/// <summary>店铺ID</summary>
|
/// <summary>店铺ID</summary>
|
||||||
[DisplayName("店铺ID")]
|
[DisplayName("店铺ID")]
|
||||||
[Description("店铺ID")]
|
[Description("店铺ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("ShopId", "店铺ID", "int")]
|
[BindColumn("ShopId", "店铺ID", "")]
|
||||||
public Int32 ShopId { get { return _ShopId; } set { if (OnPropertyChanging(__.ShopId, value)) { _ShopId = value; OnPropertyChanged(__.ShopId); } } }
|
public Int32 ShopId { get => _ShopId; set { if (OnPropertyChanging(__.ShopId, value)) { _ShopId = value; OnPropertyChanged(__.ShopId); } } }
|
||||||
|
|
||||||
private Int32 _CId;
|
private Int32 _CId;
|
||||||
/// <summary>颜色ID</summary>
|
/// <summary>颜色ID</summary>
|
||||||
[DisplayName("颜色ID")]
|
[DisplayName("颜色ID")]
|
||||||
[Description("颜色ID")]
|
[Description("颜色ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("CId", "颜色ID", "int")]
|
[BindColumn("CId", "颜色ID", "")]
|
||||||
public Int32 CId { get { return _CId; } set { if (OnPropertyChanging(__.CId, value)) { _CId = value; OnPropertyChanged(__.CId); } } }
|
public Int32 CId { get => _CId; set { if (OnPropertyChanging(__.CId, value)) { _CId = value; OnPropertyChanged(__.CId); } } }
|
||||||
|
|
||||||
private Int32 _SupportId;
|
private Int32 _SupportId;
|
||||||
/// <summary>供货商ID</summary>
|
/// <summary>供货商ID</summary>
|
||||||
[DisplayName("供货商ID")]
|
[DisplayName("供货商ID")]
|
||||||
[Description("供货商ID")]
|
[Description("供货商ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("SupportId", "供货商ID", "int")]
|
[BindColumn("SupportId", "供货商ID", "")]
|
||||||
public Int32 SupportId { get { return _SupportId; } set { if (OnPropertyChanging(__.SupportId, value)) { _SupportId = value; OnPropertyChanged(__.SupportId); } } }
|
public Int32 SupportId { get => _SupportId; set { if (OnPropertyChanging(__.SupportId, value)) { _SupportId = value; OnPropertyChanged(__.SupportId); } } }
|
||||||
|
|
||||||
private String _Title;
|
private String _Title;
|
||||||
/// <summary>标题</summary>
|
/// <summary>标题</summary>
|
||||||
[DisplayName("标题")]
|
[DisplayName("标题")]
|
||||||
[Description("标题")]
|
[Description("标题")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Title", "标题", "nvarchar(250)", Master = true)]
|
[BindColumn("Title", "标题", "", Master = true)]
|
||||||
public String Title { get { return _Title; } set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } }
|
public String Title { get => _Title; set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } }
|
||||||
|
|
||||||
private String _ItemNO;
|
private String _ItemNO;
|
||||||
/// <summary>编号</summary>
|
/// <summary>编号</summary>
|
||||||
[DisplayName("编号")]
|
[DisplayName("编号")]
|
||||||
[Description("编号")]
|
[Description("编号")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("ItemNO", "编号", "nvarchar(50)")]
|
[BindColumn("ItemNO", "编号", "")]
|
||||||
public String ItemNO { get { return _ItemNO; } set { if (OnPropertyChanging(__.ItemNO, value)) { _ItemNO = value; OnPropertyChanged(__.ItemNO); } } }
|
public String ItemNO { get => _ItemNO; set { if (OnPropertyChanging(__.ItemNO, value)) { _ItemNO = value; OnPropertyChanged(__.ItemNO); } } }
|
||||||
|
|
||||||
private String _SubTitle;
|
private String _SubTitle;
|
||||||
/// <summary>副标题</summary>
|
/// <summary>副标题</summary>
|
||||||
[DisplayName("副标题")]
|
[DisplayName("副标题")]
|
||||||
[Description("副标题")]
|
[Description("副标题")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("SubTitle", "副标题", "nvarchar(250)")]
|
[BindColumn("SubTitle", "副标题", "")]
|
||||||
public String SubTitle { get { return _SubTitle; } set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } }
|
public String SubTitle { get => _SubTitle; set { if (OnPropertyChanging(__.SubTitle, value)) { _SubTitle = value; OnPropertyChanged(__.SubTitle); } } }
|
||||||
|
|
||||||
private String _Unit;
|
private String _Unit;
|
||||||
/// <summary>商品单位</summary>
|
/// <summary>商品单位</summary>
|
||||||
[DisplayName("商品单位")]
|
[DisplayName("商品单位")]
|
||||||
[Description("商品单位")]
|
[Description("商品单位")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Unit", "商品单位", "nvarchar(250)")]
|
[BindColumn("Unit", "商品单位", "")]
|
||||||
public String Unit { get { return _Unit; } set { if (OnPropertyChanging(__.Unit, value)) { _Unit = value; OnPropertyChanged(__.Unit); } } }
|
public String Unit { get => _Unit; set { if (OnPropertyChanging(__.Unit, value)) { _Unit = value; OnPropertyChanged(__.Unit); } } }
|
||||||
|
|
||||||
private String _Spec;
|
private String _Spec;
|
||||||
/// <summary>商品规格尺寸</summary>
|
/// <summary>商品规格尺寸</summary>
|
||||||
[DisplayName("商品规格尺寸")]
|
[DisplayName("商品规格尺寸")]
|
||||||
[Description("商品规格尺寸")]
|
[Description("商品规格尺寸")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Spec", "商品规格尺寸", "nvarchar(250)")]
|
[BindColumn("Spec", "商品规格尺寸", "")]
|
||||||
public String Spec { get { return _Spec; } set { if (OnPropertyChanging(__.Spec, value)) { _Spec = value; OnPropertyChanged(__.Spec); } } }
|
public String Spec { get => _Spec; set { if (OnPropertyChanging(__.Spec, value)) { _Spec = value; OnPropertyChanged(__.Spec); } } }
|
||||||
|
|
||||||
private String _Color;
|
private String _Color;
|
||||||
/// <summary>颜色</summary>
|
/// <summary>颜色</summary>
|
||||||
[DisplayName("颜色")]
|
[DisplayName("颜色")]
|
||||||
[Description("颜色")]
|
[Description("颜色")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Color", "颜色", "nvarchar(250)")]
|
[BindColumn("Color", "颜色", "")]
|
||||||
public String Color { get { return _Color; } set { if (OnPropertyChanging(__.Color, value)) { _Color = value; OnPropertyChanged(__.Color); } } }
|
public String Color { get => _Color; set { if (OnPropertyChanging(__.Color, value)) { _Color = value; OnPropertyChanged(__.Color); } } }
|
||||||
|
|
||||||
private String _Weight;
|
private String _Weight;
|
||||||
/// <summary>重量</summary>
|
/// <summary>重量</summary>
|
||||||
[DisplayName("重量")]
|
[DisplayName("重量")]
|
||||||
[Description("重量")]
|
[Description("重量")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("Weight", "重量", "nvarchar(50)")]
|
[BindColumn("Weight", "重量", "")]
|
||||||
public String Weight { get { return _Weight; } set { if (OnPropertyChanging(__.Weight, value)) { _Weight = value; OnPropertyChanged(__.Weight); } } }
|
public String Weight { get => _Weight; set { if (OnPropertyChanging(__.Weight, value)) { _Weight = value; OnPropertyChanged(__.Weight); } } }
|
||||||
|
|
||||||
private Decimal _Price;
|
private Decimal _Price;
|
||||||
/// <summary>价格</summary>
|
/// <summary>价格</summary>
|
||||||
[DisplayName("价格")]
|
[DisplayName("价格")]
|
||||||
[Description("价格")]
|
[Description("价格")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Price", "价格", "money")]
|
[BindColumn("Price", "价格", "")]
|
||||||
public Decimal Price { get { return _Price; } set { if (OnPropertyChanging(__.Price, value)) { _Price = value; OnPropertyChanged(__.Price); } } }
|
public Decimal Price { get => _Price; set { if (OnPropertyChanging(__.Price, value)) { _Price = value; OnPropertyChanged(__.Price); } } }
|
||||||
|
|
||||||
private Decimal _MarketPrice;
|
private Decimal _MarketPrice;
|
||||||
/// <summary>市场价格</summary>
|
/// <summary>市场价格</summary>
|
||||||
[DisplayName("市场价格")]
|
[DisplayName("市场价格")]
|
||||||
[Description("市场价格")]
|
[Description("市场价格")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("MarketPrice", "市场价格", "money")]
|
[BindColumn("MarketPrice", "市场价格", "")]
|
||||||
public Decimal MarketPrice { get { return _MarketPrice; } set { if (OnPropertyChanging(__.MarketPrice, value)) { _MarketPrice = value; OnPropertyChanged(__.MarketPrice); } } }
|
public Decimal MarketPrice { get => _MarketPrice; set { if (OnPropertyChanging(__.MarketPrice, value)) { _MarketPrice = value; OnPropertyChanged(__.MarketPrice); } } }
|
||||||
|
|
||||||
private Decimal _SpecialPrice;
|
private Decimal _SpecialPrice;
|
||||||
/// <summary>特价,如有特价,以特价为准</summary>
|
/// <summary>特价,如有特价,以特价为准</summary>
|
||||||
[DisplayName("特价")]
|
[DisplayName("特价")]
|
||||||
[Description("特价,如有特价,以特价为准")]
|
[Description("特价,如有特价,以特价为准")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("SpecialPrice", "特价,如有特价,以特价为准", "money")]
|
[BindColumn("SpecialPrice", "特价,如有特价,以特价为准", "")]
|
||||||
public Decimal SpecialPrice { get { return _SpecialPrice; } set { if (OnPropertyChanging(__.SpecialPrice, value)) { _SpecialPrice = value; OnPropertyChanged(__.SpecialPrice); } } }
|
public Decimal SpecialPrice { get => _SpecialPrice; set { if (OnPropertyChanging(__.SpecialPrice, value)) { _SpecialPrice = value; OnPropertyChanged(__.SpecialPrice); } } }
|
||||||
|
|
||||||
private Decimal _Fare;
|
private Decimal _Fare;
|
||||||
/// <summary>运费</summary>
|
/// <summary>运费</summary>
|
||||||
[DisplayName("运费")]
|
[DisplayName("运费")]
|
||||||
[Description("运费")]
|
[Description("运费")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Fare", "运费", "money")]
|
[BindColumn("Fare", "运费", "")]
|
||||||
public Decimal Fare { get { return _Fare; } set { if (OnPropertyChanging(__.Fare, value)) { _Fare = value; OnPropertyChanged(__.Fare); } } }
|
public Decimal Fare { get => _Fare; set { if (OnPropertyChanging(__.Fare, value)) { _Fare = value; OnPropertyChanged(__.Fare); } } }
|
||||||
|
|
||||||
private Decimal _Discount;
|
private Decimal _Discount;
|
||||||
/// <summary>折扣</summary>
|
/// <summary>折扣</summary>
|
||||||
[DisplayName("折扣")]
|
[DisplayName("折扣")]
|
||||||
[Description("折扣")]
|
[Description("折扣")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Discount", "折扣", "money")]
|
[BindColumn("Discount", "折扣", "")]
|
||||||
public Decimal Discount { get { return _Discount; } set { if (OnPropertyChanging(__.Discount, value)) { _Discount = value; OnPropertyChanged(__.Discount); } } }
|
public Decimal Discount { get => _Discount; set { if (OnPropertyChanging(__.Discount, value)) { _Discount = value; OnPropertyChanged(__.Discount); } } }
|
||||||
|
|
||||||
private String _Material;
|
private String _Material;
|
||||||
/// <summary>材料</summary>
|
/// <summary>材料</summary>
|
||||||
[DisplayName("材料")]
|
[DisplayName("材料")]
|
||||||
[Description("材料")]
|
[Description("材料")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Material", "材料", "nvarchar(250)")]
|
[BindColumn("Material", "材料", "")]
|
||||||
public String Material { get { return _Material; } set { if (OnPropertyChanging(__.Material, value)) { _Material = value; OnPropertyChanged(__.Material); } } }
|
public String Material { get => _Material; set { if (OnPropertyChanging(__.Material, value)) { _Material = value; OnPropertyChanged(__.Material); } } }
|
||||||
|
|
||||||
private String _Front;
|
private String _Front;
|
||||||
/// <summary>封面</summary>
|
/// <summary>封面</summary>
|
||||||
[DisplayName("封面")]
|
[DisplayName("封面")]
|
||||||
[Description("封面")]
|
[Description("封面")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Front", "封面", "nvarchar(250)")]
|
[BindColumn("Front", "封面", "")]
|
||||||
public String Front { get { return _Front; } set { if (OnPropertyChanging(__.Front, value)) { _Front = value; OnPropertyChanged(__.Front); } } }
|
public String Front { get => _Front; set { if (OnPropertyChanging(__.Front, value)) { _Front = value; OnPropertyChanged(__.Front); } } }
|
||||||
|
|
||||||
private Int32 _Credits;
|
private Int32 _Credits;
|
||||||
/// <summary>积分</summary>
|
/// <summary>积分</summary>
|
||||||
[DisplayName("积分")]
|
[DisplayName("积分")]
|
||||||
[Description("积分")]
|
[Description("积分")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Credits", "积分", "int")]
|
[BindColumn("Credits", "积分", "")]
|
||||||
public Int32 Credits { get { return _Credits; } set { if (OnPropertyChanging(__.Credits, value)) { _Credits = value; OnPropertyChanged(__.Credits); } } }
|
public Int32 Credits { get => _Credits; set { if (OnPropertyChanging(__.Credits, value)) { _Credits = value; OnPropertyChanged(__.Credits); } } }
|
||||||
|
|
||||||
private Int32 _Stock;
|
private Int32 _Stock;
|
||||||
/// <summary>库存</summary>
|
/// <summary>库存</summary>
|
||||||
[DisplayName("库存")]
|
[DisplayName("库存")]
|
||||||
[Description("库存")]
|
[Description("库存")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Stock", "库存", "int")]
|
[BindColumn("Stock", "库存", "")]
|
||||||
public Int32 Stock { get { return _Stock; } set { if (OnPropertyChanging(__.Stock, value)) { _Stock = value; OnPropertyChanged(__.Stock); } } }
|
public Int32 Stock { get => _Stock; set { if (OnPropertyChanging(__.Stock, value)) { _Stock = value; OnPropertyChanged(__.Stock); } } }
|
||||||
|
|
||||||
private Int32 _WarnStock;
|
private Int32 _WarnStock;
|
||||||
/// <summary>警告库存</summary>
|
/// <summary>警告库存</summary>
|
||||||
[DisplayName("警告库存")]
|
[DisplayName("警告库存")]
|
||||||
[Description("警告库存")]
|
[Description("警告库存")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("WarnStock", "警告库存", "int")]
|
[BindColumn("WarnStock", "警告库存", "")]
|
||||||
public Int32 WarnStock { get { return _WarnStock; } set { if (OnPropertyChanging(__.WarnStock, value)) { _WarnStock = value; OnPropertyChanged(__.WarnStock); } } }
|
public Int32 WarnStock { get => _WarnStock; set { if (OnPropertyChanging(__.WarnStock, value)) { _WarnStock = value; OnPropertyChanged(__.WarnStock); } } }
|
||||||
|
|
||||||
private Int32 _IsSubProduct;
|
private Int32 _IsSubProduct;
|
||||||
/// <summary>是否为子商品</summary>
|
/// <summary>是否为子商品</summary>
|
||||||
[DisplayName("是否为子商品")]
|
[DisplayName("是否为子商品")]
|
||||||
[Description("是否为子商品")]
|
[Description("是否为子商品")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsSubProduct", "是否为子商品", "int")]
|
[BindColumn("IsSubProduct", "是否为子商品", "")]
|
||||||
public Int32 IsSubProduct { get { return _IsSubProduct; } set { if (OnPropertyChanging(__.IsSubProduct, value)) { _IsSubProduct = value; OnPropertyChanged(__.IsSubProduct); } } }
|
public Int32 IsSubProduct { get => _IsSubProduct; set { if (OnPropertyChanging(__.IsSubProduct, value)) { _IsSubProduct = value; OnPropertyChanged(__.IsSubProduct); } } }
|
||||||
|
|
||||||
private Int32 _PPId;
|
private Int32 _PPId;
|
||||||
/// <summary>父商品ID。如果为子商品,则需要填写父商品ID。实现多颜色功能</summary>
|
/// <summary>父商品ID。如果为子商品,则需要填写父商品ID。实现多颜色功能</summary>
|
||||||
[DisplayName("父商品ID")]
|
[DisplayName("父商品ID")]
|
||||||
[Description("父商品ID。如果为子商品,则需要填写父商品ID。实现多颜色功能")]
|
[Description("父商品ID。如果为子商品,则需要填写父商品ID。实现多颜色功能")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("PPId", "父商品ID。如果为子商品,则需要填写父商品ID。实现多颜色功能", "int")]
|
[BindColumn("PPId", "父商品ID。如果为子商品,则需要填写父商品ID。实现多颜色功能", "")]
|
||||||
public Int32 PPId { get { return _PPId; } set { if (OnPropertyChanging(__.PPId, value)) { _PPId = value; OnPropertyChanged(__.PPId); } } }
|
public Int32 PPId { get => _PPId; set { if (OnPropertyChanging(__.PPId, value)) { _PPId = value; OnPropertyChanged(__.PPId); } } }
|
||||||
|
|
||||||
private String _Content;
|
private String _Content;
|
||||||
/// <summary>内容</summary>
|
/// <summary>内容</summary>
|
||||||
[DisplayName("内容")]
|
[DisplayName("内容")]
|
||||||
[Description("内容")]
|
[Description("内容")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("Content", "内容", "ntext")]
|
[BindColumn("Content", "内容", "")]
|
||||||
public String Content { get { return _Content; } set { if (OnPropertyChanging(__.Content, value)) { _Content = value; OnPropertyChanged(__.Content); } } }
|
public String Content { get => _Content; set { if (OnPropertyChanging(__.Content, value)) { _Content = value; OnPropertyChanged(__.Content); } } }
|
||||||
|
|
||||||
private String _Parameters;
|
private String _Parameters;
|
||||||
/// <summary>商品参数</summary>
|
/// <summary>商品参数</summary>
|
||||||
[DisplayName("商品参数")]
|
[DisplayName("商品参数")]
|
||||||
[Description("商品参数")]
|
[Description("商品参数")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("Parameters", "商品参数", "ntext")]
|
[BindColumn("Parameters", "商品参数", "")]
|
||||||
public String Parameters { get { return _Parameters; } set { if (OnPropertyChanging(__.Parameters, value)) { _Parameters = value; OnPropertyChanged(__.Parameters); } } }
|
public String Parameters { get => _Parameters; set { if (OnPropertyChanging(__.Parameters, value)) { _Parameters = value; OnPropertyChanged(__.Parameters); } } }
|
||||||
|
|
||||||
private String _Keyword;
|
private String _Keyword;
|
||||||
/// <summary>描述</summary>
|
/// <summary>描述</summary>
|
||||||
[DisplayName("描述")]
|
[DisplayName("描述")]
|
||||||
[Description("描述")]
|
[Description("描述")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Keyword", "描述", "nvarchar(250)")]
|
[BindColumn("Keyword", "描述", "")]
|
||||||
public String Keyword { get { return _Keyword; } set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } }
|
public String Keyword { get => _Keyword; set { if (OnPropertyChanging(__.Keyword, value)) { _Keyword = value; OnPropertyChanged(__.Keyword); } } }
|
||||||
|
|
||||||
private String _Description;
|
private String _Description;
|
||||||
/// <summary>介绍</summary>
|
/// <summary>介绍</summary>
|
||||||
[DisplayName("介绍")]
|
[DisplayName("介绍")]
|
||||||
[Description("介绍")]
|
[Description("介绍")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Description", "介绍", "nvarchar(250)")]
|
[BindColumn("Description", "介绍", "")]
|
||||||
public String Description { get { return _Description; } set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
public String Description { get => _Description; set { if (OnPropertyChanging(__.Description, value)) { _Description = value; OnPropertyChanged(__.Description); } } }
|
||||||
|
|
||||||
private String _LinkURL;
|
private String _LinkURL;
|
||||||
/// <summary>跳转链接</summary>
|
/// <summary>跳转链接</summary>
|
||||||
[DisplayName("跳转链接")]
|
[DisplayName("跳转链接")]
|
||||||
[Description("跳转链接")]
|
[Description("跳转链接")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("LinkURL", "跳转链接", "nvarchar(250)")]
|
[BindColumn("LinkURL", "跳转链接", "")]
|
||||||
public String LinkURL { get { return _LinkURL; } set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } }
|
public String LinkURL { get => _LinkURL; set { if (OnPropertyChanging(__.LinkURL, value)) { _LinkURL = value; OnPropertyChanged(__.LinkURL); } } }
|
||||||
|
|
||||||
private String _TitleColor;
|
private String _TitleColor;
|
||||||
/// <summary>类别名称颜色</summary>
|
/// <summary>类别名称颜色</summary>
|
||||||
[DisplayName("类别名称颜色")]
|
[DisplayName("类别名称颜色")]
|
||||||
[Description("类别名称颜色")]
|
[Description("类别名称颜色")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("TitleColor", "类别名称颜色", "nvarchar(50)")]
|
[BindColumn("TitleColor", "类别名称颜色", "")]
|
||||||
public String TitleColor { get { return _TitleColor; } set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } }
|
public String TitleColor { get => _TitleColor; set { if (OnPropertyChanging(__.TitleColor, value)) { _TitleColor = value; OnPropertyChanged(__.TitleColor); } } }
|
||||||
|
|
||||||
private String _TemplateFile;
|
private String _TemplateFile;
|
||||||
/// <summary>模板</summary>
|
/// <summary>模板</summary>
|
||||||
[DisplayName("模板")]
|
[DisplayName("模板")]
|
||||||
[Description("模板")]
|
[Description("模板")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("TemplateFile", "模板", "nvarchar(250)")]
|
[BindColumn("TemplateFile", "模板", "")]
|
||||||
public String TemplateFile { get { return _TemplateFile; } set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } }
|
public String TemplateFile { get => _TemplateFile; set { if (OnPropertyChanging(__.TemplateFile, value)) { _TemplateFile = value; OnPropertyChanged(__.TemplateFile); } } }
|
||||||
|
|
||||||
private Int32 _IsRecommend;
|
private Int32 _IsRecommend;
|
||||||
/// <summary>是否推荐</summary>
|
/// <summary>是否推荐</summary>
|
||||||
[DisplayName("是否推荐")]
|
[DisplayName("是否推荐")]
|
||||||
[Description("是否推荐")]
|
[Description("是否推荐")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsRecommend", "是否推荐", "int")]
|
[BindColumn("IsRecommend", "是否推荐", "")]
|
||||||
public Int32 IsRecommend { get { return _IsRecommend; } set { if (OnPropertyChanging(__.IsRecommend, value)) { _IsRecommend = value; OnPropertyChanged(__.IsRecommend); } } }
|
public Int32 IsRecommend { get => _IsRecommend; set { if (OnPropertyChanging(__.IsRecommend, value)) { _IsRecommend = value; OnPropertyChanged(__.IsRecommend); } } }
|
||||||
|
|
||||||
private Int32 _IsHide;
|
private Int32 _IsHide;
|
||||||
/// <summary>是否隐藏</summary>
|
/// <summary>是否隐藏</summary>
|
||||||
[DisplayName("是否隐藏")]
|
[DisplayName("是否隐藏")]
|
||||||
[Description("是否隐藏")]
|
[Description("是否隐藏")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsHide", "是否隐藏", "int")]
|
[BindColumn("IsHide", "是否隐藏", "")]
|
||||||
public Int32 IsHide { get { return _IsHide; } set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } }
|
public Int32 IsHide { get => _IsHide; set { if (OnPropertyChanging(__.IsHide, value)) { _IsHide = value; OnPropertyChanged(__.IsHide); } } }
|
||||||
|
|
||||||
private Int32 _IsLock;
|
private Int32 _IsLock;
|
||||||
/// <summary>是否锁定,不允许删除</summary>
|
/// <summary>是否锁定,不允许删除</summary>
|
||||||
[DisplayName("是否锁定")]
|
[DisplayName("是否锁定")]
|
||||||
[Description("是否锁定,不允许删除")]
|
[Description("是否锁定,不允许删除")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsLock", "是否锁定,不允许删除", "int")]
|
[BindColumn("IsLock", "是否锁定,不允许删除", "")]
|
||||||
public Int32 IsLock { get { return _IsLock; } set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } }
|
public Int32 IsLock { get => _IsLock; set { if (OnPropertyChanging(__.IsLock, value)) { _IsLock = value; OnPropertyChanged(__.IsLock); } } }
|
||||||
|
|
||||||
private Int32 _IsDel;
|
private Int32 _IsDel;
|
||||||
/// <summary>是否删除,已经删除到回收站</summary>
|
/// <summary>是否删除,已经删除到回收站</summary>
|
||||||
[DisplayName("是否删除")]
|
[DisplayName("是否删除")]
|
||||||
[Description("是否删除,已经删除到回收站")]
|
[Description("是否删除,已经删除到回收站")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsDel", "是否删除,已经删除到回收站", "int")]
|
[BindColumn("IsDel", "是否删除,已经删除到回收站", "")]
|
||||||
public Int32 IsDel { get { return _IsDel; } set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } }
|
public Int32 IsDel { get => _IsDel; set { if (OnPropertyChanging(__.IsDel, value)) { _IsDel = value; OnPropertyChanged(__.IsDel); } } }
|
||||||
|
|
||||||
private Int32 _IsTop;
|
private Int32 _IsTop;
|
||||||
/// <summary>是否置顶</summary>
|
/// <summary>是否置顶</summary>
|
||||||
[DisplayName("是否置顶")]
|
[DisplayName("是否置顶")]
|
||||||
[Description("是否置顶")]
|
[Description("是否置顶")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsTop", "是否置顶", "int")]
|
[BindColumn("IsTop", "是否置顶", "")]
|
||||||
public Int32 IsTop { get { return _IsTop; } set { if (OnPropertyChanging(__.IsTop, value)) { _IsTop = value; OnPropertyChanged(__.IsTop); } } }
|
public Int32 IsTop { get => _IsTop; set { if (OnPropertyChanging(__.IsTop, value)) { _IsTop = value; OnPropertyChanged(__.IsTop); } } }
|
||||||
|
|
||||||
private Int32 _IsBest;
|
private Int32 _IsBest;
|
||||||
/// <summary>是否精华</summary>
|
/// <summary>是否精华</summary>
|
||||||
[DisplayName("是否精华")]
|
[DisplayName("是否精华")]
|
||||||
[Description("是否精华")]
|
[Description("是否精华")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsBest", "是否精华", "int")]
|
[BindColumn("IsBest", "是否精华", "")]
|
||||||
public Int32 IsBest { get { return _IsBest; } set { if (OnPropertyChanging(__.IsBest, value)) { _IsBest = value; OnPropertyChanged(__.IsBest); } } }
|
public Int32 IsBest { get => _IsBest; set { if (OnPropertyChanging(__.IsBest, value)) { _IsBest = value; OnPropertyChanged(__.IsBest); } } }
|
||||||
|
|
||||||
private Int32 _IsComment;
|
private Int32 _IsComment;
|
||||||
/// <summary>是否允许评论</summary>
|
/// <summary>是否允许评论</summary>
|
||||||
[DisplayName("是否允许评论")]
|
[DisplayName("是否允许评论")]
|
||||||
[Description("是否允许评论")]
|
[Description("是否允许评论")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsComment", "是否允许评论", "int")]
|
[BindColumn("IsComment", "是否允许评论", "")]
|
||||||
public Int32 IsComment { get { return _IsComment; } set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } }
|
public Int32 IsComment { get => _IsComment; set { if (OnPropertyChanging(__.IsComment, value)) { _IsComment = value; OnPropertyChanged(__.IsComment); } } }
|
||||||
|
|
||||||
private Int32 _IsMember;
|
private Int32 _IsMember;
|
||||||
/// <summary>是否会员栏目</summary>
|
/// <summary>是否会员栏目</summary>
|
||||||
[DisplayName("是否会员栏目")]
|
[DisplayName("是否会员栏目")]
|
||||||
[Description("是否会员栏目")]
|
[Description("是否会员栏目")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsMember", "是否会员栏目", "int")]
|
[BindColumn("IsMember", "是否会员栏目", "")]
|
||||||
public Int32 IsMember { get { return _IsMember; } set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } }
|
public Int32 IsMember { get => _IsMember; set { if (OnPropertyChanging(__.IsMember, value)) { _IsMember = value; OnPropertyChanged(__.IsMember); } } }
|
||||||
|
|
||||||
private Int32 _IsNew;
|
private Int32 _IsNew;
|
||||||
/// <summary>是否新品</summary>
|
/// <summary>是否新品</summary>
|
||||||
[DisplayName("是否新品")]
|
[DisplayName("是否新品")]
|
||||||
[Description("是否新品")]
|
[Description("是否新品")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsNew", "是否新品", "int")]
|
[BindColumn("IsNew", "是否新品", "")]
|
||||||
public Int32 IsNew { get { return _IsNew; } set { if (OnPropertyChanging(__.IsNew, value)) { _IsNew = value; OnPropertyChanged(__.IsNew); } } }
|
public Int32 IsNew { get => _IsNew; set { if (OnPropertyChanging(__.IsNew, value)) { _IsNew = value; OnPropertyChanged(__.IsNew); } } }
|
||||||
|
|
||||||
private Int32 _IsSpecial;
|
private Int32 _IsSpecial;
|
||||||
/// <summary>是否特价</summary>
|
/// <summary>是否特价</summary>
|
||||||
[DisplayName("是否特价")]
|
[DisplayName("是否特价")]
|
||||||
[Description("是否特价")]
|
[Description("是否特价")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsSpecial", "是否特价", "int")]
|
[BindColumn("IsSpecial", "是否特价", "")]
|
||||||
public Int32 IsSpecial { get { return _IsSpecial; } set { if (OnPropertyChanging(__.IsSpecial, value)) { _IsSpecial = value; OnPropertyChanged(__.IsSpecial); } } }
|
public Int32 IsSpecial { get => _IsSpecial; set { if (OnPropertyChanging(__.IsSpecial, value)) { _IsSpecial = value; OnPropertyChanged(__.IsSpecial); } } }
|
||||||
|
|
||||||
private Int32 _IsPromote;
|
private Int32 _IsPromote;
|
||||||
/// <summary>是否促销</summary>
|
/// <summary>是否促销</summary>
|
||||||
[DisplayName("是否促销")]
|
[DisplayName("是否促销")]
|
||||||
[Description("是否促销")]
|
[Description("是否促销")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsPromote", "是否促销", "int")]
|
[BindColumn("IsPromote", "是否促销", "")]
|
||||||
public Int32 IsPromote { get { return _IsPromote; } set { if (OnPropertyChanging(__.IsPromote, value)) { _IsPromote = value; OnPropertyChanged(__.IsPromote); } } }
|
public Int32 IsPromote { get => _IsPromote; set { if (OnPropertyChanging(__.IsPromote, value)) { _IsPromote = value; OnPropertyChanged(__.IsPromote); } } }
|
||||||
|
|
||||||
private Int32 _IsHotSales;
|
private Int32 _IsHotSales;
|
||||||
/// <summary>是否热销</summary>
|
/// <summary>是否热销</summary>
|
||||||
[DisplayName("是否热销")]
|
[DisplayName("是否热销")]
|
||||||
[Description("是否热销")]
|
[Description("是否热销")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsHotSales", "是否热销", "int")]
|
[BindColumn("IsHotSales", "是否热销", "")]
|
||||||
public Int32 IsHotSales { get { return _IsHotSales; } set { if (OnPropertyChanging(__.IsHotSales, value)) { _IsHotSales = value; OnPropertyChanged(__.IsHotSales); } } }
|
public Int32 IsHotSales { get => _IsHotSales; set { if (OnPropertyChanging(__.IsHotSales, value)) { _IsHotSales = value; OnPropertyChanged(__.IsHotSales); } } }
|
||||||
|
|
||||||
private Int32 _IsBreakup;
|
private Int32 _IsBreakup;
|
||||||
/// <summary>是否缺货</summary>
|
/// <summary>是否缺货</summary>
|
||||||
[DisplayName("是否缺货")]
|
[DisplayName("是否缺货")]
|
||||||
[Description("是否缺货")]
|
[Description("是否缺货")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsBreakup", "是否缺货", "int")]
|
[BindColumn("IsBreakup", "是否缺货", "")]
|
||||||
public Int32 IsBreakup { get { return _IsBreakup; } set { if (OnPropertyChanging(__.IsBreakup, value)) { _IsBreakup = value; OnPropertyChanged(__.IsBreakup); } } }
|
public Int32 IsBreakup { get => _IsBreakup; set { if (OnPropertyChanging(__.IsBreakup, value)) { _IsBreakup = value; OnPropertyChanged(__.IsBreakup); } } }
|
||||||
|
|
||||||
private Int32 _IsShelves;
|
private Int32 _IsShelves;
|
||||||
/// <summary>是否下架</summary>
|
/// <summary>是否下架</summary>
|
||||||
[DisplayName("是否下架")]
|
[DisplayName("是否下架")]
|
||||||
[Description("是否下架")]
|
[Description("是否下架")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsShelves", "是否下架", "int")]
|
[BindColumn("IsShelves", "是否下架", "")]
|
||||||
public Int32 IsShelves { get { return _IsShelves; } set { if (OnPropertyChanging(__.IsShelves, value)) { _IsShelves = value; OnPropertyChanged(__.IsShelves); } } }
|
public Int32 IsShelves { get => _IsShelves; set { if (OnPropertyChanging(__.IsShelves, value)) { _IsShelves = value; OnPropertyChanged(__.IsShelves); } } }
|
||||||
|
|
||||||
private Int32 _IsVerify;
|
private Int32 _IsVerify;
|
||||||
/// <summary>是否审核,1为已经审核前台显示</summary>
|
/// <summary>是否审核,1为已经审核前台显示</summary>
|
||||||
[DisplayName("是否审核")]
|
[DisplayName("是否审核")]
|
||||||
[Description("是否审核,1为已经审核前台显示")]
|
[Description("是否审核,1为已经审核前台显示")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsVerify", "是否审核,1为已经审核前台显示", "int")]
|
[BindColumn("IsVerify", "是否审核,1为已经审核前台显示", "")]
|
||||||
public Int32 IsVerify { get { return _IsVerify; } set { if (OnPropertyChanging(__.IsVerify, value)) { _IsVerify = value; OnPropertyChanged(__.IsVerify); } } }
|
public Int32 IsVerify { get => _IsVerify; set { if (OnPropertyChanging(__.IsVerify, value)) { _IsVerify = value; OnPropertyChanged(__.IsVerify); } } }
|
||||||
|
|
||||||
private Int32 _Hits;
|
private Int32 _Hits;
|
||||||
/// <summary>点击数量</summary>
|
/// <summary>点击数量</summary>
|
||||||
[DisplayName("点击数量")]
|
[DisplayName("点击数量")]
|
||||||
[Description("点击数量")]
|
[Description("点击数量")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Hits", "点击数量", "int")]
|
[BindColumn("Hits", "点击数量", "")]
|
||||||
public Int32 Hits { get { return _Hits; } set { if (OnPropertyChanging(__.Hits, value)) { _Hits = value; OnPropertyChanged(__.Hits); } } }
|
public Int32 Hits { get => _Hits; set { if (OnPropertyChanging(__.Hits, value)) { _Hits = value; OnPropertyChanged(__.Hits); } } }
|
||||||
|
|
||||||
private Int32 _IsGift;
|
private Int32 _IsGift;
|
||||||
/// <summary>是否为礼品商品</summary>
|
/// <summary>是否为礼品商品</summary>
|
||||||
[DisplayName("是否为礼品商品")]
|
[DisplayName("是否为礼品商品")]
|
||||||
[Description("是否为礼品商品")]
|
[Description("是否为礼品商品")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsGift", "是否为礼品商品", "int")]
|
[BindColumn("IsGift", "是否为礼品商品", "")]
|
||||||
public Int32 IsGift { get { return _IsGift; } set { if (OnPropertyChanging(__.IsGift, value)) { _IsGift = value; OnPropertyChanged(__.IsGift); } } }
|
public Int32 IsGift { get => _IsGift; set { if (OnPropertyChanging(__.IsGift, value)) { _IsGift = value; OnPropertyChanged(__.IsGift); } } }
|
||||||
|
|
||||||
private Int32 _IsPart;
|
private Int32 _IsPart;
|
||||||
/// <summary>是否为配件</summary>
|
/// <summary>是否为配件</summary>
|
||||||
[DisplayName("是否为配件")]
|
[DisplayName("是否为配件")]
|
||||||
[Description("是否为配件")]
|
[Description("是否为配件")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("IsPart", "是否为配件", "int")]
|
[BindColumn("IsPart", "是否为配件", "")]
|
||||||
public Int32 IsPart { get { return _IsPart; } set { if (OnPropertyChanging(__.IsPart, value)) { _IsPart = value; OnPropertyChanged(__.IsPart); } } }
|
public Int32 IsPart { get => _IsPart; set { if (OnPropertyChanging(__.IsPart, value)) { _IsPart = value; OnPropertyChanged(__.IsPart); } } }
|
||||||
|
|
||||||
private Int32 _Sequence;
|
private Int32 _Sequence;
|
||||||
/// <summary>排序</summary>
|
/// <summary>排序</summary>
|
||||||
[DisplayName("排序")]
|
[DisplayName("排序")]
|
||||||
[Description("排序")]
|
[Description("排序")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("Sequence", "排序", "int")]
|
[BindColumn("Sequence", "排序", "")]
|
||||||
public Int32 Sequence { get { return _Sequence; } set { if (OnPropertyChanging(__.Sequence, value)) { _Sequence = value; OnPropertyChanged(__.Sequence); } } }
|
public Int32 Sequence { get => _Sequence; set { if (OnPropertyChanging(__.Sequence, value)) { _Sequence = value; OnPropertyChanged(__.Sequence); } } }
|
||||||
|
|
||||||
private Int32 _CommentCount;
|
private Int32 _CommentCount;
|
||||||
/// <summary>评论数量</summary>
|
/// <summary>评论数量</summary>
|
||||||
[DisplayName("评论数量")]
|
[DisplayName("评论数量")]
|
||||||
[Description("评论数量")]
|
[Description("评论数量")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("CommentCount", "评论数量", "int")]
|
[BindColumn("CommentCount", "评论数量", "")]
|
||||||
public Int32 CommentCount { get { return _CommentCount; } set { if (OnPropertyChanging(__.CommentCount, value)) { _CommentCount = value; OnPropertyChanged(__.CommentCount); } } }
|
public Int32 CommentCount { get => _CommentCount; set { if (OnPropertyChanging(__.CommentCount, value)) { _CommentCount = value; OnPropertyChanged(__.CommentCount); } } }
|
||||||
|
|
||||||
private String _Icon;
|
private String _Icon;
|
||||||
/// <summary>图标</summary>
|
/// <summary>图标</summary>
|
||||||
[DisplayName("图标")]
|
[DisplayName("图标")]
|
||||||
[Description("图标")]
|
[Description("图标")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("Icon", "图标", "nvarchar(100)")]
|
[BindColumn("Icon", "图标", "")]
|
||||||
public String Icon { get { return _Icon; } set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } }
|
public String Icon { get => _Icon; set { if (OnPropertyChanging(__.Icon, value)) { _Icon = value; OnPropertyChanged(__.Icon); } } }
|
||||||
|
|
||||||
private String _ClassName;
|
private String _ClassName;
|
||||||
/// <summary>样式名称</summary>
|
/// <summary>样式名称</summary>
|
||||||
[DisplayName("样式名称")]
|
[DisplayName("样式名称")]
|
||||||
[Description("样式名称")]
|
[Description("样式名称")]
|
||||||
[DataObjectField(false, false, true, 50)]
|
[DataObjectField(false, false, true, 50)]
|
||||||
[BindColumn("ClassName", "样式名称", "nvarchar(50)")]
|
[BindColumn("ClassName", "样式名称", "")]
|
||||||
public String ClassName { get { return _ClassName; } set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } }
|
public String ClassName { get => _ClassName; set { if (OnPropertyChanging(__.ClassName, value)) { _ClassName = value; OnPropertyChanged(__.ClassName); } } }
|
||||||
|
|
||||||
private String _BannerImg;
|
private String _BannerImg;
|
||||||
/// <summary>banner图片</summary>
|
/// <summary>banner图片</summary>
|
||||||
[DisplayName("banner图片")]
|
[DisplayName("banner图片")]
|
||||||
[Description("banner图片")]
|
[Description("banner图片")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("BannerImg", "banner图片", "nvarchar(250)")]
|
[BindColumn("BannerImg", "banner图片", "")]
|
||||||
public String BannerImg { get { return _BannerImg; } set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } }
|
public String BannerImg { get => _BannerImg; set { if (OnPropertyChanging(__.BannerImg, value)) { _BannerImg = value; OnPropertyChanged(__.BannerImg); } } }
|
||||||
|
|
||||||
private String _Pic;
|
private String _Pic;
|
||||||
/// <summary>图片</summary>
|
/// <summary>图片</summary>
|
||||||
[DisplayName("图片")]
|
[DisplayName("图片")]
|
||||||
[Description("图片")]
|
[Description("图片")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Pic", "图片", "nvarchar(250)")]
|
[BindColumn("Pic", "图片", "")]
|
||||||
public String Pic { get { return _Pic; } set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } }
|
public String Pic { get => _Pic; set { if (OnPropertyChanging(__.Pic, value)) { _Pic = value; OnPropertyChanged(__.Pic); } } }
|
||||||
|
|
||||||
private Int32 _AdsId;
|
private Int32 _AdsId;
|
||||||
/// <summary>广告ID</summary>
|
/// <summary>广告ID</summary>
|
||||||
[DisplayName("广告ID")]
|
[DisplayName("广告ID")]
|
||||||
[Description("广告ID")]
|
[Description("广告ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("AdsId", "广告ID", "int")]
|
[BindColumn("AdsId", "广告ID", "")]
|
||||||
public Int32 AdsId { get { return _AdsId; } set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } }
|
public Int32 AdsId { get => _AdsId; set { if (OnPropertyChanging(__.AdsId, value)) { _AdsId = value; OnPropertyChanged(__.AdsId); } } }
|
||||||
|
|
||||||
private String _Tags;
|
private String _Tags;
|
||||||
/// <summary>TAG</summary>
|
/// <summary>TAG</summary>
|
||||||
[DisplayName("TAG")]
|
[DisplayName("TAG")]
|
||||||
[Description("TAG")]
|
[Description("TAG")]
|
||||||
[DataObjectField(false, false, true, 250)]
|
[DataObjectField(false, false, true, 250)]
|
||||||
[BindColumn("Tags", "TAG", "nvarchar(250)")]
|
[BindColumn("Tags", "TAG", "")]
|
||||||
public String Tags { get { return _Tags; } set { if (OnPropertyChanging(__.Tags, value)) { _Tags = value; OnPropertyChanged(__.Tags); } } }
|
public String Tags { get => _Tags; set { if (OnPropertyChanging(__.Tags, value)) { _Tags = value; OnPropertyChanged(__.Tags); } } }
|
||||||
|
|
||||||
private String _ItemImg;
|
private String _ItemImg;
|
||||||
/// <summary>更多图片</summary>
|
/// <summary>更多图片</summary>
|
||||||
[DisplayName("更多图片")]
|
[DisplayName("更多图片")]
|
||||||
[Description("更多图片")]
|
[Description("更多图片")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("ItemImg", "更多图片", "ntext")]
|
[BindColumn("ItemImg", "更多图片", "")]
|
||||||
public String ItemImg { get { return _ItemImg; } set { if (OnPropertyChanging(__.ItemImg, value)) { _ItemImg = value; OnPropertyChanged(__.ItemImg); } } }
|
public String ItemImg { get => _ItemImg; set { if (OnPropertyChanging(__.ItemImg, value)) { _ItemImg = value; OnPropertyChanged(__.ItemImg); } } }
|
||||||
|
|
||||||
private String _Service;
|
private String _Service;
|
||||||
/// <summary>售后服务</summary>
|
/// <summary>售后服务</summary>
|
||||||
[DisplayName("售后服务")]
|
[DisplayName("售后服务")]
|
||||||
[Description("售后服务")]
|
[Description("售后服务")]
|
||||||
[DataObjectField(false, false, true, -1)]
|
[DataObjectField(false, false, true, -1)]
|
||||||
[BindColumn("Service", "售后服务", "ntext")]
|
[BindColumn("Service", "售后服务", "")]
|
||||||
public String Service { get { return _Service; } set { if (OnPropertyChanging(__.Service, value)) { _Service = value; OnPropertyChanged(__.Service); } } }
|
public String Service { get => _Service; set { if (OnPropertyChanging(__.Service, value)) { _Service = value; OnPropertyChanged(__.Service); } } }
|
||||||
|
|
||||||
private Int32 _AuthorId;
|
private Int32 _AuthorId;
|
||||||
/// <summary>添加管理员ID</summary>
|
/// <summary>添加管理员ID</summary>
|
||||||
[DisplayName("添加管理员ID")]
|
[DisplayName("添加管理员ID")]
|
||||||
[Description("添加管理员ID")]
|
[Description("添加管理员ID")]
|
||||||
[DataObjectField(false, false, false, 0)]
|
[DataObjectField(false, false, false, 0)]
|
||||||
[BindColumn("AuthorId", "添加管理员ID", "int")]
|
[BindColumn("AuthorId", "添加管理员ID", "")]
|
||||||
public Int32 AuthorId { get { return _AuthorId; } set { if (OnPropertyChanging(__.AuthorId, value)) { _AuthorId = value; OnPropertyChanged(__.AuthorId); } } }
|
public Int32 AuthorId { get => _AuthorId; set { if (OnPropertyChanging(__.AuthorId, value)) { _AuthorId = value; OnPropertyChanged(__.AuthorId); } } }
|
||||||
|
|
||||||
private DateTime _AddTime;
|
private DateTime _AddTime;
|
||||||
/// <summary>添加时间</summary>
|
/// <summary>添加时间</summary>
|
||||||
[DisplayName("添加时间")]
|
[DisplayName("添加时间")]
|
||||||
[Description("添加时间")]
|
[Description("添加时间")]
|
||||||
[DataObjectField(false, false, true, 0)]
|
[DataObjectField(false, false, true, 0)]
|
||||||
[BindColumn("AddTime", "添加时间", "datetime")]
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
public DateTime AddTime { get => _AddTime; set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
||||||
|
|
||||||
private DateTime _UpdateTime;
|
private DateTime _UpdateTime;
|
||||||
/// <summary>时间</summary>
|
/// <summary>时间</summary>
|
||||||
[DisplayName("时间")]
|
[DisplayName("时间")]
|
||||||
[Description("时间")]
|
[Description("时间")]
|
||||||
[DataObjectField(false, false, true, 0)]
|
[DataObjectField(false, false, true, 0)]
|
||||||
[BindColumn("UpdateTime", "时间", "datetime")]
|
[BindColumn("UpdateTime", "时间", "")]
|
||||||
public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
public DateTime UpdateTime { get => _UpdateTime; set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
||||||
|
|
||||||
private String _Location;
|
private String _Location;
|
||||||
/// <summary>路径</summary>
|
/// <summary>路径</summary>
|
||||||
[DisplayName("路径")]
|
[DisplayName("路径")]
|
||||||
[Description("路径")]
|
[Description("路径")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("Location", "路径", "nvarchar(100)")]
|
[BindColumn("Location", "路径", "")]
|
||||||
public String Location { get { return _Location; } set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } }
|
public String Location { get => _Location; set { if (OnPropertyChanging(__.Location, value)) { _Location = value; OnPropertyChanged(__.Location); } } }
|
||||||
|
|
||||||
private String _FilePath;
|
private String _FilePath;
|
||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
[DisplayName("存放目录")]
|
[DisplayName("存放目录")]
|
||||||
[Description("存放目录")]
|
[Description("存放目录")]
|
||||||
[DataObjectField(false, false, true, 100)]
|
[DataObjectField(false, false, true, 100)]
|
||||||
[BindColumn("FilePath", "存放目录", "nvarchar(100)")]
|
[BindColumn("FilePath", "存放目录", "")]
|
||||||
public String FilePath { get { return _FilePath; } set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } }
|
public String FilePath { get => _FilePath; set { if (OnPropertyChanging(__.FilePath, value)) { _FilePath = value; OnPropertyChanged(__.FilePath); } } }
|
||||||
|
|
||||||
|
private String _FileName;
|
||||||
|
/// <summary>文件名称</summary>
|
||||||
|
[DisplayName("文件名称")]
|
||||||
|
[Description("文件名称")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("FileName", "文件名称", "")]
|
||||||
|
public String FileName { get => _FileName; set { if (OnPropertyChanging(__.FileName, value)) { _FileName = value; OnPropertyChanged(__.FileName); } } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
#region 获取/设置 字段值
|
||||||
@@ -611,6 +620,7 @@ namespace COMCMS.Core
|
|||||||
case __.UpdateTime: return _UpdateTime;
|
case __.UpdateTime: return _UpdateTime;
|
||||||
case __.Location: return _Location;
|
case __.Location: return _Location;
|
||||||
case __.FilePath: return _FilePath;
|
case __.FilePath: return _FilePath;
|
||||||
|
case __.FileName: return _FileName;
|
||||||
default: return base[name];
|
default: return base[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -618,12 +628,12 @@ namespace COMCMS.Core
|
|||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case __.Id : _Id = Convert.ToInt32(value); break;
|
case __.Id: _Id = value.ToInt(); break;
|
||||||
case __.KId : _KId = Convert.ToInt32(value); break;
|
case __.KId: _KId = value.ToInt(); break;
|
||||||
case __.BId : _BId = Convert.ToInt32(value); break;
|
case __.BId: _BId = value.ToInt(); break;
|
||||||
case __.ShopId : _ShopId = Convert.ToInt32(value); break;
|
case __.ShopId: _ShopId = value.ToInt(); break;
|
||||||
case __.CId : _CId = Convert.ToInt32(value); break;
|
case __.CId: _CId = value.ToInt(); break;
|
||||||
case __.SupportId : _SupportId = Convert.ToInt32(value); break;
|
case __.SupportId: _SupportId = value.ToInt(); break;
|
||||||
case __.Title: _Title = Convert.ToString(value); break;
|
case __.Title: _Title = Convert.ToString(value); break;
|
||||||
case __.ItemNO: _ItemNO = Convert.ToString(value); break;
|
case __.ItemNO: _ItemNO = Convert.ToString(value); break;
|
||||||
case __.SubTitle: _SubTitle = Convert.ToString(value); break;
|
case __.SubTitle: _SubTitle = Convert.ToString(value); break;
|
||||||
@@ -638,11 +648,11 @@ namespace COMCMS.Core
|
|||||||
case __.Discount: _Discount = Convert.ToDecimal(value); break;
|
case __.Discount: _Discount = Convert.ToDecimal(value); break;
|
||||||
case __.Material: _Material = Convert.ToString(value); break;
|
case __.Material: _Material = Convert.ToString(value); break;
|
||||||
case __.Front: _Front = Convert.ToString(value); break;
|
case __.Front: _Front = Convert.ToString(value); break;
|
||||||
case __.Credits : _Credits = Convert.ToInt32(value); break;
|
case __.Credits: _Credits = value.ToInt(); break;
|
||||||
case __.Stock : _Stock = Convert.ToInt32(value); break;
|
case __.Stock: _Stock = value.ToInt(); break;
|
||||||
case __.WarnStock : _WarnStock = Convert.ToInt32(value); break;
|
case __.WarnStock: _WarnStock = value.ToInt(); break;
|
||||||
case __.IsSubProduct : _IsSubProduct = Convert.ToInt32(value); break;
|
case __.IsSubProduct: _IsSubProduct = value.ToInt(); break;
|
||||||
case __.PPId : _PPId = Convert.ToInt32(value); break;
|
case __.PPId: _PPId = value.ToInt(); break;
|
||||||
case __.Content: _Content = Convert.ToString(value); break;
|
case __.Content: _Content = Convert.ToString(value); break;
|
||||||
case __.Parameters: _Parameters = Convert.ToString(value); break;
|
case __.Parameters: _Parameters = Convert.ToString(value); break;
|
||||||
case __.Keyword: _Keyword = Convert.ToString(value); break;
|
case __.Keyword: _Keyword = Convert.ToString(value); break;
|
||||||
@@ -650,39 +660,40 @@ namespace COMCMS.Core
|
|||||||
case __.LinkURL: _LinkURL = Convert.ToString(value); break;
|
case __.LinkURL: _LinkURL = Convert.ToString(value); break;
|
||||||
case __.TitleColor: _TitleColor = Convert.ToString(value); break;
|
case __.TitleColor: _TitleColor = Convert.ToString(value); break;
|
||||||
case __.TemplateFile: _TemplateFile = Convert.ToString(value); break;
|
case __.TemplateFile: _TemplateFile = Convert.ToString(value); break;
|
||||||
case __.IsRecommend : _IsRecommend = Convert.ToInt32(value); break;
|
case __.IsRecommend: _IsRecommend = value.ToInt(); break;
|
||||||
case __.IsHide : _IsHide = Convert.ToInt32(value); break;
|
case __.IsHide: _IsHide = value.ToInt(); break;
|
||||||
case __.IsLock : _IsLock = Convert.ToInt32(value); break;
|
case __.IsLock: _IsLock = value.ToInt(); break;
|
||||||
case __.IsDel : _IsDel = Convert.ToInt32(value); break;
|
case __.IsDel: _IsDel = value.ToInt(); break;
|
||||||
case __.IsTop : _IsTop = Convert.ToInt32(value); break;
|
case __.IsTop: _IsTop = value.ToInt(); break;
|
||||||
case __.IsBest : _IsBest = Convert.ToInt32(value); break;
|
case __.IsBest: _IsBest = value.ToInt(); break;
|
||||||
case __.IsComment : _IsComment = Convert.ToInt32(value); break;
|
case __.IsComment: _IsComment = value.ToInt(); break;
|
||||||
case __.IsMember : _IsMember = Convert.ToInt32(value); break;
|
case __.IsMember: _IsMember = value.ToInt(); break;
|
||||||
case __.IsNew : _IsNew = Convert.ToInt32(value); break;
|
case __.IsNew: _IsNew = value.ToInt(); break;
|
||||||
case __.IsSpecial : _IsSpecial = Convert.ToInt32(value); break;
|
case __.IsSpecial: _IsSpecial = value.ToInt(); break;
|
||||||
case __.IsPromote : _IsPromote = Convert.ToInt32(value); break;
|
case __.IsPromote: _IsPromote = value.ToInt(); break;
|
||||||
case __.IsHotSales : _IsHotSales = Convert.ToInt32(value); break;
|
case __.IsHotSales: _IsHotSales = value.ToInt(); break;
|
||||||
case __.IsBreakup : _IsBreakup = Convert.ToInt32(value); break;
|
case __.IsBreakup: _IsBreakup = value.ToInt(); break;
|
||||||
case __.IsShelves : _IsShelves = Convert.ToInt32(value); break;
|
case __.IsShelves: _IsShelves = value.ToInt(); break;
|
||||||
case __.IsVerify : _IsVerify = Convert.ToInt32(value); break;
|
case __.IsVerify: _IsVerify = value.ToInt(); break;
|
||||||
case __.Hits : _Hits = Convert.ToInt32(value); break;
|
case __.Hits: _Hits = value.ToInt(); break;
|
||||||
case __.IsGift : _IsGift = Convert.ToInt32(value); break;
|
case __.IsGift: _IsGift = value.ToInt(); break;
|
||||||
case __.IsPart : _IsPart = Convert.ToInt32(value); break;
|
case __.IsPart: _IsPart = value.ToInt(); break;
|
||||||
case __.Sequence : _Sequence = Convert.ToInt32(value); break;
|
case __.Sequence: _Sequence = value.ToInt(); break;
|
||||||
case __.CommentCount : _CommentCount = Convert.ToInt32(value); break;
|
case __.CommentCount: _CommentCount = value.ToInt(); break;
|
||||||
case __.Icon: _Icon = Convert.ToString(value); break;
|
case __.Icon: _Icon = Convert.ToString(value); break;
|
||||||
case __.ClassName: _ClassName = Convert.ToString(value); break;
|
case __.ClassName: _ClassName = Convert.ToString(value); break;
|
||||||
case __.BannerImg: _BannerImg = Convert.ToString(value); break;
|
case __.BannerImg: _BannerImg = Convert.ToString(value); break;
|
||||||
case __.Pic: _Pic = Convert.ToString(value); break;
|
case __.Pic: _Pic = Convert.ToString(value); break;
|
||||||
case __.AdsId : _AdsId = Convert.ToInt32(value); break;
|
case __.AdsId: _AdsId = value.ToInt(); break;
|
||||||
case __.Tags: _Tags = Convert.ToString(value); break;
|
case __.Tags: _Tags = Convert.ToString(value); break;
|
||||||
case __.ItemImg: _ItemImg = Convert.ToString(value); break;
|
case __.ItemImg: _ItemImg = Convert.ToString(value); break;
|
||||||
case __.Service: _Service = Convert.ToString(value); break;
|
case __.Service: _Service = Convert.ToString(value); break;
|
||||||
case __.AuthorId : _AuthorId = Convert.ToInt32(value); break;
|
case __.AuthorId: _AuthorId = value.ToInt(); break;
|
||||||
case __.AddTime : _AddTime = Convert.ToDateTime(value); break;
|
case __.AddTime: _AddTime = value.ToDateTime(); break;
|
||||||
case __.UpdateTime : _UpdateTime = Convert.ToDateTime(value); break;
|
case __.UpdateTime: _UpdateTime = value.ToDateTime(); break;
|
||||||
case __.Location: _Location = Convert.ToString(value); break;
|
case __.Location: _Location = Convert.ToString(value); break;
|
||||||
case __.FilePath: _FilePath = Convert.ToString(value); break;
|
case __.FilePath: _FilePath = Convert.ToString(value); break;
|
||||||
|
case __.FileName: _FileName = Convert.ToString(value); break;
|
||||||
default: base[name] = value; break;
|
default: base[name] = value; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -888,7 +899,10 @@ namespace COMCMS.Core
|
|||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
public static readonly Field FilePath = FindByName(__.FilePath);
|
public static readonly Field FilePath = FindByName(__.FilePath);
|
||||||
|
|
||||||
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
/// <summary>文件名称</summary>
|
||||||
|
public static readonly Field FileName = FindByName(__.FileName);
|
||||||
|
|
||||||
|
static Field FindByName(String name) => Meta.Table.FindByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>取得商品字段名称的快捷方式</summary>
|
/// <summary>取得商品字段名称的快捷方式</summary>
|
||||||
@@ -1088,6 +1102,9 @@ namespace COMCMS.Core
|
|||||||
|
|
||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
public const String FilePath = "FilePath";
|
public const String FilePath = "FilePath";
|
||||||
|
|
||||||
|
/// <summary>文件名称</summary>
|
||||||
|
public const String FileName = "FileName";
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@@ -1290,6 +1307,9 @@ namespace COMCMS.Core
|
|||||||
|
|
||||||
/// <summary>存放目录</summary>
|
/// <summary>存放目录</summary>
|
||||||
String FilePath { get; set; }
|
String FilePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>文件名称</summary>
|
||||||
|
String FileName { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 获取/设置 字段值
|
#region 获取/设置 字段值
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
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;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace COMCMS.Core
|
|||||||
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
//Meta.Factory.AdditionalFields.Add(__.Logins);
|
||||||
|
|
||||||
// 过滤器 UserModule、TimeModule、IPModule
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
Meta.Modules.Add<TimeModule>();
|
Meta.Interceptors.Add<TimeInterceptor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using XCode;
|
using XCode;
|
||||||
using XCode.Configuration;
|
using XCode.Configuration;
|
||||||
using XCode.DataAccessLayer;
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
namespace COMCMS.Core
|
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
@@ -38,4 +38,29 @@ namespace COMCMS.Core.Models
|
|||||||
public int qty { get; set; } = 1;
|
public int qty { get; set; } = 1;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 系统文件目录信息列表
|
||||||
|
/// <summary>
|
||||||
|
/// 系统文件目录信息
|
||||||
|
/// </summary>
|
||||||
|
public class DirInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 目录名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 目录
|
||||||
|
/// </summary>
|
||||||
|
public string path { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 目录详情
|
||||||
|
/// </summary>
|
||||||
|
public string fullPath { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 子目录
|
||||||
|
/// </summary>
|
||||||
|
public List<DirInfo> subList { get; set; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ namespace COMCMS.Core
|
|||||||
/// 返回URL
|
/// 返回URL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ReturnUrl { get; set; }
|
public string ReturnUrl { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 其他详情
|
||||||
|
/// </summary>
|
||||||
|
public object Detail { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取JSON字符串
|
/// 获取JSON字符串
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
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 WeixinResponseContent : Entity<WeixinResponseContent>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static WeixinResponseContent()
|
||||||
|
{
|
||||||
|
|
||||||
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
|
Meta.Interceptors.Add<TimeInterceptor>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
|
/// <param name="isNew">是否插入</param>
|
||||||
|
public override void Valid(Boolean isNew)
|
||||||
|
{
|
||||||
|
// 如果没有脏数据,则不需要进行任何处理
|
||||||
|
if (!HasDirty) return;
|
||||||
|
|
||||||
|
// 在新插入数据或者修改了指定字段时进行修正
|
||||||
|
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||||
|
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
//protected override void InitData()
|
||||||
|
//{
|
||||||
|
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||||
|
// if (Meta.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinResponseContent[公众平台回复信息]数据……");
|
||||||
|
|
||||||
|
// var entity = new WeixinResponseContent();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.OpenId = "abc";
|
||||||
|
// entity.RequestType = "abc";
|
||||||
|
// entity.RequestContent = "abc";
|
||||||
|
// entity.ResponseType = "abc";
|
||||||
|
// entity.ReponseContent = "abc";
|
||||||
|
// entity.XmlContent = "abc";
|
||||||
|
// entity.UpdateTime = DateTime.Now;
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化WeixinResponseContent[公众平台回复信息]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 WeixinResponseContent FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务
|
||||||
|
public static string GetResponseType(int typeid)
|
||||||
|
{
|
||||||
|
//Text = 0,
|
||||||
|
//Location = 1,
|
||||||
|
//Image = 2,
|
||||||
|
//Voice = 3,
|
||||||
|
//Video = 4,
|
||||||
|
//Link = 5,
|
||||||
|
//ShortVideo = 6,
|
||||||
|
//Event = 7,
|
||||||
|
|
||||||
|
switch (typeid)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
return "text";
|
||||||
|
case 1:
|
||||||
|
return "location";
|
||||||
|
case 2:
|
||||||
|
return "image";
|
||||||
|
case 3:
|
||||||
|
return "voice";
|
||||||
|
case 4:
|
||||||
|
return "video";
|
||||||
|
case 5:
|
||||||
|
return "link";
|
||||||
|
case 6:
|
||||||
|
return "shortvideo";
|
||||||
|
case 7:
|
||||||
|
return "event";
|
||||||
|
default:
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,220 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>公众平台回复信息</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("公众平台回复信息")]
|
||||||
|
[BindTable("WeixinResponseContent", Description = "公众平台回复信息", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class WeixinResponseContent : IWeixinResponseContent
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
|
private String _OpenId;
|
||||||
|
/// <summary>用户OpenId</summary>
|
||||||
|
[DisplayName("用户OpenId")]
|
||||||
|
[Description("用户OpenId")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("OpenId", "用户OpenId", "")]
|
||||||
|
public String OpenId { get { return _OpenId; } set { if (OnPropertyChanging(__.OpenId, value)) { _OpenId = value; OnPropertyChanged(__.OpenId); } } }
|
||||||
|
|
||||||
|
private String _RequestType;
|
||||||
|
/// <summary>请求类型</summary>
|
||||||
|
[DisplayName("请求类型")]
|
||||||
|
[Description("请求类型")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("RequestType", "请求类型", "")]
|
||||||
|
public String RequestType { get { return _RequestType; } set { if (OnPropertyChanging(__.RequestType, value)) { _RequestType = value; OnPropertyChanged(__.RequestType); } } }
|
||||||
|
|
||||||
|
private String _RequestContent;
|
||||||
|
/// <summary>内容</summary>
|
||||||
|
[DisplayName("内容")]
|
||||||
|
[Description("内容")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("RequestContent", "内容", "")]
|
||||||
|
public String RequestContent { get { return _RequestContent; } set { if (OnPropertyChanging(__.RequestContent, value)) { _RequestContent = value; OnPropertyChanged(__.RequestContent); } } }
|
||||||
|
|
||||||
|
private String _ResponseType;
|
||||||
|
/// <summary>回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link</summary>
|
||||||
|
[DisplayName("回复的类型文本消息:text图片消息:image地理位置消息:location链接消息:link")]
|
||||||
|
[Description("回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("ResponseType", "回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link", "")]
|
||||||
|
public String ResponseType { get { return _ResponseType; } set { if (OnPropertyChanging(__.ResponseType, value)) { _ResponseType = value; OnPropertyChanged(__.ResponseType); } } }
|
||||||
|
|
||||||
|
private String _ReponseContent;
|
||||||
|
/// <summary>系统回复的内容</summary>
|
||||||
|
[DisplayName("系统回复的内容")]
|
||||||
|
[Description("系统回复的内容")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("ReponseContent", "系统回复的内容", "")]
|
||||||
|
public String ReponseContent { get { return _ReponseContent; } set { if (OnPropertyChanging(__.ReponseContent, value)) { _ReponseContent = value; OnPropertyChanged(__.ReponseContent); } } }
|
||||||
|
|
||||||
|
private String _XmlContent;
|
||||||
|
/// <summary>xml原始内容</summary>
|
||||||
|
[DisplayName("xml原始内容")]
|
||||||
|
[Description("xml原始内容")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("XmlContent", "xml原始内容", "")]
|
||||||
|
public String XmlContent { get { return _XmlContent; } set { if (OnPropertyChanging(__.XmlContent, value)) { _XmlContent = value; OnPropertyChanged(__.XmlContent); } } }
|
||||||
|
|
||||||
|
private DateTime _UpdateTime;
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
[DisplayName("修改时间")]
|
||||||
|
[Description("修改时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("UpdateTime", "修改时间", "")]
|
||||||
|
public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取/设置 字段值
|
||||||
|
/// <summary>获取/设置 字段值</summary>
|
||||||
|
/// <param name="name">字段名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override Object this[String name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id : return _Id;
|
||||||
|
case __.OpenId : return _OpenId;
|
||||||
|
case __.RequestType : return _RequestType;
|
||||||
|
case __.RequestContent : return _RequestContent;
|
||||||
|
case __.ResponseType : return _ResponseType;
|
||||||
|
case __.ReponseContent : return _ReponseContent;
|
||||||
|
case __.XmlContent : return _XmlContent;
|
||||||
|
case __.UpdateTime : return _UpdateTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id : _Id = value.ToInt(); break;
|
||||||
|
case __.OpenId : _OpenId = Convert.ToString(value); break;
|
||||||
|
case __.RequestType : _RequestType = Convert.ToString(value); break;
|
||||||
|
case __.RequestContent : _RequestContent = Convert.ToString(value); break;
|
||||||
|
case __.ResponseType : _ResponseType = Convert.ToString(value); break;
|
||||||
|
case __.ReponseContent : _ReponseContent = Convert.ToString(value); break;
|
||||||
|
case __.XmlContent : _XmlContent = Convert.ToString(value); break;
|
||||||
|
case __.UpdateTime : _UpdateTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得公众平台回复信息字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName(__.Id);
|
||||||
|
|
||||||
|
/// <summary>用户OpenId</summary>
|
||||||
|
public static readonly Field OpenId = FindByName(__.OpenId);
|
||||||
|
|
||||||
|
/// <summary>请求类型</summary>
|
||||||
|
public static readonly Field RequestType = FindByName(__.RequestType);
|
||||||
|
|
||||||
|
/// <summary>内容</summary>
|
||||||
|
public static readonly Field RequestContent = FindByName(__.RequestContent);
|
||||||
|
|
||||||
|
/// <summary>回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link</summary>
|
||||||
|
public static readonly Field ResponseType = FindByName(__.ResponseType);
|
||||||
|
|
||||||
|
/// <summary>系统回复的内容</summary>
|
||||||
|
public static readonly Field ReponseContent = FindByName(__.ReponseContent);
|
||||||
|
|
||||||
|
/// <summary>xml原始内容</summary>
|
||||||
|
public static readonly Field XmlContent = FindByName(__.XmlContent);
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
public static readonly Field UpdateTime = FindByName(__.UpdateTime);
|
||||||
|
|
||||||
|
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得公众平台回复信息字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>用户OpenId</summary>
|
||||||
|
public const String OpenId = "OpenId";
|
||||||
|
|
||||||
|
/// <summary>请求类型</summary>
|
||||||
|
public const String RequestType = "RequestType";
|
||||||
|
|
||||||
|
/// <summary>内容</summary>
|
||||||
|
public const String RequestContent = "RequestContent";
|
||||||
|
|
||||||
|
/// <summary>回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link</summary>
|
||||||
|
public const String ResponseType = "ResponseType";
|
||||||
|
|
||||||
|
/// <summary>系统回复的内容</summary>
|
||||||
|
public const String ReponseContent = "ReponseContent";
|
||||||
|
|
||||||
|
/// <summary>xml原始内容</summary>
|
||||||
|
public const String XmlContent = "XmlContent";
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
public const String UpdateTime = "UpdateTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>公众平台回复信息接口</summary>
|
||||||
|
public partial interface IWeixinResponseContent
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
Int32 Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>用户OpenId</summary>
|
||||||
|
String OpenId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>请求类型</summary>
|
||||||
|
String RequestType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>内容</summary>
|
||||||
|
String RequestContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>回复的类型 文本消息:text 图片消息:image 地理位置消息:location 链接消息:link</summary>
|
||||||
|
String ResponseType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>系统回复的内容</summary>
|
||||||
|
String ReponseContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>xml原始内容</summary>
|
||||||
|
String XmlContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
DateTime UpdateTime { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取/设置 字段值
|
||||||
|
/// <summary>获取/设置 字段值</summary>
|
||||||
|
/// <param name="name">字段名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Object this[String name] { get; set; }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
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 WeixinRequestRule : Entity<WeixinRequestRule>
|
||||||
|
{
|
||||||
|
#region 对象操作
|
||||||
|
static WeixinRequestRule()
|
||||||
|
{
|
||||||
|
// 累加字段
|
||||||
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
|
//df.Add(__.RequestType);
|
||||||
|
|
||||||
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
|
Meta.Interceptors.Add<TimeInterceptor>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
|
/// <param name="isNew">是否插入</param>
|
||||||
|
public override void Valid(Boolean isNew)
|
||||||
|
{
|
||||||
|
// 如果没有脏数据,则不需要进行任何处理
|
||||||
|
if (!HasDirty) return;
|
||||||
|
|
||||||
|
// 在新插入数据或者修改了指定字段时进行修正
|
||||||
|
//if (!Dirtys[nameof(UpdateTime)]) UpdateTime = DateTime.Now;
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
|
||||||
|
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
|
//protected override void InitData()
|
||||||
|
//{
|
||||||
|
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||||
|
// if (Meta.Session.Count > 0) return;
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinRequestRule[微信公众号回复规则]数据……");
|
||||||
|
|
||||||
|
// var entity = new WeixinRequestRule();
|
||||||
|
// entity.Id = 0;
|
||||||
|
// entity.RuleName = "abc";
|
||||||
|
// entity.Keywords = "abc";
|
||||||
|
// entity.RequestType = 0;
|
||||||
|
// entity.ResponseType = 0;
|
||||||
|
// entity.IsLikeQuery = 0;
|
||||||
|
// entity.IsDefault = 0;
|
||||||
|
// entity.Rank = 0;
|
||||||
|
// entity.AddTime = DateTime.Now;
|
||||||
|
// entity.UpdateTime = DateTime.Now;
|
||||||
|
// entity.Insert();
|
||||||
|
|
||||||
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化WeixinRequestRule[微信公众号回复规则]数据!");
|
||||||
|
//}
|
||||||
|
|
||||||
|
///// <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 扩展属性
|
||||||
|
private IList<WeixinRequestContent> _ListContent;
|
||||||
|
/// <summary>
|
||||||
|
/// 详细规则列表
|
||||||
|
/// </summary>
|
||||||
|
public IList<WeixinRequestContent> ListContent
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_ListContent == null && Id > 0 && !Dirtys["ListWechatRequestContent_" + Id])
|
||||||
|
{
|
||||||
|
_ListContent = WeixinRequestContent.FindAll(WeixinRequestContent._.RuleId == Id, WeixinRequestContent._.Rank.Asc(), null, 0, 0);
|
||||||
|
|
||||||
|
Dirtys["ListWechatRequestContent_" + Id] = true;
|
||||||
|
}
|
||||||
|
return _ListContent;
|
||||||
|
}
|
||||||
|
set { _ListContent = value; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 扩展查询
|
||||||
|
/// <summary>根据编号查找</summary>
|
||||||
|
/// <param name="id">编号</param>
|
||||||
|
/// <returns>实体对象</returns>
|
||||||
|
public static WeixinRequestRule FindById(Int32 id)
|
||||||
|
{
|
||||||
|
if (id <= 0) return null;
|
||||||
|
|
||||||
|
// 实体缓存
|
||||||
|
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Id == id);
|
||||||
|
|
||||||
|
// 单对象缓存
|
||||||
|
return Meta.SingleCache[id];
|
||||||
|
|
||||||
|
//return Find(_.Id == id);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 高级查询
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务操作
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 业务
|
||||||
|
/// <summary>
|
||||||
|
/// 微信请求类型
|
||||||
|
/// 0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件
|
||||||
|
/// </summary>
|
||||||
|
public enum XRequestType
|
||||||
|
{
|
||||||
|
/// <summary>默认回复</summary>
|
||||||
|
Default = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// 文本请求
|
||||||
|
/// </summary>
|
||||||
|
Text = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 图片
|
||||||
|
/// </summary>
|
||||||
|
Image = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 语音
|
||||||
|
/// </summary>
|
||||||
|
Voice = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// 链接
|
||||||
|
/// </summary>
|
||||||
|
Link = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// 地理位置
|
||||||
|
/// </summary>
|
||||||
|
Location = 5,
|
||||||
|
/// <summary>
|
||||||
|
/// 关注
|
||||||
|
/// </summary>
|
||||||
|
Flow = 6,
|
||||||
|
/// <summary>
|
||||||
|
/// 取消关注
|
||||||
|
/// </summary>
|
||||||
|
Unflow = 7,
|
||||||
|
/// <summary>
|
||||||
|
/// 扫描二维码
|
||||||
|
/// </summary>
|
||||||
|
Scan = 8,
|
||||||
|
/// <summary>
|
||||||
|
/// 上报地理位置
|
||||||
|
/// </summary>
|
||||||
|
ReportingLocation = 9,
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义菜单
|
||||||
|
/// </summary>
|
||||||
|
CustomMenu = 10,
|
||||||
|
/// <summary>
|
||||||
|
/// 没找到关键字
|
||||||
|
/// </summary>
|
||||||
|
NotFindKeyword = 11
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 回复类型
|
||||||
|
/// </summary>
|
||||||
|
public enum XResponseType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文本
|
||||||
|
/// </summary>
|
||||||
|
Text = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// 地理位置
|
||||||
|
/// </summary>
|
||||||
|
Location = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 图片
|
||||||
|
/// </summary>
|
||||||
|
Image = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 语音
|
||||||
|
/// </summary>
|
||||||
|
Voice = 3,
|
||||||
|
/// <summary>
|
||||||
|
/// 视频
|
||||||
|
/// </summary>
|
||||||
|
Video = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// 链接
|
||||||
|
/// </summary>
|
||||||
|
Link = 5,
|
||||||
|
/// <summary>
|
||||||
|
/// 短片
|
||||||
|
/// </summary>
|
||||||
|
ShortVideo = 6,
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义事件
|
||||||
|
/// </summary>
|
||||||
|
Event = 7,
|
||||||
|
/// <summary>
|
||||||
|
/// 单张图片
|
||||||
|
/// </summary>
|
||||||
|
SingleImage = 8,
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,258 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>微信公众号回复规则</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("微信公众号回复规则")]
|
||||||
|
[BindTable("WeixinRequestRule", Description = "微信公众号回复规则", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class WeixinRequestRule : IWeixinRequestRule
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
|
private String _RuleName;
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
[DisplayName("规则名称")]
|
||||||
|
[Description("规则名称")]
|
||||||
|
[DataObjectField(false, false, true, 50)]
|
||||||
|
[BindColumn("RuleName", "规则名称", "")]
|
||||||
|
public String RuleName { get { return _RuleName; } set { if (OnPropertyChanging(__.RuleName, value)) { _RuleName = value; OnPropertyChanged(__.RuleName); } } }
|
||||||
|
|
||||||
|
private String _Keywords;
|
||||||
|
/// <summary>请求关键词,逗号分隔</summary>
|
||||||
|
[DisplayName("请求关键词")]
|
||||||
|
[Description("请求关键词,逗号分隔")]
|
||||||
|
[DataObjectField(false, false, true, 200)]
|
||||||
|
[BindColumn("Keywords", "请求关键词,逗号分隔", "")]
|
||||||
|
public String Keywords { get { return _Keywords; } set { if (OnPropertyChanging(__.Keywords, value)) { _Keywords = value; OnPropertyChanged(__.Keywords); } } }
|
||||||
|
|
||||||
|
private Int32 _RequestType;
|
||||||
|
/// <summary>请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)</summary>
|
||||||
|
[DisplayName("请求类型")]
|
||||||
|
[Description("请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("RequestType", "请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)", "")]
|
||||||
|
public Int32 RequestType { get { return _RequestType; } set { if (OnPropertyChanging(__.RequestType, value)) { _RequestType = value; OnPropertyChanged(__.RequestType); } } }
|
||||||
|
|
||||||
|
private Int32 _ResponseType;
|
||||||
|
/// <summary>回复类型(1文本2图文3语音4视频5第三方接口)</summary>
|
||||||
|
[DisplayName("回复类型")]
|
||||||
|
[Description("回复类型(1文本2图文3语音4视频5第三方接口)")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("ResponseType", "回复类型(1文本2图文3语音4视频5第三方接口)", "")]
|
||||||
|
public Int32 ResponseType { get { return _ResponseType; } set { if (OnPropertyChanging(__.ResponseType, value)) { _ResponseType = value; OnPropertyChanged(__.ResponseType); } } }
|
||||||
|
|
||||||
|
private Int32 _IsLikeQuery;
|
||||||
|
/// <summary>是否模糊查询 0 是完全匹配;1是模糊匹配</summary>
|
||||||
|
[DisplayName("是否模糊查询0是完全匹配;1是模糊匹配")]
|
||||||
|
[Description("是否模糊查询 0 是完全匹配;1是模糊匹配")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("IsLikeQuery", "是否模糊查询 0 是完全匹配;1是模糊匹配", "")]
|
||||||
|
public Int32 IsLikeQuery { get { return _IsLikeQuery; } set { if (OnPropertyChanging(__.IsLikeQuery, value)) { _IsLikeQuery = value; OnPropertyChanged(__.IsLikeQuery); } } }
|
||||||
|
|
||||||
|
private Int32 _IsDefault;
|
||||||
|
/// <summary>是否是默认回复</summary>
|
||||||
|
[DisplayName("是否是默认回复")]
|
||||||
|
[Description("是否是默认回复")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("IsDefault", "是否是默认回复", "")]
|
||||||
|
public Int32 IsDefault { get { return _IsDefault; } set { if (OnPropertyChanging(__.IsDefault, value)) { _IsDefault = value; OnPropertyChanged(__.IsDefault); } } }
|
||||||
|
|
||||||
|
private Int32 _Rank;
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
[DisplayName("排序")]
|
||||||
|
[Description("排序")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Rank", "排序", "")]
|
||||||
|
public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } }
|
||||||
|
|
||||||
|
private DateTime _AddTime;
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
[DisplayName("添加时间")]
|
||||||
|
[Description("添加时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
|
public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
||||||
|
|
||||||
|
private DateTime _UpdateTime;
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
[DisplayName("修改时间")]
|
||||||
|
[Description("修改时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("UpdateTime", "修改时间", "")]
|
||||||
|
public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取/设置 字段值
|
||||||
|
/// <summary>获取/设置 字段值</summary>
|
||||||
|
/// <param name="name">字段名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override Object this[String name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id : return _Id;
|
||||||
|
case __.RuleName : return _RuleName;
|
||||||
|
case __.Keywords : return _Keywords;
|
||||||
|
case __.RequestType : return _RequestType;
|
||||||
|
case __.ResponseType : return _ResponseType;
|
||||||
|
case __.IsLikeQuery : return _IsLikeQuery;
|
||||||
|
case __.IsDefault : return _IsDefault;
|
||||||
|
case __.Rank : return _Rank;
|
||||||
|
case __.AddTime : return _AddTime;
|
||||||
|
case __.UpdateTime : return _UpdateTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id : _Id = value.ToInt(); break;
|
||||||
|
case __.RuleName : _RuleName = Convert.ToString(value); break;
|
||||||
|
case __.Keywords : _Keywords = Convert.ToString(value); break;
|
||||||
|
case __.RequestType : _RequestType = value.ToInt(); break;
|
||||||
|
case __.ResponseType : _ResponseType = value.ToInt(); break;
|
||||||
|
case __.IsLikeQuery : _IsLikeQuery = value.ToInt(); break;
|
||||||
|
case __.IsDefault : _IsDefault = value.ToInt(); break;
|
||||||
|
case __.Rank : _Rank = value.ToInt(); break;
|
||||||
|
case __.AddTime : _AddTime = value.ToDateTime(); break;
|
||||||
|
case __.UpdateTime : _UpdateTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得微信公众号回复规则字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName(__.Id);
|
||||||
|
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
public static readonly Field RuleName = FindByName(__.RuleName);
|
||||||
|
|
||||||
|
/// <summary>请求关键词,逗号分隔</summary>
|
||||||
|
public static readonly Field Keywords = FindByName(__.Keywords);
|
||||||
|
|
||||||
|
/// <summary>请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)</summary>
|
||||||
|
public static readonly Field RequestType = FindByName(__.RequestType);
|
||||||
|
|
||||||
|
/// <summary>回复类型(1文本2图文3语音4视频5第三方接口)</summary>
|
||||||
|
public static readonly Field ResponseType = FindByName(__.ResponseType);
|
||||||
|
|
||||||
|
/// <summary>是否模糊查询 0 是完全匹配;1是模糊匹配</summary>
|
||||||
|
public static readonly Field IsLikeQuery = FindByName(__.IsLikeQuery);
|
||||||
|
|
||||||
|
/// <summary>是否是默认回复</summary>
|
||||||
|
public static readonly Field IsDefault = FindByName(__.IsDefault);
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public static readonly Field Rank = FindByName(__.Rank);
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public static readonly Field AddTime = FindByName(__.AddTime);
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
public static readonly Field UpdateTime = FindByName(__.UpdateTime);
|
||||||
|
|
||||||
|
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得微信公众号回复规则字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
public const String RuleName = "RuleName";
|
||||||
|
|
||||||
|
/// <summary>请求关键词,逗号分隔</summary>
|
||||||
|
public const String Keywords = "Keywords";
|
||||||
|
|
||||||
|
/// <summary>请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)</summary>
|
||||||
|
public const String RequestType = "RequestType";
|
||||||
|
|
||||||
|
/// <summary>回复类型(1文本2图文3语音4视频5第三方接口)</summary>
|
||||||
|
public const String ResponseType = "ResponseType";
|
||||||
|
|
||||||
|
/// <summary>是否模糊查询 0 是完全匹配;1是模糊匹配</summary>
|
||||||
|
public const String IsLikeQuery = "IsLikeQuery";
|
||||||
|
|
||||||
|
/// <summary>是否是默认回复</summary>
|
||||||
|
public const String IsDefault = "IsDefault";
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public const String Rank = "Rank";
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public const String AddTime = "AddTime";
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
public const String UpdateTime = "UpdateTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>微信公众号回复规则接口</summary>
|
||||||
|
public partial interface IWeixinRequestRule
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
Int32 Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
String RuleName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>请求关键词,逗号分隔</summary>
|
||||||
|
String Keywords { get; set; }
|
||||||
|
|
||||||
|
/// <summary>请求类型(0默认回复1文字2图片3语音4链接5地理位置6关注7取消关注8扫描带参数二维码事件9上报地理位置事件10自定义菜单事件)</summary>
|
||||||
|
Int32 RequestType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>回复类型(1文本2图文3语音4视频5第三方接口)</summary>
|
||||||
|
Int32 ResponseType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>是否模糊查询 0 是完全匹配;1是模糊匹配</summary>
|
||||||
|
Int32 IsLikeQuery { get; set; }
|
||||||
|
|
||||||
|
/// <summary>是否是默认回复</summary>
|
||||||
|
Int32 IsDefault { get; set; }
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
Int32 Rank { get; set; }
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
DateTime AddTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
DateTime UpdateTime { 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 System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
@@ -23,18 +24,18 @@ using XCode.Membership;
|
|||||||
|
|
||||||
namespace COMCMS.Core
|
namespace COMCMS.Core
|
||||||
{
|
{
|
||||||
/// <summary>购物车</summary>
|
/// <summary>请求回复的内容</summary>
|
||||||
public partial class ShoppingCart : Entity<ShoppingCart>
|
public partial class WeixinRequestContent : Entity<WeixinRequestContent>
|
||||||
{
|
{
|
||||||
#region 对象操作
|
#region 对象操作
|
||||||
static ShoppingCart()
|
static WeixinRequestContent()
|
||||||
{
|
{
|
||||||
// 累加字段
|
// 累加字段
|
||||||
//var df = Meta.Factory.AdditionalFields;
|
//var df = Meta.Factory.AdditionalFields;
|
||||||
//df.Add(__.UId);
|
//df.Add(__.RuleId);
|
||||||
|
|
||||||
// 过滤器 UserModule、TimeModule、IPModule
|
// 过滤器 UserModule、TimeModule、IPModule
|
||||||
Meta.Modules.Add<TimeModule>();
|
Meta.Interceptors.Add<TimeInterceptor>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
|
||||||
@@ -55,18 +56,26 @@ namespace COMCMS.Core
|
|||||||
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
// // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
|
||||||
// if (Meta.Session.Count > 0) return;
|
// if (Meta.Session.Count > 0) return;
|
||||||
|
|
||||||
// if (XTrace.Debug) XTrace.WriteLine("开始初始化ShoppingCart[购物车]数据……");
|
// if (XTrace.Debug) XTrace.WriteLine("开始初始化WeixinRequestContent[请求回复的内容]数据……");
|
||||||
|
|
||||||
// var entity = new ShoppingCart();
|
// var entity = new WeixinRequestContent();
|
||||||
// entity.Id = 0;
|
// entity.Id = 0;
|
||||||
// entity.UId = 0;
|
// entity.RuleId = 0;
|
||||||
// entity.Guid = "abc";
|
// entity.Title = "abc";
|
||||||
// entity.Details = "abc";
|
// entity.Content = "abc";
|
||||||
|
// entity.LinkUrl = "abc";
|
||||||
|
// entity.ImgURL = "abc";
|
||||||
|
// entity.MediaURL = "abc";
|
||||||
|
// entity.MeidaHdURL = "abc";
|
||||||
|
// entity.MediaID = "abc";
|
||||||
|
// entity.WXAppAppId = "abc";
|
||||||
|
// entity.WXAppPage = "abc";
|
||||||
|
// entity.Rank = 0;
|
||||||
// entity.AddTime = DateTime.Now;
|
// entity.AddTime = DateTime.Now;
|
||||||
// entity.UpdateTime = DateTime.Now;
|
// entity.UpdateTime = DateTime.Now;
|
||||||
// entity.Insert();
|
// entity.Insert();
|
||||||
|
|
||||||
// if (XTrace.Debug) XTrace.WriteLine("完成初始化ShoppingCart[购物车]数据!");
|
// if (XTrace.Debug) XTrace.WriteLine("完成初始化WeixinRequestContent[请求回复的内容]数据!");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
///// <summary>已重载。基类先调用Valid(true)验证数据,然后在事务保护内调用OnInsert</summary>
|
||||||
@@ -91,7 +100,7 @@ namespace COMCMS.Core
|
|||||||
/// <summary>根据编号查找</summary>
|
/// <summary>根据编号查找</summary>
|
||||||
/// <param name="id">编号</param>
|
/// <param name="id">编号</param>
|
||||||
/// <returns>实体对象</returns>
|
/// <returns>实体对象</returns>
|
||||||
public static ShoppingCart FindById(Int32 id)
|
public static WeixinRequestContent FindById(Int32 id)
|
||||||
{
|
{
|
||||||
if (id <= 0) return null;
|
if (id <= 0) return null;
|
||||||
|
|
||||||
@@ -0,0 +1,334 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using XCode;
|
||||||
|
using XCode.Configuration;
|
||||||
|
using XCode.DataAccessLayer;
|
||||||
|
using NewLife;
|
||||||
|
|
||||||
|
namespace COMCMS.Core
|
||||||
|
{
|
||||||
|
/// <summary>请求回复的内容</summary>
|
||||||
|
[Serializable]
|
||||||
|
[DataObject]
|
||||||
|
[Description("请求回复的内容")]
|
||||||
|
[BindTable("WeixinRequestContent", Description = "请求回复的内容", ConnName = "dbconn", DbType = DatabaseType.SqlServer)]
|
||||||
|
public partial class WeixinRequestContent : IWeixinRequestContent
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
private Int32 _Id;
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
[DisplayName("编号")]
|
||||||
|
[Description("编号")]
|
||||||
|
[DataObjectField(true, true, false, 0)]
|
||||||
|
[BindColumn("Id", "编号", "")]
|
||||||
|
public Int32 Id { get { return _Id; } set { if (OnPropertyChanging(__.Id, value)) { _Id = value; OnPropertyChanged(__.Id); } } }
|
||||||
|
|
||||||
|
private Int32 _RuleId;
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
[DisplayName("规则名称")]
|
||||||
|
[Description("规则名称")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("RuleId", "规则名称", "")]
|
||||||
|
public Int32 RuleId { get { return _RuleId; } set { if (OnPropertyChanging(__.RuleId, value)) { _RuleId = value; OnPropertyChanged(__.RuleId); } } }
|
||||||
|
|
||||||
|
private String _Title;
|
||||||
|
/// <summary>回复标题</summary>
|
||||||
|
[DisplayName("回复标题")]
|
||||||
|
[Description("回复标题")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("Title", "回复标题", "", Master = true)]
|
||||||
|
public String Title { get { return _Title; } set { if (OnPropertyChanging(__.Title, value)) { _Title = value; OnPropertyChanged(__.Title); } } }
|
||||||
|
|
||||||
|
private String _Content;
|
||||||
|
/// <summary>回复内容</summary>
|
||||||
|
[DisplayName("回复内容")]
|
||||||
|
[Description("回复内容")]
|
||||||
|
[DataObjectField(false, false, true, -1)]
|
||||||
|
[BindColumn("Content", "回复内容", "")]
|
||||||
|
public String Content { get { return _Content; } set { if (OnPropertyChanging(__.Content, value)) { _Content = value; OnPropertyChanged(__.Content); } } }
|
||||||
|
|
||||||
|
private String _LinkUrl;
|
||||||
|
/// <summary>详情链接地址</summary>
|
||||||
|
[DisplayName("详情链接地址")]
|
||||||
|
[Description("详情链接地址")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("LinkUrl", "详情链接地址", "")]
|
||||||
|
public String LinkUrl { get { return _LinkUrl; } set { if (OnPropertyChanging(__.LinkUrl, value)) { _LinkUrl = value; OnPropertyChanged(__.LinkUrl); } } }
|
||||||
|
|
||||||
|
private String _ImgURL;
|
||||||
|
/// <summary>图片地址</summary>
|
||||||
|
[DisplayName("图片地址")]
|
||||||
|
[Description("图片地址")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("ImgURL", "图片地址", "")]
|
||||||
|
public String ImgURL { get { return _ImgURL; } set { if (OnPropertyChanging(__.ImgURL, value)) { _ImgURL = value; OnPropertyChanged(__.ImgURL); } } }
|
||||||
|
|
||||||
|
private String _MediaURL;
|
||||||
|
/// <summary>语音或视频地址</summary>
|
||||||
|
[DisplayName("语音或视频地址")]
|
||||||
|
[Description("语音或视频地址")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("MediaURL", "语音或视频地址", "")]
|
||||||
|
public String MediaURL { get { return _MediaURL; } set { if (OnPropertyChanging(__.MediaURL, value)) { _MediaURL = value; OnPropertyChanged(__.MediaURL); } } }
|
||||||
|
|
||||||
|
private String _MeidaHdURL;
|
||||||
|
/// <summary>高清语音或者视频地址</summary>
|
||||||
|
[DisplayName("高清语音或者视频地址")]
|
||||||
|
[Description("高清语音或者视频地址")]
|
||||||
|
[DataObjectField(false, false, true, 250)]
|
||||||
|
[BindColumn("MeidaHdURL", "高清语音或者视频地址", "")]
|
||||||
|
public String MeidaHdURL { get { return _MeidaHdURL; } set { if (OnPropertyChanging(__.MeidaHdURL, value)) { _MeidaHdURL = value; OnPropertyChanged(__.MeidaHdURL); } } }
|
||||||
|
|
||||||
|
private String _MediaID;
|
||||||
|
/// <summary>返回的素材ID</summary>
|
||||||
|
[DisplayName("返回的素材ID")]
|
||||||
|
[Description("返回的素材ID")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("MediaID", "返回的素材ID", "")]
|
||||||
|
public String MediaID { get { return _MediaID; } set { if (OnPropertyChanging(__.MediaID, value)) { _MediaID = value; OnPropertyChanged(__.MediaID); } } }
|
||||||
|
|
||||||
|
private String _WXAppAppId;
|
||||||
|
/// <summary>小程序APPId</summary>
|
||||||
|
[DisplayName("小程序APPId")]
|
||||||
|
[Description("小程序APPId")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("WXAppAppId", "小程序APPId", "")]
|
||||||
|
public String WXAppAppId { get { return _WXAppAppId; } set { if (OnPropertyChanging(__.WXAppAppId, value)) { _WXAppAppId = value; OnPropertyChanged(__.WXAppAppId); } } }
|
||||||
|
|
||||||
|
private String _WXAppPage;
|
||||||
|
/// <summary>小程序页面</summary>
|
||||||
|
[DisplayName("小程序页面")]
|
||||||
|
[Description("小程序页面")]
|
||||||
|
[DataObjectField(false, false, true, 100)]
|
||||||
|
[BindColumn("WXAppPage", "小程序页面", "")]
|
||||||
|
public String WXAppPage { get { return _WXAppPage; } set { if (OnPropertyChanging(__.WXAppPage, value)) { _WXAppPage = value; OnPropertyChanged(__.WXAppPage); } } }
|
||||||
|
|
||||||
|
private Int32 _Rank;
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
[DisplayName("排序")]
|
||||||
|
[Description("排序")]
|
||||||
|
[DataObjectField(false, false, false, 0)]
|
||||||
|
[BindColumn("Rank", "排序", "")]
|
||||||
|
public Int32 Rank { get { return _Rank; } set { if (OnPropertyChanging(__.Rank, value)) { _Rank = value; OnPropertyChanged(__.Rank); } } }
|
||||||
|
|
||||||
|
private DateTime _AddTime;
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
[DisplayName("添加时间")]
|
||||||
|
[Description("添加时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("AddTime", "添加时间", "")]
|
||||||
|
public DateTime AddTime { get { return _AddTime; } set { if (OnPropertyChanging(__.AddTime, value)) { _AddTime = value; OnPropertyChanged(__.AddTime); } } }
|
||||||
|
|
||||||
|
private DateTime _UpdateTime;
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
[DisplayName("修改时间")]
|
||||||
|
[Description("修改时间")]
|
||||||
|
[DataObjectField(false, false, true, 0)]
|
||||||
|
[BindColumn("UpdateTime", "修改时间", "")]
|
||||||
|
public DateTime UpdateTime { get { return _UpdateTime; } set { if (OnPropertyChanging(__.UpdateTime, value)) { _UpdateTime = value; OnPropertyChanged(__.UpdateTime); } } }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取/设置 字段值
|
||||||
|
/// <summary>获取/设置 字段值</summary>
|
||||||
|
/// <param name="name">字段名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override Object this[String name]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id : return _Id;
|
||||||
|
case __.RuleId : return _RuleId;
|
||||||
|
case __.Title : return _Title;
|
||||||
|
case __.Content : return _Content;
|
||||||
|
case __.LinkUrl : return _LinkUrl;
|
||||||
|
case __.ImgURL : return _ImgURL;
|
||||||
|
case __.MediaURL : return _MediaURL;
|
||||||
|
case __.MeidaHdURL : return _MeidaHdURL;
|
||||||
|
case __.MediaID : return _MediaID;
|
||||||
|
case __.WXAppAppId : return _WXAppAppId;
|
||||||
|
case __.WXAppPage : return _WXAppPage;
|
||||||
|
case __.Rank : return _Rank;
|
||||||
|
case __.AddTime : return _AddTime;
|
||||||
|
case __.UpdateTime : return _UpdateTime;
|
||||||
|
default: return base[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case __.Id : _Id = value.ToInt(); break;
|
||||||
|
case __.RuleId : _RuleId = value.ToInt(); break;
|
||||||
|
case __.Title : _Title = Convert.ToString(value); break;
|
||||||
|
case __.Content : _Content = Convert.ToString(value); break;
|
||||||
|
case __.LinkUrl : _LinkUrl = Convert.ToString(value); break;
|
||||||
|
case __.ImgURL : _ImgURL = Convert.ToString(value); break;
|
||||||
|
case __.MediaURL : _MediaURL = Convert.ToString(value); break;
|
||||||
|
case __.MeidaHdURL : _MeidaHdURL = Convert.ToString(value); break;
|
||||||
|
case __.MediaID : _MediaID = Convert.ToString(value); break;
|
||||||
|
case __.WXAppAppId : _WXAppAppId = Convert.ToString(value); break;
|
||||||
|
case __.WXAppPage : _WXAppPage = Convert.ToString(value); break;
|
||||||
|
case __.Rank : _Rank = value.ToInt(); break;
|
||||||
|
case __.AddTime : _AddTime = value.ToDateTime(); break;
|
||||||
|
case __.UpdateTime : _UpdateTime = value.ToDateTime(); break;
|
||||||
|
default: base[name] = value; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 字段名
|
||||||
|
/// <summary>取得请求回复的内容字段信息的快捷方式</summary>
|
||||||
|
public partial class _
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public static readonly Field Id = FindByName(__.Id);
|
||||||
|
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
public static readonly Field RuleId = FindByName(__.RuleId);
|
||||||
|
|
||||||
|
/// <summary>回复标题</summary>
|
||||||
|
public static readonly Field Title = FindByName(__.Title);
|
||||||
|
|
||||||
|
/// <summary>回复内容</summary>
|
||||||
|
public static readonly Field Content = FindByName(__.Content);
|
||||||
|
|
||||||
|
/// <summary>详情链接地址</summary>
|
||||||
|
public static readonly Field LinkUrl = FindByName(__.LinkUrl);
|
||||||
|
|
||||||
|
/// <summary>图片地址</summary>
|
||||||
|
public static readonly Field ImgURL = FindByName(__.ImgURL);
|
||||||
|
|
||||||
|
/// <summary>语音或视频地址</summary>
|
||||||
|
public static readonly Field MediaURL = FindByName(__.MediaURL);
|
||||||
|
|
||||||
|
/// <summary>高清语音或者视频地址</summary>
|
||||||
|
public static readonly Field MeidaHdURL = FindByName(__.MeidaHdURL);
|
||||||
|
|
||||||
|
/// <summary>返回的素材ID</summary>
|
||||||
|
public static readonly Field MediaID = FindByName(__.MediaID);
|
||||||
|
|
||||||
|
/// <summary>小程序APPId</summary>
|
||||||
|
public static readonly Field WXAppAppId = FindByName(__.WXAppAppId);
|
||||||
|
|
||||||
|
/// <summary>小程序页面</summary>
|
||||||
|
public static readonly Field WXAppPage = FindByName(__.WXAppPage);
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public static readonly Field Rank = FindByName(__.Rank);
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public static readonly Field AddTime = FindByName(__.AddTime);
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
public static readonly Field UpdateTime = FindByName(__.UpdateTime);
|
||||||
|
|
||||||
|
static Field FindByName(String name) { return Meta.Table.FindByName(name); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>取得请求回复的内容字段名称的快捷方式</summary>
|
||||||
|
public partial class __
|
||||||
|
{
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
public const String Id = "Id";
|
||||||
|
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
public const String RuleId = "RuleId";
|
||||||
|
|
||||||
|
/// <summary>回复标题</summary>
|
||||||
|
public const String Title = "Title";
|
||||||
|
|
||||||
|
/// <summary>回复内容</summary>
|
||||||
|
public const String Content = "Content";
|
||||||
|
|
||||||
|
/// <summary>详情链接地址</summary>
|
||||||
|
public const String LinkUrl = "LinkUrl";
|
||||||
|
|
||||||
|
/// <summary>图片地址</summary>
|
||||||
|
public const String ImgURL = "ImgURL";
|
||||||
|
|
||||||
|
/// <summary>语音或视频地址</summary>
|
||||||
|
public const String MediaURL = "MediaURL";
|
||||||
|
|
||||||
|
/// <summary>高清语音或者视频地址</summary>
|
||||||
|
public const String MeidaHdURL = "MeidaHdURL";
|
||||||
|
|
||||||
|
/// <summary>返回的素材ID</summary>
|
||||||
|
public const String MediaID = "MediaID";
|
||||||
|
|
||||||
|
/// <summary>小程序APPId</summary>
|
||||||
|
public const String WXAppAppId = "WXAppAppId";
|
||||||
|
|
||||||
|
/// <summary>小程序页面</summary>
|
||||||
|
public const String WXAppPage = "WXAppPage";
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
public const String Rank = "Rank";
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
public const String AddTime = "AddTime";
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
public const String UpdateTime = "UpdateTime";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>请求回复的内容接口</summary>
|
||||||
|
public partial interface IWeixinRequestContent
|
||||||
|
{
|
||||||
|
#region 属性
|
||||||
|
/// <summary>编号</summary>
|
||||||
|
Int32 Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>规则名称</summary>
|
||||||
|
Int32 RuleId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>回复标题</summary>
|
||||||
|
String Title { get; set; }
|
||||||
|
|
||||||
|
/// <summary>回复内容</summary>
|
||||||
|
String Content { get; set; }
|
||||||
|
|
||||||
|
/// <summary>详情链接地址</summary>
|
||||||
|
String LinkUrl { get; set; }
|
||||||
|
|
||||||
|
/// <summary>图片地址</summary>
|
||||||
|
String ImgURL { get; set; }
|
||||||
|
|
||||||
|
/// <summary>语音或视频地址</summary>
|
||||||
|
String MediaURL { get; set; }
|
||||||
|
|
||||||
|
/// <summary>高清语音或者视频地址</summary>
|
||||||
|
String MeidaHdURL { get; set; }
|
||||||
|
|
||||||
|
/// <summary>返回的素材ID</summary>
|
||||||
|
String MediaID { get; set; }
|
||||||
|
|
||||||
|
/// <summary>小程序APPId</summary>
|
||||||
|
String WXAppAppId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>小程序页面</summary>
|
||||||
|
String WXAppPage { get; set; }
|
||||||
|
|
||||||
|
/// <summary>排序</summary>
|
||||||
|
Int32 Rank { get; set; }
|
||||||
|
|
||||||
|
/// <summary>添加时间</summary>
|
||||||
|
DateTime AddTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>修改时间</summary>
|
||||||
|
DateTime UpdateTime { get; set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取/设置 字段值
|
||||||
|
/// <summary>获取/设置 字段值</summary>
|
||||||
|
/// <param name="name">字段名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Object this[String name] { get; set; }
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,12 +35,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
public IActionResult AddArticleCategory()
|
public IActionResult AddArticleCategory()
|
||||||
{
|
{
|
||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
ViewBag.ListTree = list;
|
ViewBag.ListTree = list;
|
||||||
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||||
List<string> listTpls = new List<string>();
|
List<string> listTpls = new List<string>();
|
||||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
foreach (var asmItem in asms)
|
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_Article")).ToList();
|
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList();
|
||||||
if (types.Count == 0) continue;
|
if (types.Count == 0) continue;
|
||||||
@@ -50,6 +53,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
listTpls.Add(viewName);
|
listTpls.Add(viewName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ViewBag.ListTpl = listTpls;
|
ViewBag.ListTpl = listTpls;
|
||||||
Core.Admin.WriteLogActions("查看添加文章栏目页面;");
|
Core.Admin.WriteLogActions("查看添加文章栏目页面;");
|
||||||
return View();
|
return View();
|
||||||
@@ -65,12 +69,9 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "文章栏目标题不能为空!";
|
tip.Message = "文章栏目标题不能为空!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.FilePath))
|
|
||||||
{
|
|
||||||
tip.Message = "文章栏目路径不能为空!";
|
|
||||||
return Json(tip);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(model.FilePath))
|
||||||
|
{
|
||||||
if (!model.FilePath.StartsWith("/"))
|
if (!model.FilePath.StartsWith("/"))
|
||||||
{
|
{
|
||||||
tip.Message = "栏目路径请以/开头!";
|
tip.Message = "栏目路径请以/开头!";
|
||||||
@@ -81,17 +82,69 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "栏目路径结尾不用加上/";
|
tip.Message = "栏目路径结尾不用加上/";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.FilePath.Count(x => x == '/') > 4)
|
if (model.FilePath.Count(x => x == '/') > 4)
|
||||||
{
|
{
|
||||||
tip.Message = "最多只能四级路径!";
|
tip.Message = "最多只能四级路径!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 0))
|
if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, 0, 0))
|
||||||
{
|
{
|
||||||
tip.Message = "栏目路径不可用,请重新填写!";
|
tip.Message = "栏目路径不可用,请重新填写!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
//判断过滤IP地址
|
||||||
|
if (!string.IsNullOrEmpty(model.AllowIp))
|
||||||
|
{
|
||||||
|
string[] strRows = model.AllowIp.Split(new string[] { "\n" }, StringSplitOptions.None);
|
||||||
|
if (strRows != null && strRows.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var row in strRows)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(row))
|
||||||
|
{
|
||||||
|
if (row.IndexOf("-") > -1)
|
||||||
|
{
|
||||||
|
string[] arrIps = row.Split(new string[] { "-" }, StringSplitOptions.None);
|
||||||
|
if (arrIps != null && arrIps.Length > 0)
|
||||||
|
{
|
||||||
|
if (arrIps.Length != 2)
|
||||||
|
{
|
||||||
|
tip.Message = "每一行只能有一个“-”,如果需要限制多个ip段,请换行再输入!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
//判断ip是否符合规则
|
||||||
|
foreach (var ip in arrIps)
|
||||||
|
{
|
||||||
|
if (!Utils.IsIP(ip))
|
||||||
|
{
|
||||||
|
tip.Message = "您输入的IP地址有误:" + ip;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long ip1 = Utils.GetLongIP(arrIps[0]);
|
||||||
|
long ip2 = Utils.GetLongIP(arrIps[1]);
|
||||||
|
if (ip1 > ip2)
|
||||||
|
{
|
||||||
|
tip.Message = "您输入的IP地址段有误,请按小到大输入";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!Utils.IsIP(row))
|
||||||
|
{
|
||||||
|
tip.Message = "您输入的IP地址有误:" + row;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
model.Insert();
|
model.Insert();
|
||||||
Core.Admin.WriteLogActions("添加文章栏目(id:" + model.Id + ");");
|
Core.Admin.WriteLogActions("添加文章栏目(id:" + model.Id + ");");
|
||||||
@@ -112,13 +165,16 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
return EchoTipPage("系统找不到本记录!");
|
return EchoTipPage("系统找不到本记录!");
|
||||||
}
|
}
|
||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
ViewBag.ListTree = list;
|
ViewBag.ListTree = list;
|
||||||
|
|
||||||
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||||
List<string> listTpls = new List<string>();
|
List<string> listTpls = new List<string>();
|
||||||
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
var asms = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
foreach (var asmItem in asms)
|
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_Article")).ToList();
|
var types = asmItem.GetTypes().Where(e => e.Name.StartsWith("Views_Article")).ToList();
|
||||||
if (types.Count == 0) continue;
|
if (types.Count == 0) continue;
|
||||||
@@ -128,6 +184,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
listTpls.Add(viewName);
|
listTpls.Add(viewName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ViewBag.ListTpl = listTpls;
|
ViewBag.ListTpl = listTpls;
|
||||||
Core.Admin.WriteLogActions("查看/编辑文章栏目(id:" + id + ")页面;");
|
Core.Admin.WriteLogActions("查看/编辑文章栏目(id:" + id + ")页面;");
|
||||||
return View(entity);
|
return View(entity);
|
||||||
@@ -155,11 +212,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
Json(tip);
|
Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.FilePath))
|
if (!string.IsNullOrEmpty(model.FilePath))
|
||||||
{
|
{
|
||||||
tip.Message = "文章栏目路径不能为空!";
|
|
||||||
return Json(tip);
|
|
||||||
}
|
|
||||||
if (!model.FilePath.StartsWith("/"))
|
if (!model.FilePath.StartsWith("/"))
|
||||||
{
|
{
|
||||||
tip.Message = "栏目路径请以/开头!";
|
tip.Message = "栏目路径请以/开头!";
|
||||||
@@ -170,12 +224,17 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "栏目路径结尾不用加上/";
|
tip.Message = "栏目路径结尾不用加上/";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.FilePath.Count(x => x == '/') > 4)
|
if (model.FilePath.Count(x => x == '/') > 4)
|
||||||
{
|
{
|
||||||
tip.Message = "最多只能四级路径!";
|
tip.Message = "最多只能四级路径!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
if (!AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 0))
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(model.FilePath) && !AdminUtils.CheckFilePathIsOK(model.FilePath, entity.Id, 0))
|
||||||
{
|
{
|
||||||
tip.Message = "栏目路径不可用,请重新填写!";
|
tip.Message = "栏目路径不可用,请重新填写!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
@@ -192,7 +251,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
entity.Location = ArticleCategory.GetNewLocation(model.PId);
|
entity.Location = ArticleCategory.GetNewLocation(model.PId);
|
||||||
entity.Level = ArticleCategory.GetNewLevel(model.PId);
|
entity.Level = ArticleCategory.GetNewLevel(model.PId);
|
||||||
//修改文章的location
|
//修改文章的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)
|
if (alist != null && alist.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var a in alist)
|
foreach (var a in alist)
|
||||||
@@ -228,19 +287,74 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
entity.Pic = model.Pic;
|
entity.Pic = model.Pic;
|
||||||
entity.FilePath = model.FilePath;
|
entity.FilePath = model.FilePath;
|
||||||
|
|
||||||
|
//判断过滤IP地址
|
||||||
|
if (!string.IsNullOrEmpty(model.AllowIp))
|
||||||
|
{
|
||||||
|
string[] strRows = model.AllowIp.Split(new string[] { "\n" }, StringSplitOptions.None);
|
||||||
|
if (strRows != null && strRows.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var row in strRows)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(row))
|
||||||
|
{
|
||||||
|
if (row.IndexOf("-") > -1)
|
||||||
|
{
|
||||||
|
string[] arrIps = row.Split(new string[] { "-" }, StringSplitOptions.None);
|
||||||
|
if (arrIps != null && arrIps.Length > 0)
|
||||||
|
{
|
||||||
|
if (arrIps.Length != 2)
|
||||||
|
{
|
||||||
|
tip.Message = "每一行只能有一个“-”,如果需要限制多个ip段,请换行再输入!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
//判断ip是否符合规则
|
||||||
|
foreach (var ip in arrIps)
|
||||||
|
{
|
||||||
|
if (!Utils.IsIP(ip))
|
||||||
|
{
|
||||||
|
tip.Message = "您输入的IP地址有误1:" + ip;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long ip1 = Utils.GetLongIP(arrIps[0]);
|
||||||
|
long ip2 = Utils.GetLongIP(arrIps[1]);
|
||||||
|
if (ip1 > ip2)
|
||||||
|
{
|
||||||
|
tip.Message = "您输入的IP地址段有误,请按小到大输入";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!Utils.IsIP(row))
|
||||||
|
{
|
||||||
|
tip.Message = "您输入的IP地址有误2:" + row;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entity.AllowIp = model.AllowIp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entity.AllowIp = "";
|
||||||
|
}
|
||||||
|
|
||||||
entity.Save();
|
entity.Save();
|
||||||
//修改所有文章的路径
|
//修改所有文章的路径
|
||||||
if (idNeedUpdateAllArticleFilePath)
|
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)
|
if(listArticles !=null && listArticles.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var item in listArticles)
|
foreach (var item in listArticles)
|
||||||
{
|
{
|
||||||
item.FilePath = entity.FilePath;
|
item.FilePath = entity.FilePath;
|
||||||
}
|
}
|
||||||
listArticles.BatchUpdate();
|
listArticles.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");");
|
Core.Admin.WriteLogActions("修改文章栏目(id:" + entity.Id + ");");
|
||||||
@@ -281,6 +395,26 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 修改文章栏目排序
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "articlecategory", "JSON")]
|
||||||
|
public IActionResult DoEditCategoryRank(int id, int rank)
|
||||||
|
{
|
||||||
|
ArticleCategory entity = ArticleCategory.Find(ArticleCategory._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
entity.Rank = rank;
|
||||||
|
entity.Update();
|
||||||
|
Admin.WriteLogActions($"修改文章栏目排序(id:{id},排序:{rank});");
|
||||||
|
tip.Message = "修改排序成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 文章
|
#region 文章
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文章栏目管理
|
/// 文章栏目管理
|
||||||
@@ -291,7 +425,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
public IActionResult ArticleList()
|
public IActionResult ArticleList()
|
||||||
{
|
{
|
||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
ViewBag.ListKinds = list;
|
ViewBag.ListKinds = list;
|
||||||
Core.Admin.WriteLogActions("查看文章列表;");
|
Core.Admin.WriteLogActions("查看文章列表;");
|
||||||
return View();
|
return View();
|
||||||
@@ -305,7 +439,23 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
numPerPage = limit;
|
numPerPage = limit;
|
||||||
currentPage = page;
|
currentPage = page;
|
||||||
startRowIndex = (currentPage - 1) * numPerPage;
|
startRowIndex = (currentPage - 1) * numPerPage;
|
||||||
Expression ex = Article._.Id > 0;
|
Expression ex = new Expression(); ;
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory)?"[]": my.Roles.AuthorizedArticleCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
ex &= Article._.KId.In(aclist);
|
||||||
|
}
|
||||||
|
|
||||||
|
//仅显示有权限内容
|
||||||
|
if (my.Roles.OnlyEditMyselfArticle == 1)
|
||||||
|
ex &= Article._.AuthorId == my.Id;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(keyword))
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
{
|
{
|
||||||
@@ -354,7 +504,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
[MyAuthorize("add", "article")]
|
[MyAuthorize("add", "article")]
|
||||||
public IActionResult AddArticle()
|
public IActionResult AddArticle()
|
||||||
{
|
{
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
ViewBag.ListKinds = list;
|
ViewBag.ListKinds = list;
|
||||||
string lastkid = SessionHelper.GetSession("com_add_article_kid").ToString();
|
string lastkid = SessionHelper.GetSession("com_add_article_kid").ToString();
|
||||||
ViewBag.lastkid = lastkid;
|
ViewBag.lastkid = lastkid;
|
||||||
@@ -387,6 +537,28 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "文章图片填写的不是图片格式!";
|
tip.Message = "文章图片填写的不是图片格式!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(model.FileName) && !Utils.ChekHTMLFileNameIsOK(model.FileName))
|
||||||
|
{
|
||||||
|
tip.Message = "静态化文件名错误,请填写正确的,或者留空!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
if (aclist.FindIndex(x => x == model.KId) == -1)
|
||||||
|
{
|
||||||
|
tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//处理文章更多图片
|
//处理文章更多图片
|
||||||
string[] moreImgSrc = Request.Form["nImgUrl"];
|
string[] moreImgSrc = Request.Form["nImgUrl"];
|
||||||
string morIMG = string.Empty;//更多图片的时候用到
|
string morIMG = string.Empty;//更多图片的时候用到
|
||||||
@@ -407,12 +579,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
model.Content = content;
|
model.Content = content;
|
||||||
}
|
}
|
||||||
model.ItemImg = morIMG;
|
model.ItemImg = morIMG;
|
||||||
model.AuthorId = Core.Admin.GetMyInfo().Id;
|
model.AuthorId = my.Id;
|
||||||
model.Insert();
|
model.Insert();
|
||||||
ArticleCategory.UpdateDetailCount(model.KId);
|
ArticleCategory.UpdateDetailCount(model.KId);
|
||||||
SessionHelper.WriteSession("com_add_article_kid", model.KId);
|
SessionHelper.WriteSession("com_add_article_kid", model.KId);
|
||||||
//添加TAG
|
//添加TAG
|
||||||
//Tag.InsertTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title);
|
Tags.InsertTags(model.Tags, Utils.CMSType.Article, model.Id, model.Title);
|
||||||
Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");");
|
Core.Admin.WriteLogActions("添加文章(id:" + model.Id + ");");
|
||||||
tip.Status = JsonTip.SUCCESS;
|
tip.Status = JsonTip.SUCCESS;
|
||||||
tip.Message = "添加文章成功";
|
tip.Message = "添加文章成功";
|
||||||
@@ -425,7 +597,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
[MyAuthorize("edit", "article")]
|
[MyAuthorize("edit", "article")]
|
||||||
public IActionResult EditArticle(int id)
|
public IActionResult EditArticle(int id)
|
||||||
{
|
{
|
||||||
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, false);
|
IList<ArticleCategory> list = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
ViewBag.ListKinds = list;
|
ViewBag.ListKinds = list;
|
||||||
|
|
||||||
Article entity = Article.Find(Article._.Id == id);
|
Article entity = Article.Find(Article._.Id == id);
|
||||||
@@ -470,6 +642,35 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "文章图片填写的不是图片格式!";
|
tip.Message = "文章图片填写的不是图片格式!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
//处理
|
||||||
|
if (!string.IsNullOrEmpty(model.FileName) && !Utils.ChekHTMLFileNameIsOK(model.FileName))
|
||||||
|
{
|
||||||
|
tip.Message = "静态化文件名错误,请填写正确的,或者留空!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
if (aclist.FindIndex(x => x == model.KId) == -1)
|
||||||
|
{
|
||||||
|
tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(my.Roles.OnlyEditMyselfArticle ==1 && entity.AuthorId != my.Id)
|
||||||
|
{
|
||||||
|
tip.Message = "系统限制,您无法编辑非自己添加的文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//处理文章更多图片
|
//处理文章更多图片
|
||||||
string[] moreImgSrc = Request.Form["nImgUrl"];
|
string[] moreImgSrc = Request.Form["nImgUrl"];
|
||||||
string morIMG = string.Empty;//更多图片的时候用到
|
string morIMG = string.Empty;//更多图片的时候用到
|
||||||
@@ -483,8 +684,6 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//处理三个勾选属性的
|
|
||||||
string isnew = Request.Form["IsNew"];
|
string isnew = Request.Form["IsNew"];
|
||||||
model.IsNew = isnew == "1" ? 1 : 0;
|
model.IsNew = isnew == "1" ? 1 : 0;
|
||||||
|
|
||||||
@@ -493,6 +692,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
|
|
||||||
string IsHide = Request.Form["IsHide"];
|
string IsHide = Request.Form["IsHide"];
|
||||||
model.IsHide = IsHide == "1" ? 1 : 0;
|
model.IsHide = IsHide == "1" ? 1 : 0;
|
||||||
|
//处理三个勾选属性的
|
||||||
|
|
||||||
model.Hits = entity.Hits;
|
model.Hits = entity.Hits;
|
||||||
model.UpdateTime = DateTime.Now;
|
model.UpdateTime = DateTime.Now;
|
||||||
|
|
||||||
@@ -503,9 +704,45 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
content = ThumbnailHelper.SaveRemoteImgForContent(content);
|
content = ThumbnailHelper.SaveRemoteImgForContent(content);
|
||||||
model.Content = content;
|
model.Content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
entity.AddTime = model.AddTime;
|
||||||
|
entity.AdsId = model.AdsId;
|
||||||
|
entity.BannerImg = model.BannerImg;
|
||||||
|
entity.Content = model.Content;
|
||||||
|
entity.Description = model.Description;
|
||||||
|
entity.FilePath = model.FilePath;
|
||||||
|
entity.Hits = model.Hits;
|
||||||
|
entity.Icon = model.Icon;
|
||||||
|
entity.IsBest = model.IsBest;
|
||||||
|
entity.IsComment = model.IsComment;
|
||||||
|
entity.IsDel = model.IsDel;
|
||||||
|
entity.IsHide = model.IsHide;
|
||||||
|
entity.IsLock = model.IsLock;
|
||||||
|
entity.IsMember = model.IsMember;
|
||||||
|
entity.IsNew = model.IsNew;
|
||||||
|
entity.IsRecommend = model.IsRecommend;
|
||||||
|
entity.IsTop = model.IsTop;
|
||||||
|
entity.ItemImg = morIMG;
|
||||||
|
entity.Keyword = model.Keyword;
|
||||||
|
entity.KId = model.KId;
|
||||||
|
entity.LinkURL = model.LinkURL;
|
||||||
|
entity.Location = model.Location;
|
||||||
|
entity.Origin = model.Origin;
|
||||||
|
entity.OriginURL = model.OriginURL;
|
||||||
|
entity.Pic = model.Pic;
|
||||||
|
entity.Sequence = model.Sequence;
|
||||||
|
entity.SubTitle = model.SubTitle;
|
||||||
|
entity.Tags = model.Tags;
|
||||||
|
entity.TemplateFile = model.TemplateFile;
|
||||||
|
entity.Title = model.Title;
|
||||||
|
entity.TitleColor = model.TitleColor;
|
||||||
|
entity.UpdateTime = DateTime.Now;
|
||||||
|
entity.FileName = model.FileName;
|
||||||
|
|
||||||
//model.AuthorId = Core.Admin.GetMyInfo().Id;
|
//model.AuthorId = Core.Admin.GetMyInfo().Id;
|
||||||
model.Save();
|
entity.Update();
|
||||||
//Tag.ModifyTags(model.Tags, RTType.RatuoModule.Article, model.Id, model.Title);
|
Tags.ModifyTags(model.Tags, Utils.CMSType.Article, model.Id, model.Title);
|
||||||
Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");");
|
Core.Admin.WriteLogActions("编辑文章(id:" + model.Id + ");");
|
||||||
tip.Status = JsonTip.SUCCESS;
|
tip.Status = JsonTip.SUCCESS;
|
||||||
tip.Message = "编辑文章详情成功";
|
tip.Message = "编辑文章详情成功";
|
||||||
@@ -516,7 +753,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//删除文章
|
//删除文章
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[MyAuthorize("del", "article", "JSON")]
|
[MyAuthorize("del", "article", "JSON")]
|
||||||
public JsonResult DelArtice(int id)
|
public JsonResult DelArticle(int id)
|
||||||
{
|
{
|
||||||
Article entity = Article.Find(Article._.Id == id);
|
Article entity = Article.Find(Article._.Id == id);
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
@@ -524,9 +761,32 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "系统找不到本文章!";
|
tip.Message = "系统找不到本文章!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedArticleCagegory) ? "[]" : my.Roles.AuthorizedArticleCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
if (aclist.FindIndex(x => x == entity.KId) == -1)
|
||||||
|
{
|
||||||
|
tip.Message = "者您没这个栏目的权限,无法删除该栏目文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (my.Roles.OnlyEditMyselfArticle == 1 && entity.AuthorId != my.Id)
|
||||||
|
{
|
||||||
|
tip.Message = "系统限制,您无法删除非自己添加的文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int kid = entity.Id;
|
int kid = entity.Id;
|
||||||
//删除TAG
|
//删除TAG
|
||||||
//Tag.DeleteTag(RTType.RatuoModule.Article, entity.Id);
|
Tags.DeleteTag(entity.Tags, Utils.CMSType.Article, entity.Id);
|
||||||
Core.Admin.WriteLogActions("删除文章(id:" + entity.Id + ");");
|
Core.Admin.WriteLogActions("删除文章(id:" + entity.Id + ");");
|
||||||
entity.Delete();
|
entity.Delete();
|
||||||
ArticleCategory.UpdateDetailCount(kid);
|
ArticleCategory.UpdateDetailCount(kid);
|
||||||
@@ -536,6 +796,26 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 修改文章排序
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "article", "JSON")]
|
||||||
|
public IActionResult DoEditArticleSequence(int id, int rank)
|
||||||
|
{
|
||||||
|
Article entity = Article.Find(Article._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
entity.Sequence = rank;
|
||||||
|
entity.Update();
|
||||||
|
Admin.WriteLogActions($"修改文章排序(id:{id},排序:{rank});");
|
||||||
|
tip.Message = "修改排序成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 迁移文章
|
#region 迁移文章
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[MyAuthorize("batch", "article")]
|
[MyAuthorize("batch", "article")]
|
||||||
@@ -661,5 +941,51 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 批量删除文章
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("batch", "article", "JSON")]
|
||||||
|
public IActionResult DoBatchDelArticle(string ids)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ids))
|
||||||
|
{
|
||||||
|
tip.Message = "请最少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
List<int> listIds = new List<int>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
listIds = JsonConvert.DeserializeObject<List<int>>(ids);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tip.Message = "转换出错:" + ex.Message;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listIds == null || listIds.Count < 1)
|
||||||
|
{
|
||||||
|
tip.Message = "请至少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
IList<Article> list = Article.FindAll(Article._.Id.In(listIds), null, null, 0, 0);
|
||||||
|
if (list == null || list.Count < 1)
|
||||||
|
{
|
||||||
|
tip.Message = "请至少选择一篇文章!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
item.IsHide = 0;
|
||||||
|
}
|
||||||
|
list.Delete();
|
||||||
|
Admin.WriteLogActions($"批量删除文章:{ids};");
|
||||||
|
tip.Message = "批量删除文章成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,410 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using XCode;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using COMCMS.Web.Common;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using COMCMS.Web.Models;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using COMCMS.Core.Models;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
|
{
|
||||||
|
public class AttachController : AdminBaseController
|
||||||
|
{
|
||||||
|
private readonly SystemSetting _attachsetting;
|
||||||
|
private IWebHostEnvironment _env;
|
||||||
|
private AttachConfigEntity attach;
|
||||||
|
public AttachController(IWebHostEnvironment env, IOptions<SystemSetting> attachsetting)
|
||||||
|
{
|
||||||
|
attach = Config.GetSystemConfig().AttachConfigEntity;
|
||||||
|
_env = env;
|
||||||
|
_attachsetting = attachsetting.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 附件管理
|
||||||
|
[HttpGet]
|
||||||
|
[MyAuthorize("viewlist", "attach")]
|
||||||
|
public IActionResult AttachList()
|
||||||
|
{
|
||||||
|
List<DirInfo> all = getAllAttach("");
|
||||||
|
string allJson = JsonConvert.SerializeObject(all);
|
||||||
|
//string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";//基础目录
|
||||||
|
ViewBag.folderJson = allJson;
|
||||||
|
//string[] arrDirs = Directory.GetDirectories(basePath);
|
||||||
|
return View();
|
||||||
|
//return Content(JsonConvert.SerializeObject(allJson));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取附件所有目录
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("viewlist", "attach", "JSON")]
|
||||||
|
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 = "目录不存在" });
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#region 获取附件目录和所有子目录树
|
||||||
|
/// <summary>
|
||||||
|
/// 所有所有附件目录树
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="subdir">子目录,需要完整,如:images/2020</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<DirInfo> getAllAttach(string subdir)
|
||||||
|
{
|
||||||
|
List<DirInfo> list = new List<DirInfo>();
|
||||||
|
string basePath = $"{_env.WebRootPath}{Path.DirectorySeparatorChar}{attach.AttachPatch}{Path.DirectorySeparatorChar}";//基础目录
|
||||||
|
if (!string.IsNullOrEmpty(subdir))
|
||||||
|
{
|
||||||
|
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 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 = dirName,
|
||||||
|
path = nextSubDir,
|
||||||
|
//fullPath = item,
|
||||||
|
subList = tpmList
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
#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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,278 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using XCode;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using COMCMS.Web.Common;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
|
{
|
||||||
|
public class DataDictionaryController : AdminBaseController
|
||||||
|
{
|
||||||
|
#region 数据字典首页
|
||||||
|
[HttpGet]
|
||||||
|
[MyAuthorize("viewlist", "datadictionary")]
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
Admin.WriteLogActions($"查看数据字典页面;");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 异步获取数据字典列表,带分页
|
||||||
|
[MyAuthorize("viewlist", "datadictionary", "JSON")]
|
||||||
|
public IActionResult GetDataDictionaryList(string keyword, int page = 1, int limit = 20)
|
||||||
|
{
|
||||||
|
int numPerPage, currentPage, startRowIndex;
|
||||||
|
|
||||||
|
numPerPage = limit;
|
||||||
|
currentPage = page;
|
||||||
|
startRowIndex = (currentPage - 1) * numPerPage;
|
||||||
|
Expression ex = new Expression();
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
|
{
|
||||||
|
if (Utils.IsInt(keyword))
|
||||||
|
{
|
||||||
|
ex &= (DataDictionary._.Id == int.Parse(keyword) | DataDictionary._.Key.Contains(keyword));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ex &= DataDictionary._.Key.Contains(keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IList<DataDictionary> list = DataDictionary.FindAll(ex, DataDictionary._.Rank.Asc().And(DataDictionary._.Id.Desc()), null, startRowIndex, numPerPage);
|
||||||
|
long totalCount = DataDictionary.FindCount(ex, DataDictionary._.Rank.Asc().And(DataDictionary._.Id.Desc()), null, startRowIndex, numPerPage);
|
||||||
|
//return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||||
|
return Json(new { total = totalCount, rows = list });
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取数据字典
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "datadictionary", "JSON")]
|
||||||
|
public IActionResult GetDataDictionary(int id)
|
||||||
|
{
|
||||||
|
var entity = DataDictionary.Find(DataDictionary._.Id == id);
|
||||||
|
if(entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
var detail = new
|
||||||
|
{
|
||||||
|
id = entity.Id,
|
||||||
|
rank = entity.Rank,
|
||||||
|
description = entity.Description,
|
||||||
|
key = entity.Key
|
||||||
|
};
|
||||||
|
tip.Detail = detail;
|
||||||
|
tip.Message = "获取成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
Admin.WriteLogActions($"查看数据字典({entity.Id});");
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 保存(添加或者修改)数据字典
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("add", "datadictionary", "JSON")]
|
||||||
|
public IActionResult DoSaveDataDictionary(DataDictionary model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Key))
|
||||||
|
{
|
||||||
|
tip.Message = "请输入字典Key";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if(model.Id==0 && DataDictionary.FindCount(DataDictionary._.Key== model.Key, null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tip.Message = "此字典Key已经存在,请填写其他的!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if(model.Id> 0 && DataDictionary.FindCount(DataDictionary._.Key == model.Key & DataDictionary._.Id !=model.Id, null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tip.Message = "此字典Key已经存在,请填写其他的!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
DataDictionary entity = null;
|
||||||
|
string tipMessage = "";
|
||||||
|
if (model.Id > 0)
|
||||||
|
{
|
||||||
|
entity = DataDictionary.Find(DataDictionary._.Id == model.Id);
|
||||||
|
if(entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
tipMessage = "修改";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entity = new DataDictionary();
|
||||||
|
entity.AddTime = DateTime.Now;
|
||||||
|
tipMessage = "添加";
|
||||||
|
}
|
||||||
|
entity.Key = model.Key;
|
||||||
|
entity.Description = model.Description;
|
||||||
|
entity.Rank = model.Rank;
|
||||||
|
entity.Save();
|
||||||
|
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = $"{tipMessage}数据字典成功!";
|
||||||
|
Admin.WriteLogActions($"{tipMessage}数据字典成功({entity.Id});");
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 删除数据字典
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("del", "datadictionary", "JSON")]
|
||||||
|
public IActionResult DelDataDictionary(int id)
|
||||||
|
{
|
||||||
|
var entity = DataDictionary.Find(DataDictionary._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
//获取数据字典详情
|
||||||
|
IList<DataDictionaryDetail> list = DataDictionaryDetail.FindAll(DataDictionaryDetail._.DataDictionaryId == entity.Id, null, null, 0, 0);
|
||||||
|
if (list.Count > 0)
|
||||||
|
{
|
||||||
|
list.Delete();
|
||||||
|
}
|
||||||
|
Admin.WriteLogActions($"删除数据字典({entity.Id});");
|
||||||
|
entity.Delete();
|
||||||
|
|
||||||
|
|
||||||
|
tip.Message = "删除数据字典成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 获取字典值列表
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "datadictionary", "JSON")]
|
||||||
|
public IActionResult GetDataDictionaryDetail(int id)
|
||||||
|
{
|
||||||
|
var entity = DataDictionary.Find(DataDictionary._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
//获取数据字典详情
|
||||||
|
IList<DataDictionaryDetail> list = DataDictionaryDetail.FindAll(DataDictionaryDetail._.DataDictionaryId == entity.Id, DataDictionaryDetail._.Rank.Asc().And(DataDictionaryDetail._.Id.Desc()), null, 0, 0);
|
||||||
|
|
||||||
|
List<object> detail = new List<object>();
|
||||||
|
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
detail.Add(new
|
||||||
|
{
|
||||||
|
dataDictionaryId = item.DataDictionaryId,
|
||||||
|
id = item.Id,
|
||||||
|
val = item.Val,
|
||||||
|
title = item.Title,
|
||||||
|
description = item.Description,
|
||||||
|
rank = item.Rank,
|
||||||
|
isDefault = item.IsDefault,
|
||||||
|
addTime = item.AddTime.ToString("yyyy-MM-dd HH:mm")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
tip.Detail = detail;
|
||||||
|
tip.Message = "获取成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
Admin.WriteLogActions($"查看数据字典值列表({entity.Id});");
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 保存字典值详情
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("add", "datadictionary", "JSON")]
|
||||||
|
public IActionResult DoSaveDataDictionaryDetail(DataDictionaryDetail model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Val))
|
||||||
|
{
|
||||||
|
tip.Message = "请输入字典值";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if(model.DataDictionaryId == 0)
|
||||||
|
{
|
||||||
|
tip.Message = "请先选择一个字典进行查看后再编辑或者添加!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if (model.Id == 0 && DataDictionaryDetail.FindCount(DataDictionaryDetail._.Val == model.Val & DataDictionaryDetail._.DataDictionaryId == model.DataDictionaryId, null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tip.Message = "此字典值已经存在,请填写其他的!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if (model.Id > 0 && DataDictionaryDetail.FindCount(DataDictionaryDetail._.Val == model.Val & DataDictionaryDetail._.DataDictionaryId == model.DataDictionaryId & DataDictionaryDetail._.Id != model.Id, null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tip.Message = "此字典值已经存在,请填写其他的!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
DataDictionaryDetail entity = null;
|
||||||
|
string tipMessage = "";
|
||||||
|
if (model.Id > 0)
|
||||||
|
{
|
||||||
|
entity = DataDictionaryDetail.Find(DataDictionaryDetail._.Id == model.Id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
tipMessage = "修改";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entity = new DataDictionaryDetail();
|
||||||
|
entity.AddTime = DateTime.Now;
|
||||||
|
entity.DataDictionaryId = model.DataDictionaryId;
|
||||||
|
tipMessage = "添加";
|
||||||
|
}
|
||||||
|
entity.Val = model.Val;
|
||||||
|
entity.Description = model.Description;
|
||||||
|
entity.Title = model.Title;
|
||||||
|
entity.IsDefault = model.IsDefault;
|
||||||
|
entity.Rank = model.Rank;
|
||||||
|
entity.Save();
|
||||||
|
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = $"{tipMessage}数据字典成功!";
|
||||||
|
Admin.WriteLogActions($"{tipMessage}数据字典成功({entity.Id});");
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 删除数据字典
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("del", "datadictionary", "JSON")]
|
||||||
|
public IActionResult DelDataDictionaryDetail(int id)
|
||||||
|
{
|
||||||
|
var entity = DataDictionaryDetail.Find(DataDictionaryDetail._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin.WriteLogActions($"删除数据字典详情({entity.Id});");
|
||||||
|
entity.Delete();
|
||||||
|
|
||||||
|
tip.Message = "删除数据字典值详情成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using COMCMS.Common;
|
||||||
|
using COMCMS.Core;
|
||||||
|
using XCode;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using COMCMS.Web.Common;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
|
{
|
||||||
|
public class DepartmentController : AdminBaseController
|
||||||
|
{
|
||||||
|
#region 部门管理
|
||||||
|
/// <summary>
|
||||||
|
/// 部门列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[MyAuthorize("viewlist", "department")]
|
||||||
|
public IActionResult DepartmentList()
|
||||||
|
{
|
||||||
|
IList<Department> list = Department.GetListTree(0, -1, false, true);
|
||||||
|
Core.Admin.WriteLogActions("查看部门列表页面;");
|
||||||
|
return View(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#region 添加部门
|
||||||
|
[MyAuthorize("add", "department")]
|
||||||
|
public IActionResult AddDepartment()
|
||||||
|
{
|
||||||
|
//获取上级栏目
|
||||||
|
IList<Department> list = Department.GetListTree(0, 0, true, false);
|
||||||
|
ViewBag.ListTree = list;
|
||||||
|
Department entity = new Department();
|
||||||
|
Core.Admin.WriteLogActions("查看添加部门页面;");
|
||||||
|
return View(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("add", "department", "JSON")]
|
||||||
|
public IActionResult AddDepartment(Department model)
|
||||||
|
{
|
||||||
|
//获取上级栏目
|
||||||
|
if (string.IsNullOrWhiteSpace(model.DepartmentName))
|
||||||
|
{
|
||||||
|
tip.Message = "部门名称不能为空!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
model.Insert();
|
||||||
|
Core.Admin.WriteLogActions("添加部门(id:" + model.Id + ");");
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "添加部门成功";
|
||||||
|
tip.ReturnUrl = "close";
|
||||||
|
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 编辑部门
|
||||||
|
//编辑部门
|
||||||
|
[HttpGet]
|
||||||
|
[MyAuthorize("edit", "department")]
|
||||||
|
public IActionResult EditDepartment(int id)
|
||||||
|
{
|
||||||
|
Department entity = Department.Find(Department._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
return EchoTipPage("系统找不到本记录!");
|
||||||
|
}
|
||||||
|
//获取上级栏目
|
||||||
|
IList<Department> list = Department.GetListTree(0, 0, true, false);
|
||||||
|
ViewBag.ListTree = list;
|
||||||
|
Core.Admin.WriteLogActions("查看/编辑部门(id:" + id + ")页面;");
|
||||||
|
return View(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "department", "JSON")]
|
||||||
|
public IActionResult EditDepartment(Department model)
|
||||||
|
{
|
||||||
|
if (model.Id <= 0)
|
||||||
|
{
|
||||||
|
tip.Message = "错误参数传递!";
|
||||||
|
Json(tip);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrWhiteSpace(model.DepartmentName))
|
||||||
|
{
|
||||||
|
tip.Message = "部门名称不能为空!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
Department entity = Department.Find(Department._.Id == model.Id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录!";
|
||||||
|
Json(tip);
|
||||||
|
}
|
||||||
|
//赋值
|
||||||
|
|
||||||
|
entity.DepartmentName = model.DepartmentName;
|
||||||
|
entity.Pic = model.Pic;
|
||||||
|
entity.DepartmentDescription = model.DepartmentDescription;
|
||||||
|
entity.Rank = model.Rank;
|
||||||
|
entity.Pic = model.Pic;
|
||||||
|
entity.Tel = model.Tel;
|
||||||
|
entity.Fax = model.Fax;
|
||||||
|
entity.Email = model.Email;
|
||||||
|
entity.IsNotAllowDel = Request.Form["IsNotAllowDel"] == "1" ? 1 : 0;
|
||||||
|
//如果修改了路径
|
||||||
|
if (entity.PId != model.PId)
|
||||||
|
{
|
||||||
|
entity.PId = model.PId;
|
||||||
|
entity.Location = Department.GetNewLocation(model.PId);
|
||||||
|
}
|
||||||
|
entity.Save();
|
||||||
|
|
||||||
|
Core.Admin.WriteLogActions("修改部门(id:" + entity.Id + ");");
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "修改部门成功";
|
||||||
|
tip.ReturnUrl = "close";
|
||||||
|
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除栏目
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("del", "department", "JSON")]
|
||||||
|
public JsonResult DelDepartment(int id)
|
||||||
|
{
|
||||||
|
Department entity = Department.Find(Department._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本部门!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
if (Department.FindCount(Department._.PId == entity.Id, null, null, 0, 0) > 0)
|
||||||
|
{
|
||||||
|
tip.Message = "部门目有下级部门,不允许删除!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
//删除文章
|
||||||
|
|
||||||
|
Core.Admin.WriteLogActions("删除部门(id:" + entity.Id + ");");
|
||||||
|
entity.IsDel =1;
|
||||||
|
entity.Update();
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Message = "删除部门成功";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,16 +10,21 @@ using XCode;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using COMCMS.Web.Common;
|
using COMCMS.Web.Common;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using NewLife.Log;
|
||||||
|
using NewLife;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
{
|
{
|
||||||
[Area("AdminCP")]
|
[Area("AdminCP")]
|
||||||
public class IndexController : AdminBaseController
|
public class IndexController : AdminBaseController
|
||||||
{
|
{
|
||||||
private readonly IHostingEnvironment _env;
|
private readonly IWebHostEnvironment _env;
|
||||||
public IndexController(IHostingEnvironment env)
|
public IndexController(IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
_env = env;
|
_env = env;
|
||||||
|
MachineInfo.RegisterAsync();
|
||||||
}
|
}
|
||||||
#region 后台首页
|
#region 后台首页
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
@@ -32,7 +37,6 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
|
|
||||||
Admin admin = Admin.GetMyInfo();
|
Admin admin = Admin.GetMyInfo();
|
||||||
ViewBag.admin = admin;
|
ViewBag.admin = admin;
|
||||||
|
|
||||||
//获取菜单
|
//获取菜单
|
||||||
List<AdminMenu> list = new List<AdminMenu>();
|
List<AdminMenu> list = new List<AdminMenu>();
|
||||||
//这里需要获取权限,暂时先所有
|
//这里需要获取权限,暂时先所有
|
||||||
@@ -52,7 +56,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
#region 后台主界面
|
#region 后台主界面
|
||||||
public IActionResult Main()
|
public IActionResult Main()
|
||||||
{
|
{
|
||||||
string remoteip = Request.HttpContext.Connection.RemoteIpAddress.ToString();
|
string remoteip = Utils.GetIP();
|
||||||
string host = Request.HttpContext.Request.Host.Host;
|
string host = Request.HttpContext.Request.Host.Host;
|
||||||
string port = Request.HttpContext.Connection.RemotePort.ToString();
|
string port = Request.HttpContext.Connection.RemotePort.ToString();
|
||||||
|
|
||||||
@@ -62,6 +66,9 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
ViewBag.contentPath = _env.ContentRootPath;
|
ViewBag.contentPath = _env.ContentRootPath;
|
||||||
ViewBag.rootPath = _env.WebRootPath;
|
ViewBag.rootPath = _env.WebRootPath;
|
||||||
|
|
||||||
|
Admin admin = Admin.GetMyInfo();
|
||||||
|
ViewBag.admin = admin;
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -74,5 +81,79 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 释放进程内存
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult DoMemoryFree()
|
||||||
|
{
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
if (my.Roles.IsSuperAdmin == 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
GC.Collect();
|
||||||
|
|
||||||
|
// 释放当前进程所占用的内存
|
||||||
|
var p = Process.GetCurrentProcess();
|
||||||
|
SetProcessWorkingSetSize(p.Handle, -1, -1);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
XTrace.WriteException(ex);
|
||||||
|
tip.Message = "释放内存执行失败!" + ex.Message;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
|
||||||
|
tip.Message = "释放内存成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tip.Message = "您没有权限执行本操作";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern Boolean SetProcessWorkingSetSize(IntPtr proc, Int32 min, Int32 max);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取CPU内存等参数
|
||||||
|
[HttpPost]
|
||||||
|
[AutoValidateAntiforgeryToken]
|
||||||
|
public IActionResult GetMachineInfo()
|
||||||
|
{
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
if (my.Roles.IsSuperAdmin == 0)
|
||||||
|
{
|
||||||
|
tip.Message = "您没有权限执行本操作!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
var mi = MachineInfo.Current ?? new MachineInfo();
|
||||||
|
var process = Process.GetCurrentProcess();
|
||||||
|
|
||||||
|
double CpuRate = Math.Round(mi.CpuRate, 2);
|
||||||
|
string AvailableMemory = (mi.AvailableMemory / 1024 / 1024).ToString("n0") + "M";
|
||||||
|
decimal memoryUsage = Math.Round((decimal)mi.AvailableMemory / (decimal)mi.Memory * 100M, 2);
|
||||||
|
string WorkingSet64 = (process.WorkingSet64 / 1024 / 1024).ToString("n0") + "M";
|
||||||
|
string PrivateMemorySize64 = (process.PrivateMemorySize64 / 1024 / 1024).ToString("n0") + "M";
|
||||||
|
string GCMemory = (GC.GetTotalMemory(false) / 1024 / 1024).ToString("n0") + "M";
|
||||||
|
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
tip.Detail = new
|
||||||
|
{
|
||||||
|
cpuRate = CpuRate,
|
||||||
|
availableMemory = AvailableMemory,
|
||||||
|
memoryUsage = memoryUsage,
|
||||||
|
workingSet64 = WorkingSet64,
|
||||||
|
privateMemorySize64 = PrivateMemorySize64,
|
||||||
|
gCMemory = GCMemory
|
||||||
|
};
|
||||||
|
|
||||||
|
tip.Message = "获取成功";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,13 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
{
|
{
|
||||||
return Redirect("/AdminCP");
|
return Redirect("/AdminCP");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasData = AdminMenu.FindCount(null, null, null, 0, 0) > 0;
|
||||||
|
if (!hasData)
|
||||||
|
{
|
||||||
|
return Redirect("/Home/Install");
|
||||||
|
}
|
||||||
|
|
||||||
string key = Utils.GetRandomChar(12);
|
string key = Utils.GetRandomChar(12);
|
||||||
SessionHelper.WriteSession("des_key", key);
|
SessionHelper.WriteSession("des_key", key);
|
||||||
ViewBag.key = key;
|
ViewBag.key = key;
|
||||||
@@ -43,6 +50,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
{
|
{
|
||||||
string strUserName = Request.Form["username"];
|
string strUserName = Request.Form["username"];
|
||||||
string strPassWord = Request.Form["password"];
|
string strPassWord = Request.Form["password"];
|
||||||
|
string code = Request.Form["code"];
|
||||||
|
|
||||||
if (strUserName.Length % 8 != 0)
|
if (strUserName.Length % 8 != 0)
|
||||||
{
|
{
|
||||||
@@ -62,6 +70,21 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Other = "reload";
|
tip.Other = "reload";
|
||||||
return Json(tip);
|
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 username = "";
|
||||||
string password = "";
|
string password = "";
|
||||||
@@ -122,8 +145,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public IActionResult Logout()
|
public IActionResult Logout()
|
||||||
{
|
{
|
||||||
//Admin.ClearInfo();
|
Admin.ClearInfo();
|
||||||
Admin.ClearInfoAsync().Wait();
|
//Admin.ClearInfoAsync().Wait();
|
||||||
return Redirect("~/AdminCP/Login");
|
return Redirect("~/AdminCP/Login");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Hosting;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using COMCMS.Web.Models;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
{
|
{
|
||||||
@@ -23,6 +25,16 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
[DisplayName("管理员")]
|
[DisplayName("管理员")]
|
||||||
public class MemberController : AdminBaseController
|
public class MemberController : AdminBaseController
|
||||||
{
|
{
|
||||||
|
private readonly SystemSetting _systemSetting;
|
||||||
|
private IWebHostEnvironment _env;
|
||||||
|
private AttachConfigEntity attach;
|
||||||
|
public MemberController(IWebHostEnvironment env, IOptions<SystemSetting> systemSetting)
|
||||||
|
{
|
||||||
|
attach = Config.GetSystemConfig().AttachConfigEntity;
|
||||||
|
_env = env;
|
||||||
|
_systemSetting = systemSetting.Value;
|
||||||
|
}
|
||||||
|
|
||||||
#region 修改密码
|
#region 修改密码
|
||||||
//修改个人信息
|
//修改个人信息
|
||||||
[MyAuthorize("view", "editme")]
|
[MyAuthorize("view", "editme")]
|
||||||
@@ -30,6 +42,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
{
|
{
|
||||||
Core.Admin my = Core.Admin.GetMyInfo();
|
Core.Admin my = Core.Admin.GetMyInfo();
|
||||||
Core.Admin.WriteLogActions("查看/编辑我的信息;");
|
Core.Admin.WriteLogActions("查看/编辑我的信息;");
|
||||||
|
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||||
return View(my);
|
return View(my);
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@@ -88,6 +101,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "新密码不能小于5个字符!";
|
tip.Message = "新密码不能小于5个字符!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_systemSetting.PasswordStrength > 0)
|
||||||
|
{
|
||||||
|
if (!Utils.CheckPasswordStrength(newPwd, _systemSetting.PasswordStrength))
|
||||||
|
{
|
||||||
|
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (newPwd != renewPwd)
|
if (newPwd != renewPwd)
|
||||||
{
|
{
|
||||||
tip.Message = "您输入的两次密码不一样!";
|
tip.Message = "您输入的两次密码不一样!";
|
||||||
@@ -131,7 +153,14 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//获取所有的菜单列表
|
//获取所有的菜单列表
|
||||||
IList<AdminMenu> list = AdminMenu.GetListTree(0, -1, false, false);
|
IList<AdminMenu> list = AdminMenu.GetListTree(0, -1, false, false);
|
||||||
ViewBag.MenuList = list;
|
ViewBag.MenuList = list;
|
||||||
Core.Admin.WriteLogActions("查看添加管理页面;");
|
//获取所有文章 商品栏目
|
||||||
|
IList<ArticleCategory> aclist = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
|
ViewBag.aclist = aclist;
|
||||||
|
|
||||||
|
IList<Category> pclist = Category.GetListTree(0, -1, true, true);
|
||||||
|
ViewBag.pclist = pclist;
|
||||||
|
|
||||||
|
Core.Admin.WriteLogActions("查看添加管理组页面;");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
//执行添加管理组
|
//执行添加管理组
|
||||||
@@ -143,6 +172,13 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
string RoleDescription = fc["RoleDescription"];
|
string RoleDescription = fc["RoleDescription"];
|
||||||
string IsSuperAdmin = fc["IsSuperAdmin"];
|
string IsSuperAdmin = fc["IsSuperAdmin"];
|
||||||
string NotAllowDel = fc["NotAllowDel"];
|
string NotAllowDel = fc["NotAllowDel"];
|
||||||
|
string OnlyEditMyselfArticle = fc["OnlyEditMyselfArticle"];
|
||||||
|
string OnlyEditMyselfProduct = fc["OnlyEditMyselfProduct"];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(OnlyEditMyselfArticle) || !Utils.IsInt(OnlyEditMyselfProduct)) OnlyEditMyselfProduct = "0";
|
||||||
|
if (string.IsNullOrEmpty(OnlyEditMyselfProduct) || !Utils.IsInt(OnlyEditMyselfProduct)) OnlyEditMyselfProduct = "0";
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(RoleName))
|
if (string.IsNullOrEmpty(RoleName))
|
||||||
{
|
{
|
||||||
tip.Message = "管理组名称不能为空!";
|
tip.Message = "管理组名称不能为空!";
|
||||||
@@ -155,6 +191,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
entity.RoleDescription = RoleDescription;
|
entity.RoleDescription = RoleDescription;
|
||||||
entity.IsSuperAdmin = int.Parse(IsSuperAdmin);
|
entity.IsSuperAdmin = int.Parse(IsSuperAdmin);
|
||||||
entity.NotAllowDel = !string.IsNullOrEmpty(NotAllowDel) && NotAllowDel == "1" ? 1 : 0;
|
entity.NotAllowDel = !string.IsNullOrEmpty(NotAllowDel) && NotAllowDel == "1" ? 1 : 0;
|
||||||
|
entity.OnlyEditMyselfArticle = int.Parse(OnlyEditMyselfArticle);
|
||||||
|
entity.OnlyEditMyselfProduct = int.Parse(OnlyEditMyselfProduct);
|
||||||
|
|
||||||
//处理权限
|
//处理权限
|
||||||
if (entity.IsSuperAdmin == 1)
|
if (entity.IsSuperAdmin == 1)
|
||||||
@@ -208,6 +246,30 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//处理文章和商品栏目权限
|
||||||
|
string[] acpower = Request.Form["acpower"];
|
||||||
|
string[] pcpower = Request.Form["pcpower"];
|
||||||
|
|
||||||
|
List<int> acids = new List<int>();
|
||||||
|
List<int> pcids = new List<int>();
|
||||||
|
foreach (var item in acpower)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item) && Utils.IsInt(item))
|
||||||
|
{
|
||||||
|
acids.Add(int.Parse(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var item in pcpower)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item) && Utils.IsInt(item))
|
||||||
|
{
|
||||||
|
pcids.Add(int.Parse(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.AuthorizedArticleCagegory = JsonConvert.SerializeObject(acids);
|
||||||
|
entity.AuthorizedCagegory = JsonConvert.SerializeObject(pcids);
|
||||||
|
|
||||||
entity.Insert();
|
entity.Insert();
|
||||||
tip.Status = JsonTip.SUCCESS;
|
tip.Status = JsonTip.SUCCESS;
|
||||||
tip.Message = "添加管理组成功";
|
tip.Message = "添加管理组成功";
|
||||||
@@ -230,8 +292,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
entity.Powers = "[]";
|
entity.Powers = "[]";
|
||||||
if (string.IsNullOrEmpty(entity.Menus))
|
if (string.IsNullOrEmpty(entity.Menus))
|
||||||
entity.Menus = "[]";
|
entity.Menus = "[]";
|
||||||
|
if (string.IsNullOrEmpty(entity.AuthorizedArticleCagegory))
|
||||||
|
entity.AuthorizedArticleCagegory = "[]";
|
||||||
|
if (string.IsNullOrEmpty(entity.AuthorizedCagegory))
|
||||||
|
entity.AuthorizedCagegory = "[]";
|
||||||
//获取所有的菜单列表
|
//获取所有的菜单列表
|
||||||
IList<AdminMenu> list = AdminMenu.GetListTree(0, -1, false, false);
|
IList<AdminMenu> list = AdminMenu.GetListTree(0, -1, false, false);
|
||||||
|
|
||||||
|
//获取所有文章 商品栏目
|
||||||
|
IList<ArticleCategory> aclist = ArticleCategory.GetListTree(0, -1, true, true);
|
||||||
|
ViewBag.aclist = aclist;
|
||||||
|
|
||||||
|
IList<Category> pclist = Category.GetListTree(0, -1, true, true);
|
||||||
|
ViewBag.pclist = pclist;
|
||||||
|
|
||||||
ViewBag.MenuList = list;
|
ViewBag.MenuList = list;
|
||||||
Core.Admin.WriteLogActions($"查看管理组({id})详情;");
|
Core.Admin.WriteLogActions($"查看管理组({id})详情;");
|
||||||
return View(entity);
|
return View(entity);
|
||||||
@@ -246,6 +320,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
string RoleDescription = fc["RoleDescription"];
|
string RoleDescription = fc["RoleDescription"];
|
||||||
string IsSuperAdmin = fc["IsSuperAdmin"];
|
string IsSuperAdmin = fc["IsSuperAdmin"];
|
||||||
string NotAllowDel = fc["NotAllowDel"];
|
string NotAllowDel = fc["NotAllowDel"];
|
||||||
|
string OnlyEditMyselfArticle = fc["OnlyEditMyselfArticle"];
|
||||||
|
string OnlyEditMyselfProduct = fc["OnlyEditMyselfProduct"];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(OnlyEditMyselfArticle) || !Utils.IsInt(OnlyEditMyselfProduct)) OnlyEditMyselfProduct = "0";
|
||||||
|
if (string.IsNullOrEmpty(OnlyEditMyselfProduct) || !Utils.IsInt(OnlyEditMyselfProduct)) OnlyEditMyselfProduct = "0";
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Id))
|
if (string.IsNullOrEmpty(Id))
|
||||||
{
|
{
|
||||||
tip.Message = "错误参数传递!";
|
tip.Message = "错误参数传递!";
|
||||||
@@ -268,6 +348,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
entity.RoleDescription = RoleDescription;
|
entity.RoleDescription = RoleDescription;
|
||||||
entity.IsSuperAdmin = int.Parse(IsSuperAdmin);
|
entity.IsSuperAdmin = int.Parse(IsSuperAdmin);
|
||||||
entity.NotAllowDel = !string.IsNullOrEmpty(NotAllowDel) && NotAllowDel == "1" ? 1 : 0;
|
entity.NotAllowDel = !string.IsNullOrEmpty(NotAllowDel) && NotAllowDel == "1" ? 1 : 0;
|
||||||
|
entity.OnlyEditMyselfArticle = int.Parse(OnlyEditMyselfArticle);
|
||||||
|
entity.OnlyEditMyselfProduct = int.Parse(OnlyEditMyselfProduct);
|
||||||
|
|
||||||
//处理权限
|
//处理权限
|
||||||
if (entity.IsSuperAdmin == 1)
|
if (entity.IsSuperAdmin == 1)
|
||||||
@@ -320,6 +402,31 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//处理文章和商品栏目权限
|
||||||
|
string[] acpower = Request.Form["acpower"];
|
||||||
|
string[] pcpower = Request.Form["pcpower"];
|
||||||
|
|
||||||
|
List<int> acids = new List<int>();
|
||||||
|
List<int> pcids = new List<int>();
|
||||||
|
foreach (var item in acpower)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item) && Utils.IsInt(item))
|
||||||
|
{
|
||||||
|
acids.Add(int.Parse(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var item in pcpower)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item) && Utils.IsInt(item))
|
||||||
|
{
|
||||||
|
pcids.Add(int.Parse(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.AuthorizedArticleCagegory = JsonConvert.SerializeObject(acids);
|
||||||
|
entity.AuthorizedCagegory = JsonConvert.SerializeObject(pcids);
|
||||||
|
|
||||||
entity.Update();
|
entity.Update();
|
||||||
tip.Status = JsonTip.SUCCESS;
|
tip.Status = JsonTip.SUCCESS;
|
||||||
tip.Message = "编辑管理组详情成功";
|
tip.Message = "编辑管理组详情成功";
|
||||||
@@ -395,7 +502,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
if (!string.IsNullOrWhiteSpace(keyword))
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
ex &= Core.Admin._.UserName.Contains(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);
|
totalCount = Core.Admin.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||||
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||||
}
|
}
|
||||||
@@ -406,6 +513,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//加载管理组
|
//加载管理组
|
||||||
IList<AdminRoles> list = AdminRoles.FindAll(AdminRoles._.Id > 0, AdminRoles._.Rank.Asc(), null, 0, 0);
|
IList<AdminRoles> list = AdminRoles.FindAll(AdminRoles._.Id > 0, AdminRoles._.Rank.Asc(), null, 0, 0);
|
||||||
ViewBag.RoleList = list;
|
ViewBag.RoleList = list;
|
||||||
|
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||||
Core.Admin.WriteLogActions("查看添加管理员页面;");
|
Core.Admin.WriteLogActions("查看添加管理员页面;");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
@@ -446,11 +554,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "密码不能小于5个字符!";
|
tip.Message = "密码不能小于5个字符!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
if (_systemSetting.PasswordStrength > 0)
|
||||||
|
{
|
||||||
|
if (!Utils.CheckPasswordStrength(newPwd, _systemSetting.PasswordStrength))
|
||||||
|
{
|
||||||
|
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (newPwd != renewPwd)
|
if (newPwd != renewPwd)
|
||||||
{
|
{
|
||||||
tip.Message = "两次输入密码不一致,请重新输入!";
|
tip.Message = "两次输入密码不一致,请重新输入!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
//验证用户名
|
//验证用户名
|
||||||
if (Core.Admin.FindCount(Core.Admin._.UserName == userName, null, null, 0, 0) > 0)
|
if (Core.Admin.FindCount(Core.Admin._.UserName == userName, null, null, 0, 0) > 0)
|
||||||
{
|
{
|
||||||
@@ -485,6 +602,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
{
|
{
|
||||||
return EchoTipPage("系统找不到本记录!");
|
return EchoTipPage("系统找不到本记录!");
|
||||||
}
|
}
|
||||||
|
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||||
Core.Admin.WriteLogActions($"查看/编辑管理员({entity.UserName});");
|
Core.Admin.WriteLogActions($"查看/编辑管理员({entity.UserName});");
|
||||||
return View(entity);
|
return View(entity);
|
||||||
}
|
}
|
||||||
@@ -543,6 +661,14 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "密码不能小于5个字符!";
|
tip.Message = "密码不能小于5个字符!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
if (_systemSetting.PasswordStrength > 0)
|
||||||
|
{
|
||||||
|
if (!Utils.CheckPasswordStrength(newPwd, _systemSetting.PasswordStrength))
|
||||||
|
{
|
||||||
|
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (newPwd != renewPwd)
|
if (newPwd != renewPwd)
|
||||||
{
|
{
|
||||||
tip.Message = "两次输入密码不一致,请重新输入!";
|
tip.Message = "两次输入密码不一致,请重新输入!";
|
||||||
@@ -822,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);
|
totalCount = Member.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||||
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
return Content(JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||||
}
|
}
|
||||||
@@ -833,7 +959,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
IList<MemberRoles> list = MemberRoles.FindAll(MemberRoles._.Id > 0, MemberRoles._.Rank.Asc(), null, 0, 0);
|
IList<MemberRoles> list = MemberRoles.FindAll(MemberRoles._.Id > 0, MemberRoles._.Rank.Asc(), null, 0, 0);
|
||||||
ViewBag.RoleList = list;
|
ViewBag.RoleList = list;
|
||||||
ViewBag.allmember = Member.FindAll(Member._.Id > 0 & Member._.IsLock != 1, null, null, 0, 0);
|
ViewBag.allmember = Member.FindAll(Member._.Id > 0 & Member._.IsLock != 1, null, null, 0, 0);
|
||||||
|
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||||
Core.Admin.WriteLogActions($"查看添加用户页面;");
|
Core.Admin.WriteLogActions($"查看添加用户页面;");
|
||||||
Member model = new Member();
|
Member model = new Member();
|
||||||
return View(model);
|
return View(model);
|
||||||
@@ -859,6 +985,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "密码必须不小于6个字符";
|
tip.Message = "密码必须不小于6个字符";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
if (_systemSetting.PasswordStrength > 0)
|
||||||
|
{
|
||||||
|
if (!Utils.CheckPasswordStrength(model.PassWord, _systemSetting.PasswordStrength))
|
||||||
|
{
|
||||||
|
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string PassWord2 = Request.Form["PassWord2"];
|
string PassWord2 = Request.Form["PassWord2"];
|
||||||
if (model.PassWord != PassWord2)
|
if (model.PassWord != PassWord2)
|
||||||
{
|
{
|
||||||
@@ -929,7 +1064,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
IList<RebateChangeLog> listrechargebalancelogs = RebateChangeLog.FindAll(RebateChangeLog._.UId == entity.Id, null, null, 0, 0);
|
IList<RebateChangeLog> listrechargebalancelogs = RebateChangeLog.FindAll(RebateChangeLog._.UId == entity.Id, null, null, 0, 0);
|
||||||
ViewBag.listrechargebalancelogs = listrechargebalancelogs;
|
ViewBag.listrechargebalancelogs = listrechargebalancelogs;
|
||||||
|
|
||||||
|
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||||
|
|
||||||
Core.Admin.WriteLogActions($"查看/编辑用户({entity.UserName});");
|
Core.Admin.WriteLogActions($"查看/编辑用户({entity.UserName});");
|
||||||
return View(entity);
|
return View(entity);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
if (!string.IsNullOrWhiteSpace(keyword))
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
ex &= (Order._.Title.Contains(keyword) | Order._.OrderNum.Contains(keyword) | Order._.RealName.Contains(keyword) | Order._.Address.Contains(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);
|
long totalCount = Order.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||||
@@ -327,7 +327,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
if (!string.IsNullOrWhiteSpace(keyword))
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
ex &= OnlinePayOrder._.Title.Contains(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);
|
long totalCount = OnlinePayOrder.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ using XCode;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using COMCMS.Web.Common;
|
using COMCMS.Web.Common;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using System.IO;
|
||||||
|
using NewLife.Log;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.FileProviders;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||||
{
|
{
|
||||||
@@ -17,6 +22,12 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
[DisplayName("后台权限")]
|
[DisplayName("后台权限")]
|
||||||
public class PermissionController : AdminBaseController
|
public class PermissionController : AdminBaseController
|
||||||
{
|
{
|
||||||
|
private IWebHostEnvironment _env;
|
||||||
|
public PermissionController(IWebHostEnvironment env)
|
||||||
|
{
|
||||||
|
_env = env;
|
||||||
|
}
|
||||||
|
|
||||||
#region 事件管理
|
#region 事件管理
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标事件
|
/// 目标事件
|
||||||
@@ -104,6 +115,85 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
|
|
||||||
return Json(tip);
|
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
|
#endregion
|
||||||
|
|
||||||
#region 后台栏目管理
|
#region 后台栏目管理
|
||||||
@@ -328,6 +418,99 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "删除后台菜单成功";
|
tip.Message = "删除后台菜单成功";
|
||||||
return Json(tip);
|
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 系统运行日志
|
||||||
|
[HttpGet]
|
||||||
|
[MyAuthorize("viewlist", "runlogs")]
|
||||||
|
[DisplayName("系统运行日志")]
|
||||||
|
public IActionResult RunLogs()
|
||||||
|
{
|
||||||
|
string logPath = $"{_env.ContentRootPath}{Path.DirectorySeparatorChar}Log{Path.DirectorySeparatorChar}";
|
||||||
|
List<string> lognames = new List<string>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Directory.Exists(logPath))
|
||||||
|
{
|
||||||
|
DirectoryInfo directory = new DirectoryInfo(logPath);
|
||||||
|
List<string> listFiles = new List<string>();
|
||||||
|
DirectoryInfo[] directorys = directory.GetDirectories();
|
||||||
|
FileInfo[] files;
|
||||||
|
files = directory.GetFiles();
|
||||||
|
foreach (FileInfo file in files)
|
||||||
|
{
|
||||||
|
lognames.Add(file.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
XTrace.WriteException(ex);
|
||||||
|
}
|
||||||
|
lognames.Reverse();//倒序排列一下
|
||||||
|
ViewBag.logPath = logPath;
|
||||||
|
return View(lognames);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 获取日志详情
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("viewlist", "runlogs")]
|
||||||
|
public async Task<IActionResult> GetRunLogDetail(string logname)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(logname))
|
||||||
|
{
|
||||||
|
return Content("错误日志名称!");
|
||||||
|
}
|
||||||
|
string logPath = $"{_env.ContentRootPath}{Path.DirectorySeparatorChar}Log{Path.DirectorySeparatorChar}";
|
||||||
|
string logFullPath = logPath + logname;
|
||||||
|
|
||||||
|
|
||||||
|
if (!System.IO.File.Exists(logFullPath))
|
||||||
|
{
|
||||||
|
return Content("系统找不到本日志文件!");
|
||||||
|
}
|
||||||
|
//XTrace.WriteLine("查看日志:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|
||||||
|
IFileProvider fileProvider = new PhysicalFileProvider(logPath);
|
||||||
|
StringBuilder detail = new StringBuilder();
|
||||||
|
using (Stream stream = fileProvider.GetFileInfo(logname).CreateReadStream())
|
||||||
|
{
|
||||||
|
byte[] buffer = new byte[stream.Length];
|
||||||
|
await stream.ReadExactlyAsync(buffer);
|
||||||
|
detail.Append(Encoding.Default.GetString(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//using (StreamReader fs = new StreamReader(logFullPath))
|
||||||
|
//{
|
||||||
|
// detail.Append(fs.ReadToEndAsync());
|
||||||
|
//}
|
||||||
|
|
||||||
|
//string detail = await System.IO.File.ReadAllTextAsync(logFullPath);
|
||||||
|
return Content(detail.ToString());
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,24 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
||||||
ViewBag.ListTree = list;
|
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")));
|
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
||||||
//ViewBag.ListTpl = listtpl;
|
//ViewBag.ListTpl = listtpl;
|
||||||
@@ -53,6 +71,33 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "商品栏目标题不能为空!";
|
tip.Message = "商品栏目标题不能为空!";
|
||||||
return Json(tip);
|
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();
|
model.Insert();
|
||||||
Core.Admin.WriteLogActions("添加商品栏目(id:" + model.Id + ");");
|
Core.Admin.WriteLogActions("添加商品栏目(id:" + model.Id + ");");
|
||||||
tip.Status = JsonTip.SUCCESS;
|
tip.Status = JsonTip.SUCCESS;
|
||||||
@@ -74,9 +119,25 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
//获取上级栏目
|
//获取上级栏目
|
||||||
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
IList<Category> list = Category.GetListTree(0, -1, true, false);
|
||||||
ViewBag.ListTree = list;
|
ViewBag.ListTree = list;
|
||||||
//获取模板
|
//获取模板 模板规则,以Index_开头的,为栏目列表,以Detial_开头的为文章详情
|
||||||
//List<string> listtpl = COMCMS.Common.IOHelper.GetDirFiles(new DirectoryInfo(Server.MapPath("~/Views/article")));
|
List<string> listTpls = new List<string>();
|
||||||
//ViewBag.ListTpl = listtpl;
|
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 + ")页面;");
|
Core.Admin.WriteLogActions("查看/编辑商品栏目(id:" + id + ")页面;");
|
||||||
return View(entity);
|
return View(entity);
|
||||||
}
|
}
|
||||||
@@ -102,6 +163,30 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "系统找不到本记录!";
|
tip.Message = "系统找不到本记录!";
|
||||||
Json(tip);
|
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)
|
if (entity.PId != model.PId)
|
||||||
{
|
{
|
||||||
@@ -147,6 +232,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
entity.KindDomain = model.KindDomain;
|
entity.KindDomain = model.KindDomain;
|
||||||
entity.Rank = model.Rank;
|
entity.Rank = model.Rank;
|
||||||
entity.Pic = model.Pic;
|
entity.Pic = model.Pic;
|
||||||
|
entity.FilePath = model.FilePath;
|
||||||
|
|
||||||
|
|
||||||
entity.Save();
|
entity.Save();
|
||||||
@@ -186,6 +272,27 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "删除商品栏目成功";
|
tip.Message = "删除商品栏目成功";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 修改商品分类排序
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "category", "JSON")]
|
||||||
|
public IActionResult DoEditCategoryRank(int id, int rank)
|
||||||
|
{
|
||||||
|
Category entity = Category.Find(Category._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
entity.Rank = rank;
|
||||||
|
entity.Update();
|
||||||
|
Admin.WriteLogActions($"修改商品分类排序(id:{id},排序:{rank});");
|
||||||
|
tip.Message = "修改商品分类排序成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 商品列表
|
#region 商品列表
|
||||||
@@ -208,7 +315,23 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
numPerPage = limit;
|
numPerPage = limit;
|
||||||
currentPage = page;
|
currentPage = page;
|
||||||
startRowIndex = (currentPage - 1) * numPerPage;
|
startRowIndex = (currentPage - 1) * numPerPage;
|
||||||
Expression ex = Product._.Id > 0;
|
Expression ex = new Expression();
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedCagegory) ? "[]" : my.Roles.AuthorizedCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
ex &= Product._.KId.In(aclist);
|
||||||
|
}
|
||||||
|
|
||||||
|
//仅显示有权限内容
|
||||||
|
if (my.Roles.OnlyEditMyselfProduct == 1)
|
||||||
|
ex &= Product._.AuthorId == my.Id;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(keyword))
|
if (!string.IsNullOrWhiteSpace(keyword))
|
||||||
{
|
{
|
||||||
@@ -253,6 +376,26 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 修改商品排序
|
||||||
|
[HttpPost]
|
||||||
|
[MyAuthorize("edit", "product", "JSON")]
|
||||||
|
public IActionResult DoEditProductSequence(int id, int rank)
|
||||||
|
{
|
||||||
|
Product entity = Product.Find(Product._.Id == id);
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
tip.Message = "系统找不到本记录";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
entity.Sequence = rank;
|
||||||
|
entity.Update();
|
||||||
|
Admin.WriteLogActions($"修改商品排序(id:{id},排序:{rank});");
|
||||||
|
tip.Message = "修改排序成功!";
|
||||||
|
tip.Status = JsonTip.SUCCESS;
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 添加商品
|
#region 添加商品
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[MyAuthorize("add", "product")]
|
[MyAuthorize("add", "product")]
|
||||||
@@ -292,6 +435,24 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "商品图片填写的不是图片格式!";
|
tip.Message = "商品图片填写的不是图片格式!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedCagegory)?"[]": my.Roles.AuthorizedCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
if (aclist.FindIndex(x => x == model.KId) == -1)
|
||||||
|
{
|
||||||
|
tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//处理商品更多图片
|
//处理商品更多图片
|
||||||
string[] moreImgSrc = Request.Form["nImgUrl"];
|
string[] moreImgSrc = Request.Form["nImgUrl"];
|
||||||
string morIMG = string.Empty;//更多图片的时候用到
|
string morIMG = string.Empty;//更多图片的时候用到
|
||||||
@@ -312,7 +473,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
model.Content = content;
|
model.Content = content;
|
||||||
}
|
}
|
||||||
model.ItemImg = morIMG;
|
model.ItemImg = morIMG;
|
||||||
model.AuthorId = Core.Admin.GetMyInfo().Id;
|
model.AuthorId = my.Id;
|
||||||
model.Insert();
|
model.Insert();
|
||||||
Category.UpdateDetailCount(model.KId);
|
Category.UpdateDetailCount(model.KId);
|
||||||
//添加TAG
|
//添加TAG
|
||||||
@@ -381,6 +542,29 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "商品图片填写的不是图片格式!";
|
tip.Message = "商品图片填写的不是图片格式!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedCagegory) ? "[]" : my.Roles.AuthorizedCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
if (aclist.FindIndex(x => x == model.KId) == -1)
|
||||||
|
{
|
||||||
|
tip.Message = "当前选择栏目不存在,或者您没这个栏目的权限!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (my.Roles.OnlyEditMyselfProduct == 1 && entity.AuthorId != my.Id)
|
||||||
|
{
|
||||||
|
tip.Message = "系统限制,您无法编辑非自己添加的商品!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//处理商品更多图片
|
//处理商品更多图片
|
||||||
string[] moreImgSrc = Request.Form["nImgUrl"];
|
string[] moreImgSrc = Request.Form["nImgUrl"];
|
||||||
string morIMG = string.Empty;//更多图片的时候用到
|
string morIMG = string.Empty;//更多图片的时候用到
|
||||||
@@ -415,8 +599,65 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
content = ThumbnailHelper.SaveRemoteImgForContent(content);
|
content = ThumbnailHelper.SaveRemoteImgForContent(content);
|
||||||
model.Content = content;
|
model.Content = content;
|
||||||
}
|
}
|
||||||
//model.AuthorId = Core.Admin.GetMyInfo().Id;
|
entity.SupportId = model.SupportId;
|
||||||
model.Save();
|
entity.BannerImg = model.BannerImg;
|
||||||
|
entity.BId = model.BId;
|
||||||
|
entity.Color = model.Color;
|
||||||
|
entity.Content = model.Content;
|
||||||
|
entity.Credits = model.Credits;
|
||||||
|
entity.Description = model.Description;
|
||||||
|
entity.Discount = model.Discount;
|
||||||
|
entity.Fare = model.Fare;
|
||||||
|
entity.FilePath = model.FilePath;
|
||||||
|
entity.Front = model.Front;
|
||||||
|
entity.Hits = model.Hits;
|
||||||
|
entity.Icon = model.Icon;
|
||||||
|
entity.IsBest = model.IsBest;
|
||||||
|
entity.IsBreakup = model.IsBreakup;
|
||||||
|
entity.IsComment = model.IsComment;
|
||||||
|
entity.IsGift = model.IsGift;
|
||||||
|
entity.IsHide = model.IsHide;
|
||||||
|
entity.IsHotSales = model.IsHotSales;
|
||||||
|
entity.IsLock = model.IsLock;
|
||||||
|
entity.IsMember = model.IsMember;
|
||||||
|
entity.IsNew = model.IsNew;
|
||||||
|
entity.IsPart = model.IsPart;
|
||||||
|
entity.IsPromote = model.IsPromote;
|
||||||
|
entity.IsRecommend = model.IsRecommend;
|
||||||
|
entity.IsShelves = model.IsShelves;
|
||||||
|
entity.IsSpecial = model.IsSpecial;
|
||||||
|
entity.IsSubProduct = model.IsSubProduct;
|
||||||
|
entity.IsTop = model.IsTop;
|
||||||
|
entity.ItemImg = model.ItemImg;
|
||||||
|
entity.ItemNO = model.ItemNO;
|
||||||
|
entity.Keyword = model.Keyword;
|
||||||
|
entity.KId = model.KId;
|
||||||
|
entity.LinkURL = model.LinkURL;
|
||||||
|
entity.MarketPrice = model.MarketPrice;
|
||||||
|
entity.Material = model.Material;
|
||||||
|
entity.Parameters = model.Parameters;
|
||||||
|
entity.Pic = model.Pic;
|
||||||
|
entity.PPId = model.PPId;
|
||||||
|
entity.Price = model.Price;
|
||||||
|
entity.Sequence = model.Sequence;
|
||||||
|
entity.Service = model.Service;
|
||||||
|
entity.ShopId = model.ShopId;
|
||||||
|
entity.Spec = model.Spec;
|
||||||
|
entity.SpecialPrice = model.SpecialPrice;
|
||||||
|
entity.Stock = model.Stock;
|
||||||
|
entity.SubTitle = model.SubTitle;
|
||||||
|
entity.SupportId = model.SupportId;
|
||||||
|
entity.Tags = model.Tags;
|
||||||
|
entity.TemplateFile = model.TemplateFile;
|
||||||
|
entity.Title = model.Title;
|
||||||
|
entity.TitleColor = model.TitleColor;
|
||||||
|
entity.Unit = model.Unit;
|
||||||
|
entity.UpdateTime = DateTime.Now;
|
||||||
|
entity.WarnStock = model.WarnStock;
|
||||||
|
entity.Weight = model.Weight;
|
||||||
|
|
||||||
|
entity.Update();
|
||||||
|
|
||||||
//添加TAG
|
//添加TAG
|
||||||
//Tag.InsertTags(model.Tags, RTType.RatuoModule.Product, model.Id, model.Title);
|
//Tag.InsertTags(model.Tags, RTType.RatuoModule.Product, model.Id, model.Title);
|
||||||
Core.Admin.WriteLogActions("编辑商品(id:" + model.Id + ");");
|
Core.Admin.WriteLogActions("编辑商品(id:" + model.Id + ");");
|
||||||
@@ -439,6 +680,29 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
tip.Message = "系统找不到本商品!";
|
tip.Message = "系统找不到本商品!";
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Admin my = Admin.GetMyInfo();
|
||||||
|
List<int> aclist = new List<int>();
|
||||||
|
if (my.Roles.IsSuperAdmin != 1)
|
||||||
|
{
|
||||||
|
aclist = JsonConvert.DeserializeObject<List<int>>(string.IsNullOrEmpty(my.Roles.AuthorizedCagegory) ? "[]" : my.Roles.AuthorizedCagegory);
|
||||||
|
if (aclist == null) aclist = new List<int>();
|
||||||
|
|
||||||
|
if (aclist.Count > 0)
|
||||||
|
{
|
||||||
|
if (aclist.FindIndex(x => x == entity.KId) == -1)
|
||||||
|
{
|
||||||
|
tip.Message = "者您没这个栏目的权限,无法删除该栏目商品!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (my.Roles.OnlyEditMyselfArticle == 1 && entity.AuthorId != my.Id)
|
||||||
|
{
|
||||||
|
tip.Message = "系统限制,您无法删除非自己添加的商品!";
|
||||||
|
return Json(tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int kid = entity.KId;
|
int kid = entity.KId;
|
||||||
//删除TAG
|
//删除TAG
|
||||||
//Tag.DeleteTag(RTType.RatuoModule.Article, entity.Id);
|
//Tag.DeleteTag(RTType.RatuoModule.Article, entity.Id);
|
||||||
|
|||||||
@@ -16,13 +16,32 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
public class ServerController : AdminBaseController
|
public class ServerController : AdminBaseController
|
||||||
{
|
{
|
||||||
#region 中文转拼音
|
#region 中文转拼音
|
||||||
public IActionResult Hanzi2Pinyin(string name)
|
[HttpPost]
|
||||||
|
public IActionResult Hanzi2Pinyin(string name,int pid=0,string t="")
|
||||||
{
|
{
|
||||||
string pinyin = "";
|
string pinyin = "/";
|
||||||
|
if(t == "articlecategory" && pid>0)
|
||||||
|
{
|
||||||
|
ArticleCategory pcategory = ArticleCategory.FindById(pid);
|
||||||
|
if(pcategory !=null && !string.IsNullOrEmpty(pcategory.FilePath))
|
||||||
|
{
|
||||||
|
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))
|
if (!string.IsNullOrEmpty(name))
|
||||||
{
|
{
|
||||||
pinyin = PinYinHelper.GetPinyin(name).ToLower().Replace(" ","-");
|
pinyin += PinYinHelper.GetPinyin(name).ToLower().Replace(" ","-");
|
||||||
}
|
}
|
||||||
|
|
||||||
tip.Status = JsonTip.SUCCESS;
|
tip.Status = JsonTip.SUCCESS;
|
||||||
tip.Message = pinyin;
|
tip.Message = pinyin;
|
||||||
return Json(tip);
|
return Json(tip);
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
[Area("AdminCP")]
|
[Area("AdminCP")]
|
||||||
public class SystemController : AdminBaseController
|
public class SystemController : AdminBaseController
|
||||||
{
|
{
|
||||||
private IHostingEnvironment _env;
|
private IWebHostEnvironment _env;
|
||||||
public SystemController(IHostingEnvironment env)
|
public SystemController(IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
_env = env;
|
_env = env;
|
||||||
}
|
}
|
||||||
@@ -179,8 +179,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(model.WaterMarkImg))
|
if (!string.IsNullOrWhiteSpace(model.WaterMarkImg))
|
||||||
{
|
{
|
||||||
string imgPath = _env.WebRootPath + model.WaterMarkImg.Replace("/", "\\");
|
string imgPath = _env.WebRootPath + model.WaterMarkImg.Replace("/", Path.DirectorySeparatorChar.ToString());
|
||||||
NewLife.Log.XTrace.WriteLine(_env.WebRootPath + "|" + Path.Combine(_env.WebRootPath, model.WaterMarkImg) + "|" + imgPath);
|
//NewLife.Log.XTrace.WriteLine(_env.WebRootPath + "|" + Path.Combine(_env.WebRootPath, model.WaterMarkImg) + "|" + imgPath);
|
||||||
if (!System.IO.File.Exists(imgPath))
|
if (!System.IO.File.Exists(imgPath))
|
||||||
{
|
{
|
||||||
tip.Message = "水印图片不存在,请重新上传!";
|
tip.Message = "水印图片不存在,请重新上传!";
|
||||||
@@ -221,9 +221,17 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
||||||
string content = "";
|
string content = "";
|
||||||
if (System.IO.File.Exists(file))
|
if (System.IO.File.Exists(file))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
content = System.IO.File.ReadAllText(file);
|
content = System.IO.File.ReadAllText(file);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
NewLife.Log.XTrace.WriteException(ex);
|
||||||
|
// 如果读取文件失败,继续使用空内容
|
||||||
|
}
|
||||||
|
}
|
||||||
ViewBag.content = content;
|
ViewBag.content = content;
|
||||||
Admin.WriteLogActions("查看Robots.txt;");
|
Admin.WriteLogActions("查看Robots.txt;");
|
||||||
return View();
|
return View();
|
||||||
@@ -233,15 +241,18 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
|||||||
public IActionResult Robots(string content)
|
public IActionResult Robots(string content)
|
||||||
{
|
{
|
||||||
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
string file = Path.Combine(_env.WebRootPath, "robots.txt");
|
||||||
if (System.IO.File.Exists(file))
|
try
|
||||||
{
|
{
|
||||||
//写入覆盖
|
//写入覆盖
|
||||||
System.IO.File.WriteAllText(file, content);
|
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.Status = JsonTip.SUCCESS;
|
||||||
tip.Message = "修改Robots.txt成功";
|
tip.Message = "修改Robots.txt成功";
|
||||||
Admin.WriteLogActions("修改Robots.txt成功;");
|
Admin.WriteLogActions("修改Robots.txt成功;");
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user