Merge branch 'main' of https://github.com/ccnetcore/Yi into main

This commit is contained in:
lzw
2021-11-03 20:48:24 +08:00
19 changed files with 192 additions and 149 deletions

View File

@@ -50,7 +50,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
if ( user_data!=null) if ( user_data!=null)
{ {
var token = MakeJwt.app(new jwtUser() {user=user_data,menuIds= menuList}); var token = MakeJwt.app(new jwtUser() {user=user_data,menuIds= menuList});
return Result.Success().SetData(new { user = new { _user.id, _user.username, _user.introduction, _user.icon, _user.nick }, token }); return Result.Success().SetData(new { user = new { user_data.id, user_data.username, user_data.introduction, user_data.icon, user_data.nick }, token });
} }
return Result.Error(); return Result.Error();
} }

View File

@@ -23,26 +23,42 @@ namespace Yi.Framework.ApiMicroservice.Controllers
{ {
_userService = userService; _userService = userService;
_env = env; _env = env;
} }
[HttpPost] [HttpPost]
[Authorize] [Authorize]
public async Task<Result> EditIcon(IFormFile file) public async Task<Result> EditIcon(IFormFile file)
{ {
var _user = HttpContext.GetCurrentUserInfo(); try
var user_data = await _userService.GetUserById(_user.id); {
var type = "image"; var _user = HttpContext.GetCurrentUserInfo();
var filename = await Upload(type, file); var user_data = await _userService.GetUserById(_user.id);
user_data.icon = filename; var type = "image";
await _userService.UpdateAsync(user_data); var filename = await Upload(type, file);
return Result.Success(); user_data.icon = filename;
await _userService.UpdateAsync(user_data);
return Result.Success();
}
catch
{
return Result.Error();
}
} }
[Route("/api/{type}/{fileName}")]
[HttpGet] [HttpGet]
public IActionResult Get(string type, string imageNmae) public IActionResult Get(string type, string fileName)
{ {
var path = Path.Combine($"wwwroot/{type}", imageNmae); try
var stream = System.IO.File.OpenRead(path); {
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(imageNmae); var path = Path.Combine($"wwwroot/{type}", fileName);
return new FileStreamResult(stream, MimeType); var stream = System.IO.File.OpenRead(path);
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(fileName);
return new FileStreamResult(stream, MimeType);
}
catch
{
return new NotFoundResult();
}
} }
/// <summary> /// <summary>
@@ -51,9 +67,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers
/// <param name="type"></param> /// <param name="type"></param>
/// <param name="file"></param> /// <param name="file"></param>
/// <returns></returns> /// <returns></returns>
private async Task<string> Upload(string type,IFormFile file) private async Task<string> Upload(string type, IFormFile file)
{ {
string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName); string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
using (var stream = new FileStream(Path.Combine($"wwwroot/{type}", filename), FileMode.CreateNew, FileAccess.Write)) using (var stream = new FileStream(Path.Combine($"wwwroot/{type}", filename), FileMode.CreateNew, FileAccess.Write))
{ {
@@ -63,13 +78,13 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return filename; return filename;
} }
[HttpGet] [HttpGet]
public async Task<IActionResult>ExportFile() public async Task<IActionResult> ExportFile()
{ {
var userdata = await _userService.GetAllEntitiesTrueAsync(); var userdata = await _userService.GetAllEntitiesTrueAsync();
var userList = userdata.ToList(); var userList = userdata.ToList();
List<string> header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip","年龄", "个人介绍", "地址", "手机", "角色" }; List<string> header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip", "年龄", "个人介绍", "地址", "手机", "角色" };
var filename= Common.Helper.ExcelHelper.CreateExcelFromList(userList,header,_env.ContentRootPath.ToString()); var filename = Common.Helper.ExcelHelper.CreateExcelFromList(userList, header, _env.ContentRootPath.ToString());
var MimeType = Common.Helper.MimeHelper.GetMimeMapping(filename); var MimeType = Common.Helper.MimeHelper.GetMimeMapping(filename);
return new FileStreamResult(new FileStream(Path.Combine(_env.ContentRootPath+@"/wwwroot/Excel", filename), FileMode.Open),MimeType); return new FileStreamResult(new FileStream(Path.Combine(_env.ContentRootPath+@"/wwwroot/Excel", filename), FileMode.Open),MimeType);
} }

View File

@@ -84,7 +84,7 @@ namespace Yi.Framework.ApiMicroservice
#endregion #endregion
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IDbContextFactory _DbFactory) public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IDbContextFactory _DbFactory, CacheClientDB _cacheClientDB)
{ {
//if (env.IsDevelopment()) //if (env.IsDevelopment())
{ {
@@ -103,6 +103,11 @@ namespace Yi.Framework.ApiMicroservice
#endregion #endregion
//app.UseErrorHandlingService(); //app.UseErrorHandlingService();
#region
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
#endregion
//app.UseStaticFiles();
#region #region
//HttpsRedirectionע<6E><D7A2> //HttpsRedirectionע<6E><D7A2>
#endregion #endregion
@@ -142,7 +147,11 @@ namespace Yi.Framework.ApiMicroservice
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2> //<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion #endregion
app.UseDbSeedInitService(_DbFactory); app.UseDbSeedInitService(_DbFactory);
//app.UseRedisInitService(_cacheClientDB);
#region
//redis<69><73><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
#endregion
app.UseRedisSeedInitService(_cacheClientDB);
#region #region
//Endpointsע<73><D7A2> //Endpointsע<73><D7A2>
#endregion #endregion

View File

@@ -39,6 +39,14 @@
<param name="pwdDto"></param> <param name="pwdDto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Upload(System.String,Microsoft.AspNetCore.Http.IFormFile)">
<summary>
该方法不对外暴露
</summary>
<param name="type"></param>
<param name="file"></param>
<returns></returns>
</member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetMenuInMould"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.MenuController.GetMenuInMould">
<summary> <summary>
这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法 这个是要递归的,但是要过滤掉删除的,所以,可以写一个通用过滤掉删除的方法
@@ -159,11 +167,11 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.SettingController.UpdateSetting"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.SettingController.UpdateSetting(Yi.Framework.DTOModel.SettingDto)">
<summary> <summary>
</summary> </summary>
<param name="_Setting"></param> <param name="settingDto"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetUser"> <member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.GetUser">

View File

@@ -1,69 +1,69 @@
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft": "Warning", "Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.Hosting.Lifetime": "Information"
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"Consul_Enabled": false, "Consul_Enabled": false,
"DbSeed_Enabled": true, "DbSeed_Enabled": true,
"Apollo_Enabled": false, "Apollo_Enabled": false,
"HealthCheck_Enabled": false, "HealthCheck_Enabled": false,
"Cors_Enabled": true, "Cors_Enabled": true,
"RabbitMQ_Enabled": false, "RabbitMQ_Enabled": false,
"Redis_Enabled": false, "Redis_Enabled": true,
"RedisSet_Enabled": false, "RedisSeed_Enabled": false,
"Kafka_Enabled": false, "Kafka_Enabled": false,
"MutiDB_Enabled": false, "MutiDB_Enabled": false,
"DbList": ["Sqlite", "Mysql", "Sqlserver", "Oracle"], "DbList": [ "Sqlite", "Mysql", "Sqlserver", "Oracle" ],
"DbSelect": "Mysql", "DbSelect": "Mysql",
"DbConn": { "DbConn": {
"WriteUrl": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.", "WriteUrl": "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
"ReadUrl": [ "ReadUrl": [
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.", "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.", "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020.",
"server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020." "server=118.195.191.41;port=3306;database=YIDB;user id=root;password=Qz52013142020."
] ]
}, },
"Apollo": { "Apollo": {
"AppId": "Yi.Framework.ApiMicroservice", "AppId": "Yi.Framework.ApiMicroservice",
"Env": "DEV", "Env": "DEV",
"MetaServer": "http://192.168.2.168:8080", "MetaServer": "http://192.168.2.168:8080",
"ConfigServer": ["http://192.168.2.168:8080"] "ConfigServer": [ "http://192.168.2.168:8080" ]
}, },
"JWTTokenOptions": { "JWTTokenOptions": {
"Audience": "http://localhost:7000", "Audience": "http://localhost:7000",
"Issuer": "http://localhost:7000", "Issuer": "http://localhost:7000",
"SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB" "SecurityKey": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDI2a2EJ7m872v0afyoSDJT2o1+SitIeJSWtLJU8/Wz2m7gStexajkeD+Lka6DSTy8gt9UwfgVQo6uKjVLG5Ex7PiGOODVqAEghBuS7JzIYU5RvI543nNDAPfnJsas96mSA7L/mD7RTE2drj6hf3oZjJpMPZUQI/B1Qjb5H3K3PNwIDAQAB"
}, },
"RedisConn": { "RedisConnOptions": {
"Host": "118.195.191.41", "Host": "118.195.191.41",
"Prot": 6379, "Prot": 6379,
"DB": 1, "DB": 1,
"Password": "Qz52013142020." "Password": "Qz52013142020."
}, },
"KafkaOptions": { "KafkaOptions": {
"BrokerList": "192.168.3.230:9092", "BrokerList": "192.168.3.230:9092",
"TopicName": "kafkalog" "TopicName": "kafkalog"
}, },
"ConsulClientOption": { "ConsulClientOption": {
"IP": "192.168.2.128", "IP": "192.168.2.128",
"Port": "8500", "Port": "8500",
"Datacenter": "dc1" "Datacenter": "dc1"
}, },
"ConsulRegisterOption": { "ConsulRegisterOption": {
"IP": "192.168.1.104", "IP": "192.168.1.104",
"Port": "7001", "Port": "7001",
"GroupName": "ApiMicroservice", "GroupName": "ApiMicroservice",
"HealthCheckUrl": "/Health", "HealthCheckUrl": "/Health",
"Interval": 10, "Interval": 10,
"Timeout": 5, "Timeout": 5,
"DeregisterCriticalServiceAfter": 60, "DeregisterCriticalServiceAfter": 60,
"Tag": "13" "Tag": "13"
}, },
"IPLibraryServiceUrl": "http://gRPCIPLibraryService" "IPLibraryServiceUrl": "http://gRPCIPLibraryService"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -44,9 +44,9 @@ namespace Yi.Framework.Core
// } // }
//} //}
#endregion #endregion
public CacheClientDB(IOptionsMonitor<RedisConnOptions> jwtTokenOptions) public CacheClientDB(IOptionsMonitor<RedisConnOptions> redisConnOptions)
{ {
this._RedisOptions = jwtTokenOptions.CurrentValue; this._RedisOptions = redisConnOptions.CurrentValue;
client = new RedisClient(_RedisOptions.Host, _RedisOptions.Prot, _RedisOptions.Password, _RedisOptions.DB); client = new RedisClient(_RedisOptions.Host, _RedisOptions.Prot, _RedisOptions.Password, _RedisOptions.DB);
} }
// 管道模式 三种模式 // 管道模式 三种模式

View File

@@ -93,7 +93,7 @@ namespace Yi.Framework.Core
{ {
for (int i = menu_data.children.Count() - 1; i >= 0; i--) for (int i = menu_data.children.Count() - 1; i >= 0; i--)
{ {
menu_data.children = menu_data.children.AsEnumerable().OrderBy(u => u.sort).ToList(); menu_data.children = menu_data.children.AsEnumerable().OrderByDescending(u => u.sort).ToList();
if (menu_data.children != null || menu_data.children.Count() != 0) if (menu_data.children != null || menu_data.children.Count() != 0)
{ {

View File

@@ -17,7 +17,7 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
{ {
if (Appsettings.appBool("Redis_Enabled")) if (Appsettings.appBool("Redis_Enabled"))
{ {
services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConn")); services.Configure<RedisConnOptions>(Appsettings.appConfiguration("RedisConnOptions"));
services.AddTransient<CacheClientDB>(); services.AddTransient<CacheClientDB>();
} }
return services; return services;

View File

@@ -15,10 +15,10 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
public static class RedisInitExtend public static class RedisInitExtend
{ {
private static readonly ILog log = LogManager.GetLogger(typeof(RedisInitExtend)); private static readonly ILog log = LogManager.GetLogger(typeof(RedisInitExtend));
public static void UseRedisInitService(this IApplicationBuilder app, CacheClientDB _cacheClientDB) public static void UseRedisSeedInitService(this IApplicationBuilder app, CacheClientDB _cacheClientDB)
{ {
if (Appsettings.appBool("RedisSet_Enabled")) if (Appsettings.appBool("RedisSeed_Enabled"))
{ {
if (app == null) throw new ArgumentNullException(nameof(app)); if (app == null) throw new ArgumentNullException(nameof(app));

View File

@@ -1,8 +1,8 @@
import myaxios from '@/util/myaxios' import myaxios from '@/util/myaxios'
export default { export default {
Upload(file) { EditIcon(file) {
return myaxios({ return myaxios({
url: '/File/Upload', url: '/File/EditIcon',
method: 'post', method: 'post',
headers: { "Content-Type": "multipart/form-data" }, headers: { "Content-Type": "multipart/form-data" },
data: file data: file

View File

@@ -0,0 +1,28 @@
<template>
<v-avatar :size="size" >
<!-- <img src="https://z3.ax1x.com/2021/05/09/gJadhD.jpg" /> -->
<img
:src="baseurl +'/image/'+$store.state.user.user.icon"
/>
</v-avatar>
</template>
<script>
// Utilities
// import { get } from 'vuex-pathify'
export default {
name: 'ccAvatar',
mounted() {
this.baseurl = process.env.VUE_APP_BASE_API;
},
data:()=>({
baseurl: "",
}),
props: {
size: {
type: Number,
}
},
}
</script>

View File

@@ -65,8 +65,10 @@
}, },
title () { title () {
const matches = this.item.menu_name.match(/\b(\w)/g) const matches = this.item.menu_name.match(/\b(\w)/g)
if(matches!=null)
{
return matches.join('') return matches.join('')
}
}, },
}, },

View File

@@ -48,8 +48,10 @@
computed: { computed: {
title () { title () {
const matches = this.item.menu_name.match(/\b(\w)/g) const matches = this.item.menu_name.match(/\b(\w)/g)
if(matches!=null)
{
return matches.join('') return matches.join('')
}
}, },
}, },
} }

View File

@@ -8,50 +8,26 @@
transition="scale-transition" transition="scale-transition"
> >
<template v-slot:activator="{ attrs, on }"> <template v-slot:activator="{ attrs, on }">
<v-btn <v-btn class="ml-2" min-width="0" text v-bind="attrs" v-on="on">
class="ml-2"
min-width="0"
text
v-bind="attrs"
v-on="on"
>
<!-- <v-icon>mdi-account</v-icon> --> <!-- <v-icon>mdi-account</v-icon> -->
<v-avatar size="36" class="elevation-2"> <ccAvatar :size="36" class="elevation-2"></ccAvatar>
<!-- <img src="https://z3.ax1x.com/2021/05/09/gJadhD.jpg" /> -->
<img
:src="
baseurl +
'/File/ShowNoticeImg?filePath=' +
$store.state.user.user.icon
"
/>
</v-avatar>
</v-btn> </v-btn>
</template> </template>
<v-list <v-list :tile="false" flat nav>
:tile="false" <app-bar-item to="/"
flat ><v-list-item-title v-text="'用户名:'+$store.state.user.user.username"
nav /></app-bar-item>
> <app-bar-item to="/"
><v-list-item-title v-text="'称号:'+$store.state.user.user.nick"
/></app-bar-item>
<app-bar-item to="/"><v-list-item-title v-text="'用户名:橙子'" /></app-bar-item> <v-divider class="mb-2 mt-2" />
<app-bar-item to="/"><v-list-item-title v-text="'称号:橙子'" /></app-bar-item>
<v-divider class="mb-2 mt-2"/>
<template v-for="(p, i) in profile"> <template v-for="(p, i) in profile">
<v-divider <v-divider v-if="p.divider" :key="`divider-${i}`" class="mb-2 mt-2" />
v-if="p.divider"
:key="`divider-${i}`"
class="mb-2 mt-2"
/>
<app-bar-item <app-bar-item v-else :key="`item-${i}`" to="/">
v-else
:key="`item-${i}`"
to="/"
>
<v-list-item-title v-text="p.title" /> <v-list-item-title v-text="p.title" />
</app-bar-item> </app-bar-item>
</template> </template>
@@ -60,16 +36,15 @@
</template> </template>
<script> <script>
export default { export default {
name: 'DefaultAccount', name: "DefaultAccount",
data: () => ({ data: () => ({
profile: [ profile: [
{ title: '用户信息' }, { title: "用户信息" },
{ title: '设置' }, { title: "设置" },
{ divider: true }, { divider: true },
{ title: '登出' }, { title: "登出" },
], ],
}), }),
} };
</script> </script>

View File

@@ -3,11 +3,7 @@
<v-row justify="center"> <v-row justify="center">
<v-col cols="12" md="4"> <v-col cols="12" md="4">
<app-card class="mt-4 text-center"> <app-card class="mt-4 text-center">
<v-img <ccAvatar :size="128" class="rounded-circle elevation-6 mt-n12 d-inline-block"></ccAvatar>
class="rounded-circle elevation-6 mt-n12 d-inline-block"
src="https://demos.creative-tim.com/vue-material-dashboard/img/marc.aba54d65.jpg"
width="128"
/>
<v-card-text class="text-center"> <v-card-text class="text-center">
<h6 class="text-h6 mb-2 text--secondary"> <h6 class="text-h6 mb-2 text--secondary">
@@ -321,8 +317,12 @@ export default {
this.userInfo = resp.data; this.userInfo = resp.data;
this.userInfo.password = ""; this.userInfo.password = "";
this.editInfo = Object.assign({}, this.userInfo); this.editInfo = Object.assign({}, this.userInfo);
this.$store.commit('SET_USER',this.userInfo)
}); });
menuApi.GetTopMenusByHttpUser().then((resp) => { menuApi.GetTopMenusByHttpUser().then((resp) => {
this.menuInfo = resp.data; this.menuInfo = resp.data;
}); });
@@ -333,9 +333,13 @@ choiceImg() {
uploadImage() { uploadImage() {
const file = this.$refs.imgFile.files[0]; const file = this.$refs.imgFile.files[0];
let formData = new FormData(); let formData = new FormData();
formData.append("img", file); formData.append("file", file);
fileApi.Upload(formData).then(resp=>{ fileApi.EditIcon(formData).then(resp=>{
this.init(); this.init();
this.$dialog.notify.success(resp.msg, {
position: "top-right",
timeout: 5000,
});
}) })
}, },