Skip to content

Commit

Permalink
20190712
Browse files Browse the repository at this point in the history
  • Loading branch information
GspiriTer committed Aug 19, 2019
1 parent 75fb1cd commit 9b107e0
Show file tree
Hide file tree
Showing 1,370 changed files with 333,498 additions and 1,989 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/public/uploads
/runtime
<<<<<<< HEAD
/index.html
/static
/favicon.ico
/config/database.php
=======
>>>>>>> 8221771... 手机APP登录;
/application/admin/model/Center.php
/application/admin/model/Dingtalk.php
/application/crm/model/Marketing.php
/marketing
/application/oa/model/Knowledge.php
/application/crm/controller/Marketing.php
/application/crm/controller/Cryptdes.php
13 changes: 6 additions & 7 deletions application/admin/controller/ApiCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ public function _initialize()
parent::_initialize();
/*获取头部信息*/
$header = Request::instance()->header();
$request = Request::instance();

$authKey = $header['authkey'];
$sessionId = $header['sessionid'];
// $is_mobile = $header['is_mobile'];
// if ($is_mobile) {
// $cache = cache('Auth_'.$authKey.'_mobile');
// } else {
$cache = cache('Auth_'.$authKey);
// }
$paramArr = $request->param();
$platform = $paramArr['platform'] ? '_'.$paramArr['platform'] : ''; //请求平台(mobile,ding)
$cache = cache('Auth_'.$authKey.$platform);

// 校验sessionid和authKey
if (empty($sessionId) || empty($authKey) || empty($cache)) {
if (empty($sessionId) || empty($authKey) || empty($cache) || ($cache['sessionId'] !== $sessionId)) {
header('Content-Type:application/json; charset=utf-8');
exit(json_encode(['code'=>101, 'error'=>'登录已失效']));
}
Expand Down
22 changes: 11 additions & 11 deletions application/admin/controller/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ class Base extends Common
{
public function login()
{
$request = Request::instance();
$paramArr = $request->param();
$userModel = model('User');
$param = $this->param;
$username = $param['username'];
$password = $param['password'];
$verifyCode = !empty($param['verifyCode'])? $param['verifyCode']: '';
$isRemember = !empty($param['isRemember'])? $param['isRemember']: '';
$is_mobile = $param['mobile'] ? : '';
$data = $userModel->login($username, $password, $verifyCode, $isRemember, $type, $authKey, $is_mobile);
$verifyCode = !empty($param['verifyCode']) ? $param['verifyCode']: '';
$isRemember = !empty($param['isRemember']) ? $param['isRemember']: '';
$data = $userModel->login($username, $password, $verifyCode, $isRemember, $type, $authKey, $paramArr);

Session::set('user_id', $data['userInfo']['id']);
if (!$data) {
Expand All @@ -37,13 +38,12 @@ public function logout()
{
$param = $this->param;
$header = Request::instance()->header();
if ($param['mobile'] == 1) {
cache('Auth_'.$header['authkey'].'mobile', null);
} else {
cache('Auth_'.$header['authkey'], null);
}
session('null', 'admin');
session('admin','null');
$request = Request::instance();
$paramArr = $request->param();
$platform = $paramArr['platform'] ? '_'.$paramArr['platform'] : ''; //请求平台(mobile,ding)
$cache = cache('Auth_'.$authKey.$platform,null);
cookie(null, '72crm_');
cookie(null, '5kcrm_');
session('user_id','null');
return resultArray(['data'=>'退出成功']);
}
Expand Down
7 changes: 4 additions & 3 deletions application/admin/controller/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use think\Db;

class Index extends ApiCommon
{
/**

{ /**
* 用于判断权限
* @permission 无限制
* @allow 登录用户可访问
Expand Down Expand Up @@ -103,7 +103,7 @@ public function authList()
$authList = rulesListToArray($rulesList, $newRuleIds);

//系统设置权限(1超级管理员2系统设置管理员3部门与员工管理员4审批流管理员5工作台管理员6客户管理员7项目管理员8公告管理员)
$settingList = ['0' => 'system','1' => 'user','2' => 'permission','3' => 'examineFlow','4' => 'oa','5' => 'crm'];
$settingList = ['0' => 'system','1' => 'user','2' => 'permission','3' => 'examineFlow','4' => 'oa','5' => 'crm','6' => 'work'];
$adminTypes = adminGroupTypes($u_id);
$newSetting = [];
foreach ($settingList as $k=>$v) {
Expand All @@ -116,6 +116,7 @@ public function authList()
if ($v == 'examineFlow' && in_array('4', $adminTypes)) $check = true;
if ($v == 'oa' && in_array('5', $adminTypes)) $check = true;
if ($v == 'crm' && in_array('6', $adminTypes)) $check = true;
if ($v == 'work' && in_array('7', $adminTypes)) $check = true;
}
if ($check == true) {
$newSetting['manage'][$v] = $check;
Expand Down
8 changes: 7 additions & 1 deletion application/admin/controller/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public function getUserList()
// $belowIds = getSubUserId(true, 1);
}
$userList = db('admin_user')
->where(['user.id' => ['in',$belowIds]])
->alias('user')
->where(['user.id' => ['in',$belowIds]])
->where('user.status>0 and user.type=1')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->field('user.id,user.realname,user.thumb_img,structure.name as s_name')
Expand Down Expand Up @@ -249,6 +249,12 @@ public function resetPassword()
$userInfo = $this->userInfo;
$userModel = model('User');
if ($param['id'] && (int)$param['id'] !== $userInfo['id']) {
//权限判断
$adminTypes = adminGroupTypes($userInfo['id']);
if (!in_array(3,$adminTypes) && !in_array(1,$adminTypes) && !in_array(2,$adminTypes)) {
header('Content-Type:application/json; charset=utf-8');
exit(json_encode(['code'=>102,'error'=>'无权操作']));
}
//权限判断
$adminTypes = adminGroupTypes($userInfo['id']);
if (!in_array(3,$adminTypes) && !in_array(1,$adminTypes) && !in_array(2,$adminTypes)) {
Expand Down
122 changes: 66 additions & 56 deletions application/admin/model/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,94 +20,104 @@ class Comment extends Model
* 我们约定每个模块的数据表都加上相同的前缀,比如微信模块用weixin作为数据表前缀
*/
protected $name = 'admin_comment';
//protected $createTime = 'create_time';
protected $createTime = 'create_time';
protected $autoWriteTimestamp = true;
protected $insert = [
'status' => 1,
];

//根据ID查看评论
/**
* 根据ID查看评论
* @author Michael_xu
* @param
* @return
*/
public function read($param)
{
$userModel = new \app\admin\model\User();
$map['comment.type'] = $param['type'] ? : ''; //默认评论类型
$map['comment.type_id'] = $param['type_id'];
$map['comment.isreply'] = 0;
$list = Db::name('AdminComment')->alias('comment')
$list = Db::name('AdminComment')
->alias('comment')
->join('admin_user u','u.id=comment.user_id')
->field('comment.*,u.username,u.realname,u.thumb_img')
->join(' admin_user u','u.id=comment.user_id')
->where($map)
->select();
foreach ($list as $key => $value) {
$userInfo_f = Db::name('AdminUser')->field('id,realname,thumb_img')->where('id ='.$value['user_id'])->find();
$userInfo_f['thumb_img'] = $userInfo_f['thumb_img']?getFullPath($userInfo_f['thumb_img']):'';
$list[$key]['userInfo'] = $userInfo_f;
$replyuserInfo_f = Db::name('AdminUser')->field('id,realname,thumb_img')->where('id ='.$value['reply_user_id'])->find();
$replyuserInfo_f['thumb_img'] = $replyuserInfo_f['thumb_img']?getFullPath($replyuserInfo_f['thumb_img']):'';
$list[$key]['replyuserInfo'] = $replyuserInfo_f;
$replyList = Db::name('AdminComment')->where('reply_fid = '.$value['comment_id'])->select();
$list[$key]['create_time'] = $value['create_time'];
foreach($replyList as $k=>$v){
$userInfo = Db::name('AdminUser')->field('id,realname,thumb_img')->where('id ='.$v['user_id'])->find();
$userInfo['thumb_img'] = $userInfo['thumb_img']?getFullPath($userInfo['thumb_img']):'';
$replyList[$k]['userInfo'] = $userInfo;
$replyuserInfo = Db::name('AdminUser')->field('id,realname,thumb_img')->where('id ='.$v['reply_user_id'])->find();
$replyuserInfo['thumb_img'] = $replyuserInfo['thumb_img']?getFullPath($replyuserInfo['thumb_img']):'';
$replyList[$k]['replyuserInfo'] = $replyuserInfo;
$list[$key]['userInfo']['username'] = $value['username'];
$list[$key]['userInfo']['realname'] = $value['realname'];
$list[$key]['userInfo']['thumb_img'] = $value['thumb_img'] ? getFullPath($value['thumb_img']) : '';
$list[$key]['replyuserInfo'] = $userModel->getUserById($value['reply_user_id']);
$replyList = [];
$replyList = Db::name('AdminComment')->where(['reply_fid' => $value['comment_id']])->select();
foreach ($replyList as $k=>$v) {
$replyList[$k]['userInfo'] = $userModel->getUserById($v['user_id']);
$replyList[$k]['replyuserInfo'] = $userModel->getUserById($v['reply_user_id']);
}
$list[$key]['replyList'] = $replyList?:array(); // $this->commentList($value['comment_id'],$result = array());
$list[$key]['replyList'] = $replyList ? : array();
}
return $list;
}
//获取回复
function commentList($parent_id = 0,&$result = array()){

$arr = $this->where("status =1 and reply_id = '".$parent_id."'")->order("create_time desc")->select();
if(empty($arr)){
return array();
}
foreach ($arr as $cm) {
$thisArr=&$result[];
$cm["children"] = $this->commentList($cm["comment_id"],$thisArr);
$thisArr = $cm;

/**
* 获取回复
* @author Michael_xu
* @param
* @return
*/
function commentList($parent_id = 0,&$result = array())
{
$list = $this->where(['status' => 1,'reply_id' => $parent_id])->order("create_time desc")->select();
if ($list) {
foreach ($list as $cm) {
$thisArr =& $result[];
$cm["children"] = $this->commentList($cm["comment_id"],$thisArr);
$thisArr = $cm;
}
}
return $result;
return $result ? : [];
}

//新建评论
/**
* 新建评论
* @author Michael_xu
* @param
* @return
*/
public function createData($param)
{
$data['user_id'] = $param['user_id'];
$data['content'] = $param['content']; //内容拼接保存
$data['reply_content'] = $param['reply_content'] ? : ''; //内容拼接保存
$data['create_time'] = time(); //
$data['isreply'] = $param['reply_comment_id'] ? 1 : 0; //是否是回复评论
$data['reply_id'] = $param['reply_comment_id'] ? $param['reply_comment_id'] : 0; //回复消息id
$data['reply_fid'] = $param['reply_fid']?:''; //回复最上级ID
$data['reply_user_id'] = $param['reply_user_id'] ? : ''; //回复别人ID
$data['status'] = 1;
$data['type_id'] = $param['type_id']; //任务id
$data['type'] = $param['type'];//任务评论
$flag = db('admin_comment')->insertGetId($data);
if ($flag) {
return $flag;
$param['reply_content'] = $param['reply_content'] ? : ''; //内容拼接保存
$param['isreply'] = $param['reply_comment_id'] ? 1 : 0; //是否是回复评论
$param['reply_id'] = $param['reply_comment_id'] ? $param['reply_comment_id'] : 0; //回复消息id
$param['reply_fid'] = $param['reply_fid'] ? : ''; //回复最上级ID
$param['reply_user_id'] = $param['reply_user_id'] ? : ''; //回复别人ID
$param['status'] = 1;
if ($this->data($param)->allowField(true)->save()) {
return $this->comment_id;
} else {
$this->error = '回复添加失败';
$this->error = '回复失败';
return false;
}
}

//删除评论
/**
* 删除评论
* @author Michael_xu
* @param
* @return
*/
public function delDataById($param)
{
if($param['comment_id']){
$flag = $this->where('comment_id ='.$param['comment_id'])->delete();
if ($param['comment_id']) {
$flag = $this->where(['comment_id' => $param['comment_id']])->delete();
} else {
$flag = $this->where('type ='.$param['type'].' and type_id ='.$param['type_id'])->delete();
$flag = $this->where(['type' => $param['type'],'type_id' => $param['type_id']])->delete();
}
if ( $flag ){
return true;
} else {
if (!$flag){
$this->error = '不存在或已删除';
return false;
}
return true;
}
}
}

0 comments on commit 9b107e0

Please sign in to comment.