框架搭建
This commit is contained in:
281
README.md
281
README.md
@@ -1,281 +0,0 @@
|
||||
|
||||
|
||||
<h1 align="center"><img align="left" height="100px" src="https://user-images.githubusercontent.com/68722157/138828506-f58b7c57-5e10-4178-8f7d-5d5e12050113.png"> Yi框架</h1>
|
||||
<h4 align="center">一套与SqlSugar一样爽的.Net6开源框架</h4>
|
||||
<h2 align="center">集大成者,终究轮子</h2>
|
||||
|
||||
[English](README-en.md) | 简体中文
|
||||
|
||||

|
||||
|
||||
****
|
||||
### 简介:
|
||||
**中文:意框架**(和他的名字一样“简易”,同时接入Java的Ruoyi Vue3.0前端)
|
||||
|
||||
模块分化较多,可根据业务自行引用或抛弃,集大成者,大而全乎,也许你能从中学习到一些独特见解
|
||||
|
||||
正在持续更进业务模块,已接入ruoyi
|
||||
|
||||
**英文:YiFramework**
|
||||
|
||||
Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
|
||||
与Sqlsugar理念一致,以用户体验出发。
|
||||
架构干净整洁、无业务代码、采用微软风格原生框架封装、CodeFrist+配套自研文件模板代码生成器 开发。
|
||||
适合.Net6学习、Sqlsugar学习 、项目二次开发。
|
||||
集大成者,终究轮子
|
||||
|
||||
Yi框架最新版本标签:`v1.2.1`,具体版本可以查看标签迭代
|
||||
|
||||
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
|
||||
|
||||
————这不仅仅是一个程序,更是一个艺术品,面向艺术的开发!
|
||||
|
||||
**分支**:
|
||||
|
||||
(本项目由EFCore版本历经3年不断迭代至Sqlsugar版本,现EFcore版本已弃用,目前sqlsugar已带业务功能)
|
||||
|
||||
**SqlSugar**:.Net6 DDD领域驱动设计 简单分层微服务架构
|
||||
|
||||
- Yi.Framework.Net6:.NetCore 6 意框架 (后端)
|
||||
|
||||
- Yi.Vue3.X.RuoYi:Vue3 RuoYi前端框架 (前端后台)
|
||||
|
||||
(你没有听错,已经接入java流行指数最高最火爆的框架之一,与其他框架不同,Yi框架后端为完全重制版,并非为ruoyi java模仿版)
|
||||
|
||||
- Yi.Vue3.x.Vant:Vue3 移动端前端框架 (前端前台)持续迭代
|
||||
|
||||
**SqlSugar-Dev**:为sqlsugar分支的实时开发版本
|
||||
|
||||
~~**ec**: EFcore完整电商项目~~
|
||||
|
||||
****
|
||||
|
||||
### 演示地址:
|
||||
|
||||
废话少说直接上地址,**请不要**更改里面的数据
|
||||
|
||||
API服务:[yi.ccnetcore.com](http://yi.ccnetcore.com) 管理员账号:cc 、 123456
|
||||
|
||||
网关地址:~~[gate.ccnetcore.com/swagger](http://gate.ccnetcore.com/swagger)~~
|
||||
|
||||
~~WebFirst开发:所有代码生成器已经配置完成,无需任何操作数据库及任何代码,只需要网页表格上点点点即可~~
|
||||
|
||||
代码自动生成:
|
||||
|
||||

|
||||
|
||||
### 支持:
|
||||
|
||||
- [x] 完全支持单体应用架构
|
||||
- [x] 完全支持分布式应用架构
|
||||
- [x] 完全支持微服务架构
|
||||
- [ ] 即将支持网格服务架构(我们将在后续版本加入dapr)
|
||||
|
||||
****
|
||||
### 软件架构:
|
||||
|
||||
**架构**:后端.NET6(Asp.NetCore 6)、WebFirst代码生成器~~与.NET5(Asp.NetCore 5)、前端Vue(2.0)~~
|
||||
|
||||
**关系型数据库**:mysql、sql server、sqlite、oracle(正在兼容中)
|
||||
|
||||
**操作系统**:Windows、Linux
|
||||
|
||||
**身份验证**:JWT、IdentityServer4
|
||||
|
||||
**组件**:SqlSugar、Autofac、Castle、Swagger、Log4Net、Redis、RabbitMq、ES、Quartz.net、~~T4~~
|
||||
|
||||
**分布式**:CAP、Lock
|
||||
|
||||
**微服务**:Consul、Ocelot、IdentityService、Apollo、Docker、Jenkins、Nginx、K8s、ELK、Polly
|
||||
|
||||
**封装**:Json处理模块,滑动验证码模块,base64图片处理模块,异常捕捉模块、邮件处理模块、linq封装模块、随机数模块、统一接口模块、基于策略的jwt验证、过滤器、数据库连接、跨域、初始化种子数据、Base32、Console输出、日期处理、文件传输、html筛选、http请求、ip过滤、md5加密、Rsa加密、序列化、雪花算法、字符串处理、编码处理、地址处理、xml处理、心跳检查。。。
|
||||
|
||||
****
|
||||
<h3>业务支持模块</h3>
|
||||
|
||||
RABC权限管理系统(正在更新)
|
||||
(大部分ruoyi功能,采用ruoyi前端)
|
||||
- 用户管理
|
||||
- 角色管理
|
||||
- 菜单管理
|
||||
- 部门管理
|
||||
- 岗位管理
|
||||
- 字典管理
|
||||
- 参数管理
|
||||
- 用户在线
|
||||
- 操作日志
|
||||
- 登录日志
|
||||
- 等等
|
||||
|
||||
ERP进销存系统(正在更新)
|
||||
- 供货商管理
|
||||
- 等等
|
||||
|
||||
BBS论坛系统(持续迭代)
|
||||
- 文章管理
|
||||
- 评论管理
|
||||
- 等等
|
||||
|
||||
SHOP电商系统(持续迭代)
|
||||
- SPU管理
|
||||
- SKU管理
|
||||
- 商品规格
|
||||
- 商品分类
|
||||
- 等等
|
||||
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 框架支持模块:
|
||||
|
||||
大致如图:
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
(删除线代表已实现功能还未迁移过来)
|
||||
- [x] 支持大致`DDD领域驱动设计`进行分层,支持微服务扩展
|
||||
- [x] 支持采用`异步`开发awit/async
|
||||
- [x] 支持数据库主从`读写分离`
|
||||
- [x] 支持功能替换,无需改动代码,只需配置`json文件`进行装配即可
|
||||
- [x] 支持`Aop封装`,FilterAop、IocAop、LogAop、SqlAop
|
||||
- [x] 支持`Log4Net日志`记录,自动生成至bin目录下的logs文件夹
|
||||
- [x] 支持`DbSeed数据库种子数据`接入
|
||||
- [x] 支持主流`数据库随意切换`,Mysql/Sqlite/Sqlserver/Oracle
|
||||
- [x] 支持上海杰哥官方`SqlSugar ORM`封装
|
||||
- [x] 支持新版`SwaggerWebAPI`,jwt身份认证接入
|
||||
- [x] 支持`Cors`跨域
|
||||
- [x] 支持`AutoFac`自动映射依赖注入
|
||||
- [x] 支持`consul`服务器注册与发现
|
||||
- [x] 支持`健康检查`
|
||||
- [x] 支持`RabbitMQ`消息队列
|
||||
- [x] 支持`Redis`多级缓存
|
||||
- [x] 支持`MemoryCache`多级缓存
|
||||
- [x] 支持`Ocelot`网关,路由、服务聚合、服务发现、认证、鉴权、限流、熔断、缓存、Header头传递
|
||||
- [x] 支持`Apollo`全局配置中心;
|
||||
- [x] 支持`docker`镜像制作
|
||||
- [x] 支持`Quartz.net`任务调度,实现任意接口被调度
|
||||
- [x] 支持`ThumbnailSharp`缩略图封装
|
||||
- [x] 支持`ELK`,log4net+kafka+es+logstach+kibana
|
||||
- [x] 支持`IdentityService4`授权中心
|
||||
- [x] 支持`Es`分词查询
|
||||
- [x] 支持多级`缓存`
|
||||
- [x] 支持`CAP`分布式事务,mysql+rabbitMq
|
||||
- [x] 支持`Docker+k8s`部署
|
||||
- [x] 支持`Jenkins+CI/CD`
|
||||
- [x] 支持`AutoMapper`模块映射
|
||||
- [x] 支持`微信支付`模块
|
||||
- [x] 支持`单表多租户`常用功能
|
||||
- [x] 支持`逻辑删除`常用功能
|
||||
- [x] 支持`操作日志`常用功能
|
||||
- [x] 支持`自动分表`
|
||||
- [x] 支持`数据权限`
|
||||
- [x] 支持`CodeFrist`快速构建数据库
|
||||
- [x] 支持自研文件版`代码生成器`快速构建通用代码
|
||||
- [x] 支持完整`Dto`模式
|
||||
- [x] 支持 太多了忘了
|
||||
|
||||
|
||||
****
|
||||
### 目录结构:
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
我们大致依照DDD领域驱动设计分层
|
||||
|
||||
分层如此清晰!什么?还感觉太复杂了?用户只需关注Api、Service其他都是轮子啊!
|
||||
|
||||
- BackGround:后台进程(通常使用消息队列进行消费任务)
|
||||
- Test:测试(单元测试)
|
||||
- Domain:领域层(Dto、服务接口层、模型层、仓储层、服务层)
|
||||
- Infrastructure:基础实例层(通用工具层、核心层、定时任务Job、国际化、Web扩展层)
|
||||
- Module:模块层(其他模块,可按需进行引入,例如微信支付、代码生成)
|
||||
- MicroServiceInstance:服务层(微服务)
|
||||
|
||||
****
|
||||
### 安装教程:
|
||||
|
||||
我们将在之后更新教程手册!
|
||||
|
||||
后端
|
||||
1. 下载全部源码,默认使用sqlite数据库,已经生成
|
||||
2. 直接点击sln文件运行即可,没有任何其他依赖
|
||||
|
||||
前端
|
||||
1. 下载全部源码,npm i 安装依赖
|
||||
2. 使用npm run dev进行运行
|
||||
|
||||
|
||||
****
|
||||
### 使用说明:
|
||||
|
||||
~~1. 导入使用仓库中的WebFirst数据库~~
|
||||
~~2. 使用WebFirst添加实体、同步实体、修改模板生成路径并生成方案~~
|
||||
|
||||
没了,恭喜你已经成功完成了项目,并且已经具备大部分通用场景业务
|
||||
是不是一个字?爽!
|
||||
到此为止,你无需写任何一个代码!
|
||||
|
||||
**爽点**:
|
||||
|
||||
新人,看这里,项目下载之后直接可以启动,无任何依赖,之后你可以查看`Test控制器`,迫不及待的快来爽一爽!
|
||||
|
||||
我们将使用说明转移至我们的官方论坛中,正在制作中,尽情期待!
|
||||
|
||||
****
|
||||
### 感谢:
|
||||
|
||||
**大力支持**: Eleven神、Sqlsugar上海杰哥、Gerry、哲学的老张
|
||||
|
||||
[橙子]https://ccnetcore.com
|
||||
|
||||
[lzw]https://github.com/yeslode
|
||||
|
||||
[朝夕教育]https://www.zhaoxiedu.net
|
||||
|
||||
[Sqlsugar]https://www.donet5.com/Home/Doc
|
||||
|
||||
[RuYiAdmin]https://gitee.com/pang-mingjun/RuYiAdmin
|
||||
|
||||
[ZrAdminNetCore]https://gitee.com/izory/ZrAdminNetCore
|
||||
|
||||
****
|
||||
### 联系我们:
|
||||
|
||||
作者QQ:`454313500`,2029年之前作者24小时在线,时刻保持活跃更新。
|
||||
|
||||
QQ交流群:官方一群(已满)、官方二群(已满)、官方三群:`786308927`(加作者QQ后同意)
|
||||
|
||||
联系作者,这里人人都是顾问
|
||||
|
||||
官方网址:正在建设
|
||||
|
||||
****
|
||||
### FQA:
|
||||
|
||||
问1:为什么不采用EFcore?
|
||||
|
||||
答1:别问,问就是Sqlsugar,和本框架一样爽!
|
||||
|
||||
问2:以后会持续更新下去吗?
|
||||
|
||||
答2:一定会的,我们的标题是 一个和Sqlsugar一样爽的.Net6开源框架 ,只要Sqlsugar在,我们将一直更新下去。
|
||||
|
||||
问3:这个框架的针对人群是哪些人?适合所有人吗?
|
||||
|
||||
答3:并不是适合所有人,应该算适合需要有一定基础的开发人员,当然,如果你是大神,你完全可以将这个框架二次开发!
|
||||
|
||||
问4:花如此多的精力制作这个框架,是为了什么?是为了赚钱吗?和目前主流的abp等框架比,又有什么意义呢?
|
||||
|
||||
答4:我们与Sqlsugar作者理念一致,我们是从用户角度出发,框架是为用户服务,与ABP复杂上手理念完全是相反的。
|
||||
|
||||
问5:为何不出版一个详细的说明书呢?
|
||||
|
||||
答5:暂时不会了,之后可能会,代码都是基于Asp.NetCore框架,适用于新手不用造轮子,整个框架较为简单,阅读源码后,基本能自定义改造使用了,过难也已经封装完毕,别忘了,其意义是为了开发更加简易!建议添加作者好友,这里人人都是顾问。
|
||||
|
||||
我大抵要厌倦了负重前行。
|
||||
BIN
Readme/代码生成.gif
BIN
Readme/代码生成.gif
Binary file not shown.
|
Before Width: | Height: | Size: 2.5 MiB |
BIN
Readme/用户管理.png
BIN
Readme/用户管理.png
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
BIN
Readme/菜单管理.png
BIN
Readme/菜单管理.png
Binary file not shown.
|
Before Width: | Height: | Size: 153 KiB |
@@ -1,25 +0,0 @@
|
||||
**/.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
|
||||
@@ -1,4 +0,0 @@
|
||||
[*.cs]
|
||||
|
||||
# SYSLIB0014: 类型或成员已过时
|
||||
dotnet_diagnostic.SYSLIB0014.severity = none
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<log4net>
|
||||
<!-- 将日志以回滚文件的形式写到文件中 -->
|
||||
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||
<!--Error-->
|
||||
<appender name="ErrorLog" type="log4net.Appender.RollingFileAppender">
|
||||
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||
<param name="Encoding" value="utf-8" />
|
||||
<file value="log/"/>
|
||||
<appendToFile value="true" />
|
||||
<rollingStyle value="Date" />
|
||||
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||
<datePattern value=""GlobalExceptionLogs_"yyyyMMdd".log"" />
|
||||
<!--日志文件名是否为静态-->
|
||||
<StaticLogFileName value="false"/>
|
||||
<!--多线程时采用最小锁定-->
|
||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date| %-5level %newline%message%newline--------------------------------%newline" />
|
||||
</layout>
|
||||
<filter type="log4net.Filter.LevelRangeFilter">
|
||||
<levelMin value="ERROR" />
|
||||
<levelMax value="FATAL" />
|
||||
</filter>
|
||||
</appender>
|
||||
<!--Error-->
|
||||
|
||||
|
||||
|
||||
<!--Info-->
|
||||
<appender name="InfoLog" type="log4net.Appender.RollingFileAppender">
|
||||
<!--不加utf-8编码格式,中文字符将显示成乱码-->
|
||||
<param name="Encoding" value="utf-8" />
|
||||
<!--定义文件存放位置-->
|
||||
<file value="log/"/>
|
||||
<appendToFile value="true" />
|
||||
<rollingStyle value="Date" />
|
||||
<!--日志文件名是否为静态-->
|
||||
<StaticLogFileName value="false"/>
|
||||
<!--日期的格式,每天换一个文件记录,如不设置则永远只记录一天的日志,需设置-->
|
||||
<datePattern value=""GlobalInfoLogs_"yyyyMMdd".log"" />
|
||||
<!--多线程时采用最小锁定-->
|
||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||
<!--布局(向用户显示最后经过格式化的输出信息)-->
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date| %-5level%c %newline%message%newline--------------------------------%newline" />
|
||||
</layout>
|
||||
<filter type="log4net.Filter.LevelRangeFilter">
|
||||
<levelMin value="DEBUG" />
|
||||
<levelMax value="WARN" />
|
||||
</filter>
|
||||
</appender>
|
||||
<!--Info-->
|
||||
|
||||
<root>
|
||||
<!-- 控制级别,由低到高:ALL|DEBUG|INFO|WARN|ERROR|FATAL|OFF -->
|
||||
<!-- 比如定义级别为INFO,则INFO级别向下的级别,比如DEBUG日志将不会被记录 -->
|
||||
<!-- 如果没有定义LEVEL的值,则缺省为DEBUG -->
|
||||
<level value="ALL" />
|
||||
<!-- 按日期切分日志文件,并将日期作为日志文件的名字 -->
|
||||
<appender-ref ref="ErrorLog" />
|
||||
<appender-ref ref="InfoLog" />
|
||||
</root>
|
||||
</log4net>
|
||||
@@ -1,928 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Yi.Framework.ApiMicroservice</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
|
||||
<summary>
|
||||
Json To Sql 类比模式,通用模型
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetById(System.Int64)">
|
||||
<summary>
|
||||
主键查询
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.GetList(Yi.Framework.Model.Base.Query.QueryCondition)">
|
||||
<summary>
|
||||
列表查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.PageList(Yi.Framework.Model.Base.Query.QueryPageCondition)">
|
||||
<summary>
|
||||
条件分页查询
|
||||
</summary>
|
||||
<param name="queryCondition"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Add(`0)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.Update(`0)">
|
||||
<summary>
|
||||
修改
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1.DeleteList(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
列表删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseExcelController`1.Template">
|
||||
<summary>
|
||||
下载模板
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseExcelController`1.Export">
|
||||
<summary>
|
||||
导出数据
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseExcelController`1.Import(Microsoft.AspNetCore.Http.IFormFile)">
|
||||
<summary>
|
||||
导入数据
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleCrudController`1">
|
||||
<summary>
|
||||
Json To Sql 类比模式,通用模型
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleCrudController`1.GetById(System.Int64)">
|
||||
<summary>
|
||||
主键查询
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleCrudController`1.GetList">
|
||||
<summary>
|
||||
全部列表查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleCrudController`1.Add(`0)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleCrudController`1.Update(`0)">
|
||||
<summary>
|
||||
修改
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleCrudController`1.DelList(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
列表删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleRdController`1">
|
||||
<summary>
|
||||
Json To Sql 类比模式,通用模型
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleRdController`1.GetById(System.Int64)">
|
||||
<summary>
|
||||
主键查询
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleRdController`1.GetList">
|
||||
<summary>
|
||||
全部列表查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.BaseSimpleRdController`1.DelList(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
列表删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AgreeController.Operate(System.Int64)">
|
||||
<summary>
|
||||
点赞操作
|
||||
</summary>
|
||||
<param name="articleId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.ArticleController">
|
||||
<summary>
|
||||
文章控制器
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ArticleController.PageList(Yi.Framework.Model.BBS.Entitys.ArticleEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ArticleController.Add(Yi.Framework.Model.BBS.Entitys.ArticleEntity)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.CommentController.GetListByArticleId(System.Int64)">
|
||||
<summary>
|
||||
获取文章的全部一级评论
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.CommentController.GetById(System.Int64)">
|
||||
<summary>
|
||||
获取一级评论详情
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.CommentController.Add(Yi.Framework.Model.BBS.Entitys.CommentEntity)">
|
||||
<summary>
|
||||
回复文章或回复评论
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.MaterialController.PageList(Yi.Framework.DtoModel.ERP.Material.MaterialCreateUpdateInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.MaterialController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.MaterialController.Create(Yi.Framework.DtoModel.ERP.Material.MaterialCreateUpdateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.MaterialController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Material.MaterialCreateUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.MaterialController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.PageList(Yi.Framework.DtoModel.ERP.Purchase.PurchaseGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Create(Yi.Framework.DtoModel.ERP.Purchase.PurchaseCreateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Purchase.PurchaseUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.PageList(Yi.Framework.DtoModel.ERP.PurchaseDetails.PurchaseDetailsCreateUpdateInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.Create(Yi.Framework.DtoModel.ERP.PurchaseDetails.PurchaseDetailsCreateUpdateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.Update(System.Int64,Yi.Framework.DtoModel.ERP.PurchaseDetails.PurchaseDetailsCreateUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseDetailsController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.PageList(Yi.Framework.DtoModel.ERP.Supplier.SupplierCreateUpdateInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.Create(Yi.Framework.DtoModel.ERP.Supplier.SupplierCreateUpdateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Supplier.SupplierCreateUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.SupplierController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.UnitController.PageList(Yi.Framework.DtoModel.ERP.Unit.UnitCreateUpdateInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.UnitController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.UnitController.GetList">
|
||||
<summary>
|
||||
全查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.UnitController.Create(Yi.Framework.DtoModel.ERP.Unit.UnitCreateUpdateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.UnitController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Unit.UnitCreateUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.UnitController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.WarehouseController.PageList(Yi.Framework.DtoModel.ERP.Warehouse.WarehouseCreateUpdateInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.WarehouseController.GetById(System.Int64)">
|
||||
<summary>
|
||||
单查
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.WarehouseController.Create(Yi.Framework.DtoModel.ERP.Warehouse.WarehouseCreateUpdateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.WarehouseController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Warehouse.WarehouseCreateUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.WarehouseController.Del(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.AccountController">
|
||||
<summary>
|
||||
账户管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.RestCC">
|
||||
<summary>
|
||||
重置管理员CC的密码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.DtoModel.Base.Dto.LoginDto)">
|
||||
<summary>
|
||||
没啥说,登录
|
||||
</summary>
|
||||
<param name="loginDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Register(Yi.Framework.DtoModel.Base.Dto.RegisterDto)">
|
||||
<summary>
|
||||
没啥说,注册
|
||||
</summary>
|
||||
<param name="registerDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Logout">
|
||||
<summary>
|
||||
没啥说,登出
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.GetUserAllInfo">
|
||||
<summary>
|
||||
通过已登录的用户获取用户信息
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.GetRouterInfo">
|
||||
<summary>
|
||||
获取当前登录用户的前端路由
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.UpdatePassword(Yi.Framework.DtoModel.Base.Dto.UpdatePasswordDto)">
|
||||
<summary>
|
||||
自己更新密码
|
||||
</summary>
|
||||
<param name="dto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.CaptchaImage">
|
||||
<summary>
|
||||
验证码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ConfigController.PageList(Yi.Framework.Model.RABC.Entitys.ConfigEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.SelctGetList(Yi.Framework.Model.RABC.Entitys.DeptEntity)">
|
||||
<summary>
|
||||
动态条件查询
|
||||
</summary>
|
||||
<param name="dept"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.Add(Yi.Framework.Model.RABC.Entitys.DeptEntity)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.Update(Yi.Framework.Model.RABC.Entitys.DeptEntity)">
|
||||
<summary>
|
||||
更新
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.GetListByRoleId(System.Int64)">
|
||||
<summary>
|
||||
根据角色id获取该角色下全部部门
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryController.PageList(Yi.Framework.Model.RABC.Entitys.DictionaryEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dic"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.PageList(Yi.Framework.Model.RABC.Entitys.DictionaryInfoEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="dicInfo"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DictionaryInfoController.GetListByType(System.String)">
|
||||
<summary>
|
||||
根据字典类别获取字典信息
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.FileController">
|
||||
<summary>
|
||||
文件
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.#ctor(Yi.Framework.Interface.RABC.IFileService,Microsoft.Extensions.Hosting.IHostEnvironment,Yi.Framework.Core.ThumbnailSharpInvoer)">
|
||||
<summary>
|
||||
文件上传下载
|
||||
</summary>
|
||||
<param name="iFileService"></param>
|
||||
<param name="env"></param>
|
||||
<param name="thumbnailSharpInvoer"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Get(System.Int64,System.Nullable{System.Boolean})">
|
||||
<summary>
|
||||
文件下载,只需用文件code即可,可选择是否为缩略图
|
||||
</summary>
|
||||
<param name="code"></param>
|
||||
<param name="isThumbnail"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Upload(System.String,Microsoft.AspNetCore.Http.IFormFileCollection,System.String)">
|
||||
<summary>
|
||||
多文件上传,type可空,默认上传至File文件夹下,swagger返回雪花id精度是有问题的,同时如果时图片类型,还需要进行缩略图制作
|
||||
</summary>
|
||||
<param name="type">文件类型,可空</param>
|
||||
<param name="file">多文件表单</param>
|
||||
<param name="remark">描述</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.ThumbnailSync">
|
||||
<summary>
|
||||
一键同步图片到缩略图
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.LogController.Add">
|
||||
<summary>
|
||||
自动分表,日志添加
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.LogController.GetList">
|
||||
<summary>
|
||||
查询近20年与21年的日志表
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.LoginLogController.PageList(Yi.Framework.Model.RABC.Entitys.LoginLogEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="loginLog"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.MenuController">
|
||||
<summary>
|
||||
菜单管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.SelctGetList(Yi.Framework.Model.RABC.Entitys.MenuEntity)">
|
||||
<summary>
|
||||
动态条件查询全部
|
||||
</summary>
|
||||
<param name="menu"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.Add(Yi.Framework.Model.RABC.Entitys.MenuEntity)">
|
||||
<summary>
|
||||
插入
|
||||
</summary>
|
||||
<param name="menu"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.Update(Yi.Framework.Model.RABC.Entitys.MenuEntity)">
|
||||
<summary>
|
||||
更新
|
||||
</summary>
|
||||
<param name="menu"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetMenuTree">
|
||||
<summary>
|
||||
得到树形菜单
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetListByRoleId(System.Int64)">
|
||||
<summary>
|
||||
根据角色id获取该角色下全部菜单
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.OnlineController">
|
||||
<summary>
|
||||
在线管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.OnlineController.PageList(Yi.Framework.WebCore.SignalRHub.OnlineUser,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件获取当前在线用户
|
||||
</summary>
|
||||
<param name="online"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.OnlineController.ForceOut(System.String)">
|
||||
<summary>
|
||||
强制退出用户
|
||||
</summary>
|
||||
<param name="connnectionId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.OperationLogController.PageList(Yi.Framework.Model.RABC.Entitys.OperationLogEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="operationLog"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.PostController.PageList(Yi.Framework.Model.RABC.Entitys.PostEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="post"></param>
|
||||
<param name="page"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.RoleController">
|
||||
<summary>
|
||||
角色管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.PageList(Yi.Framework.Model.RABC.Entitys.RoleEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.GiveRoleSetMenu(Yi.Framework.DtoModel.Base.Dto.GiveRoleSetMenuDto)">
|
||||
<summary>
|
||||
给多用户设置多角色
|
||||
</summary>
|
||||
<param name="giveRoleSetMenuDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.Add(Yi.Framework.DtoModel.Base.Dto.RoleInfoDto)">
|
||||
<summary>
|
||||
添加角色包含菜单
|
||||
</summary>
|
||||
<param name="roleDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.Update(Yi.Framework.DtoModel.Base.Dto.RoleInfoDto)">
|
||||
<summary>
|
||||
更新角色信息
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.UpdateStatus(System.Int64,System.Boolean)">
|
||||
<summary>
|
||||
更改角色状态
|
||||
</summary>
|
||||
<param name="roleId"></param>
|
||||
<param name="isDel"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.UpdateDataScpoce(Yi.Framework.DtoModel.Base.Dto.RoleInfoDto)">
|
||||
<summary>
|
||||
更改角色数据权限
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.DelList(System.Collections.Generic.List{System.Int64})">
|
||||
<summary>
|
||||
删除
|
||||
</summary>
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.UserController">
|
||||
<summary>
|
||||
用户管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.PageList(Yi.Framework.Model.RABC.Entitys.UserEntity,Yi.Framework.Common.Models.PageParModel,System.Nullable{System.Int64})">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<param name="user"></param>
|
||||
<param name="page"></param>
|
||||
<param name="deptId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.UpdateStatus(System.Int64,System.Boolean)">
|
||||
<summary>
|
||||
更改用户状态
|
||||
</summary>
|
||||
<param name="userId"></param>
|
||||
<param name="isDel"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GiveUserSetRole(Yi.Framework.DtoModel.Base.Dto.GiveUserSetRoleDto)">
|
||||
<summary>
|
||||
给多用户设置多角色
|
||||
</summary>
|
||||
<param name="giveUserSetRoleDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetById(System.Int64)">
|
||||
<summary>
|
||||
通过用户id得到用户信息关联部门、岗位、角色
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.Update(Yi.Framework.DtoModel.Base.Dto.UserInfoDto)">
|
||||
<summary>
|
||||
更新用户信息
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.UpdateProfile(Yi.Framework.DtoModel.Base.Dto.UserInfoDto)">
|
||||
<summary>
|
||||
更新个人中心信息
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.Add(Yi.Framework.DtoModel.Base.Dto.UserInfoDto)">
|
||||
<summary>
|
||||
添加用户
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.RestPassword(Yi.Framework.Model.RABC.Entitys.UserEntity)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="user"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.SkuController.PageList(Yi.Framework.Model.SHOP.Entitys.SkuEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.SpuController.PageList(Yi.Framework.Model.SHOP.Entitys.SpuEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.TestController">
|
||||
<summary>
|
||||
测试控制器
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.#ctor(Microsoft.AspNetCore.SignalR.IHubContext{Yi.Framework.WebCore.SignalRHub.MainHub},Microsoft.Extensions.Logging.ILogger{Yi.Framework.ApiMicroservice.Controllers.TestController},Yi.Framework.Interface.RABC.IRoleService,Yi.Framework.Interface.RABC.IUserService,Microsoft.Extensions.Localization.IStringLocalizer{Yi.Framework.Language.LocalLanguage},Yi.Framework.Core.Quartz.QuartzInvoker,Yi.Framework.Core.ThumbnailSharpInvoer,Yi.Framework.Core.Cache.CacheInvoker,SqlSugar.ISugarUnitOfWork{Yi.Framework.Repository.UnitOfWork})">
|
||||
<summary>
|
||||
依赖注入,优雅写法
|
||||
</summary>
|
||||
<param name="hub"></param>
|
||||
<param name="logger"></param>
|
||||
<param name="iRoleService"></param>
|
||||
<param name="iUserService"></param>
|
||||
<param name="local"></param>
|
||||
<param name="quartzInvoker"></param>
|
||||
<param name="thumbnailSharpInvoer"></param>
|
||||
<param name="cacheInvoker"></param>
|
||||
<param name="unitOfWork"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.Swagger">
|
||||
<summary>
|
||||
swagger跳转
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.DbTest">
|
||||
<summary>
|
||||
仓储上下文对象测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.UnitOfWorkTest">
|
||||
<summary>
|
||||
工作单元测试,使用sqlsugar内置
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.SqlTest">
|
||||
<summary>
|
||||
执行Sql返回
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.LocalTest">
|
||||
<summary>
|
||||
国际化测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.PermissionTest">
|
||||
<summary>
|
||||
权限测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.AuthTest">
|
||||
<summary>
|
||||
策略授权测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.TranTest">
|
||||
<summary>
|
||||
异步事务测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.IncludeTest">
|
||||
<summary>
|
||||
极爽导航属性
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.JobTest">
|
||||
<summary>
|
||||
启动一个定时任务
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.StopJob">
|
||||
<summary>
|
||||
停止任务
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.ErrorJob">
|
||||
<summary>
|
||||
job异常处理
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.TreeTest">
|
||||
<summary>
|
||||
树形结构构建测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.AuthorizeTest">
|
||||
<summary>
|
||||
授权测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.ClearDb">
|
||||
<summary>
|
||||
清空数据库
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.SeedDb">
|
||||
<summary>
|
||||
种子数据
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.LogTest(System.Collections.Generic.List{System.String})">
|
||||
<summary>
|
||||
操作日志测试
|
||||
</summary>
|
||||
<param name="par"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.SignalrTest(System.Int32)">
|
||||
<summary>
|
||||
Signalr实时推送测试
|
||||
</summary>
|
||||
<param name="msg"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.ThumbnailTest">
|
||||
<summary>
|
||||
缩略图测试,需要生成前及生成后的路径
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.CacheDBTest">
|
||||
<summary>
|
||||
缓存测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.CustomLogTest">
|
||||
<summary>
|
||||
自定义日志
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.PropertyTest">
|
||||
<summary>
|
||||
属性注入测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.CurrentUserTest">
|
||||
<summary>
|
||||
获取当前用户信息测试
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"apollo": {
|
||||
"AppId": "ApiMicroservice",
|
||||
"Env": "DEV",
|
||||
"MetaServer": "http://[xxxx]:18080",
|
||||
"ConfigServer": [ "http://[xxxx]:18080" ]
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Org.BouncyCastle.Asn1.IsisMtt.X509;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.BBS;
|
||||
using Yi.Framework.Model.BBS.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class AgreeController : ControllerBase
|
||||
{
|
||||
[Autowired]
|
||||
public IAgreeService? _iAgreeService { get; set; }
|
||||
[Autowired]
|
||||
public IArticleService? _iArticleService { get; set; }
|
||||
[Autowired]
|
||||
public ILogger<AgreeEntity>? _logger { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点赞操作
|
||||
/// </summary>
|
||||
/// <param name="articleId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> Operate(long articleId)
|
||||
{
|
||||
long userId = HttpContext.GetUserIdInfo();
|
||||
if (await _iAgreeService!.OperateAsync(articleId, userId))
|
||||
{
|
||||
return Result.Success("点赞成功");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return Result.Success("已点赞,取消点赞").StatusFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.Base.Vo;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.BBS;
|
||||
using Yi.Framework.Model.BBS.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章控制器
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class ArticleController : BaseSimpleCrudController<ArticleEntity>
|
||||
{
|
||||
private IArticleService _iArticleService;
|
||||
private IMapper _mapper;
|
||||
public ArticleController(ILogger<ArticleEntity> logger, IArticleService iArticleService, IMapper mapper) : base(logger, iArticleService)
|
||||
{
|
||||
_iArticleService = iArticleService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] ArticleEntity entity, [FromQuery] PageParModel page)
|
||||
{
|
||||
var pageData = await _iArticleService.SelctPageList(entity, page);
|
||||
return Result.Success().SetData(new PageModel() { Data = _mapper.Map<List<ArticleVo>>(pageData.Data), Total = pageData.Total });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public override Task<Result> Add(ArticleEntity entity)
|
||||
{
|
||||
//如果标题为空,默认为内容的前20个字符
|
||||
entity.Title = string.IsNullOrEmpty(entity.Title) ?
|
||||
(entity.Content?.Length > 20 ? entity.Content.Substring(0, 20) : entity.Content) :
|
||||
entity.Title;
|
||||
entity.UserId = HttpContext.GetUserIdInfo();
|
||||
return base.Add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.Base.Vo;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.BBS;
|
||||
using Yi.Framework.Model.BBS.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class CommentController : BaseSimpleCrudController<CommentEntity>
|
||||
{
|
||||
private ICommentService _iCommentService;
|
||||
private IMapper _mapper;
|
||||
public CommentController(ILogger<CommentEntity> logger, ICommentService iCommentService, IMapper mapper) : base(logger, iCommentService)
|
||||
{
|
||||
_iCommentService = iCommentService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文章的全部一级评论
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{articleId}")]
|
||||
public async Task<Result> GetListByArticleId(long articleId)
|
||||
{
|
||||
//一级评论被回复的用户id为空
|
||||
var data = await _repository._DbQueryable.Where(u => u.ParentId == 0 && u.ArticleId == articleId).Includes(u => u.CreateUserInfo).OrderByDescending(u=>u.CreateTime).ToListAsync();
|
||||
return Result.Success().SetData(_mapper.Map<List<CommentVo>>(data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一级评论详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<Result> GetById([FromRoute] long id)
|
||||
{
|
||||
var data = await _repository._DbQueryable.Includes(u => u.CreateUserInfo).Includes(u => u.UserInfo).FirstAsync(u => u.Id == id);
|
||||
return Result.Success().SetData(_mapper.Map<CommentVo>(data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回复文章或回复评论
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public override async Task<Result> Add(CommentEntity comment)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iCommentService.AddAsync(comment));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface.Base;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Model.Base.Query;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Json To Sql 类比模式,通用模型
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
public class BaseCrudController<T> : BaseExcelController<T> where T : class,new()
|
||||
{
|
||||
protected readonly ILogger<T> _logger;
|
||||
protected IBaseService<T> _baseService;
|
||||
public BaseCrudController(ILogger<T> logger, IBaseService<T> iBaseService):base(iBaseService._repository)
|
||||
{
|
||||
_logger = logger;
|
||||
_baseService = iBaseService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主键查询
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public virtual async Task<Result> GetById(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public virtual async Task<Result> GetList(QueryCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="queryCondition"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public virtual async Task<Result> PageList(QueryPageCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public virtual async Task<Result> Add(T entity)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.InsertReturnSnowflakeIdAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public virtual async Task<Result> Update(T entity)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.UpdateIgnoreNullAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public virtual async Task<Result> DeleteList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.DeleteByIdAsync(ids.ToDynamicArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
public class BaseExcelController<T> : ControllerBase where T : class, new()
|
||||
{
|
||||
protected IRepository<T> _repository;
|
||||
public BaseExcelController(IRepository<T> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
/// <summary>
|
||||
/// 下载模板
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public IActionResult Template()
|
||||
{
|
||||
List<T> users = new();
|
||||
var fileName = typeof(T).Name + PathConst.DataTemplate;
|
||||
var path = ExcelHelper.DownloadImportTemplate(users, fileName, Path.Combine(PathConst.wwwroot, PathEnum.Excel.ToString()));
|
||||
var file = System.IO.File.OpenRead(path);
|
||||
return File(file, "text/plain", $"{DateTime.Now.ToString("yyyyMMddHHmmssffff") + fileName }.xlsx");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导出数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<IActionResult> Export()
|
||||
{
|
||||
var users = await _repository.GetListAsync();
|
||||
var fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + nameof(T) + PathConst.DataExport;
|
||||
var path = ExcelHelper.ExportExcel(users, fileName, Path.Combine(PathConst.wwwroot, PathEnum.Temp.ToString()));
|
||||
var file = System.IO.File.OpenRead(path);
|
||||
return File(file, "text/plain", $"{ fileName }.xlsx");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<Result> Import([FromForm(Name = "file")]IFormFile formFile)
|
||||
{
|
||||
List<T> datas = ExcelHelper.ImportData<T>(formFile.OpenReadStream());
|
||||
|
||||
//全量删除在重新插入
|
||||
var res = await _repository.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.DeleteAsync(u => true);
|
||||
await _repository.InsertRangeAsync(datas);
|
||||
});
|
||||
return Result.Success().SetStatus(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface.Base;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Json To Sql 类比模式,通用模型
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
public class BaseSimpleCrudController<T> : BaseExcelController<T> where T : class, new()
|
||||
{
|
||||
protected readonly ILogger<T> _logger;
|
||||
protected IBaseService<T> _baseService;
|
||||
public BaseSimpleCrudController(ILogger<T> logger, IBaseService<T> iBaseService):base(iBaseService._repository)
|
||||
{
|
||||
_logger = logger;
|
||||
_baseService = iBaseService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主键查询
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[Route("{id}")]
|
||||
[HttpGet]
|
||||
public virtual async Task<Result> GetById([FromRoute]long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部列表查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public virtual async Task<Result> GetList()
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetListAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public virtual async Task<Result> Add(T entity)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.InsertReturnSnowflakeIdAsync(entity));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public virtual async Task<Result> Update(T entity)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.UpdateIgnoreNullAsync(entity));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public virtual async Task<Result> DelList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.DeleteByIdsAsync(ids.ToDynamicArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface.Base;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Json To Sql 类比模式,通用模型
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
public class BaseSimpleRdController<T> : BaseExcelController<T> where T : class, new()
|
||||
{
|
||||
protected readonly ILogger<T> _logger;
|
||||
protected IBaseService<T> _baseService;
|
||||
public BaseSimpleRdController(ILogger<T> logger, IBaseService<T> iBaseService):base(iBaseService._repository)
|
||||
{
|
||||
_logger = logger;
|
||||
_baseService = iBaseService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主键查询
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[Route("{id}")]
|
||||
[HttpGet]
|
||||
public virtual async Task<Result> GetById([FromRoute]long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部列表查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public virtual async Task<Result> GetList()
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetListAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public virtual async Task<Result> DelList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.DeleteByIdsAsync(ids.ToDynamicArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Material;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class MaterialController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<MaterialController> _logger;
|
||||
private readonly IMaterialService _materialService;
|
||||
public MaterialController(ILogger<MaterialController> logger, IMaterialService materialService)
|
||||
{
|
||||
_logger = logger;
|
||||
_materialService = materialService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] MaterialCreateUpdateInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _materialService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _materialService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(MaterialCreateUpdateInput input)
|
||||
{
|
||||
var result = await _materialService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, MaterialCreateUpdateInput input)
|
||||
{
|
||||
var result = await _materialService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _materialService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Abstract;
|
||||
using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Purchase;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class PurchaseController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<PurchaseController> _logger;
|
||||
private readonly IPurchaseService _purchaseService;
|
||||
public PurchaseController(ILogger<PurchaseController> logger, IPurchaseService purchaseService)
|
||||
{
|
||||
_logger = logger;
|
||||
_purchaseService = purchaseService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] PurchaseGetListInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _purchaseService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _purchaseService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(PurchaseCreateInput input)
|
||||
{
|
||||
var result = await _purchaseService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, PurchaseUpdateInput input)
|
||||
{
|
||||
var result = await _purchaseService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _purchaseService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.PurchaseDetails;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class PurchaseDetailsController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<PurchaseDetailsController> _logger;
|
||||
private readonly IPurchaseDetailsService _purchaseDetailsService;
|
||||
public PurchaseDetailsController(ILogger<PurchaseDetailsController> logger, IPurchaseDetailsService purchaseDetailsService)
|
||||
{
|
||||
_logger = logger;
|
||||
_purchaseDetailsService = purchaseDetailsService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] PurchaseDetailsCreateUpdateInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _purchaseDetailsService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _purchaseDetailsService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(PurchaseDetailsCreateUpdateInput input)
|
||||
{
|
||||
var result = await _purchaseDetailsService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, PurchaseDetailsCreateUpdateInput input)
|
||||
{
|
||||
var result = await _purchaseDetailsService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _purchaseDetailsService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Supplier;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class SupplierController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<SupplierController> _logger;
|
||||
private readonly ISupplierService _supplierService;
|
||||
public SupplierController(ILogger<SupplierController> logger, ISupplierService supplierService)
|
||||
{
|
||||
_logger = logger;
|
||||
_supplierService = supplierService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] SupplierCreateUpdateInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _supplierService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _supplierService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(SupplierCreateUpdateInput input)
|
||||
{
|
||||
var result = await _supplierService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, SupplierCreateUpdateInput input)
|
||||
{
|
||||
var result = await _supplierService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _supplierService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Unit;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class UnitController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<UnitController> _logger;
|
||||
private readonly IUnitService _unitService;
|
||||
public UnitController(ILogger<UnitController> logger, IUnitService unitService)
|
||||
{
|
||||
_logger = logger;
|
||||
_unitService = unitService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] UnitCreateUpdateInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _unitService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _unitService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetList()
|
||||
{
|
||||
var result = await _unitService.GetListAsync();
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(UnitCreateUpdateInput input)
|
||||
{
|
||||
var result = await _unitService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, UnitCreateUpdateInput input)
|
||||
{
|
||||
var result = await _unitService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _unitService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.ERP.Warehouse;
|
||||
using Yi.Framework.Interface.ERP;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class WarehouseController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<WarehouseController> _logger;
|
||||
private readonly IWarehouseService _warehouseService;
|
||||
public WarehouseController(ILogger<WarehouseController> logger, IWarehouseService warehouseService)
|
||||
{
|
||||
_logger = logger;
|
||||
_warehouseService = warehouseService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] WarehouseCreateUpdateInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _warehouseService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单查
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetById(long id)
|
||||
{
|
||||
var result = await _warehouseService.GetByIdAsync(id);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(WarehouseCreateUpdateInput input)
|
||||
{
|
||||
var result = await _warehouseService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, WarehouseCreateUpdateInput input)
|
||||
{
|
||||
var result = await _warehouseService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
public async Task<Result> Del(List<long> ids)
|
||||
{
|
||||
await _warehouseService.DeleteAsync(ids);
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
using Hei.Captcha;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Cache;
|
||||
using Yi.Framework.DtoModel.Base.Dto;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 账户管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class AccountController : ControllerBase
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
private JwtInvoker _jwtInvoker;
|
||||
private ILogger _logger;
|
||||
private SecurityCodeHelper _securityCode;
|
||||
private IRepository<UserEntity> _repository;
|
||||
private CacheInvoker _cacheDb;
|
||||
public AccountController(ILogger<UserEntity> logger,
|
||||
IUserService iUserService,
|
||||
JwtInvoker jwtInvoker,
|
||||
SecurityCodeHelper securityCode,
|
||||
CacheInvoker cacheInvoker)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
_jwtInvoker = jwtInvoker;
|
||||
_logger = logger;
|
||||
_securityCode = securityCode;
|
||||
_repository = iUserService._repository;
|
||||
_cacheDb = cacheInvoker;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置管理员CC的密码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<Result> RestCC()
|
||||
{
|
||||
var user = await _iUserService._repository.GetFirstAsync(u => u.UserName == "cc");
|
||||
user.Password = "123456";
|
||||
user.BuildPassword();
|
||||
await _iUserService._repository.UpdateIgnoreNullAsync(user);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 没啥说,登录
|
||||
/// </summary>
|
||||
/// <param name="loginDto"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public async Task<Result> Login(LoginDto loginDto)
|
||||
{
|
||||
//跳过,需要redis缓存获取uuid与code的关系,进行比较即可
|
||||
//先效验验证码和UUID
|
||||
//登录还需要进行登录日志的落库
|
||||
|
||||
//先进行验证码的效验
|
||||
|
||||
var code = _cacheDb.Get<string>($"Yi:Captcha:{loginDto.Uuid}");
|
||||
//判断是否开启二维码效验
|
||||
if (GobalModel.LoginCodeEnable)
|
||||
{
|
||||
if (code != loginDto.Code)
|
||||
{
|
||||
return Result.Error("验证码错误!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var loginInfo = HttpContext.GetLoginLogInfo();
|
||||
|
||||
loginInfo.LoginUser = loginDto.UserName;
|
||||
loginInfo.LogMsg = "登录成功!";
|
||||
|
||||
|
||||
var loginLogRepository = _repository.ChangeRepository<Repository<LoginLogEntity>>();
|
||||
UserEntity user = new();
|
||||
|
||||
//这里其实可以返回Dto
|
||||
if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o))
|
||||
{
|
||||
//根据用户id获取改用户的完整信息
|
||||
var userRoleMenu = await _iUserService.GetUserAllInfo(user.Id);
|
||||
|
||||
//如果该用户没有任何一个菜单,或者没有任何一个角色,无意义的登录
|
||||
if (userRoleMenu.PermissionCodes.Count == 0)
|
||||
{
|
||||
return Result.Error("登录禁用!该用户分配无任何权限,无意义登录!");
|
||||
}
|
||||
|
||||
|
||||
//将该用户的完整信息缓存一份至缓存,后续需要完整用户信息,只需通过token中的id从缓存中获取即可
|
||||
|
||||
//先制作token
|
||||
var token = _jwtInvoker.GetAccessToken(userRoleMenu.User, userRoleMenu.Menus);
|
||||
|
||||
//需要注意,缓存用户信息时间应大于或等于token过期时间
|
||||
_cacheDb.Set($"Yi:UserInfo:{user.Id}", userRoleMenu, _jwtInvoker.GetTokenExpiration());
|
||||
|
||||
|
||||
await loginLogRepository.InsertReturnSnowflakeIdAsync(loginInfo);
|
||||
return Result.Success(loginInfo.LogMsg).SetData(new { token });
|
||||
}
|
||||
loginInfo.LogMsg = "登录失败!用户名或者密码错误!";
|
||||
await loginLogRepository.InsertReturnSnowflakeIdAsync(loginInfo);
|
||||
return Result.Error(loginInfo.LogMsg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 没啥说,注册
|
||||
/// </summary>
|
||||
/// <param name="registerDto"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
public async Task<Result> Register(RegisterDto registerDto)
|
||||
{
|
||||
UserEntity user = new();
|
||||
if (await _iUserService.Register(WebCore.Mapper.MapperHelper.Map<UserEntity, RegisterDto>(registerDto), o => user = o))
|
||||
{
|
||||
return Result.Success("注册成功!").SetData(user);
|
||||
}
|
||||
return Result.SuccessError("注册失败!用户名已存在!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 没啥说,登出
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public Result Logout()
|
||||
{
|
||||
return Result.Success("安全登出成功!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过已登录的用户获取用户信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result GetUserAllInfo()
|
||||
{
|
||||
//通过鉴权jwt获取到用户的id
|
||||
var userId = HttpContext.GetUserIdInfo();
|
||||
//此处从缓存中获取即可
|
||||
var data = _cacheDb.Get<UserRoleMenuDto>($"Yi:UserInfo:{userId}");
|
||||
//var data = await _iUserService.GetUserAllInfo(userId);
|
||||
//系统用户数据被重置,老前端访问重新授权
|
||||
if (data is null)
|
||||
{
|
||||
return Result.UnAuthorize();
|
||||
}
|
||||
|
||||
data.Menus.Clear();
|
||||
return Result.Success().SetData(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前登录用户的前端路由
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetRouterInfo()
|
||||
{
|
||||
var userId = HttpContext.GetUserIdInfo();
|
||||
var data = await _iUserService.GetUserAllInfo(userId);
|
||||
var menus = data.Menus.ToList();
|
||||
|
||||
//为超级管理员直接给全部路由
|
||||
if (SystemConst.Admin.Equals(data.User.UserName))
|
||||
{
|
||||
menus = await _iUserService._repository.ChangeRepository<Repository<MenuEntity>>().GetListAsync();
|
||||
}
|
||||
//将后端菜单转换成前端路由,组件级别需要过滤
|
||||
List<VueRouterModel> routers = MenuEntity.RouterBuild(menus);
|
||||
return Result.Success().SetData(routers);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自己更新密码
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdatePassword(UpdatePasswordDto dto)
|
||||
{
|
||||
long userId = HttpContext.GetUserIdInfo();
|
||||
|
||||
if (await _iUserService.UpdatePassword(dto, userId))
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
return Result.Error("更新失败!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
public Result CaptchaImage()
|
||||
{
|
||||
var uuid = Guid.NewGuid();
|
||||
var code = _securityCode.GetRandomEnDigitalText(4);
|
||||
//将uuid与code,Redis缓存中心化保存起来,登录根据uuid比对即可
|
||||
//10分钟过期
|
||||
_cacheDb.Set($"Yi:Captcha:{uuid}", code, new TimeSpan(0, 10, 0));
|
||||
var imgbyte = _securityCode.GetEnDigitalCodeByte(code);
|
||||
return Result.Success().SetData(new { uuid = uuid, img = imgbyte });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class ConfigController : BaseSimpleCrudController<ConfigEntity>
|
||||
{
|
||||
private IConfigService _iConfigService;
|
||||
public ConfigController(ILogger<ConfigEntity> logger, IConfigService iConfigService) : base(logger, iConfigService)
|
||||
{
|
||||
_iConfigService = iConfigService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] ConfigEntity dic, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iConfigService.SelctPageList(dic, page));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class DeptController : BaseSimpleCrudController<DeptEntity>
|
||||
{
|
||||
private IDeptService _iDeptService;
|
||||
public DeptController(ILogger<DeptEntity> logger, IDeptService iDeptService) : base(logger, iDeptService)
|
||||
{
|
||||
_iDeptService = iDeptService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件查询
|
||||
/// </summary>
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> SelctGetList([FromQuery] DeptEntity dept)
|
||||
{
|
||||
return Result.Success().SetData(await _iDeptService.SelctGetList(dept));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<Result> Add(DeptEntity entity)
|
||||
{
|
||||
return await base.Add(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<Result> Update(DeptEntity entity)
|
||||
{
|
||||
return await base.Update(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色id获取该角色下全部部门
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetListByRoleId(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iDeptService.GetListByRoleId(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class DictionaryController :BaseSimpleCrudController<DictionaryEntity>
|
||||
{
|
||||
private IDictionaryService _iDictionaryService;
|
||||
public DictionaryController(ILogger<DictionaryEntity> logger, IDictionaryService iDictionaryService):base(logger, iDictionaryService)
|
||||
{
|
||||
_iDictionaryService = iDictionaryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] DictionaryEntity dic, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryService.SelctPageList(dic, page));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class DictionaryInfoController:BaseSimpleCrudController<DictionaryInfoEntity>
|
||||
{
|
||||
private IDictionaryInfoService _iDictionaryInfoService;
|
||||
public DictionaryInfoController(ILogger<DictionaryInfoEntity> logger, IDictionaryInfoService iDictionaryInfoService):base(logger, iDictionaryInfoService)
|
||||
{
|
||||
_iDictionaryInfoService = iDictionaryInfoService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="dicInfo"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] DictionaryInfoEntity dicInfo, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService.SelctPageList(dicInfo, page));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类别获取字典信息
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{type}")]
|
||||
public async Task<Result> GetListByType([FromRoute] string type)
|
||||
{
|
||||
return Result.Success().SetData(await _iDictionaryInfoService._repository.GetListAsync(u=>u.DictType==type&&u.IsDeleted==false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,242 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.WebCore;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件
|
||||
/// </summary>
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class FileController : ControllerBase
|
||||
{
|
||||
private IFileService _iFileService;
|
||||
private readonly IHostEnvironment _env;
|
||||
private ThumbnailSharpInvoer _thumbnailSharpInvoer;
|
||||
|
||||
/// <summary>
|
||||
/// 文件上传下载
|
||||
/// </summary>
|
||||
/// <param name="iFileService"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <param name="thumbnailSharpInvoer"></param>
|
||||
public FileController(IFileService iFileService, IHostEnvironment env, ThumbnailSharpInvoer thumbnailSharpInvoer)
|
||||
{
|
||||
_iFileService = iFileService;
|
||||
_env = env;
|
||||
_thumbnailSharpInvoer = thumbnailSharpInvoer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件下载,只需用文件code即可,可选择是否为缩略图
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="isThumbnail"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/file/{code}/{isThumbnail?}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get(long code, bool? isThumbnail)
|
||||
{
|
||||
var file = await _iFileService._repository.GetByIdAsync(code);
|
||||
if (file is null)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
try
|
||||
{
|
||||
//如果为缩略图
|
||||
if (isThumbnail is true)
|
||||
{
|
||||
file.FilePath = PathEnum.Thumbnail.ToString();
|
||||
}
|
||||
//路径为: 文件路径/文件id+文件扩展名
|
||||
var path = Path.Combine($"{PathConst.wwwroot}/{file.FilePath}", file.Id.ToString() + Path.GetExtension(file.FileName));
|
||||
var stream = System.IO.File.OpenRead(path);
|
||||
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(file.FileName!);
|
||||
return File(stream, MimeType, file.FileName);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多文件上传,type可空,默认上传至File文件夹下,swagger返回雪花id精度是有问题的,同时如果时图片类型,还需要进行缩略图制作
|
||||
/// </summary>
|
||||
/// <param name="type">文件类型,可空</param>
|
||||
/// <param name="file">多文件表单</param>
|
||||
/// <param name="remark">描述</param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/file/Upload/{type?}")]
|
||||
[HttpPost]
|
||||
public async Task<Result> Upload([FromRoute] string? type, [FromForm] IFormFileCollection file, [FromQuery] string? remark)
|
||||
{
|
||||
type = type ?? PathEnum.File.ToString();
|
||||
|
||||
type = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(type.ToLower());
|
||||
if (!Enum.IsDefined(typeof(PathEnum), type))
|
||||
{
|
||||
//后续类型可从字典表中获取
|
||||
return Result.Error("上传失败!文件类型不支持!");
|
||||
}
|
||||
|
||||
|
||||
if (file.Count() == 0)
|
||||
{
|
||||
return Result.Error("未选择文件");
|
||||
}
|
||||
//批量插入
|
||||
List<FileEntity> datas = new();
|
||||
|
||||
//返回的codes
|
||||
List<long> codes = new();
|
||||
try
|
||||
{
|
||||
foreach (var f in file)
|
||||
{
|
||||
FileEntity data = new();
|
||||
data.Id = SnowFlakeSingle.Instance.NextId();
|
||||
data.FileSize = ((decimal)f.Length) / 1024;
|
||||
data.FileName = f.FileName;
|
||||
data.FileType = Common.Helper.MimeHelper.GetMimeMapping(f.FileName);
|
||||
data.FilePath = type;
|
||||
data.Remark = remark;
|
||||
data.IsDeleted = false;
|
||||
|
||||
//落盘文件,文件名为雪花id+自己的扩展名
|
||||
string filename = data.Id.ToString() + Path.GetExtension(f.FileName);
|
||||
string typePath = $"{PathConst.wwwroot}/{type}";
|
||||
if (!Directory.Exists(typePath))
|
||||
{
|
||||
Directory.CreateDirectory(typePath);
|
||||
}
|
||||
|
||||
//生成文件
|
||||
using (var stream = new FileStream(Path.Combine(typePath, filename), FileMode.CreateNew, FileAccess.ReadWrite))
|
||||
{
|
||||
await f.CopyToAsync(stream);
|
||||
|
||||
//如果是图片类型,还需要生成缩略图,当然,如果图片很小,直接复制过去即可
|
||||
if (PathEnum.Image.ToString().Equals(type))
|
||||
{
|
||||
string thumbnailPath = $"{PathConst.wwwroot}/{PathEnum.Thumbnail}";
|
||||
if (!Directory.Exists(thumbnailPath))
|
||||
{
|
||||
Directory.CreateDirectory(thumbnailPath);
|
||||
}
|
||||
//保存至缩略图路径
|
||||
byte[] result=null!;
|
||||
try
|
||||
{
|
||||
result = _thumbnailSharpInvoer.CreateThumbnailBytes(thumbnailSize: 300,
|
||||
imageStream: stream,
|
||||
imageFormat: Format.Jpeg);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = new byte[stream.Length];
|
||||
stream.Read(result, 0, result.Length);
|
||||
// 设置当前流的位置为流的开始
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
await System.IO.File.WriteAllBytesAsync(Path.Combine(thumbnailPath, filename), result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
//将文件信息添加到数据库
|
||||
datas.Add(data);
|
||||
codes.Add(data.Id);
|
||||
}
|
||||
return Result.Success().SetData(codes).SetStatus(await _iFileService._repository.InsertRangeAsync(datas));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Result.Error();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 一键同步图片到缩略图
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> ThumbnailSync()
|
||||
{
|
||||
string typePath = $"{PathConst.wwwroot}/{PathEnum.Image}";
|
||||
string thumbnailPath = $"{PathConst.wwwroot}/{PathEnum.Thumbnail}";
|
||||
List<string> fileNames = FileHelper.GetAllFileNames(typePath);
|
||||
foreach (var filename in fileNames)
|
||||
{
|
||||
if (System.IO.File.Exists(Path.Combine(thumbnailPath, filename)))
|
||||
{
|
||||
//如果缩略图存在,直接跳过
|
||||
continue;
|
||||
}
|
||||
if (!Directory.Exists(typePath))
|
||||
{
|
||||
Directory.CreateDirectory(typePath);
|
||||
}
|
||||
|
||||
|
||||
using (var stream = new FileStream(Path.Combine(typePath, filename), FileMode.Open, FileAccess.ReadWrite))
|
||||
{
|
||||
byte[] result=null!;
|
||||
try
|
||||
{
|
||||
|
||||
//保存至缩略图路径
|
||||
result = _thumbnailSharpInvoer.CreateThumbnailBytes(thumbnailSize: 300,
|
||||
imageStream: stream,
|
||||
imageFormat: Format.Jpeg);
|
||||
|
||||
if (!Directory.Exists(thumbnailPath))
|
||||
{
|
||||
Directory.CreateDirectory(thumbnailPath);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = new byte[stream.Length];
|
||||
stream.Read(result, 0, result.Length);
|
||||
// 设置当前流的位置为流的开始
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
////如果当前文件同步失败,就跳转到下一个
|
||||
}
|
||||
finally {
|
||||
|
||||
await System.IO.File.WriteAllBytesAsync(Path.Combine(thumbnailPath, filename), result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class LogController : ControllerBase
|
||||
{
|
||||
private ILogService _iLogService;
|
||||
//大量日志,将采用自动分表形式,默认1年分一次表
|
||||
public LogController(ILogger<LogEntity> logger, ILogService iLogService)
|
||||
{
|
||||
_iLogService = iLogService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动分表,日志添加
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Add()
|
||||
{
|
||||
Random random = new Random();
|
||||
var logList = new List<LogEntity>() {
|
||||
new LogEntity() { CreateTime = Convert.ToDateTime("2019-12-1"), Message = "jack"+random.Next() } ,
|
||||
new LogEntity() { CreateTime = Convert.ToDateTime("2022-02-1"), Message = "jack"+random.Next() },
|
||||
new LogEntity() { CreateTime = Convert.ToDateTime("2020-02-1"), Message = "jack"+random.Next() },
|
||||
new LogEntity() { CreateTime = Convert.ToDateTime("2021-12-1"), Message = "jack"+random.Next() } };
|
||||
return Result.Success().SetData(await _iLogService.AddListTest(logList));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询近20年与21年的日志表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetList()
|
||||
{
|
||||
return Result.Success().SetData(await _iLogService.GetListTest());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class LoginLogController : BaseSimpleCrudController<LoginLogEntity>
|
||||
{
|
||||
private ILoginLogService _iLoginLogService;
|
||||
public LoginLogController(ILogger<LoginLogEntity> logger, ILoginLogService iLoginLogService) : base(logger, iLoginLogService)
|
||||
{
|
||||
_iLoginLogService = iLoginLogService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="loginLog"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] LoginLogEntity loginLog, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iLoginLogService.SelctPageList(loginLog, page));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class MenuController: BaseSimpleRdController<MenuEntity>
|
||||
{
|
||||
private IMenuService _iMenuService;
|
||||
public MenuController(ILogger<MenuEntity> logger, IMenuService iMenuService):base(logger,iMenuService)
|
||||
{
|
||||
_iMenuService = iMenuService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件查询全部
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Permission("system:menu:query")]
|
||||
public async Task<Result> SelctGetList([FromQuery] MenuEntity menu)
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.SelctGetList(menu));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Permission("system:menu:add")]
|
||||
public async Task<Result> Add(MenuEntity menu)
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService._repository.InsertReturnSnowflakeIdAsync(menu));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:menu:edit")]
|
||||
public async Task<Result> Update(MenuEntity menu)
|
||||
{
|
||||
//注意,这里如果是主目录,还需要判断/,需要以/开头
|
||||
return Result.Success().SetData(await _iMenuService._repository.UpdateIgnoreNullAsync(menu));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到树形菜单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Permission("system:menu:query")]
|
||||
public async Task<Result> GetMenuTree()
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.GetMenuTreeAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色id获取该角色下全部菜单
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
[Permission("system:menu:query")]
|
||||
public async Task<Result> GetListByRoleId(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.GetListByRoleId(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using Hei.Captcha;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.DtoModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
using Yi.Framework.WebCore.SignalRHub;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 在线管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class OnlineController : ControllerBase
|
||||
{
|
||||
private ILogger<OnlineController> _logger;
|
||||
private IHubContext<MainHub> _hub;
|
||||
public OnlineController(ILogger<OnlineController> logger, IHubContext<MainHub> hub)
|
||||
{
|
||||
_logger = logger;
|
||||
_hub = hub;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件获取当前在线用户
|
||||
/// </summary>
|
||||
/// <param name="online"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result PageList([FromQuery] OnlineUser online, [FromQuery] PageParModel page)
|
||||
{
|
||||
var data = MainHub.clientUsers;
|
||||
IEnumerable<OnlineUser> dataWhere = data.AsEnumerable();
|
||||
|
||||
if (!string.IsNullOrEmpty(online.Ipaddr))
|
||||
{
|
||||
dataWhere = dataWhere.Where((u) => u.Ipaddr!.Contains(online.Ipaddr));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(online.UserName))
|
||||
{
|
||||
dataWhere = dataWhere.Where((u) => u.UserName!.Contains(online.UserName));
|
||||
}
|
||||
return Result.Success().SetData(new PageModel<List<OnlineUser>>() { Total = data.Count, Data = dataWhere.ToList() });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 强制退出用户
|
||||
/// </summary>
|
||||
/// <param name="connnectionId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpDelete]
|
||||
[Route("{connnectionId}")]
|
||||
public async Task<Result> ForceOut(string connnectionId)
|
||||
{
|
||||
if (MainHub.clientUsers.Exists(u => u.ConnnectionId == connnectionId))
|
||||
{
|
||||
//前端接受到这个事件后,触发前端自动退出
|
||||
await _hub.Clients.Client(connnectionId).SendAsync(HubTypeEnum.forceOut.ToString(),"你已被强制退出!");
|
||||
return Result.Success();
|
||||
}
|
||||
return Result.Error("操作失败!未发现该连接!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class OperationLogController : BaseSimpleCrudController<OperationLogEntity>
|
||||
{
|
||||
private IOperationLogService _iOperationLogService;
|
||||
public OperationLogController(ILogger<OperationLogEntity> logger, IOperationLogService iOperationLogService) : base(logger, iOperationLogService)
|
||||
{
|
||||
_iOperationLogService = iOperationLogService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="operationLog"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] OperationLogEntity operationLog, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iOperationLogService.SelctPageList(operationLog, page));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class PostController : BaseSimpleCrudController<PostEntity>
|
||||
{
|
||||
private IPostService _iPostService;
|
||||
public PostController(ILogger<PostEntity> logger, IPostService iPostService) : base(logger, iPostService)
|
||||
{
|
||||
_iPostService = iPostService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] PostEntity post, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iPostService.SelctPageList(post, page));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override async Task<Result> Add(PostEntity entity)
|
||||
{
|
||||
return await base.Add(entity);
|
||||
}
|
||||
|
||||
public override async Task<Result> Update(PostEntity entity)
|
||||
{
|
||||
return await base.Update(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.Base.Dto;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.Service;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class RoleController : BaseSimpleRdController<RoleEntity>
|
||||
{
|
||||
private IRoleService _iRoleService;
|
||||
public RoleController(ILogger<RoleEntity> logger, IRoleService iRoleService) : base(logger, iRoleService)
|
||||
{
|
||||
_iRoleService = iRoleService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Permission("system:role:query")]
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] RoleEntity role, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iRoleService.SelctPageList(role, page));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 给多用户设置多角色
|
||||
/// </summary>
|
||||
/// <param name="giveRoleSetMenuDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:role:edit")]
|
||||
public async Task<Result> GiveRoleSetMenu(GiveRoleSetMenuDto giveRoleSetMenuDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRoleService.GiveRoleSetMenu(giveRoleSetMenuDto.RoleIds, giveRoleSetMenuDto.MenuIds));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加角色包含菜单
|
||||
/// </summary>
|
||||
/// <param name="roleDto"></param>
|
||||
/// <returns></returns>
|
||||
[Permission("system:role:add")]
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetData(await _iRoleService.AddInfo(roleDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Permission("system:role:edit")]
|
||||
[HttpPut]
|
||||
public async Task<Result> Update(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRoleService.UpdateInfo(roleDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改角色状态
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <param name="isDel"></param>
|
||||
/// <returns></returns>
|
||||
[Permission("system:role:edit")]
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateStatus(long roleId, bool isDel)
|
||||
{
|
||||
return Result.Success().SetData(await _iRoleService._repository.UpdateIgnoreNullAsync(new RoleEntity() { Id = roleId, IsDeleted = isDel }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///更改角色数据权限
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Permission("system:role:edit")]
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateDataScpoce(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRoleService.UpdateDataScpoce(roleDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[Permission("system:role:remove")]
|
||||
[HttpDelete]
|
||||
public override async Task<Result> DelList(List<long> ids)
|
||||
{
|
||||
return await base.DelList(ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DtoModel.Base.Dto;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class UserController : BaseSimpleRdController<UserEntity>
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
|
||||
public UserController(ILogger<UserEntity> logger, IUserService iUserService) : base(logger, iUserService)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="page"></param>
|
||||
/// <param name="deptId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Permission("system:user:query")]
|
||||
public async Task<Result> PageList([FromQuery] UserEntity user, [FromQuery] PageParModel page, [FromQuery] long? deptId)
|
||||
{
|
||||
return Result.Success().SetData(await _iUserService.SelctPageList(user, page, deptId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更改用户状态
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="isDel"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:user:edit")]
|
||||
[Log("用户模块", OperEnum.Update)]
|
||||
public async Task<Result> UpdateStatus(long userId, bool isDel)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.UpdateIgnoreNullAsync(new UserEntity() { Id = userId, IsDeleted = isDel }));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给多用户设置多角色
|
||||
/// </summary>
|
||||
/// <param name="giveUserSetRoleDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:user:edit")]
|
||||
[Log("用户模块", OperEnum.Update)]
|
||||
public async Task<Result> GiveUserSetRole(GiveUserSetRoleDto giveUserSetRoleDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iUserService.GiveUserSetRole(giveUserSetRoleDto.UserIds, giveUserSetRoleDto.RoleIds));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过用户id得到用户信息关联部门、岗位、角色
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
[Permission("system:user:query")]
|
||||
public override async Task<Result> GetById([FromRoute] long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iUserService.GetInfoById(id));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户信息
|
||||
/// </summary>
|
||||
/// <param name="userDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:user:edit")]
|
||||
[Log("用户模块", OperEnum.Update)]
|
||||
public async Task<Result> Update(UserInfoDto userDto)
|
||||
{
|
||||
if (await _repository.IsAnyAsync(u => userDto.User!.UserName!.Equals(u.UserName) && !userDto.User.Id.Equals(u.Id)))
|
||||
{
|
||||
return Result.Error("用户名已存在,修改失败!");
|
||||
}
|
||||
return Result.Success().SetStatus(await _iUserService.UpdateInfo(userDto));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新个人中心信息
|
||||
/// </summary>
|
||||
/// <param name="userDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:user:edit")]
|
||||
[Log("用户模块", OperEnum.Update)]
|
||||
public async Task<Result> UpdateProfile(UserInfoDto userDto)
|
||||
{
|
||||
//修改需要赋值上主键哦
|
||||
userDto.User!.Id = HttpContext.GetUserIdInfo();
|
||||
return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户
|
||||
/// </summary>
|
||||
/// <param name="userDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Permission("system:user:add")]
|
||||
[Log("用户模块", OperEnum.Insert)]
|
||||
public async Task<Result> Add(UserInfoDto userDto)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userDto?.User?.Password))
|
||||
{
|
||||
return Result.Error("密码为空,添加失败!");
|
||||
}
|
||||
if (await _repository.IsAnyAsync(u => userDto.User.UserName!.Equals(u.UserName)))
|
||||
{
|
||||
return Result.Error("用户已经存在,添加失败!");
|
||||
}
|
||||
|
||||
return Result.Success().SetStatus(await _iUserService.AddInfo(userDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置密码
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Permission("system:user:edit")]
|
||||
[Log("用户模块", OperEnum.Update)]
|
||||
public async Task<Result> RestPassword(UserEntity user)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iUserService.RestPassword(user.Id, user.Password));
|
||||
}
|
||||
[Permission("system:user:query")]
|
||||
public override Task<Result> GetList()
|
||||
{
|
||||
return base.GetList();
|
||||
}
|
||||
[Permission("system:user:remove")]
|
||||
[Log("用户模块", OperEnum.Delete)]
|
||||
public override Task<Result> DelList(List<long> ids)
|
||||
{
|
||||
return base.DelList(ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface.SHOP;
|
||||
using Yi.Framework.Model.SHOP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class CategoryController : BaseCrudController<CategoryEntity>
|
||||
{
|
||||
private ICategoryService _iCategoryService;
|
||||
public CategoryController(ILogger<CategoryEntity> logger, ICategoryService iCategoryService) : base(logger, iCategoryService)
|
||||
{
|
||||
_iCategoryService = iCategoryService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.SHOP;
|
||||
using Yi.Framework.Model.SHOP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class SkuController : BaseSimpleCrudController<SkuEntity>
|
||||
{
|
||||
private ISkuService _iSkuService;
|
||||
public SkuController(ILogger<SkuEntity> logger, ISkuService iSkuService) : base(logger, iSkuService)
|
||||
{
|
||||
_iSkuService = iSkuService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] SkuEntity eneity, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iSkuService.SelctPageList(eneity, page));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//数据测试
|
||||
[HttpGet]
|
||||
public async Task<Result> Test(OperEnum operEnum)
|
||||
{
|
||||
switch (operEnum)
|
||||
{
|
||||
case OperEnum.Insert:
|
||||
List<SkuEntity> spus = new();
|
||||
var sku1 = new SkuEntity()
|
||||
{
|
||||
Id = 1,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 1,
|
||||
Price = 1000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="1GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "红" } },
|
||||
};
|
||||
var sku2 = new SkuEntity()
|
||||
{
|
||||
Id = 2,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 1,
|
||||
Price = 4000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="2GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "绿" } },
|
||||
};
|
||||
|
||||
|
||||
var sku3 = new SkuEntity()
|
||||
{
|
||||
Id = 3,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 2,
|
||||
Price = 2000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="3GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "红" } },
|
||||
};
|
||||
var sku4 = new SkuEntity()
|
||||
{
|
||||
Id = 4,
|
||||
Stock = 100,
|
||||
IsDeleted = false,
|
||||
SpuId = 2,
|
||||
Price = 1000,
|
||||
SpecsSkuAllInfo = new List<SpecsSkuAllInfoModel> {
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="内存",SpecsName="2GB" } ,
|
||||
new SpecsSkuAllInfoModel { SpecsGroupName="颜色",SpecsName= "蓝" } },
|
||||
};
|
||||
spus.Add(sku1);
|
||||
spus.Add(sku2);
|
||||
spus.Add(sku3);
|
||||
spus.Add(sku4);
|
||||
await _iSkuService._repository.InsertRangeAsync(spus);
|
||||
break;
|
||||
|
||||
case OperEnum.Delete:
|
||||
await _iSkuService._repository.DeleteAsync((u)=>true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface.SHOP;
|
||||
using Yi.Framework.Model.SHOP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class SpecsController : BaseCrudController<SpecsEntity>
|
||||
{
|
||||
private ISpecsService _iSpecsService;
|
||||
public SpecsController(ILogger<SpecsEntity> logger, ISpecsService iSpecsService) : base(logger, iSpecsService)
|
||||
{
|
||||
_iSpecsService = iSpecsService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface.SHOP;
|
||||
using Yi.Framework.Model.SHOP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class SpecsGroupController : BaseCrudController<SpecsGroupEntity>
|
||||
{
|
||||
private ISpecsGroupService _iSpecsGroupService;
|
||||
public SpecsGroupController(ILogger<SpecsGroupEntity> logger, ISpecsGroupService iSpecsGroupService) : base(logger, iSpecsGroupService)
|
||||
{
|
||||
_iSpecsGroupService = iSpecsGroupService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.SHOP;
|
||||
using Yi.Framework.Model.SHOP.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class SpuController : BaseSimpleCrudController<SpuEntity>
|
||||
{
|
||||
private ISpuService _iSpuService;
|
||||
public SpuController(ILogger<SpuEntity> logger, ISpuService iSpuService) : base(logger, iSpuService)
|
||||
{
|
||||
_iSpuService = iSpuService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] SpuEntity eneity, [FromQuery] PageParModel page)
|
||||
{
|
||||
return Result.Success().SetData(await _iSpuService.SelctPageList(eneity, page));
|
||||
}
|
||||
|
||||
[Route("{id}")]
|
||||
[HttpGet]
|
||||
public override async Task<Result> GetById([FromRoute] long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository._DbQueryable.Includes(u=>u.Skus).SingleAsync(u=>u.Id.Equals(id)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//数据测试
|
||||
[HttpGet]
|
||||
public async Task<Result> Test(OperEnum operEnum)
|
||||
{
|
||||
switch (operEnum)
|
||||
{
|
||||
case OperEnum.Insert:
|
||||
List<SpuEntity> spus = new();
|
||||
var spu1 = new SpuEntity()
|
||||
{
|
||||
Id = 1,
|
||||
SpuName = "华为mate40 5G手机",
|
||||
IsDeleted = false,
|
||||
Details = "华为手机就是牛",
|
||||
Price = "1000-2000",
|
||||
SpecsSpuAllInfo = new List<SpecsSpuAllInfoModel> {
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="内存",SpecsNames=new List<string> { "1GB","2GB","3GB"} } ,
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="颜色",SpecsNames=new List<string> { "红","蓝","绿"} } },
|
||||
};
|
||||
var spu2 = new SpuEntity()
|
||||
{
|
||||
Id = 2,
|
||||
SpuName = "小米888 8G手机",
|
||||
IsDeleted = false,
|
||||
Details = "小米手机就是牛",
|
||||
Price = "2000-3000",
|
||||
SpecsSpuAllInfo = new List<SpecsSpuAllInfoModel> {
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="内存",SpecsNames=new List<string> { "1GB","2GB","3GB"} } ,
|
||||
new SpecsSpuAllInfoModel { SpecsGroupName="颜色",SpecsNames=new List<string> { "红","蓝","绿"} } },
|
||||
};
|
||||
spus.Add(spu1);
|
||||
spus.Add(spu2);
|
||||
await _iSpuService._repository.InsertRangeAsync(spus);
|
||||
break;
|
||||
|
||||
case OperEnum.Delete:
|
||||
await _iSpuService._repository.DeleteAsync((u) => true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return Result.Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,423 +0,0 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Abstract;
|
||||
using Yi.Framework.Common.Attribute;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.Core.Cache;
|
||||
using Yi.Framework.Core.Quartz;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Interface.RABC;
|
||||
using Yi.Framework.Job;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Model.RABC.Entitys;
|
||||
using Yi.Framework.Repository;
|
||||
using Yi.Framework.WebCore;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
using Yi.Framework.WebCore.DbExtend;
|
||||
using Yi.Framework.WebCore.SignalRHub;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试控制器
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class TestController : ControllerBase
|
||||
{
|
||||
private IStringLocalizer<LocalLanguage> _local;
|
||||
private IUserService _iUserService;
|
||||
private IRoleService _iRoleService;
|
||||
private QuartzInvoker _quartzInvoker;
|
||||
private IHubContext<MainHub> _hub;
|
||||
private ThumbnailSharpInvoer _thumbnailSharpInvoer;
|
||||
private CacheInvoker _cacheDb;
|
||||
private ILogger<TestController> _logger;
|
||||
ISugarUnitOfWork<UnitOfWork> _unitOfWork;
|
||||
[Autowired]
|
||||
private ICurrentUser _currentUser { get; set; }
|
||||
|
||||
[Autowired]
|
||||
public CacheInvoker CacheInvoker { get; set; }
|
||||
//你可以依赖注入服务层各各接口,也可以注入其他仓储层,怎么爽怎么来!
|
||||
/// <summary>
|
||||
/// 依赖注入,优雅写法
|
||||
/// </summary>
|
||||
/// <param name="hub"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="iRoleService"></param>
|
||||
/// <param name="iUserService"></param>
|
||||
/// <param name="local"></param>
|
||||
/// <param name="quartzInvoker"></param>
|
||||
/// <param name="thumbnailSharpInvoer"></param>
|
||||
/// <param name="cacheInvoker"></param>
|
||||
/// <param name="unitOfWork"></param>
|
||||
public TestController(IHubContext<MainHub> hub,
|
||||
ILogger<TestController> logger,
|
||||
IRoleService iRoleService,
|
||||
IUserService iUserService,
|
||||
IStringLocalizer<LocalLanguage> local,
|
||||
QuartzInvoker quartzInvoker,
|
||||
ThumbnailSharpInvoer thumbnailSharpInvoer,
|
||||
CacheInvoker cacheInvoker,
|
||||
ISugarUnitOfWork<UnitOfWork> unitOfWork
|
||||
) =>
|
||||
|
||||
(_logger, _iUserService, _iRoleService, _quartzInvoker, _hub, _local, _thumbnailSharpInvoer, _cacheDb, _unitOfWork) =
|
||||
|
||||
(logger, iUserService, iRoleService, quartzInvoker, hub, local, thumbnailSharpInvoer, cacheInvoker, unitOfWork);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// swagger跳转
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("/")]
|
||||
public IActionResult Swagger()
|
||||
{
|
||||
return Redirect("/Swagger");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仓储上下文对象测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
// 特点:化繁为简!意框架仓储代理上下文对象,用起来就是爽,但最好按规范来爽!
|
||||
// 规范:控制器严禁使用DB上下文对象,其它怎么爽怎么来!
|
||||
public async Task<Result> DbTest()
|
||||
{
|
||||
//非常好,使用UserService的特有方法
|
||||
await _iUserService.DbTest();
|
||||
|
||||
//非常好,依赖注入使用其他Service的特有方法
|
||||
await _iRoleService.DbTest();
|
||||
|
||||
//很核理,使用仓储的通用方法
|
||||
await _iUserService._repository.GetListAsync();
|
||||
|
||||
//挺不错,依赖注入其他仓储
|
||||
await _iRoleService._repository.GetListAsync();
|
||||
|
||||
//还行,直接切换其他仓储,怎么爽怎么来
|
||||
await _iUserService._repository.ChangeRepository<Repository<RoleEntity>>().GetListAsync();
|
||||
|
||||
//最好不要在控制器直接操作Db对象
|
||||
await _iUserService._repository._Db.Queryable<UserEntity>().ToListAsync();
|
||||
await _iUserService._repository._DbQueryable.ToListAsync();
|
||||
|
||||
return Result.Success().SetData(await _iUserService.DbTest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工作单元测试,使用sqlsugar内置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
|
||||
public async Task<Result> UnitOfWorkTest()
|
||||
{
|
||||
var data = await _iRoleService._repository._DbQueryable.ToListAsync();
|
||||
using (var uow = _unitOfWork.CreateContext())
|
||||
{
|
||||
var res = await _iRoleService._repository.InsertReturnSnowflakeIdAsync(new RoleEntity { RoleName = "测试", RoleCode = "tt" });
|
||||
throw new ApplicationException("测试uow");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行Sql返回
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//简单语句不推荐使用sql!
|
||||
public async Task<Result> SqlTest()
|
||||
{
|
||||
return Result.Success().SetData(await _iUserService._repository.UseSqlAsync<UserEntity>("select * from User"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 国际化测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//根据浏览器语言设置来切换输出
|
||||
public Result LocalTest()
|
||||
{
|
||||
return Result.Success().SetData(_local["succeed"]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 权限测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Permission("user:get:test")]
|
||||
public Result PermissionTest()
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 策略授权测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Authorize(PolicyName.Sid)]
|
||||
public Result AuthTest()
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步事务测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//注册一个用户获取它的信息之后再更新它,但是这个年龄可能会报错
|
||||
//如果一个事务中有任何一个错误,将会把所有执行过的操作进行回滚,确保数据的原子性
|
||||
public async Task<Result> TranTest()
|
||||
{
|
||||
UserEntity user = new() { UserName = $"杰哥{DateTime.Now}", Password = "5201314", Age = 99 };
|
||||
|
||||
var res = await _iUserService._repository.UseTranAsync(async () =>
|
||||
{
|
||||
await _iUserService.Register(user, (o) => user = o);
|
||||
user.Age = 18 / (new Random().Next(0, 2));
|
||||
await _iUserService._repository.UpdateAsync(user);
|
||||
});
|
||||
if (res)
|
||||
{
|
||||
return Result.Success("执行成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Result.Error("发生错误,插入已回滚!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 极爽导航属性
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//Sqlsugar精髓之一!必学!最新版本
|
||||
public async Task<Result> IncludeTest()
|
||||
{
|
||||
return Result.Success().SetData(await _iUserService.GetListInRole());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动一个定时任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//每5秒访问一次百度,可查看控制台
|
||||
public async Task<Result> JobTest()
|
||||
{
|
||||
Dictionary<string, object> data = new Dictionary<string, object>()
|
||||
{
|
||||
{JobConst.method,"get" },
|
||||
{JobConst.url,"https://www.baidu.com" }
|
||||
};
|
||||
await _quartzInvoker.StartAsync("*/5 * * * * ?", "HttpJob", jobName: "test", jobGroup: "my", data: data);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> StopJob()
|
||||
{
|
||||
await _quartzInvoker.StopAsync(new Quartz.JobKey("test", "my"));
|
||||
return Result.Success("http://localhost:19001/hangfire");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// job异常处理
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> ErrorJob()
|
||||
{
|
||||
await _quartzInvoker.StartAsync("*/5 * * * * ?", "ErrorJob");
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 树形结构构建测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result TreeTest()
|
||||
{
|
||||
List<VueRouterModel> vueRouterModels = new()
|
||||
{
|
||||
new VueRouterModel { Id = 1, OrderNum = 1, ParentId = 0, Name = "001" },
|
||||
new VueRouterModel { Id = 2, OrderNum = 1, ParentId = 1, Name = "001001" },
|
||||
new VueRouterModel { Id = 3, OrderNum = 1, ParentId = 1, Name = "001002" }
|
||||
};
|
||||
var treeData = Common.Helper.TreeHelper.SetTree(vueRouterModels);
|
||||
return Result.Success().SetData(treeData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 授权测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
public Result AuthorizeTest()
|
||||
{
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清空数据库
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> ClearDb()
|
||||
{
|
||||
var rep = _iUserService._repository;
|
||||
return Result.Success().SetStatus(await rep.UseTranAsync(async () =>
|
||||
{
|
||||
await rep.DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<MenuEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<RoleEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<RoleMenuEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<UserRoleEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<DictionaryEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<DictionaryInfoEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<ConfigEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<PostEntity>>().DeleteAsync(u => true);
|
||||
await rep.ChangeRepository<Repository<DeptEntity>>().DeleteAsync(u => true);
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 种子数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result SeedDb()
|
||||
{
|
||||
var rep = _iUserService._repository;
|
||||
return Result.Success().SetStatus(DbSeedExtend.DataInvoer(rep._Db));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 操作日志测试
|
||||
/// </summary>
|
||||
/// <param name="par"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Log("测试模块", Common.Enum.OperEnum.Insert)]
|
||||
public Result LogTest(List<string> par)
|
||||
{
|
||||
return Result.Success().SetData(par);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Signalr实时推送测试
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> SignalrTest(int msg)
|
||||
{
|
||||
await _hub.Clients.All.SendAsync("onlineNum", msg);
|
||||
return Result.Success("向所有连接客户端发送一个消息");
|
||||
}
|
||||
//job任务与公告管理
|
||||
|
||||
/// <summary>
|
||||
/// 缩略图测试,需要生成前及生成后的路径
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result ThumbnailTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = @"D:\App\test11.jpg";
|
||||
var result = _thumbnailSharpInvoer.CreateThumbnailBytes(thumbnailSize: 300,
|
||||
imageStream: new FileStream(path, FileMode.Open, FileAccess.ReadWrite),
|
||||
imageFormat: Format.Jpeg);
|
||||
System.IO.File.WriteAllBytes(@"D:\App\test222.jpg", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Error(ex.Message);
|
||||
}
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓存测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result CacheDBTest()
|
||||
{
|
||||
var key = "Yi:Test";
|
||||
var item = "你好世界";
|
||||
_cacheDb.Set(key, item);
|
||||
|
||||
var data = _cacheDb.Get<string>(key);
|
||||
return Result.Success().SetData(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义日志
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result CustomLogTest()
|
||||
{
|
||||
_logger.LogWarning("输出一条日志");
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 属性注入测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public Result PropertyTest()
|
||||
{
|
||||
return Result.Success().SetStatus(CacheInvoker is not null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户信息测试
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Authorize]
|
||||
public Result CurrentUserTest()
|
||||
{
|
||||
var per = _currentUser.Permission;
|
||||
return Result.Success().SetData(per);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
global using System;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Yi.Framework.WebCore.BuilderExtend;
|
||||
using Yi.Framework.Core;
|
||||
using Yi.Framework.WebCore.MiddlewareExtend;
|
||||
using Autofac;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Language;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.WebCore.AttributeExtend;
|
||||
using Yi.Framework.WebCore.SignalRHub;
|
||||
using Hei.Captcha;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Yi.Framework.WebCore.DbExtend;
|
||||
using IPTools.Core;
|
||||
using Yi.Framework.WebCore.LogExtend;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Yi.Framework.WebCore.AutoFacExtend;
|
||||
using AspectCore.Extensions.DependencyInjection;
|
||||
using AspectCore.Extensions.Hosting;
|
||||
using Yi.Framework.WebCore.AspNetCoreExtensions;
|
||||
using Yi.Framework.WebCore.CommonExtend;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddCommandLine(args);
|
||||
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
|
||||
builder.Host.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
|
||||
{
|
||||
configurationBuilder.AddCommandLine(args);
|
||||
configurationBuilder.AddJsonFileService();
|
||||
#region
|
||||
//Apollo<6C><6F><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
configurationBuilder.AddApolloService("Yi");
|
||||
});
|
||||
|
||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
|
||||
{
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>Module<6C><65><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
containerBuilder.RegisterModule<CustomAutofacModule>();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ģ<EFBFBD><C4A3>
|
||||
#endregion
|
||||
containerBuilder.RegisterModule<PropertiesAutowiredModule>();
|
||||
#region
|
||||
//ʹ<><CAB9>AppService<63><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵĽ<C5B5><C4BD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>,<2C>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ø<EFBFBD><C3B8>ַ<EFBFBD>ʽ<EFBFBD>Զ<EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
containerBuilder.AddAutoIocService("Yi.Framework.Repository", "Yi.Framework.Service");
|
||||
});
|
||||
|
||||
////<2F><><EFBFBD><EFBFBD>ע<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mvcģ<63><C4A3>ת<EFBFBD>Ӹ<EFBFBD>ioc
|
||||
builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
|
||||
|
||||
builder.Host.ConfigureLogging(loggingBuilder =>
|
||||
{
|
||||
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
|
||||
loggingBuilder.AddLog4Net("./Config/Log4net.config");
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>־
|
||||
//loggingBuilder.AddCustomLogger();
|
||||
});
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//builder.Host.ConfigureWebHostDefaults(webBuilder =>
|
||||
// {
|
||||
// //webBuilder.UseStartup<Startup>();
|
||||
// });
|
||||
#endregion
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
#region
|
||||
//Ioc<6F><63><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddIocService(builder.Configuration);
|
||||
#region
|
||||
//Sqlsugar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>,<2C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><DEB9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBB><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddSqlsugarServer(DbFiterExtend.Data);
|
||||
#region
|
||||
//Quartz<74><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddQuartzService();
|
||||
#region
|
||||
//AutoMapperע<72><D7A2>
|
||||
#endregion
|
||||
builder.Services.AddAutoMapperService();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddControllers(optios =>
|
||||
{
|
||||
//ע<><D7A2>ȫ<EFBFBD><C8AB>
|
||||
optios.Filters.Add<GlobalLogAttribute>();
|
||||
}).AddJsonFileService();
|
||||
#region
|
||||
//Ȩ<><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
//Ȩ<><C8A8>
|
||||
builder.Services.AddSingleton<PermissionAttribute>();
|
||||
//<2F><>־
|
||||
builder.Services.AddSingleton<GlobalLogAttribute>();
|
||||
#region
|
||||
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddSwaggerService<Program>();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddCorsService();
|
||||
#region
|
||||
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddJwtService();
|
||||
#region
|
||||
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddAuthorizationService();
|
||||
#region
|
||||
//Redis<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddCacheService();
|
||||
#region
|
||||
//RabbitMQ<4D><51><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddRabbitMQService();
|
||||
#region
|
||||
//ElasticSeach<63><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddElasticSeachService();
|
||||
#region
|
||||
//<2F><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddSMSService();
|
||||
#region
|
||||
//CAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddCAPService();
|
||||
#region
|
||||
//<2F><><EFBFBD>ʻ<EFBFBD><CABB><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddLocalizerService();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>signalR
|
||||
#endregion
|
||||
builder.Services.AddSignalR();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>
|
||||
#endregion
|
||||
builder.Services.AddHeiCaptcha();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>Http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>System.Drawing<6E><67>linu<6E><75>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>
|
||||
#endregion
|
||||
builder.Services.AddSingleton<ThumbnailSharpInvoer>();
|
||||
|
||||
#region
|
||||
//<2F><><EFBFBD>ӵ<EFBFBD>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣʹ<CFA2><CAB9>
|
||||
#endregion
|
||||
builder.Services.AddCurrentUserServer();
|
||||
|
||||
#region
|
||||
//ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC>ֵ
|
||||
#endregion
|
||||
GobalModel.SqlLogEnable = Appsettings.appBool("SqlLog_Enable");
|
||||
GobalModel.LoginCodeEnable = Appsettings.appBool("LoginCode_Enable");
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
var app = builder.Build();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
ServiceLocator.Instance = app.Services;
|
||||
//if (app.Environment.IsDevelopment())
|
||||
{
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwaggerService();
|
||||
}
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseErrorHandlingService();
|
||||
|
||||
#region
|
||||
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseStaticFiles();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9>ʻ<EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseLocalizerService();
|
||||
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>body
|
||||
#endregion
|
||||
app.UseHttpBodyService();
|
||||
#region
|
||||
//HttpsRedirectionע<6E><D7A2>
|
||||
#endregion
|
||||
app.UseHttpsRedirection();
|
||||
#region
|
||||
//·<><C2B7>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseRouting();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseCorsService();
|
||||
#region
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseHealthCheckService();
|
||||
#region
|
||||
//<2F><>Ȩע<C8A8><D7A2>
|
||||
#endregion
|
||||
app.UseAuthentication();
|
||||
#region
|
||||
//<2F><>Ȩע<C8A8><D7A2>
|
||||
#endregion
|
||||
app.UseAuthorization();
|
||||
#region
|
||||
//<2F><><EFBFBD>ӵ<EFBFBD>ǰ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>Ϣʹ<CFA2><CAB9>
|
||||
#endregion
|
||||
app.UseCurrentUserServer();
|
||||
#region
|
||||
//Consul<75><6C><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseConsulService();
|
||||
|
||||
#region
|
||||
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseDbSeedInitService();
|
||||
#region
|
||||
//redis<69><73><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
||||
#endregion
|
||||
app.UseRedisSeedInitService();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
#region
|
||||
//SignalR<6C><52><EFBFBD><EFBFBD>
|
||||
#endregion
|
||||
endpoints.MapHub<MainHub>("/api/hub/main");
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
//<><D7BC><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6>⻧
|
||||
app.Run();
|
||||
@@ -1,52 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UserSecretsId>f5ce4739-9524-4330-9aea-cfcdb41501de</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>./Config/SwaggerDoc.xml</DocumentationFile>
|
||||
<NoWarn>1701;1702;CS1591;CS8618</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="wwwrooot\**" />
|
||||
<Content Remove="wwwrooot\**" />
|
||||
<EmbeddedResource Remove="wwwrooot\**" />
|
||||
<None Remove="wwwrooot\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspectCore.Extensions.Hosting" Version="2.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="wwwroot\Image\0.jpg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Config\SwaggerDoc.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ip2region.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="key.pem">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="public.pem">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,138 +0,0 @@
|
||||
{
|
||||
//程序启动地址,*代表全部网口
|
||||
"StartUrl": "http://*:19001",
|
||||
|
||||
//默认日志打印过滤
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
|
||||
//运行全部主机
|
||||
"AllowedHosts": "*",
|
||||
|
||||
//【全局配置开启】
|
||||
//Sql语句日志是否打印
|
||||
"SqlLog_Enable": false,
|
||||
//登录二维码是否打印
|
||||
"LoginCode_Enable": false,
|
||||
|
||||
//【数据库配置】
|
||||
//多数据库主从复制是否开启
|
||||
"MutiDB_Enabled": false,
|
||||
//数据库CodeFirst是否开启
|
||||
"DbCodeFirst_Enabled": true,
|
||||
//数据库种子数据是否开启
|
||||
"DbSeed_Enabled": true,
|
||||
//数据库列表
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
//数据库类型选择
|
||||
"DbSelect": "Sqlite",
|
||||
//数据库连接地址,支持读写分离
|
||||
"DbConn": {
|
||||
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
|
||||
"ReadUrl": [
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
//【缓存配置】
|
||||
//缓存列表
|
||||
"CacheList": [ "Redis", "MemoryCache" ],
|
||||
//选择缓存
|
||||
"CacheSelect": "MemoryCache",
|
||||
//缓存种子数据是否开启
|
||||
"CacheSeed_Enabled": false,
|
||||
|
||||
|
||||
//【中间件开启】
|
||||
//Consul是否开启
|
||||
"Consul_Enabled": false,
|
||||
//健康检查是否开启
|
||||
"HealthCheck_Enabled": false,
|
||||
//跨域开放是否开启
|
||||
"Cors_Enabled": true,
|
||||
//Apollo是否开启
|
||||
"Apollo_Enabled": false,
|
||||
//RabbitMQ是否开启
|
||||
"RabbitMQ_Enabled": false,
|
||||
//Kafka是否开启
|
||||
"Kafka_Enabled": false,
|
||||
//ElasticSeach是否开启
|
||||
"ElasticSeach_Enabled": false,
|
||||
//短信发送是否开启
|
||||
"SMS_Enabled": false,
|
||||
//分布式CAP是否开启
|
||||
"CAP_Enabled": false,
|
||||
//分布式CAP面板是否开启
|
||||
"CAPDashboard_Enabled": false,
|
||||
|
||||
|
||||
//【中间件配置】
|
||||
//jwt授权内容,公钥私钥转移到目录下的pem文件
|
||||
"JwtAuthorize": {
|
||||
"Issuer": "cc",
|
||||
"Audience": "cc",
|
||||
"PolicyName": "permission",
|
||||
"DefaultScheme": "Bearer",
|
||||
"IsHttps": false,
|
||||
"Expiration": 300,
|
||||
"ReExpiration": 3000
|
||||
},
|
||||
//Redis地址配置
|
||||
"RedisConnOptions": {
|
||||
"Host": "[]",
|
||||
"Prot": 6379,
|
||||
"DB": 1,
|
||||
"Password": "[]"
|
||||
},
|
||||
//RabbitMq地址配置
|
||||
"RabbitConn": {
|
||||
"HostName": "[]",
|
||||
"UserName": "[]",
|
||||
"Password": "[]",
|
||||
"Port": 5672
|
||||
},
|
||||
//ElasticSeach地址配置
|
||||
"ElasticSeachConn": {
|
||||
"Url": "[]",
|
||||
"IndexName": "[]",
|
||||
"UserName": "[]",
|
||||
"PassWord": "[]."
|
||||
},
|
||||
//Kafka地址配置
|
||||
"KafkaOptions": {
|
||||
"BrokerList": "[]:9092",
|
||||
"TopicName": "kafkalog"
|
||||
},
|
||||
//Consul地址配置
|
||||
"ConsulClientOption": {
|
||||
"IP": "[]",
|
||||
"Port": "8500",
|
||||
"Datacenter": "dc1"
|
||||
},
|
||||
//Consul注册本机配置
|
||||
"ConsulRegisterOption": {
|
||||
"IP": "[]",
|
||||
"Port": "[]",
|
||||
"GroupName": "ApiMicroservice",
|
||||
"HealthCheckUrl": "/Health",
|
||||
"Interval": 10,
|
||||
"Timeout": 5,
|
||||
"DeregisterCriticalServiceAfter": 60,
|
||||
"Tag": "13"
|
||||
},
|
||||
//阿里云短信配置
|
||||
"SMS": {
|
||||
"ID": "[]",
|
||||
"Secret": "[]",
|
||||
"Sign": "[]",
|
||||
"Template": "[]"
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
{
|
||||
//程序启动地址,*代表全部网口
|
||||
"StartUrl": "http://*:19001",
|
||||
|
||||
//默认日志打印过滤
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
|
||||
//运行全部主机
|
||||
"AllowedHosts": "*",
|
||||
|
||||
//【全局配置开启】
|
||||
//Sql语句日志是否打印
|
||||
"SqlLog_Enable": false,
|
||||
//登录二维码是否打印
|
||||
"LoginCode_Enable": false,
|
||||
|
||||
//【数据库配置】
|
||||
//多数据库主从复制是否开启
|
||||
"MutiDB_Enabled": false,
|
||||
//数据库CodeFirst是否开启
|
||||
"DbCodeFirst_Enabled": true,
|
||||
//数据库种子数据是否开启
|
||||
"DbSeed_Enabled": true,
|
||||
//数据库列表
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
//数据库类型选择
|
||||
"DbSelect": "Sqlite",
|
||||
//数据库连接地址,支持读写分离
|
||||
"DbConn": {
|
||||
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
|
||||
"ReadUrl": [
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]"
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
//【缓存配置】
|
||||
//缓存列表
|
||||
"CacheList": [ "Redis", "MemoryCache" ],
|
||||
//选择缓存
|
||||
"CacheSelect": "MemoryCache",
|
||||
//缓存种子数据是否开启
|
||||
"CacheSeed_Enabled": false,
|
||||
|
||||
|
||||
//【中间件开启】
|
||||
//Consul是否开启
|
||||
"Consul_Enabled": false,
|
||||
//健康检查是否开启
|
||||
"HealthCheck_Enabled": false,
|
||||
//跨域开放是否开启
|
||||
"Cors_Enabled": true,
|
||||
//Apollo是否开启
|
||||
"Apollo_Enabled": false,
|
||||
//RabbitMQ是否开启
|
||||
"RabbitMQ_Enabled": false,
|
||||
//Kafka是否开启
|
||||
"Kafka_Enabled": false,
|
||||
//ElasticSeach是否开启
|
||||
"ElasticSeach_Enabled": false,
|
||||
//短信发送是否开启
|
||||
"SMS_Enabled": false,
|
||||
//分布式CAP是否开启
|
||||
"CAP_Enabled": false,
|
||||
//分布式CAP面板是否开启
|
||||
"CAPDashboard_Enabled": false,
|
||||
|
||||
|
||||
//【中间件配置】
|
||||
//jwt授权内容,公钥私钥转移到目录下的pem文件
|
||||
"JwtAuthorize": {
|
||||
"Issuer": "cc",
|
||||
"Audience": "cc",
|
||||
"PolicyName": "permission",
|
||||
"DefaultScheme": "Bearer",
|
||||
"IsHttps": false,
|
||||
"Expiration": 300,
|
||||
"ReExpiration": 3000
|
||||
},
|
||||
//Redis地址配置
|
||||
"RedisConnOptions": {
|
||||
"Host": "[]",
|
||||
"Prot": 6379,
|
||||
"DB": 1,
|
||||
"Password": "[]"
|
||||
},
|
||||
//RabbitMq地址配置
|
||||
"RabbitConn": {
|
||||
"HostName": "[]",
|
||||
"UserName": "[]",
|
||||
"Password": "[]",
|
||||
"Port": 5672
|
||||
},
|
||||
//ElasticSeach地址配置
|
||||
"ElasticSeachConn": {
|
||||
"Url": "[]",
|
||||
"IndexName": "[]",
|
||||
"UserName": "[]",
|
||||
"PassWord": "[]."
|
||||
},
|
||||
//Kafka地址配置
|
||||
"KafkaOptions": {
|
||||
"BrokerList": "[]:9092",
|
||||
"TopicName": "kafkalog"
|
||||
},
|
||||
//Consul地址配置
|
||||
"ConsulClientOption": {
|
||||
"IP": "[]",
|
||||
"Port": "8500",
|
||||
"Datacenter": "dc1"
|
||||
},
|
||||
//Consul注册本机配置
|
||||
"ConsulRegisterOption": {
|
||||
"IP": "[]",
|
||||
"Port": "[]",
|
||||
"GroupName": "ApiMicroservice",
|
||||
"HealthCheckUrl": "/Health",
|
||||
"Interval": 10,
|
||||
"Timeout": 5,
|
||||
"DeregisterCriticalServiceAfter": 60,
|
||||
"Tag": "13"
|
||||
},
|
||||
//阿里云短信配置
|
||||
"SMS": {
|
||||
"ID": "[]",
|
||||
"Secret": "[]",
|
||||
"Sign": "[]",
|
||||
"Template": "[]"
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
{
|
||||
//程序启动地址,*代表全部网口
|
||||
"StartUrl": "http://*:19001",
|
||||
|
||||
//默认日志打印过滤
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
|
||||
//运行全部主机
|
||||
"AllowedHosts": "*",
|
||||
|
||||
//【全局配置开启】
|
||||
//Sql语句日志是否打印
|
||||
"SqlLog_Enable": false,
|
||||
//登录二维码是否打印
|
||||
"LoginCode_Enable": false,
|
||||
|
||||
//【数据库配置】
|
||||
//多数据库主从复制是否开启
|
||||
"MutiDB_Enabled": false,
|
||||
//数据库CodeFirst是否开启
|
||||
"DbCodeFirst_Enabled": true,
|
||||
//数据库种子数据是否开启
|
||||
"DbSeed_Enabled": true,
|
||||
//数据库列表
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
//数据库类型选择
|
||||
"DbSelect": "Sqlite",
|
||||
//数据库连接地址,支持读写分离
|
||||
"DbConn": {
|
||||
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
|
||||
"ReadUrl": [
|
||||
"DataSource=[xxxx]",//sqlite
|
||||
"server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]", //mysql
|
||||
"Data Source=[xxxx];Initial Catalog=[xxxx];User ID=[xxxx];password=[xxxx]" //sqlserver
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
//【缓存配置】
|
||||
//缓存列表
|
||||
"CacheList": [ "Redis", "MemoryCache" ],
|
||||
//选择缓存
|
||||
"CacheSelect": "MemoryCache",
|
||||
//缓存种子数据是否开启
|
||||
"CacheSeed_Enabled": false,
|
||||
|
||||
|
||||
//【中间件开启】
|
||||
//Consul是否开启
|
||||
"Consul_Enabled": false,
|
||||
//健康检查是否开启
|
||||
"HealthCheck_Enabled": false,
|
||||
//跨域开放是否开启
|
||||
"Cors_Enabled": true,
|
||||
//Apollo是否开启
|
||||
"Apollo_Enabled": false,
|
||||
//RabbitMQ是否开启
|
||||
"RabbitMQ_Enabled": false,
|
||||
//Kafka是否开启
|
||||
"Kafka_Enabled": false,
|
||||
//ElasticSeach是否开启
|
||||
"ElasticSeach_Enabled": false,
|
||||
//短信发送是否开启
|
||||
"SMS_Enabled": false,
|
||||
//分布式CAP是否开启
|
||||
"CAP_Enabled": false,
|
||||
//分布式CAP面板是否开启
|
||||
"CAPDashboard_Enabled": false,
|
||||
|
||||
|
||||
//【中间件配置】
|
||||
//jwt授权内容,公钥私钥转移到目录下的pem文件
|
||||
"JwtAuthorize": {
|
||||
"Issuer": "cc",
|
||||
"Audience": "cc",
|
||||
"PolicyName": "permission",
|
||||
"DefaultScheme": "Bearer",
|
||||
"IsHttps": false,
|
||||
"Expiration": 300,
|
||||
"ReExpiration": 3000
|
||||
},
|
||||
//Redis地址配置
|
||||
"RedisConnOptions": {
|
||||
"Host": "[]",
|
||||
"Prot": 6379,
|
||||
"DB": 1,
|
||||
"Password": "[]"
|
||||
},
|
||||
//RabbitMq地址配置
|
||||
"RabbitConn": {
|
||||
"HostName": "[]",
|
||||
"UserName": "[]",
|
||||
"Password": "[]",
|
||||
"Port": 5672
|
||||
},
|
||||
//ElasticSeach地址配置
|
||||
"ElasticSeachConn": {
|
||||
"Url": "[]",
|
||||
"IndexName": "[]",
|
||||
"UserName": "[]",
|
||||
"PassWord": "[]."
|
||||
},
|
||||
//Kafka地址配置
|
||||
"KafkaOptions": {
|
||||
"BrokerList": "[]:9092",
|
||||
"TopicName": "kafkalog"
|
||||
},
|
||||
//Consul地址配置
|
||||
"ConsulClientOption": {
|
||||
"IP": "[]",
|
||||
"Port": "8500",
|
||||
"Datacenter": "dc1"
|
||||
},
|
||||
//Consul注册本机配置
|
||||
"ConsulRegisterOption": {
|
||||
"IP": "[]",
|
||||
"Port": "[]",
|
||||
"GroupName": "ApiMicroservice",
|
||||
"HealthCheckUrl": "/Health",
|
||||
"Interval": 10,
|
||||
"Timeout": 5,
|
||||
"DeregisterCriticalServiceAfter": 60,
|
||||
"Tag": "13"
|
||||
},
|
||||
//阿里云短信配置
|
||||
"SMS": {
|
||||
"ID": "[]",
|
||||
"Secret": "[]",
|
||||
"Sign": "[]",
|
||||
"Template": "[]"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,28 +0,0 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC7VJTUt9Us8cKj
|
||||
MzEfYyjiWA4R4/M2bS1GB4t7NXp98C3SC6dVMvDuictGeurT8jNbvJZHtCSuYEvu
|
||||
NMoSfm76oqFvAp8Gy0iz5sxjZmSnXyCdPEovGhLa0VzMaQ8s+CLOyS56YyCFGeJZ
|
||||
qgtzJ6GR3eqoYSW9b9UMvkBpZODSctWSNGj3P7jRFDO5VoTwCQAWbFnOjDfH5Ulg
|
||||
p2PKSQnSJP3AJLQNFNe7br1XbrhV//eO+t51mIpGSDCUv3E0DDFcWDTH9cXDTTlR
|
||||
ZVEiR2BwpZOOkE/Z0/BVnhZYL71oZV34bKfWjQIt6V/isSMahdsAASACp4ZTGtwi
|
||||
VuNd9tybAgMBAAECggEBAKTmjaS6tkK8BlPXClTQ2vpz/N6uxDeS35mXpqasqskV
|
||||
laAidgg/sWqpjXDbXr93otIMLlWsM+X0CqMDgSXKejLS2jx4GDjI1ZTXg++0AMJ8
|
||||
sJ74pWzVDOfmCEQ/7wXs3+cbnXhKriO8Z036q92Qc1+N87SI38nkGa0ABH9CN83H
|
||||
mQqt4fB7UdHzuIRe/me2PGhIq5ZBzj6h3BpoPGzEP+x3l9YmK8t/1cN0pqI+dQwY
|
||||
dgfGjackLu/2qH80MCF7IyQaseZUOJyKrCLtSD/Iixv/hzDEUPfOCjFDgTpzf3cw
|
||||
ta8+oE4wHCo1iI1/4TlPkwmXx4qSXtmw4aQPz7IDQvECgYEA8KNThCO2gsC2I9PQ
|
||||
DM/8Cw0O983WCDY+oi+7JPiNAJwv5DYBqEZB1QYdj06YD16XlC/HAZMsMku1na2T
|
||||
N0driwenQQWzoev3g2S7gRDoS/FCJSI3jJ+kjgtaA7Qmzlgk1TxODN+G1H91HW7t
|
||||
0l7VnL27IWyYo2qRRK3jzxqUiPUCgYEAx0oQs2reBQGMVZnApD1jeq7n4MvNLcPv
|
||||
t8b/eU9iUv6Y4Mj0Suo/AU8lYZXm8ubbqAlwz2VSVunD2tOplHyMUrtCtObAfVDU
|
||||
AhCndKaA9gApgfb3xw1IKbuQ1u4IF1FJl3VtumfQn//LiH1B3rXhcdyo3/vIttEk
|
||||
48RakUKClU8CgYEAzV7W3COOlDDcQd935DdtKBFRAPRPAlspQUnzMi5eSHMD/ISL
|
||||
DY5IiQHbIH83D4bvXq0X7qQoSBSNP7Dvv3HYuqMhf0DaegrlBuJllFVVq9qPVRnK
|
||||
xt1Il2HgxOBvbhOT+9in1BzA+YJ99UzC85O0Qz06A+CmtHEy4aZ2kj5hHjECgYEA
|
||||
mNS4+A8Fkss8Js1RieK2LniBxMgmYml3pfVLKGnzmng7H2+cwPLhPIzIuwytXywh
|
||||
2bzbsYEfYx3EoEVgMEpPhoarQnYPukrJO4gwE2o5Te6T5mJSZGlQJQj9q4ZB2Dfz
|
||||
et6INsK0oG8XVGXSpQvQh3RUYekCZQkBBFcpqWpbIEsCgYAnM3DQf3FJoSnXaMhr
|
||||
VBIovic5l0xFkEHskAjFTevO86Fsz1C2aSeRKSqGFoOQ0tmJzBEs1R6KqnHInicD
|
||||
TQrKhArgLXX4v3CddjfTRJkFWDbE/CkvKZNOrcf1nhaGCPspRJj2KUkj1Fhl9Cnc
|
||||
dn/RsYEONbwQSjIfMPkvxF+8HQ==
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -1,9 +0,0 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1SU1LfVLPHCozMxH2Mo
|
||||
4lgOEePzNm0tRgeLezV6ffAt0gunVTLw7onLRnrq0/IzW7yWR7QkrmBL7jTKEn5u
|
||||
+qKhbwKfBstIs+bMY2Zkp18gnTxKLxoS2tFczGkPLPgizskuemMghRniWaoLcyeh
|
||||
kd3qqGElvW/VDL5AaWTg0nLVkjRo9z+40RQzuVaE8AkAFmxZzow3x+VJYKdjykkJ
|
||||
0iT9wCS0DRTXu269V264Vf/3jvredZiKRkgwlL9xNAwxXFg0x/XFw005UWVRIkdg
|
||||
cKWTjpBP2dPwVZ4WWC+9aGVd+Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbc
|
||||
mwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 119 B |
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
Binary file not shown.
@@ -1,26 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.AuthenticationCenter.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.AuthenticationCenter
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.AuthenticationCenter
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddControllers();
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Yi.Framework.AuthenticationCenter", Version = "v1" });
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Yi.Framework.AuthenticationCenter v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Abstract
|
||||
{
|
||||
public interface ICurrentUser
|
||||
{
|
||||
public bool IsAuthenticated { get; set; }
|
||||
public long Id { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
|
||||
public Guid? TenantId { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
public bool EmailVerified { get; set; }
|
||||
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
public bool PhoneNumberVerified { get; set; }
|
||||
|
||||
public string[]? Roles { get; set; }
|
||||
|
||||
public string[]? Permission { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Common.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 参考地址:https://www.cnblogs.com/kelelipeng/p/10643556.html
|
||||
/// 1、[AppService]:自动去找接口,如果存在就是接口,如果不存在就是本身
|
||||
/// 2、[AppService(ServiceType = typeof(注册抽象或者接口或者本身))],手动去注册,放type即可
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||
public class AppServiceAttribute : System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务声明周期
|
||||
/// 不给默认值的话注册的是作用域
|
||||
/// </summary>
|
||||
public LifeTime ServiceLifetime { get; set; } = LifeTime.Scoped;
|
||||
/// <summary>
|
||||
/// 指定服务类型
|
||||
/// </summary>
|
||||
public Type? ServiceType { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public enum LifeTime
|
||||
{
|
||||
Transient, Scoped, Singleton
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Attribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class AutowiredAttribute : System.Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.Enum;
|
||||
|
||||
namespace Yi.Framework.Common.Attribute
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : System.Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作类型
|
||||
/// </summary>
|
||||
public OperEnum OperType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志标题(模块)
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否保存请求数据
|
||||
/// </summary>
|
||||
public bool IsSaveRequestData { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 是否保存返回数据
|
||||
/// </summary>
|
||||
public bool IsSaveResponseData { get; set; } = true;
|
||||
|
||||
public LogAttribute(string title, OperEnum operationType)
|
||||
{
|
||||
this.Title = title;
|
||||
this.OperType = operationType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,434 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Common.Base
|
||||
{
|
||||
#region 无值定义
|
||||
|
||||
/// <summary>
|
||||
/// 无值定义
|
||||
/// </summary>
|
||||
public class NullValue
|
||||
{
|
||||
/// <summary>
|
||||
/// 唯一识别型的默认无值
|
||||
/// </summary>
|
||||
public static readonly Guid Guid = Guid.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 日期时间的默认无值
|
||||
/// </summary>
|
||||
/// <remarks>解决C#DateTime最小值是SQL 2005不允许的范围内</remarks>
|
||||
public static readonly DateTime DateTime = DateTime.Parse("1753-1-1 12:00:01");
|
||||
|
||||
/// <summary>
|
||||
/// JavaScript日期时间的默认无值
|
||||
/// </summary>
|
||||
/// <remarks></remarks>
|
||||
public static readonly DateTime JavaScriptDateTime = DateTime.Parse("1970-1-1 00:00:00");
|
||||
|
||||
#region 数字类型
|
||||
|
||||
/// <summary>
|
||||
/// 短整数的默认无值
|
||||
/// </summary>
|
||||
public const short ShortInterger = -1;//short.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// 整数的默认无值
|
||||
/// </summary>
|
||||
public const int Interger = -1;//int.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// 长整数的默认无值
|
||||
/// </summary>
|
||||
public const long LongInterger = -1;//long.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Decimal数的默认无值
|
||||
/// </summary>
|
||||
public const decimal Decimal = -1;//decimal.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Float数的默认无值
|
||||
/// </summary>
|
||||
public const float Float = -1;//float.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Double数的默认无值
|
||||
/// </summary>
|
||||
public const double Double = -1;//double.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Byte数的默认无值
|
||||
/// </summary>
|
||||
public const byte Byte = byte.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// SByte数的默认无值
|
||||
/// </summary>
|
||||
public const sbyte SByte = sbyte.MinValue;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 字串的默认无值
|
||||
/// </summary>
|
||||
public static readonly string String = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 一般对象的判断
|
||||
/// </summary>
|
||||
public const object Object = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 无值的扩展方法
|
||||
|
||||
/// <summary>
|
||||
/// 无值的扩展方法
|
||||
/// </summary>
|
||||
public static class NullValueExtensions
|
||||
{
|
||||
#region 一般类型
|
||||
|
||||
|
||||
|
||||
public static Guid TryToGuid(this string guid)
|
||||
{
|
||||
if (Guid.TryParse(guid, out var guid1))
|
||||
{
|
||||
return guid1;
|
||||
}
|
||||
return Guid.Empty;
|
||||
|
||||
}
|
||||
|
||||
public static string TryStringNull(this string value)
|
||||
{
|
||||
return value == null ? "" : value;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this object value)
|
||||
{
|
||||
if (value == null || value == NullValue.Object)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Object类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this object value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
public static bool IsGuidNotNull(this Guid? value)
|
||||
{
|
||||
return !value.IsGuidNull();
|
||||
}
|
||||
public static bool IsGuidNull(this Guid? value)
|
||||
{
|
||||
if (value == null || value == Guid.Empty)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/// <summary>
|
||||
/// String类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value) || string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// String类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this string value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Guid类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this Guid value)
|
||||
{
|
||||
if (value == NullValue.Guid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Guid类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this Guid value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
#region 数字类型
|
||||
|
||||
/// <summary>
|
||||
/// ShortInterger类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this short value)
|
||||
{
|
||||
if (value == NullValue.ShortInterger)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ShortInterger类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this short value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interger类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this int value)
|
||||
{
|
||||
if (value == NullValue.Interger)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interger类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this int value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LongInterger类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this long value)
|
||||
{
|
||||
if (value == NullValue.LongInterger)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LongInterger类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this long value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decimal类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this decimal value)
|
||||
{
|
||||
if (value == NullValue.Decimal)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decimal类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this decimal value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Float类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this float value)
|
||||
{
|
||||
if (value == NullValue.Float)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Float类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this float value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Double类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this double value)
|
||||
{
|
||||
if (value == NullValue.Double)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Double类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this double value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Byte类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this byte value)
|
||||
{
|
||||
if (value == NullValue.Byte)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Byte类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this byte value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SByte类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this sbyte value)
|
||||
{
|
||||
if (value == NullValue.SByte)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SByte类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this sbyte value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// DateTime类型无值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否为空(true--真,false--假)</returns>
|
||||
public static bool IsNull(this DateTime value)
|
||||
{
|
||||
if (value == DateTime.MinValue || value <= NullValue.DateTime || value == NullValue.JavaScriptDateTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DateTime类型有值判断
|
||||
/// </summary>
|
||||
/// <param name="value">待判断对象</param>
|
||||
/// <returns>是否不为空(true--真,false--假)</returns>
|
||||
public static bool IsNotNull(this DateTime value)
|
||||
{
|
||||
return !value.IsNull();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class DbConst
|
||||
{
|
||||
public const string Mysql = "Mysql";
|
||||
public const string Sqlite = "Sqlite";
|
||||
public const string Sqlserver = "Sqlserver";
|
||||
public const string Oracle = "Oracle";
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class JobConst
|
||||
{
|
||||
|
||||
public const string url = nameof(url);
|
||||
|
||||
public const string method = nameof(method);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class JwtConst
|
||||
{
|
||||
public const string SecurityKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB";
|
||||
public const string Domain = "https://localhost:44329";
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class PathConst
|
||||
{
|
||||
public const string wwwroot = "wwwroot";
|
||||
public const string DataTemplate = "_DataTemplate";
|
||||
public const string DataExport = "_DataExport";
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class RabbitConst
|
||||
{
|
||||
private const string prefix = "Yi.Framework.";
|
||||
public const string SMS_Exchange = prefix+"SMS.Exchange";
|
||||
public const string SMS_Queue_Send = prefix+ "SMS.Queue.Send";
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class RedisConst
|
||||
{
|
||||
/// <summary>
|
||||
/// 前缀
|
||||
/// </summary>
|
||||
public const string key = "YiFramework:data";
|
||||
|
||||
public const string keyCode = "YiFramework:code";
|
||||
|
||||
public const string userMenusApi = "YiFramework:userMenusApi";
|
||||
///// <summary>
|
||||
///// 初始化角色名
|
||||
///// </summary>
|
||||
//public const string InitRole_key = nameof(InitRole_key);
|
||||
|
||||
///// <summary>
|
||||
///// 标题名
|
||||
///// </summary>
|
||||
//public const string Title_key = nameof(Title_key);
|
||||
|
||||
///// <summary>
|
||||
///// 图片列表名
|
||||
///// </summary>
|
||||
//public const string ImageList_key = nameof(ImageList_key);
|
||||
|
||||
//public static Dictionary<string, string> stringData = new Dictionary<string, string>()
|
||||
//{
|
||||
// {prefix+nameof(InitRole_key), "普通用户"},
|
||||
// {prefix+nameof(Title_key), "YiFramework"},
|
||||
//};
|
||||
|
||||
//public static Dictionary<string, List<string>> listData = new Dictionary<string, List<string>>()
|
||||
//{
|
||||
// {prefix+nameof(ImageList_key), new List<string>(){"图片地址1", "图片地址2", "图片地址3", "图片地址4" } }
|
||||
//};
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Const
|
||||
{
|
||||
public class SystemConst
|
||||
{
|
||||
public const string Admin = "cc";
|
||||
public const string AdminRolesCode = "admin";
|
||||
public const string AdminPermissionCode = "*:*:*";
|
||||
public const string PermissionClaim = "permission";
|
||||
public const string UserName = "userName";
|
||||
public const string DeptId = "deptId";
|
||||
public const string TenantId = "tenantId";
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum AgrFlagEnum
|
||||
{
|
||||
wait = 0,
|
||||
Agree = 1
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum DataScopeEnum
|
||||
{
|
||||
ALL = 0,
|
||||
CUSTOM = 1,
|
||||
DEPT = 2,
|
||||
DEPT_FOLLOW = 3,
|
||||
USER = 4
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum DelFlagEnum
|
||||
{
|
||||
Normal=0,
|
||||
Deleted=1
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum HubTypeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 在线总数
|
||||
/// </summary>
|
||||
onlineNum,
|
||||
|
||||
/// <summary>
|
||||
/// 强制退出
|
||||
/// </summary>
|
||||
forceOut
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum MenuTypeEnum
|
||||
{
|
||||
Catalogue=0, //目录
|
||||
Menu=1, //菜单
|
||||
Component = 2//组件
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum OperEnum
|
||||
{
|
||||
Insert=1,
|
||||
Update=2,
|
||||
Delete=3,
|
||||
Auth=4,
|
||||
Export=5,
|
||||
Import=6,
|
||||
ForcedOut = 7,
|
||||
GenerateCode=8,
|
||||
ClearData=9
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum PathEnum
|
||||
{
|
||||
Excel,
|
||||
File,
|
||||
Image,
|
||||
Thumbnail,
|
||||
Temp
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum ResultCodeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作成功。
|
||||
/// </summary>
|
||||
Success = 200,
|
||||
|
||||
/// <summary>
|
||||
/// 操作不成功
|
||||
/// </summary>
|
||||
NotSuccess = 500,
|
||||
|
||||
/// <summary>
|
||||
/// 无权限
|
||||
/// </summary>
|
||||
NoPermission = 401,
|
||||
|
||||
/// <summary>
|
||||
/// Access过期
|
||||
/// </summary>
|
||||
AccessTokenExpire = 1001,
|
||||
|
||||
/// <summary>
|
||||
/// Refresh过期
|
||||
/// </summary>
|
||||
RefreshTokenExpire = 1002,
|
||||
|
||||
/// <summary>
|
||||
/// 没有角色登录
|
||||
/// </summary>
|
||||
NoRoleLogin = 1003,
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum ShowFlagEnum
|
||||
{
|
||||
NoShow=0,
|
||||
Show=1
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum StateEnum
|
||||
{
|
||||
Normal=0,
|
||||
Disable=1
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum TopFlagEnum
|
||||
{
|
||||
Children=0,
|
||||
Top=1
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum WriteAndReadEnum
|
||||
{
|
||||
Write, //主库操作
|
||||
Read //从库操作
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yi.Framework.Common.Enum;
|
||||
|
||||
namespace Yi.Framework.Common.Exceptions;
|
||||
|
||||
[Serializable]
|
||||
public class BusinessException : Exception,
|
||||
IHasErrorCode,
|
||||
IHasErrorDetails,
|
||||
IHasLogLevel
|
||||
{
|
||||
public ResultCodeEnum Code { get; set; }
|
||||
|
||||
public string? Details { get; set; }
|
||||
|
||||
public LogLevel LogLevel { get; set; }
|
||||
|
||||
public BusinessException(
|
||||
ResultCodeEnum code = ResultCodeEnum.NotSuccess,
|
||||
string? message = null,
|
||||
string? details = null,
|
||||
Exception? innerException = null,
|
||||
LogLevel logLevel = LogLevel.Warning)
|
||||
: base(message, innerException)
|
||||
{
|
||||
Code = code;
|
||||
Details = details;
|
||||
LogLevel = logLevel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化参数的构造函数
|
||||
/// </summary>
|
||||
public BusinessException(SerializationInfo serializationInfo, StreamingContext context)
|
||||
: base(serializationInfo, context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BusinessException WithData(string name, object value)
|
||||
{
|
||||
Data[name] = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yi.Framework.Common.Enum;
|
||||
|
||||
namespace Yi.Framework.Common.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="Exception"/><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public static class ExceptionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// ʹ<><CAB9> <see cref="ExceptionDispatchInfo.Capture"/> <20>ٴ<EFBFBD><D9B4>׳<EFBFBD><D7B3>쳣
|
||||
/// </summary>
|
||||
/// <param name="exception">Exception to be re-thrown</param>
|
||||
public static void ReThrow(this Exception exception)
|
||||
{
|
||||
ExceptionDispatchInfo.Capture(exception).Throw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>쳣<EFBFBD>е<EFBFBD><D0B5><EFBFBD>־<EFBFBD>ȼ<EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="exception"></param>
|
||||
/// <param name="defaultLevel"></param>
|
||||
/// <returns></returns>
|
||||
public static LogLevel GetLogLevel(this Exception exception, LogLevel defaultLevel = LogLevel.Error)
|
||||
{
|
||||
return (exception as IHasLogLevel)?.LogLevel ?? defaultLevel;
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD>쳣<EFBFBD>е<EFBFBD><D0B5><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
/// <param name="exception"></param>
|
||||
/// <param name="defaultLevel"></param>
|
||||
/// <returns></returns>
|
||||
public static ResultCodeEnum GetLogErrorCode(this Exception exception, ResultCodeEnum defaultCode = ResultCodeEnum.NotSuccess)
|
||||
{
|
||||
return (exception as IHasErrorCode)?.Code ?? defaultCode;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Yi.Framework.Common.Enum;
|
||||
|
||||
namespace Yi.Framework.Common.Exceptions;
|
||||
|
||||
public interface IHasErrorCode
|
||||
{
|
||||
ResultCodeEnum Code { get; }
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Yi.Framework.Common.Exceptions;
|
||||
|
||||
public interface IHasErrorDetails
|
||||
{
|
||||
string? Details { get; }
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Yi.Framework.Common.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD><EFBFBD><see cref="LogLevel"/> <20><><EFBFBD>ԵĽӿ<C4BD>
|
||||
/// </summary>
|
||||
public interface IHasLogLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Log severity.
|
||||
/// </summary>
|
||||
LogLevel LogLevel { get; set; }
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yi.Framework.Common.Enum;
|
||||
|
||||
namespace Yi.Framework.Common.Exceptions;
|
||||
|
||||
/// <summary>
|
||||
/// <20>û<EFBFBD><C3BB>Ѻ<EFBFBD><D1BA>쳣
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class UserFriendlyException : BusinessException
|
||||
{
|
||||
public UserFriendlyException(
|
||||
string message,
|
||||
ResultCodeEnum code = ResultCodeEnum.NotSuccess,
|
||||
string? details = null,
|
||||
Exception? innerException = null,
|
||||
LogLevel logLevel = LogLevel.Warning)
|
||||
: base(
|
||||
code,
|
||||
message,
|
||||
details,
|
||||
innerException,
|
||||
logLevel)
|
||||
{
|
||||
Details = details;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><C4B9>캯<EFBFBD><ECBAAF>
|
||||
/// </summary>
|
||||
public UserFriendlyException(SerializationInfo serializationInfo, StreamingContext context)
|
||||
: base(serializationInfo, context)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class AssemblyHelper
|
||||
{
|
||||
public static List<Type> GetClass(string assemblyFile, string? className = null, string? spaceName = null)
|
||||
{
|
||||
Assembly assembly = Assembly.Load(assemblyFile);
|
||||
return assembly.GetTypes().Where(m => m.IsClass
|
||||
&& className == null ? true : m.Name == className
|
||||
&& spaceName == null ? true : m.Namespace == spaceName
|
||||
).ToList();
|
||||
}
|
||||
|
||||
public static List<Type> GetClassByBaseClassesAndInterfaces(string assemblyFile, Type type)
|
||||
{
|
||||
Assembly assembly = Assembly.Load(assemblyFile);
|
||||
|
||||
List<Type> resList = new List<Type>();
|
||||
|
||||
List<Type> typeList = assembly.GetTypes().Where(m => m.IsClass).ToList();
|
||||
foreach (var t in typeList)
|
||||
{
|
||||
var data = t.BaseClassesAndInterfaces();
|
||||
if (data.Contains(type))
|
||||
{
|
||||
resList.Add(t);
|
||||
}
|
||||
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public sealed class Base32Helper
|
||||
{
|
||||
|
||||
// the valid chars for the encoding
|
||||
private static string ValidChars = "QAZ2WSX3" + "EDC4RFV5" + "TGB6YHN7" + "UJM8K9LP";
|
||||
|
||||
/// <summary>
|
||||
/// Converts an array of bytes to a Base32-k string.
|
||||
/// </summary>
|
||||
public static string ToString(byte[] bytes)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(); // holds the base32 chars
|
||||
byte index;
|
||||
int hi = 5;
|
||||
int currentByte = 0;
|
||||
|
||||
while (currentByte < bytes.Length)
|
||||
{
|
||||
// do we need to use the next byte?
|
||||
if (hi > 8)
|
||||
{
|
||||
// get the last piece from the current byte, shift it to the right
|
||||
// and increment the byte counter
|
||||
index = (byte)(bytes[currentByte++] >> (hi - 5));
|
||||
if (currentByte != bytes.Length)
|
||||
{
|
||||
// if we are not at the end, get the first piece from
|
||||
// the next byte, clear it and shift it to the left
|
||||
index = (byte)(((byte)(bytes[currentByte] << (16 - hi)) >> 3) | index);
|
||||
}
|
||||
|
||||
hi -= 3;
|
||||
}
|
||||
else if (hi == 8)
|
||||
{
|
||||
index = (byte)(bytes[currentByte++] >> 3);
|
||||
hi -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// simply get the stuff from the current byte
|
||||
index = (byte)((byte)(bytes[currentByte] << (8 - hi)) >> 3);
|
||||
hi += 5;
|
||||
}
|
||||
|
||||
sb.Append(ValidChars[index]);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Converts a Base32-k string into an array of bytes.
|
||||
/// </summary>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// Input string <paramref name="s">s</paramref> contains invalid Base32-k characters.
|
||||
/// </exception>
|
||||
public static byte[] FromBase32String(string str)
|
||||
{
|
||||
int numBytes = str.Length * 5 / 8;
|
||||
byte[] bytes = new Byte[numBytes];
|
||||
|
||||
// all UPPERCASE chars
|
||||
str = str.ToUpper();
|
||||
|
||||
int bit_buffer;
|
||||
int currentCharIndex;
|
||||
int bits_in_buffer;
|
||||
|
||||
if (str.Length < 3)
|
||||
{
|
||||
bytes[0] = (byte)(ValidChars.IndexOf(str[0]) | ValidChars.IndexOf(str[1]) << 5);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bit_buffer = (ValidChars.IndexOf(str[0]) | ValidChars.IndexOf(str[1]) << 5);
|
||||
bits_in_buffer = 10;
|
||||
currentCharIndex = 2;
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
bytes[i] = (byte)bit_buffer;
|
||||
bit_buffer >>= 8;
|
||||
bits_in_buffer -= 8;
|
||||
while (bits_in_buffer < 8 && currentCharIndex < str.Length)
|
||||
{
|
||||
bit_buffer |= ValidChars.IndexOf(str[currentCharIndex++]) << bits_in_buffer;
|
||||
bits_in_buffer += 5;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class ConsoleHelper
|
||||
{
|
||||
public static void WriteColorLine(string str, ConsoleColor color)
|
||||
{
|
||||
ConsoleColor currentForeColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = color;
|
||||
Console.WriteLine(str);
|
||||
Console.ForegroundColor = currentForeColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印错误信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteErrorLine(this string str, ConsoleColor color = ConsoleColor.Red)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印警告信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteWarningLine(this string str, ConsoleColor color = ConsoleColor.Yellow)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印正常信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteInfoLine(this string str, ConsoleColor color = ConsoleColor.White)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
/// <summary>
|
||||
/// 打印成功的信息
|
||||
/// </summary>
|
||||
/// <param name="str">待打印的字符串</param>
|
||||
/// <param name="color">想要打印的颜色</param>
|
||||
public static void WriteSuccessLine(this string str, ConsoleColor color = ConsoleColor.Green)
|
||||
{
|
||||
WriteColorLine(str, color);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class DateHelper
|
||||
{
|
||||
public static DateTime StampToDateTime(string time)
|
||||
{
|
||||
time = time.Substring(0, 10);
|
||||
double timestamp = Convert.ToInt64(time);
|
||||
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
dateTime = dateTime.AddSeconds(timestamp).ToLocalTime();
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static string TimeSubTract(DateTime time1,DateTime time2)
|
||||
{
|
||||
TimeSpan subTract = time1.Subtract(time2);
|
||||
return $"{subTract.Days} 天 {subTract.Hours} 时 {subTract.Minutes} 分 ";
|
||||
}
|
||||
/// <summary>
|
||||
/// 时间戳转本地时间-时间戳精确到秒
|
||||
/// </summary>
|
||||
public static DateTime ToLocalTimeDateBySeconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeSeconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间转时间戳Unix-时间戳精确到秒
|
||||
/// </summary>
|
||||
public static long ToUnixTimestampBySeconds(DateTime dt)
|
||||
{
|
||||
DateTimeOffset dto = new DateTimeOffset(dt);
|
||||
return dto.ToUnixTimeSeconds();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳转本地时间-时间戳精确到毫秒
|
||||
/// </summary>
|
||||
public static DateTime ToLocalTimeDateByMilliseconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeMilliseconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间转时间戳Unix-时间戳精确到毫秒
|
||||
/// </summary>
|
||||
public static long ToUnixTimestampByMilliseconds(DateTime dt)
|
||||
{
|
||||
DateTimeOffset dto = new DateTimeOffset(dt);
|
||||
return dto.ToUnixTimeMilliseconds();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class Compare<T, C> : IEqualityComparer<T>
|
||||
{
|
||||
private Func<T, C> _getField;
|
||||
public Compare(Func<T, C> getfield)
|
||||
{
|
||||
this._getField = getfield;
|
||||
}
|
||||
public bool Equals(T? x, T? y)
|
||||
{
|
||||
return EqualityComparer<C>.Default.Equals(_getField(x!), _getField(y!));
|
||||
}
|
||||
|
||||
public int GetHashCode(T obj)
|
||||
{
|
||||
return EqualityComparer<C>.Default.GetHashCode(this._getField(obj)!);
|
||||
}
|
||||
}
|
||||
public static class DistinctHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义Distinct扩展方法
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要去重的对象类</typeparam>
|
||||
/// <typeparam name="C">自定义去重的字段类型</typeparam>
|
||||
/// <param name="source">要去重的对象</param>
|
||||
/// <param name="getfield">获取自定义去重字段的委托</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> DistinctNew<T, C>(this IEnumerable<T> source, Func<T, C> getfield)
|
||||
{
|
||||
return source.Distinct(new Compare<T, C>(getfield));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Mail;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class EmailHelper
|
||||
{
|
||||
public static string fromMail { get; set; } = string.Empty;
|
||||
public static string pwdMail { get; set; } = string.Empty;
|
||||
public static string senderMail { get; set; } = string.Empty;
|
||||
public static string subjectMail { get; set; } = string.Empty;
|
||||
public static void Init(string fromMail,string pwdMail,string senderMail, string subjectMail)
|
||||
{
|
||||
EmailHelper.fromMail = fromMail;
|
||||
EmailHelper.pwdMail = pwdMail;
|
||||
EmailHelper.senderMail = senderMail;
|
||||
EmailHelper.subjectMail = subjectMail;
|
||||
}
|
||||
|
||||
public static bool sendMail(string body, string toMail)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//string fromMail = "454313500@qq.com";
|
||||
//string pwdMail = "yvjioburildgbhdf";
|
||||
MailMessage message = new MailMessage();
|
||||
//设置发件人,发件人需要与设置的邮件发送服务器的邮箱一致
|
||||
System.Net.Mail.MailAddress fromAddr = new System.Net.Mail.MailAddress(fromMail, EmailHelper.senderMail);
|
||||
message.From = fromAddr;
|
||||
|
||||
//设置收件人,可添加多个,添加方法与下面的一样
|
||||
message.To.Add(toMail);
|
||||
|
||||
|
||||
//设置邮件标题
|
||||
message.Subject = EmailHelper.subjectMail;
|
||||
|
||||
//设置邮件内容
|
||||
message.Body = body;
|
||||
|
||||
//设置邮件发送服务器,服务器根据你使用的邮箱而不同,可以到相应的 邮箱管理后台查看,下面是QQ的
|
||||
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.qq.com", 25)
|
||||
;
|
||||
//设置发送人的邮箱账号和密码,POP3/SMTP服务要开启, 密码要是POP3/SMTP等服务的授权码
|
||||
client.Credentials = new System.Net.NetworkCredential(fromMail, pwdMail);//vtirsfsthwuadjfe fhszmpegwoqnecja
|
||||
|
||||
//启用ssl,也就是安全发送
|
||||
client.EnableSsl = true;
|
||||
|
||||
//发送邮件
|
||||
client.Send(message);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void 接受邮件()
|
||||
{
|
||||
using (TcpClient client = new TcpClient("pop.qq.com", 110))
|
||||
using (NetworkStream n = client.GetStream())
|
||||
{
|
||||
GetEmail.ReadLine(n); // Read the welcome message.
|
||||
GetEmail.SendCommand(n, "USER 1040079213@qq.com");
|
||||
GetEmail.SendCommand(n, "PASS odfaizoqdiupbfgi");
|
||||
GetEmail.SendCommand(n, "LIST"); // Retrieve message IDs
|
||||
List<int> messageIDs = new List<int>();
|
||||
while (true)
|
||||
{
|
||||
string line = GetEmail.ReadLine(n); // e.g., "11876"
|
||||
if (line == ".") break;
|
||||
messageIDs.Add(int.Parse(line.Split(' ')[0])); // Message ID
|
||||
}
|
||||
foreach (int id in messageIDs) // Retrieve each message.
|
||||
{
|
||||
GetEmail.SendCommand(n, "RETR " + id);
|
||||
string randomFile = Guid.NewGuid().ToString() + ".eml";
|
||||
using (StreamWriter writer = File.CreateText(randomFile))
|
||||
while (true)
|
||||
{
|
||||
string line = GetEmail.ReadLine(n); // Read next line of message.
|
||||
if (line == ".") break; // Single dot = end of message.
|
||||
if (line == "..") line = "."; // "Escape out" double dot.
|
||||
writer.WriteLine(line); // Write to output file.
|
||||
}
|
||||
GetEmail.SendCommand(n, "DELE " + id); // Delete message off server.
|
||||
}
|
||||
GetEmail.SendCommand(n, "QUIT");
|
||||
}
|
||||
}
|
||||
}
|
||||
//接受邮件pop
|
||||
public class GetEmail
|
||||
{
|
||||
public static void SendCommand(Stream stream, string line)
|
||||
{
|
||||
byte[] data = Encoding.UTF8.GetBytes(line + "\r\n");
|
||||
stream.Write(data, 0, data.Length);
|
||||
string response = ReadLine(stream);
|
||||
if (!response.StartsWith("+OK"))
|
||||
throw new Exception("POP Error: " + response);
|
||||
}
|
||||
public static string ReadLine(Stream s)
|
||||
{
|
||||
List<byte> lineBuffer = new List<byte>();
|
||||
while (true)
|
||||
{
|
||||
int b = s.ReadByte();
|
||||
if (b == 10 || b < 0) break;
|
||||
if (b != 13) lineBuffer.Add((byte)b);
|
||||
}
|
||||
return Encoding.UTF8.GetString(lineBuffer.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 此处来源于ZrAdmin
|
||||
/// </summary>
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class ExcelHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 导出Excel
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="sheetName"></param>
|
||||
/// <param name="fileName"></param>
|
||||
public static string ExportExcel<T>(List<T> list, string fileName,string path,string sheetName= "default")
|
||||
{
|
||||
string sFileName = $"{fileName}.xlsx";
|
||||
string newFileName = Path.Combine(path, sFileName);
|
||||
//调试模式需要加上
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(newFileName)!);
|
||||
using (ExcelPackage package = new(new FileInfo(newFileName)))
|
||||
{
|
||||
// 添加worksheet
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(sheetName);
|
||||
//单元格自动适应大小
|
||||
worksheet.Cells.Style.ShrinkToFit = true;
|
||||
//全部字段导出
|
||||
worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
|
||||
package.Save();
|
||||
}
|
||||
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载导入模板
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="stream"></param>
|
||||
/// <param name="fileName">下载文件名</param>
|
||||
/// <returns></returns>
|
||||
public static string DownloadImportTemplate<T>(List<T> list, string fileName,string path)
|
||||
{
|
||||
string sFileName = $"{fileName}.xlsx";
|
||||
string newFileName = Path.Combine(path, sFileName);
|
||||
|
||||
//如果文件存在,直接返回即可
|
||||
if (File.Exists(newFileName))
|
||||
{
|
||||
return newFileName;
|
||||
}
|
||||
//调试模式需要加上
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
if (!Directory.Exists(newFileName))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(newFileName)!);
|
||||
}
|
||||
|
||||
|
||||
Stream stream = new FileStream(newFileName, FileMode.OpenOrCreate);
|
||||
using (ExcelPackage package = new(new FileInfo(newFileName)))
|
||||
{
|
||||
// 添加worksheet
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(fileName);
|
||||
//单元格自动适应大小
|
||||
worksheet.Cells.Style.ShrinkToFit = true;
|
||||
//全部字段导出
|
||||
worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
|
||||
package.SaveAs(stream);
|
||||
}
|
||||
stream.Dispose();
|
||||
|
||||
return newFileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导入数据
|
||||
/// </summary>
|
||||
/// <param name="stream"></param>
|
||||
/// <returns></returns>
|
||||
public static List<T> ImportData<T>(Stream stream) where T : new()
|
||||
{
|
||||
using ExcelPackage package = new(stream);
|
||||
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet
|
||||
//获取表格的列数和行数
|
||||
|
||||
int colStart = worksheet.Dimension.Start.Column;
|
||||
int colEnd = worksheet.Dimension.End.Column;
|
||||
int rowStart = worksheet.Dimension.Start.Row;
|
||||
int rowEnd = worksheet.Dimension.End.Row;
|
||||
//int rowCount = worksheet.Dimension.Rows;
|
||||
//int ColCount = worksheet.Dimension.Columns;
|
||||
|
||||
List<T> resultList = new();
|
||||
List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties());
|
||||
Dictionary<string, int> dictHeader = new();
|
||||
for (int i = colStart; i < colEnd; i++)
|
||||
{
|
||||
var name = worksheet.Cells[rowStart, i].Value.ToString();
|
||||
dictHeader[name!] = i;
|
||||
|
||||
PropertyInfo propertyInfo = MapPropertyInfo<T>(name!);
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
propertyInfos.Add(propertyInfo);
|
||||
}
|
||||
}
|
||||
for (int row = rowStart + 1; row <= rowEnd; row++)
|
||||
{
|
||||
T result = new();
|
||||
|
||||
foreach (PropertyInfo p in propertyInfos)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]];
|
||||
if (cell.Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (p.PropertyType.Name.ToLower())
|
||||
{
|
||||
case "string":
|
||||
p.SetValue(result, cell.GetValue<string>());
|
||||
break;
|
||||
case "int16":
|
||||
p.SetValue(result, cell.GetValue<short>()); break;
|
||||
case "int32":
|
||||
p.SetValue(result, cell.GetValue<int>()); break;
|
||||
case "int64":
|
||||
p.SetValue(result, cell.GetValue<long>()); break;
|
||||
case "decimal":
|
||||
p.SetValue(result, cell.GetValue<decimal>());
|
||||
break;
|
||||
case "double":
|
||||
p.SetValue(result, cell.GetValue<double>()); break;
|
||||
case "datetime":
|
||||
p.SetValue(result, cell.GetValue<DateTime>()); break;
|
||||
case "boolean":
|
||||
p.SetValue(result, cell.GetValue<bool>()); break;
|
||||
case "char":
|
||||
p.SetValue(result, cell.GetValue<string>()); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (KeyNotFoundException ex)
|
||||
{
|
||||
Console.WriteLine("未找到该列将继续循环," + ex.Message);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
resultList.Add(result);
|
||||
}
|
||||
|
||||
return resultList.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找Excel列名对应的实体属性
|
||||
/// </summary>
|
||||
/// <param name="columnName"></param>
|
||||
/// <returns></returns>
|
||||
private static PropertyInfo MapPropertyInfo<T>(string columnName)
|
||||
{
|
||||
PropertyInfo[] propertyList = GetProperties(typeof(T));
|
||||
PropertyInfo propertyInfo = propertyList.Where(p => p.Name == columnName).FirstOrDefault()!;
|
||||
if (propertyInfo != null)
|
||||
{
|
||||
return propertyInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (PropertyInfo tempPropertyInfo in propertyList)
|
||||
{
|
||||
System.ComponentModel.DescriptionAttribute[] attributes = (System.ComponentModel.DescriptionAttribute[])tempPropertyInfo.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
|
||||
if (attributes.Length > 0)
|
||||
{
|
||||
if (attributes[0].Description == columnName)
|
||||
{
|
||||
return tempPropertyInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到类里面的属性集合
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="columns"></param>
|
||||
/// <returns></returns>
|
||||
private static PropertyInfo[] GetProperties(Type type, string[] columns = null!)
|
||||
{
|
||||
PropertyInfo[] properties = null!;
|
||||
properties = type.GetProperties();
|
||||
|
||||
if (columns != null && columns.Length > 0)
|
||||
{
|
||||
// 按columns顺序返回属性
|
||||
var columnPropertyList = new List<PropertyInfo>();
|
||||
foreach (var column in columns)
|
||||
{
|
||||
var columnProperty = properties.Where(p => p.Name == column).FirstOrDefault();
|
||||
if (columnProperty != null)
|
||||
{
|
||||
columnPropertyList.Add(columnProperty);
|
||||
}
|
||||
}
|
||||
return columnPropertyList.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,490 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class FileHelper : IDisposable
|
||||
{
|
||||
|
||||
private bool _alreadyDispose = false;
|
||||
|
||||
|
||||
|
||||
#region 构造函数
|
||||
public FileHelper()
|
||||
{
|
||||
//
|
||||
// TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
~FileHelper()
|
||||
{
|
||||
Dispose(); ;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool isDisposing)
|
||||
{
|
||||
if (_alreadyDispose) return;
|
||||
_alreadyDispose = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable 成员
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 取得文件后缀名
|
||||
/****************************************
|
||||
* 函数名称:GetPostfixStr
|
||||
* 功能说明:取得文件后缀名
|
||||
* 参 数:filename:文件名称
|
||||
* 调用示列:
|
||||
* string filename = "aaa.aspx";
|
||||
* string s = EC.FileObj.GetPostfixStr(filename);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 取后缀名
|
||||
/// </summary>
|
||||
/// <param name="filename">文件名</param>
|
||||
/// <returns>.gif|.html格式</returns>
|
||||
public static string GetPostfixStr(string filename)
|
||||
{
|
||||
int start = filename.LastIndexOf(".");
|
||||
int length = filename.Length;
|
||||
string postfix = filename.Substring(start, length - start);
|
||||
return postfix;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 根据文件大小获取指定前缀的可用文件名
|
||||
/// <summary>
|
||||
/// 根据文件大小获取指定前缀的可用文件名
|
||||
/// </summary>
|
||||
/// <param name="folderPath">文件夹</param>
|
||||
/// <param name="prefix">文件前缀</param>
|
||||
/// <param name="size">文件大小(1m)</param>
|
||||
/// <param name="ext">文件后缀(.log)</param>
|
||||
/// <returns>可用文件名</returns>
|
||||
//public static string GetAvailableFileWithPrefixOrderSize(string folderPath, string prefix, int size = 1 * 1024 * 1024, string ext = ".log")
|
||||
//{
|
||||
// var allFiles = new DirectoryInfo(folderPath);
|
||||
// var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d=>d.Name).ToList();
|
||||
|
||||
// if (selectFiles.Count > 0)
|
||||
// {
|
||||
// return selectFiles.FirstOrDefault().FullName;
|
||||
// }
|
||||
|
||||
// return Path.Combine(folderPath, $@"{prefix}_{DateTime.Now.DateToTimeStamp()}.log");
|
||||
//}
|
||||
//public static string GetAvailableFileNameWithPrefixOrderSize(string _contentRoot, string prefix, int size = 1 * 1024 * 1024, string ext = ".log")
|
||||
//{
|
||||
// var folderPath = Path.Combine(_contentRoot, "Log");
|
||||
// if (!Directory.Exists(folderPath))
|
||||
// {
|
||||
// Directory.CreateDirectory(folderPath);
|
||||
// }
|
||||
|
||||
// var allFiles = new DirectoryInfo(folderPath);
|
||||
// var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d => d.Name).ToList();
|
||||
|
||||
// if (selectFiles.Count > 0)
|
||||
// {
|
||||
// return selectFiles.FirstOrDefault().Name.Replace(".log","");
|
||||
// }
|
||||
|
||||
// return $@"{prefix}_{DateTime.Now.DateToTimeStamp()}";
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 写文件
|
||||
/****************************************
|
||||
* 函数名称:WriteFile
|
||||
* 功能说明:写文件,会覆盖掉以前的内容
|
||||
* 参 数:Path:文件路径,Strings:文本内容
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default2.aspx");
|
||||
* string Strings = "这是我写的内容啊";
|
||||
* EC.FileObj.WriteFile(Path,Strings);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 写文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="Strings">文件内容</param>
|
||||
public static void WriteFile(string Path, string Strings)
|
||||
{
|
||||
if (!File.Exists(Path))
|
||||
{
|
||||
FileStream f = File.Create(Path);
|
||||
f.Close();
|
||||
}
|
||||
StreamWriter f2 = new StreamWriter(Path, false, System.Text.Encoding.GetEncoding("gb2312"));
|
||||
f2.Write(Strings);
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="Strings">文件内容</param>
|
||||
/// <param name="encode">编码格式</param>
|
||||
public static void WriteFile(string Path, string Strings, Encoding encode)
|
||||
{
|
||||
if (!File.Exists(Path))
|
||||
{
|
||||
FileStream f = File.Create(Path);
|
||||
f.Close();
|
||||
}
|
||||
StreamWriter f2 = new StreamWriter(Path, false, encode);
|
||||
f2.Write(Strings);
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 读文件
|
||||
/****************************************
|
||||
* 函数名称:ReadFile
|
||||
* 功能说明:读取文本内容
|
||||
* 参 数:Path:文件路径
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default2.aspx");
|
||||
* string s = EC.FileObj.ReadFile(Path);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 读文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <returns></returns>
|
||||
public static string ReadFile(string Path)
|
||||
{
|
||||
string s = "";
|
||||
if (!File.Exists(Path))
|
||||
s = "不存在相应的目录";
|
||||
else
|
||||
{
|
||||
StreamReader f2 = new StreamReader(Path, System.Text.Encoding.GetEncoding("gb2312"));
|
||||
s = f2.ReadToEnd();
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="encode">编码格式</param>
|
||||
/// <returns></returns>
|
||||
public static string ReadFile(string Path, Encoding encode)
|
||||
{
|
||||
string s = "";
|
||||
if (!File.Exists(Path))
|
||||
s = "不存在相应的目录";
|
||||
else
|
||||
{
|
||||
StreamReader f2 = new StreamReader(Path, encode);
|
||||
s = f2.ReadToEnd();
|
||||
f2.Close();
|
||||
f2.Dispose();
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 追加文件
|
||||
/****************************************
|
||||
* 函数名称:FileAdd
|
||||
* 功能说明:追加文件内容
|
||||
* 参 数:Path:文件路径,strings:内容
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default2.aspx");
|
||||
* string Strings = "新追加内容";
|
||||
* EC.FileObj.FileAdd(Path, Strings);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 追加文件
|
||||
/// </summary>
|
||||
/// <param name="Path">文件路径</param>
|
||||
/// <param name="strings">内容</param>
|
||||
public static void FileAdd(string Path, string strings)
|
||||
{
|
||||
StreamWriter sw = File.AppendText(Path);
|
||||
sw.Write(strings);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 拷贝文件
|
||||
/****************************************
|
||||
* 函数名称:FileCoppy
|
||||
* 功能说明:拷贝文件
|
||||
* 参 数:OrignFile:原始文件,NewFile:新文件路径
|
||||
* 调用示列:
|
||||
* string orignFile = Server.MapPath("Default2.aspx");
|
||||
* string NewFile = Server.MapPath("Default3.aspx");
|
||||
* EC.FileObj.FileCoppy(OrignFile, NewFile);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 拷贝文件
|
||||
/// </summary>
|
||||
/// <param name="OrignFile">原始文件</param>
|
||||
/// <param name="NewFile">新文件路径</param>
|
||||
public static void FileCoppy(string orignFile, string NewFile)
|
||||
{
|
||||
File.Copy(orignFile, NewFile, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 删除文件
|
||||
/****************************************
|
||||
* 函数名称:FileDel
|
||||
* 功能说明:删除文件
|
||||
* 参 数:Path:文件路径
|
||||
* 调用示列:
|
||||
* string Path = Server.MapPath("Default3.aspx");
|
||||
* EC.FileObj.FileDel(Path);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 删除文件
|
||||
/// </summary>
|
||||
/// <param name="Path">路径</param>
|
||||
public static void FileDel(string Path)
|
||||
{
|
||||
File.Delete(Path);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 移动文件
|
||||
/****************************************
|
||||
* 函数名称:FileMove
|
||||
* 功能说明:移动文件
|
||||
* 参 数:OrignFile:原始路径,NewFile:新文件路径
|
||||
* 调用示列:
|
||||
* string orignFile = Server.MapPath("../说明.txt");
|
||||
* string NewFile = Server.MapPath("http://www.cnblogs.com/说明.txt");
|
||||
* EC.FileObj.FileMove(OrignFile, NewFile);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 移动文件
|
||||
/// </summary>
|
||||
/// <param name="OrignFile">原始路径</param>
|
||||
/// <param name="NewFile">新路径</param>
|
||||
public static void FileMove(string orignFile, string NewFile)
|
||||
{
|
||||
File.Move(orignFile, NewFile);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 在当前目录下创建目录
|
||||
/****************************************
|
||||
* 函数名称:FolderCreate
|
||||
* 功能说明:在当前目录下创建目录
|
||||
* 参 数:OrignFolder:当前目录,NewFloder:新目录
|
||||
* 调用示列:
|
||||
* string orignFolder = Server.MapPath("test/");
|
||||
* string NewFloder = "new";
|
||||
* EC.FileObj.FolderCreate(OrignFolder, NewFloder);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 在当前目录下创建目录
|
||||
/// </summary>
|
||||
/// <param name="OrignFolder">当前目录</param>
|
||||
/// <param name="NewFloder">新目录</param>
|
||||
public static void FolderCreate(string orignFolder, string NewFloder)
|
||||
{
|
||||
Directory.SetCurrentDirectory(orignFolder);
|
||||
Directory.CreateDirectory(NewFloder);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 递归删除文件夹目录及文件
|
||||
/****************************************
|
||||
* 函数名称:DeleteFolder
|
||||
* 功能说明:递归删除文件夹目录及文件
|
||||
* 参 数:dir:文件夹路径
|
||||
* 调用示列:
|
||||
* string dir = Server.MapPath("test/");
|
||||
* EC.FileObj.DeleteFolder(dir);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 递归删除文件夹目录及文件
|
||||
/// </summary>
|
||||
/// <param name="dir"></param>
|
||||
/// <returns></returns>
|
||||
public static void DeleteFolder(string dir)
|
||||
{
|
||||
if (Directory.Exists(dir)) //如果存在这个文件夹删除之
|
||||
{
|
||||
foreach (string d in Directory.GetFileSystemEntries(dir))
|
||||
{
|
||||
if (File.Exists(d))
|
||||
File.Delete(d); //直接删除其中的文件
|
||||
else
|
||||
DeleteFolder(d); //递归删除子文件夹
|
||||
}
|
||||
Directory.Delete(dir); //删除已空文件夹
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。
|
||||
/****************************************
|
||||
* 函数名称:CopyDir
|
||||
* 功能说明:将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。
|
||||
* 参 数:srcPath:原始路径,aimPath:目标文件夹
|
||||
* 调用示列:
|
||||
* string srcPath = Server.MapPath("test/");
|
||||
* string aimPath = Server.MapPath("test1/");
|
||||
* EC.FileObj.CopyDir(srcPath,aimPath);
|
||||
*****************************************/
|
||||
/// <summary>
|
||||
/// 指定文件夹下面的所有内容copy到目标文件夹下面
|
||||
/// </summary>
|
||||
/// <param name="srcPath">原始路径</param>
|
||||
/// <param name="aimPath">目标文件夹</param>
|
||||
public static void CopyDir(string srcPath, string aimPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查目标目录是否以目录分割字符结束如果不是则添加之
|
||||
if (aimPath[aimPath.Length - 1] != Path.DirectorySeparatorChar)
|
||||
aimPath += Path.DirectorySeparatorChar;
|
||||
// 判断目标目录是否存在如果不存在则新建之
|
||||
if (!Directory.Exists(aimPath))
|
||||
Directory.CreateDirectory(aimPath);
|
||||
// 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组
|
||||
//如果你指向copy目标文件下面的文件而不包含目录请使用下面的方法
|
||||
//string[] fileList = Directory.GetFiles(srcPath);
|
||||
string[] fileList = Directory.GetFileSystemEntries(srcPath);
|
||||
//遍历所有的文件和目录
|
||||
foreach (string file in fileList)
|
||||
{
|
||||
//先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
|
||||
|
||||
if (Directory.Exists(file))
|
||||
CopyDir(file, aimPath + Path.GetFileName(file));
|
||||
//否则直接Copy文件
|
||||
else
|
||||
File.Copy(file, aimPath + Path.GetFileName(file), true);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
throw new Exception(ee.ToString());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取目录下全部文件名
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetAllFileNames(string path, string pattern = "*")
|
||||
{
|
||||
List<FileInfo> folder = new DirectoryInfo(path).GetFiles(pattern).ToList();
|
||||
|
||||
return folder.Select(x => x.Name).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件内容替换
|
||||
/// </summary>
|
||||
public static string FileContentReplace(string path, string oldStr, string newStr)
|
||||
{
|
||||
var content = File.ReadAllText(path);
|
||||
|
||||
if (content.Contains(oldStr))
|
||||
{
|
||||
File.Delete(path);
|
||||
File.WriteAllText(path, content.Replace(oldStr, newStr));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public static string FileNameReplace(string path, string oldStr, string newStr)
|
||||
{
|
||||
string fileName = Path.GetFileName(path);
|
||||
if (!fileName.Contains(oldStr))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
string? directoryName = Path.GetDirectoryName(path);
|
||||
string newFileName = fileName.Replace(oldStr, newStr);
|
||||
string newPath = Path.Combine(directoryName ?? "", newFileName);
|
||||
File.Move(path, newPath);
|
||||
|
||||
return newPath;
|
||||
}
|
||||
/// <summary>
|
||||
/// 目录名替换
|
||||
/// </summary>
|
||||
public static string DirectoryNameReplace(string path, string oldStr, string newStr)
|
||||
{
|
||||
string fileName = Path.GetFileName(path);
|
||||
if (!fileName.Contains(oldStr))
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
string? directoryName = Path.GetDirectoryName(path);
|
||||
string newFileName = fileName.Replace(oldStr, newStr);
|
||||
string newPath = Path.Combine(directoryName ?? "", newFileName);
|
||||
Directory.Move(path, newPath);
|
||||
return newPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全部信息递归替换
|
||||
/// </summary>
|
||||
/// <param name="dirPath"></param>
|
||||
/// <param name="oldStr"></param>
|
||||
/// <param name="newStr"></param>
|
||||
public static void AllInfoReplace(string dirPath, string oldStr, string newStr)
|
||||
{
|
||||
var path = DirectoryNameReplace(dirPath, oldStr, newStr);
|
||||
var dirInfo = new DirectoryInfo(path);
|
||||
var files = dirInfo.GetFiles();
|
||||
var dirs = dirInfo.GetDirectories();
|
||||
if (files.Length > 0)
|
||||
{
|
||||
foreach (var f in files)
|
||||
{
|
||||
FileContentReplace(f.FullName, oldStr, newStr);
|
||||
FileNameReplace(f.FullName, oldStr, newStr);
|
||||
}
|
||||
}
|
||||
if (dirs.Length > 0)
|
||||
{
|
||||
foreach (var d in dirs)
|
||||
{
|
||||
AllInfoReplace(d.FullName, oldStr, newStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class HtmlHelper
|
||||
{
|
||||
#region 去除富文本中的HTML标签
|
||||
/// <summary>
|
||||
/// 去除富文本中的HTML标签
|
||||
/// </summary>
|
||||
/// <param name="html"></param>
|
||||
/// <param name="length"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReplaceHtmlTag(string html, int length = 0)
|
||||
{
|
||||
string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
|
||||
strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
|
||||
|
||||
if (length > 0 && strText.Length > length)
|
||||
return strText.Substring(0, length);
|
||||
|
||||
return strText;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Mime;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class HttpHelper
|
||||
{
|
||||
|
||||
public static HttpClient Client { get; set; } = new HttpClient();
|
||||
|
||||
public static async Task<string> Get(string url)
|
||||
{
|
||||
return await Client.GetStringAsync(url);
|
||||
}
|
||||
|
||||
public static async Task<Stream> GetIO(string url)
|
||||
{
|
||||
return await Client.GetStreamAsync(url);
|
||||
}
|
||||
|
||||
|
||||
public static async Task<string> Post(string url, object? item = null, Dictionary<string, string>? head = null)
|
||||
{
|
||||
|
||||
using StringContent json = new(JsonSerializer.Serialize(item), Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
|
||||
|
||||
if (head is not null)
|
||||
{
|
||||
foreach (var d in head)
|
||||
{
|
||||
json.Headers.Add(d.Key, d.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var httpResponse = await Client.PostAsync(url, json);
|
||||
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var content = httpResponse.Content;
|
||||
|
||||
return await content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
||||
// public static string HttpGet(string Url, string postDataStr="")
|
||||
// {
|
||||
//#pragma warning disable SYSLIB0014 // 类型或成员已过时
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
||||
//#pragma warning restore SYSLIB0014 // 类型或成员已过时
|
||||
// request.Method = "GET";
|
||||
// request.ContentType = "text/html;charset=UTF-8";
|
||||
|
||||
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
// Stream myResponseStream = response.GetResponseStream();
|
||||
// StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||||
// string retString = myStreamReader.ReadToEnd();
|
||||
// myStreamReader.Close();
|
||||
// myResponseStream.Close();
|
||||
|
||||
// return retString;
|
||||
// }
|
||||
|
||||
// public static bool HttpIOGet(string Url, string file, string postDataStr="")
|
||||
// {
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
||||
// request.Method = "GET";
|
||||
// request.ContentType = "text/html;charset=UTF-8";
|
||||
|
||||
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
// Stream myResponseStream = response.GetResponseStream();
|
||||
// FileStream writer = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int c;
|
||||
// while ((c = myResponseStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
// {
|
||||
// writer.Write(buffer, 0, c);
|
||||
// }
|
||||
// writer.Close();
|
||||
// myResponseStream.Close();
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// public static string HttpPost(string Url, string postDataStr="")
|
||||
// {
|
||||
// CookieContainer cookie = new CookieContainer();
|
||||
//#pragma warning disable SYSLIB0014 // 类型或成员已过时
|
||||
// HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
|
||||
//#pragma warning restore SYSLIB0014 // 类型或成员已过时
|
||||
// request.Method = "POST";
|
||||
// request.ContentType = "application/x-www-form-urlencoded";
|
||||
// request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
|
||||
// request.CookieContainer = cookie;
|
||||
|
||||
// Stream myRequestStream = request.GetRequestStream();
|
||||
// StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
|
||||
// myStreamWriter.Write(postDataStr);
|
||||
// myStreamWriter.Close();
|
||||
|
||||
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
// response.Cookies = cookie.GetCookies(response.ResponseUri);
|
||||
// Stream myResponseStream = response.GetResponseStream();
|
||||
// StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
||||
// string retString = myStreamReader.ReadToEnd();
|
||||
// myStreamReader.Close();
|
||||
// myResponseStream.Close();
|
||||
|
||||
// return retString;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class IdHelper
|
||||
{
|
||||
public static dynamic[] ToDynamicArray(this IEnumerable<long> ids)
|
||||
{
|
||||
return ids.Select(id => (dynamic)id).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class IpHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取当前IP地址
|
||||
/// </summary>
|
||||
/// <param name="preferredNetworks"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetCurrentIp(string preferredNetworks)
|
||||
{
|
||||
var instanceIp = "127.0.0.1";
|
||||
|
||||
try
|
||||
{
|
||||
// 获取可用网卡
|
||||
var nics = NetworkInterface.GetAllNetworkInterfaces()?.Where(network => network.OperationalStatus == OperationalStatus.Up);
|
||||
|
||||
// 获取所有可用网卡IP信息
|
||||
var ipCollection = nics?.Select(x => x.GetIPProperties())?.SelectMany(x => x.UnicastAddresses);
|
||||
|
||||
if (ipCollection is null)
|
||||
{
|
||||
return instanceIp;
|
||||
}
|
||||
|
||||
foreach (var ipadd in ipCollection)
|
||||
{
|
||||
if (!IPAddress.IsLoopback(ipadd.Address) && ipadd.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
if (string.IsNullOrEmpty(preferredNetworks))
|
||||
{
|
||||
instanceIp = ipadd.Address.ToString();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ipadd.Address.ToString().StartsWith(preferredNetworks)) continue;
|
||||
instanceIp = ipadd.Address.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
return instanceIp;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user