ResCenter.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace app\admin\controller;
  3. use app\data\model\DataResCenter as Model;
  4. use app\data\model\DataXwAd;
  5. use app\data\model\DataXwCategory;
  6. use think\admin\Controller;
  7. /**
  8. * 资源中心
  9. * Class Xw
  10. * @package app\admin\controller\Xw
  11. */
  12. class ResCenter extends Controller
  13. {
  14. /**
  15. * 资源列表
  16. * @auth true
  17. * @menu true
  18. */
  19. public function index(){
  20. $this->title='资源列表';
  21. Model::mQuery()
  22. ->like('title')->dateBetween('create_time')->layTable();
  23. }
  24. /**
  25. * 资源添加
  26. * @auth true
  27. * @menu true
  28. */
  29. public function add(){
  30. $this->xw_vali();
  31. Model::mForm('form');
  32. }
  33. /**
  34. * 资源编辑
  35. * @auth true
  36. * @menu true
  37. */
  38. public function edit(){
  39. $this->xw_vali();
  40. Model::mForm('form');
  41. }
  42. protected function xw_vali(){
  43. if($this->request->isPost()){
  44. $this->_vali([
  45. 'title.max:50'=>'标题过长',
  46. ]);
  47. }
  48. }
  49. /**
  50. * 资源删除
  51. * @auth true
  52. * @menu true
  53. */
  54. public function remove(){
  55. $ids=$this->request->post('id');
  56. Model::whereIn('id',$ids)->select()->each(function ($d){$d->delete();});
  57. $this->success('删除成功');
  58. }
  59. /**
  60. * 资源设置
  61. * @auth true
  62. * @menu true
  63. */
  64. public function config(){
  65. if($this->request->isGet()){
  66. $this->title='资源设置';
  67. $this->assign('vo',sysconf('config_res_center.'));
  68. $this->fetch();
  69. }else{
  70. $data=$this->_vali([
  71. 'c_rule.require'=>'规则数必须',
  72. 'c_conv.require'=>'公约数必须',
  73. 'c_menu.require'=>'清单数必须',
  74. ]);
  75. sysconf('config_res_center',$data);
  76. $this->success('保存成功');
  77. }
  78. }
  79. }