Skip to content

Commit 3d3ba9c

Browse files
insistencegitee-org
authored andcommitted
!3 RuoYi-Vue-FastAPI v1.0.1
Merge pull request !3 from insistence/develop
2 parents 3d45187 + bf61200 commit 3d3ba9c

File tree

6 files changed

+39
-38
lines changed

6 files changed

+39
-38
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<p align="center">
22
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
33
</p>
4-
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi-Vue-FastAPI v1.0.0</h1>
4+
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi-Vue-FastAPI v1.0.1</h1>
55
<h4 align="center">基于RuoYi-Vue+FastAPI前后端分离的快速开发框架</h4>
66
<p align="center">
77
<a href="https://gitee.com/insistence2022/RuoYi-Vue-FastAPI/stargazers"><img src="https://gitee.com/insistence2022/RuoYi-Vue-FastAPI/badge/star.svg?theme=dark"></a>
88
<a href="https://github.com/insistence/RuoYi-Vue-FastAPI"><img src="https://img.shields.io/github/stars/insistence/RuoYi-Vue-FastAPI?style=social"></a>
9-
<a href="https://gitee.com/insistence2022/RuoYi-Vue-FastAPI"><img src="https://img.shields.io/badge/RuoYiVueFastAPI-v1.0.0-brightgreen.svg"></a>
9+
<a href="https://gitee.com/insistence2022/RuoYi-Vue-FastAPI"><img src="https://img.shields.io/badge/RuoYiVueFastAPI-v1.0.1-brightgreen.svg"></a>
1010
<a href="https://gitee.com/insistence2022/RuoYi-Vue-FastAPI/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
1111
<img src="https://img.shields.io/badge/python-≥3.8-blue">
1212
<img src="https://img.shields.io/badge/MySQL-≥5.7-blue">
1313
</p>
1414

15+
1516
## 平台简介
1617

1718
RuoYi-Vue-FastAPI是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。

ruoyi-fastapi-backend/module_admin/dao/log_dao.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from sqlalchemy import asc, desc
12
from sqlalchemy.orm import Session
23
from module_admin.entity.do.log_do import SysOperLog, SysLogininfor
34
from module_admin.entity.vo.log_vo import *
45
from utils.page_util import PageUtil
6+
from utils.common_util import CamelCaseUtil
57
from datetime import datetime, time
68

79

@@ -18,6 +20,12 @@ def get_operation_log_list(cls, db: Session, query_object: OperLogPageQueryModel
1820
:param is_page: 是否开启分页
1921
:return: 操作日志列表信息对象
2022
"""
23+
if query_object.is_asc == 'ascending':
24+
order_by_column = asc(getattr(SysOperLog, CamelCaseUtil.camel_to_snake(query_object.order_by_column), None))
25+
elif query_object.is_asc == 'descending':
26+
order_by_column = desc(getattr(SysOperLog, CamelCaseUtil.camel_to_snake(query_object.order_by_column), None))
27+
else:
28+
order_by_column = desc(SysOperLog.oper_time)
2129
query = db.query(SysOperLog) \
2230
.filter(SysOperLog.title.like(f'%{query_object.title}%') if query_object.title else True,
2331
SysOperLog.oper_name.like(f'%{query_object.oper_name}%') if query_object.oper_name else True,
@@ -28,7 +36,7 @@ def get_operation_log_list(cls, db: Session, query_object: OperLogPageQueryModel
2836
datetime.combine(datetime.strptime(query_object.end_time, '%Y-%m-%d'), time(23, 59, 59)))
2937
if query_object.begin_time and query_object.end_time else True
3038
)\
31-
.distinct()
39+
.distinct().order_by(order_by_column)
3240
operation_log_list = PageUtil.paginate(query, query_object.page_num, query_object.page_size, is_page)
3341

3442
return operation_log_list
@@ -84,6 +92,12 @@ def get_login_log_list(cls, db: Session, query_object: LoginLogPageQueryModel, i
8492
:param is_page: 是否开启分页
8593
:return: 登录日志列表信息对象
8694
"""
95+
if query_object.is_asc == 'ascending':
96+
order_by_column = asc(getattr(SysLogininfor, CamelCaseUtil.camel_to_snake(query_object.order_by_column), None))
97+
elif query_object.is_asc == 'descending':
98+
order_by_column = desc(getattr(SysLogininfor, CamelCaseUtil.camel_to_snake(query_object.order_by_column), None))
99+
else:
100+
order_by_column = desc(SysLogininfor.login_time)
87101
query = db.query(SysLogininfor) \
88102
.filter(SysLogininfor.ipaddr.like(f'%{query_object.ipaddr}%') if query_object.ipaddr else True,
89103
SysLogininfor.user_name.like(f'%{query_object.user_name}%') if query_object.user_name else True,
@@ -93,7 +107,7 @@ def get_login_log_list(cls, db: Session, query_object: LoginLogPageQueryModel, i
93107
datetime.combine(datetime.strptime(query_object.end_time, '%Y-%m-%d'), time(23, 59, 59)))
94108
if query_object.begin_time and query_object.end_time else True
95109
)\
96-
.distinct()
110+
.distinct().order_by(order_by_column)
97111
login_log_list = PageUtil.paginate(query, query_object.page_num, query_object.page_size, is_page)
98112

99113
return login_log_list

ruoyi-fastapi-backend/module_admin/entity/vo/log_vo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class OperLogQueryModel(OperLogModel):
5151
"""
5252
操作日志管理不分页查询模型
5353
"""
54+
order_by_column: Optional[str] = None
55+
is_asc: Optional[str] = None
5456
begin_time: Optional[str] = None
5557
end_time: Optional[str] = None
5658

@@ -78,6 +80,8 @@ class LoginLogQueryModel(LogininforModel):
7880
"""
7981
登录日志管理不分页查询模型
8082
"""
83+
order_by_column: Optional[str] = None
84+
is_asc: Optional[str] = None
8185
begin_time: Optional[str] = None
8286
end_time: Optional[str] = None
8387

ruoyi-fastapi-backend/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
APScheduler==3.10.4
22
DateTime==5.4
3-
fastapi[all]==0.109.0
3+
fastapi[all]==0.109.1
44
loguru==0.7.2
55
openpyxl==3.1.2
66
pandas==2.1.4

ruoyi-fastapi-backend/utils/common_util.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pandas as pd
22
import io
33
import os
4+
import re
45
from openpyxl import Workbook
56
from openpyxl.styles import Alignment, PatternFill
67
from openpyxl.utils import get_column_letter
@@ -39,10 +40,21 @@ def worship():
3940

4041
class CamelCaseUtil:
4142
"""
42-
下划线形式(snake_case)转换为小驼峰形式(camelCase)工具方法
43+
小驼峰形式(camelCase)与下划线形式(snake_case)互相转换工具方法
4344
"""
4445
@classmethod
45-
def __to_camel_case(cls, snake_str):
46+
def camel_to_snake(cls, camel_str):
47+
"""
48+
小驼峰形式字符串(camelCase)转换为下划线形式字符串(snake_case)
49+
:param camel_str: 小驼峰形式字符串
50+
:return: 下划线形式字符串
51+
"""
52+
# 在大写字母前添加一个下划线,然后将整个字符串转为小写
53+
words = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', camel_str)
54+
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', words).lower()
55+
56+
@classmethod
57+
def snake_to_camel(cls, snake_str):
4658
"""
4759
下划线形式字符串(snake_case)转换为小驼峰形式字符串(camelCase)
4860
:param snake_str: 下划线形式字符串
@@ -64,7 +76,7 @@ def transform_result(cls, result):
6476
return result
6577
# 如果是字典,直接转换键
6678
elif isinstance(result, dict):
67-
return {cls.__to_camel_case(k): v for k, v in result.items()}
79+
return {cls.snake_to_camel(k): v for k, v in result.items()}
6880
# 如果是一组字典或其他类型的列表,遍历列表进行转换
6981
elif isinstance(result, list):
7082
return [cls.transform_result(row) if isinstance(row, (dict, Row)) else (cls.transform_result({c.name: getattr(row, c.name) for c in row.__table__.columns}) if row else row) for row in result]

ruoyi-fastapi-frontend/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)