BestKnowledge.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免费声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  13. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  14. // +----------------------------------------------------------------------
  15. namespace app\admin\controller;
  16. use app\data\model\DataBestKnowledge;
  17. use app\data\model\DataClassification;
  18. use app\data\model\DataPoolTalent;
  19. use app\data\model\DataZhicheng;
  20. use Carbon\Carbon;
  21. use think\admin\Controller;
  22. use think\admin\model\SystemUser;
  23. use think\db\Query;
  24. /**
  25. * 百知文库管理
  26. * Class BestKnowledge
  27. * @package app\admin\controller
  28. */
  29. class BestKnowledge extends Controller
  30. {
  31. /**
  32. * 分类管理
  33. * @auth true
  34. * @menu true
  35. */
  36. public function class(){
  37. $this->title='分类管理';
  38. DataClassification::mQuery()
  39. ->show(1)
  40. ->like('name')
  41. ->order('id','desc')
  42. ->layTable();
  43. }
  44. /**
  45. * 分类编辑
  46. * @auth true
  47. * @menu true
  48. */
  49. public function class_edit(){
  50. DataClassification::mForm('class_form');
  51. }
  52. /**
  53. * 分类添加
  54. * @auth true
  55. * @menu true
  56. */
  57. public function class_add(){
  58. DataClassification::mForm('class_form');
  59. }
  60. /**
  61. * 分类删除
  62. * @auth true
  63. * @menu true
  64. */
  65. public function class_del($id){
  66. DataClassification::whereIn('id',$id)->save([
  67. 'is_del'=>0,
  68. ]);
  69. $this->success('删除成功');
  70. }
  71. /**
  72. * 百知文库申请管理
  73. * @auth true
  74. * @menu true
  75. */
  76. public function index(){
  77. $this->title='百知文库申请列表';
  78. $name=input('name');
  79. DataBestKnowledge::mQuery()
  80. ->when($name,function (Query $query) use ($name) {
  81. $query->hasWhere('user',function (Query $query) use ($name) {
  82. $query->whereLike('nickname',"%{$name}%");
  83. });
  84. })
  85. ->with(['user','classTo'])
  86. ->where('type',2)
  87. ->where('is_del',1)
  88. ->order('id','desc')
  89. ->layTable();
  90. }
  91. /**
  92. * 百知文库申请审核
  93. * @auth true
  94. * @menu true
  95. */
  96. public function audit($id){
  97. $this->title='百知文库申请审核';
  98. $row=DataBestKnowledge::mk()->findOrFail($id);
  99. if($this->request->isGet()){
  100. $this->assign('row',$row);
  101. $this->fetch();
  102. }else{
  103. if($row['audit']>1){
  104. $this->error('该记录已审核');
  105. }
  106. $data=$this->_vali([
  107. 'audit.require'=>'结果必须',
  108. 'audit.in:2,3'=>'结果有误',
  109. 'why.requireIf:audit,3'=>'原因必须',
  110. 'why.max:200'=>'原因有误',
  111. ]);
  112. $row['audit']=$data['audit'];
  113. $row['why']=$data['why']??'';
  114. $row['audit_at']=Carbon::now();
  115. $row->save();
  116. $this->success('审核成功');
  117. }
  118. }
  119. /**
  120. * 百知文库申请管理
  121. * @auth true
  122. * @menu true
  123. */
  124. public function index2(){
  125. $this->title='百知文库列表';
  126. $name=input('name');
  127. DataBestKnowledge::mQuery()
  128. ->when($name,function (Query $query) use ($name) {
  129. $query->hasWhere('user',function (Query $query) use ($name) {
  130. $query->whereLike('nickname',"%{$name}%");
  131. });
  132. })
  133. ->with(['user','classTo'])
  134. ->where('type',1)
  135. ->where('is_del',1)
  136. ->order('id','desc')
  137. ->layTable();
  138. }
  139. /**
  140. * 百知文库添加
  141. * @auth true
  142. * @menu true
  143. */
  144. public function add(){
  145. $this->assign('category',DataClassification::show(1)->select());
  146. DataBestKnowledge::mForm('form');
  147. }
  148. /**
  149. * 百知文库编辑
  150. * @auth true
  151. * @menu true
  152. */
  153. public function edit(){
  154. $this->assign('category',DataClassification::show(1)->select());
  155. DataBestKnowledge::mForm('form');
  156. }
  157. public function _form_filter($vo){
  158. if ($this->request->isGet()) {
  159. if (isset($vo['id'])){
  160. if (isset($vo['imgs'])){
  161. $vo['imgs']= implode('|',explode(',',implode(',',$vo['imgs'])));
  162. }
  163. $this->assign('vo',$vo);
  164. $this->fetch('form');
  165. }
  166. }elseif ($this->request->isPost()){
  167. $vo['imgs'] = implode(',',explode('|',$vo['imgs']));
  168. $vo['audit'] =2;
  169. isset($vo['id']) ? DataBestKnowledge::mk()->where('id',$vo['id'])->update($vo) : DataBestKnowledge::mk()->insert($vo);
  170. $this->success('数据更新成功');
  171. }
  172. }
  173. /**
  174. * 删除
  175. * @auth true
  176. * @menu true
  177. */
  178. public function del($id){
  179. DataBestKnowledge::whereIn('id',$id)->save([
  180. 'is_del'=>0,
  181. ]);
  182. $this->success('删除成功');
  183. }
  184. }