|
@@ -4,7 +4,7 @@ namespace app\api\controller\company;
|
|
|
|
|
|
use app\common\controller\Apic;
|
|
|
use think\Db;
|
|
|
-
|
|
|
+use fast\Random;
|
|
|
/**
|
|
|
* 员工管理
|
|
|
*/
|
|
@@ -25,12 +25,20 @@ class Staff extends Apic
|
|
|
//新增
|
|
|
public function add(){
|
|
|
$data = [
|
|
|
- 'truename' => input('truename',''),
|
|
|
- 'mobile' => input('mobile',''),
|
|
|
+ 'truename' => input('truename',''),
|
|
|
+ 'mobile' => input('mobile',''),
|
|
|
'company_id' => $this->auth->company_id,
|
|
|
- 'type' => 2,
|
|
|
+ 'type' => 2,
|
|
|
];
|
|
|
|
|
|
+ //密码
|
|
|
+ $password = input('password','123456');
|
|
|
+ $salt = Random::alnum();
|
|
|
+ $newpassword = $this->getEncryptPassword($password, $salt);
|
|
|
+ $data['password'] = $newpassword;
|
|
|
+ $data['salt'] = $salt;
|
|
|
+
|
|
|
+
|
|
|
//检查
|
|
|
$check2 = Db::name('company_staff')->where('mobile',$data['mobile'])->find();
|
|
|
if($check2){
|
|
@@ -41,6 +49,17 @@ class Staff extends Apic
|
|
|
$this->success('添加成功');
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取密码加密后的字符串
|
|
|
+ * @param string $password 密码
|
|
|
+ * @param string $salt 密码盐
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getEncryptPassword($password, $salt = '')
|
|
|
+ {
|
|
|
+ return md5(md5($password) . $salt);
|
|
|
+ }
|
|
|
+
|
|
|
//详情
|
|
|
public function info(){
|
|
|
$id = input('id',0);
|
|
@@ -56,6 +75,13 @@ class Staff extends Apic
|
|
|
'mobile' => input('mobile',''),
|
|
|
];
|
|
|
|
|
|
+ //密码
|
|
|
+ $password = input('password','123456');
|
|
|
+ $salt = Random::alnum();
|
|
|
+ $newpassword = $this->getEncryptPassword($password, $salt);
|
|
|
+ $data['password'] = $newpassword;
|
|
|
+ $data['salt'] = $salt;
|
|
|
+
|
|
|
//检查
|
|
|
$check2 = Db::name('company_staff')->where('id','neq',$id)->where('mobile',$data['mobile'])->find();
|
|
|
if($check2){
|