修改测试案例

This commit is contained in:
Anyon 2020-09-03 10:28:02 +08:00
parent cd3a9b1f02
commit 1ad143e2ce
11 changed files with 51 additions and 49 deletions

View File

@ -22,11 +22,12 @@ class Config extends Controller
public function slider()
{
if ($this->request->isGet()) {
$this->skey = 'slider';
$this->title = '轮播图管理';
$this->data = sysdata('slider');
$this->data = sysdata($this->skey);
$this->fetch();
} else {
if (sysdata('slider', json_decode(input('data'), true))) {
if (sysdata($this->skey, json_decode(input('data'), true))) {
$this->success('轮播图保存成功!', '');
} else {
$this->error('轮播图保存失败,请稍候再试!');

View File

@ -41,8 +41,9 @@ class NewsItem extends Controller
*/
public function select()
{
$query = $this->_query($this->table)->equal('status')->like('title');
$query->where(['deleted' => '0'])->dateBetween('create_at')->order('sort desc,id desc')->page();
$query = $this->_query($this->table);
$query->equal('status')->like('title')->dateBetween('create_at');
$query->where(['deleted' => '0'])->order('sort desc,id desc')->page();
}
/**

View File

@ -2,16 +2,16 @@
namespace app\data\controller\api;
use app\data\service\MemberService;
use app\data\service\UserService;
use think\admin\Controller;
use think\exception\HttpResponseException;
/**
* 会员管理基类
* 授权认证基类
* Class Member
* @package app\store\controller\api
*/
abstract class Member extends Controller
abstract class Auth extends Controller
{
/**
* 当前会员MID
@ -45,13 +45,13 @@ abstract class Member extends Controller
* 获取会员数据
* @return array
*/
protected function getMember()
protected function getMember(): array
{
try {
if (empty($this->token)) {
$this->error('接口授权TOKEN无效');
}
return MemberService::instance()->get($this->token);
return UserService::instance()->get($this->token);
} catch (HttpResponseException $exception) {
throw $exception;
} catch (\Exception $exception) {

View File

@ -2,7 +2,7 @@
namespace app\data\controller\api;
use app\data\service\MemberService;
use app\data\service\UserService;
use think\admin\Controller;
/**
@ -37,7 +37,7 @@ class Login extends Controller
if (empty($user)) $this->error('该手机号还没有注册哦!');
if (empty($user['status'])) $this->error('该会员账号状态异常!');
if (md5($data['password']) === $user['password']) {
$this->success('手机登录成功!', MemberService::instance()->token($user['id']));
$this->success('手机登录成功!', UserService::instance()->token($user['id']));
} else {
$this->error('账号登录失败,请稍候再试!');
}
@ -67,7 +67,7 @@ class Login extends Controller
}
$data['password'] = md5($data['password']);
if (($mid = $this->app->db->name($this->table)->insertGetId($data)) !== false) {
$this->success('会员注册成功!', MemberService::instance()->token($mid));
$this->success('会员注册成功!', UserService::instance()->token($mid));
} else {
$this->error('手机注册失败!');
}

View File

@ -1,16 +1,16 @@
<?php
namespace app\data\controller\api\member;
namespace app\data\controller\api\auth;
use app\data\controller\api\Member;
use app\data\service\MemberService;
use app\data\controller\api\Auth;
use app\data\service\UserService;
/**
* 会员资料管理
* Class Center
* @package app\data\controller\api\member
* @package app\data\controller\api\auth
*/
class Center extends Member
class Center extends Auth
{
/**
* 绑定数据表
@ -55,7 +55,7 @@ class Center extends Member
*/
public function total()
{
$this->success('获取会员数据统计!', MemberService::instance()->total($this->mid));
$this->success('获取会员数据统计!', UserService::instance()->total($this->mid));
}
/**
@ -68,15 +68,15 @@ class Center extends Member
{
$data = $this->_vali(['from.require' => '邀请人不能为空']);
if ($data['from'] == $this->mid) {
$this->error('邀请人不能是自己哦', MemberService::instance()->total($this->mid));
$this->error('邀请人不能是自己哦', UserService::instance()->total($this->mid));
}
$from = $this->app->db->name($this->table)->where(['id' => $data['from']])->find();
if (empty($from)) $this->error('邀请人状态异常', MemberService::instance()->total($this->mid));
if ($this->member['from'] > 0) $this->error('您已经绑定了邀请人', MemberService::instance()->total($this->mid));
if (empty($from)) $this->error('邀请人状态异常', UserService::instance()->total($this->mid));
if ($this->member['from'] > 0) $this->error('您已经绑定了邀请人', UserService::instance()->total($this->mid));
if ($this->app->db->name($this->table)->where(['id' => $this->mid])->update($data) !== false) {
$this->success('绑定邀请人成功!', MemberService::instance()->total($this->mid));
$this->success('绑定邀请人成功!', UserService::instance()->total($this->mid));
} else {
$this->error('绑定邀请人失败!', MemberService::instance()->total($this->mid));
$this->error('绑定邀请人失败!', UserService::instance()->total($this->mid));
}
}

View File

@ -1,16 +1,16 @@
<?php
namespace app\data\controller\api\member;
namespace app\data\controller\api\auth;
use app\data\controller\api\Member;
use app\data\controller\api\Auth;
use app\data\service\NewsService;
/**
* 文章评论内容
* Class News
* @package app\data\controller\api\member
* @package app\data\controller\api\auth
*/
class News extends Member
class News extends Auth
{
/**
* 会员评论内容

View File

@ -49,9 +49,9 @@ class NewsService extends Service
public function buildListByMid(array &$list = []): array
{
if (count($list) > 0) {
$ids = array_unique(array_column($list, 'mid'));
$mids = array_unique(array_column($list, 'mid'));
$cols = 'id,phone,nickname,username,headimg,status';
$mems = $this->app->db->name('DataMember')->whereIn('id', $ids)->column($cols, 'id');
$mems = $this->app->db->name('DataMember')->whereIn('id', $mids)->column($cols, 'id');
foreach ($list as &$vo) $vo['member'] = $mems[$vo['mid']] ?? [];
}
return $list;

View File

@ -5,11 +5,11 @@ namespace app\data\service;
use think\admin\Service;
/**
* 会员数据服务
* Class MemberService
* 会员数据接口服务
* Class UserService
* @package app\store\service
*/
class MemberService extends Service
class UserService extends Service
{
/**
* 绑定数据表

View File

@ -209,17 +209,17 @@ return array(
'app\\admin\\controller\\api\\Queue' => $baseDir . '/app/admin/controller/api/Queue.php',
'app\\admin\\controller\\api\\Update' => $baseDir . '/app/admin/controller/api/Update.php',
'app\\admin\\controller\\api\\Upload' => $baseDir . '/app/admin/controller/api/Upload.php',
'app\\data\\controller\\ArticleContent' => $baseDir . '/app/data/controller/ArticleContent.php',
'app\\data\\controller\\ArticleTags' => $baseDir . '/app/data/controller/ArticleTags.php',
'app\\data\\controller\\Config' => $baseDir . '/app/data/controller/Config.php',
'app\\data\\controller\\api\\Article' => $baseDir . '/app/data/controller/api/Article.php',
'app\\data\\controller\\NewsItem' => $baseDir . '/app/data/controller/NewsItem.php',
'app\\data\\controller\\NewsMark' => $baseDir . '/app/data/controller/NewsMark.php',
'app\\data\\controller\\api\\Auth' => $baseDir . '/app/data/controller/api/Auth.php',
'app\\data\\controller\\api\\Data' => $baseDir . '/app/data/controller/api/Data.php',
'app\\data\\controller\\api\\Login' => $baseDir . '/app/data/controller/api/Login.php',
'app\\data\\controller\\api\\Member' => $baseDir . '/app/data/controller/api/Member.php',
'app\\data\\controller\\api\\member\\Article' => $baseDir . '/app/data/controller/api/member/Article.php',
'app\\data\\controller\\api\\member\\Center' => $baseDir . '/app/data/controller/api/member/Center.php',
'app\\data\\service\\ArticleService' => $baseDir . '/app/data/service/ArticleService.php',
'app\\data\\service\\MemberService' => $baseDir . '/app/data/service/MemberService.php',
'app\\data\\controller\\api\\News' => $baseDir . '/app/data/controller/api/News.php',
'app\\data\\controller\\api\\auth\\Center' => $baseDir . '/app/data/controller/api/auth/Center.php',
'app\\data\\controller\\api\\auth\\News' => $baseDir . '/app/data/controller/api/auth/News.php',
'app\\data\\service\\NewsService' => $baseDir . '/app/data/service/NewsService.php',
'app\\data\\service\\UserService' => $baseDir . '/app/data/service/UserService.php',
'app\\index\\controller\\Index' => $baseDir . '/app/index/controller/Index.php',
'app\\wechat\\command\\Fans' => $baseDir . '/app/wechat/command/Fans.php',
'app\\wechat\\controller\\Config' => $baseDir . '/app/wechat/controller/Config.php',

View File

@ -346,17 +346,17 @@ class ComposerStaticInitd21bcdb0e9e0fd6013ffb7c64c8a9d94
'app\\admin\\controller\\api\\Queue' => __DIR__ . '/../..' . '/app/admin/controller/api/Queue.php',
'app\\admin\\controller\\api\\Update' => __DIR__ . '/../..' . '/app/admin/controller/api/Update.php',
'app\\admin\\controller\\api\\Upload' => __DIR__ . '/../..' . '/app/admin/controller/api/Upload.php',
'app\\data\\controller\\ArticleContent' => __DIR__ . '/../..' . '/app/data/controller/ArticleContent.php',
'app\\data\\controller\\ArticleTags' => __DIR__ . '/../..' . '/app/data/controller/ArticleTags.php',
'app\\data\\controller\\Config' => __DIR__ . '/../..' . '/app/data/controller/Config.php',
'app\\data\\controller\\api\\Article' => __DIR__ . '/../..' . '/app/data/controller/api/Article.php',
'app\\data\\controller\\NewsItem' => __DIR__ . '/../..' . '/app/data/controller/NewsItem.php',
'app\\data\\controller\\NewsMark' => __DIR__ . '/../..' . '/app/data/controller/NewsMark.php',
'app\\data\\controller\\api\\Auth' => __DIR__ . '/../..' . '/app/data/controller/api/Auth.php',
'app\\data\\controller\\api\\Data' => __DIR__ . '/../..' . '/app/data/controller/api/Data.php',
'app\\data\\controller\\api\\Login' => __DIR__ . '/../..' . '/app/data/controller/api/Login.php',
'app\\data\\controller\\api\\Member' => __DIR__ . '/../..' . '/app/data/controller/api/Member.php',
'app\\data\\controller\\api\\member\\Article' => __DIR__ . '/../..' . '/app/data/controller/api/member/Article.php',
'app\\data\\controller\\api\\member\\Center' => __DIR__ . '/../..' . '/app/data/controller/api/member/Center.php',
'app\\data\\service\\ArticleService' => __DIR__ . '/../..' . '/app/data/service/ArticleService.php',
'app\\data\\service\\MemberService' => __DIR__ . '/../..' . '/app/data/service/MemberService.php',
'app\\data\\controller\\api\\News' => __DIR__ . '/../..' . '/app/data/controller/api/News.php',
'app\\data\\controller\\api\\auth\\Center' => __DIR__ . '/../..' . '/app/data/controller/api/auth/Center.php',
'app\\data\\controller\\api\\auth\\News' => __DIR__ . '/../..' . '/app/data/controller/api/auth/News.php',
'app\\data\\service\\NewsService' => __DIR__ . '/../..' . '/app/data/service/NewsService.php',
'app\\data\\service\\UserService' => __DIR__ . '/../..' . '/app/data/service/UserService.php',
'app\\index\\controller\\Index' => __DIR__ . '/../..' . '/app/index/controller/Index.php',
'app\\wechat\\command\\Fans' => __DIR__ . '/../..' . '/app/wechat/command/Fans.php',
'app\\wechat\\controller\\Config' => __DIR__ . '/../..' . '/app/wechat/controller/Config.php',

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2020-09-02 14:11:14
// This file is automatically generated at:2020-09-03 10:27:17
declare (strict_types = 1);
return array (
0 => 'think\\admin\\Library',