Files
tuiguangzhushou/application/common/service/Team.php
2020-08-06 15:26:41 +08:00

99 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\service;
use app\common\model\Team as TeamModel;
use app\common\validate\Team as TeamValidate;
class Team extends _Init
{
/**
* 添加信息
* @param [type] $data 团队数据
*/
public static function create($data)
{
$validate = new TeamValidate();
if (!$validate->scene('add')->check($data)) {
return $validate->getError();
}
$info = TeamModel::create($data);
if ($info) {
return true;
} else {
return '创建团队失败';
}
}
/**
* 编辑团队
* @param [type] $data 更新的数据
* @return [type] 返回 修改的结果
*/
public static function edit($data)
{
$validate = new TeamValidate();
if (!$validate->scene('add')->check($data)) {
return $validate->getError();
}
$info = TeamModel::update($data);
if ($info) {
return true;
} else {
return '编辑团队失败';
}
}
/**
* 修改团队状态
* @param [type] $id 团队id
* @param [type] $status 状态
* @return [type] 返回结果
*/
public static function status($id, $status)
{
$info = TeamModel::get($id);
if (!$info) {
return '团队不存在';
} elseif ($info->save(['status' => $status])) {
return true;
} else {
return '修改状态失败';
}
}
/**
* 删除团队
* @param [type] $id 要删除的团队id
* @return [type] 返回 结果
*/
public static function del($id)
{
$info = TeamModel::get($id);
if (!$info) {
return '团队不存在';
// } elseif ($info->save(['status' => -1])) {
} elseif ($info->destroy($id)) {
return true;
} else {
return '删除失败';
}
// $model = new TeamModel();
// if ($model->destroy($id)) {
// return true;
// } else {
// return '删除失败';
// }
}
}