You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
2.7 KiB
105 lines
2.7 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
// | Author: Niucloud Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\service\admin\student_label;
|
|
|
|
use app\model\student_label\StudentLabel;
|
|
|
|
use app\service\core\member\CoreMemberLabelService;
|
|
use core\base\BaseAdminService;
|
|
|
|
|
|
/**
|
|
* 学员标签服务层
|
|
* Class StudentLabelService
|
|
* @package app\service\admin\student_label
|
|
*/
|
|
class StudentLabelService extends BaseAdminService
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->model = new StudentLabel();
|
|
}
|
|
|
|
/**
|
|
* 获取学员标签列表
|
|
* @param array $where
|
|
* @return array
|
|
*/
|
|
public function getPage(array $where = [])
|
|
{
|
|
$field = 'label_id,label_name,memo,sort,create_time,update_time';
|
|
$order = 'label_id desc';
|
|
|
|
$search_model = $this->model->withSearch(["label_name"], $where)->field($field)->order($order);
|
|
$list = $this->pageQuery($search_model);
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* 获取学员标签信息
|
|
* @param int $id
|
|
* @return array
|
|
*/
|
|
public function getInfo(int $id)
|
|
{
|
|
$field = 'label_id,label_name,memo,sort,create_time,update_time';
|
|
|
|
$info = $this->model->field($field)->where([['label_id', "=", $id]])->findOrEmpty()->toArray();
|
|
return $info;
|
|
}
|
|
|
|
/**
|
|
* 添加学员标签
|
|
* @param array $data
|
|
* @return mixed
|
|
*/
|
|
public function add(array $data)
|
|
{
|
|
$res = $this->model->create($data);
|
|
return $res->label_id;
|
|
|
|
}
|
|
|
|
/**
|
|
* 学员标签编辑
|
|
* @param int $id
|
|
* @param array $data
|
|
* @return bool
|
|
*/
|
|
public function edit(int $id, array $data)
|
|
{
|
|
|
|
$this->model->where([['label_id', '=', $id]])->update($data);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 删除学员标签
|
|
* @param int $id
|
|
* @return bool
|
|
*/
|
|
public function del(int $id)
|
|
{
|
|
$model = $this->model->where([['label_id', '=', $id]])->find();
|
|
$res = $model->delete();
|
|
return $res;
|
|
}
|
|
|
|
|
|
public function getMemberLabelListByLabelIds(array $label_ids)
|
|
{
|
|
return ( new CoreMemberLabelService() )->getMemberLabelListByLabelIds($label_ids);
|
|
}
|
|
|
|
|
|
}
|
|
|