app_api.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. syntax = "proto3";
  2. option go_package = "api/app";
  3. package app.v1;
  4. import "google/protobuf/duration.proto";
  5. import "google/protobuf/timestamp.proto";
  6. enum ErrorCode{
  7. OK = 0;
  8. TokenExpire = 1000;
  9. UserBan = 1001;
  10. VfCodeExpire = 1002;
  11. SmsSendFail = 1003;
  12. UserStatusErr = 1008;
  13. StatusErr = 1009;
  14. PhoneNotExist = 2001;
  15. UnknownErr = 2002;
  16. ParamErr = 5000;
  17. HeadSourceErr = 5001;
  18. DATABASE = 9000;
  19. NoRecord = 9001;
  20. }
  21. message Image {
  22. string ext = 1;
  23. bytes data = 2;
  24. }
  25. /* 需验证身份的接口均在metadata中添加auth字段,填充登录返回的token值,version字段检查版本兼容性,不兼容
  26. 报unimplemented错误,且message为 "VERSION_TOO_LOW"
  27. */
  28. service ApiApp {
  29. rpc AuthSendCodeToPhone(AuthSendCodeToPhoneRequest) returns (DefaultReply); //获取短信验证码
  30. rpc GetVfPic(DefaultRequest) returns (Image); //获取滑动校验图片
  31. rpc SignOut (SignOutRequest) returns (DefaultReply); //登出
  32. rpc Unsubscribe (DefaultRequest) returns (DefaultReply); //注销
  33. rpc SignIn(SignInRequest) returns(SignInReply); //手机App用户登录
  34. rpc SignUp (SignUpRequest) returns (SignInReply); //注册
  35. rpc UserNameEdit(UserNameEditRequest) returns(DefaultReply); //用户名称修改
  36. rpc ProviderList(ProviderListRequest) returns (ProviderListReply); //商家列表,根据传入的经纬度来排序
  37. rpc ProviderDetail(IdRequest) returns (ProviderDetailReply); //商家详情
  38. rpc ProjectListByPosition(PositionRequest) returns (ProjectListReply); //方案列表查询根据传入的经纬度
  39. rpc ProjectListByProvider(IdRequest) returns (ProjectListReply); //方案列表查询通过商家ID
  40. rpc ProjectDetail(IdRequest) returns (ProjectDetailReply); //方案详情,传入方案ID
  41. rpc GameStart(GameStartRequest) returns (GameStartReply); //游戏开始
  42. rpc GameSaveUpload(GameSaveUploadRequest) returns (DefaultReply); //游戏中上报打点信息
  43. //rpc GameGiveUp(DefaultRequest) returns (DefaultReply); //游戏放弃
  44. rpc GameFinish(GameFinishRequest) returns (GameDetailReply); //游戏放弃
  45. rpc GetRegion(DefaultRequest) returns(Region); //获取区域
  46. rpc RegionList(RegionListRequest)returns(RegionListReply); //区域列表查询
  47. rpc GetInGameData(DefaultRequest)returns(GetInGameDataReply); //获取进行中的游戏数据,若没有,报notFound错误
  48. rpc GetServerTime(DefaultRequest)returns(GetServerTimeReply); //获取系统时间
  49. rpc GetSmsSendLeftTime(GetSmsSendLeftTimeRequest)returns(GetSmsSendLeftTimeReply); //查询下次短信发送剩余时间
  50. rpc GetUpdateVersion(GetUpdateVersionRequest)returns(GetUpdateVersionReply); //查询升级信息
  51. rpc MyHistoryGame(DefaultRequest)returns(MyHistoryGameReply); //查询历史记录
  52. rpc HistoryGameDetail(IdRequest)returns(GameDetailReply); //历史记录详情
  53. rpc MyUserQuery(DefaultRequest)returns(MyUserQueryReply); //用户自身信息查询
  54. rpc AssShopList(DefaultRequest) returns (AssShopListReply); //管理助手商家列表
  55. rpc AssControlInfoList(IdRequest) returns (AssControlInfoListReply); //管理助手商家下属检查点列表
  56. rpc AssControlInfoDetail(IdRequest) returns (AssControlInfoDetailReply); //管理助手检查点详情
  57. rpc AssControlInfoSave(AssControlInfoSaveRequest) returns (DefaultReply); //管理助手上报点位信息
  58. rpc AssControlInfoGpsSave(AssControlInfoGpsSaveRequest) returns (DefaultReply); //管理助手上报点位gps信息
  59. rpc AssVerification(AssVerificationRequest) returns (DefaultReply); // 管理助手核销
  60. }
  61. message GameFinishRequest{
  62. int32 game_id = 1; //游戏记录id
  63. bool isDrop =2; //是否中途退赛,中途未打卡结束点为 true ,其余为false
  64. }
  65. message GameDetailReply{
  66. int32 game_id = 1; //游戏记录id
  67. bool isComplete = 2; //是否成功完赛 中途退赛,没有打卡结束点为false,打卡结束点为 true
  68. google.protobuf.Timestamp start_at = 3; //开始时间
  69. repeated GameControlPoint checked_sorted_list = 4; //检查点
  70. google.protobuf.Duration duration = 5; //从游戏开始到上报的时间差
  71. google.protobuf.Timestamp stop_at = 6;//结束时间//0为未结束
  72. string qrJsonCode = 7;//生成核销二维码的字符串
  73. }
  74. message GameControlPoint{
  75. int64 id = 1; //检查点id
  76. string sn = 2; //检查点编号,如:A51
  77. CType cType = 3; //1开始点 2途径点 3结束点
  78. int32 orderNo = 4; //正确的途经点序号
  79. bool is_check_success=5; //是否成功
  80. google.protobuf.Duration check_after_last =6; //打卡相对于上一个点时间,给检查点显示用
  81. google.protobuf.Timestamp punchTime = 7;//打点时间,给开始点结束点显示用
  82. }
  83. message AssVerificationRequest{
  84. int32 userId = 1; //用户id
  85. int32 uoId =2; //游戏记录id
  86. }
  87. message GameHistory {
  88. int64 game_id = 1; //实例Id ,对应数据库uoId
  89. string name = 2; //方案名称
  90. string shopName = 3; //商家名称
  91. bool isComplete = 4;//比赛完成状态 true:完赛 false:退赛
  92. google.protobuf.Timestamp game_time = 5; //开始时间
  93. NetImage image = 6; //方案图片
  94. }
  95. message NetImage{
  96. string url = 1;
  97. bytes md5 =2;
  98. }
  99. message Position{
  100. double longitude = 1;
  101. double latitude = 2;
  102. }
  103. message ControlPointInfo{
  104. NetImage image = 1; //检查点内容图片(文创)
  105. string content = 2; //检查点内容文字
  106. }
  107. message ControlPoint{
  108. int64 id = 1; //检查点id
  109. ControlPointInfo info = 2; //检查点显示信息
  110. repeated string nfc_id_list = 3; //nfcId
  111. int64 on_map_x = 4; //地图X坐标
  112. int64 on_map_y = 5; //地图Y坐标
  113. string sn = 6; //检查点编号,如:A51
  114. }
  115. message ControlPointSimple{
  116. int64 id = 1; //检查点id
  117. repeated string nfc_id_list = 2; //nfcId
  118. string sn = 3; // 检查点编号,如:A51
  119. }
  120. message GameData{
  121. int64 game_id = 1; //用户定向记录Id,对应数据库uoId
  122. NetImage map_image = 2; //路线地图
  123. int64 map_width_cm = 3; //场地实际
  124. int64 map_height_cm = 4; //场地实际
  125. repeated ControlPoint control_point_sorted_list = 5; //按打点顺序排列的检查点序列
  126. google.protobuf.Duration max_duration = 6; //正常结束时间
  127. google.protobuf.Duration max_forced_end_duration = 7; //强制结束时间
  128. double map_direction_offset_angle = 8; //地图正上与北偏移角度
  129. Position map_left_bottom_position = 9; //原点经纬度
  130. google.protobuf.Timestamp game_start = 10; //游戏开始时间
  131. repeated ControlPointSimple control_point_all = 11; //范围内所有检查点
  132. NetImage legend_image = 12; //图例
  133. }
  134. message GameSaveControlPoint{
  135. int64 control_point_id = 1; //检查点Id
  136. bool is_check_success=2; //是否成功
  137. google.protobuf.Duration check_after_start =3; //打卡相对于开始时间
  138. }
  139. // 游戏进度存档
  140. message GameSave{
  141. int64 game_id = 1; //实例Id ,对应数据库uoId
  142. google.protobuf.Timestamp start_at =2; //开始时间
  143. repeated GameSaveControlPoint checked_sorted_list = 3; //检查点
  144. google.protobuf.Duration duration = 4; //从游戏开始到上报的时间差
  145. google.protobuf.Timestamp stop_at = 5;//结束时间//0为未结束
  146. }
  147. //======================================================== Request ===============================================
  148. message AuthSendCodeToPhoneRequest {
  149. string phone = 1;
  150. UserType userType = 2;
  151. SmsType smsType = 3;
  152. }
  153. message PositionRequest{
  154. Position position = 1;
  155. }
  156. message IdRequest{
  157. int64 id = 1;
  158. }
  159. message SignOutRequest {
  160. string name = 1;
  161. }
  162. message UserNameEditRequest {
  163. string name = 1;
  164. }
  165. message GetSmsSendLeftTimeRequest{
  166. string phone = 1;
  167. }
  168. message ProviderListRequest{
  169. Position position = 1;
  170. string name = 2;
  171. int32 is_open = 3; // 是否营业中,0或空为全部,1是2否
  172. string region_id = 4; // 地区编号
  173. }
  174. message AssControlInfoSaveRequest {
  175. int32 ciId =1; //点位id
  176. repeated string nfcCodeList = 2; //nfcCode,如04AA8642591390,不含冒号
  177. }
  178. message AssControlInfoGpsSaveRequest {
  179. int32 ciId =1; //点位id
  180. Position position = 2; //经纬度
  181. }
  182. message GetUpdateVersionRequest {
  183. string vCode = 1; //当前版本号
  184. }
  185. message DefaultRequest{
  186. }
  187. message SignUpRequest {
  188. string phone = 1;
  189. string password = 2;
  190. string nickname = 3;
  191. UserType userType = 4;
  192. string headUrl = 5; //用户头像,可为空,后台随机分配
  193. User.Sex sex = 6;
  194. }
  195. message User{
  196. enum Sex{
  197. UnDefine = 0;
  198. Male = 1;
  199. Female = 2;
  200. }
  201. }
  202. message SignInRequest{
  203. string name = 1;
  204. string password = 2;
  205. string deviceId = 3;
  206. }
  207. message GameStartRequest{
  208. int64 project_id = 1;
  209. int64 map_route_id = 2;
  210. }
  211. message GameSaveUploadRequest{
  212. GameSave game_save= 1;
  213. }
  214. //======================================================== Reply ===============================================
  215. message DefaultReply{}
  216. message SignInReply{
  217. string token = 1;
  218. }
  219. message HistoryGameDetailReply {
  220. GameData game_data = 1;
  221. GameSave game_save =2;
  222. }
  223. message MyHistoryGameReply {
  224. repeated GameHistory games = 1; //历史游戏记录
  225. }
  226. message ProviderInfoSimple{
  227. int64 id = 1;
  228. string name = 2;
  229. Position position = 3;
  230. string address = 4;
  231. NetImage image = 5;
  232. double distance = 6;
  233. bool is_open = 7; // 是否营业中 0 关店 1 营业中
  234. int32 project_num = 8; // 方案数量
  235. string phone = 9;//电话
  236. }
  237. message ProviderListReply {
  238. repeated ProviderInfoSimple list = 1;
  239. }
  240. message ProviderDetailReply {
  241. ProviderInfoSimple base = 1;
  242. google.protobuf.Timestamp open_begin = 2; // 营业时间开始
  243. google.protobuf.Timestamp open_end = 3; // 营业时间结束
  244. string telephone =4;
  245. string introduction =5; // 商家简介
  246. }
  247. message ProjectInfoSimple{
  248. int64 rsId = 1; //方案Id
  249. string rsName = 2; //方案名称
  250. NetImage projectImage = 3;//方案图片
  251. string shopName = 4;//商家名称
  252. Position Position = 5;//商家位置
  253. string addr = 6;//商家地址
  254. double distance = 7; //距离
  255. bool isInGame = 8; // 是否游戏中
  256. }
  257. message ProjectListReply{
  258. repeated ProjectInfoSimple list = 1;
  259. }
  260. message MapRoute{
  261. int64 id = 1; //路线id
  262. string name = 2;//路线名称
  263. NetImage image = 3;//路线底图信息
  264. }
  265. message ProjectDetailReply{
  266. ProjectInfoSimple base_info = 1;
  267. ProjectContentType content_type = 2;//项目介绍类型
  268. string content = 3; //项目介绍
  269. int32 lockup = 4;//关门时间单位:秒
  270. int32 forcedEntTime = 5;//强制结束时间单位:秒
  271. int32 totalControlNum = 6;//总计打点数
  272. int32 maxRange = 7;//直线最大距离,单位:米
  273. NetImage image = 8;//宣传图片
  274. int32 mapScaleNumber = 9;//比例尺,例:1:1500 为 1500
  275. int32 contourInterval = 10;//等高距 单位:米
  276. repeated MapRoute routes = 11; // 路线数组
  277. }
  278. message GameStartReply{
  279. GameData game_data = 1;
  280. }
  281. message GetRegionReply{
  282. string province = 1; // 省份
  283. string provinceId = 2; // 省份代码
  284. string city = 3; // 城市
  285. string cityId = 4; // 城市代码
  286. }
  287. message RegionListRequest{
  288. string country_code = 1;// 国家代码(ISO 3166-1): 中国 CN
  289. }
  290. // example: code = 370000 name = 山东省;code = 370100 name = 济南市;code = 370102 name = 历下区
  291. message Region{
  292. string code = 1;
  293. string name = 2;
  294. }
  295. // 省市区编码列表
  296. message RegionListReply{
  297. repeated Region region = 1;
  298. }
  299. message GetInGameDataReply{
  300. GameData data = 1;
  301. GameSave save = 2;
  302. }
  303. message MyUserQueryReply {
  304. int32 userId =1; //用户id
  305. string name = 2; //名称
  306. NetImage head =3; //头像
  307. int32 sysPoint =4; //百味豆
  308. string phone = 5; //手机
  309. }
  310. message AssShopListReply {
  311. repeated ShopList list = 1;
  312. }
  313. message ShopList {
  314. int32 shopId =1; //商家id
  315. string name = 2; //名称
  316. }
  317. message AssControlInfoListReply {
  318. repeated ControlInfoList list = 1;
  319. }
  320. message ControlInfoList {
  321. int32 ciId =1; //id
  322. string ciCode = 2; //编码
  323. }
  324. message AssControlInfoDetailReply {
  325. int32 ciId =1; //id
  326. string ciCode = 2; //编码
  327. Position position = 3; //经纬度
  328. repeated string nfcCodeList = 4; //nfcCode,如04AA8642591390,不含冒号
  329. }
  330. message GetUpdateVersionReply {
  331. bool needUpdate = 1; //是否需要升级 false 最新不用升级 true需要升级
  332. string vCode = 2; //最新版本号
  333. string vMemo = 3; //升级说明
  334. string vUrl = 4; //下载链接
  335. }
  336. message GetSmsSendLeftTimeReply{
  337. int32 second = 1;
  338. }
  339. message GetServerTimeReply{
  340. int64 millisecondStamp = 1;
  341. }
  342. //======================================================== Enum ===============================================
  343. // UserType 用户类型
  344. enum UserType{
  345. UnDefine = 0;
  346. AppUser = 1; //手机App用户
  347. ParkAdmin = 2; //园区管理员
  348. IPAdmin = 3; //内容商管理员
  349. SysAdmin = 4; //系统管理员
  350. }
  351. // LoginSource 登陆来源
  352. enum LoginSource {
  353. UnDef = 0;
  354. UserApp = 1; //用户手机APP
  355. WebAdmin = 2; //网页管理端
  356. ShopApp = 3; //商家助手APP
  357. }
  358. enum SmsType{
  359. UnKnow = 0;
  360. Login = 1; //登录
  361. SignUp = 2; //注册
  362. }
  363. enum ProjectContentType{
  364. Text = 0;
  365. Html = 1;
  366. }
  367. enum CType{
  368. UnKnowType = 0;
  369. BeginType = 1; //开始点
  370. MiddleType = 2; //途经点
  371. EndType = 3; //结束点
  372. }