开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
标签 (10)
master
version1
v3.8.31
v3.6.24
v3.3.02
v3.1.12
v3.0.12
v2.7.01
v2.6.01
v2.5.15
v1.04.28
v1.0424
master
分支 (2)
标签 (10)
master
version1
v3.8.31
v3.6.24
v3.3.02
v3.1.12
v3.0.12
v2.7.01
v2.6.01
v2.5.15
v1.04.28
v1.0424
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
标签 (10)
master
version1
v3.8.31
v3.6.24
v3.3.02
v3.1.12
v3.0.12
v2.7.01
v2.6.01
v2.5.15
v1.04.28
v1.0424
dev
/
app
/
api
/
controller
/
Index.php
dev
/
app
/
api
/
controller
/
Index.php
Index.php 11.70 KB
一键复制 编辑 原始数据 按行查看 历史
勾股开源 提交于 2023年06月24日 17:44 +08:00 . 1、升级:layui升级到最新的2.8.8版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
<?php
/**
* @copyright Copyright (c) 2022 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\api\controller;
use app\api\BaseController;
use think\facade\Db;
class Index extends BaseController
{
//上传文件
public function upload()
{
$param = get_params();
if (request()->file('file')) {
$file = request()->file('file');
} else {
return to_assign(1, '没有选择上传文件');
}
// dump($file);die;
// 获取上传文件的hash散列值
$sha1 = $file->hash('sha1');
$md5 = $file->hash('md5');
$rule = [
'image' => 'jpg,png,jpeg,gif',
'doc' => 'txt,doc,docx,ppt,pptx,xls,xlsx,pdf',
'file' => 'zip,gz,7z,rar,tar',
'video' => 'mpg,mp4,mpeg,avi,wmv,mov,flv,m4v',
];
$fileExt = $rule['image'] . ',' . $rule['doc'] . ',' . $rule['file'] . ',' . $rule['video'];
//1M=1024*1024=1048576字节
$fileSize = 100 * 1024 * 1024;
if (isset($param['type']) && $param['type']) {
$fileExt = $rule[$param['type']];
}
if (isset($param['size']) && $param['size']) {
$fileSize = $param['size'];
}
$validate = \think\facade\Validate::rule([
'image' => 'require|fileSize:' . $fileSize . '|fileExt:' . $fileExt,
]);
$file_check['image'] = $file;
if (!$validate->check($file_check)) {
return to_assign(1, $validate->getError());
}
// 日期前綴
$dataPath = date('Ym');
$use = 'thumb';
$filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) {
return $md5;
});
if ($filename) {
//写入到附件表
$data = [];
$path = get_config('filesystem.disks.public.url');
$data['filepath'] = $path . '/' . $filename;
$data['name'] = $file->getOriginalName();
$data['mimetype'] = $file->getOriginalMime();
$data['fileext'] = $file->extension();
$data['filesize'] = $file->getSize();
$data['filename'] = $filename;
$data['sha1'] = $sha1;
$data['md5'] = $md5;
$data['module'] = \think\facade\App::initialize()->http->getName();
$data['action'] = app('request')->action();
$data['uploadip'] = app('request')->ip();
$data['create_time'] = time();
$data['user_id'] = $this->uid;
if ($data['module'] = 'admin') {
//通过后台上传的文件直接审核通过
$data['status'] = 1;
$data['admin_id'] = $data['user_id'];
$data['audit_time'] = time();
}
$data['use'] = request()->has('use') ? request()->param('use') : $use; //附件用处
$res['id'] = Db::name('file')->insertGetId($data);
$res['filepath'] = $data['filepath'];
$res['name'] = $data['name'];
$res['filename'] = $data['filename'];
$res['filesize'] = $data['filesize'];
add_log('upload', $data['user_id'], $data);
return to_assign(0, '上传成功', $res);
} else {
return to_assign(1, '上传失败,请重试');
}
}
//编辑器图片上传
public function md_upload()
{
$param = get_params();
if (request()->file('editormd-image-file')) {
$file = request()->file('editormd-image-file');
} else {
return to_assign(1, '没有选择上传文件');
}
// dump($file);die;
// 获取上传文件的hash散列值
$sha1 = $file->hash('sha1');
$md5 = $file->hash('md5');
$rule = [
'image' => 'jpg,png,jpeg,gif',
'doc' => 'doc,docx,ppt,pptx,xls,xlsx,pdf',
'file' => 'zip,gz,7z,rar,tar',
];
$fileExt = $rule['image'] . ',' . $rule['doc'] . ',' . $rule['file'];
//1M=1024*1024=1048576字节
$fileSize = 2 * 1024 * 1024;
if (isset($param['type']) && $param['type']) {
$fileExt = $rule[$param['type']];
}
if (isset($param['size']) && $param['size']) {
$fileSize = $param['size'];
}
$validate = \think\facade\Validate::rule([
'image' => 'require|fileSize:' . $fileSize . '|fileExt:' . $fileExt,
]);
$file_check['image'] = $file;
if (!$validate->check($file_check)) {
return to_assign(1, $validate->getError());
}
// 日期前綴
$dataPath = date('Ym');
$use = 'thumb';
$filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) {
return $md5;
});
if ($filename) {
//写入到附件表
$data = [];
$path = get_config('filesystem.disks.public.url');
$data['filepath'] = $path . '/' . $filename;
$data['name'] = $file->getOriginalName();
$data['mimetype'] = $file->getOriginalMime();
$data['fileext'] = $file->extension();
$data['filesize'] = $file->getSize();
$data['filename'] = $filename;
$data['sha1'] = $sha1;
$data['md5'] = $md5;
return json(['success' => 1, 'message' => '上传成功', 'url' => $data['filepath']]);
} else {
return json(['success' => 0, 'message' => '上传失败', 'url' => '']);
}
}
//清空缓存
public function cache_clear()
{
\think\facade\Cache::clear();
return to_assign(0, '系统缓存已清空');
}
//获取部门树形节点列表
public function get_department_tree()
{
$department = get_department();
$list = get_tree($department, 0, 2);
$data['trees'] = $list;
return json($data);
}
//获取部门树形节点列表2
public function get_department_select()
{
$keyword = get_params('keyword');
$selected = [];
if (!empty($keyword)) {
$selected = explode(",", $keyword);
}
$department = get_department();
$list = get_select_tree($department, 0, 0, $selected);
return to_assign(0, '', $list);
}
//获取子部门所有员工
public function get_employee($did = 0)
{
$did = get_params('did');
/*
if ($did == 1) {
$department = $did;
} else {
$department = get_department_son($did);
}
*/
$department = get_department_son($did);
$employee = Db::name('admin')
->field('a.id,a.did,a.position_id,a.mobile,a.name,a.nickname,a.sex,a.status,a.thumb,a.username,d.title as department')
->alias('a')
->join('Department d', 'a.did = d.id')
->where(['a.status' => 1])
->where('a.did', "in", $department)
->select();
return to_assign(0, '', $employee);
}
//获取部门所有员工
public function get_employee_select()
{
$employee = Db::name('admin')->field('id as value,name')->where(['status' => 1])->select();
return to_assign(0, '', $employee);
}
//获取角色列表
public function get_position()
{
$position = Db::name('Position')->field('id,title as name')->where([['status', '=', 1], ['id', '>', 1]])->select();
return to_assign(0, '', $position);
}
//获取工作类型列表
public function get_work()
{
$cate = Db::name('WorkCate')->field('id,title')->where([['status', '=', 1]])->select();
return to_assign(0, '', $cate);
}
//获取任务类型列表
public function get_task_cate()
{
$cate = Db::name('TaskCate')->field('id,title')->where([['status', '=', 1]])->select();
return to_assign(0, '', $cate);
}
//获取产品列表
public function get_product()
{
$map1 = [
['admin_id', '=', $this->uid],
];
$map2 = [
['director_uid', '=', $this->uid],
];
$map3 = [
['', 'exp', Db::raw("FIND_IN_SET({$this->uid},check_admin_ids)")],
];
$map4 = [
['is_open', '=', 2],
];
$whereOr=[];
if(is_super($this->pid) == 0){
$whereOr =[$map1,$map2,$map3,$map4];
}
$product = Db::name('Product')->field('id,name as title')
->where(function ($query) use ($whereOr) {
if (!empty($whereOr))
$query->whereOr($whereOr);
})
->where('delete_time', 0)->select();
return to_assign(0, '', $product);
}
//获取项目列表
public function get_project($pid = 0)
{
$where = [];
$where[] = ['delete_time', '=', 0];
if ($pid > 0) {
$where[] = ['product_id', '=', $pid];
}
if(is_super($this->pid) == 0){
$project_ids = Db::name('ProjectUser')->where(['uid' => $this->uid, 'delete_time' => 0])->column('project_id');
$where[]=['id', 'in', $project_ids];
}
$project = Db::name('Project')->field('id,name as title')->where($where)->select();
return to_assign(0, '', $project);
}
//文档列表
public function get_doc_list($kid = 0, $tree = 0)
{
if ($tree == 2) {
$list = Db::name('knowledgeDoc')->where(['knowledge_id' => $kid, 'delete_time' => 0])
->field('id,pid as pId,title as name,type,link,knowledge_id,sort,read')
->order('sort asc,id asc')
->select();
return to_assign(0, '', $list);
} else {
$list = Db::name('knowledgeDoc')->where(['knowledge_id' => $kid, 'delete_time' => 0])
->field('id,pid,title,type,knowledge_id,sort,read')
->order('sort asc,id asc')
->select();
if ($tree == 1) {
foreach ($list as $k => &$v) {
$v['title'] = sub_str($v['title'], 9);
}
$tree = get_tree($list, 0, 4);
$data['trees'] = $tree;
return json($data);
} else {
return to_assign(0, '', $list);
}
}
}
//删除消息附件
public function del_message_interfix()
{
$id = get_params("id");
$detail = Db::name('MessageFileInterfix')->where('id', $id)->find();
if ($detail['admin_id'] == $this->uid) {
if (Db::name('MessageFileInterfix')->where('id', $id)->delete() !== false) {
$data = Db::name('MessageFileInterfix')->where('mid', $detail['mid'])->column('file_id');
return to_assign(0, "删除成功", $data);
} else {
return to_assign(1, "删除失败");
}
} else {
return to_assign(1, "您没权限删除该消息附件");
}
}
// 测试邮件发送
public function email_test()
{
$sender = get_params('email');
//检查是否邮箱格式
if (!is_email($sender)) {
return to_assign(1, '测试邮箱码格式有误');
}
$email_config = \think\facade\Db::name('config')->where('name', 'email')->find();
$config = unserialize($email_config['content']);
$content = $config['template'];
//所有项目必须填写
if (empty($config['smtp']) || empty($config['smtp_port']) || empty($config['smtp_user']) || empty($config['smtp_pwd'])) {
return to_assign(1, '请完善邮件配置信息!');
}
$send = send_email($sender, '测试邮件', $content);
if ($send) {
return to_assign(0, '邮件发送成功!');
} else {
return to_assign(1, '邮件发送失败!');
}
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

🔥🔥🔥勾股DEV是一款任务管理与团队协作的任务/项目管理系统,可以进行工作任务计划、执行、管理,完整地覆盖了项目管理的核心流程。支持多产品,多项目管理,支持任务分发,工时统计等。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/viking_code/dev.git
git@gitee.com:viking_code/dev.git
viking_code
dev
勾股DEV项目任务协作系统
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /