Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/crud/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pydantic import BaseModel
from typing import TypeVar, Generic, List, Type, Any, Dict, Optional
from sqlmodel import Session, select, SQLModel, func, desc
from ..schemas.internal.pagination import Pagination
from ..models.internal import Pagination

ModelType = TypeVar('ModelType', bound=SQLModel)

Expand Down
2 changes: 1 addition & 1 deletion server/crud/internal/dictonary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sqlmodel import select, Session, desc
from ...models.internal.dictonary import DataDict, DictItem, DictItemSearch
from ..base import CRUDBase
from ...schemas.internal.pagination import Pagination
from ...models.internal import Pagination


class CRUDDict(CRUDBase[DataDict]):
Expand Down
2 changes: 1 addition & 1 deletion server/crud/internal/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from sqlmodel import select, Session
from ...models.internal.user import User
from ..base import CRUDBase
from ...schemas.internal.user import UserInfo, UserLogin
from ...models.internal.user import UserInfo, UserLogin
from .roles import role


Expand Down
11 changes: 11 additions & 0 deletions server/models/internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@
from .role import Role, RoleMenu
from .dictonary import DataDict, DictItem
from .job import Job, JobLog
from pydantic import BaseModel
from typing import TypeVar, Generic, Optional

T = TypeVar('T')


class Pagination(BaseModel, Generic[T]):
search: T
page: Optional[int] = 1
page_size: Optional[int] = 10
model: Optional[str] = 'asc'
17 changes: 17 additions & 0 deletions server/models/internal/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,20 @@ class JobLog(SQLModel, table=True):

class Config:
arbitrary_types_allowed = True


class JobSearch(SQLModel):
job_name: Optional[str] = None


class JobLogs(SQLModel):
id: int
status: int
start_time: datetime
end_time: datetime
log: Any
job_id: str


class JobLogSearch(BaseModel):
job_id: str
5 changes: 5 additions & 0 deletions server/models/internal/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ class UserLogin(SQLModel):
class LoginResponse(SQLModel):
uid: int
token: str


class UserInfo(BaseModel):
user: User
roles: List[str]
2 changes: 1 addition & 1 deletion server/routers/internal/dictonary.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional, List
from fastapi import APIRouter, Depends, status, HTTPException
from sqlmodel import Session
from ...schemas.internal.pagination import Pagination
from ...models.internal import Pagination
from ...models.internal.dictonary import DataDict, DictRead, DictUpdate, DictItem, DataDictSearch, \
DictItemSearch, DictItemSearchFilter
from ...common.response_code import ApiResponse, SearchResponse
Expand Down
4 changes: 2 additions & 2 deletions server/routers/internal/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from server.common.database import get_session, get_redis
from server.common.response_code import ApiResponse, SearchResponse
from server.common.utils import get_task_logs
from server.schemas.internal.pagination import Pagination
from server.schemas.job import JobSearch, JobLogs, JobLogSearch
from server.models.internal import Pagination
from server.models.internal.job import JobSearch, JobLogs, JobLogSearch
from server import crud
from server.common.dep import get_uid

Expand Down
2 changes: 1 addition & 1 deletion server/routers/internal/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ... import crud
from ...models.internal import Role, Menu
from ...models.internal.role import RoleBase, RoleWithMenus, RoleInsert, RoleUpdate
from ...schemas.internal.pagination import Pagination
from server.models.internal import Pagination
from ...common.utils import menu_convert

router = APIRouter(prefix='/api')
Expand Down
2 changes: 1 addition & 1 deletion server/routers/internal/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ...models.internal import User, Role
from ...models.internal.user import UserCreateWithRoles, UserReadWithRoles, UserUpdateWithRoles, UserUpdatePassword, \
UserWithOutPasswd
from ...schemas.internal.pagination import Pagination
from server.models.internal import Pagination
from ... import crud

router = APIRouter(prefix='/api', )
Expand Down
Empty file.
16 changes: 0 additions & 16 deletions server/schemas/internal/dictonary.py

This file was deleted.

15 changes: 0 additions & 15 deletions server/schemas/internal/pagination.py

This file was deleted.

17 changes: 0 additions & 17 deletions server/schemas/internal/user.py

This file was deleted.

21 changes: 0 additions & 21 deletions server/schemas/job.py

This file was deleted.

1 change: 1 addition & 0 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "www",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
Expand Down
86 changes: 0 additions & 86 deletions www/src/views/system/user/ChangePasswd.vue

This file was deleted.

89 changes: 89 additions & 0 deletions www/src/views/system/user/ResetPasswdDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<template>
<el-dialog v-model="visible" title="用户密码重置" width="30%" @close="ruleFormRef.resetFields()">
<el-form ref="ruleFormRef" :model="form" label-width="100px" :rules="rules">
<el-form-item label="用户名:">
<el-input v-model="userName" disabled></el-input>
</el-form-item>
<el-form-item label="登录密码:" prop="password">
<el-input v-model="form.password" placeholder="请输入登录密码" show-password></el-input>
</el-form-item>
<el-form-item label="确认密码:" prop="secondPassword">
<el-input v-model="form.secondPassword" placeholder="请重新输入登录密码" show-password></el-input>
</el-form-item>
</el-form>
<el-button @click="visible=false">关闭</el-button>
<el-button @click="updatePasswd" type="primary">确定</el-button>
</el-dialog>
</template>

<script setup>
import {ResetPasswd} from '@/api/users'
import {ElNotification} from 'element-plus'
import md5 from 'js-md5'
import {computed, reactive, ref} from 'vue'

const visible = ref(false)
const user = ref(null)
const form = reactive({})
const ruleFormRef = ref(null)

const userName = computed(() => user.value.name)
const userId = computed(() => user.value.id)
const checkPassword = (rule, value, callback) => {
console.log(form)
console.log(value)
if (value.length === 0) {
callback(new Error('请确认密码不能为空'))
} else if (value !== form.password) {
callback(new Error('2次密码不一致'))
} else {
callback()
}
}

const rules = {
password: [{required: true, trigger: 'blur', message: '请输入密码'}],
secondPassword: [{required: true, trigger: 'blur', message: '请再次输入密码进行确认'},
{validator: checkPassword, trigger: 'blur'}]
}

async function updatePasswd() {
console.log(userId)
await ruleFormRef.value.validate(async (valid) => {
if (valid) {
console.log('submit')
try {
await ResetPasswd(userId.value, md5(form.password))
ElNotification({
title: 'success',
message: '密码重置成功',
type: 'success'
})
} catch {
ElNotification({
title: '错误',
message: '密码重置失败:' + error,
type: 'error'
})
}
visible.value = false
}
})
}

function reset(resetUser) {
Object.assign(form, {
password: null,
secondPassword: null,
})
user.value = resetUser
visible.value = true
}

defineExpose({reset,})

</script>

<style scoped>

</style>
Loading