Compare commits
181 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3555b08fe8 | ||
|
|
55ad046e96 | ||
|
|
ea4ddb68f3 | ||
|
|
edde5f8a88 | ||
|
|
de28fd4ca4 | ||
|
|
dd7bbb138a | ||
|
|
4a54eb56a7 | ||
|
|
24cda70cbc | ||
|
|
a0c869d0a1 | ||
|
|
58f85992b0 | ||
|
|
f11f5e1ca4 | ||
|
|
0672698ba7 | ||
|
|
cf37f7c950 | ||
|
|
c7d64554ad | ||
|
|
039021532e | ||
|
|
e39ae170c3 | ||
|
|
8a44fe9d1c | ||
|
|
70649653fb | ||
|
|
db1f241c33 | ||
|
|
c9ed317e62 | ||
|
|
afde26a7ae | ||
|
|
1a2d9ba2b2 | ||
|
|
3943536485 | ||
|
|
e963a4051f | ||
|
|
2b02194a18 | ||
|
|
dd1aec3b60 | ||
|
|
0b05d4d186 | ||
|
|
8f0327604f | ||
|
|
40dddb3316 | ||
|
|
be7ea64c5a | ||
|
|
8eef0e410e | ||
|
|
63f0b20fd6 | ||
|
|
87a685b823 | ||
|
|
4796a494de | ||
|
|
a329ff3796 | ||
|
|
00ab65e720 | ||
|
|
4997e25cdc | ||
|
|
6ce05984d5 | ||
|
|
26e08774b0 | ||
|
|
83ce9fb4c4 | ||
|
|
ac946f4903 | ||
|
|
d6480db609 | ||
|
|
9f9c191240 | ||
|
|
cb781aa4ad | ||
|
|
6a31e88855 | ||
|
|
f862e5ea1b | ||
|
|
b8de3e9867 | ||
|
|
1959160681 | ||
|
|
b665ec5717 | ||
|
|
8ef2c12be1 | ||
|
|
d85e7f0bcb | ||
|
|
544d65c7d0 | ||
|
|
1bd5fc389a | ||
|
|
9149d6de9a | ||
|
|
261d9fcd79 | ||
|
|
5ecac4223d | ||
|
|
215c21ad8a | ||
|
|
5772de888c | ||
|
|
55979e90dc | ||
|
|
5785f5beea | ||
|
|
e8bb256a8d | ||
|
|
729a563545 | ||
|
|
1b38ed5c78 | ||
|
|
483aea5c4f | ||
|
|
a64d493a29 | ||
|
|
2a8d436267 | ||
|
|
7905f82d65 | ||
|
|
dcf82d041a | ||
|
|
9618bd891f | ||
|
|
c63f9de5c5 | ||
|
|
0e6113f0a6 | ||
|
|
71cf85f535 | ||
|
|
2a4f646181 | ||
|
|
0cc326836c | ||
|
|
52b8bc8909 | ||
|
|
844a7b455c | ||
|
|
489a0b6fb8 | ||
|
|
e535133eca | ||
|
|
ea2be7609c | ||
|
|
011d9d639b | ||
|
|
e78e9d8e55 | ||
|
|
89762cad78 | ||
|
|
4788562241 | ||
|
|
5b1ad450d3 | ||
|
|
7b6d8671cf | ||
|
|
01631860f4 | ||
|
|
c65e76bbc3 | ||
|
|
ef35e1cfd9 | ||
|
|
1d535b5d61 | ||
|
|
004cb20132 | ||
|
|
909bdf60e7 | ||
|
|
0cd3bea6bd | ||
|
|
d001a0de15 | ||
|
|
0dca7acee6 | ||
|
|
b5ad7a1721 | ||
|
|
9f23b911c1 | ||
|
|
1db8bb4d13 | ||
|
|
eebafda9e5 | ||
|
|
0fb57a0a2c | ||
|
|
d4c55620f1 | ||
|
|
ef26567850 | ||
|
|
c15c43dba4 | ||
|
|
5d738d99fe | ||
|
|
43120b0017 | ||
|
|
23dc82f042 | ||
|
|
49330536c7 | ||
|
|
781fa7ea1b | ||
|
|
bf17312a5f | ||
|
|
e4da8d4f15 | ||
|
|
cc26bd09e6 | ||
|
|
9dc1c5c9e9 | ||
|
|
442ae94ad5 | ||
|
|
43820f71a3 | ||
|
|
63920e034a | ||
|
|
cddc47305f | ||
|
|
583bebd10c | ||
|
|
7fe9a6c900 | ||
|
|
670e457dc6 | ||
|
|
300d8224ec | ||
|
|
924f5320bb | ||
|
|
dd09fb2283 | ||
|
|
3e18af626b | ||
|
|
89dd5b79d6 | ||
|
|
356f71f13e | ||
|
|
2f5d71a299 | ||
|
|
b581c12edb | ||
|
|
d4d6aeb0b4 | ||
|
|
77114e6cfc | ||
|
|
e14a078440 | ||
|
|
3b38a0d628 | ||
|
|
927d8cb6c9 | ||
|
|
eb8ea2f549 | ||
|
|
208c93bc8f | ||
|
|
93180faa23 | ||
|
|
816858f231 | ||
|
|
fa1d68848f | ||
|
|
bce955a1e1 | ||
|
|
82f70e0ac9 | ||
|
|
fc9b78cfef | ||
|
|
72400a48da | ||
|
|
537b39b3c4 | ||
|
|
47e6e48729 | ||
|
|
d252229777 | ||
|
|
7f4c7f607d | ||
|
|
994ba5dd1a | ||
|
|
e3a06b28dd | ||
|
|
10d512470e | ||
|
|
c1d8040fd5 | ||
|
|
e4b81da386 | ||
|
|
fd7360e6f4 | ||
|
|
62f15e218e | ||
|
|
5c1b91f348 | ||
|
|
378cbd580f | ||
|
|
3994f14010 | ||
|
|
e7f4e743e3 | ||
|
|
b934ce2893 | ||
|
|
5eec076ea2 | ||
|
|
ada36ebff5 | ||
|
|
d9543ca23c | ||
|
|
3871eb3c84 | ||
|
|
4ba696d289 | ||
|
|
2f69e0b96c | ||
|
|
d6b0c56c35 | ||
|
|
d8fe983b9d | ||
|
|
76079faca0 | ||
|
|
5d5c62123c | ||
|
|
6c7b2224b1 | ||
|
|
4d80ae2372 | ||
|
|
c651b60c59 | ||
|
|
90b39d075d | ||
|
|
5099c7e462 | ||
|
|
2f8b5dd229 | ||
|
|
7e427605ab | ||
|
|
512e640c13 | ||
|
|
acb1c6cc99 | ||
|
|
d01c3ff9ca | ||
|
|
3720644153 | ||
|
|
630cfb6769 | ||
|
|
f3061ed643 | ||
|
|
2556c037ba | ||
|
|
0b4626a5a2 |
68
README.md
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
<h4 align="center">一套与SqlSugar一样爽的.Net6开源框架</h4>
|
||||
<h2 align="center">集大成者,终究轮子</h2>
|
||||
|
||||
[English](README-en.md) | 简体中文
|
||||
@@ -10,7 +10,11 @@
|
||||
|
||||
****
|
||||
### 简介:
|
||||
**中文:意框架**(和他的名字一样“简易”)
|
||||
**中文:意框架**(和他的名字一样“简易”,同时接入Java的Ruoyi Vue3.0前端)
|
||||
|
||||
模块分化较多,可根据业务自行引用或抛弃,集大成者,大而全乎,也许你能从中学习到一些独特见解
|
||||
|
||||
正在持续更进业务模块,已接入ruoyi
|
||||
|
||||
**英文:YiFramework**
|
||||
|
||||
@@ -20,7 +24,7 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
|
||||
适合.Net6学习、Sqlsugar学习 、项目二次开发。
|
||||
集大成者,终究轮子
|
||||
|
||||
Yi框架最新版本标签:`v1.0.4`
|
||||
Yi框架最新版本标签:`v1.2.0`,具体版本可以查看标签迭代
|
||||
|
||||
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
|
||||
|
||||
@@ -28,11 +32,19 @@ Yi框架最新版本标签:`v1.0.4`
|
||||
|
||||
**分支**:
|
||||
|
||||
(本项目由EFCore版本历经3年不断迭代至Sqlsugar版本,现EFcore版本已弃用,目前sqlsugar不带任何业务,之后会更新业务功能)
|
||||
(本项目由EFCore版本历经3年不断迭代至Sqlsugar版本,现EFcore版本已弃用,目前sqlsugar已带业务功能)
|
||||
|
||||
**SqlSugar**:.Net6 DDD领域驱动设计 简单分层微服务架构
|
||||
|
||||
**ec**:EFcore完整电商项目
|
||||
- Yi.Framework.Net6:.NetCore 6 意框架
|
||||
|
||||
- Yi.Vue3.X.RuoYi:Vue3 RuoYi前端框架
|
||||
|
||||
(你没有听错,已经接入java流行指数最高最火爆的框架之一,与其他框架不同,Yi框架后端为完全重制版,并非为ruoyi java模仿版)
|
||||
|
||||
**SqlSugar-Dev**:为sqlsugar分支的实时开发版本
|
||||
|
||||
~~**ec**: EFcore完整电商项目~~
|
||||
|
||||
****
|
||||
|
||||
@@ -72,7 +84,7 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数
|
||||
|
||||
**身份验证**:JWT、IdentityServer4
|
||||
|
||||
**组件**:~~EFcore~~SqlSugar、Autofac、Castle、Swagger、Log4Net、Redis、RabbitMq、ES、Quartz.net、~~T4~~
|
||||
**组件**:SqlSugar、Autofac、Castle、Swagger、Log4Net、Redis、RabbitMq、ES、Quartz.net、~~T4~~
|
||||
|
||||
**分布式**:CAP、Lock
|
||||
|
||||
@@ -81,7 +93,37 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数
|
||||
**封装**:Json处理模块,滑动验证码模块,base64图片处理模块,异常捕捉模块、邮件处理模块、linq封装模块、随机数模块、统一接口模块、基于策略的jwt验证、过滤器、数据库连接、跨域、初始化种子数据、Base32、Console输出、日期处理、文件传输、html筛选、http请求、ip过滤、md5加密、Rsa加密、序列化、雪花算法、字符串处理、编码处理、地址处理、xml处理、心跳检查。。。
|
||||
|
||||
****
|
||||
### 支持模块:
|
||||
<h3>业务支持模块</h3>
|
||||
|
||||
(大部分ruoyi功能,采用ruoyi前端)
|
||||
|
||||
- 用户管理
|
||||
|
||||
- 角色管理
|
||||
|
||||
- 菜单管理
|
||||
|
||||
- 部门管理
|
||||
|
||||
- 岗位管理
|
||||
|
||||
- 字典管理
|
||||
|
||||
- 参数管理
|
||||
|
||||
- 用户在线
|
||||
|
||||
- 操作日志
|
||||
|
||||
- 登录日志
|
||||
|
||||
- 等等
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### 框架支持模块:
|
||||
|
||||
大致如图:
|
||||
|
||||
@@ -94,9 +136,8 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数
|
||||
- [x] 支持采用`异步`开发awit/async
|
||||
- [x] 支持数据库主从`读写分离`
|
||||
- [x] 支持功能替换,无需改动代码,只需配置`json文件`进行装配即可
|
||||
- [x] ~~-支持采用DbFirst开发方式,使用`T4模板代码生成器`,自动映射模型一键生成Service及IService所有代码~~
|
||||
- [x] 支持WebFirst,无需改动代码,自动生成全套代码与数据库,只需点点点
|
||||
- [x] ~~-支持`用户-角色-菜单-接口`以及vue2.0前端全部逻辑代码,下载无需修改直接使用~~
|
||||
- [x] 支持`用户-角色-菜单-接口`以及vue2.0前端全部逻辑代码,下载无需修改直接使用
|
||||
- [x] 支持`Aop封装`,FilterAop、IocAop、LogAop、SqlAop
|
||||
- [x] 支持`Log4Net日志`记录,自动生成至bin目录下的logs文件夹
|
||||
- [x] 支持`DbSeed数据库种子数据`接入
|
||||
@@ -112,7 +153,6 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数
|
||||
- [x] 支持`Ocelot`网关,路由、服务聚合、服务发现、认证、鉴权、限流、熔断、缓存、Header头传递
|
||||
- [x] 支持`Apollo`全局配置中心;
|
||||
- [x] 支持`docker`镜像制作
|
||||
- [x] ~~-支持页面`静态化处理`,将动态页面生成静态页面~~
|
||||
- [x] 支持`Quartz.net`任务调度,实现任意接口被调度
|
||||
- [x] 支持`ELK`,log4net+kafka+es+logstach+kibana
|
||||
- [x] 支持`IdentityService4`授权中心
|
||||
@@ -122,7 +162,7 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数
|
||||
- [x] 支持`Docker+k8s`部署
|
||||
- [x] 支持`Jenkins+CI/CD`
|
||||
- [x] 支持`AutoMapper`模块映射
|
||||
- [ ] 支持`微信支付`(没账号)
|
||||
- [x] 支持`微信支付`
|
||||
- [x] 支持`单表多租户`常用功能
|
||||
- [x] 支持`逻辑删除`常用功能
|
||||
- [x] 支持`操作日志`常用功能
|
||||
@@ -190,7 +230,9 @@ WebFirst开发:所有代码生成器已经配置完成,无需任何操作数
|
||||
****
|
||||
### 联系我们:
|
||||
|
||||
作者QQ:454313500
|
||||
作者QQ:`454313500`,2029年之前作者24小时在线,时刻保持活跃更新。
|
||||
|
||||
QQ交流群:官方一群(已满)、官方二群(已满)、官方三群:`786308927`(加作者QQ后同意)
|
||||
|
||||
联系作者,这里人人都是顾问
|
||||
|
||||
|
||||
BIN
Readme/用户管理.png
Normal file
|
After Width: | Height: | Size: 79 KiB |
BIN
Readme/菜单管理.png
Normal file
|
After Width: | Height: | Size: 153 KiB |
@@ -6,9 +6,82 @@
|
||||
<members>
|
||||
<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.LoginDto)">
|
||||
<summary>
|
||||
没啥说,登录
|
||||
</summary>
|
||||
<param name="loginDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Register(Yi.Framework.DTOModel.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.UpdateUserByHttp(Yi.Framework.Model.Models.UserEntity)">
|
||||
<summary>
|
||||
更新已登录用户的用户信息
|
||||
</summary>
|
||||
<param name="user"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.UpdatePassword(Yi.Framework.DTOModel.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.ArticleController.PageList(Yi.Framework.Model.Models.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.Models.ArticleEntity)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Yi.Framework.ApiMicroservice.Controllers.BaseCrudController`1">
|
||||
<summary>
|
||||
Json To Sql 类比模式,通用模型
|
||||
@@ -56,6 +129,177 @@
|
||||
<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.ConfigController.PageList(Yi.Framework.Model.Models.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.Models.DeptEntity)">
|
||||
<summary>
|
||||
动态条件查询
|
||||
</summary>
|
||||
<param name="dept"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.Add(Yi.Framework.Model.Models.DeptEntity)">
|
||||
<summary>
|
||||
添加
|
||||
</summary>
|
||||
<param name="entity"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.DeptController.Update(Yi.Framework.Model.Models.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.Models.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.Models.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.IFileService,Microsoft.Extensions.Hosting.IHostEnvironment)">
|
||||
<summary>
|
||||
文件上传下载
|
||||
</summary>
|
||||
<param name="iFileService"></param>
|
||||
<param name="env"></param>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Get(System.Int64)">
|
||||
<summary>
|
||||
文件下载,只需用文件code即可
|
||||
</summary>
|
||||
<param name="code"></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.LogController.Add">
|
||||
<summary>
|
||||
自动分表,日志添加
|
||||
@@ -68,11 +312,156 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.LoginLogController.PageList(Yi.Framework.Model.Models.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.Models.MenuEntity)">
|
||||
<summary>
|
||||
动态条件查询全部
|
||||
</summary>
|
||||
<param name="menu"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.Add(Yi.Framework.Model.Models.MenuEntity)">
|
||||
<summary>
|
||||
插入
|
||||
</summary>
|
||||
<param name="menu"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.Update(Yi.Framework.Model.Models.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.Models.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.Models.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.Models.RoleEntity,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
动态条件分页查询
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.GiveRoleSetMenu(Yi.Framework.DTOModel.GiveRoleSetMenuDto)">
|
||||
<summary>
|
||||
给多用户设置多角色
|
||||
</summary>
|
||||
<param name="giveRoleSetMenuDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.Add(Yi.Framework.DTOModel.RoleInfoDto)">
|
||||
<summary>
|
||||
添加角色包含菜单
|
||||
</summary>
|
||||
<param name="roleDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.RoleController.Update(Yi.Framework.DTOModel.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.RoleInfoDto)">
|
||||
<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.Model.Models.UserEntity},Yi.Framework.Interface.IRoleService,Yi.Framework.Interface.IUserService,Microsoft.Extensions.Localization.IStringLocalizer{Yi.Framework.Language.LocalLanguage},Yi.Framework.Core.QuartzInvoker)">
|
||||
<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>
|
||||
</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>
|
||||
仓储上下文对象测试
|
||||
@@ -121,11 +510,113 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.stopJob">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.TestController.StopJob">
|
||||
<summary>
|
||||
停止任务
|
||||
</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="T:Yi.Framework.ApiMicroservice.Controllers.UserController">
|
||||
<summary>
|
||||
用户管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.PageList(Yi.Framework.Model.Models.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.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.UserInfoDto)">
|
||||
<summary>
|
||||
更新用户信息
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.UpdateProfile(Yi.Framework.DTOModel.UserInfoDto)">
|
||||
<summary>
|
||||
更新个人中心信息
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.Add(Yi.Framework.DTOModel.UserInfoDto)">
|
||||
<summary>
|
||||
添加用户
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.RestPassword(Yi.Framework.Model.Models.UserEntity)">
|
||||
<summary>
|
||||
重置密码
|
||||
</summary>
|
||||
<param name="user"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
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.DTOModel;
|
||||
@@ -18,32 +22,78 @@ using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 账户控制器
|
||||
/// 账户管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class AccountController :ControllerBase
|
||||
public class AccountController : ControllerBase
|
||||
{
|
||||
private IUserService _iUserService;
|
||||
private IUserService _iUserService;
|
||||
private JwtInvoker _jwtInvoker;
|
||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
|
||||
private ILogger _logger;
|
||||
private SecurityCodeHelper _securityCode;
|
||||
private IRepository<UserEntity> _repository;
|
||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker, SecurityCodeHelper securityCode)
|
||||
{
|
||||
_iUserService = iUserService;
|
||||
_jwtInvoker = jwtInvoker;
|
||||
_logger = logger;
|
||||
_securityCode = securityCode;
|
||||
_repository = iUserService._repository;
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
UserEntity user=new();
|
||||
if (await _iUserService.Login(loginDto.UserName, loginDto.Password,o=> user=o))
|
||||
//跳过,需要redis缓存获取uuid与code的关系,进行比较即可
|
||||
//先效验验证码和UUID
|
||||
//登录还需要进行登录日志的落库
|
||||
|
||||
var loginInfo = HttpContext.GetLoginLogInfo();
|
||||
loginInfo.LoginUser = loginDto.UserName;
|
||||
loginInfo.LogMsg = "登录成功!";
|
||||
var loginLogRepository = _repository.ChangeRepository<Repository<LoginLogEntity>>();
|
||||
UserEntity user = new();
|
||||
if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o))
|
||||
{
|
||||
return Result.Success("登录成功!").SetData(new { user, token = _jwtInvoker.GetAccessToken(user)});
|
||||
var userRoleMenu = await _iUserService.GetUserAllInfo(user.Id);
|
||||
await loginLogRepository.InsertReturnSnowflakeIdAsync(loginInfo);
|
||||
return Result.Success(loginInfo.LogMsg).SetData(new { token = _jwtInvoker.GetAccessToken(userRoleMenu.User, userRoleMenu.Menus) });
|
||||
}
|
||||
return Result.SuccessError("登录失败!用户名或者密码错误!");
|
||||
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)
|
||||
@@ -55,5 +105,107 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
}
|
||||
return Result.SuccessError("注册失败!用户名已存在!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 没啥说,登出
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public Result Logout()
|
||||
{
|
||||
return Result.Success("安全登出成功!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过已登录的用户获取用户信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//[Authorize]
|
||||
public async Task<Result> GetUserAllInfo()
|
||||
{
|
||||
//通过鉴权jwt获取到用户的id
|
||||
var userId = HttpContext.GetUserIdInfo();
|
||||
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="user"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateUserByHttp(UserEntity user)
|
||||
{
|
||||
//当然,密码是不能给他修改的
|
||||
user.Password = null;
|
||||
user.Salt = null;
|
||||
|
||||
//修改需要赋值上主键哦
|
||||
user.Id = HttpContext.GetUserIdInfo();
|
||||
return Result.Success().SetStatus(await _iUserService._repository.UpdateIgnoreNullAsync(user));
|
||||
}
|
||||
|
||||
/// <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比对即可
|
||||
var imgbyte = _securityCode.GetEnDigitalCodeByte(code);
|
||||
return Result.Success().SetData(new { uuid = uuid, img = imgbyte });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
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;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
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 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)
|
||||
{
|
||||
entity.UserId = HttpContext.GetUserIdInfo();
|
||||
return base.Add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Language;
|
||||
@@ -15,16 +16,14 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[ApiController]
|
||||
public class BaseCrudController<T> : ControllerBase where T : class, IBaseModelEntity,new()
|
||||
public class BaseCrudController<T> : BaseExcelController<T> where T : class,new()
|
||||
{
|
||||
private readonly ILogger<T> _logger;
|
||||
private IBaseService<T> _baseService;
|
||||
private IRepository<T> _repository;
|
||||
public BaseCrudController(ILogger<T> logger, IBaseService<T> iBaseService)
|
||||
protected readonly ILogger<T> _logger;
|
||||
protected IBaseService<T> _baseService;
|
||||
public BaseCrudController(ILogger<T> logger, IBaseService<T> iBaseService):base(iBaseService._repository)
|
||||
{
|
||||
_logger = logger;
|
||||
_baseService = iBaseService;
|
||||
_repository = iBaseService._repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -32,9 +31,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:one")]
|
||||
[HttpGet]
|
||||
public async Task<Result> GetById(long id)
|
||||
public virtual async Task<Result> GetById(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetByIdAsync(id));
|
||||
}
|
||||
@@ -43,9 +41,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// 列表查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:list")]
|
||||
[HttpPost]
|
||||
public async Task<Result> GetList(QueryCondition queryCondition)
|
||||
public virtual async Task<Result> GetList(QueryCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.GetListAsync(queryCondition));
|
||||
}
|
||||
@@ -55,9 +52,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <param name="queryCondition"></param>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:get:page")]
|
||||
[HttpPost]
|
||||
public async Task<Result> PageList(QueryPageCondition queryCondition)
|
||||
public virtual async Task<Result> PageList(QueryPageCondition queryCondition)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.CommonPageAsync(queryCondition));
|
||||
}
|
||||
@@ -67,9 +63,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:add")]
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(T entity)
|
||||
public virtual async Task<Result> Add(T entity)
|
||||
{
|
||||
return Result.Success().SetData(await _repository.InsertReturnSnowflakeIdAsync(entity));
|
||||
}
|
||||
@@ -79,9 +74,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:update")]
|
||||
[HttpPut]
|
||||
public async Task<Result> Update(T entity)
|
||||
public virtual async Task<Result> Update(T entity)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.UpdateIgnoreNullAsync(entity));
|
||||
}
|
||||
@@ -91,11 +85,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[Permission($"{nameof(T)}:delete:list")]
|
||||
[HttpDelete]
|
||||
public async Task<Result> DeleteList(List<long> ids)
|
||||
public virtual async Task<Result> DeleteList(List<long> ids)
|
||||
{
|
||||
return Result.Success().SetStatus(await _repository.DeleteByLogicAsync(ids));
|
||||
return Result.Success().SetStatus(await _repository.DeleteByIdAsync(ids.ToDynamicArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
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.Model.Models;
|
||||
using Yi.Framework.Model.Query;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.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 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>
|
||||
[Permission($"{nameof(T)}:get")]
|
||||
[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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Helper;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Language;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Model.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 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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.Model.Models;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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.Model.Models;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
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.Model.Models;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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.Model.Models;
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
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.Models;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// 文件上传下载
|
||||
/// </summary>
|
||||
/// <param name="iFileService"></param>
|
||||
/// <param name="env"></param>
|
||||
public FileController(IFileService iFileService, IHostEnvironment env)
|
||||
{
|
||||
_iFileService = iFileService;
|
||||
_env = env;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件下载,只需用文件code即可
|
||||
/// </summary>
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
[Route("/api/file/{code}")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Get(long code)
|
||||
{
|
||||
var file = await _iFileService._repository.GetByIdAsync(code);
|
||||
if (file is null)
|
||||
{
|
||||
return new NotFoundResult();
|
||||
}
|
||||
try
|
||||
{
|
||||
//路径为: 文件路径/文件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)
|
||||
{
|
||||
if (type is null)
|
||||
{
|
||||
type = PathEnum.File.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
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.Write))
|
||||
{
|
||||
await f.CopyToAsync(stream);
|
||||
}
|
||||
//将文件信息添加到数据库
|
||||
datas.Add(data);
|
||||
codes.Add(data.Id);
|
||||
}
|
||||
return Result.Success().SetData(codes).SetStatus(await _iFileService._repository.InsertRangeAsync(datas));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Result.Error();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,10 +35,10 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
Random random = new Random();
|
||||
var logList = new List<LogEntity>() {
|
||||
new LogEntity() { LogCreateTime = Convert.ToDateTime("2019-12-1"), Message = "jack"+random.Next() } ,
|
||||
new LogEntity() { LogCreateTime = Convert.ToDateTime("2022-02-1"), Message = "jack"+random.Next() },
|
||||
new LogEntity() { LogCreateTime = Convert.ToDateTime("2020-02-1"), Message = "jack"+random.Next() },
|
||||
new LogEntity() { LogCreateTime = Convert.ToDateTime("2021-12-1"), Message = "jack"+random.Next() } };
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
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.Model.Models;
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,14 +15,75 @@ using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class MenuController : BaseCrudController<MenuEntity>
|
||||
public class MenuController: BaseSimpleRdController<MenuEntity>
|
||||
{
|
||||
private IMenuService _iMenuService;
|
||||
public MenuController(ILogger<MenuEntity> logger, IMenuService iMenuService) : base(logger, iMenuService)
|
||||
public MenuController(ILogger<MenuEntity> logger, IMenuService iMenuService):base(logger,iMenuService)
|
||||
{
|
||||
_iMenuService = iMenuService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件查询全部
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
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]
|
||||
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]
|
||||
public async Task<Result> Update(MenuEntity menu)
|
||||
{
|
||||
//注意,这里如果是主目录,还需要判断/,需要以/开头
|
||||
return Result.Success().SetData(await _iMenuService._repository.UpdateIgnoreNullAsync(menu));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 得到树形菜单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetMenuTree()
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.GetMenuTreeAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色id获取该角色下全部菜单
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> GetListByRoleId(long id)
|
||||
{
|
||||
return Result.Success().SetData(await _iMenuService.GetListByRoleId(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
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.Model.Models;
|
||||
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("操作失败!未发现该连接!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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.Model.Models;
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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.Model.Models;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,95 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Models;
|
||||
using Yi.Framework.DTOModel;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
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 : BaseCrudController<RoleEntity>
|
||||
public class RoleController : BaseSimpleRdController<RoleEntity>
|
||||
{
|
||||
private IRoleService _iRoleService;
|
||||
public RoleController(ILogger<RoleEntity> logger, IRoleService iRoleService) : base(logger, iRoleService)
|
||||
{
|
||||
_iRoleService = iRoleService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 动态条件分页查询
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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]
|
||||
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>
|
||||
|
||||
[HttpPost]
|
||||
public async Task<Result> Add(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetData(await _iRoleService.AddInfo(roleDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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>
|
||||
[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>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateDataScpoce(RoleInfoDto roleDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iRoleService.UpdateDataScpoce(roleDto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Localization;
|
||||
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.Models;
|
||||
using Yi.Framework.Core;
|
||||
@@ -16,6 +18,8 @@ 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
|
||||
{
|
||||
@@ -30,13 +34,34 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
private IUserService _iUserService;
|
||||
private IRoleService _iRoleService;
|
||||
private QuartzInvoker _quartzInvoker;
|
||||
private IHubContext<MainHub> _hub;
|
||||
//你可以依赖注入服务层各各接口,也可以注入其他仓储层,怎么爽怎么来!
|
||||
public TestController(ILogger<UserEntity> logger, IRoleService iRoleService, IUserService iUserService, IStringLocalizer<LocalLanguage> local, QuartzInvoker quartzInvoker)
|
||||
/// <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>
|
||||
public TestController(IHubContext<MainHub> hub , ILogger<UserEntity> logger, IRoleService iRoleService, IUserService iUserService, IStringLocalizer<LocalLanguage> local, QuartzInvoker quartzInvoker)
|
||||
{
|
||||
_local = local;
|
||||
_iUserService = iUserService;
|
||||
_iRoleService = iRoleService;
|
||||
_quartzInvoker = quartzInvoker;
|
||||
_hub = hub;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// swagger跳转
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("/")]
|
||||
public IActionResult Swagger()
|
||||
{
|
||||
return Redirect("/Swagger");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -45,7 +70,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
// 特点:化繁为简!意框架仓储代理上下文对象,用起来就是爽,但最好按规范来爽!
|
||||
// 规范:控制器不建议使用切换仓储方法、控制器严禁使用DB上下文对象,其它怎么爽怎么来!
|
||||
// 规范:控制器严禁使用DB上下文对象,其它怎么爽怎么来!
|
||||
public async Task<Result> DbTest()
|
||||
{
|
||||
//非常好,使用UserService的特有方法
|
||||
@@ -60,11 +85,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
//挺不错,依赖注入其他仓储
|
||||
await _iRoleService._repository.GetListAsync();
|
||||
|
||||
//不建议操作,直接切换其他仓储
|
||||
//还行,直接切换其他仓储,怎么爽怎么来
|
||||
await _iUserService._repository.ChangeRepository<Repository<RoleEntity>>().GetListAsync();
|
||||
|
||||
//直接操作Db对象???恭喜你已经毕业了!此后将有一天,接手到这个的软件的程序员将破口大骂。
|
||||
//最好不要在控制器直接操作Db对象
|
||||
await _iUserService._repository._Db.Queryable<UserEntity>().ToListAsync();
|
||||
await _iUserService._repository._DbQueryable.ToListAsync();
|
||||
|
||||
return Result.Success().SetData(await _iUserService.DbTest());
|
||||
}
|
||||
@@ -74,7 +100,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
//简单语句不推荐!
|
||||
//简单语句不推荐使用sql!
|
||||
public async Task<Result> SqlTest()
|
||||
{
|
||||
return Result.Success().SetData(await _iUserService._repository.UseSqlAsync<UserEntity>("select * from User"));
|
||||
@@ -165,7 +191,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{JobConst.method,"get" },
|
||||
{JobConst.url,"https://www.baidu.com" }
|
||||
};
|
||||
await _quartzInvoker.start("*/5 * * * * ?", new Quartz.JobKey("test", "my"), "Yi.Framework.Job", "HttpJob", data: data);
|
||||
await _quartzInvoker.StartAsync("*/5 * * * * ?", "HttpJob", jobName: "test", jobGroup: "my", data: data);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
@@ -174,10 +200,100 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> stopJob()
|
||||
public async Task<Result> StopJob()
|
||||
{
|
||||
await _quartzInvoker.Stop(new Quartz.JobKey("test", "my"));
|
||||
await _quartzInvoker.StopAsync(new Quartz.JobKey("test", "my"));
|
||||
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.Invoer(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任务与公告管理
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,12 @@ 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;
|
||||
using Yi.Framework.Interface;
|
||||
using Yi.Framework.Model.Models;
|
||||
using Yi.Framework.Repository;
|
||||
@@ -15,14 +20,152 @@ using Yi.Framework.WebCore.AuthorizationPolicy;
|
||||
|
||||
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户管理
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
[Route("api/[controller]/[action]")]
|
||||
public class UserController : BaseCrudController<UserEntity>
|
||||
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)
|
||||
{
|
||||
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,3 +1,4 @@
|
||||
global using System;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Yi.Framework.WebCore.BuilderExtend;
|
||||
using Yi.Framework.Core;
|
||||
@@ -8,6 +9,12 @@ 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 Yi.Framework.WebCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Yi.Framework.WebCore.DbExtend;
|
||||
using IPTools.Core;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddCommandLine(args);
|
||||
@@ -24,17 +31,21 @@ builder.Host.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder
|
||||
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
||||
builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
|
||||
{
|
||||
|
||||
#region
|
||||
//交由Module依赖注入
|
||||
#endregion
|
||||
containerBuilder.RegisterModule<CustomAutofacModule>();
|
||||
#region
|
||||
//使用AppService特性优雅的进行自动依赖注入,仓储与基类服务便是使用该种方式自动注入
|
||||
#endregion
|
||||
containerBuilder.AddAutoIocService("Yi.Framework.Repository", "Yi.Framework.Service");
|
||||
});
|
||||
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");
|
||||
|
||||
});
|
||||
#region
|
||||
//配置类配置
|
||||
@@ -49,9 +60,10 @@ builder.Host.ConfigureLogging(loggingBuilder =>
|
||||
#endregion
|
||||
builder.Services.AddIocService(builder.Configuration);
|
||||
#region
|
||||
//Sqlsugar上下文注入
|
||||
//Sqlsugar上下文注入,是否开启数据权限功能,开启需要Redis缓存
|
||||
#endregion
|
||||
builder.Services.AddSqlsugarServer();
|
||||
//builder.Services.AddSqlsugarServer(DbFiterExtend.Data);
|
||||
#region
|
||||
//Quartz任务调度配置
|
||||
#endregion
|
||||
@@ -64,12 +76,16 @@ builder.Services.AddAutoMapperService();
|
||||
//控制器+过滤器配置
|
||||
#endregion
|
||||
builder.Services.AddControllers(optios => {
|
||||
//optios.Filters.Add<PermissionAttribute>();
|
||||
//注册全局
|
||||
optios.Filters.Add<GlobalLogAttribute>();
|
||||
}).AddJsonFileService();
|
||||
#region
|
||||
//权限过滤器
|
||||
#endregion
|
||||
//权限
|
||||
builder.Services.AddSingleton<PermissionAttribute>();
|
||||
//日志
|
||||
builder.Services.AddSingleton<GlobalLogAttribute>();
|
||||
#region
|
||||
//Swagger服务配置
|
||||
#endregion
|
||||
@@ -110,6 +126,19 @@ builder.Services.AddCAPService();
|
||||
//国际化配置
|
||||
#endregion
|
||||
builder.Services.AddLocalizerService();
|
||||
#region
|
||||
//添加signalR
|
||||
#endregion
|
||||
builder.Services.AddSignalR();
|
||||
#region
|
||||
//添加验证码
|
||||
#endregion
|
||||
builder.Services.AddHeiCaptcha();
|
||||
#region
|
||||
//添加Http上下文
|
||||
#endregion
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
var app = builder.Build();
|
||||
#region
|
||||
@@ -131,6 +160,7 @@ ServiceLocator.Instance = app.Services;
|
||||
//错误抓取反馈注入
|
||||
#endregion
|
||||
app.UseErrorHandlingService();
|
||||
|
||||
#region
|
||||
//静态文件注入
|
||||
#endregion
|
||||
@@ -139,6 +169,11 @@ app.UseStaticFiles();
|
||||
//多语言国际化注入
|
||||
#endregion
|
||||
app.UseLocalizerService();
|
||||
|
||||
#region
|
||||
//上下文请求body
|
||||
#endregion
|
||||
app.UseHttpBodyService();
|
||||
#region
|
||||
//HttpsRedirection注入
|
||||
#endregion
|
||||
@@ -167,15 +202,23 @@ app.UseAuthorization();
|
||||
//Consul服务注入
|
||||
#endregion
|
||||
app.UseConsulService();
|
||||
|
||||
#region
|
||||
//数据库种子注入
|
||||
#endregion
|
||||
app.UseDbSeedInitService();
|
||||
#region
|
||||
//redis种子注入
|
||||
#endregion
|
||||
app.UseRedisSeedInitService();
|
||||
#region
|
||||
//Endpoints注入
|
||||
#endregion
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
#region
|
||||
//SignalR配置
|
||||
#endregion
|
||||
endpoints.MapHub<MainHub>("/api/hub/main");
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
|
||||
app.Run();
|
||||
@@ -2,7 +2,8 @@
|
||||
"profiles": {
|
||||
"Yi.Framework.ApiMicroservice": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
//开发环境根据情况是否自动启动浏览器,个人感觉开开关关比较麻烦
|
||||
"launchBrowser": false,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
|
||||
@@ -21,16 +21,25 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.DTOModel\Yi.Framework.DTOModel.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Interface\Yi.Framework.Interface.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Service\Yi.Framework.Service.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.WebCore\Yi.Framework.WebCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\file\" />
|
||||
<Folder Include="wwwroot\image\" />
|
||||
<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>
|
||||
<None Update="yi-sqlsugar-dev.db">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -10,12 +10,10 @@
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"Consul_Enabled": false,
|
||||
"DbSeed_Enabled": false,
|
||||
"Apollo_Enabled": false,
|
||||
"HealthCheck_Enabled": false,
|
||||
"RabbitMQ_Enabled": false,
|
||||
"Redis_Enabled": false,
|
||||
"RedisSeed_Enabled": false,
|
||||
"Kafka_Enabled": false,
|
||||
"ElasticSeach_Enabled": false,
|
||||
"MutiDB_Enabled": false,
|
||||
@@ -23,57 +21,60 @@
|
||||
"CAP_Enabled": false,
|
||||
"CAPDashboard_Enabled": false,
|
||||
|
||||
"DbSeed_Enabled": true,
|
||||
"RedisSeed_Enabled": false,
|
||||
|
||||
"Cors_Enabled": true,
|
||||
"DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
|
||||
"DbSelect": "Mysql",
|
||||
"Pan": {
|
||||
"ZipPath": "D:/AppWeb/test/zip"
|
||||
},
|
||||
|
||||
"DbSelect": "Sqlite",
|
||||
"DbConn": {
|
||||
//"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
|
||||
"WriteUrl": "server=[xxxx];port=3306;database=[xxxx];user id=[xxxx];password=[xxxx]",
|
||||
"WriteUrl": "DataSource=yi-sqlsugar-dev.db",
|
||||
//"WriteUrl": "server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020.",
|
||||
"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]"
|
||||
"server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020.",
|
||||
"server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020.",
|
||||
"server=119.91.207.67;port=3306;database=yi-sqlsugar-dev;user id=root;password=Qz52013142020."
|
||||
]
|
||||
},
|
||||
"JWTTokenOptions": {
|
||||
"Audience": "http://localhost:7000",
|
||||
"Issuer": "http://localhost:7000",
|
||||
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
|
||||
"JwtAuthorize": {
|
||||
"Issuer": "cc",
|
||||
"Audience": "cc",
|
||||
"PolicyName": "permission",
|
||||
"DefaultScheme": "Bearer",
|
||||
"IsHttps": false,
|
||||
"Expiration": 30,
|
||||
"ReExpiration": 3000
|
||||
},
|
||||
"RedisConnOptions": {
|
||||
"Host": "[xxxx]",
|
||||
"Host": "118.195.191.41",
|
||||
"Prot": 6379,
|
||||
"DB": 1,
|
||||
"Password": "[xxxx]"
|
||||
"Password": "Qz52013142020."
|
||||
},
|
||||
"RabbitConn": {
|
||||
"HostName": "[xxxx]",
|
||||
"UserName": "[xxxx]",
|
||||
"Password": "[xxxx]",
|
||||
"HostName": "118.195.191.41",
|
||||
"UserName": "cc",
|
||||
"Password": "cc",
|
||||
"Port": 5672
|
||||
},
|
||||
"ElasticSeachConn": {
|
||||
"Url": "[xxxx]",
|
||||
"IndexName": "[xxxx]",
|
||||
"UserName": "[xxxx]",
|
||||
"PassWord": "[xxxx]"
|
||||
"Url": "https://es-4zakkyyn.public.tencentelasticsearch.com:9200",
|
||||
"IndexName": "yies",
|
||||
"UserName": "elastic",
|
||||
"PassWord": "Qz52013142020."
|
||||
},
|
||||
"KafkaOptions": {
|
||||
"BrokerList": "[xxxx]",
|
||||
"TopicName": "[xxxx]"
|
||||
"BrokerList": "192.168.3.230:9092",
|
||||
"TopicName": "kafkalog"
|
||||
},
|
||||
"ConsulClientOption": {
|
||||
"IP": "[xxxx]",
|
||||
"Port": "[xxxx]",
|
||||
"Datacenter": "[xxxx]"
|
||||
"IP": "118.195.191.41",
|
||||
"Port": "8500",
|
||||
"Datacenter": "dc1"
|
||||
},
|
||||
"ConsulRegisterOption": {
|
||||
"IP": "[xxxx]",
|
||||
"Port": "19001",
|
||||
"IP": "118.195.191.41",
|
||||
"Port": "19005",
|
||||
"GroupName": "ApiMicroservice",
|
||||
"HealthCheckUrl": "/Health",
|
||||
"Interval": 10,
|
||||
@@ -82,10 +83,10 @@
|
||||
"Tag": "13"
|
||||
},
|
||||
"SMS": {
|
||||
"ID": "[xxxx]",
|
||||
"Secret": "[xxxx]",
|
||||
"Sign": "[xxxx]",
|
||||
"Template": "[xxxx]"
|
||||
"ID": "LTAI5tJvjPaXCyyPMfXLNbVA",
|
||||
"Secret": "fLQv7jjj57fUKLFK8REeAQPFVDjUYn",
|
||||
"Sign": "JiftCC",
|
||||
"Template": "SMS_221640732"
|
||||
},
|
||||
"IPLibraryServiceUrl": "http://gRPCIPLibraryService"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"StartUrl": "http://localohost:19001",
|
||||
"StartUrl": "http://*:19001",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
"PolicyName": "permission",
|
||||
"DefaultScheme": "Bearer",
|
||||
"IsHttps": false,
|
||||
"Expiration": 30,
|
||||
"Expiration": 300,
|
||||
"ReExpiration": 3000
|
||||
},
|
||||
"RedisConnOptions": {
|
||||
|
||||
BIN
Yi.Framework.Net6/Yi.Framework.ApiMicroservice/ip2region.db
Normal file
@@ -0,0 +1,97 @@
|
||||
测试,测试,测试账号,密码123456:
|
||||
sh:LEBG部门管理员,拥有全部权限,最高权限
|
||||
xz: 星能研究所管理员,能查看星能研究所及以下的所有的权限
|
||||
cdb:星能研究所访客测试,除了通用软件框架,其他星能研究所下的权限能看,可自定义配置
|
||||
ccb:通用软件框架部门个人管理员,只能看到自我全权限,范围最小
|
||||
ynb: plc部门管理员,只能看plc部门的权限
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
杨建:c语言开发过学生管理系统,专业能力比较低,不太了解行业,未来规划较模糊。和语言绑定,只要c和c++就可以,抗压能力大。
|
||||
|
||||
张傲:学习期间成绩较好,大概年纪百分之10,在工业界做过相关光伏损伤图形检测。表达思路比较清晰。抗压能力较强,参与多项学硕的项目,担任学院研究生主席。
|
||||
第一年根据公司具体的项目,着手锻炼专业技能,第二年根据公司发展,融入公司。
|
||||
|
||||
黄炳洁:
|
||||
在校经历:
|
||||
在校发表三篇论文,在工业界江苏宁阳公司实习,进行智能电表通信模块的开发与测试,在同事指导下工作。本科成绩前百分之40,硕士成绩前百分之50
|
||||
|
||||
职业规划:
|
||||
第一年对公司业务不太熟悉,需要一定的嵌入式知识的学习。认为第一年会有导师来带项目。
|
||||
工作一年之后,有了经验,第二年绩效考核,进入公司之后刻苦学习。
|
||||
遇到学习上的困难,可以请教别人有经验的人,相信自己可以克服困难。
|
||||
|
||||
问题解答:
|
||||
表达沟通比较吞吐,总结能力不太强。有一定的自学能力
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
杨哲:
|
||||
机械专业面试图像算法
|
||||
1、在校经历
|
||||
机械专业,图像算法方向。本科成绩排名百分之前30,研究生成绩前百分之10。一直在做导师的项目,在工业界没有经验。
|
||||
|
||||
2、职业规划
|
||||
第一年熟悉公司算法库的流程,怎么调用,然后从项目的一部分开始熟悉项目的流程,争取独立完成项目的一部分内容
|
||||
第二年先继续学习算法的内容,争取完成一个项目的经历。
|
||||
遇到困难,有准备,现在目前只能从加班。
|
||||
自学能力比较强,完成度比较高。
|
||||
前期充当学习的角色,后期担当负责人
|
||||
|
||||
|
||||
|
||||
季建杰:
|
||||
1、在校经历
|
||||
做过无人机点源处理,成绩比较靠后,后百分之50。公司内没有无人机相关,不太了解海目星。
|
||||
对于学习新领域的知识,自学去找比较困难,请教身边的人。从事无人机激光测距专业。
|
||||
|
||||
2、职业规划
|
||||
为什么选择这个岗位:因为其他岗位更不了解,这个岗位稍微好点
|
||||
对规划挺少的,不太了解未来
|
||||
只要给的够多,抗压不是问题。
|
||||
自学能力比较强,在校期间基本是自学。
|
||||
性格比较开朗,没有很多突出的地方,比较随和
|
||||
没有说明补充的。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
为什么选择这个岗位
|
||||
目标是什么
|
||||
来海目星担当什么角色
|
||||
抗压能力怎么样
|
||||
自学能力怎么样
|
||||
相比于其他人你的独特的优势是什么
|
||||
|
||||
|
||||
李志刚
|
||||
1、在校经历
|
||||
研究生成绩综合排名前百分之5,实习经历没有,没有在工控行业的经验。学习过(桥梁)缺陷检测
|
||||
|
||||
2、职业规划
|
||||
对于应届生做一个长远规划不太现实
|
||||
前两年主要是学习
|
||||
相比于理论,更喜欢实践。
|
||||
|
||||
碰到不会,以自学为主,最后在找人
|
||||
为什么选择这个岗位:专业对口,能力比较强
|
||||
来海目星担当什么角色:刚开始是学习的角度,积累经验
|
||||
抗压能力怎么样:抗压能力还可以,就业压力,放松心态
|
||||
自学能力怎么样:自学能力在校期间基本都是靠自己自学,主要靠自己搭建自己知识体系
|
||||
|
||||
优势:兴趣,自律,信用
|
||||
沟通比较清楚,有些紧张
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
After Width: | Height: | Size: 181 KiB |
|
After Width: | Height: | Size: 320 KiB |
|
After Width: | Height: | Size: 460 KiB |
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 18 KiB |
@@ -0,0 +1,30 @@
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
432
Yi.Framework.Net6/Yi.Framework.Common/Base/NullValue.cs
Normal file
@@ -0,0 +1,432 @@
|
||||
namespace System
|
||||
{
|
||||
#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,14 +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 FileConst
|
||||
{
|
||||
public const string Image = "Image";
|
||||
public const string File = "File";
|
||||
}
|
||||
}
|
||||
15
Yi.Framework.Net6/Yi.Framework.Common/Const/PathConst.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
16
Yi.Framework.Net6/Yi.Framework.Common/Const/SystemConst.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
17
Yi.Framework.Net6/Yi.Framework.Common/Enum/DataScopeEnum.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
21
Yi.Framework.Net6/Yi.Framework.Common/Enum/HubTypeEnum.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
13
Yi.Framework.Net6/Yi.Framework.Common/Enum/MenuTypeEnum.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum MenuTypeEnum
|
||||
{
|
||||
Catalogue=0, //目录
|
||||
Menu=1, //菜单
|
||||
Component = 2//组件
|
||||
}
|
||||
}
|
||||
21
Yi.Framework.Net6/Yi.Framework.Common/Enum/OperEnum.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
16
Yi.Framework.Net6/Yi.Framework.Common/Enum/PathEnum.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
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,
|
||||
Temp
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Models.Enum
|
||||
namespace Yi.Framework.Common.Enum
|
||||
{
|
||||
public enum ResultCode
|
||||
public enum ResultCodeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作成功。
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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,60 +1,237 @@
|
||||
using System;
|
||||
using OfficeOpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OfficeOpenXml;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 此处来源于ZrAdmin
|
||||
/// </summary>
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class ExcelHelper
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// 导出Excel
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dataList">数据</param>
|
||||
/// <param name="headers">表头</param>
|
||||
/// <returns></returns>
|
||||
public static string CreateExcelFromList<T>(List<T> dataList, List<string> headers,string evn)
|
||||
/// <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;
|
||||
string sWebRootFolder = Path.Combine($"{evn}", "wwwroot/Excel");//如果用浏览器url下载的方式 存放excel的文件夹一定要建在网站首页的同级目录下!!!
|
||||
if (!Directory.Exists(sWebRootFolder))
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(newFileName)!);
|
||||
using (ExcelPackage package = new(new FileInfo(newFileName)))
|
||||
{
|
||||
Directory.CreateDirectory(sWebRootFolder);
|
||||
}
|
||||
string sFileName = $@"Excel_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
|
||||
var path = Path.Combine(sWebRootFolder, sFileName);
|
||||
FileInfo file = new FileInfo(path);
|
||||
if (file.Exists)
|
||||
{
|
||||
file.Delete();
|
||||
file = new FileInfo(path);
|
||||
}
|
||||
using (ExcelPackage package = new(file))
|
||||
{
|
||||
//创建sheet
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("sheet1");
|
||||
worksheet.Cells.LoadFromCollection(dataList, true);
|
||||
//表头字段
|
||||
for (int i = 0; i < headers.Count; i++)
|
||||
{
|
||||
worksheet.Cells[1, i + 1].Value = headers[i];
|
||||
}
|
||||
for (int i = 0; i < headers.Count + 1; i++)
|
||||
{//删除不需要的列
|
||||
string aa = worksheet.Cells[1, i + 1].Value.ToString();
|
||||
if (aa == "总行数")
|
||||
{
|
||||
worksheet.DeleteColumn(i + 1);
|
||||
}
|
||||
}
|
||||
// 添加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 path;//这是返回文件的方式
|
||||
return sFileName; //如果用浏览器url下载的方式 这里直接返回生成的文件名就可以了
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ 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;
|
||||
|
||||
@@ -12,71 +14,109 @@ namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class HttpHelper
|
||||
{
|
||||
public static string HttpGet(string Url, string postDataStr="")
|
||||
|
||||
public static HttpClient Client { get; set; } = new HttpClient();
|
||||
|
||||
public static async Task<string> Get(string url)
|
||||
{
|
||||
#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;
|
||||
return await Client.GetStringAsync(url);
|
||||
}
|
||||
|
||||
public static bool HttpIOGet(string Url, string file, string postDataStr="")
|
||||
public static async Task<Stream> GetIO(string url)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url + (postDataStr == "" ? "" : "?") + postDataStr);
|
||||
request.Method = "GET";
|
||||
request.ContentType = "text/html;charset=UTF-8";
|
||||
return await Client.GetStreamAsync(url);
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
{
|
||||
writer.Write(buffer, 0, c);
|
||||
foreach (var d in head)
|
||||
{
|
||||
json.Headers.Add(d.Key, d.Value);
|
||||
}
|
||||
}
|
||||
writer.Close();
|
||||
myResponseStream.Close();
|
||||
|
||||
return true;
|
||||
var httpResponse = await Client.PostAsync(url, json);
|
||||
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
|
||||
var content = httpResponse.Content;
|
||||
|
||||
return await content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
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();
|
||||
// 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();
|
||||
// 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();
|
||||
|
||||
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;
|
||||
// }
|
||||
|
||||
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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
16
Yi.Framework.Net6/Yi.Framework.Common/Helper/IdHelper.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@ namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public static class TreeHelper
|
||||
{
|
||||
public static IList<T> SetTree<T>(IList<T> list, Action<T> action = null)
|
||||
public static List<T> SetTree<T>(List<T> list, Action<T> action = null)
|
||||
{
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
IList<T> result = new List<T>();
|
||||
long pid = list.Min(m => (m as ITreeModel<T>).parentId);
|
||||
IList<T> t = list.Where(m => (m as ITreeModel<T>).parentId == pid).ToList();
|
||||
long pid = list.Min(m => (m as ITreeModel<T>).ParentId);
|
||||
IList<T> t = list.Where(m => (m as ITreeModel<T>).ParentId == pid).ToList();
|
||||
foreach (T model in t)
|
||||
{
|
||||
if (action != null)
|
||||
@@ -24,35 +24,35 @@ namespace Yi.Framework.Common.Helper
|
||||
}
|
||||
result.Add(model);
|
||||
var item = (model as ITreeModel<T>);
|
||||
IList<T> children = list.Where(m => (m as ITreeModel<T>).parentId == item.id).ToList();
|
||||
IList<T> children = list.Where(m => (m as ITreeModel<T>).ParentId == item.Id).ToList();
|
||||
if (children.Count > 0)
|
||||
{
|
||||
SetTreeChildren(list, children, model, action);
|
||||
}
|
||||
}
|
||||
return result.OrderBy(m => (m as ITreeModel<T>).sort).ToList();
|
||||
return result.OrderBy(m => (m as ITreeModel<T>).OrderNum).ToList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private static void SetTreeChildren<T>(IList<T> list, IList<T> children, T model, Action<T> action = null)
|
||||
{
|
||||
var mm = (model as ITreeModel<T>);
|
||||
mm.children = new List<T>();
|
||||
mm.Children = new List<T>();
|
||||
foreach (T item in children)
|
||||
{
|
||||
if (action != null)
|
||||
{
|
||||
action(item);
|
||||
}
|
||||
mm.children.Add(item);
|
||||
mm.Children.Add(item);
|
||||
var _item = (item as ITreeModel<T>);
|
||||
IList<T> _children = list.Where(m => (m as ITreeModel<T>).parentId == _item.id).ToList();
|
||||
IList<T> _children = list.Where(m => (m as ITreeModel<T>).ParentId == _item.Id).ToList();
|
||||
if (_children.Count > 0)
|
||||
{
|
||||
SetTreeChildren(list, _children, item, action);
|
||||
}
|
||||
}
|
||||
mm.children = mm.children.OrderBy(m => (m as ITreeModel<T>).sort).ToList();
|
||||
mm.Children = mm.Children.OrderBy(m => (m as ITreeModel<T>).OrderNum).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
397
Yi.Framework.Net6/Yi.Framework.Common/Helper/ZipHelper.cs
Normal file
@@ -0,0 +1,397 @@
|
||||
/***
|
||||
* Title:"基础工具" 项目
|
||||
* Title:"基础工具" 项目
|
||||
* 主题:压缩包帮助类
|
||||
* Description:
|
||||
* 功能:
|
||||
* 1、压缩单个文件
|
||||
* 2、压缩多个文件
|
||||
* 3、压缩多层目录
|
||||
* 4、递归遍历目录
|
||||
* 5、解压缩一个 zip 文件
|
||||
* 6、获取压缩文件中指定类型的文件
|
||||
* 7、获取压缩文件中的所有文件
|
||||
* Date:2021
|
||||
* Version:0.1版本
|
||||
* Author:Coffee
|
||||
* Modify Recoder:
|
||||
*/
|
||||
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Yi.Framework.Common.Helper
|
||||
{
|
||||
public class ZipHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 压缩单个文件
|
||||
/// </summary>
|
||||
/// <param name="fileToZip">要压缩的文件</param>
|
||||
/// <param name="zipedFile">压缩后的文件</param>
|
||||
/// <param name="compressionLevel">压缩等级</param>
|
||||
/// <param name="blockSize">每次写入大小</param>
|
||||
public static void ZipFile(string fileToZip, string zipedFile, int compressionLevel, int blockSize)
|
||||
{
|
||||
//如果文件没有找到,则报错
|
||||
if (!File.Exists(fileToZip))
|
||||
{
|
||||
throw new FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!");
|
||||
}
|
||||
|
||||
using (FileStream ZipFile = File.Create(zipedFile))
|
||||
{
|
||||
using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile))
|
||||
{
|
||||
using (FileStream StreamToZip = new FileStream(fileToZip, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
|
||||
|
||||
ZipEntry ZipEntry = new ZipEntry(fileName);
|
||||
|
||||
ZipStream.PutNextEntry(ZipEntry);
|
||||
|
||||
ZipStream.SetLevel(compressionLevel);
|
||||
|
||||
byte[] buffer = new byte[blockSize];
|
||||
|
||||
int sizeRead = 0;
|
||||
|
||||
try
|
||||
{
|
||||
do
|
||||
{
|
||||
sizeRead = StreamToZip.Read(buffer, 0, buffer.Length);
|
||||
ZipStream.Write(buffer, 0, sizeRead);
|
||||
}
|
||||
while (sizeRead > 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
StreamToZip.Close();
|
||||
}
|
||||
|
||||
ZipStream.Finish();
|
||||
ZipStream.Close();
|
||||
}
|
||||
|
||||
ZipFile.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 压缩单个文件
|
||||
/// </summary>
|
||||
/// <param name="fileToZip">要进行压缩的文件名</param>
|
||||
/// <param name="zipedFile">压缩后生成的压缩文件名</param>
|
||||
public static void ZipFile(string fileToZip, string zipedFile)
|
||||
{
|
||||
//如果文件没有找到,则报错
|
||||
if (!File.Exists(fileToZip))
|
||||
{
|
||||
throw new FileNotFoundException("指定要压缩的文件: " + fileToZip + " 不存在!");
|
||||
}
|
||||
|
||||
using (FileStream fs = File.OpenRead(fileToZip))
|
||||
{
|
||||
byte[] buffer = new byte[fs.Length];
|
||||
fs.Read(buffer, 0, buffer.Length);
|
||||
fs.Close();
|
||||
|
||||
using (FileStream ZipFile = File.Create(zipedFile))
|
||||
{
|
||||
using (ZipOutputStream ZipStream = new ZipOutputStream(ZipFile))
|
||||
{
|
||||
string fileName = fileToZip.Substring(fileToZip.LastIndexOf("\\") + 1);
|
||||
ZipEntry ZipEntry = new ZipEntry(fileName);
|
||||
ZipStream.PutNextEntry(ZipEntry);
|
||||
ZipStream.SetLevel(5);
|
||||
|
||||
ZipStream.Write(buffer, 0, buffer.Length);
|
||||
ZipStream.Finish();
|
||||
ZipStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 压缩多个文件到指定路径
|
||||
/// </summary>
|
||||
/// <param name="sourceFileNames">压缩到哪个路径</param>
|
||||
/// <param name="zipFileName">压缩文件名称</param>
|
||||
public static void ZipFile(List<string> sourceFileNames, string zipFileName)
|
||||
{
|
||||
//压缩文件打包
|
||||
using (ZipOutputStream s = new ZipOutputStream(File.Create(zipFileName)))
|
||||
{
|
||||
s.SetLevel(9);
|
||||
byte[] buffer = new byte[4096];
|
||||
foreach (string file in sourceFileNames)
|
||||
{
|
||||
if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
|
||||
{
|
||||
string pPath = "";
|
||||
pPath += Path.GetFileName(file);
|
||||
pPath += "\\";
|
||||
ZipSetp(file, s, pPath, sourceFileNames);
|
||||
}
|
||||
else // 否则直接压缩文件
|
||||
{
|
||||
|
||||
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
|
||||
entry.DateTime = DateTime.Now;
|
||||
s.PutNextEntry(entry);
|
||||
using (FileStream fs = File.OpenRead(file))
|
||||
{
|
||||
int sourceBytes;
|
||||
do
|
||||
{
|
||||
sourceBytes = fs.Read(buffer, 0, buffer.Length);
|
||||
s.Write(buffer, 0, sourceBytes);
|
||||
} while (sourceBytes > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Finish();
|
||||
s.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 压缩多层目录
|
||||
/// </summary>
|
||||
/// <param name="strDirectory">待压缩目录</param>
|
||||
/// <param name="zipedFile">压缩后生成的压缩文件名,绝对路径</param>
|
||||
public static void ZipFileDirectory(string strDirectory, string zipedFile)
|
||||
{
|
||||
using (FileStream ZipFile = File.Create(zipedFile))
|
||||
{
|
||||
using (ZipOutputStream s = new ZipOutputStream(ZipFile))
|
||||
{
|
||||
s.SetLevel(9);
|
||||
ZipSetp(strDirectory, s, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 压缩多层目录
|
||||
/// </summary>
|
||||
/// <param name="strDirectory">待压缩目录</param>
|
||||
/// <param name="zipedFile">压缩后生成的压缩文件名,绝对路径</param>
|
||||
/// <param name="files">指定要压缩的文件列表(完全路径)</param>
|
||||
public static void ZipFileDirectory(string strDirectory, string zipedFile, List<string> files)
|
||||
{
|
||||
using (FileStream ZipFile = File.Create(zipedFile))
|
||||
{
|
||||
using (ZipOutputStream s = new ZipOutputStream(ZipFile))
|
||||
{
|
||||
s.SetLevel(9);
|
||||
ZipSetp(strDirectory, s, "", files);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归遍历目录
|
||||
/// </summary>
|
||||
/// <param name="strDirectory">需遍历的目录</param>
|
||||
/// <param name="s">压缩输出流对象</param>
|
||||
/// <param name="parentPath">The parent path.</param>
|
||||
/// <param name="files">需要压缩的文件</param>
|
||||
private static void ZipSetp(string strDirectory, ZipOutputStream s, string parentPath, List<string> files = null!)
|
||||
{
|
||||
if (strDirectory[strDirectory.Length - 1] != Path.DirectorySeparatorChar)
|
||||
{
|
||||
strDirectory += Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
string[] filenames = Directory.GetFileSystemEntries(strDirectory);
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
foreach (string file in filenames)// 遍历所有的文件和目录
|
||||
{
|
||||
if (files != null && !files.Contains(file))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (Directory.Exists(file))// 先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
|
||||
{
|
||||
string pPath = parentPath;
|
||||
pPath += Path.GetFileName(file);
|
||||
pPath += "\\";
|
||||
ZipSetp(file, s, pPath, files!);
|
||||
}
|
||||
else // 否则直接压缩文件
|
||||
{
|
||||
//打开压缩文件
|
||||
string fileName = parentPath + Path.GetFileName(file);
|
||||
ZipEntry entry = new ZipEntry(fileName);
|
||||
|
||||
entry.DateTime = DateTime.Now;
|
||||
|
||||
s.PutNextEntry(entry);
|
||||
using (FileStream fs = File.OpenRead(file))
|
||||
{
|
||||
int sourceBytes;
|
||||
do
|
||||
{
|
||||
sourceBytes = fs.Read(buffer, 0, buffer.Length);
|
||||
s.Write(buffer, 0, sourceBytes);
|
||||
} while (sourceBytes > 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解压缩一个 zip 文件。
|
||||
/// </summary>
|
||||
/// <param name="zipedFile">压缩文件</param>
|
||||
/// <param name="strDirectory">解压目录</param>
|
||||
/// <param name="password">zip 文件的密码。</param>
|
||||
/// <param name="overWrite">是否覆盖已存在的文件。</param>
|
||||
public static void UnZip(string zipedFile, string strDirectory, bool overWrite, string password)
|
||||
{
|
||||
|
||||
if (strDirectory == "")
|
||||
strDirectory = Directory.GetCurrentDirectory();
|
||||
if (!strDirectory.EndsWith("\\"))
|
||||
strDirectory = strDirectory + "\\";
|
||||
|
||||
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipedFile)))
|
||||
{
|
||||
if (password != null)
|
||||
{
|
||||
s.Password = password;
|
||||
}
|
||||
ZipEntry theEntry;
|
||||
|
||||
while ((theEntry = s.GetNextEntry()) != null)
|
||||
{
|
||||
string directoryName = "";
|
||||
string pathToZip = "";
|
||||
pathToZip = theEntry.Name;
|
||||
|
||||
if (pathToZip != "")
|
||||
directoryName = Path.GetDirectoryName(pathToZip) + "\\";
|
||||
|
||||
string fileName = Path.GetFileName(pathToZip);
|
||||
|
||||
Directory.CreateDirectory(strDirectory + directoryName);
|
||||
|
||||
if (fileName != "")
|
||||
{
|
||||
if (File.Exists(strDirectory + directoryName + fileName) && overWrite || !File.Exists(strDirectory + directoryName + fileName))
|
||||
{
|
||||
using (FileStream streamWriter = File.Create(strDirectory + directoryName + fileName))
|
||||
{
|
||||
int size = 2048;
|
||||
byte[] data = new byte[2048];
|
||||
while (true)
|
||||
{
|
||||
size = s.Read(data, 0, data.Length);
|
||||
|
||||
if (size > 0)
|
||||
streamWriter.Write(data, 0, size);
|
||||
else
|
||||
break;
|
||||
}
|
||||
streamWriter.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解压缩一个 zip 文件。
|
||||
/// </summary>
|
||||
/// <param name="zipedFile">压缩文件</param>
|
||||
/// <param name="strDirectory">解压目录</param>
|
||||
/// <param name="overWrite">是否覆盖已存在的文件。</param>
|
||||
public static void UnZip(string zipedFile, string strDirectory, bool overWrite)
|
||||
{
|
||||
UnZip(zipedFile, strDirectory, overWrite, null!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解压缩一个 zip 文件。
|
||||
/// 覆盖已存在的文件。
|
||||
/// </summary>
|
||||
/// <param name="zipedFile">压缩文件</param>
|
||||
/// <param name="strDirectory">解压目录</param>
|
||||
public static void UnZip(string zipedFile, string strDirectory)
|
||||
{
|
||||
UnZip(zipedFile, strDirectory, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取压缩文件中指定类型的文件
|
||||
/// </summary>
|
||||
/// <param name="zipedFile">压缩文件</param>
|
||||
/// <param name="fileExtension">文件类型(.txt|.exe)</param>
|
||||
/// <returns>文件名称列表(包含子目录)</returns>
|
||||
public static List<string> GetFiles(string zipedFile, List<string> fileExtension)
|
||||
{
|
||||
List<string> files = new List<string>();
|
||||
if (!File.Exists(zipedFile))
|
||||
{
|
||||
//return files;
|
||||
throw new FileNotFoundException(zipedFile);
|
||||
}
|
||||
|
||||
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipedFile)))
|
||||
{
|
||||
ZipEntry theEntry;
|
||||
while ((theEntry = s.GetNextEntry()) != null)
|
||||
{
|
||||
if (theEntry.IsFile)
|
||||
{
|
||||
//Console.WriteLine("Name : {0}", theEntry.Name);
|
||||
if (fileExtension != null)
|
||||
{
|
||||
if (fileExtension.Contains(Path.GetExtension(theEntry.Name)))
|
||||
{
|
||||
files.Add(theEntry.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
files.Add(theEntry.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
s.Close();
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取压缩文件中的所有文件
|
||||
/// </summary>
|
||||
/// <param name="zipedFile">压缩文件</param>
|
||||
/// <returns>文件名称列表(包含子目录)</returns>
|
||||
public static List<string> GetFiles(string zipedFile)
|
||||
{
|
||||
return GetFiles(zipedFile, null!);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//Class_end
|
||||
|
||||
}
|
||||
@@ -8,10 +8,10 @@ namespace Yi.Framework.Common.Models
|
||||
{
|
||||
public interface ITreeModel<T>
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int parentId { get; set; }
|
||||
public int sort { get; set; }
|
||||
public long Id { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public IList<T> children { get; set; }
|
||||
public List<T> Children { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,21 @@ namespace Yi.Framework.Common.Models
|
||||
|
||||
public class PageModel<T>
|
||||
{
|
||||
public PageModel() { }
|
||||
public PageModel(T data,int total)
|
||||
{
|
||||
Data = data;
|
||||
Total = total;
|
||||
}
|
||||
public int Total { get; set; }
|
||||
public T Data { get; set; }
|
||||
}
|
||||
|
||||
public class PageModel : PageModel<object>
|
||||
{
|
||||
public PageModel() { }
|
||||
public PageModel(object data, int total) : base(data, total)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
Yi.Framework.Net6/Yi.Framework.Common/Models/PageParModel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Models
|
||||
{
|
||||
|
||||
public class PageParModel
|
||||
{
|
||||
public int PageNum { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
|
||||
public DateTime? StartTime {get;set;}
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Yi.Framework.Common.Models.Enum;
|
||||
using Yi.Framework.Common.Enum;
|
||||
using Yi.Framework.Language;
|
||||
|
||||
namespace Yi.Framework.Common.Models
|
||||
@@ -7,35 +7,45 @@ namespace Yi.Framework.Common.Models
|
||||
public class Result
|
||||
{
|
||||
public static IStringLocalizer<LocalLanguage> _local;
|
||||
public ResultCode code { get; set; }
|
||||
public ResultCodeEnum code { get; set; }
|
||||
|
||||
public bool status { get; set; }
|
||||
public string message { get; set; }
|
||||
public object data { get; set; }
|
||||
public static Result Expire(ResultCode code, string msg="")
|
||||
public static Result Expire(ResultCodeEnum code, string msg="")
|
||||
{
|
||||
return new Result() { code = code, status=false, message = Get(msg, "token_expiration") };
|
||||
}
|
||||
public static Result Error(string msg = "")
|
||||
{
|
||||
return new Result() { code = ResultCode.NotSuccess,status=false, message =Get(msg, "fail") };
|
||||
return new Result() { code = ResultCodeEnum.NotSuccess,status=false, message =Get(msg, "fail") };
|
||||
}
|
||||
public static Result Success(string msg = "")
|
||||
{
|
||||
return new Result() { code = ResultCode.Success,status=true, message =Get( msg, "succeed" )};
|
||||
return new Result() { code = ResultCodeEnum.Success,status=true, message =Get( msg, "succeed" )};
|
||||
}
|
||||
public static Result SuccessError(string msg = "")
|
||||
{
|
||||
return new Result() { code = ResultCode.Success, status = false, message = Get(msg, "fail") };
|
||||
return new Result() { code = ResultCodeEnum.Success, status = false, message = Get(msg, "fail") };
|
||||
}
|
||||
|
||||
|
||||
public static Result UnAuthorize(string msg = "")
|
||||
{
|
||||
return new Result() { code = ResultCode.NoPermission,status=false, message = Get(msg, "unAuthorize") };
|
||||
return new Result() { code = ResultCodeEnum.NoPermission,status=false, message = Get(msg, "unAuthorize") };
|
||||
}
|
||||
public Result SetStatus(bool _status)
|
||||
{
|
||||
if (_status)
|
||||
{
|
||||
this.code = ResultCodeEnum.Success;
|
||||
this.message = "操作成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.code = code = ResultCodeEnum.NotSuccess;
|
||||
this.message = "操作失败";
|
||||
}
|
||||
this.status = _status;
|
||||
return this;
|
||||
}
|
||||
@@ -44,7 +54,7 @@ namespace Yi.Framework.Common.Models
|
||||
this.data = obj;
|
||||
return this;
|
||||
}
|
||||
public Result SetCode(ResultCode Code)
|
||||
public Result SetCode(ResultCodeEnum Code)
|
||||
{
|
||||
this.code = Code;
|
||||
return this;
|
||||
@@ -71,20 +81,20 @@ namespace Yi.Framework.Common.Models
|
||||
}
|
||||
public class Result<T>
|
||||
{
|
||||
public ResultCode code { get; set; }
|
||||
public ResultCodeEnum code { get; set; }
|
||||
public string message { get; set; }
|
||||
public T data { get; set; }
|
||||
public static Result<T> Error(string msg = "fail")
|
||||
{
|
||||
return new Result<T>() { code = ResultCode.NotSuccess, message = msg };
|
||||
return new Result<T>() { code = ResultCodeEnum.NotSuccess, message = msg };
|
||||
}
|
||||
public static Result<T> Success(string msg = "succeed")
|
||||
{
|
||||
return new Result<T>() { code = ResultCode.Success, message = msg };
|
||||
return new Result<T>() { code = ResultCodeEnum.Success, message = msg };
|
||||
}
|
||||
public static Result<T> UnAuthorize(string msg = "unAuthorize")
|
||||
{
|
||||
return new Result<T>() { code = ResultCode.NoPermission, message = msg };
|
||||
return new Result<T>() { code = ResultCodeEnum.NoPermission, message = msg };
|
||||
}
|
||||
|
||||
public Result<T> SetData(T TValue)
|
||||
@@ -93,7 +103,7 @@ namespace Yi.Framework.Common.Models
|
||||
return this;
|
||||
}
|
||||
|
||||
public Result<T> SetCode(ResultCode Code)
|
||||
public Result<T> SetCode(ResultCodeEnum Code)
|
||||
{
|
||||
this.code = Code;
|
||||
return this;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Yi.Framework.Common.Models
|
||||
{
|
||||
public static class ServiceLocator
|
||||
{
|
||||
public static IServiceProvider Instance { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Common.Models
|
||||
{
|
||||
public class VueRouterModel : ITreeModel<VueRouterModel>
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long ParentId { get; set; }
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public bool Hidden { get; set; }
|
||||
public string Redirect { get; set; }
|
||||
public string Component { get; set; }
|
||||
public bool AlwaysShow { get; set; }
|
||||
public Meta Meta { get; set; } = new Meta();
|
||||
public List<VueRouterModel> Children { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class Meta
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public bool NoCache { get; set; }
|
||||
public string link { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EPPlus" Version="5.8.4" />
|
||||
<PackageReference Include="Hei.Captcha" Version="0.3.0" />
|
||||
<PackageReference Include="IPTools.China" Version="1.6.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="6.0.3" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
||||
<PackageReference Include="UAParser" Version="3.1.47" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,28 +18,33 @@ namespace Yi.Framework.Core
|
||||
public delegate T MyAction<T>(CSRedisClient client);
|
||||
|
||||
private readonly RedisConnOptions _RedisOptions;
|
||||
|
||||
private CSRedisClient Client { get; set; }
|
||||
|
||||
public CSRedisClient _Db { get { return Client; } set { } }
|
||||
public CacheClientDB(IOptionsMonitor<RedisConnOptions> redisConnOptions)
|
||||
{
|
||||
this._RedisOptions = redisConnOptions.CurrentValue;
|
||||
Client = new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
|
||||
}
|
||||
|
||||
private T TryCatch<T>(MyAction<T> action)
|
||||
{
|
||||
var client2 = new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
|
||||
T result;
|
||||
|
||||
|
||||
T result = default(T);
|
||||
try
|
||||
{
|
||||
result = action(client2);
|
||||
result = action(Client);
|
||||
}
|
||||
catch (Exception exinfo)
|
||||
{
|
||||
object p = null;
|
||||
result = (T)p;
|
||||
Console.WriteLine(exinfo);
|
||||
}
|
||||
finally
|
||||
{
|
||||
client2.Dispose();
|
||||
}
|
||||
//finally
|
||||
//{
|
||||
// Client.Dispose();
|
||||
//}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -55,6 +60,11 @@ namespace Yi.Framework.Core
|
||||
return this.TryCatch((u) => u.Del(key));
|
||||
}
|
||||
|
||||
public long HRemove(string key, params string[] par)
|
||||
{
|
||||
return this.TryCatch((u) => u.HDel(key, par));
|
||||
}
|
||||
|
||||
public T Get<T>(string key)
|
||||
{
|
||||
return this.TryCatch<T>((u) => u.Get<T>(key));
|
||||
@@ -68,9 +78,36 @@ namespace Yi.Framework.Core
|
||||
{
|
||||
return this.TryCatch<bool>((u) => u.Set(key, data));
|
||||
}
|
||||
public bool AddHash<T>(string key,string field, T data)
|
||||
public T QueuePop<T>(string key)
|
||||
{
|
||||
return this.TryCatch<bool>((u)=>u.HSet(key ,field,data));
|
||||
return this.TryCatch<T>((u) => u.RPop<T>(key));
|
||||
}
|
||||
public long QueuePush<T>(string key, T data)
|
||||
{
|
||||
return this.TryCatch<long>((u) => u.LPush<T>(key, data));
|
||||
}
|
||||
public long QueueLen(string key)
|
||||
{
|
||||
return TryCatch((u) => u.LLen(key));
|
||||
}
|
||||
|
||||
public bool HSet<T>(string key, string fieId, T data)
|
||||
{
|
||||
return this.TryCatch<bool>((u) => u.HSet(key, fieId, data));
|
||||
}
|
||||
public bool HSet<T>(string key, string fieId, T data, TimeSpan time)
|
||||
{
|
||||
return this.TryCatch<bool>((u) =>
|
||||
{
|
||||
var res = u.HSet(key, fieId, data);
|
||||
u.Expire(key, time);
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
public CSRedisClient Db()
|
||||
{
|
||||
return new CSRedisClient($"{_RedisOptions.Host}:{_RedisOptions.Prot},password={_RedisOptions.Password},defaultDatabase ={ _RedisOptions.DB }");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Common.Const;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Model.Models;
|
||||
using JwtRegisteredClaimNames = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames;
|
||||
@@ -23,28 +24,34 @@ namespace Yi.Framework.Core
|
||||
}
|
||||
public string GetRefreshToken(UserEntity user)
|
||||
{
|
||||
return this.GetToken(_JWTTokenOptions.ReExpiration, user, true);
|
||||
return this.GetToken(_JWTTokenOptions.ReExpiration, user, null, true);
|
||||
}
|
||||
|
||||
public string GetAccessToken(UserEntity user)
|
||||
public string GetAccessToken(UserEntity user, HashSet<MenuEntity> menus)
|
||||
{
|
||||
return this.GetToken(_JWTTokenOptions.Expiration, user);
|
||||
return this.GetToken(_JWTTokenOptions.Expiration, user, menus);
|
||||
}
|
||||
|
||||
private string GetToken(int minutes, UserEntity user, bool isRefresh = false)
|
||||
private string GetToken(int minutes, UserEntity user, HashSet<MenuEntity> menus, bool isRefresh = false)
|
||||
{
|
||||
List<Claim> claims = new List<Claim>();
|
||||
claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, $"{new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds()}"));
|
||||
claims.Add(new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddMinutes(minutes)).ToUnixTimeSeconds()}"));
|
||||
claims.Add(new Claim(JwtRegisteredClaimNames.Sid, user.Id.ToString()));
|
||||
|
||||
claims.Add(new Claim("userName", user.UserName));
|
||||
claims.Add(new Claim("deptId", user.DeptId.ToString()));
|
||||
//-----------------------------以下从user的权限表中添加权限-----------------------例如:
|
||||
claims.Add(new Claim("permission", "userentity:get:list"));
|
||||
claims.Add(new Claim("permission", "userentity:get:one"));
|
||||
|
||||
if (isRefresh)
|
||||
foreach (var m in menus)
|
||||
{
|
||||
claims.Add(new Claim("Re", "true"));
|
||||
if (!string.IsNullOrEmpty(m.PermissionCode))
|
||||
{
|
||||
claims.Add(new Claim(SystemConst.PermissionClaim, m.PermissionCode.ToString()));
|
||||
}
|
||||
}
|
||||
if (SystemConst.Admin.Equals(user.UserName))
|
||||
{
|
||||
claims.Add(new Claim(SystemConst.PermissionClaim, SystemConst.AdminPermissionCode));
|
||||
}
|
||||
|
||||
var creds = new SigningCredentials(new RsaSecurityKey(Common.Helper.RSAFileHelper.GetKey()), SecurityAlgorithms.RsaSha256);
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace Yi.Framework.Core
|
||||
private IScheduler _scheduler;
|
||||
private ILogger<QuartzInvoker> _logger;
|
||||
private IJobFactory _jobFactory;
|
||||
|
||||
private const string JobDllName = "Yi.Framework.Job";
|
||||
public QuartzInvoker(ISchedulerFactory schedulerFactory, ILogger<QuartzInvoker> logger, IJobFactory jobFactory)
|
||||
{
|
||||
_schedulerFactory = schedulerFactory;
|
||||
@@ -29,27 +31,28 @@ namespace Yi.Framework.Core
|
||||
/// 开始任务
|
||||
/// </summary>
|
||||
/// <param name="cron"></param>
|
||||
/// <param name="jobKey"></param>
|
||||
/// <param name="jobClass"></param>
|
||||
/// <param name="jobName"></param>
|
||||
/// <param name="jobGroup"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task start(string cron, JobKey jobKey, string dllName,string jobClass, long second = 0, IDictionary<string, object> data = null)
|
||||
public async Task StartAsync(string cron, string jobClass, string jobName = "", string jobGroup = "default", long startAtSecondTime = 0, IDictionary<string, object> data = null)
|
||||
{
|
||||
jobName = jobName == "" ? jobClass : jobName;
|
||||
if (data == null)
|
||||
{
|
||||
data = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
var myClass = AssemblyHelper.GetClass(dllName, jobClass).FirstOrDefault();
|
||||
JobKey jobKey = new JobKey(jobName, jobGroup);
|
||||
var myClass = AssemblyHelper.GetClass(JobDllName, jobClass).FirstOrDefault();
|
||||
|
||||
_scheduler = await _schedulerFactory.GetScheduler();
|
||||
_scheduler.JobFactory = _jobFactory;
|
||||
//开启调度器
|
||||
await _scheduler.Start();
|
||||
|
||||
//创建一个触发器
|
||||
var trigger = TriggerBuilder.Create()
|
||||
.StartAt(DateTimeOffset.Now.AddSeconds(second))
|
||||
.StartAt(DateTimeOffset.Now.AddSeconds(startAtSecondTime))
|
||||
.WithCronSchedule(cron)
|
||||
.Build();
|
||||
//创建任务
|
||||
@@ -57,18 +60,78 @@ namespace Yi.Framework.Core
|
||||
.UsingJobData(new JobDataMap(data))
|
||||
.WithIdentity(jobKey.Name, jobKey.Group)
|
||||
.Build();
|
||||
|
||||
//await _scheduler.AddJob(jobDetail,false);
|
||||
|
||||
//await _scheduler.ScheduleJob(trigger);
|
||||
//将触发器和任务器绑定到调度器中
|
||||
await _scheduler.ScheduleJob(jobDetail, trigger);
|
||||
|
||||
//开启调度器
|
||||
await _scheduler.Start();
|
||||
|
||||
_logger.LogWarning($"开始任务:{jobKey.Name},组别:{jobKey.Group}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始任务
|
||||
/// </summary>
|
||||
/// <param name="cron"></param>
|
||||
/// <param name="jobClass"></param>
|
||||
/// <param name="jobName"></param>
|
||||
/// <param name="jobGroup"></param>
|
||||
/// <param name="second"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task StartAsync(int milliSecondTime, string jobClass, string jobName = "", string jobGroup = "default", long startAtSecondTime = 0, IDictionary<string, object> data = null)
|
||||
{
|
||||
|
||||
jobName = jobName == "" ? jobClass : jobName;
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new Dictionary<string, object>();
|
||||
}
|
||||
JobKey jobKey = new JobKey(jobName, jobGroup);
|
||||
var myClass = AssemblyHelper.GetClass(JobDllName, jobClass).FirstOrDefault();
|
||||
|
||||
_scheduler = await _schedulerFactory.GetScheduler();
|
||||
_scheduler.JobFactory = _jobFactory;
|
||||
|
||||
//创建一个触发器
|
||||
var trigger = TriggerBuilder.Create()
|
||||
.StartAt(DateTimeOffset.Now.AddSeconds(startAtSecondTime))
|
||||
.WithSimpleSchedule(option =>
|
||||
{
|
||||
option.WithInterval(TimeSpan.FromMilliseconds(milliSecondTime)).RepeatForever();
|
||||
})
|
||||
|
||||
.Build();
|
||||
//创建任务
|
||||
var jobDetail = JobBuilder.Create(myClass)
|
||||
.UsingJobData(new JobDataMap(data))
|
||||
.WithIdentity(jobKey.Name, jobKey.Group)
|
||||
.Build();
|
||||
|
||||
//await _scheduler.AddJob(jobDetail,false);
|
||||
|
||||
//await _scheduler.ScheduleJob(trigger);
|
||||
//将触发器和任务器绑定到调度器中
|
||||
await _scheduler.ScheduleJob(jobDetail, trigger);
|
||||
|
||||
//开启调度器
|
||||
await _scheduler.Start();
|
||||
|
||||
_logger.LogWarning($"开始任务:{jobKey.Name},组别:{jobKey.Group}");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 暂停任务
|
||||
/// </summary>
|
||||
/// <param name="jobKey"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Stop(JobKey jobKey)
|
||||
public async Task StopAsync(JobKey jobKey)
|
||||
{
|
||||
var _scheduler = await _schedulerFactory.GetScheduler();
|
||||
//LogUtil.Debug($"暂停任务{jobKey.Group},{jobKey.Name}");
|
||||
@@ -77,7 +140,7 @@ namespace Yi.Framework.Core
|
||||
}
|
||||
|
||||
|
||||
public async Task Delete(JobKey jobKey)
|
||||
public async Task DeleteAsync(JobKey jobKey)
|
||||
{
|
||||
var _scheduler = await _schedulerFactory.GetScheduler();
|
||||
//LogUtil.Debug($"暂停任务{jobKey.Group},{jobKey.Name}");
|
||||
@@ -85,7 +148,7 @@ namespace Yi.Framework.Core
|
||||
_logger.LogWarning($"删除任务:{jobKey.Name},组别:{jobKey.Group}");
|
||||
}
|
||||
|
||||
public async Task Resume(JobKey jobKey)
|
||||
public async Task ResumeAsync(JobKey jobKey)
|
||||
{
|
||||
var _scheduler = await _schedulerFactory.GetScheduler();
|
||||
//LogUtil.Debug($"恢复任务{jobKey.Group},{jobKey.Name}");
|
||||
@@ -98,9 +161,9 @@ namespace Yi.Framework.Core
|
||||
/// 得到可运行的job列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<string> getJobClassList()
|
||||
public List<string> GetJobClassList()
|
||||
{
|
||||
var myClassList = AssemblyHelper.GetClass("Yi.Framework.Job");
|
||||
var myClassList = AssemblyHelper.GetClass("ETX.Job");
|
||||
List<string> data = new List<string>();
|
||||
myClassList.ForEach(k => data.Add(k.Name));
|
||||
return data;
|
||||
@@ -126,9 +189,9 @@ namespace Yi.Framework.Core
|
||||
foreach (ITrigger trigger in triggers)
|
||||
{
|
||||
///下一次的执行时间
|
||||
var utcTime =trigger.GetNextFireTimeUtc();
|
||||
var utcTime = trigger.GetNextFireTimeUtc();
|
||||
string str = utcTime.ToString();
|
||||
//TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(str));
|
||||
//TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(str));
|
||||
|
||||
|
||||
}
|
||||
@@ -142,7 +205,7 @@ namespace Yi.Framework.Core
|
||||
|
||||
|
||||
public class JobKeyModel
|
||||
{
|
||||
{
|
||||
public JobKey jobKey { get; set; }
|
||||
public DateTime? nextTime { get; set; }
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace Yi.Framework.Core
|
||||
autoAck: false,//不ACK
|
||||
consumer: consumer);
|
||||
Console.WriteLine($" Register Consumer To {rabbitMQConsumerMode.ExchangeName}-{rabbitMQConsumerMode.QueueName}");
|
||||
Console.ReadLine();
|
||||
//Console.ReadLine();
|
||||
Console.WriteLine($" After Register Consumer To {rabbitMQConsumerMode.ExchangeName}-{rabbitMQConsumerMode.QueueName}");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Yi.Framework.Common\Yi.Framework.Common.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Model\Yi.Framework.Model.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Task\Yi.Framework.Job.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
38
Yi.Framework.Net6/Yi.Framework.DTOModel/ArticleVo.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.DTOModel
|
||||
{
|
||||
public class ArticleVo
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
|
||||
public string Content { get; set; }
|
||||
|
||||
public long? UserId { get; set; }
|
||||
|
||||
public long? CreateUser { get; set; }
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
public long? ModifyUser { get; set; }
|
||||
|
||||
public DateTime? ModifyTime { get; set; }
|
||||
|
||||
public bool? IsDeleted { get; set; }
|
||||
|
||||
public long? TenantId { get; set; }
|
||||
|
||||
public int? OrderNum { get; set; }
|
||||
|
||||
public string Remark { get; set; }
|
||||
public List<string> Images { get; set; }
|
||||
|
||||
public UserVo User { get; set; }
|
||||
}
|
||||
}
|
||||