修改授权方式为手机号码和验证码方式

测试出的问题修复
This commit is contained in:
范露尧
2023-07-12 16:11:42 +08:00
parent fbbabeb690
commit 589b8a0132
86 changed files with 365 additions and 120 deletions

View File

@@ -1,4 +1,6 @@
namespace Ewide.Core
using System;
namespace Ewide.Core
{
public class ClaimConst
{
@@ -21,6 +23,10 @@
/// 是否超级管理
/// </summary>
public const string CLAINM_SUPERADMIN = "SuperAdmin";
/// <summary>
/// 过期时间
/// </summary>
public const string ExpireTime = "";
}
}

View File

@@ -489,6 +489,11 @@
是否超级管理
</summary>
</member>
<member name="F:Ewide.Core.ClaimConst.ExpireTime">
<summary>
过期时间
</summary>
</member>
<member name="F:Ewide.Core.CommonConst.DEFAULT_PASSWORD">
<summary>
默认密码

View File

@@ -115,19 +115,19 @@ namespace Ewide.Core.Extension
return filter;
}
public static Task<PagedList<T>> ToPageData<T>(this IQueryable<T> source, PageInputBase input) where T : new()
public static async Task<PagedList<T>> ToPageData<T>(this IQueryable<T> source, PageInputBase input) where T : new()
{
return source.OrderBy(OrderBuilder<T>(input)).ToPagedListAsync(input.PageIndex, input.PageSize);
return await source.OrderBy(OrderBuilder<T>(input)).ToPagedListAsync(input.PageIndex, input.PageSize);
}
public static Task<PagedList<O>> ToPageData<T, O>(this IQueryable<T> source, PageInputBase input) where O : new()
public static async Task<PagedList<O>> ToPageData<T, O>(this IQueryable<T> source, PageInputBase input) where O : new()
{
return source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>()).ToPagedListAsync(input.PageIndex, input.PageSize);
return await source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>()).ToPagedListAsync(input.PageIndex, input.PageSize);
}
public static Task<PagedList<O>> ToPageData<T, O>(this IQueryable<T> source, PageInputBase input, TypeAdapterConfig config) where O : new()
public static async Task<PagedList<O>> ToPageData<T, O>(this IQueryable<T> source, PageInputBase input, TypeAdapterConfig config) where O : new()
{
return source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>(config)).ToPagedListAsync(input.PageIndex, input.PageSize);
return await source.OrderBy(OrderBuilder<T>(input)).Select(u => u.Adapt<O>(config)).ToPagedListAsync(input.PageIndex, input.PageSize);
}
#region DAPPER

View File

@@ -11,6 +11,7 @@ namespace Ewide.Core
bool SuperAdmin { get; }
SysUser User { get; }
string UserId { get; }
bool IsExpire { get; }
Task<SysUser> CheckUserAsync(string userId);
Task<SysUser> CheckUserAsync();

View File

@@ -51,7 +51,23 @@ namespace Ewide.Core
{
get => _httpContextAccessor.HttpContext.User.FindFirst(ClaimConst.CLAINM_SUPERADMIN)?.Value == ((int)AdminType.SuperAdmin).ToString();
}
public bool IsExpire
{
get
{
var _extime = _httpContextAccessor.HttpContext.User.FindFirst(ClaimConst.ExpireTime)?.Value;
if (string.IsNullOrWhiteSpace(_extime))
return true;
else
{
var extime = Convert.ToDateTime(_extime);
if (extime > DateTime.Now)
return false;
else
return true;
}
}
}
public SysUser User
{
get => _sysUserRep.Find(UserId);
@@ -220,9 +236,9 @@ namespace Ewide.Core
.Select(u => u.SysOrgId).ToListAsync();
}
public Task<List<string>> GetUserExtraAreaScopeList()
public async Task<List<string>> GetUserExtraAreaScopeList()
{
return GetUserExtraAreaScopeList(UserId);
return await GetUserExtraAreaScopeList(UserId);
}
public async Task<List<string>> GetUserExtraAreaScopeList(string userId)
@@ -230,14 +246,14 @@ namespace Ewide.Core
return await _sysUserAreaRep.DetachedEntities.Where(u => u.SysUserId == userId).Select(u => u.AreaCode).ToListAsync();
}
public Task<List<string>> GetRoleExtraDataScopeList(string roleId)
public async Task<List<string>> GetRoleExtraDataScopeList(string roleId)
{
return _sysRoleDataRep.DetachedEntities.Where(u => u.SysRoleId == roleId).Select(u => u.SysOrgId).ToListAsync();
return await _sysRoleDataRep.DetachedEntities.Where(u => u.SysRoleId == roleId).Select(u => u.SysOrgId).ToListAsync();
}
public Task<List<string>> GetRoleExtraAreaScopeList(string roleId)
public async Task<List<string>> GetRoleExtraAreaScopeList(string roleId)
{
return _sysRoleAreaRep.DetachedEntities.Where(u => u.SysRoleId == roleId).Select(u => u.AreaCode).ToListAsync();
return await _sysRoleAreaRep.DetachedEntities.Where(u => u.SysRoleId == roleId).Select(u => u.AreaCode).ToListAsync();
}
public Task<List<string>> GetUserAllDataScopeList()
{

View File

@@ -157,7 +157,7 @@ namespace Ewide.Core.Service
var user = await _sysUserRep.FirstOrDefaultAsync(u => (u.Account.Equals(input.Account) || u.Phone.Equals(input.Account) || u.Email.Equals(input.Account)) && u.Password.Equals(encryptPasswod));
_ = user ?? throw Oops.Oh(ErrorCode.D1000);
#endif
_ = user ?? throw Oops.Oh(ErrorCode.D1000);
// 验证账号是否被冻结
if (user.Status == CommonStatus.DISABLE)
throw Oops.Oh(ErrorCode.D1017);
@@ -176,6 +176,7 @@ namespace Ewide.Core.Service
{ ClaimConst.CLAINM_ACCOUNT, user.Account },
{ ClaimConst.CLAINM_NAME, user.Name },
{ ClaimConst.CLAINM_SUPERADMIN, user.AdminType },
{ ClaimConst.ExpireTime,DateTime.Now.AddHours(2)},
});
// 设置Swagger自动登录

View File

@@ -117,10 +117,10 @@ namespace Ewide.Core.Service
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public Task<bool> DelAsync(string key)
public async Task<bool> DelAsync(string key)
{
_cache.DelAsync(key);
return Task.FromResult(true);
await _cache.DelAsync(key);
return true;
}
/// <summary>
@@ -128,10 +128,10 @@ namespace Ewide.Core.Service
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public Task<bool> DelByPatternAsync(string key)
public async Task<bool> DelByPatternAsync(string key)
{
_cache.DelByPatternAsync(key);
return Task.FromResult(true);
await _cache.DelByPatternAsync(key);
return true;
}
/// <summary>

View File

@@ -141,7 +141,7 @@ namespace Ewide.Core.Service
codeGenConfig.EffectType = DataTypeToEff(codeGenConfig.NetType);
codeGenConfig.QueryType = "=="; // QueryTypeEnum.eq.ToString();
codeGenConfig.InsertAsync();
codeGenConfig.Insert();
}
}

View File

@@ -236,7 +236,7 @@ namespace Ewide.Core.Service.CodeGen
var pid1 = _sysMenuRep.InsertNowAsync(menuType1).GetAwaiter().GetResult().Entity.Id;
// 按钮-page
var menuType2 = new SysMenu
var menuType2 = await new SysMenu
{
Pid = pid1,
Pids = "[0],[" + pid0 + "],[" + pid1 + "],",
@@ -248,7 +248,7 @@ namespace Ewide.Core.Service.CodeGen
}.InsertAsync();
// 按钮-detail
var menuType2_1 = new SysMenu
var menuType2_1 = await new SysMenu
{
Pid = pid1,
Pids = "[0],[" + pid0 + "],[" + pid1 + "],",
@@ -260,7 +260,7 @@ namespace Ewide.Core.Service.CodeGen
}.InsertAsync();
// 按钮-add
var menuType2_2 = new SysMenu
var menuType2_2 = await new SysMenu
{
Pid = pid1,
Pids = "[0],[" + pid0 + "],[" + pid1 + "],",
@@ -272,7 +272,7 @@ namespace Ewide.Core.Service.CodeGen
}.InsertAsync();
// 按钮-delete
var menuType2_3 = new SysMenu
var menuType2_3 = await new SysMenu
{
Pid = pid1,
Pids = "[0],[" + pid0 + "],[" + pid1 + "],",
@@ -284,7 +284,7 @@ namespace Ewide.Core.Service.CodeGen
}.InsertAsync();
// 按钮-edit
var menuType2_4 = new SysMenu
var menuType2_4 = await new SysMenu
{
Pid = pid1,
Pids = "[0],[" + pid0 + "],[" + pid1 + "],",

View File

@@ -97,7 +97,7 @@
"logout",
"sysDictType:dropDown",
"sysDictType:dropDowns",
"sysFileInfo:upload",
//"sysFileInfo:upload",
"sysFileInfo:download",
"sysFileInfo:detail",
"sysFileInfo:preview",
@@ -112,7 +112,11 @@
"sysNotice:detail",
"houseLog:list",
"houseLog:listByInfoId",
"houseLog:listByTaskId"
"houseLog:listByTaskId",
"gb:yjb:api:outsidewall:Communitys",
"gb:yjb:api:outsidewall:sysFileInfo:upload",
"gb:yjb:api:outsidewall:VerifyIsLogin",
"gb:yjb:api:outsidewall:submit"
]
},

View File

@@ -88,8 +88,9 @@ namespace Ewide.EntityFramework.Core
try
{
if (dbContext == null) return;
// 获取所有更改,删除,新增的实体,但排除审计实体(避免死循环)
var entities = dbContext.ChangeTracker.Entries()
var entities = dbContext?.ChangeTracker?.Entries()?
.Where(u => u.Entity.GetType() != typeof(SysLogAudit) && u.Entity.GetType() != typeof(SysLogOp) && u.Entity.GetType() != typeof(SysLogVis) &&
(u.State == EntityState.Modified || u.State == EntityState.Deleted || u.State == EntityState.Added))
.ToList();

View File

@@ -49,6 +49,7 @@ namespace Ewide.Web.Core
{
// 管理员跳过判断
var userManager = App.GetService<IUserManager>();
if (userManager.IsExpire) return false;
if (userManager.SuperAdmin) return true;
// 路由名称

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 831 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

View File

@@ -21,7 +21,7 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="提交码:" prop="name">
<el-form-item label="手机号码:" prop="name">
<el-input v-model="form.submitCode" style="width:300px"></el-input>
</el-form-item>
<el-form-item>
@@ -34,7 +34,7 @@
<el-table-column type="expand">
<template slot-scope="props">
<el-form label-position="left" class="demo-table-expand" :model="props.row" style="width: 90%;margin:0 auto;">
<el-form-item label="提交码:">
<el-form-item label="手机号码:">
<span style="font-weight:bold;">{{ props.row.submitCode }}</span>
</el-form-item>
<el-form-item label="社区/小区名称:">
@@ -111,7 +111,7 @@
</el-form>
</template>
</el-table-column>
<el-table-column label="提交码" width="120"><template slot-scope="props">{{ props.row.submitCode}}</template></el-table-column>
<el-table-column label="手机号码" width="120"><template slot-scope="props">{{ props.row.submitCode}}</template></el-table-column>
<el-table-column label="社区/小区名称" width="200"><template slot-scope="props">{{ props.row.communityName}}</template></el-table-column>
<el-table-column label="提交日期" width="120"><template slot-scope="props">{{ dateFormat("mm-dd", props.row.createtime )}}</template></el-table-column>
<el-table-column label="幢名称"><template slot-scope="props">{{ props.row.buildingName}}</template></el-table-column>
@@ -160,7 +160,6 @@
},
methods: {
handlePreview(src, srcs) {
debugger
this.loading = true;
console.log(src);
this.dialogImageUrl = src.preview;
@@ -197,7 +196,7 @@
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/outsidewall/querybuilding',
url: `/gb/yjb/api/outsidewall/querybuilding`,
data: { wallId: row.id },
responseType: "json",
headers: {
@@ -236,7 +235,7 @@
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'get',
url: '/gb/yjb/api/outsidewall/Communitys?searchkey=' + queryString,
url: `/gb/yjb/api/outsidewall/Communitys?access_token=${window.sessionStorage.getItem('__TOKEN')}&searchkey=` + queryString,
responseType: "json",
}).then(async response => {
_this.communitys = response.data.data

View File

@@ -18,6 +18,26 @@
<body>
<div id="app">
<el-dialog v-model="pageData.dialogLoginVisible" title="请先登录" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" append-to-body width="60%">
<el-form :model="pageData.loginForm" ref="loginFormRef" label-position="top">
<el-form-item label="手机号码" label-width="80px" prop="phone" :rules="[{ required: true, trigger: 'blur', min: 11, max: 11, message: '请输入正确的手机号码' }]">
<el-input v-model="pageData.loginForm.phone" autocomplete="off" />
</el-form-item>
<el-form-item label="验证码" label-width="80px">
<el-input type="text" maxlength="4" placeholder="验证码" v-model="pageData.loginForm.code">
<template slot="append" #append>
<el-button :disabled="pageData.loginForm.disabled" @click="(v,v2)=>funHandles.getCode(v,pageData,loginFormRef)">{{ pageData.loginForm.valiBtn }}</el-button>
</template>
</el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<!--<el-button @click="dialogFormVisible = false">Cancel</el-button>-->
<el-button type="primary" @click="(v,v2)=>funHandles.verifyKey(pageData,loginFormRef)">登录</el-button>
</span>
</template>
</el-dialog>
<h3 style="text-align:center;">宁波既有建筑外墙脱落问卷调查</h3>
<el-form ref="formRef" :model="pageData.form" label-position="left" require-asterisk-position="right" label-width="160px" style="margin-top:15px;">
<el-form-item label="1.社区/小区名:" prop="communityId" :rules="[{ required: true, trigger: 'blur', message: '请选择社区/小区' }]">
@@ -43,7 +63,7 @@
</el-form-item>*@-->
<el-form-item label="3.外墙结构:" prop="outsidewallstructurefiles">
<el-upload class="upload-demo" drag multiple
action="/gb/yjb/api/outsidewall/sysFileInfo/upload"
:action="pageData.uploadaction"
auto-upload
list-type="picture-card"
v-model:file-list="pageData.fileList"
@@ -141,11 +161,11 @@
</el-form-item>
<el-form-item label="8.7 问题照片:">
<el-upload class="upload-demo" drag multiple
action="/gb/yjb/api/outsidewall/sysFileInfo/upload"
:action="pageData.uploadaction"
auto-upload
list-type="picture-card"
v-model:file-list="pageData.childFileList1"
:on-preview="(file)=>funHandles.filePreview(file,pageData.childFileList1)"
v-model:file-list="buildingItem.childFileList1"
:on-preview="(file)=>funHandles.filePreview(file,buildingItem.childFileList1)"
:on-remove="(file, fileList)=>funHandles.fileChildRemove(file, fileList,buildingItem)"
:on-success="(response, file, fileList)=>funHandles.fileChildChange(response, file, fileList, buildingItem,'东')"
style="width:100%">
@@ -155,11 +175,11 @@
</el-upload>
<el-upload class="upload-demo" drag multiple
action="/gb/yjb/api/outsidewall/sysFileInfo/upload"
:action="pageData.uploadaction"
auto-upload
list-type="picture-card"
v-model:file-list="pageData.childFileList2"
:on-preview="(file)=> funHandles.filePreview(file,pageData.childFileList2)"
v-model:file-list="buildingItem.childFileList2"
:on-preview="(file)=> funHandles.filePreview(file,buildingItem.childFileList2)"
:on-remove="(file, fileList)=>funHandles.fileChildRemove(file, fileList,buildingItem)"
:on-success="(response, file, fileList)=>funHandles.fileChildChange(response, file, fileList, buildingItem,'西')"
style="width:100%">
@@ -168,11 +188,11 @@
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
<el-upload class="upload-demo" drag multiple
action="/gb/yjb/api/outsidewall/sysFileInfo/upload"
:action="pageData.uploadaction"
auto-upload
list-type="picture-card"
v-model:file-list="pageData.childFileList3"
:on-preview="(file)=> funHandles.filePreview(file,pageData.childFileList3)"
v-model:file-list="buildingItem.childFileList3"
:on-preview="(file)=> funHandles.filePreview(file,buildingItem.childFileList3)"
:on-remove="(file, fileList)=>funHandles.fileChildRemove(file, fileList,buildingItem)"
:on-success="(response, file, fileList)=>funHandles.fileChildChange(response, file, fileList, buildingItem,'南')"
style="width:100%">
@@ -181,11 +201,11 @@
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件且不超过500kb</div>
</el-upload>
<el-upload class="upload-demo" drag multiple
action="/gb/yjb/api/outsidewall/sysFileInfo/upload"
:action="pageData.uploadaction"
auto-upload
list-type="picture-card"
v-model:file-list="pageData.childFileList4"
:on-preview="(file)=>funHandles.filePreview(file,pageData.childFileList4)"
v-model:file-list="buildingItem.childFileList4"
:on-preview="(file)=>funHandles.filePreview(file,buildingItem.childFileList4)"
:on-remove="(file, fileList)=>funHandles.fileChildRemove(file, fileList,buildingItem)"
:on-success="(response, file, fileList)=>funHandles.fileChildChange(response, file, fileList, buildingItem,'北')"
style="width:100%">
@@ -244,12 +264,17 @@
<el-button type="primary" @click.prevent="funHandles.onSubmit(formRef,childFormRef,pageData)"> 提 交 </el-button>
<!--<el-button @click.prevent="showinfo()">我的报名</el-button>-->
</el-form-item>
<el-form-item>
</el-form-item>
</el-form>
<el-image-viewer v-if="pageData.dialogImageUrl"
:zIndex="8000"
@close="() => { pageData.dialogImageUrl='' }"
:url-list="pageData.dialogImageUrls"
:initial-index="XEUtils.indexOf(pageData.dialogImageUrls, pageData.dialogImageUrl)"></el-image-viewer>
</div>
<script type="text/javascript">
@@ -260,14 +285,27 @@
setup() {
const formRef = ref();
const childFormRef = ref();
const loginFormRef = ref();
const pageData = ref({
form: {},
loginForm: {
valiBtn: '获取验证码',
disabled: false
},
//communitys: [],
//buildings: [],
//buildingItemId: ''
//buildingItemId: '',
dialogLoginVisible: false,
uploadaction: "/gb/yjb/api/outsidewall/sysFileInfo/upload"
});
const checkPhone = (rule, value, callback) => {
const regMobile = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
if (regMobile.test(value)) {
callback()
}
callback(new Error("请输入正确的手机号码"))
};
const rulesCheckData = {
checkPhone: (rule, value, callback) => {
const regMobile = /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
@@ -305,42 +343,104 @@
const staticData = { wallproblems: ['漏水', '开裂', '脱落', '空鼓', '其他问题'] };
const funHandles = {
init: async (data) => {
do {
data.key = await funHandles.verifyKey();
} while (!data.key);
try {
const response = await axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'get',
url: `/gb/yjb/api/outsidewall/VerifyIsLogin?access_token=${window.sessionStorage.getItem('__VerifyLogin')}`,
responseType: "json",
});
window.loadingInstance?.close();
if (response.data.data != true) {
//if (!window.sessionStorage.getItem('__VerifyLogin'))
data.dialogLoginVisible = true
} else {
data.uploadaction = `/gb/yjb/api/outsidewall/sysFileInfo/upload?access_token=${window.sessionStorage.getItem('__VerifyLogin')}`
}
//do {
// data.key = await funHandles.verifyKey(data);
//} while (data.key == false);
await funHandles.getCommunitys("", data);
//await funHandles.getCommunitys("", data);
} catch (error) {
window.loadingInstance?.close();
console.log(error)
//await ElMessageBox.alert(error.message, '异常', { type: 'error' });
//window.location.reload();//刷新当前页面
data.dialogLoginVisible = true
}
},
verifyKey: async () => {
const key = await ElMessageBox.prompt('请输入授权码', {
title: '授权',
inputPlaceholder: '授权码',
draggable: true,
showClose: false,
showCancelButton: false,
closeOnClickModal: false,
closeOnPressEscape: false,
inputErrorMessage: '请输入授权码',
getCode(v, pageData, loginFormRef) {
loginFormRef.validate(async (valid) => {
if (valid) {
console.log('已通过')
console.log(pageData.loginForm.phone)
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: '/gb/yjb/api/ningbozhichun/sendcode',
data: pageData.loginForm,
responseType: "json",
}).then(async response => {
if (response.data.data != true) {
await ElMessageBox.alert("发送失败:" + response.data.message, '错误', { type: 'error' });
} else {
funHandles.tackBtn(pageData); //验证码倒数60秒
}
//_this.loading = false;
}).catch(async error => {
console.log(error)
await ElMessageBox.alert(error.message, '错误', { type: 'error' });
})
} else {
console.log('未通过')
return;
}
});
},
tackBtn(pageData) { //验证码倒数60秒
let time = 60;
let timer = setInterval(() => {
if (time == 0) {
clearInterval(timer);
pageData.loginForm.valiBtn = '获取验证码';
pageData.loginForm.disabled = false;
} else {
pageData.loginForm.disabled = true;
pageData.loginForm.valiBtn = time + '秒后重试';
time--;
}
}, 1000);
},
verifyKey: async (pageData) => {
if (pageData.loginForm?.phone?.length != 11 || pageData.loginForm?.code?.length != 4) {
return;
}
try {
window.loadingInstance = ElLoading.service({ lock: true, text: '处理中' });
const response = await axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'post',
url: `/gb/yjb/api/outsidewall/VerifyKey?key=${key?.value ?? ''}`,
url: `/gb/yjb/api/outsidewall/VerifyLogin`,
data: pageData.loginForm,
responseType: "json",
});
window.loadingInstance?.close();
if (response.data.data)
return key?.value;
if (response.data.data.passed == true) {
window.sessionStorage.setItem('__VerifyLogin', response.data.data.token);
await funHandles.getCommunitys("", pageData);
pageData.dialogLoginVisible = false
pageData.uploadaction = `/gb/yjb/api/outsidewall/sysFileInfo/upload?access_token=${window.sessionStorage.getItem('__VerifyLogin')}`
//return response.data.data;
}
else {
await ElMessageBox.alert("授权码错误,授权失败", '授权', { type: 'error' });
await ElMessageBox.alert("验证码错误或已失效,登录失败", '登录', { type: 'error' });
}
} catch (error) {
window.loadingInstance?.close();
console.log(error)
await ElMessageBox.alert(error.message, '异常', { type: 'error' });
window.location.reload();//刷新当前页面
//window.location.reload();//刷新当前页面
}
},
getCommunitys: async (queryString, data) => {
@@ -352,7 +452,7 @@
const response = await axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'get',
url: `/gb/yjb/api/outsidewall/Communitys?searchkey=${queryString ?? ''}`,
url: `/gb/yjb/api/outsidewall/Communitys?access_token=${window.sessionStorage.getItem('__VerifyLogin')}&searchkey=${queryString ?? ''}`,
responseType: "json",
});
window.loadingInstance?.close();
@@ -361,6 +461,9 @@
} catch (error) {
window.loadingInstance?.close();
console.log(error)
if (error.response.status == 401)
ElMessageBox.alert("请先登录", '异常', { type: 'error' });
else
ElMessageBox.alert(error.message, '异常', { type: 'error' });
}
},
@@ -446,7 +549,7 @@
if (data?.form?.isExistProblem == '0') { isAllChildValid = true; }
else {
//验证
var waitValid = data.form?.buildingsForm
var waitValid = data.form?.buildingsForm?.filter(a => a.building.curwallproblems.length > 0)
if (waitValid?.length > 0) {
for (let ii = 0; ii < waitValid.length; ii++) {
let _fe = waitValid[ii]?.formEl;
@@ -578,13 +681,13 @@
debugger
window.loadingInstance = ElLoading.service({ lock: true, text: '提交中...请稍候' });
try {
data.form.buildings = data.form.buildings.filter(a => a.curwallproblems?.length > 0)
data.form.buildings = data.form.buildings?.filter(a => a.curwallproblems?.length > 0)
const response = await axios({
headers: { 'Content-Type': 'multipart/form-data' },
method: 'post',
url: `/gb/yjb/api/outsidewall/submit?key=${data.key ?? ''}`,
url: `/gb/yjb/api/outsidewall/submit?access_token=${window.sessionStorage.getItem('__VerifyLogin')}`,
data: data.form,
responseType: "json",
responseType: "json"
});
window.loadingInstance?.close();
@@ -691,7 +794,9 @@
XEUtils,
formRef,
childFormRef,
loginFormRef,
rulesCheckData,
checkPhone,
pageData,
staticData,
funHandles

View File

@@ -30,7 +30,7 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="提交码:" prop="name">
<el-form-item label="手机号码:" prop="name">
<el-input v-model="form.submitCode" style="width:300px"></el-input>
</el-form-item>
<el-form-item>
@@ -139,7 +139,7 @@
</el-table>
</template>
</el-table-column>
<el-table-column label="提交码">
<el-table-column label="手机号码">
<template slot-scope="props">
{{ props.row.submitCode}}
</template>
@@ -259,12 +259,10 @@
},
methods: {
lookphoto(outside_wall_photos) {
debugger;
this.outside_wall_photos = outside_wall_photos
this.dialogTableVisible = true
},
handlePreview(src, srcs) {
debugger
this.loading = true;
console.log(src);
this.dialogImageUrl = src.preview;
@@ -340,7 +338,7 @@
axios({
headers: { 'Content-Type': 'application/json;charset=UTF-8' },
method: 'get',
url: '/gb/yjb/api/outsidewall/Communitys?searchkey=' + queryString,
url: `/gb/yjb/api/outsidewall/Communitys?access_token=${window.sessionStorage.getItem('__TOKEN')}&searchkey=` + queryString,
responseType: "json",
}).then(async response => {
_this.communitys = response.data.data

View File

@@ -87,7 +87,7 @@ namespace Vote.Services.ApiController
{
code = code.ToString(),
CreatedTime = DateTime.Now,
expire_time = DateTime.Now.AddMinutes(10),
expire_time = DateTime.Now.AddMinutes(1),
IsDeleted = false,
phone = args.phone
}.InsertOrUpdate();

View File

@@ -1,7 +1,9 @@
using Ewide.Core;
using Ewide.Core.Service;
using Furion;
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DataEncryption;
using Furion.DataEncryption.Extensions;
using Furion.DynamicApiController;
using Furion.FriendlyException;
@@ -9,9 +11,11 @@ using Furion.RemoteRequest.Extensions;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Minio;
using System;
using System.Collections.Generic;
using System.IO;
@@ -39,6 +43,9 @@ namespace Vote.Services.ApiController
private readonly SqlSugarRepository<SysFile> rep_SysFile;
private readonly IMemoryCache _memoryCache;
readonly IOptions<UploadFileOptions> _options;
private readonly SqlSugarRepository<Entities.nbzc_sms_code> repSmsCode;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IUserManager _userManager; // 用户管理
/// <summary>
///
/// </summary>
@@ -47,7 +54,7 @@ namespace Vote.Services.ApiController
/// <param name="_repoutside_wall_building_photo"></param>
/// <param name="_repoutside_wall_photo"></param>
/// <param name="memoryCache"></param>
public OutsideWallService(SqlSugarRepository<Entities.Experts> repoutsideExperts, SqlSugarRepository<Entities.outside_wall> _repoutside_wall, SqlSugarRepository<Entities.outside_wall_building> _repoutside_wall_building, SqlSugarRepository<Entities.outside_wall_building_photo> _repoutside_wall_building_photo, SqlSugarRepository<Entities.outside_wall_photo> _repoutside_wall_photo, IMemoryCache memoryCache, SqlSugarRepository<SysFile> _rep_SysFile, IOptions<UploadFileOptions> options)
public OutsideWallService(SqlSugarRepository<Entities.Experts> repoutsideExperts, SqlSugarRepository<Entities.outside_wall> _repoutside_wall, SqlSugarRepository<Entities.outside_wall_building> _repoutside_wall_building, SqlSugarRepository<Entities.outside_wall_building_photo> _repoutside_wall_building_photo, SqlSugarRepository<Entities.outside_wall_photo> _repoutside_wall_photo, IMemoryCache memoryCache, SqlSugarRepository<SysFile> _rep_SysFile, IOptions<UploadFileOptions> options, SqlSugarRepository<Entities.nbzc_sms_code> _repSmsCode, IHttpContextAccessor httpContextAccessor, IUserManager userManager)
{
_repoutsideExperts = repoutsideExperts;
repoutside_wall = _repoutside_wall;
@@ -57,6 +64,9 @@ namespace Vote.Services.ApiController
_memoryCache = memoryCache;
_options = options;
rep_SysFile = _rep_SysFile;
this.repSmsCode = _repSmsCode;
_httpContextAccessor = httpContextAccessor;
_userManager = userManager;
}
/// <summary>
/// 导出Excel
@@ -206,7 +216,7 @@ namespace Vote.Services.ApiController
/// </summary>
/// <param name="file"></param>
/// <returns></returns>
[AllowAnonymous]
//[AllowAnonymous]
[HttpPost("sysFileInfo/upload")]
public async Task<string> UploadFileDefault(IFormFile file)
{
@@ -316,6 +326,60 @@ namespace Vote.Services.ApiController
#region
/// <summary>
/// 授权验证
/// </summary>
/// <returns></returns>
[HttpGet("VerifyIsLogin")]
public async Task<bool> VerifyIsLogin()
{
return true;
}
/// <summary>
/// 授权验证
/// </summary>
/// <returns></returns>
[HttpPost("VerifyLogin")]
[AllowAnonymous]
public async Task<dynamic> VerifyLogin(VerifyLoginInput args)
{
_ = args == null ? throw Oops.Oh("参数异常") : 1;
var passed = false;
var entity = await repSmsCode.AsQueryable().Where(p => p.phone == args.phone && !p.IsDeleted && p.code.Trim() == args.code.Trim() && p.expire_time > DateTime.Now).FirstAsync();
if (entity != null)
{
passed = true;
entity.IsDeleted = true;
await repSmsCode.UpdateAsync(entity);
var token = await HandlerLoginAsync(args);
return new { passed, token };
}
return new { passed, token = "" };
}
private async Task<string> HandlerLoginAsync(VerifyLoginInput args)
{
// 生成Token令牌
//var accessToken = await _jwtBearerManager.CreateTokenAdmin(user);
var accessToken = JWTEncryption.Encrypt(new Dictionary<string, object>
{
{ ClaimConst.CLAINM_USERID, args.phone },
{ ClaimConst.CLAINM_ACCOUNT, args.phone},
{ ClaimConst.CLAINM_NAME, args.phone},
{ ClaimConst.ExpireTime,DateTime.Now.AddMinutes(60)},
});
// 设置Swagger自动登录
_httpContextAccessor.HttpContext.SigninToSwagger(accessToken);
// 生成刷新Token令牌
var refreshToken = JWTEncryption.GenerateRefreshToken(accessToken, 30);
// 设置刷新Token令牌
_httpContextAccessor.HttpContext.Response.Headers["x-access-token"] = refreshToken;
return accessToken;
}
/// <summary>
/// 授权验证
/// </summary>
@@ -331,7 +395,7 @@ namespace Vote.Services.ApiController
/// 获取三居系统中的社区
/// </summary>
/// <returns></returns>
[AllowAnonymous]
//[AllowAnonymous]
[HttpGet("communitys")]
public async Task<List<SanjuCommunity>> GetCommunitys(string searchkey)
{
@@ -396,20 +460,15 @@ namespace Vote.Services.ApiController
/// <returns></returns>
[Consumes("application/json", "multipart/form-data")]
[HttpPost("submit")]
[AllowAnonymous]
public async Task<dynamic> Submit([FromForm] OutsideWallInput args, [FromQuery] string key)
//[AllowAnonymous]
public async Task<dynamic> Submit([FromForm] OutsideWallInput args)
{
var verifyKey = await _repoutsideExperts.IsExistsAsync(f => f.login_code.ToUpper() == key.ToUpper());
if (!verifyKey)
{
throw Oops.Oh("授权码错误");
}
try
{
//string key = GetCode(6, true);
repoutside_wall.Ado.BeginTran();
var wall = args.Adapt<outside_wall>();
wall.submitCode = key;
wall.submitCode = _userManager.Account;
wall.Id = Guid.NewGuid().ToString();
wall.createtime = DateTime.Now;
wall.isdeleted = 0;
@@ -425,6 +484,8 @@ namespace Vote.Services.ApiController
});
}
}
if (args.buildings != null)
{
foreach (var item in args.buildings)
{
if (!item.curwallproblems.Any())
@@ -448,8 +509,9 @@ namespace Vote.Services.ApiController
}
}
}
}
repoutside_wall.Ado.CommitTran();
return key;
return true;
}
catch (Exception ex)
{

View File

@@ -3,6 +3,7 @@ using Mapster;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -113,4 +114,22 @@ namespace Vote.Services.Dto
.Map(dest => dest.diaoluowu, src => Newtonsoft.Json.JsonConvert.SerializeObject(src.diaoluowu));
}
}
/// <summary>
///
/// </summary>
public class VerifyLoginInput
{
/// <summary>
///
/// </summary>
[Required]
public string code { get; set; }
/// <summary>
///
/// </summary>
[Required]
public string phone { get; set; }
}
}

View File

@@ -103,7 +103,7 @@
外墙调查问卷
</summary>
</member>
<member name="M:Vote.Services.ApiController.OutsideWallService.#ctor(Ewide.Core.SqlSugarRepository{Vote.Services.Entities.Experts},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall_building},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall_building_photo},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall_photo},Microsoft.Extensions.Caching.Memory.IMemoryCache,Ewide.Core.SqlSugarRepository{Ewide.Core.SysFile},Microsoft.Extensions.Options.IOptions{Ewide.Core.UploadFileOptions})">
<member name="M:Vote.Services.ApiController.OutsideWallService.#ctor(Ewide.Core.SqlSugarRepository{Vote.Services.Entities.Experts},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall_building},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall_building_photo},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.outside_wall_photo},Microsoft.Extensions.Caching.Memory.IMemoryCache,Ewide.Core.SqlSugarRepository{Ewide.Core.SysFile},Microsoft.Extensions.Options.IOptions{Ewide.Core.UploadFileOptions},Ewide.Core.SqlSugarRepository{Vote.Services.Entities.nbzc_sms_code},Microsoft.AspNetCore.Http.IHttpContextAccessor,Ewide.Core.IUserManager)">
<summary>
</summary>
@@ -161,6 +161,18 @@
<param name="Length">生成长度</param>
<param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param>
</member>
<member name="M:Vote.Services.ApiController.OutsideWallService.VerifyIsLogin">
<summary>
授权验证
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.OutsideWallService.VerifyLogin(Vote.Services.Dto.VerifyLoginInput)">
<summary>
授权验证
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.OutsideWallService.VerifyKey(System.String)">
<summary>
授权验证
@@ -185,7 +197,7 @@
</summary>
<returns></returns>
</member>
<member name="M:Vote.Services.ApiController.OutsideWallService.Submit(Vote.Services.Dto.OutsideWallInput,System.String)">
<member name="M:Vote.Services.ApiController.OutsideWallService.Submit(Vote.Services.Dto.OutsideWallInput)">
<summary>
提交
</summary>
@@ -418,6 +430,21 @@
</summary>
</member>
<member name="T:Vote.Services.Dto.VerifyLoginInput">
<summary>
</summary>
</member>
<member name="P:Vote.Services.Dto.VerifyLoginInput.code">
<summary>
</summary>
</member>
<member name="P:Vote.Services.Dto.VerifyLoginInput.phone">
<summary>
</summary>
</member>
<member name="P:Vote.Services.Dto.ProjectsInput.type">
<summary>
项目类型