123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- namespace app\admin\controller;
- use app\admin\AdminBaseController;
- use app\common\model\SmsAuthModel;
- use app\common\model\SmsLogModel;
- use app\common\validate\SmsAuthValidate;
- use app\common\validate\SmsTemplateValidate;
- use app\common\model\SmsTemplateModel;
- use think\exception\ValidateException;
- class Sms extends AdminBaseController
- {
- /**
- * 授权
- */
- public function auth()
- {
- return view();
- }
- public function authForm()
- {
- $id = input('id/d, 0');
- $info = SmsAuthModel::find($id);
- if (empty($info)) {
- $info['token'] = rand_str(8) . uniqid();
- }
- return view('', [
- 'info' => $info,
- ]);
- }
- public function listAuth()
- {
- $list = SmsAuthModel::limit(input('limit'))
- ->page(input('page'))
- ->select();
- $count = SmsAuthModel::count();
- if ($count == 0) {
- ajax_return(1, '未查询到数据');
- }
- list_return($list, $count);
- }
- public function delAuth()
- {
- $id = input('id/d', 0);
- SmsAuthModel::destroy($id);
- ajax_return();
- }
- public function editAuth()
- {
- $data = input('post.');
- try {
- validate(SmsAuthValidate::class)->check($data);
- } catch (ValidateException $e) {
- ajax_return(1, $e->getError());
- }
- if (empty($data['id'])) {
- $check = SmsAuthModel::where('token', $data['token'])->find();
- if (!empty($check)) {
- ajax_return(1, '该token已存在');
- }
- SmsAuthModel::create($data);
- } else {
- $check = SmsAuthModel::where('token', $data['token'])->where('id', '<>', $data['id'])->find();
- if (!empty($check)) {
- ajax_return(1, '该token已存在');
- }
- SmsAuthModel::update($data, ['id' => $data['id']]);
- }
- ajax_return();
- }
- /**
- * 日志
- */
- public function log()
- {
- return view('', [
- 'status_list' => SmsLogModel::STATUS,
- ]);
- }
- public function listLog()
- {
- $map = $this->dealEqualInput(['status']);
- $list = SmsLogModel::limit(input('limit'))
- ->where($map)
- ->page(input('page'))
- ->append(['status_text'])
- ->select();
- $count = SmsLogModel::where($map)->count();
- if ($count == 0) {
- ajax_return(1, '未查询到数据');
- }
- list_return($list, $count);
- }
- }
|