Commit 919732a5 authored by liuxiaohui's avatar liuxiaohui

UploadFile The Server

parent 0f7bb16e
...@@ -35,10 +35,11 @@ ...@@ -35,10 +35,11 @@
"ApiKey": "Uicm6VMjVPdzepbqnwNvpl25xJjRxFekMV8QZdeTLTwacNBl" "ApiKey": "Uicm6VMjVPdzepbqnwNvpl25xJjRxFekMV8QZdeTLTwacNBl"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Host=yg-sql-dev-wan.pg.rds.aliyuncs.com;Port=5432;Database=BBMChatGLM;User ID=yg;Password=YG@sql!dev2022123;", "Default": "Host=yg-sql-dev-wan.pg.rds.aliyuncs.com;Port=5432;Database=BBMChatGLM;User ID=yg;Password=YG@sql!dev2022123;"
}, },
"Redis": { "Redis": {
"Configuration": "yg-redis-dev-wan.redis.rds.aliyuncs.com:6379,password=YG@redis!dev2022123,defaultDatabase=5" "Configuration": "yg-redis-dev-wan.redis.rds.aliyuncs.com:6379,password=YG@redis!dev2022123,defaultDatabase=5"
}, },
"Jwt": { "Jwt": {
"Audience": "BBM.ChatGLM", "Audience": "BBM.ChatGLM",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,6 +3,8 @@ using BBM.ChatGLM.User; ...@@ -3,6 +3,8 @@ using BBM.ChatGLM.User;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using OfficeOpenXml; using OfficeOpenXml;
using System;
using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity; using Volo.Abp.Identity;
...@@ -77,14 +79,15 @@ namespace BBM.ChatGLM.Controllers ...@@ -77,14 +79,15 @@ namespace BBM.ChatGLM.Controllers
Dtos.Results xiangying = new Dtos.Results(); Dtos.Results xiangying = new Dtos.Results();
var failNum = 0; var failNum = 0;
if (file == null) if (file == null)
return BadRequest("Excel文件为空"); return BadRequest("Excel文件为空");
string directoryPath = Environment.CurrentDirectory + @"\Excels";
var fileName = file.FileName; if (!Directory.Exists(directoryPath))
var filePath = Path.Combine("C:\\Excel", fileName); Directory.CreateDirectory(directoryPath);
var filePath = Path.Combine(directoryPath, file.FileName);
using (var stream = new FileStream(filePath, FileMode.Create)) using (var stream = new FileStream(filePath, FileMode.Create))
{ {
...@@ -97,9 +100,10 @@ namespace BBM.ChatGLM.Controllers ...@@ -97,9 +100,10 @@ namespace BBM.ChatGLM.Controllers
var totalRows = worksheet.Dimension.Rows; var totalRows = worksheet.Dimension.Rows;
var row = 2; var row = 2;
var userName = "";
var userName = "";
var phoneNumber = ""; var phoneNumber = "";
var userRole = ""; var userRole = "";
while (row <= totalRows) while (row <= totalRows)
{ {
...@@ -139,7 +143,7 @@ namespace BBM.ChatGLM.Controllers ...@@ -139,7 +143,7 @@ namespace BBM.ChatGLM.Controllers
userInput.Role = userRole; userInput.Role = userRole;
userInput.IsActive = true; userInput.IsActive = true;
var userDto = await _usersAppService.CreateAsync(userInput); await _usersAppService.CreateAsync(userInput);
continue; continue;
} }
} }
......
...@@ -466,7 +466,8 @@ const UserManage = () => { ...@@ -466,7 +466,8 @@ const UserManage = () => {
options={false} options={false}
headerTitle="账号列表" headerTitle="账号列表"
toolBarRender={() => [ toolBarRender={() => [
<Button onClick={downloadExcelTemplate}>批量添加用户Excel模板</Button>, <Button>
<a href='https://baibaomen.oss-cn-hangzhou.aliyuncs.com/zhensheng/excelTemplate.xlsx'>批量添加用户Excel模板</a></Button>,
<Upload <Upload
beforeUpload={handleUpload} beforeUpload={handleUpload}
disabled={uploadButtonDisable} disabled={uploadButtonDisable}
......
...@@ -5,7 +5,6 @@ interface ILoginParams { ...@@ -5,7 +5,6 @@ interface ILoginParams {
password: string; password: string;
} }
const request = extend({}); const request = extend({});
let host = ""; let host = "";
...@@ -30,7 +29,6 @@ request.interceptors.request.use((url, options) => { ...@@ -30,7 +29,6 @@ request.interceptors.request.use((url, options) => {
Authorization: `Bearer ${token || ''}`, Authorization: `Bearer ${token || ''}`,
'Content-Type': 'application/json', 'Content-Type': 'application/json',
__tenant: '3a0a90fe-9a0d-70f4-200d-a80a41fb6195', __tenant: '3a0a90fe-9a0d-70f4-200d-a80a41fb6195',
}; };
} }
return { return {
...@@ -200,7 +198,7 @@ export const postExcelFile = (file) => { ...@@ -200,7 +198,7 @@ export const postExcelFile = (file) => {
export const postDowload = () => { export const postDowload = () => {
return request('Template.xlsx', { return request('Template.xlsx', {
method: 'GET', method: 'GET',
responseType: 'blob', // 将响应类型设置为二进制流 responseType: 'blob', // 将响应类型设置为二进制流
}).then((response) => { }).then((response) => {
const url = window.URL.createObjectURL(new Blob([response])); const url = window.URL.createObjectURL(new Blob([response]));
const link = document.createElement('a'); const link = document.createElement('a');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment