123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\api\controller\v1;
- use app\api\controller\Base;
- use app\hander\HelpHander;
- use think\Db;
- class User extends Base
- {
- public function logout(){
- model('Token')->logout($this->userId);
- HelpHander::success([],'退出登录成功');
- }
- // 获取登录后信息
- public function userInfo(){
- $ret = model('User')->userinfo($this->userId,0);
- if($ret){
- HelpHander::success($ret);
- }else{
- HelpHander::error('用户信息获取失败');
- }
- }
- // 获取登录后信息 -- APP端
- public function appUserInfo(){
- $ret = model('User')->userinfo($this->userId,1);
- if($ret){
- HelpHander::success($ret);
- }else{
- HelpHander::error('用户信息获取失败');
- }
- }
- // 修改密码
- public function updatePassword(){
- $data = [
- 'account' => input('account','','trim'),
- 'password' => input('password','','trim'),
- 'newPassword' => input('newPassword','','trim'),
- ];
- $ret = model('User')->updatePassword($this->userId,$data);
- if($ret){
- $token = Db::name('token')->where('user_id',$this->userId)->find();
- HelpHander::success($token,'修改成功');
- }else{
- HelpHander::error('修改失败');
- }
- }
- // 重置密码
- public function resetPassword(){
- $id = input('id/d',0);
- $ret = model('User')->resetPassword($id);
- if($ret){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error('操作失败');
- }
- }
- // 修改用户名
- public function updateAccount(){
- $account = input('account','','','trim');
- $ret = model('User')->updateAccount($this->userId,$account);
- if($ret){
- HelpHander::success([],'操作成功');
- }else{
- HelpHander::error('操作失败');
- }
- }
- // 根据用户ID获取组织列表
- public function queryOrgListByUserId(){
- $ret = model('Org')->queryOrgListByUserId($this->userId);
- HelpHander::success($ret);
- }
- // 获取组织下的所有人员
- public function queryUserListByOrg(){
- $ret = model('User')->queryUserListByOrg($this->orgId);
- HelpHander::success($ret);
- }
- // 根据用户和组织ID获取部门列表
- public function queryDepByUserId(){
- $ret = model('Dep')->queryUserListByOrg($this->orgId);
- HelpHander::success($ret);
- }
- // 获取指定组织下所有在职人员
- public function queryUserNameListOnTheJob(){
- $ret = model('User')->queryUserListByOrg($this->orgId);
- HelpHander::success($ret);
- }
- // 新版通讯录接口
- public function appAddressBook(){
- $ret = model('User')->appAddressBook($this->orgId);
- HelpHander::success($ret);
- }
- // 新版通讯录接口搜索
- public function selectUserTelList(){
- $keyword = input('keyWord','','trim');
- if(!$keyword){
- HelpHander::error('搜索关键词不能为空');
- }
- $ret = model('User')->selectUserTelList($this->orgId,$keyword);
- HelpHander::success($ret);
- }
- }
|