52论坛 首发
有服务器的小伙伴可以将就着玩玩,没怎么深入去写
java环境自行配置
项目jdk11
没有服务器的小伙伴 安卓用户可以使用
https://www.52pojie.cn/thread-1243897-1-1.html
已开源的意思是已开源 并不是说源码一定放在论坛 各位网络小警察麻烦自行搜索
介于很多人不会善用搜索引擎 这里附上开源地址(项目是从安卓端移植的,代码质量粗糙,可自行优化)
https://github.com/YYYet/CzStepServer
上传
此处以宝塔面板做演示
进入站点根目录,上传jar包,等待上传完成
创建数据库
创建名为 mysteps
的数据库
用户名设置为 mystep
密码设置为 root
进入管理
mysteps--->导入--->选择文件导入mysteps.sql--->点击执行
数据库导入完成
部署
进入终端,进入站点根目录。即文件上传目录
输入以下命令启动服务,若你想保持前台运行 输入java -jar StepService.jar
java -jar StepService.jar &
如图所示表示启动成功
若出现8080端口占用情况如下
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8080 was already in use.
Action:
Identify and stop the process that's listening on port 8080 or configure this application to listenon another port.
需停止占用端口的应用 方法如下
-
netstat -lnp|grep 80
-
kill -9 12095
-
netstat -lnp|grep 80
然后重新 使用 java -jar StepService.jar & 运行服务
接口文档
参数说明:
phone 手机号
password 密码
steps 提交的步数
flag 是否开启自动刷步 0为不自动刷步 1为自动刷步 刷步时间为每日中午12点
单次提交步数
get请求
http://你的域名(或者公网ip:8080)/Service/updateStep?phone=18888888888&password=CZ123456&steps=9990&flag=0
响应
{
"code": 200,
"msg": "成功",
"data": {
"pedometerRecordHourlyList": [{
"id": "08be23751dc24a4bbca0638ad8880973",
"userId": 26993431,
"deviceId": "M_NULL",
"measurementTime": "2020-08-22 00:00:00",
"step": "9950,9950,0,0,0,0,0,0,0,0,0,0,4550,5650,0,0,9990,0,0,0,0,0,0,0",
"calories": "2487.00,2487.00,0,0,0,0,0,0,0,0,0,0,1137.00,1412.00,0,0,2497.00,0,0,0,0,0,0,0",
"distance": "3316.00,3316.00,0,0,0,0,0,0,0,0,0,0,1516.00,1883.00,0,0,3330.00,0,0,0,0,0,0,0",
"dataSource": 2,
"created": "2020-08-22 00:17:42",
"active": 0,
"updated": 1598084752590
}]
}
}
提交自动刷步
get请求
http://你的域名(或者公网ip:8080)/Service/updateStep?phone=18888888888&password=CZ123456&steps=9990&flag=1
响应
{
"code": 508,
"msg": "已加入数据库进行定时任务"
}
响应码
{
"code": 200,
"msg": "成功",
"data": {
"pedometerRecordHourlyList": [{
"id": "08be23751dc24a4bbca0638ad8880973",
"userId": 27753231,
"deviceId": "M_NULL",
"measurementTime": "2020-08-22 00:00:00",
"step": "9950,9950,0,0,0,0,0,0,0,0,0,0,4550,5650,0,0,9990,0,0,0,0,0,0,0",
"calories": "2487.00,2487.00,0,0,0,0,0,0,0,0,0,0,1137.00,1412.00,0,0,2497.00,0,0,0,0,0,0,0",
"distance": "3316.00,3316.00,0,0,0,0,0,0,0,0,0,0,1516.00,1883.00,0,0,3330.00,0,0,0,0,0,0,0",
"dataSource": 2,
"created": "2020-08-22 00:17:42",
"active": 0,
"updated": 1598084752590
}]
}
}
{
"code": 508,
"msg": "已加入数据库进行定时任务"
}
{
"code": 407,
"msg": "密码错误"
}
{
"code": 510,
"msg": "手机号长度错误"
}