|
@@ -3,7 +3,11 @@
|
|
|
namespace app\common\controller;
|
|
|
|
|
|
use app\BaseController;
|
|
|
+use app\common\api\EnterpriseApi;
|
|
|
use app\common\middleware\Auth;
|
|
|
+use app\common\model\TalentChecklog;
|
|
|
+use app\common\validate\Enterprise;
|
|
|
+use think\exception\ValidateException;
|
|
|
use think\facade\Db;
|
|
|
use app\enterprise\api\TalentApi;
|
|
|
use app\common\api\TalentLogApi;
|
|
@@ -490,4 +494,55 @@ class Api extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function changePwd(){
|
|
|
+ $password = \StrUtil::getRequestDecodeParam($this->request,'password');
|
|
|
+ $newPassword = \StrUtil::getRequestDecodeParam($this->request,'newPassword');
|
|
|
+ //数据校验(原密码与新密码不能为空)
|
|
|
+ if (\StrUtil::isEmpOrNull($password)) {
|
|
|
+ return json(['code' => 500, 'msg' => "请填写原密码!"]);
|
|
|
+ }
|
|
|
+ if (\StrUtil::isEmpOrNull($newPassword)) {
|
|
|
+ return json(['code' => 500, 'msg' => "请填写新密码!"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ validate(Enterprise::class)->batch(true)->scene('changePwd')->check(['password' => $password, 'password' => $newPassword]);
|
|
|
+ $ep = EnterpriseApi::getOne(session("user")['uid']);
|
|
|
+ if(!$ep){
|
|
|
+ return json(['code' => 500, 'msg' => "请刷新页面后重试!"]);
|
|
|
+ }
|
|
|
+ if($ep->password != hash('md5',$password)){
|
|
|
+ return json(['code' => 500, 'msg' => "旧密码不正确!"]);
|
|
|
+ }
|
|
|
+ $ep->password = hash('md5',$newPassword);
|
|
|
+ $ep->updateUser = session("user")['uid'];
|
|
|
+ $ep->updateTime = date("Y-m-d H:i:s");
|
|
|
+ $ep->save();
|
|
|
+
|
|
|
+ TalentChecklog::create([
|
|
|
+ 'id' => getStringId(),
|
|
|
+ 'category' => 'enterprise_change',
|
|
|
+ 'mainId' => $ep->id,
|
|
|
+ 'type' => 10,
|
|
|
+ 'typeField' => null,
|
|
|
+ 'active' => 1,
|
|
|
+ 'state' => 1,
|
|
|
+ 'step' => 100,
|
|
|
+ 'stateChange' => null,
|
|
|
+ 'description' => '用户修改密码',
|
|
|
+ 'createTime' => date("Y-m-d H:i:s",time()),
|
|
|
+ 'createUser' => '用户'
|
|
|
+ ]);
|
|
|
+
|
|
|
+ return json(['code' => 200, 'msg' => "修改成功!"]);
|
|
|
+
|
|
|
+
|
|
|
+ } catch (ValidateException $e){
|
|
|
+ $error = $e->getError();
|
|
|
+ return json(['code' => 500, 'msg' => array_pop($error)]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|