WxSyncRelationRepositories.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Http\Controllers\Api\Repositories;
  3. use App\Models\WxSyncRelation as Model;
  4. class WxSyncRelationRepositories{
  5. protected $eloquentClass = Model::class;
  6. /** 获取内部id
  7. * @param $domain
  8. * @param $type
  9. * @param $id
  10. * @return mixed
  11. */
  12. public static function inner_id($domain, $type, $id){
  13. return Model::where([['domain', '=', $domain],['type', '=', $type],['external_id', '=', $id]])->value('inner_id');
  14. }
  15. /** 获取外部id
  16. * @param $domain
  17. * @param $type
  18. * @param $id
  19. * @return mixed
  20. */
  21. public static function external_id($domain, $type, $id){
  22. return Model::where([['domain', '=', $domain],['type', '=', $type],['inner_id', '=', $id]])->value('external_id');
  23. }
  24. /**
  25. * 根据inner_id获取外部external_id
  26. * @param $domain
  27. * @param $uid
  28. * @return mixed
  29. */
  30. public static function uid($domain, $uid){
  31. return Model::where([['domain', '=', $domain],['type', '=', 'user'],['inner_id', '=', $uid]])->value('external_id');
  32. }
  33. /**
  34. * 根据inner_id获取外部external_id
  35. * @param $domain
  36. * @param $post_id
  37. * @return mixed
  38. */
  39. public static function post_id($domain, $post_id){
  40. return Model::where([['domain', '=', $domain],['type', '=', 'post'],['inner_id', '=', $post_id]])->value('external_id');
  41. }
  42. /**
  43. * 获取外部评论id
  44. * @param $domain
  45. * @param $comment_id
  46. * @return mixed
  47. */
  48. public static function comment_id($domain, $comment_id){
  49. return Model::where([['domain', '=', $domain],['type', '=', 'comment'],['inner_id', '=', $comment_id]])->value('external_id');
  50. }
  51. /**
  52. * 根据inner_id获取外部external_id
  53. * @param $domain
  54. * @param $good_id
  55. * @return mixed
  56. */
  57. public static function good_id($domain, $good_id){
  58. return Model::where([['domain', '=', $domain],['type', '=', 'good'],['inner_id', '=', $good_id]])->value('external_id');
  59. }
  60. /**
  61. * 根据外部id获取内部id
  62. * @param $domain
  63. * @param $uid
  64. * @return mixed
  65. */
  66. public static function wx_uid( $domain, $uid ){
  67. return Model::where([['domain', '=', $domain],['type', '=', 'user'],['external_id', '=', $uid]])->value('inner_id');
  68. }
  69. /**
  70. * 根据外部id获取内部id
  71. * @param $domain
  72. * @param $post_id
  73. * @return mixed
  74. */
  75. public static function wx_post_id($domain, $post_id){
  76. return Model::where([['domain', '=', $domain],['type', '=', 'post'],['external_id', '=', $post_id]])->value('inner_id');
  77. }
  78. public static function wx_good_id($domain, $good_id){
  79. return Model::where([['domain', '=', $domain],['type', '=', 'good'],['external_id', '=', $good_id]])->value('inner_id');
  80. }
  81. public static function wx_comment_id($domain, $comment_id){
  82. return Model::where([['domain', '=', $domain],['type', '=', 'comment'],['external_id', '=', $comment_id]])->value('inner_id');
  83. }
  84. }