169 lines
5.7 KiB
PHP
169 lines
5.7 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
require_once APPPATH . 'controllers/api/BaseController.php';
|
|
|
|
/**
|
|
* Notes:私域直播_用户管理
|
|
* Created on: 2022/9/19 17:15
|
|
* Created by: dengbw
|
|
*/
|
|
class User extends BaseController
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('market/Market_sylive_user_model', 'mdSyliveUser');
|
|
}
|
|
|
|
/**
|
|
* Notes:用户管理列表
|
|
* Created on: 2022/9/20 14:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function page_get()
|
|
{
|
|
$page = $this->input_param('page');
|
|
$limit = $this->input_param('limit');
|
|
$uname = $this->input_param('uname');
|
|
$nickname = $this->input_param('nickname');
|
|
$sort = $this->input_param('sort');
|
|
$order = $this->input_param('order');
|
|
$organizationId = intval($this->input_param('organizationId'));
|
|
!$page && $page = 1;
|
|
!$limit && $limit = 10;
|
|
$sort_order = 'userId desc';
|
|
if ($sort && $order) {
|
|
if ($sort == 'sexName') {
|
|
$sort_order = 'sex ' . $order;
|
|
} else {
|
|
$sort_order = $sort . ' ' . $order;
|
|
}
|
|
}
|
|
$list = [];
|
|
$where['status>='] = 0;
|
|
$organizationId && $where['organizationId'] = $organizationId;
|
|
$uname && $where['uname'] = $uname;
|
|
$nickname && $where['nickname'] = $nickname;
|
|
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
|
|
$organizationType = 0;
|
|
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $organizationId]);
|
|
$re_org && $organizationType = $re_org['organizationType'];
|
|
$roleName = $this->mdSyliveUser->roleAry($organizationType);
|
|
$count = $this->mdSyliveUser->count($where);
|
|
if ($count) {
|
|
$res = $this->mdSyliveUser->select($where, $sort_order, $page, $limit);
|
|
foreach ($res as $v) {
|
|
$sexName = $this->mdSyliveUser->sexAry($v['sex']);
|
|
$status = intval($v['status']);
|
|
$list[] = [
|
|
'userId' => $v['userId'], 'uname' => $v['uname'], 'nickname' => $v['nickname'], 'mobile' => $v['mobile']
|
|
, 'roleName' => $roleName, 'organizationId' => $organizationId, 'status' => $status
|
|
, 'sex' => $v['sex'], 'sexName' => $sexName, 'createTime' => $v['createTime']];
|
|
}
|
|
}
|
|
$date = ['list' => $list, 'count' => $count];
|
|
$this->return_response_list($date);
|
|
}
|
|
|
|
/**
|
|
* Notes:添加用户
|
|
* Created on: 2022/9/21 16:46
|
|
* Created by: dengbw
|
|
*/
|
|
public function index_post()
|
|
{
|
|
$mobile = $this->input_param('mobile');
|
|
$organizationId = intval($this->input_param('organizationId'));
|
|
$sex = intval($this->input_param('sex'));
|
|
$uname = $this->input_param('uname');
|
|
if (!$mobile) {
|
|
$this->return_json('请输入手机号');
|
|
}
|
|
if (!$organizationId) {
|
|
$this->return_json('请选择所属机构');
|
|
}
|
|
if (!$uname) {
|
|
$this->return_json('请输入姓名');
|
|
}
|
|
$re = $this->mdSyliveUser->get(['mobile' => $mobile]);
|
|
if ($re['organizationId']) {
|
|
$this->return_json('手机号已存在');
|
|
}
|
|
$addDate = ['organizationId' => $organizationId, 'sex' => $sex, 'uname' => $uname];
|
|
if ($re['userId']) {
|
|
$this->mdSyliveUser->update($addDate, ['userId' => $re['userId']]);
|
|
$this->return_response([], '绑定用户成功');
|
|
} else {
|
|
$addDate['mobile'] = $mobile;
|
|
$addDate['createTime'] = date('Y-m-d H:i:s');
|
|
$id = $this->mdSyliveUser->add($addDate);
|
|
if (!$id) {
|
|
$this->return_json('添加用户失败');
|
|
}
|
|
$this->return_response();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Notes:修改用户
|
|
* Created on: 2022/9/21 14:48
|
|
* Created by: dengbw
|
|
*/
|
|
public function index_put()
|
|
{
|
|
$userId = intval($this->input_param('userId'));
|
|
$organizationId = intval($this->input_param('organizationId'));
|
|
$sex = intval($this->input_param('sex'));
|
|
$uname = $this->input_param('uname');
|
|
if (!$userId) {
|
|
$this->return_json('参数错误');
|
|
}
|
|
if (!$organizationId) {
|
|
$this->return_json('请选择所属机构');
|
|
}
|
|
if (!$uname) {
|
|
$this->return_json('请输入姓名');
|
|
}
|
|
$upDate = ['organizationId' => $organizationId, 'sex' => $sex, 'uname' => $uname];
|
|
$this->mdSyliveUser->update($upDate, ['userId' => $userId]);
|
|
$this->return_response();
|
|
}
|
|
|
|
/**
|
|
* Notes:删除用户
|
|
* Created on: 2022/9/21 16:10
|
|
* Created by: dengbw
|
|
* @param null $userId
|
|
*/
|
|
public function index_delete($userId = null)
|
|
{
|
|
if (!$userId) {
|
|
$this->return_json('参数错误');
|
|
}
|
|
$this->mdSyliveUser->update(['status' => -1], ['userId' => $userId]);
|
|
$this->return_response();
|
|
}
|
|
|
|
/**
|
|
* Notes:栓验字段
|
|
* Created on: 2022/9/21 15:52
|
|
* Created by: dengbw
|
|
*/
|
|
public function existence_get()
|
|
{
|
|
$field = $this->input_param('field');
|
|
$value = $this->input_param('value');
|
|
$id = $this->input_param('id');
|
|
if (!$id) {
|
|
$where = [$field => $value];
|
|
$field == 'mobile' && $where['organizationId>'] = 0;
|
|
$re = $this->mdSyliveUser->get([$field => $value]);
|
|
if ($re) {
|
|
$this->return_json('已存在', 0);
|
|
}
|
|
}
|
|
$this->return_json('不存在', 1);
|
|
}
|
|
|
|
} |