From 8c1fbfd00a845fb8071bd6f84ac4e84a5bfc61c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Wed, 31 Oct 2018 16:57:15 +0800 Subject: [PATCH] =?UTF-8?q?Time=E6=89=A9=E5=B1=95=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=95=99=E5=8A=A1=E7=AE=A1=E7=90=86=E8=A1=A8=E7=BC=96=E5=86=99?= =?UTF-8?q?=E6=95=99=E5=8A=A1=E7=AE=A1=E7=90=86=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=A7=92=E8=89=B2=E6=B7=BB=E5=8A=A0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Index.php | 49 +-- application/admin/model/Admin.php | 45 +++ application/admin/validate/Admin.php | 2 +- application/admin/view/index/create.html | 18 +- application/admin/view/index/edit.html | 18 +- application/admin/view/index/index.html | 2 + application/common.php | 4 +- application/system/view/school/create.html | 6 +- application/system/view/school/edit.html | 6 +- application/teach/common.php | 31 ++ application/teach/controller/Index.php | 1 - application/teach/controller/Kaoshi.php | 314 +++++++++++++++--- application/teach/controller/Subject.php | 233 +++++++++++++ application/teach/model/Kaoshi.php | 100 +++++- application/teach/model/KaoshiNianji.php | 10 + application/teach/model/KaoshiSubject.php | 10 + application/teach/model/Subject.php | 16 + application/teach/validate/Kaoshi.php | 10 +- application/teach/validate/Subject.php | 29 ++ application/teach/view/index/create.html | 6 +- application/teach/view/index/edit.html | 6 +- application/teach/view/kaoshi/create.html | 115 ++++--- application/teach/view/kaoshi/edit.html | 119 ++++--- application/teach/view/kaoshi/index.html | 36 +- application/teach/view/subject/create.html | 64 ++++ application/teach/view/subject/edit.html | 64 ++++ application/teach/view/subject/index.html | 124 +++++++ application/teach/view/xueqi/create.html | 6 +- application/teach/view/xueqi/edit.html | 6 +- composer.json | 3 +- composer.lock | 44 ++- .../migrations/20181028023517_teacher.php | 6 +- database/migrations/20181028024920_xueqi.php | 4 +- database/migrations/20181028025648_kaoshi.php | 5 +- .../migrations/20181030024954_subject.php | 47 +++ .../20181030072708_kaoshi_nianji.php | 42 +++ .../20181030072733_kaoshi_subject.php | 41 +++ database/seeds/Category.php | 128 ++++--- database/seeds/Rule.php | 8 + database/seeds/Subject.php | 43 +++ route/teach.php | 1 + vendor/composer/autoload_files.php | 1 + vendor/composer/autoload_psr4.php | 1 + vendor/composer/autoload_static.php | 6 + vendor/composer/installed.json | 44 +++ vendor/topthink/think-helper/.gitignore | 2 + vendor/topthink/think-helper/LICENSE | 201 +++++++++++ vendor/topthink/think-helper/README.md | 92 +++++ vendor/topthink/think-helper/composer.json | 19 ++ vendor/topthink/think-helper/src/Arr.php | 41 +++ vendor/topthink/think-helper/src/Hash.php | 48 +++ vendor/topthink/think-helper/src/Str.php | 202 +++++++++++ vendor/topthink/think-helper/src/Time.php | 198 +++++++++++ .../topthink/think-helper/src/hash/Bcrypt.php | 51 +++ vendor/topthink/think-helper/src/hash/Md5.php | 42 +++ vendor/topthink/think-helper/src/helper.php | 93 ++++++ 56 files changed, 2564 insertions(+), 299 deletions(-) create mode 100644 application/teach/controller/Subject.php create mode 100644 application/teach/model/KaoshiNianji.php create mode 100644 application/teach/model/KaoshiSubject.php create mode 100644 application/teach/model/Subject.php create mode 100644 application/teach/validate/Subject.php create mode 100644 application/teach/view/subject/create.html create mode 100644 application/teach/view/subject/edit.html create mode 100644 application/teach/view/subject/index.html create mode 100644 database/migrations/20181030024954_subject.php create mode 100644 database/migrations/20181030072708_kaoshi_nianji.php create mode 100644 database/migrations/20181030072733_kaoshi_subject.php create mode 100644 database/seeds/Subject.php create mode 100644 vendor/topthink/think-helper/.gitignore create mode 100644 vendor/topthink/think-helper/LICENSE create mode 100644 vendor/topthink/think-helper/README.md create mode 100644 vendor/topthink/think-helper/composer.json create mode 100644 vendor/topthink/think-helper/src/Arr.php create mode 100644 vendor/topthink/think-helper/src/Hash.php create mode 100644 vendor/topthink/think-helper/src/Str.php create mode 100644 vendor/topthink/think-helper/src/Time.php create mode 100644 vendor/topthink/think-helper/src/hash/Bcrypt.php create mode 100644 vendor/topthink/think-helper/src/hash/Md5.php create mode 100644 vendor/topthink/think-helper/src/helper.php diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 7c488e5d..b1c2c653 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -6,8 +6,6 @@ namespace app\admin\controller; use app\common\controller\Base; // 引用用户数据模型 use app\admin\model\Admin as AD; -// 引用用户与组关联数据表模型 -use app\admin\model\AuthGroupAccess as AGA; // 引用加密类 use WhiteHat101\Crypt\APR1_MD5; @@ -65,7 +63,7 @@ class Index extends Base // 如果需要查询 if($search){ $data = AD::field('id,xingming,sex,username,phone,shengri,denglucishu,status,create_time') - ->where('id','>','1') + ->where('id','>','1') ->order([$order_field=>$order]) ->limit($limit_start,$limit_length) ->where('username|xingming','like','%'.$search.'%') @@ -73,6 +71,9 @@ class Index extends Base } $datacnt = $data->count(); + + // 追加角色名 + $data = $data->append(['groupnames']); @@ -116,6 +117,7 @@ class Index extends Base // 获取表单数据 $list = request()->only(['xingming','username','sex','shengri','phone','beizhu','group_id'],'post'); + // 设置密码,默认为123456 $list['password'] = $md5->hash('123456'); @@ -124,25 +126,23 @@ class Index extends Base $result = $validate->check($list); $msg = $validate->getError(); - unset($list['group_id']); - - // 如果验证不通过则停止保存 if(!$result){ return json(['msg'=>$msg,'val'=>0]);; } - // 保存数据 - $data = AD::create($list); - - $group_id = request()->post('group_id'); - - $data = AGA::create(['uid'=>$data->id,'group_id'=>$group_id]); - + // 实例化管理员数据模型类 + $admin = new AD(); + $admindata = $admin->create($list); + // 重组用户角色列表 + foreach ($list['group_id'] as $key => $value) { + $groupids[]=['group_id'=>$value]; + } + $authgroupdata = $admindata->authgroup()->saveAll($groupids); // 根据更新结果设置返回提示信息 - $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + $authgroupdata ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; // 返回信息 return json($data); @@ -176,7 +176,8 @@ class Index extends Base // 获取用户信息 $list = AD::field('id,username,xingming,sex,shengri,phone,beizhu') ->get($id); - $list->group_id = AGA::where('uid',$id)->value('group_id'); + // 追加用户id字符串 + $list = $list->append(['groupids']); $this->assign('list',$list); @@ -198,7 +199,6 @@ class Index extends Base // 验证表单数据 $result = $validate->check($list); $msg = $validate->getError(); - unset($list['group_id']); // 如果验证不通过则停止保存 if(!$result){ @@ -206,15 +206,20 @@ class Index extends Base } // 更新管理员信息 - $admin = new AD(); - $data = $admin->save($list,['id'=>$id]); + $list['id'] = $id; + $admindata = AD::update($list); + + // 删除原来角色 + $aa = $admindata->authgroup()->delete();dump($aa); - // 更新管理员角色 - $group_id = request()->put('group_id'); - $data = AGA::where('uid',$id)->update(['group_id'=>$group_id]); + // 重组用户角色列表 + foreach ($list['group_id'] as $key => $value) { + $groupids[]=['group_id'=>$value]; + } + $groupdata = $admindata->authgroup()->create($groupids); // 根据更新结果设置返回提示信息 - $data >= 0 ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + $admindata&&$groupdata ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; // 返回信息 return json($data); diff --git a/application/admin/model/Admin.php b/application/admin/model/Admin.php index 4119b814..16d82d7d 100644 --- a/application/admin/model/Admin.php +++ b/application/admin/model/Admin.php @@ -45,5 +45,50 @@ class Admin extends Base } + // 权限关联 + public function authgroup() + { + return $this->hasMany('AuthGroupAccess','uid','id')->field('id,uid,group_id'); + } + + + // 获取角色id表 + public function getGroupidsAttr() + { + // 获取当前当前管理员信息 + $admin = $this->get($this->getAttr('id')); + // 获取角色id + $list = $admin->authgroup()->column('group_id'); + + // 将角色id转换成数组 + foreach ($list as $key => $value) { + $key == 0 ? $str =$value : $str = $str.','.$value; + } + + // 返回值 + return $str; + } + + // 获取角色名称 + public function getGroupnamesAttr() + { + // 获取角色id + $group = $this->get($this->getAttr('id'))->append(['groupids']); + + // 查询角色名称 + $grouplist= db('AuthGroup')->where('id','in',$group->groupids)->column('title'); + // 重组角色名 + foreach ($grouplist as $key => $value) { + if($key == 0){ + $str = $value; + }else{ + $str = $str.'、'.$value; + } + } + // 返回角色名 + return $str; + } + + } diff --git a/application/admin/validate/Admin.php b/application/admin/validate/Admin.php index 0d303c7b..d18987eb 100644 --- a/application/admin/validate/Admin.php +++ b/application/admin/validate/Admin.php @@ -15,7 +15,7 @@ class Admin extends Validate protected $rule = [ 'xingming|用户姓名' => 'require|chs|length:2,6', 'username|帐号' => ['require','uset'=>'/^[a-z][a-z0-9-_]*$/'], - 'group_id|角色' => 'require|number', + 'group_id|角色' => 'require|array', 'shengri|出生日期' => 'date', 'xingbie|性别' => 'in:0,1,2', 'phone|手机' => 'mobile', diff --git a/application/admin/view/index/create.html b/application/admin/view/index/create.html index 2e38b6d4..4fc7eaec 100644 --- a/application/admin/view/index/create.html +++ b/application/admin/view/index/create.html @@ -15,16 +15,16 @@
-
- {php} + {php} $group = db('auth_group')->where('status',true)->field('id,title')->all(); - {/php} - {volist name="group" id="vo" key="k"} -
- - -
- {/volist} + {/php} +
+
{foreach $group as $key=>$vo } + {/foreach} +
diff --git a/application/admin/view/index/edit.html b/application/admin/view/index/edit.html index 3e081dae..b7889d26 100644 --- a/application/admin/view/index/edit.html +++ b/application/admin/view/index/edit.html @@ -15,16 +15,16 @@
-
- {php} + {php} $group = db('auth_group')->where('status',true)->field('id,title')->all(); - {/php} - {volist name="group" id="vo" key="k"} -
- - -
- {/volist} + {/php} +
+
{foreach $group as $key=>$vo } + {/foreach} +
diff --git a/application/admin/view/index/index.html b/application/admin/view/index/index.html index aabd97cf..1761869f 100644 --- a/application/admin/view/index/index.html +++ b/application/admin/view/index/index.html @@ -41,6 +41,7 @@ 出生日期 帐号 手机号码 + 角色 登录次数 创建时间 状态 @@ -71,6 +72,7 @@ { "data": "shengri" }, { "data": "username" }, { "data": "phone" }, + { "data": "groupnames" }, { "data": "denglucishu" }, { "data": "create_time" }, { "data": "status" }, diff --git a/application/common.php b/application/common.php index 266a749d..1d8fedfc 100644 --- a/application/common.php +++ b/application/common.php @@ -12,11 +12,11 @@ // 应用公共文件 // 获取类别列表 -function getCategory($id = 0) +function getCategory($id = '0') { // 根据父级id查询类别列表 $list = db('category') - ->where('pid',$id) + ->where('pid','in',$id) ->where('status',1) ->field('id,title') ->select(); diff --git a/application/system/view/school/create.html b/application/system/view/school/create.html index f7d4fd07..4d1b8e83 100644 --- a/application/system/view/school/create.html +++ b/application/system/view/school/create.html @@ -24,7 +24,7 @@
- {php}$category = getCategory(1);{/php} + {php}$category = getCategory(101);{/php} {volist name="category" id="vo"} @@ -52,7 +52,7 @@
- {php} $catetory = getCategory(3);{/php} + {php} $catetory = getCategory(301);{/php} {volist name="category" id="vo"} @@ -38,7 +38,7 @@
- {php} $category = getCategory(2);{/php} + {php} $category = getCategory(201);{/php} {volist name="catetory" id="vo"} diff --git a/application/teach/common.php b/application/teach/common.php index b3d9bbc7..84b1f8a7 100644 --- a/application/teach/common.php +++ b/application/teach/common.php @@ -1 +1,32 @@ today(); + + if($thisday[0]<=$jiedian) + { + $str = 1; + }else{ + $str = 0; + } + + $nian = date('Y') - $str; + + $njlist = array(); + + $njlist[$nian]='一年级'; + $njlist[$nian-1]='二年级'; + $njlist[$nian-2]='三年级'; + $njlist[$nian-3]='四年级'; + $njlist[$nian-4]='五年级'; + $njlist[$nian-5]='六年级'; + + return $njlist; +} diff --git a/application/teach/controller/Index.php b/application/teach/controller/Index.php index c5129043..186c0190 100644 --- a/application/teach/controller/Index.php +++ b/application/teach/controller/Index.php @@ -18,7 +18,6 @@ class Index extends Base // 设置页面标题 $list['title'] = '教师列表'; - // 模板赋值 $this->assign('list', $list); diff --git a/application/teach/controller/Kaoshi.php b/application/teach/controller/Kaoshi.php index f0be578c..15f5797a 100644 --- a/application/teach/controller/Kaoshi.php +++ b/application/teach/controller/Kaoshi.php @@ -2,84 +2,294 @@ namespace app\teach\controller; -use think\Controller; -use think\Request; +// 引用控制器基类 +use app\common\controller\Base; +// 引用学期数据模型类 +use app\teach\model\Kaoshi as KS; -class Kaoshi extends Controller +class Kaoshi extends Base { - /** - * 显示资源列表 - * - * @return \think\Response - */ + // 显示学期列表 public function index() { - // + + // 设置数据总数 + $list['count'] = KS::count(); + // 设置页面标题 + $list['title'] = '考试列表'; + + // 模板赋值 + $this->assign('list', $list); + + // 渲染模板 + return $this->fetch(); } - /** - * 显示创建资源表单页. - * - * @return \think\Response - */ + + // 获取学期信息列表 + public function ajaxData() + { + + // 获取DT的传值 + $getdt = request()->param(); + + //得到排序的方式 + $order = $getdt['order'][0]['dir']; + //得到排序字段的下标 + $order_column = $getdt['order'][0]['column']; + //根据排序字段的下标得到排序字段 + $order_field = $getdt['columns'][$order_column]['data']; + //得到limit参数 + $limit_start = $getdt['start']; + $limit_length = $getdt['length']; + //得到搜索的关键词 + $search = $getdt['search']['value']; + + + // 获取记录集总数 + $cnt = KS::count(); + //查询数据 + $data =KS::field('id,title,xueqi,category,bfdate,enddate,status') + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->all(); + + + // 如果需要查询 + if($search){ + $data = KS::field('id,title,xueqi,category,bfdate,enddate,status') + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->where('title','like','%'.$search.'%') + ->where('category','in',function($query) use($search) + { + $query->table('catagory') + ->where('title','like','%'.$search.'%') + ->field('id'); + }) + ->all(); + } + + $data = $data->append(['nianjinames','subjectnames']); + + $datacnt = $data->count(); + + + $data = [ + 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 + 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) + 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'data'=>$data, // 获取到的数据结果 + ]; + + + return json($data); + } + + + + // 创建学期 public function create() { - // + // 设置页面标题 + $list['title'] = '添加学期'; + + // 模板赋值 + $this->assign('list',$list); + + // 渲染 + return $this->fetch(); } - /** - * 保存新建的资源 - * - * @param \think\Request $request - * @return \think\Response - */ - public function save(Request $request) + + + // 保存信息 + public function save() { - // + // 实例化验证模型 + $validate = new \app\teach\validate\Kaoshi; + + + // 获取表单数据 + $list = request()->only(['title','xueqi','category','bfdate','enddate','nianji','subject'],'post'); + + + // 验证表单数据 + $result = $validate->check($list); + $msg = $validate->getError(); + + + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg'=>$msg,'val'=>0]); + } + + + // 保存数据 + $ks = new KS(); + + $ksdata = $ks->create($list); + + + + // 获取年级列表 + $njname = nianjilist(); + // 重组参加考试年级信息 + foreach ($list['nianji'] as $key => $value) { + $nianjiarr[]=['nianji'=>$value,'nianjiname'=>$njname[$value]]; + } + + // 添加考试年级信息 + $njdata = $ksdata->kaoshinianji()->saveAll($nianjiarr); + + + + // 重组参加考试学科信息 + foreach ($list['subject'] as $key => $value) { + $subjectarr[]=['subjectid'=>$value]; + } + // 添加考试学科信息 + $xkdata = $ksdata->kaoshisubject()->saveAll($subjectarr); + + // 根据更新结果设置返回提示信息 + $ksdata&&$njdata&&$xkdata ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); } - /** - * 显示指定的资源 - * - * @param int $id - * @return \think\Response - */ + // public function read($id) { // } - /** - * 显示编辑资源表单页. - * - * @param int $id - * @return \think\Response - */ + + + + // 修改学期信息 public function edit($id) { - // + + // 获取学期信息 + $list = KS::where('id',$id) + ->field('id,title,xueqi,category,bfdate,enddate') + // ->with('kaoshinianji,kaoshisubject') + ->find(); + + $list = $list->append(['nianjiids','subjectids']); + + // 模板赋值 + $this->assign('list',$list); + + //渲染模板 + return $this->fetch(); + } - /** - * 保存更新的资源 - * - * @param \think\Request $request - * @param int $id - * @return \think\Response - */ - public function update(Request $request, $id) + + + + + // 更新学期信息 + public function update($id) { - // + $validate = new \app\teach\validate\Kaoshi; + + // 获取表单数据 + $list = request()->only(['title','xueqi','category','bfdate','enddate','nianji','subject'],'post'); + + // 验证表单数据 + $result = $validate->check($list); + $msg = $validate->getError(); + + + + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg'=>$msg,'val'=>0]);; + } + + $list['id'] = $id; + // 更新数据 + $ks = new KS(); + $ksdata = $ks::update($list); + + + // 删除参加考试的年级和学科 + $ksdata->kaoshinianji()->delete(); + $ksdata->kaoshisubject()->delete(); + + + // 添加考试年级和学科 + // 获取年级列表 + $njname = nianjilist(); + // 重组参加考试年级信息 + foreach ($list['nianji'] as $key => $value) { + $nianjiarr[]=['nianji'=>$value,'nianjiname'=>$njname[$value]]; + } + + // 添加考试年级信息 + $njdata = $ksdata->kaoshinianji()->saveAll($nianjiarr); + + + + + // 重组参加考试学科信息 + foreach ($list['subject'] as $key => $value) { + $subjectarr[]=['subjectid'=>$value]; + } + // 添加考试学科信息 + $xkdata = $ksdata->kaoshisubject()->saveAll($subjectarr); + + + + // 根据更新结果设置返回提示信息 + $ksdata&&$njdata&&$xkdata ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); } - /** - * 删除指定资源 - * - * @param int $id - * @return \think\Response - */ + + + + + // 删除学期 public function delete($id) { - // + + if($id == 'm') + { + $id = request()->delete('ids/a');// 获取delete请求方式传送过来的数据并转换成数据 + } + + $data = KS::destroy($id); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + } + + + + // 设置学期状态 + public function setStatus() + { + + // 获取id变量 + $id = request()->post('id'); + $value = request()->post('value'); + + // 获取学期信息 + $data = KS::where('id',$id)->update(['status'=>$value]); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); } } diff --git a/application/teach/controller/Subject.php b/application/teach/controller/Subject.php new file mode 100644 index 00000000..b1a53f18 --- /dev/null +++ b/application/teach/controller/Subject.php @@ -0,0 +1,233 @@ +assign('list', $list); + + // 渲染模板 + return $this->fetch(); + } + + + // 获取学期信息列表 + public function ajaxData() + { + + // 获取DT的传值 + $getdt = request()->param(); + + //得到排序的方式 + $order = $getdt['order'][0]['dir']; + //得到排序字段的下标 + $order_column = $getdt['order'][0]['column']; + //根据排序字段的下标得到排序字段 + $order_field = $getdt['columns'][$order_column]['data']; + //得到limit参数 + $limit_start = $getdt['start']; + $limit_length = $getdt['length']; + //得到搜索的关键词 + $search = $getdt['search']['value']; + + + // 获取记录集总数 + $cnt = SJ::count(); + //查询数据 + $data =SJ::field('id,title,jiancheng,category,paixu,status') + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->all(); + + + // 如果需要查询 + if($search){ + $data = SJ::field('id,title,jiancheng,category,paixu,status') + ->order([$order_field=>$order]) + ->limit($limit_start,$limit_length) + ->where('title','like','%'.$search.'%') + ->where('category','in',function($query) use($search) + { + $query->table('catagory') + ->where('title','like','%'.$search.'%') + ->field('id'); + }) + ->all(); + } + + $datacnt = $data->count(); + + + $data = [ + 'draw'=> $getdt["draw"] , // ajax请求次数,作为标识符 + 'recordsTotal'=>$datacnt, // 获取到的结果数(每页显示数量) + 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'data'=>$data, // 获取到的数据结果 + ]; + + + return json($data); + } + + + + // 创建学期 + public function create() + { + // 设置页面标题 + $list['title'] = '添加学科'; + + // 模板赋值 + $this->assign('list',$list); + + // 渲染 + return $this->fetch(); + } + + + + // 保存信息 + public function save() + { + // 实例化验证模型 + $validate = new \app\teach\validate\Subject; + + + // 获取表单数据 + $list = request()->only(['title','jiancheng','category','paixu'],'post'); + + + // 验证表单数据 + $result = $validate->check($list); + $msg = $validate->getError(); + + + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg'=>$msg,'val'=>0]); + } + + // 保存数据 + $data = SJ::create($list); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'添加成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + } + + // + public function read($id) + { + // + } + + + + + // 修改学期信息 + public function edit($id) + { + + // 获取学期信息 + $list = SJ::field('id,title,jiancheng,category,paixu,status') + ->get($id); + + + $this->assign('list',$list); + + return $this->fetch(); + } + + + + + + // 更新学期信息 + public function update($id) + { + $validate = new \app\teach\validate\Subject; + + // 获取表单数据 + $list = request()->only(['title','jiancheng','category','paixu'],'put'); + + // 验证表单数据 + $result = $validate->check($list); + $msg = $validate->getError(); + + // 如果验证不通过则停止保存 + if(!$result){ + return json(['msg'=>$msg,'val'=>0]);; + } + + + // 更新数据 + $data = SJ::where('id',$id)->update($list); + + // 根据更新结果设置返回提示信息 + $data>=0 ? $data=['msg'=>'更新成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + } + + + + + + // 删除学期 + public function delete($id) + { + + if($id == 'm') + { + $id = request()->delete('ids/a');// 获取delete请求方式传送过来的数据并转换成数据 + } + + $data = SJ::destroy($id); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + } + + + + // 设置学期状态 + public function setStatus() + { + + // 获取id变量 + $id = request()->post('id'); + $value = request()->post('value'); + + // 获取学期信息 + $data = SJ::where('id',$id)->update(['status'=>$value]); + + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + // 返回信息 + return json($data); + } + +} diff --git a/application/teach/model/Kaoshi.php b/application/teach/model/Kaoshi.php index 6410bb04..3bf5a0bb 100644 --- a/application/teach/model/Kaoshi.php +++ b/application/teach/model/Kaoshi.php @@ -7,5 +7,103 @@ use app\common\model\Base; class Kaoshi extends Base { - // + // 开始时间修改器 + public function setBfdateAttr($value) + { + return strtotime($value); + } + + // 开始时间获取器 + public function getBfdateAttr($value) + { + return date('Y-m-d',$value); + } + + // 结束时间修改器 + public function setEnddateAttr($value) + { + return strtotime($value); + } + + // 结束时间获取器 + public function getEnddateAttr($value) + { + return date('Y-m-d',$value); + } + + //参考年级关联表 + public function kaoshinianji() + { + return $this->hasMany('KaoshiNianji','kaoshiid','id')->field('id,kaoshiid,nianji,nianjiname'); + } + + // 参考学年关联表 + public function kaoshisubject() + { + return $this->hasMany('KaoshiSubject','kaoshiid','id')->field('kaoshiid,subjectid'); + } + + // 类别获取器 + public function getCategoryAttr($value) + { + return db('category')->where('id',$value)->value('title'); + } + + // 学期获取器 + public function getXueqiAttr($value) + { + return db('xueqi')->where('id',$value)->value('title'); + } + + // 获取参考年级列表并返回nianji字段值 + public function getNianjiidsAttr() + { + $list = $this->get($this->getAttr('id')); + $nianji = $list->kaoshinianji; + + foreach ($nianji as $key => $value) { + $key == 0 ? $str = $value['nianji'] : $str = $str.','.$value['nianji']; + } + return $str; + } + + // 获取参考学科并返回学科id + public function getSubjectidsAttr() + { + $list = $this->get($this->getAttr('id')); + $nianji = $list->kaoshisubject; + + foreach ($nianji as $key => $value) { + $key == 0 ? $str = $value['subjectid'] : $str = $str.','.$value['subjectid']; + } + return $str; + } + + // 获取参考年级,并返回年级名称 + public function getNianjinamesAttr() + { + $list = $this->get($this->getAttr('id')); + $nianji = $list->kaoshinianji; + + foreach ($nianji as $key => $value) { + $key == 0 ? $str = $value['nianjiname'] : $str = $str.'、'.$value['nianjiname']; + } + return $str; + } + + // 获取参考学科,并返回学科简称 + public function getSubjectnamesAttr() + { + $subject = $this->get($this->getAttr('id'))->append(['subjectids']); + + $subject= db('subject')->where('id','in',$subject->subjectids)->column('jiancheng'); + foreach ($subject as $key => $value) { + if($key == 0){ + $str = $value; + }else{ + $str = $str.'、'.$value; + } + } + return $str; + } } diff --git a/application/teach/model/KaoshiNianji.php b/application/teach/model/KaoshiNianji.php new file mode 100644 index 00000000..5776e447 --- /dev/null +++ b/application/teach/model/KaoshiNianji.php @@ -0,0 +1,10 @@ +where('id',$value) + ->value('title'); + } +} diff --git a/application/teach/validate/Kaoshi.php b/application/teach/validate/Kaoshi.php index 73df60dd..6c489c68 100644 --- a/application/teach/validate/Kaoshi.php +++ b/application/teach/validate/Kaoshi.php @@ -12,7 +12,15 @@ class Kaoshi extends Validate * * @var array */ - protected $rule = []; + protected $rule = [ + 'title|标题' => 'require|length:1,25', + 'xueqi|学期' => 'require|number', + 'category|分类' => 'require|number', + 'bfdate|考试时间' => 'require|date', + 'enddate|考试时间' => 'require|date', + 'nianji|参考年级' => 'require|array', + 'subject|参考学科' => 'require|array', + ]; /** * 定义错误信息 diff --git a/application/teach/validate/Subject.php b/application/teach/validate/Subject.php new file mode 100644 index 00000000..d152427d --- /dev/null +++ b/application/teach/validate/Subject.php @@ -0,0 +1,29 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'title|名称' => 'require|length:1,25', + 'jiancheng|简称' => 'require|length:1,6', + 'category|分类' => 'require|number', + 'paixu|排序' => 'number', + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = []; +} diff --git a/application/teach/view/index/create.html b/application/teach/view/index/create.html index 3a192e63..3e800f7c 100644 --- a/application/teach/view/index/create.html +++ b/application/teach/view/index/create.html @@ -55,7 +55,7 @@
- {php}$list = getCategory(7);{/php} + {php}$list = getCategory(701);{/php} {volist name="list" id="vo"} @@ -83,7 +83,7 @@
- {php}$list = getCategory(5);{/php} + {php}$list = getCategory(501);{/php} {volist name="category" id="vo"} @@ -69,7 +69,7 @@
- {php}$category = getCategory(6);{/php} + {php}$category = getCategory(601);{/php} {volist name="category" id="vo"} diff --git a/application/teach/view/kaoshi/create.html b/application/teach/view/kaoshi/create.html index 2d37d9af..aa0e81c0 100644 --- a/application/teach/view/kaoshi/create.html +++ b/application/teach/view/kaoshi/create.html @@ -1,65 +1,75 @@ {extend name="common@create" /} {block name="formaa"} -
+
- +
- +
- -
- -
-
-
- +
- {php} $authrulemod = new app\admin\model\AuthRule; $pid = $authrulemod->getRule();{/php} - + + {volist name="xueqi" id="vo"} - {php} $child = $authrulemod->getRule($vo['id']);{/php} - {volist name="child" id="va"} - - {/volist} {/volist}
- -
- + +
+ + {php}$list = getCategory(901);{/php} + +
- +
- + + ~ +
- -
-
- - -
-
- - -
+ +
+
{foreach $njlist=nianjilist() as $key=>$vo } + {/foreach} +
- + {php} + $subject = new \app\teach\model\Subject; + $sjlist = $subject->where('status',1)->where('id','<=',3)->field('id,title')->order(['paixu'])->select(); + {/php} +
- +
{foreach $sjlist as $key=>$vo } + {/foreach} +
@@ -71,33 +81,34 @@ {/block} {block name="yanzheng"} +{/block} \ No newline at end of file diff --git a/application/teach/view/subject/edit.html b/application/teach/view/subject/edit.html new file mode 100644 index 00000000..5e0b8562 --- /dev/null +++ b/application/teach/view/subject/edit.html @@ -0,0 +1,64 @@ +{extend name="common@create" /} +{block name="formaa"} + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + {php}$category = getCategory(1001);{/php} + + +
+
+
+ +
+ +
+
+
+
+ +
+
+ +{/block} +{block name="yanzheng"} + +{/block} \ No newline at end of file diff --git a/application/teach/view/subject/index.html b/application/teach/view/subject/index.html new file mode 100644 index 00000000..f09b06a8 --- /dev/null +++ b/application/teach/view/subject/index.html @@ -0,0 +1,124 @@ +{extend name="common@list" /} +{block name="topnav"} + +{/block} +{block name="bouttons"} +
+ + + + + 批量删除 + + + + + 添加学科 + + + + 共有数据:{$list.count} 条 + +
+{/block} +{block name="tables"} + + + + + + + + + + + + + + +
标题简称分类排序状态操作
+ + +{/block} +{block name="myjs"} + +{/block} \ No newline at end of file diff --git a/application/teach/view/xueqi/create.html b/application/teach/view/xueqi/create.html index cc2c6153..3ee09a8a 100644 --- a/application/teach/view/xueqi/create.html +++ b/application/teach/view/xueqi/create.html @@ -17,7 +17,7 @@
- {php}$list = getCategory(8);{/php} + {php}$list = getCategory(801);{/php} {volist name="category" id="vo"} @@ -54,6 +54,10 @@ required:true, rangelength:[1,15] }, + category:{ + required:true, + digits:true + }, bfdate:{ required:true, dateISO:true diff --git a/composer.json b/composer.json index 618df8ec..074d83c7 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "topthink/think-migration": "^2.0", "php4world/auth": "^1.0", "topthink/think-captcha": "^2.0", - "whitehat101/apr1-md5": "^1.0" + "whitehat101/apr1-md5": "^1.0", + "topthink/think-helper": "^1.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 003d06fc..42b64929 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "07150719627d3a1c8f9538fe65750f56", + "content-hash": "d2caa71f351a54a74ac773af02033871", "packages": [ { "name": "php4world/auth", @@ -150,6 +150,48 @@ "description": "captcha package for thinkphp5", "time": "2017-12-31T16:37:49+00:00" }, + { + "name": "topthink/think-helper", + "version": "v1.0.6", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-helper.git", + "reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f", + "reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f", + "shasum": "", + "mirrors": [ + { + "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "type": "library", + "autoload": { + "psr-4": { + "think\\helper\\": "src" + }, + "files": [ + "src/helper.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP5 Helper Package", + "time": "2017-04-05T07:15:37+00:00" + }, { "name": "topthink/think-installer", "version": "v2.0.0", diff --git a/database/migrations/20181028023517_teacher.php b/database/migrations/20181028023517_teacher.php index d4a9200f..b687d17f 100644 --- a/database/migrations/20181028023517_teacher.php +++ b/database/migrations/20181028023517_teacher.php @@ -34,9 +34,9 @@ class Teacher extends Migrator // 添加当前表字段 $table ->addColumn('xingming','string',['limit'=>8,'null'=>false,'comment'=>'姓名']) - ->addColumn('sex','boolean',['limit'=>1,'default'=>2,'null'=>false,'comment'=>'性别']) - ->addColumn('shengri','string',['limit'=>11,'null'=>true,'comment'=>'生日']) - ->addColumn('worktime','string',['limit'=>11,'null'=>true,'comment'=>'工作时间']) + ->addColumn('sex','boolean',['limit'=>1,'default'=>1,'null'=>false,'comment'=>'性别']) + ->addColumn('shengri','integer',['limit'=>11,'null'=>true,'comment'=>'生日']) + ->addColumn('worktime','integer',['limit'=>11,'null'=>true,'comment'=>'工作时间']) ->addColumn('zhiwu','string',['limit'=>11,'null'=>true,'comment'=>'职务']) ->addColumn('zhicheng','string',['limit'=>11,'null'=>true,'comment'=>'职称']) ->addColumn('danwei','string',['limit'=>11,'null'=>false,'comment'=>'现工作单位']) diff --git a/database/migrations/20181028024920_xueqi.php b/database/migrations/20181028024920_xueqi.php index ebb21ada..a8183c35 100644 --- a/database/migrations/20181028024920_xueqi.php +++ b/database/migrations/20181028024920_xueqi.php @@ -36,8 +36,8 @@ class Xueqi extends Migrator ->addColumn('title','string',['limit'=>25,'null'=>false,'comment'=>'学期标题']) ->addColumn('xuenian','string',['limit'=>15,'null'=>false,'comment'=>'学年标题']) ->addColumn('category','string',['limit'=>11,'null'=>false,'comment'=>'学期分类']) - ->addColumn('bfdate','string',['limit'=>11,'null'=>false,'comment'=>'开始日期']) - ->addColumn('enddate','string',['limit'=>11,'null'=>false,'comment'=>'结束日期']) + ->addColumn('bfdate','integer',['limit'=>11,'null'=>false,'comment'=>'开始日期']) + ->addColumn('enddate','integer',['limit'=>11,'null'=>false,'comment'=>'结束日期']) ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'null'=>true,'comment'=>'更新时间']) diff --git a/database/migrations/20181028025648_kaoshi.php b/database/migrations/20181028025648_kaoshi.php index 58d2577f..4ec73941 100644 --- a/database/migrations/20181028025648_kaoshi.php +++ b/database/migrations/20181028025648_kaoshi.php @@ -35,8 +35,9 @@ class Kaoshi extends Migrator $table ->addColumn('title','string',['limit'=>25,'null'=>false,'comment'=>'考试名称']) ->addColumn('xueqi','string',['limit'=>11,'null'=>false,'comment'=>'学期']) - ->addColumn('bfdate','string',['limit'=>11,'null'=>false,'comment'=>'开始日期']) - ->addColumn('endate','string',['limit'=>11,'null'=>false,'comment'=>'结束日期']) + ->addColumn('category','string',['limit'=>11,'null'=>false,'comment'=>'类别']) + ->addColumn('bfdate','integer',['limit'=>11,'null'=>false,'comment'=>'开始日期']) + ->addColumn('enddate','integer',['limit'=>11,'default'=>0,'null'=>false,'comment'=>'结束日期']) ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间']) ->addColumn('update_time','integer',['limit'=>11,'null'=>true,'comment'=>'更新时间']) diff --git a/database/migrations/20181030024954_subject.php b/database/migrations/20181030024954_subject.php new file mode 100644 index 00000000..8181de15 --- /dev/null +++ b/database/migrations/20181030024954_subject.php @@ -0,0 +1,47 @@ +table('subject'); + + // 添加当前表字段 + $table + ->addColumn('title','string',['limit'=>25,'null'=>false,'comment'=>'学科名称']) + ->addColumn('jiancheng','string',['limit'=>6,'null'=>false,'comment'=>'简称']) + ->addColumn('category','string',['limit'=>11,'null'=>false,'comment'=>'大学科类别']) + ->addColumn('paixu','integer',['limit'=>4,'default'=>'999','null'=>false,'comment'=>'排序']) + ->addColumn('status','boolean',['limit'=>1,'default'=>'1','null'=>false,'comment'=>'0=禁用,1=正常']) + ->addColumn('create_time','integer',['limit'=>11,'null'=>true,'comment'=>'创建时间']) + ->addColumn('update_time','integer',['limit'=>11,'null'=>true,'comment'=>'更新时间']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->addColumn('beizhu','string',['limit'=>80,'null'=>true,'comment'=>'备注']) + ->create(); + } +} diff --git a/database/migrations/20181030072708_kaoshi_nianji.php b/database/migrations/20181030072708_kaoshi_nianji.php new file mode 100644 index 00000000..95bcfc37 --- /dev/null +++ b/database/migrations/20181030072708_kaoshi_nianji.php @@ -0,0 +1,42 @@ +table('kaoshi_nianji'); + + // 添加当前表字段 + $table + ->addColumn('kaoshiid','integer',['limit'=>11,'null'=>false,'comment'=>'考试id']) + ->addColumn('nianji','integer',['limit'=>80,'null'=>false,'comment'=>'年级']) + ->addColumn('nianjiname','string',['limit'=>10,'null'=>false,'comment'=>'年级名']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->create(); + } +} diff --git a/database/migrations/20181030072733_kaoshi_subject.php b/database/migrations/20181030072733_kaoshi_subject.php new file mode 100644 index 00000000..2e787656 --- /dev/null +++ b/database/migrations/20181030072733_kaoshi_subject.php @@ -0,0 +1,41 @@ +table('kaoshi_subject'); + + // 添加当前表字段 + $table + ->addColumn('kaoshiid','integer',['limit'=>11,'null'=>false,'comment'=>'考试id']) + ->addColumn('subjectid','integer',['limit'=>170,'null'=>false,'comment'=>'年级']) + ->addColumn('delete_time','integer',['limit'=>11,'null'=>true,'comment'=>'删除时间']) + ->create(); + } +} diff --git a/database/seeds/Category.php b/database/seeds/Category.php index 96d3d1cb..bdf6e153 100644 --- a/database/seeds/Category.php +++ b/database/seeds/Category.php @@ -17,69 +17,89 @@ class Category extends Seeder // 初始化类别 $rows= [ // 一级类别 - ['id'=>1,'title'=>'单位性质','pid'=>0,'paixu' =>1], - ['id'=>2,'title'=>'单位级别','pid'=>0,'paixu' =>2], - ['id'=>3,'title'=>'大学段','pid'=>0,'paixu' =>3], - ['id'=>4,'title'=>'小学段','pid'=>0,'paixu' =>4], - ['id'=>5,'title'=>'学历','pid'=>0,'paixu'=>5], - ['id'=>6,'title'=>'职称','pid'=>0,'paixu'=>6], - ['id'=>7,'title'=>'职务','pid'=>0,'paixu'=>7], - ['id'=>8,'title'=>'学期','pid'=>0,'paixu'=>8], + ['id'=>101,'title'=>'单位性质','pid'=>0,'paixu' =>1], + ['id'=>201,'title'=>'单位级别','pid'=>0,'paixu' =>2], + ['id'=>301,'title'=>'大学段','pid'=>0,'paixu' =>3], + ['id'=>401,'title'=>'小学段','pid'=>0,'paixu' =>4], + ['id'=>501,'title'=>'学历','pid'=>0,'paixu'=>5], + ['id'=>601,'title'=>'职称','pid'=>0,'paixu'=>6], + ['id'=>701,'title'=>'职务','pid'=>0,'paixu'=>7], + ['id'=>801,'title'=>'学期','pid'=>0,'paixu'=>8], + ['id'=>901,'title'=>'考试','pid'=>0,'paixu'=>9], + ['id'=>1001,'title'=>'学科','pid'=>0,'paixu'=>10], + + // 二级类别 + // 大学科 + ['id'=>2011,'title'=>'语文','pid'=>1001,'paixu'=>1], + ['id'=>2012,'title'=>'数学','pid'=>1001,'paixu'=>2], + ['id'=>2013,'title'=>'外语','pid'=>1001,'paixu'=>3], + ['id'=>2014,'title'=>'品德','pid'=>1001,'paixu'=>4], + ['id'=>2015,'title'=>'历史与社会','pid'=>1001,'paixu'=>5], + ['id'=>2016,'title'=>'科学','pid'=>1001,'paixu'=>6], + ['id'=>2017,'title'=>'体育与健康','pid'=>1001,'paixu'=>7], + ['id'=>2018,'title'=>'艺术','pid'=>1001,'paixu'=>8], + ['id'=>2019,'title'=>'综合实践活动','pid'=>1001,'paixu'=>9], + ['id'=>2020,'title'=>'地方校本课程','pid'=>1001,'paixu'=>10], + ['id'=>2021,'title'=>'其它','pid'=>1001,'paixu'=>11], - // 二级类别 // 单位性质 - ['title'=>'幼儿园','pid'=>1,'paixu'=>1], - ['title'=>'小学','pid'=>1,'paixu'=>2], - ['title'=>'九年一贯','pid'=>1,'paixu'=>3], - ['title'=>'初中','pid'=>1,'paixu'=>4], - ['title'=>'高中','pid'=>1,'paixu'=>5], - ['title'=>'中等职业技术学校','pid'=>1,'paixu'=>6], - ['title'=>'科研机构(教师进修学校)','pid'=>1,'paixu'=>7], - ['title'=>'教育行政部门','pid'=>1,'paixu'=>8], - ['title'=>'其他教育机构','pid'=>1,'paixu'=>9], + ['id'=>10000,'title'=>'幼儿园','pid'=>101,'paixu'=>1], + ['title'=>'小学','pid'=>101,'paixu'=>2], + ['title'=>'九年一贯','pid'=>101,'paixu'=>3], + ['title'=>'初中','pid'=>101,'paixu'=>4], + ['title'=>'高中','pid'=>101,'paixu'=>5], + ['title'=>'中等职业技术学校','pid'=>101,'paixu'=>6], + ['title'=>'科研机构(教师进修学校)','pid'=>101,'paixu'=>7], + ['title'=>'教育行政部门','pid'=>101,'paixu'=>8], + ['title'=>'其他教育机构','pid'=>101,'paixu'=>9], // 单位级别 - ['title'=>'校级','pid'=>2,'paixu'=>1], - ['title'=>'区级','pid'=>2,'paixu'=>2], - ['title'=>'市级','pid'=>2,'paixu'=>3], - ['title'=>'省级','pid'=>2,'paixu'=>4], - ['title'=>'部级','pid'=>2,'paixu'=>5], - ['title'=>'其它级','pid'=>2,'paixu'=>6], + ['title'=>'校级','pid'=>201,'paixu'=>1], + ['title'=>'区级','pid'=>201,'paixu'=>2], + ['title'=>'市级','pid'=>201,'paixu'=>3], + ['title'=>'省级','pid'=>201,'paixu'=>4], + ['title'=>'部级','pid'=>201,'paixu'=>5], + ['title'=>'其它级','pid'=>201,'paixu'=>6], // 大学段 - ['title'=>'幼儿园','pid'=>3,'paixu'=>1], - ['title'=>'小学','pid'=>3,'paixu'=>2], - ['title'=>'中小学','pid'=>3,'paixu'=>3], - ['title'=>'初中','pid'=>3,'paixu'=>4], - ['title'=>'高中','pid'=>3,'paixu'=>5], - ['title'=>'其他学段','pid'=>3,'paixu'=>6], + ['title'=>'幼儿园','pid'=>301,'paixu'=>1], + ['title'=>'小学','pid'=>301,'paixu'=>2], + ['title'=>'中小学','pid'=>301,'paixu'=>3], + ['title'=>'初中','pid'=>301,'paixu'=>4], + ['title'=>'高中','pid'=>301,'paixu'=>5], + ['title'=>'其他学段','pid'=>301,'paixu'=>6], // 大学段 - ['title'=>'低年级','pid'=>4,'paixu'=>1], - ['title'=>'中年级','pid'=>4,'paixu'=>2], - ['title'=>'高级年','pid'=>4,'paixu'=>3], - ['title'=>'其他学段','pid'=>4,'paixu'=>4], + ['title'=>'低年级','pid'=>401,'paixu'=>1], + ['title'=>'中年级','pid'=>401,'paixu'=>2], + ['title'=>'高级年','pid'=>401,'paixu'=>3], + ['title'=>'其他学段','pid'=>401,'paixu'=>4], // 学历 - ['title'=>'高中/中专','pid'=>5,'paixu'=>1], - ['title'=>'专科','pid'=>5,'paixu'=>2], - ['title'=>'本科','pid'=>5,'paixu'=>3], - ['title'=>'硕士研究生','pid'=>5,'paixu'=>4], - ['title'=>'博士研究生','pid'=>5,'paixu'=>5], - ['title'=>'其他学历','pid'=>5,'paixu'=>6], + ['title'=>'高中/中专','pid'=>501,'paixu'=>1], + ['title'=>'专科','pid'=>501,'paixu'=>2], + ['title'=>'本科','pid'=>501,'paixu'=>3], + ['title'=>'硕士研究生','pid'=>501,'paixu'=>4], + ['title'=>'博士研究生','pid'=>501,'paixu'=>5], + ['title'=>'其他学历','pid'=>501,'paixu'=>6], // 职称 - ['title'=>'正高级','pid'=>6,'paixu'=>1], - ['title'=>'高级','pid'=>6,'paixu'=>2], - ['title'=>'一级','pid'=>6,'paixu'=>3], - ['title'=>'二级','pid'=>6,'paixu'=>4], - ['title'=>'三级','pid'=>6,'paixu'=>5], - ['title'=>'其他','pid'=>6,'paixu'=>6], + ['title'=>'正高级','pid'=>601,'paixu'=>1], + ['title'=>'高级','pid'=>601,'paixu'=>2], + ['title'=>'一级','pid'=>601,'paixu'=>3], + ['title'=>'二级','pid'=>601,'paixu'=>4], + ['title'=>'三级','pid'=>601,'paixu'=>5], + ['title'=>'其他','pid'=>601,'paixu'=>6], // 职务 - ['title'=>'校长','pid'=>7,'paixu'=>1], - ['title'=>'副校长','pid'=>7,'paixu'=>2], - ['title'=>'主任','pid'=>7,'paixu'=>3], - ['title'=>'教研组长','pid'=>7,'paixu'=>4], - ['title'=>'教师','pid'=>7,'paixu'=>5], - ['title'=>'其他','pid'=>7,'paixu'=>6], + ['title'=>'校长','pid'=>701,'paixu'=>1], + ['title'=>'副校长','pid'=>701,'paixu'=>2], + ['title'=>'主任','pid'=>701,'paixu'=>3], + ['title'=>'教研组长','pid'=>701,'paixu'=>4], + ['title'=>'教师','pid'=>701,'paixu'=>5], + ['title'=>'其他','pid'=>701,'paixu'=>6], // 学期 - ['title'=>'第一学期','pid'=>8,'paixu'=>1], - ['title'=>'第二学期','pid'=>8,'paixu'=>2], + ['title'=>'第一学期','pid'=>801,'paixu'=>1], + ['title'=>'第二学期','pid'=>801,'paixu'=>2], + // 考试分类 + ['title'=>'期末考试','pid'=>901,'paixu'=>1], + ['title'=>'期中考试','pid'=>901,'paixu'=>2], + ['title'=>'单项测试','pid'=>901,'paixu'=>3], + ]; // 保存数据 $this->table('category')->insert($rows)->save(); diff --git a/database/seeds/Rule.php b/database/seeds/Rule.php index 418323b6..030c4ff9 100644 --- a/database/seeds/Rule.php +++ b/database/seeds/Rule.php @@ -34,6 +34,7 @@ class Rule extends Seeder ['id'=>32,'title'=>'教师列表','name'=>'teach/Index/index','paixu'=>2,'ismenu' =>true,'pid' =>3,'url'=>'/teacher',], ['id'=>33,'title'=>'学生列表','name'=>'teach/Studen/index','paixu'=>3,'ismenu' =>true,'pid' =>3,'url'=>'/teacher',], ['id'=>34,'title'=>'学期列表','name'=>'teach/Xueqi/index','paixu'=>4,'ismenu' =>true,'pid' =>3,'url'=>'/xueqi',], + ['id'=>35,'title'=>'学科列表','name'=>'teach/Subject/index','paixu'=>5,'ismenu' =>true,'pid' =>3,'url'=>'/subject',], // 教务管理 @@ -61,6 +62,12 @@ class Rule extends Seeder ['title'=>'编辑','name'=>'teach/Xueqi/edit','paixu'=>3,'pid'=>34,], ['title'=>'查看','name'=>'teach/Xueqi/read','paixu'=>4,'pid'=>34,], ['title'=>'状态','name'=>'teach/Xueqi/status','paixu'=>5,'pid'=>34], + // 学科列表权限 + ['title'=>'添加','name'=>'admin/Subject/create','paixu' =>1,'pid'=>35], + ['title'=>'删除','name'=>'admin/Subject/delete','paixu'=>2,'pid'=>35], + ['title'=>'编辑','name'=>'admin/Subject/edit','paixu'=>3,'pid'=>35,], + ['title'=>'查看','name'=>'admin/Subject/read','paixu'=>4,'pid'=>35,], + ['title'=>'状态','name'=>'admin/Subject/status','paixu'=>5,'pid'=>35], // 系统设置 @@ -100,6 +107,7 @@ class Rule extends Seeder ['title'=>'编辑','name'=>'admin/AuthGroup/edit','paixu'=>3,'pid'=>23,], ['title'=>'查看','name'=>'admin/AuthGroup/read','paixu'=>4,'pid'=>23,], ['title'=>'状态','name'=>'admin/AuthGroup/status','paixu'=>5,'pid'=>23], + ]; diff --git a/database/seeds/Subject.php b/database/seeds/Subject.php new file mode 100644 index 00000000..ac3adccf --- /dev/null +++ b/database/seeds/Subject.php @@ -0,0 +1,43 @@ +'语文','jiancheng'=>'语','category'=>'2011','paixu'=>1], + ['title'=>'数学','jiancheng'=>'数','category'=>'2012','paixu'=>2], + ['title'=>'外语','jiancheng'=>'外','category'=>'2013','paixu'=>3], + ['title'=>'物理','jiancheng'=>'物','category'=>'2016','paixu'=>4], + ['title'=>'化学','jiancheng'=>'化','category'=>'2016','paixu'=>5], + ['title'=>'体育与健康','jiancheng'=>'体','category'=>'2017','paixu'=>6], + ['title'=>'音乐','jiancheng'=>'音','category'=>'2018','paixu'=>7], + ['title'=>'美术','jiancheng'=>'美','category'=>'2018','paixu'=>8], + ['title'=>'信息技术','jiancheng'=>'信','category'=>'2019','paixu'=>9], + ['title'=>'科学','jiancheng'=>'科','category'=>'2016','paixu'=>10], + ['title'=>'品德与生活/社会','jiancheng'=>'品','category'=>'2014','paixu'=>11], + ['title'=>'历史','jiancheng'=>'史','category'=>'2015','paixu'=>12], + ['title'=>'地理','jiancheng'=>'地','category'=>'2015','paixu'=>13], + ['title'=>'思想品德','jiancheng'=>'品','category'=>'2014','paixu'=>14], + ['title'=>'生物','jiancheng'=>'生','category'=>'2016','paixu'=>15], + ['title'=>'地方课程','jiancheng'=>'地','category'=>'2020','paixu'=>16], + ['title'=>'校本课程','jiancheng'=>'校','category'=>'2020','paixu'=>17], + ['title'=>'劳动与技术','jiancheng'=>'劳','category'=>'2019','paixu'=>18], + ['title'=>'研究性学习/社区服务、实践','jiancheng'=>'社','category'=>'2019','paixu'=>19], + + ]; + // 保存数据 + $this->table('subject')->insert($rows)->save(); + } +} \ No newline at end of file diff --git a/route/teach.php b/route/teach.php index 0054d996..79aeb11c 100644 --- a/route/teach.php +++ b/route/teach.php @@ -13,3 +13,4 @@ Route::resource('teacher','teach/Index'); Route::resource('xueqi','teach/Xueqi'); Route::resource('kaoshi','teach/Kaoshi'); +Route::resource('subject','teach/Subject'); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 8d3b8a95..e23e3d39 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -7,5 +7,6 @@ $baseDir = dirname($vendorDir); return array( '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', + '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', 'ddc3cd2a04224f9638c5d0de6a69c7e3' => $vendorDir . '/topthink/think-migration/src/config.php', ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 3bd1e037..64da9b24 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -7,6 +7,7 @@ $baseDir = dirname($vendorDir); return array( 'think\\migration\\' => array($vendorDir . '/topthink/think-migration/src'), + 'think\\helper\\' => array($vendorDir . '/topthink/think-helper/src'), 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 'php4world\\' => array($vendorDir . '/php4world/auth/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e6ae68ca..5e1eb3b9 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -8,6 +8,7 @@ class ComposerStaticInitbe7733f58d7b733cc58f1391b7bd5053 { public static $files = array ( '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', + '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', 'ddc3cd2a04224f9638c5d0de6a69c7e3' => __DIR__ . '/..' . '/topthink/think-migration/src/config.php', ); @@ -15,6 +16,7 @@ class ComposerStaticInitbe7733f58d7b733cc58f1391b7bd5053 't' => array ( 'think\\migration\\' => 16, + 'think\\helper\\' => 13, 'think\\composer\\' => 15, 'think\\captcha\\' => 14, ), @@ -41,6 +43,10 @@ class ComposerStaticInitbe7733f58d7b733cc58f1391b7bd5053 array ( 0 => __DIR__ . '/..' . '/topthink/think-migration/src', ), + 'think\\helper\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-helper/src', + ), 'think\\composer\\' => array ( 0 => __DIR__ . '/..' . '/topthink/think-installer/src', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index d17efb4a..16d67653 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -149,6 +149,50 @@ ], "description": "captcha package for thinkphp5" }, + { + "name": "topthink/think-helper", + "version": "v1.0.6", + "version_normalized": "1.0.6.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-helper.git", + "reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f", + "reference": "0c99dc625b0d2d4124e1b6ca15a3ad6f0125963f", + "shasum": "", + "mirrors": [ + { + "url": "https://dl.laravel-china.org/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "time": "2017-04-05T07:15:37+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\helper\\": "src" + }, + "files": [ + "src/helper.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP5 Helper Package" + }, { "name": "topthink/think-installer", "version": "v2.0.0", diff --git a/vendor/topthink/think-helper/.gitignore b/vendor/topthink/think-helper/.gitignore new file mode 100644 index 00000000..e244eda0 --- /dev/null +++ b/vendor/topthink/think-helper/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +/.idea/ \ No newline at end of file diff --git a/vendor/topthink/think-helper/LICENSE b/vendor/topthink/think-helper/LICENSE new file mode 100644 index 00000000..8dada3ed --- /dev/null +++ b/vendor/topthink/think-helper/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/topthink/think-helper/README.md b/vendor/topthink/think-helper/README.md new file mode 100644 index 00000000..27ef6709 --- /dev/null +++ b/vendor/topthink/think-helper/README.md @@ -0,0 +1,92 @@ +# thinkphp5 常用的一些扩展类库 + +> 更新完善中 + +> 以下类库都在`\\think\\helper`命名空间下 + +## Str +> 字符串操作 + +``` +// 检查字符串中是否包含某些字符串 +Str::contains($haystack, $needles) + +// 检查字符串是否以某些字符串结尾 +Str::endsWith($haystack, $needles) + +// 获取指定长度的随机字母数字组合的字符串 +Str::random($length = 16) + +// 字符串转小写 +Str::lower($value) + +// 字符串转大写 +Str::upper($value) + +// 获取字符串的长度 +Str::length($value) + +// 截取字符串 +Str::substr($string, $start, $length = null) + +``` + +## Hash +> 创建密码的哈希 + +``` +// 创建 +Hash::make($value, $type = null, array $options = []) + +// 检查 +Hash::check($value, $hashedValue, $type = null, array $options = []) + +``` + +## Time +> 时间戳操作 + +``` +// 今日开始和结束的时间戳 +Time::today(); + +// 昨日开始和结束的时间戳 +Time::yesterday(); + +// 本周开始和结束的时间戳 +Time::week(); + +// 上周开始和结束的时间戳 +Time::lastWeek(); + +// 本月开始和结束的时间戳 +Time::month(); + +// 上月开始和结束的时间戳 +Time::lastMonth(); + +// 今年开始和结束的时间戳 +Time::year(); + +// 去年开始和结束的时间戳 +Time::lastYear(); + +// 获取7天前零点到现在的时间戳 +Time::dayToNow(7) + +// 获取7天前零点到昨日结束的时间戳 +Time::dayToNow(7, true) + +// 获取7天前的时间戳 +Time::daysAgo(7) + +// 获取7天后的时间戳 +Time::daysAfter(7) + +// 天数转换成秒数 +Time::daysToSecond(5) + +// 周数转换成秒数 +Time::weekToSecond(5) + +``` \ No newline at end of file diff --git a/vendor/topthink/think-helper/composer.json b/vendor/topthink/think-helper/composer.json new file mode 100644 index 00000000..d246fa3c --- /dev/null +++ b/vendor/topthink/think-helper/composer.json @@ -0,0 +1,19 @@ +{ + "name": "topthink/think-helper", + "description": "The ThinkPHP5 Helper Package", + "license": "Apache-2.0", + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "autoload": { + "psr-4": { + "think\\helper\\": "src" + }, + "files": [ + "src/helper.php" + ] + } +} diff --git a/vendor/topthink/think-helper/src/Arr.php b/vendor/topthink/think-helper/src/Arr.php new file mode 100644 index 00000000..7350bb24 --- /dev/null +++ b/vendor/topthink/think-helper/src/Arr.php @@ -0,0 +1,41 @@ + +// +---------------------------------------------------------------------- + +namespace think\helper; + + +class Arr +{ + + public static function isAssoc(array $array) + { + $keys = array_keys($array); + + return array_keys($keys) !== $keys; + } + + public static function sortRecursive($array) + { + foreach ($array as &$value) { + if (is_array($value)) { + $value = static::sortRecursive($value); + } + } + + if (static::isAssoc($array)) { + ksort($array); + } else { + sort($array); + } + + return $array; + } +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/Hash.php b/vendor/topthink/think-helper/src/Hash.php new file mode 100644 index 00000000..b56543ea --- /dev/null +++ b/vendor/topthink/think-helper/src/Hash.php @@ -0,0 +1,48 @@ + +// +---------------------------------------------------------------------- + +namespace think\helper; + + +class Hash +{ + protected static $handle = []; + + public static function make($value, $type = null, array $options = []) + { + return self::handle($type)->make($value, $options); + } + + public static function check($value, $hashedValue, $type = null, array $options = []) + { + return self::handle($type)->check($value, $hashedValue, $options); + } + + public static function handle($type) + { + if (is_null($type)) { + if (PHP_VERSION_ID >= 50500) { + $type = 'bcrypt'; + } else { + $type = 'md5'; + } + } + if (empty(self::$handle[$type])) { + $class = "\\think\\helper\\hash\\" . ucfirst($type); + if (!class_exists($class)) { + throw new \ErrorException("Not found {$type} hash type!"); + } + self::$handle[$type] = new $class(); + } + return self::$handle[$type]; + } + +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/Str.php b/vendor/topthink/think-helper/src/Str.php new file mode 100644 index 00000000..ba56cb44 --- /dev/null +++ b/vendor/topthink/think-helper/src/Str.php @@ -0,0 +1,202 @@ + +// +---------------------------------------------------------------------- +namespace think\helper; + +class Str +{ + + protected static $snakeCache = []; + + protected static $camelCache = []; + + protected static $studlyCache = []; + + /** + * 检查字符串中是否包含某些字符串 + * @param string $haystack + * @param string|array $needles + * @return bool + */ + public static function contains($haystack, $needles) + { + foreach ((array) $needles as $needle) { + if ($needle != '' && mb_strpos($haystack, $needle) !== false) { + return true; + } + } + + return false; + } + + /** + * 检查字符串是否以某些字符串结尾 + * + * @param string $haystack + * @param string|array $needles + * @return bool + */ + public static function endsWith($haystack, $needles) + { + foreach ((array) $needles as $needle) { + if ((string) $needle === static::substr($haystack, -static::length($needle))) { + return true; + } + } + + return false; + } + + /** + * 检查字符串是否以某些字符串开头 + * + * @param string $haystack + * @param string|array $needles + * @return bool + */ + public static function startsWith($haystack, $needles) + { + foreach ((array) $needles as $needle) { + if ($needle != '' && mb_strpos($haystack, $needle) === 0) { + return true; + } + } + + return false; + } + + /** + * 获取指定长度的随机字母数字组合的字符串 + * + * @param int $length + * @return string + */ + public static function random($length = 16) + { + $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + return static::substr(str_shuffle(str_repeat($pool, $length)), 0, $length); + } + + /** + * 字符串转小写 + * + * @param string $value + * @return string + */ + public static function lower($value) + { + return mb_strtolower($value, 'UTF-8'); + } + + /** + * 字符串转大写 + * + * @param string $value + * @return string + */ + public static function upper($value) + { + return mb_strtoupper($value, 'UTF-8'); + } + + /** + * 获取字符串的长度 + * + * @param string $value + * @return int + */ + public static function length($value) + { + return mb_strlen($value); + } + + /** + * 截取字符串 + * + * @param string $string + * @param int $start + * @param int|null $length + * @return string + */ + public static function substr($string, $start, $length = null) + { + return mb_substr($string, $start, $length, 'UTF-8'); + } + + /** + * 驼峰转下划线 + * + * @param string $value + * @param string $delimiter + * @return string + */ + public static function snake($value, $delimiter = '_') + { + $key = $value; + + if (isset(static::$snakeCache[$key][$delimiter])) { + return static::$snakeCache[$key][$delimiter]; + } + + if (!ctype_lower($value)) { + $value = preg_replace('/\s+/u', '', $value); + + $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1' . $delimiter, $value)); + } + + return static::$snakeCache[$key][$delimiter] = $value; + } + + /** + * 下划线转驼峰(首字母小写) + * + * @param string $value + * @return string + */ + public static function camel($value) + { + if (isset(static::$camelCache[$value])) { + return static::$camelCache[$value]; + } + + return static::$camelCache[$value] = lcfirst(static::studly($value)); + } + + /** + * 下划线转驼峰(首字母大写) + * + * @param string $value + * @return string + */ + public static function studly($value) + { + $key = $value; + + if (isset(static::$studlyCache[$key])) { + return static::$studlyCache[$key]; + } + + $value = ucwords(str_replace(['-', '_'], ' ', $value)); + + return static::$studlyCache[$key] = str_replace(' ', '', $value); + } + + /** + * 转为首字母大写的标题格式 + * + * @param string $value + * @return string + */ + public static function title($value) + { + return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8'); + } +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/Time.php b/vendor/topthink/think-helper/src/Time.php new file mode 100644 index 00000000..4284ed46 --- /dev/null +++ b/vendor/topthink/think-helper/src/Time.php @@ -0,0 +1,198 @@ + +// +---------------------------------------------------------------------- +namespace think\helper; + +class Time +{ + /** + * 返回今日开始和结束的时间戳 + * + * @return array + */ + public static function today() + { + return [ + mktime(0, 0, 0, date('m'), date('d'), date('Y')), + mktime(23, 59, 59, date('m'), date('d'), date('Y')) + ]; + } + + /** + * 返回昨日开始和结束的时间戳 + * + * @return array + */ + public static function yesterday() + { + $yesterday = date('d') - 1; + return [ + mktime(0, 0, 0, date('m'), $yesterday, date('Y')), + mktime(23, 59, 59, date('m'), $yesterday, date('Y')) + ]; + } + + /** + * 返回本周开始和结束的时间戳 + * + * @return array + */ + public static function week() + { + $timestamp = time(); + return [ + strtotime(date('Y-m-d', strtotime("+0 week Monday", $timestamp))), + strtotime(date('Y-m-d', strtotime("+0 week Sunday", $timestamp))) + 24 * 3600 - 1 + ]; + } + + /** + * 返回上周开始和结束的时间戳 + * + * @return array + */ + public static function lastWeek() + { + $timestamp = time(); + return [ + strtotime(date('Y-m-d', strtotime("last week Monday", $timestamp))), + strtotime(date('Y-m-d', strtotime("last week Sunday", $timestamp))) + 24 * 3600 - 1 + ]; + } + + /** + * 返回本月开始和结束的时间戳 + * + * @return array + */ + public static function month($everyDay = false) + { + return [ + mktime(0, 0, 0, date('m'), 1, date('Y')), + mktime(23, 59, 59, date('m'), date('t'), date('Y')) + ]; + } + + /** + * 返回上个月开始和结束的时间戳 + * + * @return array + */ + public static function lastMonth() + { + $begin = mktime(0, 0, 0, date('m') - 1, 1, date('Y')); + $end = mktime(23, 59, 59, date('m') - 1, date('t', $begin), date('Y')); + + return [$begin, $end]; + } + + /** + * 返回今年开始和结束的时间戳 + * + * @return array + */ + public static function year() + { + return [ + mktime(0, 0, 0, 1, 1, date('Y')), + mktime(23, 59, 59, 12, 31, date('Y')) + ]; + } + + /** + * 返回去年开始和结束的时间戳 + * + * @return array + */ + public static function lastYear() + { + $year = date('Y') - 1; + return [ + mktime(0, 0, 0, 1, 1, $year), + mktime(23, 59, 59, 12, 31, $year) + ]; + } + + public static function dayOf() + { + + } + + /** + * 获取几天前零点到现在/昨日结束的时间戳 + * + * @param int $day 天数 + * @param bool $now 返回现在或者昨天结束时间戳 + * @return array + */ + public static function dayToNow($day = 1, $now = true) + { + $end = time(); + if (!$now) { + list($foo, $end) = self::yesterday(); + } + + return [ + mktime(0, 0, 0, date('m'), date('d') - $day, date('Y')), + $end + ]; + } + + /** + * 返回几天前的时间戳 + * + * @param int $day + * @return int + */ + public static function daysAgo($day = 1) + { + $nowTime = time(); + return $nowTime - self::daysToSecond($day); + } + + /** + * 返回几天后的时间戳 + * + * @param int $day + * @return int + */ + public static function daysAfter($day = 1) + { + $nowTime = time(); + return $nowTime + self::daysToSecond($day); + } + + /** + * 天数转换成秒数 + * + * @param int $day + * @return int + */ + public static function daysToSecond($day = 1) + { + return $day * 86400; + } + + /** + * 周数转换成秒数 + * + * @param int $week + * @return int + */ + public static function weekToSecond($week = 1) + { + return self::daysToSecond() * 7 * $week; + } + + private static function startTimeToEndTime() + { + + } +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/hash/Bcrypt.php b/vendor/topthink/think-helper/src/hash/Bcrypt.php new file mode 100644 index 00000000..8f55a771 --- /dev/null +++ b/vendor/topthink/think-helper/src/hash/Bcrypt.php @@ -0,0 +1,51 @@ + +// +---------------------------------------------------------------------- +namespace think\helper\hash; + +class Bcrypt +{ + + /** + * Default crypt cost factor. + * + * @var int + */ + protected $rounds = 10; + + public function make($value, array $options = []) + { + $cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds; + + $hash = password_hash($value, PASSWORD_BCRYPT, ['cost' => $cost]); + + if ($hash === false) { + throw new \RuntimeException('Bcrypt hashing not supported.'); + } + + return $hash; + } + + public function check($value, $hashedValue, array $options = []) + { + if (strlen($hashedValue) === 0) { + return false; + } + + return password_verify($value, $hashedValue); + } + + public function setRounds($rounds) + { + $this->rounds = (int)$rounds; + + return $this; + } +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/hash/Md5.php b/vendor/topthink/think-helper/src/hash/Md5.php new file mode 100644 index 00000000..5ec07ca0 --- /dev/null +++ b/vendor/topthink/think-helper/src/hash/Md5.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- +namespace think\helper\hash; + +class Md5 +{ + + protected $salt = 'think'; + + public function make($value, array $options = []) + { + $salt = isset($options['salt']) ? $options['salt'] : $this->salt; + + return md5(md5($value) . $salt); + } + + public function check($value, $hashedValue, array $options = []) + { + if (strlen($hashedValue) === 0) { + return false; + } + + $salt = isset($options['salt']) ? $options['salt'] : $this->salt; + + return md5(md5($value) . $salt) == $hashedValue; + } + + public function setSalt($salt) + { + $this->salt = (string)$salt; + + return $this; + } +} \ No newline at end of file diff --git a/vendor/topthink/think-helper/src/helper.php b/vendor/topthink/think-helper/src/helper.php new file mode 100644 index 00000000..f6a55233 --- /dev/null +++ b/vendor/topthink/think-helper/src/helper.php @@ -0,0 +1,93 @@ + +// +---------------------------------------------------------------------- + +if (!function_exists('class_basename')) { + /** + * 获取类名(不包含命名空间) + * + * @param string|object $class + * @return string + */ + function class_basename($class) + { + $class = is_object($class) ? get_class($class) : $class; + + return basename(str_replace('\\', '/', $class)); + } +} + +if (!function_exists('class_uses_recursive')) { + /** + *获取一个类里所有用到的trait,包括父类的 + * + * @param $class + * @return array + */ + function class_uses_recursive($class) + { + if (is_object($class)) { + $class = get_class($class); + } + + $results = []; + + foreach (array_merge([$class => $class], class_parents($class)) as $class) { + $results += trait_uses_recursive($class); + } + + return array_unique($results); + } +} + +if (!function_exists('trait_uses_recursive')) { + /** + * 获取一个trait里所有引用到的trait + * + * @param string $trait + * @return array + */ + function trait_uses_recursive($trait) + { + $traits = class_uses($trait); + + foreach ($traits as $trait) { + $traits += trait_uses_recursive($trait); + } + + return $traits; + } +} +if (!function_exists('classnames')) { + /** + * css样式名生成器 + * classnames("foo", "bar"); // => "foo bar" + * classnames("foo", [ "bar"=> true ]); // => "foo bar" + * classnames([ "foo-bar"=> true ]); // => "foo-bar" + * classnames([ "foo-bar"=> false ]); // => " + * classnames([ "foo" => true ], [ "bar"=> true ]); // => "foo bar" + * classnames([ "foo" => true, "bar"=> true ]); // => "foo bar" + * classnames("foo", [ "bar"=> true, "duck"=> false ], "baz", [ "quux"=> true ]); // => "foo bar baz quux" + * classnames(null, false, "bar", 0, 1, [ "baz"=> null ]); // => "bar 1" + */ + function classnames() + { + $args = func_get_args(); + $classes = array_map(function ($arg) { + if (is_array($arg)) { + return implode(" ", array_filter(array_map(function ($expression, $class) { + return $expression ? $class : false; + }, $arg, array_keys($arg)))); + } + return $arg; + }, $args); + return implode(" ", array_filter($classes)); + } +} \ No newline at end of file