当前位置: 首页 > news >正文

查建筑企业信息的网站百度seo有用吗

查建筑企业信息的网站,百度seo有用吗,福田网站建设效果,工程设计公司refer: http://ip-api.com/ 1.首先需要创建一个保存用户历史的登录的表,然后连接go 2.在用户登录的时候,获取用户的IP IP位置,在后端直接处理数据即可(不需要在前端传递数据) (1)增加路由&am…

refer: http://ip-api.com/

1.首先需要创建一个保存用户历史的登录的表,然后连接go

2.在用户登录的时候,获取用户的IP IP位置,在后端直接处理数据即可(不需要在前端传递数据)

(1)增加路由:

apiv1.POST("/history_login_logs", v1.AddHistoryLoginLog)

(2)在model里增加(例如:models/history_login_logs.go)
 

 func AddHistoryLoginLog(user_id int, ip_address string, ip_location string, login_at time.Time) bool {db.Create(&HistoryLoginLogs{UserId:    user_id,IpAddress: ip_address,IpLocation:   ip_location,LoginAt: login_at,})return true}


  (3) 在登录后的方法中增加(需要引入

import("time""io/ioutil""fmt""encoding/json"
)type Location struct {Status      string  `json:"status"`Country     string  `json:"country"`CountryCode string  `json:"countryCode"`Region      string  `json:"region"`RegionName  string  `json:"regionName"`City        string  `json:"city"`Zip         string  `json:"zip"`Lat         float64 `json:"lat"`Lon         float64 `json:"lon"`Timezone    string  `json:"timezone"`Isp         string  `json:"isp"`Org         string  `json:"org"`As          string  `json:"as"`Query       string  `json:"query"`
}...
ipAddress := c.ClientIP()
fmt.Println("== ip_address:", ipAddress)
resp, err := http.Get("http://ip-api.com/json/" + ipAddress + "?lang=zh-CN")
if err != nil {fmt.Println("Error:", err)return
}defer resp.Body.Close()body, err := ioutil.ReadAll(resp.Body)if err != nil {fmt.Println("Error:", err)return}var location Location
err = json.Unmarshal(body, &location)if err != nil {fmt.Println("Error:", err)return}fmt.Println("=== Location:", location)
City := location.CitycurrentTime := time.Now()
models.AddHistoryLoginLog(user.ID, ipAddress, City, currentTime)
...

  (4)增加action (例如:routers/api/v1/history_login_log.go)(需要引入import  "net/http"   "time"  "fmt")
 

type AddHistoryLoginLogRequest struct {UserID     int    `json:"user_id" binding:"required"`IPAddress  string `json:"ip_address" binding:"required"`City string `json:"ip_location" binding:"required"`CurrentTime time.Time `json:"login_at" binding:"required"`}func AddHistoryLoginLog(c *gin.Context) {var request AddHistoryLoginLogRequestif err := c.ShouldBindJSON(&request); err != nil {fmt.Println("== err: ", err)return}models.AddHistoryLoginLog(request.UserID, request.IPAddress, request.City, request.CurrentTime)}

3.在前端写一个展示的列表页面即可。(登录时间写现在的时间即可。)
例如:src/pages/HistoryLoginLog/index.jsx

import React, { Component } from 'react'
import { Table } from 'antd';
import axios from 'axios'
import Config from '@/settings'
import { getToken, removeToken } from '@/utils/auth'const columns = [{title: '登录名',dataIndex: 'user_id',key: 'user_id',render: text => <a>{text}</a>,},{title: '登陆时间',dataIndex: 'login_at',key: 'login_at',// 这里是进行时间的处理,转换为北京时间,格式为:2023/08/16 21:40render: text => {const dateObj = new Date(text);const localizedDate = dateObj.toLocaleString('zh-CN', {timeZone: 'Asia/Shanghai',year: 'numeric',month: '2-digit',day: '2-digit',hour: '2-digit',minute: '2-digit',});return <span>{localizedDate}</span>;},},{title: '登陆ip',dataIndex: 'ip_address',key: 'ip_address',},{title: '登陆位置',dataIndex: 'ip_location',key: 'ip_locatio',}
];export default class CalculationPlan extends Component {state = {data: [],loading: true,}async fetchData() {try {const response = await axios.get(`${Config.BASE_URL}/api/v1/history_login_logs?token=${getToken()}`)if (response.data.message == "ok") {const sortedData = response.data.data.sort((a, b) => new Date(b.id) - new Date(a.id));this.setState({data: sortedData,loading: false,})}} catch (error) {console.error(error)removeToken()window.location.href = '/'}}componentDidMount() {this.fetchData()}render() {const { data, loading } = this.statereturn (<Table columns={columns} dataSource={data} loading={loading} />)}
}

http://www.bjxfkj.com.cn/article/102322.html

相关文章:

  • 上海公司注册查询山西网站seo
  • 抓取网站后台密码文员短期电脑培训
  • 做门户网站服务器选择线上营销推广方案
  • 有哪些可以做1元夺宝的网站互动营销是什么意思
  • 顺德企业手机网站建设小红书seo排名规则
  • 网站的主题定位快速排名生客seo
  • 汉狮做网站公司郑州网络软文营销案例
  • 深圳响应式网站百度搜索竞价
  • 表白网页生成器下载长沙seo
  • 山东疫情最新消息今天封城了南京关键词优化软件
  • 网站建设 岗位百度平台我的订单查询在哪里
  • icp ip 网站备案查询广东网络优化推广
  • 长春网站建设找源晟seo推广是什么意思
  • 最好的网站建设价格深圳创新创业大赛
  • 网站上的图是怎么做的aso关键词优化工具
  • 网站开发的工资百度云手机登录入口
  • 做会计网站的流程如何自己弄一个网站
  • 威海互联网推广汕头最好的seo外包
  • 杭州建设网站公司哪家好长沙百度网站优化
  • 建筑产业大数据综合服务平台seo综合查询什么意思
  • 创建自由摄影师的网站内容网站seo视频教程
  • 专业型网站建设方案服务器ip域名解析
  • 在乐文网站做翻译靠谱吗化学sem是什么意思
  • 网站主体信息制作网站费用
  • 做网站引入字体国外网站开发
  • 强生公司营销网站为什么要这样做网址怎么弄
  • 汝州市城乡建设局网站网络广告策划书范文
  • 网站推广制作近期国际新闻20条
  • 中国人民建设人行网站首页营销策略主要包括哪些
  • 青岛网络优化公司seo网站优化方案案例