mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-15 13:22:49 +00:00
perf: 签到设置保存
This commit is contained in:
parent
be262c3a69
commit
a8361299c7
@ -1661,8 +1661,6 @@ class UsersController extends AbstractController
|
|||||||
$list = UserCheckinMac::whereUserid($user->userid)->orderBy('id')->get();
|
$list = UserCheckinMac::whereUserid($user->userid)->orderBy('id')->get();
|
||||||
$userface = UserCheckinFace::whereUserid($user->userid)->first();
|
$userface = UserCheckinFace::whereUserid($user->userid)->first();
|
||||||
|
|
||||||
// 组装数据
|
|
||||||
// TODO 如何获取http连接
|
|
||||||
$data = [
|
$data = [
|
||||||
'list' => $list,
|
'list' => $list,
|
||||||
'faceimg' => $userface ? Base::fillUrl($userface->faceimg) : ''
|
'faceimg' => $userface ? Base::fillUrl($userface->faceimg) : ''
|
||||||
@ -1693,12 +1691,19 @@ class UsersController extends AbstractController
|
|||||||
if ($setting['open'] !== 'open') {
|
if ($setting['open'] !== 'open') {
|
||||||
return Base::retError('此功能未开启,请联系管理员开启');
|
return Base::retError('此功能未开启,请联系管理员开启');
|
||||||
}
|
}
|
||||||
if ($setting['edit'] !== 'open') {
|
if ($setting['edit'] !== 'open' && $setting['faceupload'] !== 'open') {
|
||||||
return Base::retError('未开放修改权限,请联系管理员');
|
return Base::retError('未开放修改权限,请联系管理员');
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
$list = Request::input('list');
|
$list = Request::input('list');
|
||||||
$faceimg = Request::input('faceimg');
|
$faceimg = Request::input('faceimg');
|
||||||
|
// 默认返回值,使用用户传递数据
|
||||||
|
$data = [
|
||||||
|
'list' => $list,
|
||||||
|
'faceimg' => $faceimg
|
||||||
|
];
|
||||||
|
// 当mac允许修改
|
||||||
|
if ($setting['edit' === 'open']) {
|
||||||
$array = [];
|
$array = [];
|
||||||
if (empty($list) || !is_array($list)) {
|
if (empty($list) || !is_array($list)) {
|
||||||
return Base::retError('参数错误');
|
return Base::retError('参数错误');
|
||||||
@ -1716,31 +1721,23 @@ class UsersController extends AbstractController
|
|||||||
if (count($array) > 3) {
|
if (count($array) > 3) {
|
||||||
return Base::retError('最多只能添加3个MAC地址');
|
return Base::retError('最多只能添加3个MAC地址');
|
||||||
}
|
}
|
||||||
// TODO 后续考虑是否单独写一个接口
|
|
||||||
if ($setting['faceupload'] !== 'open' && $faceimg != '') {
|
|
||||||
return Base::retError('未开放修改权限,请联系管理员');
|
|
||||||
}
|
|
||||||
if ($setting['faceupload'] === 'open') {
|
|
||||||
try{
|
|
||||||
$saveFaceRes = UserCheckinFace::saveFace($user->userid, $user->nickname(), $faceimg, "用户上传");
|
|
||||||
if ($saveFaceRes['ret'] == 0) {
|
|
||||||
return $saveFaceRes;
|
|
||||||
}
|
|
||||||
} catch(\Throwable) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$saveMacRes = UserCheckinMac::saveMac($user->userid, $array);
|
$saveMacRes = UserCheckinMac::saveMac($user->userid, $array);
|
||||||
|
$data['list'] = $saveMacRes['data'];
|
||||||
|
} else {
|
||||||
|
$list = UserCheckinMac::whereUserid($user->userid)->orderBy('id')->get();
|
||||||
|
$data['list'] = $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
// 当图片允许修改
|
||||||
'list' => $saveMacRes['data'],
|
if ($setting['faceupload'] === 'open') {
|
||||||
'faceimg' => $faceimg
|
UserCheckinFace::saveFace($user->userid, $user->nickname(), $faceimg, "用户上传");
|
||||||
];
|
} else {
|
||||||
$saveMacRes['data'] = $data;
|
$userface = UserCheckinFace::whereUserid($user->userid)->first();
|
||||||
return $saveMacRes;
|
$data['faceimg'] = $userface;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Base::retSuccess('修改成功', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -52,21 +52,15 @@ class UserCheckinFace extends AbstractModel
|
|||||||
$data['record'] = $record;
|
$data['record'] = $record;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = Ihttp::ihttp_post($url, json_encode($data));
|
$res = Ihttp::ihttp_post($url, json_encode($data), 15);
|
||||||
if($res['data'] && $data = json_decode($res['data'])){
|
if($res['data'] && $data = json_decode($res['data'])){
|
||||||
if($data->ret != 1 && $data->msg){
|
if($data->ret != 1 && $data->msg){
|
||||||
return Base::retError($data->msg);
|
throw new ApiException($data->msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return AbstractModel::transaction(function() use ($userid, $faceimg, $remark) {
|
return AbstractModel::transaction(function() use ($userid, $faceimg, $remark) {
|
||||||
// self::updateInsert([
|
|
||||||
// 'userid' => $userid,
|
|
||||||
// 'faceimg' => $faceimg,
|
|
||||||
// 'status' => 1,
|
|
||||||
// 'remark' => $remark
|
|
||||||
// ]);
|
|
||||||
$checkinFace = self::query()->whereUserid($userid)->first();
|
$checkinFace = self::query()->whereUserid($userid)->first();
|
||||||
if ($checkinFace) {
|
if ($checkinFace) {
|
||||||
self::updateData(['id' => $checkinFace->id], [
|
self::updateData(['id' => $checkinFace->id], [
|
||||||
@ -87,7 +81,7 @@ class UserCheckinFace extends AbstractModel
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Base::retSuccess('上传成功');
|
return Base::retSuccess('设置成功');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,13 +89,14 @@ class UserCheckinFace extends AbstractModel
|
|||||||
$url = 'http://' . env('APP_IPPR') . '.55' . ":7788/user/delete";
|
$url = 'http://' . env('APP_IPPR') . '.55' . ":7788/user/delete";
|
||||||
$data = [
|
$data = [
|
||||||
'enrollid' => $userid,
|
'enrollid' => $userid,
|
||||||
'backupnum' => 50,
|
'backupnum' => 50, // 13 删除整个用户 50 删除图片
|
||||||
];
|
];
|
||||||
|
|
||||||
$res = Ihttp::ihttp_post($url, json_encode($data));
|
$res = Ihttp::ihttp_post($url, json_encode($data));
|
||||||
if($res['data'] && $data = json_decode($res['data'])){
|
if($res['data'] && $data = json_decode($res['data'])){
|
||||||
if($data->ret != 1 && $data->msg){
|
if($data->ret != 1 && $data->msg){
|
||||||
return Base::retError($data->msg);
|
throw new ApiException($data->msg);
|
||||||
|
// return Base::retError($data->msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user