diff --git a/goserver/main.go b/goserver/main.go index 458eefb..4a1a71d 100644 --- a/goserver/main.go +++ b/goserver/main.go @@ -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) } diff --git a/src/Table.js b/src/Table.js index d3ab455..85045b8 100644 --- a/src/Table.js +++ b/src/Table.js @@ -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 (