Merge branch 'master' into net6.0
This commit is contained in:
@@ -160,14 +160,13 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
throw new CustomException("表不能为空");
|
||||
}
|
||||
string[] tableNames = tables.Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
var userName = HttpContext.GetName();
|
||||
|
||||
int result = 0;
|
||||
foreach (var tableName in tableNames)
|
||||
{
|
||||
var tabInfo = _CodeGeneraterService.GetTableInfo(dbName, tableName);
|
||||
if (tabInfo != null)
|
||||
{
|
||||
GenTable genTable = CodeGeneratorTool.InitTable(dbName, userName, tableName, tabInfo?.Description);
|
||||
GenTable genTable = CodeGeneratorTool.InitTable(dbName, HttpContext.GetName(), tableName, tabInfo?.Description);
|
||||
genTable.TableId = GenTableService.ImportGenTable(genTable);
|
||||
|
||||
if (genTable.TableId > 0)
|
||||
@@ -179,13 +178,12 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
GenTableColumnService.DeleteGenTableColumnByTableName(tableName);
|
||||
GenTableColumnService.InsertGenTableColumn(genTableColumns);
|
||||
genTable.Columns = genTableColumns;
|
||||
|
||||
return SUCCESS(genTable);
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ToResponse(ResultCode.FAIL, "生成失败");
|
||||
return ToResponse(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,6 +19,8 @@ using ZR.Service.System;
|
||||
using Microsoft.Extensions.Options;
|
||||
using UAParser;
|
||||
using IPTools.Core;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace ZR.Admin.WebApi.Controllers.System
|
||||
{
|
||||
@@ -80,13 +82,13 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
}
|
||||
|
||||
var user = sysLoginService.Login(loginBody, RecordLogInfo(httpContextAccessor.HttpContext));
|
||||
|
||||
|
||||
List<SysRole> roles = roleService.SelectUserRoleListByUserId(user.UserId);
|
||||
//权限集合 eg *:*:*,system:user:list
|
||||
List<string> permissions = permissionService.GetMenuPermission(user);
|
||||
|
||||
LoginUser loginUser = new(user, roles, permissions);
|
||||
CacheHelper.SetCache(GlobalConstant.UserPermKEY + user.UserId, permissions);
|
||||
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + user.UserId, permissions);
|
||||
return SUCCESS(JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser), jwtSettings.JwtSettings));
|
||||
}
|
||||
|
||||
@@ -105,9 +107,9 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
//}).Wait();
|
||||
var userid = HttpContext.GetUId();
|
||||
var name = HttpContext.GetName();
|
||||
|
||||
CacheHelper.Remove(GlobalConstant.UserPermKEY + userid);
|
||||
return SUCCESS(new { name , id = userid });
|
||||
|
||||
CacheService.RemoveUserPerms(GlobalConstant.UserPermKEY + userid);
|
||||
return SUCCESS(new { name, id = userid });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,9 +200,41 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
ipaddr = ipAddr,
|
||||
userName = context.GetName(),
|
||||
loginLocation = ip_info.Province + "-" + ip_info.City
|
||||
};
|
||||
};
|
||||
|
||||
return sysLogininfor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/register")]
|
||||
[AllowAnonymous]
|
||||
[Log(Title = "注册", BusinessType = Infrastructure.Enums.BusinessType.INSERT)]
|
||||
public IActionResult Register([FromBody] RegisterDto dto)
|
||||
{
|
||||
SysConfig config = sysConfigService.GetSysConfigByKey("sys.account.register");
|
||||
if (config?.ConfigValue != "true")
|
||||
{
|
||||
return ToResponse(ResultCode.CUSTOM_ERROR, "当前系统没有开启注册功能!");
|
||||
}
|
||||
SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
|
||||
if (sysConfig?.ConfigValue != "off" && CacheHelper.Get(dto.Uuid) is string str && !str.ToLower().Equals(dto.Code.ToLower()))
|
||||
{
|
||||
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
||||
}
|
||||
if (UserConstants.NOT_UNIQUE.Equals(sysUserService.CheckUserNameUnique(dto.Username)))
|
||||
{
|
||||
return ToResponse(ResultCode.CUSTOM_ERROR, $"保存用户{dto.Username}失败,注册账号已存在");
|
||||
}
|
||||
SysUser user = sysUserService.Register(dto);
|
||||
if (user.UserId > 0)
|
||||
{
|
||||
return SUCCESS(user);
|
||||
}
|
||||
return ToResponse(ResultCode.CUSTOM_ERROR, "注册失败,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,9 +134,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
LoginUser loginUser = Framework.JwtUtil.GetLoginUser(HttpContext);
|
||||
if (formFile == null) throw new CustomException("请选择文件");
|
||||
|
||||
string fileExt = Path.GetExtension(formFile.FileName);
|
||||
string fileName = FileUtil.HashFileName() + (fileExt.IsEmpty() ? ".png" : fileExt);
|
||||
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, fileName, "", HttpContext.GetName(), formFile);
|
||||
SysFile file = await FileService.SaveFileToLocal(hostEnvironment.WebRootPath, "", "", HttpContext.GetName(), formFile);
|
||||
|
||||
UserService.UpdatePhoto(new SysUser() { Avatar = file.AccessUrl, UserId = loginUser.UserId });
|
||||
return SUCCESS(new { imgUrl = file.AccessUrl });
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// <param name="formFile">使用IFromFile必须使用name属性否则获取不到文件</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("importData")]
|
||||
[Log(Title = "用户导入", BusinessType = BusinessType.IMPORT)]
|
||||
[Log(Title = "用户导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||
[ActionPermissionFilter(Permission = "system:user:import")]
|
||||
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
|
||||
{
|
||||
@@ -189,7 +189,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("importTemplate")]
|
||||
[Log(Title = "用户模板", BusinessType = BusinessType.EXPORT)]
|
||||
[Log(Title = "用户模板", BusinessType = BusinessType.EXPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
|
||||
[AllowAnonymous]
|
||||
public IActionResult ImportTemplateExcel()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user