AssetAreaValidate.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\validate\asset;
  15. use app\common\validate\BaseValidate;
  16. use app\common\model\asset\AssetArea;
  17. /**
  18. * 资产地址管理验证
  19. * Class ArticleValidate
  20. * @package app\adminapi\validate\article
  21. */
  22. class AssetAreaValidate extends BaseValidate
  23. {
  24. protected $rule = [
  25. 'id' => 'require|checkAssetInfo',
  26. 'title' => 'require|length:1,50',
  27. ];
  28. protected $message = [
  29. 'id.require' => '资产地址id必传',
  30. 'title.require' => '地址名称不能为空',
  31. 'title.length' => '地址名称长度须在1-55位字符',
  32. ];
  33. /**
  34. * @notes 添加场景
  35. * @return ArticleValidate
  36. * @author heshihu
  37. * @date 2022/2/22 9:57
  38. */
  39. public function sceneAdd()
  40. {
  41. return $this->remove(['id'])
  42. ->remove('id','require|checkAssetInfo');
  43. }
  44. /**
  45. * @notes 详情场景
  46. * @return ArticleValidate
  47. * @author heshihu
  48. * @date 2022/2/22 10:15
  49. */
  50. public function sceneDetail()
  51. {
  52. return $this->only(['id']);
  53. }
  54. public function sceneEdit()
  55. {
  56. }
  57. public function sceneStatus()
  58. {
  59. return $this->only(['id']);
  60. }
  61. /**
  62. * @notes 删除场景
  63. * @return ArticleValidate
  64. * @author heshihu
  65. * @date 2022/2/22 10:17
  66. */
  67. public function sceneDelete()
  68. {
  69. return $this->only(['id']);
  70. }
  71. /**
  72. * @notes 检查指定地址是否存在
  73. * @param $value
  74. * @return bool|string
  75. * @author heshihu
  76. * @date 2022/2/22 10:11
  77. */
  78. public function checkAssetInfo($value)
  79. {
  80. $article = AssetArea::findOrEmpty($value);
  81. if ($article->isEmpty()) {
  82. return '地址不存在';
  83. }
  84. return true;
  85. }
  86. }