Ghuser.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Ghuser extends Model
  5. {
  6. // 表名
  7. protected $name = 'user';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'real_status_text',
  17. 'gender_text',
  18. 'idcard_status_text',
  19. 'prevtime_text',
  20. 'logintime_text',
  21. 'jointime_text',
  22. 'status_text',
  23. 'open_match_video_text',
  24. 'open_match_audio_text',
  25. 'open_match_typing_text',
  26. 'free_video_text',
  27. 'free_audio_text',
  28. 'free_typing_text',
  29. 'hide_is_finishinfo_text',
  30. 'is_guild_text',
  31. 'is_online_text',
  32. 'onlinetime_text',
  33. 'is_livebc_text',
  34. 'is_active_text',
  35. 'active_time_text',
  36. 'secretvideo_status_text'
  37. ];
  38. public function getRealStatusList()
  39. {
  40. return ['-1' => __('Real_status -1'), '0' => __('Real_status 0'), '1' => __('Real_status 1'), '2' => __('Real_status 2')];
  41. }
  42. public function getGenderList()
  43. {
  44. return ['1' => __('Gender 1'), '0' => __('Gender 0')];
  45. }
  46. public function getIdcardStatusList()
  47. {
  48. return ['-1' => __('Idcard_status -1'), '0' => __('Idcard_status 0'), '1' => __('Idcard_status 1'), '2' => __('Idcard_status 2')];
  49. }
  50. public function getStatusList()
  51. {
  52. return ['1' => __('Status 1'), '0' => __('Status 0'), '-1' => __('Status -1')];
  53. }
  54. public function getOpenMatchVideoList()
  55. {
  56. return ['1' => __('Open_match_video 1'), '0' => __('Open_match_video 0')];
  57. }
  58. public function getOpenMatchAudioList()
  59. {
  60. return ['1' => __('Open_match_audio 1'), '0' => __('Open_match_audio 0')];
  61. }
  62. public function getOpenMatchTypingList()
  63. {
  64. return ['1' => __('Open_match_typing 1'), '0' => __('Open_match_typing 0')];
  65. }
  66. public function getFreeVideoList()
  67. {
  68. return ['1' => __('Free_video 1'), '0' => __('Free_video 0')];
  69. }
  70. public function getFreeAudioList()
  71. {
  72. return ['1' => __('Free_audio 1'), '0' => __('Free_audio 0')];
  73. }
  74. public function getFreeTypingList()
  75. {
  76. return ['1' => __('Free_typing 1'), '0' => __('Free_typing 0')];
  77. }
  78. public function getHideIsFinishinfoList()
  79. {
  80. return ['1' => __('Hide_is_finishinfo 1'), '0' => __('Hide_is_finishinfo 0')];
  81. }
  82. public function getIsGuildList()
  83. {
  84. return ['1' => __('Is_guild 1'), '0' => __('Is_guild 0'), '-1' => __('Is_guild -1'), '2' => __('Is_guild 2'), '3' => __('Is_guild 3')];
  85. }
  86. public function getIsOnlineList()
  87. {
  88. return ['1' => __('Is_online 1'), '0' => __('Is_online 0')];
  89. }
  90. public function getIsLivebcList()
  91. {
  92. return ['1' => __('Is_livebc 1'), '0' => __('Is_livebc 0')];
  93. }
  94. public function getIsActiveList()
  95. {
  96. return ['1' => __('Is_active 1'), '0' => __('Is_active 0')];
  97. }
  98. public function getSecretvideoStatusList()
  99. {
  100. return ['-1' => __('Secretvideo_status -1'), '0' => __('Secretvideo_status 0'), '1' => __('Secretvideo_status 1'), '2' => __('Secretvideo_status 2')];
  101. }
  102. public function getRealStatusTextAttr($value, $data)
  103. {
  104. $value = $value ? $value : (isset($data['real_status']) ? $data['real_status'] : '');
  105. $list = $this->getRealStatusList();
  106. return isset($list[$value]) ? $list[$value] : '';
  107. }
  108. public function getGenderTextAttr($value, $data)
  109. {
  110. $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
  111. $list = $this->getGenderList();
  112. return isset($list[$value]) ? $list[$value] : '';
  113. }
  114. public function getIdcardStatusTextAttr($value, $data)
  115. {
  116. $value = $value ? $value : (isset($data['idcard_status']) ? $data['idcard_status'] : '');
  117. $list = $this->getIdcardStatusList();
  118. return isset($list[$value]) ? $list[$value] : '';
  119. }
  120. public function getPrevtimeTextAttr($value, $data)
  121. {
  122. $value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : '');
  123. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  124. }
  125. public function getLogintimeTextAttr($value, $data)
  126. {
  127. $value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
  128. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  129. }
  130. public function getJointimeTextAttr($value, $data)
  131. {
  132. $value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
  133. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  134. }
  135. public function getStatusTextAttr($value, $data)
  136. {
  137. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  138. $list = $this->getStatusList();
  139. return isset($list[$value]) ? $list[$value] : '';
  140. }
  141. public function getOpenMatchVideoTextAttr($value, $data)
  142. {
  143. $value = $value ? $value : (isset($data['open_match_video']) ? $data['open_match_video'] : '');
  144. $list = $this->getOpenMatchVideoList();
  145. return isset($list[$value]) ? $list[$value] : '';
  146. }
  147. public function getOpenMatchAudioTextAttr($value, $data)
  148. {
  149. $value = $value ? $value : (isset($data['open_match_audio']) ? $data['open_match_audio'] : '');
  150. $list = $this->getOpenMatchAudioList();
  151. return isset($list[$value]) ? $list[$value] : '';
  152. }
  153. public function getOpenMatchTypingTextAttr($value, $data)
  154. {
  155. $value = $value ? $value : (isset($data['open_match_typing']) ? $data['open_match_typing'] : '');
  156. $list = $this->getOpenMatchTypingList();
  157. return isset($list[$value]) ? $list[$value] : '';
  158. }
  159. public function getFreeVideoTextAttr($value, $data)
  160. {
  161. $value = $value ? $value : (isset($data['free_video']) ? $data['free_video'] : '');
  162. $list = $this->getFreeVideoList();
  163. return isset($list[$value]) ? $list[$value] : '';
  164. }
  165. public function getFreeAudioTextAttr($value, $data)
  166. {
  167. $value = $value ? $value : (isset($data['free_audio']) ? $data['free_audio'] : '');
  168. $list = $this->getFreeAudioList();
  169. return isset($list[$value]) ? $list[$value] : '';
  170. }
  171. public function getFreeTypingTextAttr($value, $data)
  172. {
  173. $value = $value ? $value : (isset($data['free_typing']) ? $data['free_typing'] : '');
  174. $list = $this->getFreeTypingList();
  175. return isset($list[$value]) ? $list[$value] : '';
  176. }
  177. public function getHideIsFinishinfoTextAttr($value, $data)
  178. {
  179. $value = $value ? $value : (isset($data['hide_is_finishinfo']) ? $data['hide_is_finishinfo'] : '');
  180. $list = $this->getHideIsFinishinfoList();
  181. return isset($list[$value]) ? $list[$value] : '';
  182. }
  183. public function getIsGuildTextAttr($value, $data)
  184. {
  185. $value = $value ? $value : (isset($data['is_guild']) ? $data['is_guild'] : '');
  186. $list = $this->getIsGuildList();
  187. return isset($list[$value]) ? $list[$value] : '';
  188. }
  189. public function getIsOnlineTextAttr($value, $data)
  190. {
  191. $value = $value ? $value : (isset($data['is_online']) ? $data['is_online'] : '');
  192. $list = $this->getIsOnlineList();
  193. return isset($list[$value]) ? $list[$value] : '';
  194. }
  195. public function getOnlinetimeTextAttr($value, $data)
  196. {
  197. $value = $value ? $value : (isset($data['onlinetime']) ? $data['onlinetime'] : '');
  198. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  199. }
  200. public function getIsLivebcTextAttr($value, $data)
  201. {
  202. $value = $value ? $value : (isset($data['is_livebc']) ? $data['is_livebc'] : '');
  203. $list = $this->getIsLivebcList();
  204. return isset($list[$value]) ? $list[$value] : '';
  205. }
  206. public function getIsActiveTextAttr($value, $data)
  207. {
  208. $value = $value ? $value : (isset($data['is_active']) ? $data['is_active'] : '');
  209. $list = $this->getIsActiveList();
  210. return isset($list[$value]) ? $list[$value] : '';
  211. }
  212. public function getActiveTimeTextAttr($value, $data)
  213. {
  214. $value = $value ? $value : (isset($data['active_time']) ? $data['active_time'] : '');
  215. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  216. }
  217. public function getSecretvideoStatusTextAttr($value, $data)
  218. {
  219. $value = $value ? $value : (isset($data['secretvideo_status']) ? $data['secretvideo_status'] : '');
  220. $list = $this->getSecretvideoStatusList();
  221. return isset($list[$value]) ? $list[$value] : '';
  222. }
  223. protected function setPrevtimeAttr($value)
  224. {
  225. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  226. }
  227. protected function setLogintimeAttr($value)
  228. {
  229. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  230. }
  231. protected function setJointimeAttr($value)
  232. {
  233. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  234. }
  235. protected function setOnlinetimeAttr($value)
  236. {
  237. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  238. }
  239. protected function setActiveTimeAttr($value)
  240. {
  241. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  242. }
  243. public function gonghui()
  244. {
  245. return $this->belongsTo('Gonghui', 'gh_id', 'id', [], 'LEFT')->setEagerlyType(0);
  246. }
  247. }