更新目录结构

This commit is contained in:
2023-10-21 21:18:46 +08:00
parent 664295167d
commit 1153b13299
298 changed files with 3032 additions and 2173 deletions
+41
View File
@@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services;
class FieldService{
public function getFields($model = 'student'){
if(method_exists(new self(), $model)){
return $this->$model();
}else{
return [];
}
}
/**
* @title 学员导入字段
*
* @return void
*/
public function student(){
return ['学生姓名' => 'name', '性别' => 'sex', '电话' => 'mobile', '身份证号码' => 'id_card'];
}
/**
* @title 题库导入字段
*
* @return void
*/
public function exam(){
return [
'题目类型' => 'type_text', '题干' => 'title', '答案' => 'answer', '解析' => 'analysis',
'选项A' => 'A', '选项B' => 'B', '选项C' => 'C', '选项D' => 'D', '选项E' => 'E'
];
}
}
+8 -2
View File
@@ -49,11 +49,11 @@ class RoleService{
}
$role = Roles::find($id);
// 删除权限
PermissionAccess::where('role_id', '=', $role_id)->delete();
PermissionAccess::where('role_id', '=', $id)->delete();
// 删除部门关联
// $role->detachDepartments();
// 删除用户关联
RolesAccess::where('role_id', '=', $role_id)->delete();
RolesAccess::where('role_id', '=', $id)->delete();
// 删除
$role->delete();
}
@@ -73,6 +73,7 @@ class RoleService{
(new PermissionAccess())->saveAll($save);
return true;
}
public function updateRoleAuth($request){
$role_id = $request->param('role_id', '');
$data_range = $request->param('data_range', '');
@@ -87,6 +88,11 @@ class RoleService{
return $role->save($save);
}
public function createRole($request){
$data = $request->param();
return Roles::create($data);
}
public function updateRole($request){
$data = $request->param();
return Roles::update($data);
-119
View File
@@ -1,119 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\company;
use app\model\customer\Company;
use app\model\customer\Contact;
/**
* Undocumented class
*/
class CompanyService {
/**
* @title 获取企业列表
*
* @param [type] $request
* @return void
*/
public function getCompanyList($request) {
$param = $request->param();
$map = [];
if (isset($param['name']) && $param['name']) {
$map[] = ['name', 'LIKE', '%' . $param['name'] . '%'];
}
if (isset($param['org_code']) && $param['org_code']) {
$map[] = ['org_code', '=', $param['org_code']];
}
$list = Company::with(['contact'])->where($map)->order('id desc')->paginate($request->pageConfig);
return $list->append(['area_t', 'industry_t']);
}
/**
* @title 获取企业详情
*
* @param [type] $request
* @return void
*/
public function getCompanyDetail($request) {
$param = $request->param();
if (!isset($param['id'])) {
return [];
}
$map = [];
$map[] = ['id', '=', $param['id']];
$data = Company::with(['contact'])->where($map)->find();
return $data->append(['area_t', 'industry_t']);
}
/**
* @title 导入数据
*
* @return void
*/
public function insertCompanyData($request) {
$data = $request->post('data');
$company = new Company();
$contactM = new Contact();
$resultData = [];
foreach ($data as $k => $item) {
$info = [];
if (!is_array($item)) {
continue;
}
foreach ($item as $key => $value) {
if (isset($company->insertFieldAlis[$key])) {
$info[$company->insertFieldAlis[$key]['table']][$company->insertFieldAlis[$key]['name']] = trim($value);
}
}
$info['company']['uid'] = $info['contact']['uid'] = request()->user['uid'];
if (isset($info['company']) && isset($info['company']['name'])) {
$customer = $company->where('name', '=', trim($info['company']['name']))->find();
$company_id = isset($customer['id']) ? $customer['id'] : 0;
if (!$company_id) {
$info['company']['turnover'] = '';
$info['company']['staff_num'] = '';
$info['company']['come_from'] = '';
$info['company']['company_type'] = '';
$info['company']['pc_count'] = '';
$customer = Company::create($info['company']);
$company_id = $customer->id;
} else {
$save_coustomer = $info['company'];
if (!empty($save_coustomer)) {
$save_coustomer['id'] = $company_id;
$result = $customer->save($save_coustomer);
}
}
if (isset($info['contact']['name'])) {
$map = [];
$map[] = ['name', '=', $info['contact']['name']];
$map[] = ['mobile', '=', isset($info['contact']['mobile']) ? $info['contact']['mobile'] : ''];
$map[] = ['company_id', '=', $company_id];
$contact = $contactM->where($map)->find(); //每次查询重新实例化
$contact_id = isset($contact['id']) ? $contact['id'] : 0;
if (!$contact_id) {
$info['contact']['company_id'] = $company_id;
$res = Contact::create($info['contact']);
$contact_id = $res->id;
} else {
$info['contact']['id'] = $contact_id;
$contact->save($info['contact']);
}
} else {
$contact_id = 0;
}
$resultData[] = ['company_id' => $company_id, 'contact_id' => (int) $contact_id, 'company' => $info['company'], 'contact' => $info['contact']];
}
}
return empty($resultData) ? false : $resultData;
}
}
+81
View File
@@ -0,0 +1,81 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\Ads;
class AdsService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = Ads::where($map)->order($order)->append(['status_text', 'photo'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
$data['user_id'] = $request->user['uid'];
return Ads::create($data);
}
/**
* @title 编辑广告
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$ads = Ads::find($data['id']);
return $ads->save($data);
}
/**
* @title 删除广告
*
* @param [type] $request
* @return void
*/
public function delete($request){
$id = $request->post('id', 0);
if(!$id){
throw new \think\Exception("非法操作!", 1);
}
return Ads::where('id', $id)->delete();
}
public function getAdsDetail($request){
$name = $request->param('name', '');
return Ads::where('name', $name)->append(['photo'])->find();
}
}
@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\ClientConfig;
class ClientConfigService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = ClientConfig::where($map)->order($order)->append(['status_text'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
return ClientConfig::create($data);
}
/**
* @title 编辑配置
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$config = ClientConfig::find($data['id']);
$config->save($data);
return $config;
}
/**
* @title 删除配置
*
* @param [type] $request
* @return void
*/
public function delete($request){
$data = $request->param();
$config = ClientConfig::find($data['id']);
return $config->delete();
}
}
@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\ClientMenu;
class ClientMenuService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = ClientMenu::where($map)->order($order)->append(['status_text'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
$data['user_id'] = $request->user['uid'];
return ClientMenu::create($data);
}
/**
* @title 编辑广告
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$menu = ClientMenu::find($data['id']);
return $client->save($data);
}
/**
* @title 删除配置
*
* @param [type] $request
* @return void
*/
public function delete($request){
$data = $request->param();
$menu = ClientMenu::find($data['id']);
return $menu->delete();
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\operate;
use app\model\operate\Client;
class ClientService{
/**
* @title 获取广告
*
* @param [type] $request
* @return void
*/
public function getDataList($request){
$param = $request->param();
$order = "id desc";
$map = [];
if(isset($param['title']) && $param['title'] != ''){
$map[] = ['title', 'LIKE', '%' . $param['title'] . '%'];
}
if(isset($param['name']) && $param['name'] != ''){
$map[] = ['name', '=', $param['name']];
}
$list = Client::with(['setting'])->where($map)->order($order)->append(['status_text'])->paginate($request->pageConfig);
return $list;
}
/**
* @title 添加广告
*
* @param [type] $request
* @return void
*/
public function create($request){
$data = $request->param();
$data['user_id'] = $request->user['uid'];
return Client::create($data);
}
/**
* @title 编辑广告
*
* @param [type] $request
* @return void
*/
public function update($request){
$data = $request->param();
$client = Client::find($data['id']);
return $client->save($data);
}
public function getClientMenu($request){
$param = $request->param();
$list = [];
if(isset($param['type'])){
if($param['type'] == 'home'){
$list = [
['title' => '常考题', 'image' => request()->static() . 'images/icon/5.jpg', 'url' => '/pages/exam/index/index'],
['title' => '模拟考', 'image' => request()->static() . 'images/icon/6.jpg', 'url' => '/pages/exam/index/index'],
['title' => '题库练习', 'image' => request()->static() . 'images/icon/7.jpg', 'url' => '/pages/exam/index/index'],
['title' => '易错题', 'image' => request()->static() . 'images/icon/8.jpg', 'url' => '/pages/exam/index/index'],
['title' => '我的错题', 'image' => request()->static() . 'images/icon/10.png', 'url' => '/pages/exam/my/index', 'desc' => '巩固错题,轻轻松松过考'],
['title' => '我的收藏', 'image' => request()->static() . 'images/icon/9.png', 'url' => '/pages/exam/my/index', 'desc' => '您收藏的题目,都在这里'],
];
}else{
$list = [
['title' => '我的资料', 'icon' => 'profile', 'iconColor' => 'green', 'url' => '/pages/ucenter/profile/index'],
['title' => '我的报名', 'icon' => 'edit', 'iconColor' => 'green', 'url' => '/pages/ucenter/enter/index'],
['title' => '我的记录', 'icon' => 'list', 'iconColor' => 'green', 'url' => '/pages/ucenter/exam/index'],
['title' => '我的订单', 'icon' => 'shop', 'iconColor' => 'green', 'url' => '/pages/ucenter/order/index'],
['title' => '邀请推广', 'icon' => 'qrcode', 'iconColor' => 'green', 'url' => '/pages/ucenter/invite/index'],
['title' => '关于我们', 'icon' => 'info', 'iconColor' => 'green', 'url' => '/pages/ucenter/about/index'],
];
}
}
return $list;
}
}
+14
View File
@@ -30,6 +30,20 @@ class DictionaryService{
$list = Dictionary::where($map)->order('id desc')->paginate($request->pageConfig);
return $list;
}
/**
* @title 所有字典数据
*
* @return void
*/
public function getDictionaryAll(){
$list = Dictionary::where([])->select();
$data = [];
foreach($list as $value){
$data[$value['dic_type']][] = $value->toArray();
}
return $data;
}
/**
* @title 获取字典明细
*
+60
View File
@@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace app\services\wechat;
use EasyWeChat\Factory;
use think\facade\Config;
use app\model\student\Student;
use app\model\student\Wechat;
class OauthService{
public function oauth($request){
$code = $request->post('code');
$config = Config::get('wechat.miniapp');
$app = Factory::miniProgram($config);
try {
//获取openid
$session_code = $app->auth->session($code);
$wechat = Wechat::where('openid', '=', $session_code['openid'])->findOrEmpty();
if($wechat->isEmpty()){
$userInfo = $app->encryptor->decryptData($session_code['session_key'], $request->post('iv'), $request->post('encrypted'));
$data = [
'headimgurl' => $userInfo['avatarUrl'],
'nickname' => $userInfo['nickName'],
'openid'=> $userInfo['openId'],
'sex' => $userInfo['gender'],
'city' => $userInfo['city'],
'country' => $userInfo['country'],
'province' => $userInfo['province'],
'language' => $userInfo['language']
];
$wechat = Wechat::create($data);
}
if($wechat['uid'] > 0){
$wechat['users'] = Student::with(['enter'])->visible(['name', 'mobile', 'sex', 'address', 'id', 'id_card', 'invite_id', 'exam_num', 'incorrect_num', 'point'])->find($wechat['uid'])->append(['token']);
}
return $wechat;
} catch (\Exception $e) {
throw new \think\Exception($e->getMessage(), 100);
}
}
public function getQrCode($request){
$config = Config::get('wechat.miniapp');
$app = Factory::miniProgram($config);
$res = $app->url_link->generate([]);
return $res;
}
}