mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-20 00:16:37 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
378cbd580f | ||
|
|
e7f4e743e3 | ||
|
|
b934ce2893 | ||
|
|
5eec076ea2 |
@@ -22,7 +22,7 @@ Yi框架-一套与SqlSugar一样爽的.Net6低代码开源框架。
|
|||||||
适合.Net6学习、Sqlsugar学习 、项目二次开发。
|
适合.Net6学习、Sqlsugar学习 、项目二次开发。
|
||||||
集大成者,终究轮子
|
集大成者,终究轮子
|
||||||
|
|
||||||
Yi框架最新版本标签:`v1.1.0`,具体版本可以查看标签迭代
|
Yi框架最新版本标签:`v1.1.2`,具体版本可以查看标签迭代
|
||||||
|
|
||||||
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
|
(项目与Sqlsugar同步更新,但这作者老杰哥代码天天爆肝到凌晨两点,我们也尽量会跟上他的脚步。更新频繁,所以可watching持续关注。)
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -90,6 +90,34 @@
|
|||||||
<param name="ids"></param>
|
<param name="ids"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="T:Yi.Framework.ApiMicroservice.Controllers.FileController">
|
||||||
|
<summary>
|
||||||
|
文件
|
||||||
|
</summary>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.#ctor(Yi.Framework.Interface.IUserService,Microsoft.Extensions.Hosting.IHostEnvironment)">
|
||||||
|
<summary>
|
||||||
|
使用本地存储,未进行数据库记录
|
||||||
|
</summary>
|
||||||
|
<param name="iUserService"></param>
|
||||||
|
<param name="env"></param>
|
||||||
|
</member>
|
||||||
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.FileController.Get(System.String,System.String)">
|
||||||
|
<summary>
|
||||||
|
文件下载
|
||||||
|
</summary>
|
||||||
|
<param name="type"></param>
|
||||||
|
<param name="fileName"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</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.LogController.Add">
|
<member name="M:Yi.Framework.ApiMicroservice.Controllers.LogController.Add">
|
||||||
<summary>
|
<summary>
|
||||||
自动分表,日志添加
|
自动分表,日志添加
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
{
|
{
|
||||||
private IUserService _iUserService;
|
private IUserService _iUserService;
|
||||||
private JwtInvoker _jwtInvoker;
|
private JwtInvoker _jwtInvoker;
|
||||||
|
private ILogger _logger;
|
||||||
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
|
public AccountController(ILogger<UserEntity> logger, IUserService iUserService, JwtInvoker jwtInvoker)
|
||||||
{
|
{
|
||||||
_iUserService = iUserService;
|
_iUserService = iUserService;
|
||||||
_jwtInvoker = jwtInvoker;
|
_jwtInvoker = jwtInvoker;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -45,7 +47,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
UserEntity user = new();
|
UserEntity user = new();
|
||||||
if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o))
|
if (await _iUserService.Login(loginDto.UserName, loginDto.Password, o => user = o))
|
||||||
{
|
{
|
||||||
return Result.Success("登录成功!").SetData(new { user, token = _jwtInvoker.GetAccessToken(user) });
|
return Result.Success("登录成功!").SetData(new { token = _jwtInvoker.GetAccessToken(user) });
|
||||||
}
|
}
|
||||||
return Result.SuccessError("登录失败!用户名或者密码错误!");
|
return Result.SuccessError("登录失败!用户名或者密码错误!");
|
||||||
}
|
}
|
||||||
@@ -67,7 +69,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
|||||||
return Result.SuccessError("注册失败!用户名已存在!");
|
return Result.SuccessError("注册失败!用户名已存在!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public Result Logout()
|
||||||
|
{
|
||||||
|
return Result.Success("安全登出成功!");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过已登录的用户获取用户信息及菜单
|
/// 通过已登录的用户获取用户信息及菜单
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Yi.Framework.Common.Models;
|
||||||
|
using Yi.Framework.Interface;
|
||||||
|
using Yi.Framework.WebCore;
|
||||||
|
|
||||||
|
namespace Yi.Framework.ApiMicroservice.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class FileController : ControllerBase
|
||||||
|
{
|
||||||
|
private IUserService _iUserService;
|
||||||
|
private readonly IHostEnvironment _env;
|
||||||
|
/// <summary>
|
||||||
|
/// 使用本地存储,未进行数据库记录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iUserService"></param>
|
||||||
|
/// <param name="env"></param>
|
||||||
|
public FileController(IUserService iUserService, IHostEnvironment env)
|
||||||
|
{
|
||||||
|
_iUserService = iUserService;
|
||||||
|
_env = env;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件下载
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Route("/api/{type}/{fileName}")]
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Get(string type, string fileName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var path = Path.Combine($"wwwroot/{type}", fileName);
|
||||||
|
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>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Route("/api/Upload/{type}")]
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<Result> Upload(string type, IFormFile file)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string filename = Guid.NewGuid().ToString() + Path.GetExtension(file.FileName);
|
||||||
|
using (var stream = new FileStream(Path.Combine($"wwwroot/{type}", filename), FileMode.CreateNew, FileAccess.Write))
|
||||||
|
{
|
||||||
|
await file.CopyToAsync(stream);
|
||||||
|
}
|
||||||
|
return Result.Success().SetData(filename);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return Result.Error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//[HttpGet]
|
||||||
|
//public async Task<IActionResult> ExportFile()
|
||||||
|
//{
|
||||||
|
// var userdata = await _userService.GetAllEntitiesTrueAsync();
|
||||||
|
// var userList = userdata.ToList();
|
||||||
|
// List<string> header = new() { "用户", "密码", "头像", "昵称", "邮箱", "ip", "年龄", "个人介绍", "地址", "手机", "角色" };
|
||||||
|
// var filename = Common.Helper.ExcelHelper.CreateExcelFromList(userList, header, _env.ContentRootPath.ToString());
|
||||||
|
// var MimeType = Common.Helper.MimeHelper.GetMimeMapping(filename);
|
||||||
|
// return new FileStreamResult(new FileStream(Path.Combine(_env.ContentRootPath+@"/wwwroot/excel", filename), FileMode.Open),MimeType);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
@@ -78,7 +78,7 @@ namespace Yi.Framework.Model.Models
|
|||||||
///
|
///
|
||||||
///</summary>
|
///</summary>
|
||||||
[SugarColumn(ColumnName="Icon" )]
|
[SugarColumn(ColumnName="Icon" )]
|
||||||
public long? Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
///</summary>
|
///</summary>
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ export default {
|
|||||||
},
|
},
|
||||||
updateUserByHttp(user)
|
updateUserByHttp(user)
|
||||||
{
|
{
|
||||||
|
|
||||||
return myaxios({
|
return myaxios({
|
||||||
url: `/Account/updateUserByHttp`,
|
url: `/Account/updateUserByHttp`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import myaxios from '@/util/myaxios'
|
import myaxios from '@/util/myaxios'
|
||||||
export default {
|
export default {
|
||||||
EditIcon(file) {
|
UploadImage(file) {
|
||||||
return myaxios({
|
return myaxios({
|
||||||
url: '/File/EditIcon',
|
url: '/Upload/image',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers: { "Content-Type": "multipart/form-data" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
data: file
|
data: file
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { getToken, setToken, getUser, setUser, removeToken } from '../../util/usertoken'
|
import { getPer, setPer, getToken, setToken, getUser, setUser, removeToken } from '../../util/usertoken'
|
||||||
import accountApi from "@/api/accountApi"
|
import accountApi from "@/api/accountApi"
|
||||||
|
|
||||||
//再导入axion请求
|
//再导入axion请求
|
||||||
const state = { //状态
|
const state = { //状态
|
||||||
|
per: getPer(),
|
||||||
token: getToken(),
|
token: getToken(),
|
||||||
user: getUser(),
|
user: getUser(),
|
||||||
dark: false,
|
dark: false,
|
||||||
@@ -20,19 +21,24 @@ const state = { //状态
|
|||||||
'https://s1.ax1x.com/2022/03/26/qdNnbD.jpg',
|
'https://s1.ax1x.com/2022/03/26/qdNnbD.jpg',
|
||||||
'https://s1.ax1x.com/2022/03/26/qdNMUH.jpg',
|
'https://s1.ax1x.com/2022/03/26/qdNMUH.jpg',
|
||||||
'https://s1.ax1x.com/2022/03/26/qdNKVe.jpg',
|
'https://s1.ax1x.com/2022/03/26/qdNKVe.jpg',
|
||||||
'https://s1.ax1x.com/2022/03/26/qdNmDO.jpg'
|
'https://s1.ax1x.com/2022/03/26/qdNmDO.jpg'
|
||||||
],
|
],
|
||||||
notifications: [],
|
notifications: [],
|
||||||
rtl: false
|
rtl: false
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutations = { //变化//载荷
|
const mutations = { //变化//载荷
|
||||||
|
SET_PER(state, per) {
|
||||||
|
state.per = per
|
||||||
|
setPer(per)
|
||||||
|
},
|
||||||
SET_TOKEN(state, token) {
|
SET_TOKEN(state, token) {
|
||||||
state.token = token
|
state.token = token
|
||||||
setToken(token)
|
setToken(token)
|
||||||
},
|
},
|
||||||
SET_USER(state, user) {
|
SET_USER(state, user) {
|
||||||
state.user = user
|
state.user = user
|
||||||
|
console.log(user)
|
||||||
setUser(user)
|
setUser(user)
|
||||||
},
|
},
|
||||||
SetGradient(state, gradient) {
|
SetGradient(state, gradient) {
|
||||||
@@ -45,7 +51,7 @@ const mutations = { //变化//载荷
|
|||||||
|
|
||||||
//在action中可以配合axios进行权限判断
|
//在action中可以配合axios进行权限判断
|
||||||
const actions = { //动作
|
const actions = { //动作
|
||||||
setIcon({ commit, state }, icon) {
|
SetIcon({ commit, state }, icon) {
|
||||||
state.user.icon = icon
|
state.user.icon = icon
|
||||||
commit('SET_USER', state.user)
|
commit('SET_USER', state.user)
|
||||||
},
|
},
|
||||||
@@ -78,9 +84,22 @@ const actions = { //动作
|
|||||||
accountApi.login(form.username.trim(), form.password.trim()).then(resp => {
|
accountApi.login(form.username.trim(), form.password.trim()).then(resp => {
|
||||||
if (resp.status) {
|
if (resp.status) {
|
||||||
commit('SET_TOKEN', resp.data.token)
|
commit('SET_TOKEN', resp.data.token)
|
||||||
commit('SET_USER', resp.data.user)
|
|
||||||
|
|
||||||
|
accountApi.getUserAllInfo().then(resp2=>{
|
||||||
|
commit('SET_USER', resp2.data.user)
|
||||||
|
|
||||||
|
var code=[];
|
||||||
|
resp2.data.menus.forEach(element => {
|
||||||
|
code.push(element.permissionCode)
|
||||||
|
});
|
||||||
|
commit('SET_PER', code)
|
||||||
|
resolv(resp)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
resolv(resp)
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,18 +1,30 @@
|
|||||||
const TOKEN_KEY = "token_key"
|
const TOKEN_KEY = "token_key"
|
||||||
const USER_KEY = "user_key"
|
const USER_KEY = "user_key"
|
||||||
|
const PER_KEY="per_key"
|
||||||
export function getToken() {
|
export function getToken() {
|
||||||
return localStorage.getItem(TOKEN_KEY)
|
return localStorage.getItem(TOKEN_KEY)
|
||||||
}
|
}
|
||||||
export function setToken(token) {
|
|
||||||
return localStorage.setItem(TOKEN_KEY, token)
|
|
||||||
}
|
|
||||||
export function getUser() {
|
export function getUser() {
|
||||||
return JSON.parse(localStorage.getItem(USER_KEY))
|
return JSON.parse(localStorage.getItem(USER_KEY))
|
||||||
}
|
}
|
||||||
|
export function getPer() {
|
||||||
|
return JSON.parse(localStorage.getItem(PER_KEY))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function setToken(token) {
|
||||||
|
return localStorage.setItem(TOKEN_KEY, token)
|
||||||
|
}
|
||||||
|
|
||||||
export function setUser(user) {
|
export function setUser(user) {
|
||||||
return localStorage.setItem(USER_KEY, JSON.stringify(user))
|
return localStorage.setItem(USER_KEY, JSON.stringify(user))
|
||||||
}
|
}
|
||||||
|
export function setPer(per) {
|
||||||
|
return localStorage.setItem(PER_KEY, JSON.stringify(per))
|
||||||
|
}
|
||||||
export function removeToken() {
|
export function removeToken() {
|
||||||
localStorage.removeItem(TOKEN_KEY)
|
localStorage.removeItem(TOKEN_KEY)
|
||||||
localStorage.removeItem(USER_KEY)
|
localStorage.removeItem(USER_KEY)
|
||||||
|
localStorage.removeItem(PER_KEY)
|
||||||
}
|
}
|
||||||
@@ -59,6 +59,9 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
|
|
||||||
|
//这里可以遍历后台的菜单code,根据对应的菜单code来给axiosUrls的增删改查赋值即可
|
||||||
|
|
||||||
this.axiosUrls = {
|
this.axiosUrls = {
|
||||||
get: "/user/GetList",
|
get: "/user/GetList",
|
||||||
update: "/user/Update",
|
update: "/user/Update",
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
login() {
|
login() {
|
||||||
this.loader = "true";
|
this.loader = true;
|
||||||
this.btn_dis=true;
|
this.btn_dis=true;
|
||||||
this.$store.dispatch("Login", this.form).then((resp) => {
|
this.$store.dispatch("Login", this.form).then((resp) => {
|
||||||
if (resp.status) {
|
if (resp.status) {
|
||||||
|
|||||||
@@ -272,7 +272,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import fileApi from "../api/fileApi";
|
import fileApi from "../api/fileApi";
|
||||||
import userApi from "../api/userApi";
|
|
||||||
import accountApi from "../api/accountApi";
|
import accountApi from "../api/accountApi";
|
||||||
export default {
|
export default {
|
||||||
name: "UserProfileView",
|
name: "UserProfileView",
|
||||||
@@ -343,15 +342,19 @@ export default {
|
|||||||
this.$refs.imgFile.dispatchEvent(new MouseEvent("click"));
|
this.$refs.imgFile.dispatchEvent(new MouseEvent("click"));
|
||||||
},
|
},
|
||||||
uploadImage() {
|
uploadImage() {
|
||||||
|
//修改头像,需要先上传头像,修改editInfo的头像信息即可
|
||||||
const file = this.$refs.imgFile.files[0];
|
const file = this.$refs.imgFile.files[0];
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
fileApi.EditIcon(formData).then((resp) => {
|
|
||||||
this.init();
|
|
||||||
this.$dialog.notify.success(resp.msg, {
|
fileApi.UploadImage(formData).then((resp) => {
|
||||||
|
this.editInfo.icon=resp.data
|
||||||
|
this.$dialog.notify.success("头像加载成功,点击保存以设置", {
|
||||||
position: "top-right",
|
position: "top-right",
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
|
this.$store.dispatch("SetIcon", this.editInfo.icon)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user