ArticleRecord.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. use think\Db;
  7. use think\exception\Handle;
  8. class ArticleRecord extends Base
  9. {
  10. public function __construct(App $app = null) {
  11. parent::__construct($app);
  12. $this->model = new \app\common\model\ArticleRecord();
  13. }
  14. //员工学习考试记录列表
  15. public function list(){
  16. $userId=$this->userId;
  17. $page=input("page/d",1);
  18. $size=input("size/d",10);
  19. $ret=$this->model->lists($userId,$page,$size);
  20. if($ret){
  21. HelpHander::success($ret);
  22. }else{
  23. HelpHander::error('暂无数据');
  24. }
  25. }
  26. //员工学习剩余考试次数
  27. public function paperRecordLimit(){
  28. $userId=$this->userId;
  29. $paperId=input('paperId');
  30. $ret=$this->model->limits($userId,$paperId);
  31. HelpHander::success($ret);
  32. }
  33. //员工学习提交考试答案
  34. public function commit(){
  35. $userId=$this->userId;
  36. $orgId=$this->orgId;
  37. $paperId=input('paperId');
  38. $json=input('json');
  39. if(!$json){
  40. HelpHander::error('参数错误');
  41. }
  42. $jsonArray=json_decode($json,true);
  43. $ret=$this->model->saveData($userId,$orgId,$paperId,$jsonArray);
  44. if($ret){
  45. HelpHander::success([],'添加成功');
  46. }else{
  47. HelpHander::error($this->model->getError());
  48. }
  49. }
  50. }