rcvr.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package impl
  4. import (
  5. "context"
  6. "property-device/impl/v1/gate"
  7. "property-device/impl/v1/gate_card"
  8. "property-device/impl/v1/gate_command"
  9. "property-device/impl/v1/gate_match"
  10. "property-device/impl/v1/gate_pic"
  11. "property-device/impl/v1/gate_record"
  12. "property-device/impl/v1/gate_unit"
  13. "property-device/impl/v1/mqtt_device"
  14. "property-device/impl/v1/visitor"
  15. "property-device/pb"
  16. pb_v1 "property-device/pb/v1"
  17. "git.getensh.com/common/gopkgs/tasker/rpctasker"
  18. "google.golang.org/grpc"
  19. )
  20. // 具体实现
  21. type Rcvr struct {
  22. }
  23. func Register(s *grpc.Server) {
  24. pb.RegisterDeviceServer(s, &Rcvr{})
  25. }
  26. //
  27. func (c *Rcvr) GateOnline(ctx context.Context, req *pb_v1.GateOnlineRequest) (reply *pb_v1.GateOnlineReply, err error) {
  28. t1 := func() error {
  29. reply, err = gate.GateOnline(ctx, req)
  30. return err
  31. }
  32. return reply, rpctasker.Exec(ctx, t1)
  33. }
  34. func (c *Rcvr) GateIn(ctx context.Context, req *pb_v1.GateInRequest) (reply *pb_v1.GateInReply, err error) {
  35. t1 := func() error {
  36. reply, err = gate.GateIn(ctx, req)
  37. return err
  38. }
  39. return reply, rpctasker.Exec(ctx, t1)
  40. }
  41. func (c *Rcvr) GateBatchIn(ctx context.Context, req *pb_v1.GateBatchInRequest) (reply *pb_v1.GateBatchInReply, err error) {
  42. t1 := func() error {
  43. reply, err = gate.GateBatchIn(ctx, req)
  44. return err
  45. }
  46. return reply, rpctasker.Exec(ctx, t1)
  47. }
  48. func (c *Rcvr) GateList(ctx context.Context, req *pb_v1.GateListRequest) (reply *pb_v1.GateListReply, err error) {
  49. t1 := func() error {
  50. reply, err = gate.GateList(ctx, req)
  51. return err
  52. }
  53. return reply, rpctasker.Exec(ctx, t1)
  54. }
  55. func (c *Rcvr) GateOut(ctx context.Context, req *pb_v1.GateOutRequest) (reply *pb_v1.GateOutReply, err error) {
  56. t1 := func() error {
  57. reply, err = gate.GateOut(ctx, req)
  58. return err
  59. }
  60. return reply, rpctasker.Exec(ctx, t1)
  61. }
  62. func (c *Rcvr) GateProtocols(ctx context.Context, req *pb_v1.GateProtocolsRequest) (reply *pb_v1.GateProtocolsReply, err error) {
  63. t1 := func() error {
  64. reply, err = gate.GateProtocols(ctx, req)
  65. return err
  66. }
  67. return reply, rpctasker.Exec(ctx, t1)
  68. }
  69. func (c *Rcvr) GateDel(ctx context.Context, req *pb_v1.GateDelRequest) (reply *pb_v1.GateDelReply, err error) {
  70. t1 := func() error {
  71. reply, err = gate.GateDel(ctx, req)
  72. return err
  73. }
  74. return reply, rpctasker.Exec(ctx, t1)
  75. }
  76. func (c *Rcvr) GateRecovery(ctx context.Context, req *pb_v1.GateRecoveryRequest) (reply *pb_v1.GateRecoveryReply, err error) {
  77. t1 := func() error {
  78. reply, err = gate.GateRecovery(ctx, req)
  79. return err
  80. }
  81. return reply, rpctasker.Exec(ctx, t1)
  82. }
  83. func (c *Rcvr) GateEnable(ctx context.Context, req *pb_v1.GateEnableRequest) (reply *pb_v1.GateEnableReply, err error) {
  84. t1 := func() error {
  85. reply, err = gate.GateEnable(ctx, req)
  86. return err
  87. }
  88. return reply, rpctasker.Exec(ctx, t1)
  89. }
  90. func (c *Rcvr) GateSet(ctx context.Context, req *pb_v1.GateSetRequest) (reply *pb_v1.GateSetReply, err error) {
  91. t1 := func() error {
  92. reply, err = gate.GateSet(ctx, req)
  93. return err
  94. }
  95. return reply, rpctasker.Exec(ctx, t1)
  96. }
  97. // 添加门禁卡
  98. func (c *Rcvr) GateCardAdd(ctx context.Context, req *pb_v1.GateCardAddRequest) (reply *pb_v1.GateCardAddReply, err error) {
  99. t1 := func() error {
  100. reply, err = gate_card.GateCardAdd(ctx, req)
  101. return err
  102. }
  103. return reply, rpctasker.Exec(ctx, t1)
  104. }
  105. func (c *Rcvr) GateCardDel(ctx context.Context, req *pb_v1.GateCardDelRequest) (reply *pb_v1.GateCardDelReply, err error) {
  106. t1 := func() error {
  107. reply, err = gate_card.GateCardDel(ctx, req)
  108. return err
  109. }
  110. return reply, rpctasker.Exec(ctx, t1)
  111. }
  112. // 卡列表
  113. func (c *Rcvr) GateCardList(ctx context.Context, req *pb_v1.GateCardListRequest) (reply *pb_v1.GateCardListReply, err error) {
  114. t1 := func() error {
  115. reply, err = gate_card.GateCardList(ctx, req)
  116. return err
  117. }
  118. return reply, rpctasker.Exec(ctx, t1)
  119. }
  120. // 获取卡还可以绑定的设备
  121. func (c *Rcvr) GateCardCanBindDevices(ctx context.Context, req *pb_v1.GateCardCanBindDevicesRequest) (reply *pb_v1.GateCardCanBindDevicesReply, err error) {
  122. t1 := func() error {
  123. reply, err = gate_card.GateCardCanBindDevices(ctx, req)
  124. return err
  125. }
  126. return reply, rpctasker.Exec(ctx, t1)
  127. }
  128. // 卡下发
  129. func (c *Rcvr) GateCardSync(ctx context.Context, req *pb_v1.GateCardSyncRequest) (reply *pb_v1.GateCardSyncReply, err error) {
  130. t1 := func() error {
  131. reply, err = gate_card.GateCardSync(ctx, req)
  132. return err
  133. }
  134. return reply, rpctasker.Exec(ctx, t1)
  135. }
  136. // 人脸录入
  137. func (c *Rcvr) GateUserPicAdd(ctx context.Context, req *pb_v1.GateUserPicAddRequest) (reply *pb_v1.GateUserPicAddReply, err error) {
  138. t1 := func() error {
  139. reply, err = gate_pic.GateUserPicAdd(ctx, req)
  140. return err
  141. }
  142. return reply, rpctasker.Exec(ctx, t1)
  143. }
  144. func (c *Rcvr) GateUserPicDel(ctx context.Context, req *pb_v1.GateUserPicDelRequest) (reply *pb_v1.GateUserPicDelReply, err error) {
  145. t1 := func() error {
  146. reply, err = gate_pic.GateUserPicDel(ctx, req)
  147. return err
  148. }
  149. return reply, rpctasker.Exec(ctx, t1)
  150. }
  151. // 人脸审核
  152. func (c *Rcvr) GateUserPicApprove(ctx context.Context, req *pb_v1.GateUserPicApproveRequest) (reply *pb_v1.GateUserPicApproveReply, err error) {
  153. t1 := func() error {
  154. reply, err = gate_pic.GateUserPicApprove(ctx, req)
  155. return err
  156. }
  157. return reply, rpctasker.Exec(ctx, t1)
  158. }
  159. // 人脸下发
  160. func (c *Rcvr) GateUserPicSync(ctx context.Context, req *pb_v1.GateUserPicSyncRequest) (reply *pb_v1.GateUserPicSyncReply, err error) {
  161. t1 := func() error {
  162. reply, err = gate_pic.GateUserPicSync(ctx, req)
  163. return err
  164. }
  165. return reply, rpctasker.Exec(ctx, t1)
  166. }
  167. // 人脸列表
  168. func (c *Rcvr) GateUserPicList(ctx context.Context, req *pb_v1.GateUserPicListRequest) (reply *pb_v1.GateUserPicListReply, err error) {
  169. t1 := func() error {
  170. reply, err = gate_pic.GateUserPicList(ctx, req)
  171. return err
  172. }
  173. return reply, rpctasker.Exec(ctx, t1)
  174. }
  175. // 人脸信息
  176. func (c *Rcvr) GateUserPicInfo(ctx context.Context, req *pb_v1.GateUserPicInfoRequest) (reply *pb_v1.GateUserPicInfoReply, err error) {
  177. t1 := func() error {
  178. reply, err = gate_pic.GateUserPicInfo(ctx, req)
  179. return err
  180. }
  181. return reply, rpctasker.Exec(ctx, t1)
  182. }
  183. func (c *Rcvr) HouseholdGateSyncCheck(ctx context.Context, req *pb_v1.HouseholdGateSyncCheckRequest) (reply *pb_v1.HouseholdGateSyncCheckReply, err error) {
  184. t1 := func() error {
  185. reply, err = gate_pic.HouseholdGateSyncCheck(ctx, req)
  186. return err
  187. }
  188. return reply, rpctasker.Exec(ctx, t1)
  189. }
  190. func (c *Rcvr) MqttFaceGate(ctx context.Context, req *pb_v1.MqttFaceGateRequest) (reply *pb_v1.MqttFaceGateReply, err error) {
  191. t1 := func() error {
  192. reply, err = mqtt_device.MqttFaceGate(ctx, req)
  193. return err
  194. }
  195. return reply, rpctasker.Exec(ctx, t1)
  196. }
  197. // 门禁白名单匹配
  198. func (c *Rcvr) GateWhiteMatch(ctx context.Context, req *pb_v1.GateWhiteMatchRequest) (reply *pb_v1.GateWhiteMatchReply, err error) {
  199. t1 := func() error {
  200. reply, err = gate_match.GateWhiteMatch(ctx, req)
  201. return err
  202. }
  203. return reply, rpctasker.Exec(ctx, t1)
  204. }
  205. // 门禁进出记录添加
  206. func (c *Rcvr) GateRecordAdd(ctx context.Context, req *pb_v1.GateRecordAddRequest) (reply *pb_v1.GateRecordAddReply, err error) {
  207. t1 := func() error {
  208. reply, err = gate_record.GateRecordAdd(ctx, req)
  209. return err
  210. }
  211. return reply, rpctasker.Exec(ctx, t1)
  212. }
  213. // 门禁进出记录列表
  214. func (c *Rcvr) GateRecordList(ctx context.Context, req *pb_v1.GateRecordListRequest) (reply *pb_v1.GateRecordListReply, err error) {
  215. t1 := func() error {
  216. reply, err = gate_record.GateRecordList(ctx, req)
  217. return err
  218. }
  219. return reply, rpctasker.Exec(ctx, t1)
  220. }
  221. // 获取门禁远程命令
  222. func (c *Rcvr) GateCommandUse(ctx context.Context, req *pb_v1.GateCommandUseRequest) (reply *pb_v1.GateCommandUseReply, err error) {
  223. t1 := func() error {
  224. reply, err = gate_command.GateCommandUse(ctx, req)
  225. return err
  226. }
  227. return reply, rpctasker.Exec(ctx, t1)
  228. }
  229. // 门禁远程命令结果
  230. func (c *Rcvr) GateCommandResult(ctx context.Context, req *pb_v1.GateCommandResultRequest) (reply *pb_v1.GateCommandResultReply, err error) {
  231. t1 := func() error {
  232. reply, err = gate_command.GateCommandResult(ctx, req)
  233. return err
  234. }
  235. return reply, rpctasker.Exec(ctx, t1)
  236. }
  237. // 门禁命令添加
  238. func (c *Rcvr) GateCommandAdd(ctx context.Context, req *pb_v1.GateCommandAddRequest) (reply *pb_v1.GateCommandAddReply, err error) {
  239. t1 := func() error {
  240. reply, err = gate_command.GateCommandAdd(ctx, req)
  241. return err
  242. }
  243. return reply, rpctasker.Exec(ctx, t1)
  244. }
  245. // 门禁命令记录
  246. func (c *Rcvr) GateCommandList(ctx context.Context, req *pb_v1.GateCommandListRequest) (reply *pb_v1.GateCommandListReply, err error) {
  247. t1 := func() error {
  248. reply, err = gate_command.GateCommandList(ctx, req)
  249. return err
  250. }
  251. return reply, rpctasker.Exec(ctx, t1)
  252. }
  253. func (c *Rcvr) GateVisitorAdd(ctx context.Context, req *pb_v1.GateVisitorAddRequest) (reply *pb_v1.GateVisitorAddReply, err error) {
  254. t1 := func() error {
  255. reply, err = visitor.GateVisitorAdd(ctx, req)
  256. return err
  257. }
  258. return reply, rpctasker.Exec(ctx, t1)
  259. }
  260. func (c *Rcvr) GateVisitorDel(ctx context.Context, req *pb_v1.GateVisitorDelRequest) (reply *pb_v1.GateVisitorDelReply, err error) {
  261. t1 := func() error {
  262. reply, err = visitor.GateVisitorDel(ctx, req)
  263. return err
  264. }
  265. return reply, rpctasker.Exec(ctx, t1)
  266. }
  267. func (c *Rcvr) GateVisitorCheck(ctx context.Context, req *pb_v1.GateVisitorCheckRequest) (reply *pb_v1.GateVisitorCheckReply, err error) {
  268. t1 := func() error {
  269. reply, err = visitor.GateVisitorCheck(ctx, req)
  270. return err
  271. }
  272. return reply, rpctasker.Exec(ctx, t1)
  273. }
  274. func (c *Rcvr) GateVisitorList(ctx context.Context, req *pb_v1.GateVisitorListRequest) (reply *pb_v1.GateVisitorListReply, err error) {
  275. t1 := func() error {
  276. reply, err = visitor.GateVisitorList(ctx, req)
  277. return err
  278. }
  279. return reply, rpctasker.Exec(ctx, t1)
  280. }
  281. // 门禁绑定范围
  282. func (c *Rcvr) GateUnitAdd(ctx context.Context, req *pb_v1.GateUnitAddRequest) (reply *pb_v1.GateUnitAddReply, err error) {
  283. t1 := func() error {
  284. reply, err = gate_unit.GateUnitAdd(ctx, req)
  285. return err
  286. }
  287. return reply, rpctasker.Exec(ctx, t1)
  288. }
  289. // 门禁单元列表
  290. func (c *Rcvr) GateUnitList(ctx context.Context, req *pb_v1.GateUnitListRequest) (reply *pb_v1.GateUnitListReply, err error) {
  291. t1 := func() error {
  292. reply, err = gate_unit.GateUnitList(ctx, req)
  293. return err
  294. }
  295. return reply, rpctasker.Exec(ctx, t1)
  296. }
  297. // 绑定了某单元的门禁
  298. func (c *Rcvr) GateUnitDevice(ctx context.Context, req *pb_v1.GateUnitDeviceRequest) (reply *pb_v1.GateUnitDeviceReply, err error) {
  299. t1 := func() error {
  300. reply, err = gate_unit.GateUnitDevice(ctx, req)
  301. return err
  302. }
  303. return reply, rpctasker.Exec(ctx, t1)
  304. }