Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b0fae6b3
authored
Nov 23, 2023
by
luxl
Committed by
GitHub
Nov 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
绘图列表更新
parent
df5a3e68
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
12 deletions
+68
-12
controller/midjourney.go
+19
-2
model/midjourney.go
+49
-10
web/src/components/MjLogsTable.js
+0
-0
No files found.
controller/midjourney.go
View file @
b0fae6b3
...
...
@@ -148,7 +148,16 @@ func GetAllMidjourney(c *gin.Context) {
if
p
<
0
{
p
=
0
}
logs
:=
model
.
GetAllTasks
(
p
*
common
.
ItemsPerPage
,
common
.
ItemsPerPage
)
// 解析其他查询参数
queryParams
:=
model
.
TaskQueryParams
{
ChannelID
:
c
.
Query
(
"channel_id"
),
MjID
:
c
.
Query
(
"mj_id"
),
StartTimestamp
:
c
.
Query
(
"start_timestamp"
),
EndTimestamp
:
c
.
Query
(
"end_timestamp"
),
}
logs
:=
model
.
GetAllTasks
(
p
*
common
.
ItemsPerPage
,
common
.
ItemsPerPage
,
queryParams
)
if
logs
==
nil
{
logs
=
make
([]
*
model
.
Midjourney
,
0
)
}
...
...
@@ -164,9 +173,17 @@ func GetUserMidjourney(c *gin.Context) {
if
p
<
0
{
p
=
0
}
userId
:=
c
.
GetInt
(
"id"
)
log
.
Printf
(
"userId = %d
\n
"
,
userId
)
logs
:=
model
.
GetAllUserTask
(
userId
,
p
*
common
.
ItemsPerPage
,
common
.
ItemsPerPage
)
queryParams
:=
model
.
TaskQueryParams
{
MjID
:
c
.
Query
(
"mj_id"
),
StartTimestamp
:
c
.
Query
(
"start_timestamp"
),
EndTimestamp
:
c
.
Query
(
"end_timestamp"
),
}
logs
:=
model
.
GetAllUserTask
(
userId
,
p
*
common
.
ItemsPerPage
,
common
.
ItemsPerPage
,
queryParams
)
if
logs
==
nil
{
logs
=
make
([]
*
model
.
Midjourney
,
0
)
}
...
...
model/midjourney.go
View file @
b0fae6b3
...
...
@@ -22,29 +22,68 @@ type Midjourney struct {
ChannelId
int
`json:"channel_id"`
}
func
GetAllUserTask
(
userId
int
,
startIdx
int
,
num
int
)
[]
*
Midjourney
{
// 用于包含所有搜索条件的结构体,可以根据需求添加更多字段
type
TaskQueryParams
struct
{
ChannelID
string
MjID
string
StartTimestamp
string
EndTimestamp
string
}
func
GetAllUserTask
(
userId
int
,
startIdx
int
,
num
int
,
queryParams
TaskQueryParams
)
[]
*
Midjourney
{
var
tasks
[]
*
Midjourney
var
err
error
err
=
DB
.
Where
(
"user_id = ?"
,
userId
)
.
Order
(
"id desc"
)
.
Limit
(
num
)
.
Offset
(
startIdx
)
.
Find
(
&
tasks
)
.
Error
// 初始化查询构建器
query
:=
DB
.
Where
(
"user_id = ?"
,
userId
)
if
queryParams
.
MjID
!=
""
{
query
=
query
.
Where
(
"mj_id = ?"
,
queryParams
.
MjID
)
}
if
queryParams
.
StartTimestamp
!=
""
{
// 假设您已将前端传来的时间戳转换为数据库所需的时间格式,并处理了时间戳的验证和解析
query
=
query
.
Where
(
"submit_time >= ?"
,
queryParams
.
StartTimestamp
)
}
if
queryParams
.
EndTimestamp
!=
""
{
query
=
query
.
Where
(
"submit_time <= ?"
,
queryParams
.
EndTimestamp
)
}
// 获取数据
err
=
query
.
Order
(
"id desc"
)
.
Limit
(
num
)
.
Offset
(
startIdx
)
.
Find
(
&
tasks
)
.
Error
if
err
!=
nil
{
return
nil
}
for
_
,
task
:=
range
tasks
{
task
.
ImageUrl
=
common
.
ServerAddress
+
"/mj/image/"
+
task
.
MjId
}
return
tasks
}
func
GetAllTasks
(
startIdx
int
,
num
int
)
[]
*
Midjourney
{
func
GetAllTasks
(
startIdx
int
,
num
int
,
queryParams
TaskQueryParams
)
[]
*
Midjourney
{
var
tasks
[]
*
Midjourney
var
err
error
err
=
DB
.
Order
(
"id desc"
)
.
Limit
(
num
)
.
Offset
(
startIdx
)
.
Find
(
&
tasks
)
.
Error
// 初始化查询构建器
query
:=
DB
// 添加过滤条件
if
queryParams
.
ChannelID
!=
""
{
query
=
query
.
Where
(
"channel_id = ?"
,
queryParams
.
ChannelID
)
}
if
queryParams
.
MjID
!=
""
{
query
=
query
.
Where
(
"mj_id = ?"
,
queryParams
.
MjID
)
}
if
queryParams
.
StartTimestamp
!=
""
{
query
=
query
.
Where
(
"submit_time >= ?"
,
queryParams
.
StartTimestamp
)
}
if
queryParams
.
EndTimestamp
!=
""
{
query
=
query
.
Where
(
"submit_time <= ?"
,
queryParams
.
EndTimestamp
)
}
// 获取数据
err
=
query
.
Order
(
"id desc"
)
.
Limit
(
num
)
.
Offset
(
startIdx
)
.
Find
(
&
tasks
)
.
Error
if
err
!=
nil
{
return
nil
}
for
_
,
task
:=
range
tasks
{
task
.
ImageUrl
=
common
.
ServerAddress
+
"/mj/image/"
+
task
.
MjId
}
return
tasks
}
...
...
web/src/components/MjLogsTable.js
View file @
b0fae6b3
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment