Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
admin-backend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
admin-backend
Commits
17a2a8d3
Commit
17a2a8d3
authored
Mar 25, 2024
by
brent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add model by id interface
parent
e3edd5eb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
0 deletions
+123
-0
task.go
controllers/task.go
+123
-0
No files found.
controllers/task.go
View file @
17a2a8d3
...
@@ -2532,6 +2532,129 @@ func (server *TaskController) Models() {
...
@@ -2532,6 +2532,129 @@ func (server *TaskController) Models() {
server
.
respond
(
http
.
StatusOK
,
""
,
responseData
)
server
.
respond
(
http
.
StatusOK
,
""
,
responseData
)
}
}
func
(
server
*
TaskController
)
ModelById
()
{
body
:=
server
.
Ctx
.
Input
.
RequestBody
appRequest
:=
models
.
AppRequest
{}
_
=
json
.
Unmarshal
(
body
,
&
appRequest
)
//解析body中数据
logs
.
Debug
(
"appRequest"
,
appRequest
,
string
(
body
))
if
appRequest
.
Id
==
0
{
server
.
respond
(
models
.
MissingParameter
,
"Missing id parameter"
)
return
}
queryQB
,
_
:=
orm
.
NewQueryBuilder
(
"mysql"
)
queryQB
.
Select
(
"task_type.id"
,
"task_type.name AS tit"
,
"task_type.type"
,
"task_type.desc AS content"
,
"task_type.sort"
,
"task_type.tags"
,
"task_type.estimat_exe_time"
,
"task_type.price"
,
"task_type.unit"
,
"task_type.examples"
,
"task_type.codes"
,
"task_type.base_model"
,
"task_type.model"
,
"task_type.api_path"
,
"task_type.api_doc_url"
,
"task_type.api_doc_content"
,
"task_type.version"
,
"task_type.category"
,
"task_type.form"
,
"task_type.access_status"
,
"task_type.publish_status"
,
"favorite.id AS is_favorite"
)
.
From
(
"task_type"
)
.
LeftJoin
(
"favorite"
)
.
On
(
"favorite.task_type_id = task_type.id and favorite.deleted = 0"
)
queryQB
.
Where
(
"task_type.deleted = 0"
)
.
And
(
fmt
.
Sprintf
(
"task_type.id = '%d'"
,
appRequest
.
Id
))
var
data
models
.
Model
sql
:=
queryQB
.
String
()
mysql
.
GetMysqlInstace
()
.
Ormer
.
Raw
(
sql
)
.
QueryRow
(
&
data
)
type
ResponseType
struct
{
Id
int
`json:"id"`
Tit
string
`json:"tit"`
Version
string
`json:"version,omitempty"`
Content
string
`json:"content"`
Type
int
`json:"type"`
ApiPath
string
`json:"api_path"`
BaseModel
string
`json:"base_model"`
Model
string
`json:"model""`
Examples
interface
{}
`json:"examples"`
ApiDocUrl
string
`json:"api_doc_url"`
ApiDocContent
string
`json:"api_doc_content"`
Codes
interface
{}
`json:"codes"`
Tags
interface
{}
`json:"tags"`
Form
interface
{}
`json:"form"`
Category
int
`json:"category"`
ResultFileExpires
int
`json:"result_file_expires"`
AccessStatus
int
`json:"access_status,omitempty"`
PublishStatus
int
`json:"publish_status,omitempty"`
Price
float64
`json:"price"`
Unit
string
`json:"unit"`
Sort
int
`json:"sort"`
EstimatExeTime
int
`json:"estimat_exe_time"`
IsFavorite
int
`json:"is_favorite"`
}
if
data
.
PublishStatus
!=
1
{
server
.
respond
(
models
.
BusinessFailed
,
"This model has not been published yet."
)
return
}
var
examples
interface
{}
eer
:=
json
.
Unmarshal
([]
byte
(
data
.
Examples
),
&
examples
)
if
eer
!=
nil
{
}
var
codes
interface
{}
eer
=
json
.
Unmarshal
([]
byte
(
data
.
Codes
),
&
codes
)
if
eer
!=
nil
{
}
var
tags
interface
{}
eer
=
json
.
Unmarshal
([]
byte
(
data
.
Tags
),
&
tags
)
if
eer
!=
nil
{
}
var
form
interface
{}
eer
=
json
.
Unmarshal
([]
byte
(
data
.
Form
),
&
form
)
if
eer
!=
nil
{
}
responseData
:=
ResponseType
{
Id
:
data
.
Id
,
Tit
:
data
.
Tit
,
Version
:
data
.
Version
,
Content
:
data
.
Content
,
Type
:
data
.
Type
,
ApiPath
:
data
.
ApiPath
,
BaseModel
:
data
.
BaseModel
,
Model
:
data
.
Model
,
Examples
:
examples
,
ApiDocUrl
:
data
.
ApiDocUrl
,
ApiDocContent
:
data
.
ApiDocContent
,
Codes
:
codes
,
Tags
:
tags
,
Category
:
data
.
Category
,
Form
:
form
,
ResultFileExpires
:
data
.
ResultFileExpires
,
AccessStatus
:
data
.
AccessStatus
,
PublishStatus
:
data
.
PublishStatus
,
Price
:
float64
(
data
.
Price
)
/
1000000
,
Unit
:
data
.
Unit
,
Sort
:
data
.
Sort
,
EstimatExeTime
:
data
.
EstimatExeTime
,
IsFavorite
:
data
.
IsFavorite
,
}
server
.
respond
(
http
.
StatusOK
,
""
,
responseData
)
}
func
(
server
*
TaskController
)
RunCount
()
{
func
(
server
*
TaskController
)
RunCount
()
{
//_, err := server.Check()
//_, err := server.Check()
//if err != nil {
//if err != nil {
...
...
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