commit
6739f68cf0
@ -27,7 +27,7 @@ class Member extends CommonModel
|
||||
'last_login_time' => Db::raw('now()'),
|
||||
]);
|
||||
$list = MemberAccount::where(['member_code' => $member['code']])->order('id asc')->select()->toArray();
|
||||
$organizationList = [];
|
||||
$organizationList = self::getOrgList($member['code'], true);
|
||||
if ($list) {
|
||||
foreach ($list as &$item) {
|
||||
$departments = [];
|
||||
@ -40,10 +40,6 @@ class Member extends CommonModel
|
||||
}
|
||||
}
|
||||
$item['department'] = $departments ? implode(' - ', $departments) : '';
|
||||
$organization = Organization::where(['code' => $item['organization_code']])->find();
|
||||
if ($organization) {
|
||||
$organizationList[] = $organization;
|
||||
}
|
||||
}
|
||||
}
|
||||
$member['account_id'] = $list[0]['id'];
|
||||
@ -64,6 +60,41 @@ class Member extends CommonModel
|
||||
return $loginInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户所在的组织
|
||||
* @param string $memberCode
|
||||
* @param bool $newest 是否取最新的值
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function getOrgList(string $memberCode, $newest = false)
|
||||
{
|
||||
$organizationList = [];
|
||||
if (!$memberCode) {
|
||||
return $organizationList;
|
||||
}
|
||||
$cacheKey = 'member:orgList:' . $memberCode;
|
||||
if (!$newest) {
|
||||
$organizationList = cache($cacheKey);
|
||||
if ($organizationList) {
|
||||
return $organizationList;
|
||||
}
|
||||
}
|
||||
$list = MemberAccount::where(['member_code' => $memberCode])->order('id asc')->select()->toArray();
|
||||
if ($list) {
|
||||
foreach ($list as $item) {
|
||||
$organization = Organization::where(['code' => $item['organization_code']])->find();
|
||||
if ($organization) {
|
||||
$organizationList[] = $organization;
|
||||
}
|
||||
}
|
||||
}
|
||||
cache($cacheKey, $organizationList, 3600 * 24);
|
||||
return $organizationList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $memberData
|
||||
* @return Member
|
||||
@ -176,7 +207,7 @@ class Member extends CommonModel
|
||||
if (!$currentMember['dingtalk_unionid'] || !$currentMember['dingtalk_userid']) {
|
||||
if ($currentMember['mobile']) {
|
||||
unset($memberData['mobile']);
|
||||
}else{
|
||||
} else {
|
||||
$has = self::where(['mobile' => $memberData['mobile']])->find();
|
||||
if ($has) {
|
||||
return error('1', '您想要绑定的手机号码已经被绑定给其他帐号,请先用该手机号码登录后进行重置,再切回当前帐号发起绑定');
|
||||
@ -184,7 +215,7 @@ class Member extends CommonModel
|
||||
}
|
||||
if ($currentMember['email']) {
|
||||
unset($memberData['email']);
|
||||
}else{
|
||||
} else {
|
||||
$has = self::where(['email' => $memberData['email']])->find();
|
||||
if ($has) {
|
||||
return error('1', '您想要绑定的邮箱已经被绑定给其他帐号,请先用该邮箱登录后进行重置,再切回当前帐号发起绑定');
|
||||
|
@ -73,7 +73,10 @@ class MemberAccount extends CommonModel
|
||||
'mobile' => $mobile,
|
||||
'email' => $memberDate['email'],
|
||||
];
|
||||
return MemberAccount::create($data);
|
||||
$result = MemberAccount::create($data);
|
||||
$cacheKey = 'member:orgList:' . $memberCode;
|
||||
cache($cacheKey, null);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,6 +129,8 @@ class MemberAccount extends CommonModel
|
||||
$orgCode = getCurrentOrganizationCode();
|
||||
DepartmentMember::where(['account_code' => $accountCode, 'organization_code' => $orgCode])->delete();
|
||||
}
|
||||
$cacheKey = 'member:orgList:' . $memberAccount['member_code'];
|
||||
cache($cacheKey, null);
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
|
@ -22,12 +22,14 @@ class Notify extends CommonModel
|
||||
$formatList = [];
|
||||
$total = $this->where($where)->count('id');
|
||||
if ($list) {
|
||||
foreach ($types as $type) {
|
||||
!isset($formatList[$type]) and $formatList[$type] = [];
|
||||
!isset($totalSum[$type]) and $totalSum[$type] = 0;
|
||||
$sum = $this->where($where)->where(['type' => $type])->count('id');
|
||||
$totalSum[$type] = $sum;
|
||||
}
|
||||
foreach ($list as &$item) {
|
||||
foreach ($types as $type) {
|
||||
!isset($formatList[$type]) and $formatList[$type] = [];
|
||||
!isset($totalSum[$type]) and $totalSum[$type] = 0;
|
||||
$sum = $this->where($where)->where(['type' => $type])->count('id');
|
||||
$totalSum[$type] = $sum;
|
||||
if ($size and count($formatList[$type]) >= $size) {
|
||||
continue;
|
||||
}
|
||||
|
@ -36,7 +36,14 @@ class Project extends CommonModel
|
||||
$offset = ($page - 1) * $page;
|
||||
$limit = $pageSize;
|
||||
$prefix = config('database.prefix');
|
||||
$sql = "select *,p.id as id,p.name as name,p.code as code,p.create_time as create_time from {$prefix}project as p join {$prefix}project_member as pm on p.code = pm.project_code left join {$prefix}project_collection as pc on p.code = pc.project_code where pm.member_code = '{$memberCode}' and p.organization_code = '$organizationCode' and p.deleted = {$deleted} and p.archive = {$archive} order by pc.id desc, p.id desc";
|
||||
$sql = "select *,p.id as id,p.name as name,p.code as code,p.create_time as create_time from {$prefix}project as p join {$prefix}project_member as pm on p.code = pm.project_code left join {$prefix}project_collection as pc on p.code = pc.project_code where pm.member_code = '{$memberCode}' and p.organization_code = '$organizationCode'";
|
||||
if ($deleted != -1) {
|
||||
$sql .= " and p.deleted = {$deleted} ";
|
||||
}
|
||||
if ($archive != -1) {
|
||||
$sql .= " and p.archive = {$archive} ";
|
||||
}
|
||||
$sql .= " order by pc.id desc, p.id desc";
|
||||
$total = Db::query($sql);
|
||||
$total = count($total);
|
||||
$sql .= " limit {$offset},{$limit}";
|
||||
|
@ -86,7 +86,7 @@ class Login extends BasicApi
|
||||
} else {
|
||||
!$data['password'] && $this->error('登录密码不能为空!');
|
||||
!$data['account'] && $this->error('登录账号不能为空!');
|
||||
$member = Member::where(['account' => $data['account']])->whereOr(['email' => $data['account']])->order('id asc')->find();
|
||||
$member = Member::where(['account' => $data['account']])->whereOr(['email' => $data['account']])->whereOr(['mobile' => $data['account']])->order('id asc')->find();
|
||||
}
|
||||
empty($member) && $this->error('账号或密码错误', 201);
|
||||
$member = $member->toArray();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\project\controller;
|
||||
|
||||
use app\common\Model\Member;
|
||||
use controller\BasicApi;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
@ -18,6 +19,12 @@ class Organization extends BasicApi
|
||||
}
|
||||
}
|
||||
|
||||
public function _getOrgList()
|
||||
{
|
||||
$list = Member::getOrgList(getCurrentMember()['code']);
|
||||
$this->success('', $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示资源列表
|
||||
*
|
||||
@ -103,7 +110,7 @@ class Organization extends BasicApi
|
||||
/**
|
||||
* 删除指定资源
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @return void
|
||||
*/
|
||||
public function delete($id = 0)
|
||||
|
@ -181,8 +181,10 @@ class Project extends BasicApi
|
||||
*/
|
||||
public function selfList()
|
||||
{
|
||||
$type = Request::post('type');
|
||||
$type = Request::post('type', 0);
|
||||
$archive = Request::param('archive', 0);
|
||||
$delete = Request::param('delete');
|
||||
$organizationCode = Request::param('organizationCode', '');
|
||||
$memberCode = Request::post('memberCode', '');
|
||||
if (!$memberCode) {
|
||||
$member = getCurrentMember();
|
||||
@ -192,11 +194,11 @@ class Project extends BasicApi
|
||||
if (!$member) {
|
||||
$this->error("参数有误");
|
||||
}
|
||||
$deleted = 1;
|
||||
$deleted = $delete === null ? 1 : $delete;
|
||||
if (!$type) {
|
||||
$deleted = 0;
|
||||
}
|
||||
$list = $this->model->getMemberProjects($member['code'], getCurrentOrganizationCode(), $deleted, $archive, Request::post('page'), Request::post('pageSize'));
|
||||
$list = $this->model->getMemberProjects($member['code'], $organizationCode ?? getCurrentOrganizationCode(), $deleted, $archive, Request::post('page'), Request::post('pageSize'));
|
||||
if ($list['list']) {
|
||||
foreach ($list['list'] as $key => &$item) {
|
||||
$item['owner_name'] = '-';
|
||||
@ -206,9 +208,8 @@ class Project extends BasicApi
|
||||
}
|
||||
$collected = ProjectCollection::where(['project_code' => $item['code'], 'member_code' => getCurrentMember()['code']])->field('id')->find();
|
||||
$item['collected'] = $collected ? 1 : 0;
|
||||
$owner = ProjectMember::where(['project_code' => $item['code'], 'is_owner' => 1])->field('member_code')->find();
|
||||
$member = Member::where(['code' => $owner['member_code']])->field('name')->find();
|
||||
$item['owner_name'] = $member['name'];
|
||||
$owner = ProjectMember::alias('pm')->leftJoin('member m', 'pm.member_code = m.code')->where(['pm.project_code' => $item['code'], 'is_owner' => 1])->field('member_code,name')->find();
|
||||
$item['owner_name'] = $owner['name'];
|
||||
}
|
||||
unset($item);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ return [
|
||||
// 应用名称
|
||||
'app_name' => 'pearProject',
|
||||
// 应用版本
|
||||
'app_version' => '2.8.8',
|
||||
'app_version' => '2.8.9',
|
||||
// 应用地址
|
||||
'app_host' => '',
|
||||
// 应用调试模式
|
||||
|
File diff suppressed because it is too large
Load Diff
7
data/2.8.0/2.8.8-2.8.9.sql
Normal file
7
data/2.8.0/2.8.8-2.8.9.sql
Normal file
@ -0,0 +1,7 @@
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
update pear_project_menu set params = ':org' where id = 120;
|
||||
update pear_project_node set is_auth = 0 where id = 512;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
@ -11,7 +11,7 @@
|
||||
Target Server Version : 50726
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 22/02/2020 20:22:08
|
||||
Date: 23/02/2020 16:14:45
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@ -1974,7 +1974,7 @@ CREATE TABLE `pear_project_menu` (
|
||||
-- ----------------------------
|
||||
-- Records of pear_project_menu
|
||||
-- ----------------------------
|
||||
INSERT INTO `pear_project_menu` VALUES (120, 0, '工作台', 'appstore-o', 'home', 'home', '', '#', 0, 1, 0, '2018-09-30 16:30:01', 0, '', 0);
|
||||
INSERT INTO `pear_project_menu` VALUES (120, 0, '工作台', 'appstore-o', 'home', 'home', ':org', '#', 0, 1, 0, '2018-09-30 16:30:01', 0, '', 0);
|
||||
INSERT INTO `pear_project_menu` VALUES (121, 0, '项目管理', 'project', '#', '#', '', '#', 0, 1, 0, '0000-00-00 00:00:00', 0, '', 1);
|
||||
INSERT INTO `pear_project_menu` VALUES (122, 121, '项目列表', 'branches', '#', '#', '', '#', 0, 1, 0, '0000-00-00 00:00:00', 0, '', 1);
|
||||
INSERT INTO `pear_project_menu` VALUES (124, 0, '系统设置', 'setting', '#', '#', '', '#', 100, 1, 0, '0000-00-00 00:00:00', 0, '', 1);
|
||||
@ -2077,7 +2077,7 @@ INSERT INTO `pear_project_node` VALUES (508, 'project/department_member/index',
|
||||
INSERT INTO `pear_project_node` VALUES (509, 'project/department_member/searchinvitemember', '搜索部门成员', 0, 0, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (510, 'project/department_member/invitemember', '添加部门成员', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (511, 'project/department_member/removemember', '移除部门成员', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (512, 'project/index/changecurrentorganization', '切换当前组织', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (512, 'project/index/changecurrentorganization', '切换当前组织', 0, 0, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (513, 'project/index/editpassword', '修改密码', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (514, 'project/index/uploadimg', '上传图片', 0, 0, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (515, 'project/menu', '菜单管理', 0, 1, 1, NULL);
|
||||
|
@ -11,7 +11,7 @@
|
||||
Target Server Version : 50726
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 22/02/2020 20:22:08
|
||||
Date: 23/02/2020 16:14:45
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@ -1974,7 +1974,7 @@ CREATE TABLE `pear_project_menu` (
|
||||
-- ----------------------------
|
||||
-- Records of pear_project_menu
|
||||
-- ----------------------------
|
||||
INSERT INTO `pear_project_menu` VALUES (120, 0, '工作台', 'appstore-o', 'home', 'home', '', '#', 0, 1, 0, '2018-09-30 16:30:01', 0, '', 0);
|
||||
INSERT INTO `pear_project_menu` VALUES (120, 0, '工作台', 'appstore-o', 'home', 'home', ':org', '#', 0, 1, 0, '2018-09-30 16:30:01', 0, '', 0);
|
||||
INSERT INTO `pear_project_menu` VALUES (121, 0, '项目管理', 'project', '#', '#', '', '#', 0, 1, 0, '0000-00-00 00:00:00', 0, '', 1);
|
||||
INSERT INTO `pear_project_menu` VALUES (122, 121, '项目列表', 'branches', '#', '#', '', '#', 0, 1, 0, '0000-00-00 00:00:00', 0, '', 1);
|
||||
INSERT INTO `pear_project_menu` VALUES (124, 0, '系统设置', 'setting', '#', '#', '', '#', 100, 1, 0, '0000-00-00 00:00:00', 0, '', 1);
|
||||
@ -2077,7 +2077,7 @@ INSERT INTO `pear_project_node` VALUES (508, 'project/department_member/index',
|
||||
INSERT INTO `pear_project_node` VALUES (509, 'project/department_member/searchinvitemember', '搜索部门成员', 0, 0, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (510, 'project/department_member/invitemember', '添加部门成员', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (511, 'project/department_member/removemember', '移除部门成员', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (512, 'project/index/changecurrentorganization', '切换当前组织', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (512, 'project/index/changecurrentorganization', '切换当前组织', 0, 0, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (513, 'project/index/editpassword', '修改密码', 0, 1, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (514, 'project/index/uploadimg', '上传图片', 0, 0, 1, NULL);
|
||||
INSERT INTO `pear_project_node` VALUES (515, 'project/menu', '菜单管理', 0, 1, 1, NULL);
|
||||
|
@ -21,6 +21,7 @@ class NodeService
|
||||
{
|
||||
cache('member_need_access_node', null);
|
||||
$member = getCurrentMember();
|
||||
$member['nodes'] = [];
|
||||
if (($authorize = $member['authorize'])) {
|
||||
$where = ['status' => '1'];
|
||||
$authorizeIds = Db::name('ProjectAuth')->whereIn('id', explode(',', $authorize))->where($where)->column('id');
|
||||
@ -32,7 +33,7 @@ class NodeService
|
||||
$member['nodes'] = $nodes;
|
||||
return setCurrentMember($member);
|
||||
}
|
||||
return false;
|
||||
return setCurrentMember($member);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,7 +69,7 @@ class NodeService
|
||||
if (!in_array($currentNode, self::getProjectAuthNode())) {
|
||||
return true;
|
||||
}
|
||||
return in_array($currentNode, (array)$member['nodes']);
|
||||
return in_array($currentNode, !empty($member['nodes']) ? (array)$member['nodes'] : []);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user