65 changed files with 2068 additions and 850 deletions
@ -1,5 +1,5 @@ |
|||
// Generated by 'unplugin-auto-import'
|
|||
export {} |
|||
declare global { |
|||
|
|||
const ElNotification: typeof import('element-plus/es')['ElNotification'] |
|||
} |
|||
|
|||
@ -0,0 +1,295 @@ |
|||
<template> |
|||
<el-dialog v-model="showDialog" :title="t('addBindingPersonnel')" width="50%" class="diy-dialog-wrap" :destroy-on-close="true"> |
|||
<el-form :inline="true" :model="lessonCourseTeachingTable.searchParam" ref="searchFormRef"> |
|||
<el-form-item :label="t('userName')" prop="title"> |
|||
<el-input v-model="lessonCourseTeachingTable.searchParam.name" :placeholder="t('userName')" /> |
|||
</el-form-item> |
|||
<el-form-item :label="t('userPhone')" prop="status"> |
|||
<el-input v-model="lessonCourseTeachingTable.searchParam.phone" :placeholder="t('userPhone')" /> |
|||
</el-form-item> |
|||
<el-form-item> |
|||
<el-button type="primary" @click="loadLessonCourseTeachingList()">{{ t('search') }}</el-button> |
|||
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button> |
|||
</el-form-item> |
|||
</el-form> |
|||
|
|||
<div class="mt-[10px]"> |
|||
<el-table :data="lessonCourseTeachingTable.data" size="large" v-loading="lessonCourseTeachingTable.loading" @selection-change="handleSelectionChange"> |
|||
<template #empty> |
|||
<span>{{ !lessonCourseTeachingTable.loading ? t('emptyData') : '' }}</span> |
|||
</template> |
|||
<el-table-column type="selection" width="55" /> |
|||
<el-table-column prop="name" :label="t('userName')" min-width="70" :show-overflow-tooltip="true"/> |
|||
<el-table-column prop="phone" :label="t('userPhone')" min-width="120" :show-overflow-tooltip="true"/> |
|||
<el-table-column :label="t('userStatus')" min-width="100" align="center" :show-overflow-tooltip="true"> |
|||
<template #default="{ row }"> |
|||
<div v-if="row.status == 1">待审核</div> |
|||
<div v-if="row.status == 2">已审核</div> |
|||
<div v-if="row.status == 3">已禁用</div> |
|||
</template> |
|||
</el-table-column> |
|||
<el-table-column prop="create_time" :label="t('userCreateTime')" min-width="150" :show-overflow-tooltip="true"/> |
|||
<el-table-column prop="update_time" :label="t('userUpdateTime')" min-width="150" :show-overflow-tooltip="true"/> |
|||
|
|||
<el-table-column :label="t('operation')" fixed="right" min-width="120"> |
|||
<template #default="{ row }"> |
|||
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button> |
|||
<el-button type="primary" link @click="deleteEvent(row.id, 1)">{{ t('delete') }}</el-button> |
|||
</template> |
|||
</el-table-column> |
|||
|
|||
</el-table> |
|||
<div class="mt-[16px] flex justify-end"> |
|||
<el-pagination v-model:current-page="lessonCourseTeachingTable.page" v-model:page-size="lessonCourseTeachingTable.limit" |
|||
layout="total, sizes, prev, pager, next, jumper" :total="lessonCourseTeachingTable.total" |
|||
@size-change="loadLessonCourseTeachingList()" @current-change="loadLessonCourseTeachingList" /> |
|||
</div> |
|||
</div> |
|||
|
|||
<!-- <el-form-item :label="t('bindingModule')" style="margin-top: 15px;">--> |
|||
<!-- <el-select class="w-[280px]" v-model="binding_module" clearable :placeholder="t('bindingModule')">--> |
|||
<!-- <el-option label="课程教学大纲" value="1" />--> |
|||
<!-- <el-option label="跳绳教案库" value="2" />--> |
|||
<!-- <el-option label="增高教案库" value="3" />--> |
|||
<!-- <el-option label="篮球教案库" value="4" />--> |
|||
<!-- <el-option label="强化教案库" value="5" />--> |
|||
<!-- <el-option label="空中忍者教案库" value="6" />--> |
|||
<!-- <el-option label="少儿安防教案库" value="7" />--> |
|||
<!-- <el-option label="体能教案库" value="8" />--> |
|||
<!-- <el-option label="热身动作库" value="9" />--> |
|||
<!-- <el-option label="体能动作库" value="10" />--> |
|||
<!-- <el-option label="趣味游戏库" value="11" />--> |
|||
<!-- <el-option label="放松动作库" value="12" />--> |
|||
<!-- <el-option label="训练内容" value="13" />--> |
|||
<!-- <el-option label="训练视频" value="14" />--> |
|||
<!-- <el-option label="课后作业" value="15" />--> |
|||
<!-- <el-option label="优秀一堂课" value="16" />--> |
|||
<!-- <el-option label="空中忍者" value="17" />--> |
|||
<!-- <el-option label="篮球动作" value="18" />--> |
|||
<!-- <el-option label="跳绳动作" value="19" />--> |
|||
<!-- <el-option label="跑酷动作" value="20" />--> |
|||
<!-- <el-option label="安防动作" value="21" />--> |
|||
<!-- <el-option label="标准化动作" value="22" />--> |
|||
<!-- <el-option label="3-6岁体测" value="23" />--> |
|||
<!-- <el-option label="7+体测" value="24" />--> |
|||
<!-- <el-option label="3-6岁体测讲解—解读" value="25" />--> |
|||
<!-- <el-option label="7+岁体测讲解—解读" value="26" />--> |
|||
<!-- <el-option label="互动游戏" value="27" />--> |
|||
<!-- <el-option label="套圈游戏" value="28" />--> |
|||
<!-- <el-option label="鼓励方式" value="29" />--> |
|||
<!-- </el-select>--> |
|||
<!-- </el-form-item>--> |
|||
|
|||
<template #footer> |
|||
<span class="dialog-footer"> |
|||
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
|||
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
|||
t('confirm') |
|||
}}</el-button> |
|||
</span> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import { ref, reactive, computed, watch } from 'vue' |
|||
import { useDictionary } from '@/app/api/dict' |
|||
import { t } from '@/lang' |
|||
import type { FormInstance } from 'element-plus' |
|||
import { |
|||
addLessonCourseTeaching, |
|||
editLessonCourseTeaching, |
|||
getLessonCourseTeachingInfo, |
|||
getLessonCourseTeachingList, |
|||
getWithPersonnelDataList, |
|||
setBindingModule |
|||
} from '@/app/api/lesson_course_teaching' |
|||
|
|||
let showDialog = ref(false) |
|||
const loading = ref(false) |
|||
|
|||
let lessonCourseTeachingTable = reactive({ |
|||
page: 1, |
|||
limit: 10, |
|||
total: 0, |
|||
loading: true, |
|||
data: [], |
|||
searchParam:{ |
|||
"name":"", |
|||
"phone":"" |
|||
} |
|||
}) |
|||
|
|||
const multipleSelection = ref<[]>([]) |
|||
const binding_module = ref('') |
|||
const handleSelectionChange = (val: []) => { |
|||
multipleSelection.value = val |
|||
} |
|||
|
|||
|
|||
const loadLessonCourseTeachingList = (page: number = 1) => { |
|||
lessonCourseTeachingTable.loading = true |
|||
lessonCourseTeachingTable.page = page |
|||
|
|||
getWithPersonnelDataList({ |
|||
page: lessonCourseTeachingTable.page, |
|||
limit: lessonCourseTeachingTable.limit, |
|||
...lessonCourseTeachingTable.searchParam |
|||
}).then(res => { |
|||
lessonCourseTeachingTable.loading = false |
|||
lessonCourseTeachingTable.data = res.data.data |
|||
lessonCourseTeachingTable.total = res.data.total |
|||
}).catch(() => { |
|||
lessonCourseTeachingTable.loading = false |
|||
}) |
|||
} |
|||
loadLessonCourseTeachingList() |
|||
|
|||
const resetForm = (page: number = 1) => { |
|||
lessonCourseTeachingTable.searchParam.name = '' |
|||
lessonCourseTeachingTable.searchParam.phone = '' |
|||
loadLessonCourseTeachingList() |
|||
} |
|||
|
|||
/** |
|||
* 表单数据 |
|||
*/ |
|||
const initialFormData = { |
|||
id: '', |
|||
title: '', |
|||
image: '', |
|||
type: '', |
|||
content: '', |
|||
status: '' |
|||
// user_permission: [], |
|||
} |
|||
const formData: Record<string, any> = reactive({ ...initialFormData }) |
|||
|
|||
const formRef = ref<FormInstance>() |
|||
|
|||
// 表单验证规则 |
|||
const formRules = computed(() => { |
|||
return { |
|||
title: [ |
|||
{ required: true, message: t('titlePlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
image: [ |
|||
{ required: true, message: t('imagePlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
type: [ |
|||
{ required: true, message: t('typePlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
content: [ |
|||
{ required: true, message: t('contentPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
, |
|||
status: [ |
|||
{ required: true, message: t('statusPlaceholder'), trigger: 'blur' }, |
|||
|
|||
] |
|||
} |
|||
}) |
|||
|
|||
const emit = defineEmits(['complete']) |
|||
|
|||
/** |
|||
* 确认 |
|||
* @param formEl |
|||
*/ |
|||
const confirm = async (formEl: FormInstance | undefined) => { |
|||
let data = { |
|||
id: BindingId.value, |
|||
user_permission: multipleSelection.value.map(item => item.sys_user_id).join(','), |
|||
user_permission_name: multipleSelection.value.map(item => item.name).join(','), |
|||
table_type: binding_module.value, |
|||
} |
|||
setBindingModule(data).then(res => { |
|||
loading.value = false |
|||
showDialog.value = false |
|||
emit('complete') |
|||
}).catch(err => { |
|||
loading.value = false |
|||
}) |
|||
} |
|||
|
|||
// 获取字典数据 |
|||
let typeList = ref([]) |
|||
const typeDictList = async () => { |
|||
typeList.value = await (await useDictionary('material_type')).data.dictionary |
|||
} |
|||
typeDictList(); |
|||
watch(() => typeList.value, () => { formData.type = typeList.value[0].value }) |
|||
let statusList = ref([]) |
|||
const statusDictList = async () => { |
|||
statusList.value = await (await useDictionary('course_status')).data.dictionary |
|||
} |
|||
statusDictList(); |
|||
watch(() => statusList.value, () => { formData.status = statusList.value[0].value }) |
|||
|
|||
|
|||
const userPermissionList = ref([] as any[]) |
|||
const BindingId = ref(undefined) |
|||
const setUserPermissionList = async () => { |
|||
userPermissionList.value = await (await getWithPersonnelDataList({})).data |
|||
} |
|||
setUserPermissionList() |
|||
const setFormData = async (row: any = null) => { |
|||
BindingId.value = row.id |
|||
binding_module.value = row.table_type |
|||
} |
|||
|
|||
// 验证手机号格式 |
|||
const mobileVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
|||
callback(new Error(t('generateMobile'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证身份证号 |
|||
const idCardVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
|||
callback(new Error(t('generateIdCard'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证邮箱号 |
|||
const emailVerify = (rule: any, value: any, callback: any) => { |
|||
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
|||
callback(new Error(t('generateEmail'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
// 验证请输入整数 |
|||
const numberVerify = (rule: any, value: any, callback: any) => { |
|||
if (!Number.isInteger(value)) { |
|||
callback(new Error(t('generateNumber'))) |
|||
} else { |
|||
callback() |
|||
} |
|||
} |
|||
|
|||
defineExpose({ |
|||
showDialog, |
|||
setFormData |
|||
}) |
|||
</script> |
|||
|
|||
<style lang="scss" scoped></style> |
|||
<style lang="scss"> |
|||
.diy-dialog-wrap .el-form-item__label{ |
|||
height: auto !important; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,44 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\dict\member\MemberLoginTypeDict; |
|||
use app\Request; |
|||
use app\service\api\apiService\PersonnelService; |
|||
use app\service\api\captcha\CaptchaService; |
|||
use app\service\api\login\ConfigService; |
|||
use app\service\api\login\LoginService; |
|||
use core\base\BaseApiService; |
|||
use Exception; |
|||
use think\Response; |
|||
|
|||
/** |
|||
* 公共控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class Common extends BaseApiService |
|||
{ |
|||
|
|||
//员工详情 |
|||
public function info(Request $request){ |
|||
//获取员工信息 |
|||
$where = [ |
|||
'id'=>$this->member_id, |
|||
]; |
|||
$res = (new PersonnelService())->info($where); |
|||
if(!$res){ |
|||
return fail('账户信息有误'); |
|||
} |
|||
return success($res); |
|||
} |
|||
} |
|||
@ -0,0 +1,179 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\dict\member\MemberLoginTypeDict; |
|||
use app\Request; |
|||
use app\service\api\apiService\PersonnelService; |
|||
use app\service\api\captcha\CaptchaService; |
|||
use app\service\api\login\ConfigService; |
|||
use app\service\api\login\LoginService; |
|||
use core\base\BaseApiService; |
|||
use Exception; |
|||
use think\Response; |
|||
|
|||
/** |
|||
* 员工端相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class Personnel extends BaseApiService |
|||
{ |
|||
|
|||
//员工详情 |
|||
public function info(Request $request){ |
|||
//获取员工信息 |
|||
$where = [ |
|||
'id'=>$this->member_id, |
|||
]; |
|||
$res = (new PersonnelService())->info($where); |
|||
if(!$res){ |
|||
return fail('账户信息有误'); |
|||
} |
|||
return success($res); |
|||
} |
|||
|
|||
//员工修改 |
|||
public function edit(Request $request){ |
|||
$params = $request->all(); |
|||
$data = [ |
|||
'head_img'=>$params['head_img'],//头像|绝对地址 |
|||
'name'=>$params['name'],//姓名 |
|||
'address'=>$params['address'],//住址 |
|||
'gender'=>$params['gender'],//性别 |
|||
'birthday'=>$params['birthday'],//生日 |
|||
'email'=>$params['email'],//邮箱 |
|||
'phone'=>$params['phone'],//手机号 |
|||
'wx'=>$params['wx'],//微信号 |
|||
]; |
|||
//获取员工信息 |
|||
$where = [ |
|||
'id'=>$this->member_id, |
|||
]; |
|||
$res = (new PersonnelService())->edit($where,$data); |
|||
if(!$res['code']){ |
|||
return fail('操作失败'); |
|||
} |
|||
return success([]); |
|||
} |
|||
|
|||
/** |
|||
* 登录 |
|||
* @return Response |
|||
*/ |
|||
public function login() |
|||
{ |
|||
$data = $this->request->params([ |
|||
['username', ''], |
|||
['password', ''], |
|||
]); |
|||
//校验登录注册配置 |
|||
(new ConfigService())->checkLoginConfig(MemberLoginTypeDict::USERNAME); |
|||
//参数验证 |
|||
//验证码验证 |
|||
$result = (new LoginService())->account($data['username'], $data['password']); |
|||
if (!$result) { |
|||
//账号密码错误, 重置验证码 |
|||
return fail('ACCOUNT_OR_PASSWORD_ERROR'); |
|||
} |
|||
return success($result); |
|||
} |
|||
|
|||
/** |
|||
* 登出 |
|||
* @return Response |
|||
*/ |
|||
public function logout() |
|||
{ |
|||
(new LoginService)->logout(); |
|||
return success('MEMBER_LOGOUT'); |
|||
} |
|||
|
|||
/** |
|||
* 创建验证码 |
|||
* @return Response |
|||
*/ |
|||
public function captcha() |
|||
{ |
|||
return success((new CaptchaService())->create()); |
|||
} |
|||
|
|||
/** |
|||
* 发送手机验证码 |
|||
* @param $type |
|||
* @return Response |
|||
* @throws Exception |
|||
*/ |
|||
public function sendMobileCode($type) |
|||
{ |
|||
$data = $this->request->params([ |
|||
['mobile', ''], |
|||
]); |
|||
return success((new LoginService())->sendMobileCode($data['mobile'], $type)); |
|||
} |
|||
|
|||
/** |
|||
* 手机号登录 |
|||
* @return Response |
|||
*/ |
|||
public function mobile() |
|||
{ |
|||
$data = $this->request->params([ |
|||
['mobile', ''], |
|||
['nickname', ''], |
|||
['headimg', ''], |
|||
['mobile', ''] |
|||
]); |
|||
//校验登录注册配置 |
|||
(new ConfigService())->checkLoginConfig(MemberLoginTypeDict::MOBILE); |
|||
return success((new LoginService())->mobile($data)); |
|||
} |
|||
|
|||
/** |
|||
* 重置密码 |
|||
* @return Response |
|||
*/ |
|||
public function resetPassword() |
|||
{ |
|||
$data = $this->request->params([ |
|||
['mobile', ''], |
|||
['password', ''] |
|||
]); |
|||
//参数验证 |
|||
$this->validate($data, 'app\validate\member\Member.reset_password'); |
|||
(new LoginService())->resetPassword($data['mobile'], $data['password']); |
|||
return success('PASSWORD_RESET_SUCCESS'); |
|||
} |
|||
|
|||
//销售教师人员登陆 |
|||
public function personnelLogin() |
|||
{ |
|||
$data = $this->request->params([ |
|||
['phone', ''], |
|||
['password', ''], |
|||
['login_type', ''],//登陆类型|1=教练,2=销售 |
|||
]); |
|||
//验证码验证 |
|||
$result = (new LoginService())->loginByPersonnel($data); |
|||
|
|||
if(!$result['user_type']){ |
|||
if($data['login_type'] == 1){ |
|||
$msg = '暂无教练权限'; |
|||
}else{ |
|||
$msg = '暂无销售权限'; |
|||
} |
|||
return fail($msg);//code|0错误 |
|||
} |
|||
|
|||
return success($result);//code|1正确 |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\controller\apiController; |
|||
|
|||
use app\dict\member\MemberLoginTypeDict; |
|||
use app\Request; |
|||
use app\service\api\apiService\PersonnelService; |
|||
use app\service\api\captcha\CaptchaService; |
|||
use app\service\api\login\ConfigService; |
|||
use app\service\api\login\LoginService; |
|||
use core\base\BaseApiService; |
|||
use Exception; |
|||
use think\Response; |
|||
|
|||
/** |
|||
* 公共控制器相关接口 |
|||
* Class Personnel |
|||
* @package app\api\controller\apiController |
|||
*/ |
|||
class teachingResearch extends BaseApiService |
|||
{ |
|||
//教研管理列表 |
|||
public function list(){ |
|||
$id = $this->member_id; |
|||
dd($id); |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\api\middleware; |
|||
|
|||
use app\dict\sys\AppTypeDict; |
|||
use app\Request; |
|||
use app\service\api\login\AuthService; |
|||
use app\service\api\login\LoginService; |
|||
use Closure; |
|||
use Exception; |
|||
use core\exception\AuthException; |
|||
|
|||
|
|||
/** |
|||
* 员工端登录token验证 |
|||
* Class ApiCheckToken |
|||
* @package app\api\middleware |
|||
*/ |
|||
class ApiPersonnelCheckToken |
|||
{ |
|||
/** |
|||
* @param Request $request |
|||
* @param Closure $next |
|||
* @param bool $is_throw_exception 是否把错误抛出 |
|||
* @return mixed |
|||
* @throws Exception |
|||
*/ |
|||
public function handle(Request $request, Closure $next, bool $is_throw_exception = false) |
|||
{ |
|||
$request->appType(AppTypeDict::PERSONNEL); |
|||
// 校验渠道 |
|||
( new AuthService() )->checkChannel($request); |
|||
//通过配置来设置系统header参数 |
|||
try { |
|||
$token = $request->apiToken(); |
|||
$token_info = ( new LoginService() )->parsePersonnelToken($token); |
|||
if (!empty($token_info)) { |
|||
$request->memberId($token_info[ 'member_id' ]); |
|||
} |
|||
//校验会员和站点 |
|||
$a= ( new AuthService() )->checkPersonnelMember($request); |
|||
} catch (AuthException $e) { |
|||
//是否将登录错误抛出 |
|||
if ($is_throw_exception) |
|||
return fail($e->getMessage(), [], $e->getCode()); |
|||
} |
|||
return $next($request); |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
<?php |
|||
// +---------------------------------------------------------------------- |
|||
// | Niucloud-admin 企业快速开发的多应用管理平台 |
|||
// +---------------------------------------------------------------------- |
|||
// | 官方网址:https://www.niucloud.com |
|||
// +---------------------------------------------------------------------- |
|||
// | niucloud团队 版权所有 开源版本可自由商用 |
|||
// +---------------------------------------------------------------------- |
|||
// | Author: Niucloud Team |
|||
// +---------------------------------------------------------------------- |
|||
|
|||
namespace app\service\api\apiService; |
|||
|
|||
use app\model\campus_person_role\CampusPersonRole; |
|||
use app\model\departments\Departments; |
|||
use app\model\member\Member; |
|||
use app\model\personnel\Personnel; |
|||
use app\model\sys\SysRole; |
|||
use app\service\core\member\CoreMemberService; |
|||
use core\base\BaseApiService; |
|||
use core\exception\ApiException; |
|||
use core\util\Barcode; |
|||
use think\Model; |
|||
|
|||
/** |
|||
* 员工服务层 |
|||
* Class MemberService |
|||
* @package app\service\api\member |
|||
*/ |
|||
class PersonnelService extends BaseApiService |
|||
{ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
$this->model = new Personnel(); |
|||
} |
|||
|
|||
//获取员工信息 |
|||
public function info(array $where,string $field = '*'){ |
|||
$model = $this->model; |
|||
if(!empty($where['id'])){ |
|||
$model = $model->where('id',$where['id']); |
|||
} |
|||
$res = $model->field($field)->find();//员工信息 |
|||
|
|||
//查询部门信息 |
|||
$campus_person_role = CampusPersonRole::where('person_id',$where['id'])->select()->toArray(); |
|||
$role_id = array_unique(array_column($campus_person_role, 'role_id')); |
|||
$dept_id = array_unique(array_column($campus_person_role, 'dept_id')); |
|||
//查询用户角色 |
|||
$role_name_arr = SysRole::whereIn('role_id',$role_id)->column('role_name'); |
|||
$role_name_str = implode(',',$role_name_arr);// |
|||
|
|||
//查询部门 |
|||
$department_name_arr = Departments::whereIn('id',$dept_id)->column('department_name'); |
|||
$department_name_str = implode(',',$department_name_arr); |
|||
|
|||
|
|||
if($res){ |
|||
$res = $res->toArray(); |
|||
$res['role_name_str'] = $role_name_str; |
|||
$res['department_name_str'] = $department_name_str; |
|||
|
|||
}else{ |
|||
$res = []; |
|||
} |
|||
return $res; |
|||
|
|||
} |
|||
|
|||
//员工信息-修改 |
|||
public function edit(array $where,array $data){ |
|||
$data['update_time'] = date('Y-m-d H:i:s'); |
|||
|
|||
if(!$where){ |
|||
return [ |
|||
'code'=>0, |
|||
'msg'=>'查询条件不能为空' |
|||
]; |
|||
} |
|||
|
|||
$model = $this->model; |
|||
if(!empty($where['id'])){ |
|||
$model = $model->where('id',$where['id']); |
|||
} |
|||
$res = $model->update($data);//员工信息 |
|||
|
|||
if($res){ |
|||
$res = [ |
|||
'code'=>1, |
|||
'msg'=>'操作成功' |
|||
]; |
|||
}else{ |
|||
$res = [ |
|||
'code'=>0, |
|||
'msg'=>'操作失败' |
|||
]; |
|||
} |
|||
return $res; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
/** |
|||
* 获取会员的模型对象(todo 慎用!!! 现主要用于登录) |
|||
* @param array $data |
|||
* @return Member|array|mixed|Model !!! 仔细看,返回值是模型对象 如果想要判断是否为空 请用 $member->isEmpty() |
|||
*/ |
|||
public function findMemberInfo(array $data){ |
|||
//会员账号 |
|||
if(!empty($data['username'])) |
|||
$where[] = ['username', '=', $data['username']]; |
|||
//会员手机号 |
|||
if(!empty($data['mobile'])) |
|||
$where[] = ['mobile', '=', $data['mobile']]; |
|||
//会员id |
|||
if(!empty($data['id'])) |
|||
$where[] = ['id', '=', $data['id']]; |
|||
//微信公众号openid |
|||
if(!empty($data['wx_openid'])) |
|||
$where[] = ['wx_openid', '=', $data['wx_openid']]; |
|||
//微信小程序openid |
|||
if(!empty($data['weapp_openid'])) |
|||
$where[] = ['weapp_openid', '=', $data['weapp_openid']]; |
|||
// 微信unionid |
|||
if(!empty($data['wx_unionid'])) |
|||
$where[] = ['wx_unionid', '=', $data['wx_unionid']]; |
|||
if(!empty($data['username|mobile'])) |
|||
$where[] = ['username|mobile', '=', $data['username|mobile']]; |
|||
if(empty($where)){ |
|||
$where[] = ['member_id', '=', -1]; |
|||
} |
|||
return $this->model->where($where)->findOrEmpty(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue