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.
135 lines
4.0 KiB
135 lines
4.0 KiB
<?php
|
|
|
|
/**
|
|
* +----------------------------------------------------------------------
|
|
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
* +----------------------------------------------------------------------
|
|
* | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
|
* +----------------------------------------------------------------------
|
|
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
* +----------------------------------------------------------------------
|
|
* | Author: CRMEB Team <admin@crmeb.com>
|
|
* +----------------------------------------------------------------------
|
|
*/
|
|
|
|
/**
|
|
* 投诉管理
|
|
* @author crud自动生成代码
|
|
* @date 2023/10/16 15:26:40
|
|
*/
|
|
|
|
namespace app\services\crud;
|
|
|
|
use app\services\BaseServices;
|
|
use think\exception\ValidateException;
|
|
use app\dao\crud\UserComplaintDao;
|
|
use crmeb\services\FormBuilder;
|
|
|
|
use app\services\crud\SchoolServices;
|
|
|
|
/**
|
|
* Class CrudService
|
|
* @date 2023/10/16
|
|
* @package app\services\crud
|
|
*/
|
|
class UserComplaintServices extends BaseServices
|
|
{
|
|
|
|
/**
|
|
* UserComplaintServices constructor.
|
|
* @param UserComplaintDao $dao
|
|
*/
|
|
public function __construct(UserComplaintDao $dao)
|
|
{
|
|
$this->dao = $dao;
|
|
}
|
|
|
|
/**
|
|
* 主页数据接口
|
|
* @param array $where
|
|
* @return array
|
|
* @date 2023/10/16
|
|
*/
|
|
public function getCrudListIndex(array $where = [])
|
|
{
|
|
[$page, $limit] = $this->getPageValue();
|
|
$model = $this->dao->searchCrudModel($where, 'content,school_name,user_id,id,user_name,create_time', 'id desc', ['schoolIdHasOne', 'userIdHasOne']);
|
|
|
|
return ['count' => $model->count(), 'list' => $model->page($page ?: 1, $limit ?: 10)->select()->toArray()];
|
|
}
|
|
|
|
/**
|
|
* 编辑和获取表单
|
|
* @date 2023/10/16
|
|
* @param int $id
|
|
* @return array
|
|
*/
|
|
public function getCrudForm(int $id = 0)
|
|
{
|
|
$url = '/crud/user_complaint';
|
|
$info = [];
|
|
if ($id) {
|
|
$info = $this->dao->get($id);
|
|
if (!$info) {
|
|
throw new ValidateException(100026);
|
|
}
|
|
$url .= '/' . $id;
|
|
}
|
|
$rule = [];
|
|
|
|
$rule[] = FormBuilder::textarea("content", "投诉内容", $info["content"] ?? '');
|
|
$rule[] = FormBuilder::number("school_id", "学校ID", $info["school_id"] ?? '');
|
|
$rule[] = FormBuilder::input("school_name", "学校名称", $info["school_name"] ?? '');
|
|
$rule[] = FormBuilder::number("user_id", "用户ID", $info["user_id"] ?? '');
|
|
if (isset($info['create_time'])) {
|
|
$time = is_array($info['create_time']) ? $info['create_time'] : json_decode($info['create_time'], true);
|
|
} else {
|
|
$time = ['', ''];
|
|
}
|
|
$statTime = $time[0] ?? '';
|
|
$endTime = $time[1] ?? '';
|
|
$rule[] = FormBuilder::dateTimeRange("create_time", "添加时间", $statTime, $endTime);
|
|
if (isset($info['update_time'])) {
|
|
$time = is_array($info['update_time']) ? $info['update_time'] : json_decode($info['update_time'], true);
|
|
} else {
|
|
$time = ['', ''];
|
|
}
|
|
$statTime = $time[0] ?? '';
|
|
$endTime = $time[1] ?? '';
|
|
$rule[] = FormBuilder::dateTimeRange("update_time", "修改时间", $statTime, $endTime);
|
|
|
|
return create_form('投诉管理', $rule, $url, $id ? 'PUT' : 'POST');
|
|
}
|
|
|
|
/**
|
|
* 新增
|
|
* @date 2023/10/16
|
|
* @param array $data
|
|
* @return mixed
|
|
*/
|
|
public function crudSave(array $data)
|
|
{
|
|
return $this->dao->save($data);
|
|
}
|
|
|
|
/**
|
|
* 修改
|
|
* @date 2023/10/16
|
|
* @param int $id
|
|
* @param array $data
|
|
* @return \crmeb\basic\BaseModel
|
|
*/
|
|
public function crudUpdate(int $id, array $data)
|
|
{
|
|
return $this->dao->update($id, $data);
|
|
}
|
|
|
|
/**
|
|
* 查询学校数据
|
|
*/
|
|
public function getSchoolData($schooleId)
|
|
{
|
|
$SchoolServices = app()->make(SchoolServices::class);
|
|
return $SchoolServices->selectSchoolById($schooleId);
|
|
}
|
|
}
|
|
|