😎1、修复刷新页面后个人中心密码修改无效问题 2、修改小程序二维码生成功能路径配置,增加相对路径的适配,并且返回相对路径 3、代码清理

This commit is contained in:
zuohuaijun 2025-03-25 00:24:49 +08:00
parent fb4e0d1de5
commit caf2abd9bf
9 changed files with 145 additions and 21 deletions

View File

@ -249,7 +249,7 @@ public class SysCodeGenService : IDynamicApiController, ITransient
foreach (var column in columnList)
{
var property = properties.First(u => u.ColumnName == column.ColumnName);
var property = properties.FirstOrDefault(u => u.ColumnName == column.ColumnName);
column.ColumnComment ??= property?.ColumnComment;
column.PropertyName = property?.PropertyName;
}

View File

@ -261,6 +261,15 @@ public class SysConfigService : IDynamicApiController, ITransient
}
}
/// <summary>
/// 获取密码加解密公钥
/// </summary>
/// <returns></returns>
public string GetSmPublicKey()
{
return App.GetConfig<string>("Cryptogram:PublicKey", true);
}
/// <summary>
/// 清除配置缓存
/// </summary>

View File

@ -33,7 +33,7 @@ public class SysUserLdapService : ITransient
await _sysUserLdapRep.AsUpdateable()
.InnerJoin<SysUser>((l, u) => l.EmployeeId == u.Account)
.SetColumns((l, u) => new SysUserLdap { UserId = u.Id })
.Where((l, u) => l.TenantId == tenantId && u.Status == StatusEnum.Enable && u.IsDelete == false)
.Where((l, u) => l.TenantId == tenantId && u.Status == StatusEnum.Enable)
.ExecuteCommandAsync();
}

View File

@ -18,7 +18,23 @@ public class WxPhoneOutput
public class GenerateQRImageOutput
{
public bool Success { get; set; }
public string ImgPath { get; set; }
public string Message { get; set; }
/// <summary>
/// 生成状态
/// </summary>
public bool Success { get; set; } = false;
/// <summary>
/// 生成图片的绝对路径
/// </summary>
public string ImgPath { get; set; } = "";
/// <summary>
/// 生成图片的相对路径
/// </summary>
public string RelativeImgPath { get; set; } = "";
/// <summary>
/// 生成图片的错误信息
/// </summary>
public string Message { get; set; } = "";
}

View File

@ -274,8 +274,6 @@ public class SysWxOpenService : IDynamicApiController, ITransient
GenerateQRImageOutput generateQRImageOutInput = new();
if (input.PagePath.IsNullOrEmpty())
{
generateQRImageOutInput.Success = false;
generateQRImageOutInput.ImgPath = "";
generateQRImageOutInput.Message = $"生成失败 页面路径不能为空";
return generateQRImageOutInput;
}
@ -297,27 +295,39 @@ public class SysWxOpenService : IDynamicApiController, ITransient
if (response.IsSuccessful())
{
var QRImagePath = App.GetConfig<string>("Wechat:QRImagePath");
QRImagePath = string.IsNullOrEmpty(QRImagePath) ? Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "QRImage") : QRImagePath;
var relativeImgPath = string.Empty;
// 判断路径是绝对路径还是相对路径
var isPathRooted = Path.IsPathRooted(QRImagePath);
if (!isPathRooted)
{
// 相对路径
relativeImgPath = string.IsNullOrEmpty(QRImagePath) ? Path.Combine("upload", "QRImage") : QRImagePath;
QRImagePath = Path.Combine(App.WebHostEnvironment.WebRootPath, relativeImgPath);
}
//判断文件存放路径是否存在
if (!Directory.Exists(QRImagePath))
{
Directory.CreateDirectory(QRImagePath);
}
// 将二维码图片数据保存为文件
var filePath = Path.Combine(QRImagePath, $"{input.ImageName.ToUpper()}.png");
var fileName = $"{input.ImageName.ToUpper()}.png";
var filePath = Path.Combine(QRImagePath, fileName);
if (File.Exists(filePath))
{
File.Delete(filePath);
}
File.WriteAllBytes(filePath, response.GetRawBytes());
generateQRImageOutInput.Success = true;
generateQRImageOutInput.ImgPath = filePath;
generateQRImageOutInput.RelativeImgPath = Path.Combine(relativeImgPath, fileName);
generateQRImageOutInput.Message = "生成成功";
}
else
{
// 处理错误情况
generateQRImageOutInput.Success = false;
generateQRImageOutInput.ImgPath = "";
generateQRImageOutInput.Message = $"生成失败 错误代码:{response.ErrorCode} 错误描述:{response.ErrorMessage}";
}
return generateQRImageOutInput;

View File

@ -465,6 +465,49 @@ export const SysConfigApiAxiosParamCreator = function (configuration?: Configura
options: localVarRequestOptions,
};
},
/**
*
* @summary
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
apiSysConfigSmPublicKeyGet: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/sysConfig/smPublicKey`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, 'https://example.com');
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions :AxiosRequestConfig = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication Bearer required
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
const query = new URLSearchParams(localVarUrlObj.search);
for (const key in localVarQueryParameter) {
query.set(key, localVarQueryParameter[key]);
}
for (const key in options.params) {
query.set(key, options.params[key]);
}
localVarUrlObj.search = (new URLSearchParams(query)).toString();
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash,
options: localVarRequestOptions,
};
},
/**
*
* @summary 🔖
@ -647,6 +690,19 @@ export const SysConfigApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysConfigSmPublicKeyGet(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => Promise<AxiosResponse<AdminNETResultString>>> {
const localVarAxiosArgs = await SysConfigApiAxiosParamCreator(configuration).apiSysConfigSmPublicKeyGet(options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs :AxiosRequestConfig = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url};
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary 🔖
@ -759,6 +815,15 @@ export const SysConfigApiFactory = function (configuration?: Configuration, base
async apiSysConfigPagePost(body?: PageConfigInput, options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultSqlSugarPagedListSysConfig>> {
return SysConfigApiFp(configuration).apiSysConfigPagePost(body, options).then((request) => request(axios, basePath));
},
/**
*
* @summary
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async apiSysConfigSmPublicKeyGet(options?: AxiosRequestConfig): Promise<AxiosResponse<AdminNETResultString>> {
return SysConfigApiFp(configuration).apiSysConfigSmPublicKeyGet(options).then((request) => request(axios, basePath));
},
/**
*
* @summary 🔖
@ -877,6 +942,16 @@ export class SysConfigApi extends BaseAPI {
public async apiSysConfigPagePost(body?: PageConfigInput, options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultSqlSugarPagedListSysConfig>> {
return SysConfigApiFp(this.configuration).apiSysConfigPagePost(body, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof SysConfigApi
*/
public async apiSysConfigSmPublicKeyGet(options?: AxiosRequestConfig) : Promise<AxiosResponse<AdminNETResultString>> {
return SysConfigApiFp(this.configuration).apiSysConfigSmPublicKeyGet(options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @summary 🔖

View File

@ -21,18 +21,32 @@
export interface GenerateQRImageOutput {
/**
*
*
* @type {boolean}
* @memberof GenerateQRImageOutput
*/
success?: boolean;
/**
*
*
* @type {string}
* @memberof GenerateQRImageOutput
*/
imgPath?: string | null;
/**
*
*
* @type {string}
* @memberof GenerateQRImageOutput
*/
relativeImgPath?: string | null;
/**
*
*
* @type {string}
* @memberof GenerateQRImageOutput
*/

View File

@ -33,10 +33,6 @@ import 'vue3-flag-icons/styles';
disAutoConnect();
// // 加载系统信息
// import { loadSysInfo } from '/@/utils/sysInfo';
// loadSysInfo();
const app = createApp(App);
directive(app);
other.elSvg(app);

View File

@ -183,7 +183,7 @@ import { sm2 } from 'sm-crypto-v2';
import { clearAccessTokens, getAPI } from '/@/utils/axios-utils';
import { useI18n } from 'vue-i18n';
import { SysFileApi, SysUserApi } from '/@/api-services/api';
import { SysConfigApi, SysFileApi, SysUserApi } from '/@/api-services/api';
import { ChangePwdInput, SysUser, SysFile } from '/@/api-services/models';
const { t } = useI18n();
@ -312,8 +312,12 @@ const submitPassword = () => {
if (!valid) return;
// SM2
const cpwd: ChangePwdInput = { passwordOld: '', passwordNew: '' };
const publicKey = window.__env__.VITE_SM_PUBLIC_KEY;
var cpwd: ChangePwdInput = { passwordOld: '', passwordNew: '' };
var publicKey = window.__env__.VITE_SM_PUBLIC_KEY;
if (publicKey == '') {
var res = await getAPI(SysConfigApi).apiSysConfigSmPublicKeyGet();
publicKey = window.__env__.VITE_SM_PUBLIC_KEY = res.data.result ?? '';
}
cpwd.passwordOld = sm2.doEncrypt(state.ruleFormPassword.passwordOld, publicKey, 1);
cpwd.passwordNew = sm2.doEncrypt(state.ruleFormPassword.passwordNew, publicKey, 1);
await getAPI(SysUserApi).apiSysUserChangePwdPost(cpwd);