TODO: fetch mehtod for sort and filter.

This commit is contained in:
eson 2020-08-24 01:14:36 +08:00
parent 3a987464e6
commit e91995fc65
2 changed files with 21 additions and 19 deletions

View File

@ -112,13 +112,13 @@ func Query(cxt *gin.Context, platform string) {
ot := &ObjectQuery{}
var view, gratuity sql.NullInt64
var lstm, letm, utm sql.NullTime
var tags, livetitle sql.NullString
var username, tags, livetitle, liveurl sql.NullString
err = rows.Scan(
&ot.Uid,
&ot.Platform,
&ot.UserId,
&ot.UserName,
&ot.LiveUrl,
&username,
&liveurl,
&tags,
&ot.Followers,
&view,
@ -160,6 +160,14 @@ func Query(cxt *gin.Context, platform string) {
ot.Gratuity = gratuity.Int64
}
if username.Valid {
ot.UserName = username.String
}
if liveurl.Valid {
ot.LiveUrl = liveurl.String
}
if err = json.Unmarshal([]byte(tags.String), &ot.Tags); err != nil {
// log.Println(tags)
}

View File

@ -66,6 +66,9 @@ const columns = [
dataIndex: 'Gratuity',
key: 'Gratuity',
width: "8%",
sorter: (a, b) => a.Gratuity - b.Gratuity,
// sortOrder: sortedInfo.columnKey === 'Gratuity' && sortedInfo.order,
ellipsis: true,
},
{
title: '数据更新时间',
@ -78,15 +81,6 @@ const columns = [
const getRandomuserParams = params => {
return {
psize: params.pagination.pageSize,
page: params.pagination.current,
// ...params,
};
};
class DataTable extends React.Component {
@ -143,7 +137,7 @@ class DataTable extends React.Component {
const { pagination } = this.state;
pagination.current = 1;
this.setState({ platform: p }, () => {
this.fetch({
this.fetchapi({
pagination
});
});
@ -156,8 +150,8 @@ class DataTable extends React.Component {
}
handleTableChange = (pagination, filters, sorter) => {
// console.log(filters, sorter);
this.fetch({
console.log(filters, sorter);
this.fetchapi({
sortField: sorter.field,
sortOrder: sorter.order,
pagination,
@ -165,12 +159,12 @@ class DataTable extends React.Component {
});
};
fetch = (params = {}) => {
fetchapi = (params = {}) => {
this.setState({ loading: true });
const { platform, pagination } = this.state;
fetch(`${apihost}/${platform}/query?page=${pagination.current}&psize=${pagination.pageSize}`, { mode: "cors" }).then((response) => {
console.log(response);
// console.log(response);
response.json().then(
(data) => {
var result = JSON.parse(data)
@ -193,7 +187,7 @@ class DataTable extends React.Component {
return (
<div>
<Row justify="start">
{/* <Row justify="start">
<Col span={6}>
<Input.Group compact size="small">
<Select size="small" defaultValue="operator">
@ -212,7 +206,7 @@ class DataTable extends React.Component {
<Input size="small" style={{ width: '50%' }} defaultValue="Xihu District, Hangzhou" />
</Input.Group>
</Col>
</Row>
</Row> */}
<Table
bordered={true}