Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projecttwo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangtao
projecttwo
Commits
833afb02
Commit
833afb02
authored
May 20, 2025
by
wangtao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
业务板块api接口
parent
44347432
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
495 additions
and
16 deletions
+495
-16
CourseTeacher.php
app/api/controller/manage/CourseTeacher.php
+12
-0
CourseUserWork.php
app/api/controller/manage/CourseUserWork.php
+79
-0
ShCourse.php
app/api/controller/manage/ShCourse.php
+43
-5
ShCourseClass.php
app/api/controller/manage/ShCourseClass.php
+21
-1
ShCourseClassCategory.php
app/api/controller/manage/ShCourseClassCategory.php
+105
-0
ShCourseWork.php
app/api/controller/manage/ShCourseWork.php
+103
-0
UtilService.php
app/api/service/UtilService.php
+18
-0
CourseUserWorkValidate.php
app/api/validate/CourseUserWorkValidate.php
+25
-0
ShCourseClassCategoryValidate.php
app/api/validate/ShCourseClassCategoryValidate.php
+22
-0
ShCourseWorkValidate.php
app/api/validate/ShCourseWorkValidate.php
+27
-0
CourseUserWork.php
app/model/CourseUserWork.php
+39
-9
app.php
config/app.php
+1
-1
No files found.
app/api/controller/manage/CourseTeacher.php
View file @
833afb02
...
...
@@ -79,4 +79,16 @@ class CourseTeacher extends BaseController
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//讲师详情
public
function
CourseTeacherDetail
(
Request
$request
)
{
$vo
=
(
new
CourseTeacherValidate
())
->
goCheck
([
'teacher_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$info
=
CourseTeacherModel
::
find
(
$parm
[
'teacher_id'
])
->
append
([
'thumbpath'
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$info
);
}
}
\ No newline at end of file
app/api/controller/manage/CourseUserWork.php
0 → 100644
View file @
833afb02
<?php
namespace
app\api\controller\manage
;
use
app\api\middleware\Auth
;
use
app\api\service\UtilService
;
use
app\api\validate\CourseUserWorkValidate
;
use
app\BaseController
;
use
app\model\CertTag
;
use
app\model\CourseUserWork
as
CourseUserWorkModel
;
use
app\Request
;
class
CourseUserWork
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
//学员作业列表
public
function
getCourseUserWorkList
(
Request
$request
)
{
$vo
=
(
new
CourseUserWorkValidate
())
->
goCheck
([
'work_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$map
=
[];
$where
=
[
'course_user_work.is_del'
=>
0
,
'work_id'
=>
$parm
[
'work_id'
]];
if
(
isset
(
$parm
[
'searchnickname'
])
&&
$parm
[
'searchnickname'
])
{
$map
[]
=
[
'username|mobile'
,
'like'
,
'%'
.
$parm
[
'searchnickname'
]
.
'%'
];
}
$page
=
$request
->
param
(
'page'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize'
,
10
);
$list
=
CourseUserWorkModel
::
where
(
$where
)
->
where
(
'course_user_work.status'
,
'>'
,
0
)
->
hasWhere
(
'userprofile'
,
$map
)
->
order
(
'createtime desc'
)
->
with
([
'userprofile'
])
->
append
([
'status_text'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//学员作业详情
public
function
getCourseUserWorkDetail
(
Request
$request
)
{
$vo
=
(
new
CourseUserWorkValidate
())
->
goCheck
([
'user_work_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$info
=
CourseUserWorkModel
::
where
(
'id'
,
$parm
[
'user_work_id'
])
->
with
([
'userprofile'
,
'course'
,
'courseWork'
])
->
append
([
'status_text'
,
'filelist'
])
->
find
(
$parm
[
'user_work_id'
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$info
);
}
//学员作业考核
public
function
shenheCourseUserWork
(
Request
$request
)
{
$vo
=
(
new
CourseUserWorkValidate
())
->
goCheck
([
'user_work_id'
,
'status'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$updatedata
[
'status'
]
=
$parm
[
'status'
];
$updatedata
[
'note'
]
=
$parm
[
'note'
];
$result
=
CourseUserWorkModel
::
where
(
'id'
,
$parm
[
'user_work_id'
])
->
update
(
$updatedata
);
return
$this
->
returnMsg
(
'success'
,
1
,
$result
);
}
}
\ No newline at end of file
app/api/controller/manage/ShCourse.php
View file @
833afb02
...
...
@@ -6,8 +6,10 @@ use app\api\middleware\Auth;
use
app\api\service\UtilService
;
use
app\api\validate\ShCourseValidate
;
use
app\BaseController
;
use
app\model\CertTag
;
use
app\model\ShCourse
as
ShCourseModel
;
use
app\Request
;
use
think\facade\Db
;
class
ShCourse
extends
BaseController
{
...
...
@@ -44,11 +46,22 @@ class ShCourse extends BaseController
$list
=
ShCourseModel
::
where
(
$where
)
->
where
(
$map
)
->
field
(
'id,title,createtime,thumb,tag_ids,price,status,is_sell,is_del,tvclick,click,cate_id,teacher_id'
)
->
order
(
'createtime desc'
)
->
append
([
'thumbpath'
,
'cate_name'
,
't
ag_title'
,
't
eacher_name'
,
'status_text'
])
->
append
([
'thumbpath'
,
'cate_name'
,
'teacher_name'
,
'status_text'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
$list
=
UtilService
::
listWithTags
(
$list
,
(
\app\model\CourseTag
::
class
),
'tag_ids'
);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//获取课程列表 作业 课时 选择时用
public
function
selectShCourseList
(
Request
$request
)
{
$where
=
[
'is_del'
=>
0
,
'user_id'
=>
$request
->
userId
];
$list
=
ShCourseModel
::
where
(
$where
)
->
field
(
'id,title'
)
->
select
();
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
...
...
@@ -75,9 +88,21 @@ class ShCourse extends BaseController
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$where
=
[
'id'
=>
$parm
[
'course_id'
],
'user_id'
=>
$request
->
userId
];
$result
=
ShCourseModel
::
where
(
$where
)
->
update
([
'is_del'
=>
1
]);
// 启动事务
Db
::
startTrans
();
try
{
$parm
=
$request
->
param
();
$where
=
[
'id'
=>
$parm
[
'course_id'
],
'user_id'
=>
$request
->
userId
];
$result
=
ShCourseModel
::
where
(
$where
)
->
update
([
'is_del'
=>
1
]);
\app\model\ShCourseClassCategory
::
where
(
'course_id'
,
$parm
[
'course_id'
])
->
update
([
'is_del'
=>
1
]);
//删除章节
\app\model\ShCourseClass
::
where
(
'course_id'
,
$parm
[
'course_id'
])
->
update
([
'is_del'
=>
1
]);
//删除课时
\app\model\ShCourseWork
::
where
(
'course_id'
,
$parm
[
'course_id'
])
->
update
([
'is_del'
=>
1
]);
//删除作业
Db
::
commit
();
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
return
$this
->
returnMsg
(
$e
->
getMessage
());
}
event
(
'Course'
,
[
'course_id'
=>
$parm
[
'course_id'
],
'tasktype'
=>
'course'
,
'action'
=>
'shcourseupdate'
]);
//同步数据
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
...
...
@@ -90,7 +115,7 @@ class ShCourse extends BaseController
return
$vo
;
}
$parm
=
$request
->
param
();
$parm
[
'sn'
]
=
UtilService
::
generateOrderNo
(
$request
->
userId
,
'K'
);
$parm
[
'sn'
]
=
UtilService
::
generate
Compact
OrderNo
(
$request
->
userId
,
'K'
);
$parm
[
'createtime'
]
=
time
();
$parm
[
'user_id'
]
=
$request
->
userId
;
$result
=
ShCourseModel
::
create
(
$parm
);
...
...
@@ -114,6 +139,19 @@ class ShCourse extends BaseController
}
//课程详情
public
function
ShCourseDetail
(
Request
$request
)
{
$vo
=
(
new
ShCourseValidate
())
->
goCheck
([
'course_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$info
=
ShCourseModel
::
find
(
$parm
[
'course_id'
])
->
append
([
'thumbpath'
,
'cate_name'
,
'teacher_name'
,
'status_text'
]);
$info
=
UtilService
::
infoWithTags
(
$info
,
(
\app\model\CourseTag
::
class
),
'tag_ids'
);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$info
);
}
}
\ No newline at end of file
app/api/controller/manage/ShCourseClass.php
View file @
833afb02
...
...
@@ -7,6 +7,7 @@ use app\api\validate\ShCourseClassValidate;
use
app\BaseController
;
use
app\Request
;
use
app\model\ShCourseClass
as
ShCourseClassModel
;
use
app\model\ShCourse
;
class
ShCourseClass
extends
BaseController
{
...
...
@@ -26,6 +27,7 @@ class ShCourseClass extends BaseController
$parm
[
'createtime'
]
=
time
();
$parm
[
'user_id'
]
=
$request
->
userId
;
$result
=
ShCourseClassModel
::
create
(
$parm
);
ShCourse
::
where
(
'id'
,
$parm
[
'course_id'
])
->
update
([
'status'
=>
0
]);
//待提交
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
...
...
@@ -41,6 +43,7 @@ class ShCourseClass extends BaseController
$updatedata
=
$parm
;
unset
(
$updatedata
[
'course_class_id'
]);
$result
=
ShCourseClassModel
::
where
([
'user_id'
=>
$request
->
userId
,
'id'
=>
$parm
[
'course_class_id'
]])
->
update
(
$updatedata
);
ShCourse
::
where
(
'id'
,
$parm
[
'course_id'
])
->
update
([
'status'
=>
0
]);
//待提交
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
...
...
@@ -71,12 +74,15 @@ class ShCourseClass extends BaseController
if
(
isset
(
$parm
[
'is_sell'
])
&&
$parm
[
'is_sell'
])
{
$map
[]
=
[
'is_sell'
,
'='
,
$parm
[
'is_sell'
]];
}
if
(
isset
(
$parm
[
'cate_id'
])
&&
$parm
[
'cate_id'
]){
$map
[]
=
[
'cate_id'
,
'='
,
$parm
[
'cate_id'
]];
}
$page
=
$request
->
param
(
'page'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize'
,
10
);
$where
=
[
'is_del'
=>
0
,
'user_id'
=>
$request
->
userId
];
$list
=
ShCourseClassModel
::
where
(
$where
)
->
where
(
$map
)
->
order
(
'createtime desc'
)
->
append
([
'
thumbpath
'
])
->
append
([
'
course_class_cate'
,
'course_title
'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
...
...
@@ -101,4 +107,18 @@ class ShCourseClass extends BaseController
}
//课时详情
public
function
ShCourseDetail
(
Request
$request
)
{
$vo
=
(
new
ShCourseClassValidate
())
->
goCheck
([
'course_class_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$info
=
ShCourseClassModel
::
find
(
$parm
[
'course_class_id'
])
->
append
([
'tvfilepath'
,
'course_class_cate'
,
'course_title'
]);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$info
);
}
}
\ No newline at end of file
app/api/controller/manage/ShCourseClassCategory.php
0 → 100644
View file @
833afb02
<?php
namespace
app\api\controller\manage
;
use
app\api\middleware\Auth
;
use
app\api\validate\ShCourseClassCategoryValidate
;
use
app\BaseController
;
use
app\model\ShCourse
;
use
app\model\ShCourseClassCategory
as
ShCourseCategoryModel
;
use
app\Request
;
class
ShCourseClassCategory
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
//添加章节
public
function
createShCourseClassCategory
(
Request
$request
)
{
$vo
=
(
new
ShCourseClassCategoryValidate
())
->
goCheck
([
'course_id'
,
'title'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$parm
[
'createtime'
]
=
time
();
$parm
[
'user_id'
]
=
$request
->
userId
;
$result
=
ShCourseCategoryModel
::
create
(
$parm
);
if
(
$result
){
ShCourse
::
where
(
'id'
,
$parm
[
'course_id'
])
->
update
([
'status'
=>
0
]);
//待提交
}
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
//修改章节
public
function
editShCourseClassCategory
(
Request
$request
)
{
$vo
=
(
new
ShCourseClassCategoryValidate
())
->
goCheck
([
'course_id'
,
'title'
,
'cate_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$udpatedata
=
$parm
;
unset
(
$udpatedata
[
'cate_id'
]);
$result
=
ShCourseCategoryModel
::
where
([
'user_id'
=>
$request
->
userId
,
'id'
=>
$parm
[
'cate_id'
]])
->
update
(
$udpatedata
);
if
(
$result
){
ShCourse
::
where
(
'id'
,
$parm
[
'course_id'
])
->
update
([
'status'
=>
0
]);
//待提交
}
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
//章节列表
public
function
ShCourseClassCategoryList
(
Request
$request
)
{
$parm
=
$request
->
param
();
$where
=
[
'is_del'
=>
0
,
'user_id'
=>
$request
->
userId
];
$map
=
[];
if
(
isset
(
$parm
[
'searchKeyWords'
])
&&
$parm
[
'searchKeyWords'
])
{
$map
[]
=
[
'title'
,
'like'
,
'%'
.
$parm
[
'searchKeyWords'
]
.
'%'
];
}
$page
=
$request
->
param
(
'page'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize'
,
10
);
$list
=
ShCourseCategoryModel
::
where
(
$where
)
->
where
(
$map
)
->
order
(
'createtime desc'
)
->
append
([
'course_title'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//删除章节
public
function
deleteShCourseClassCategory
(
Request
$request
)
{
$vo
=
(
new
ShCourseClassCategoryValidate
())
->
goCheck
([
'cate_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$where
=
[
'id'
=>
$parm
[
'cate_id'
],
'user_id'
=>
$request
->
userId
];
$result
=
ShCourseCategoryModel
::
where
(
$where
)
->
update
([
'is_del'
=>
1
]);
$course_id
=
ShCourseCategoryModel
::
where
([
'id'
=>
$parm
[
'cate_id'
]])
->
value
(
'course_id'
);
event
(
'Course'
,
[
'course_id'
=>
$course_id
,
'tasktype'
=>
'course'
,
'action'
=>
'shcourseupdate'
]);
//同步数据
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
//章节详情
public
function
detailShCourseClassCategory
(
Request
$request
)
{
$vo
=
(
new
ShCourseClassCategoryValidate
())
->
goCheck
([
'cate_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$info
=
ShCourseCategoryModel
::
find
(
$parm
[
'cate_id'
])
->
append
([
'course_title'
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$info
);
}
}
\ No newline at end of file
app/api/controller/manage/ShCourseWork.php
0 → 100644
View file @
833afb02
<?php
namespace
app\api\controller\manage
;
use
app\api\middleware\Auth
;
use
app\api\service\UtilService
;
use
app\api\validate\ShCourseWorkValidate
;
use
app\BaseController
;
use
app\model\CertTag
;
use
app\model\ShCourse
;
use
app\model\ShCourseWork
as
ShCourseWorkModel
;
use
app\Request
;
class
ShCourseWork
extends
BaseController
{
protected
$middleware
=
[
Auth
::
class
,
];
//添加作业
public
function
createShCourseWork
(
Request
$request
)
{
$vo
=
(
new
ShCourseWorkValidate
())
->
goCheck
([
'course_id'
,
'title'
,
'content'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$parm
[
'createtime'
]
=
time
();
$parm
[
'sn'
]
=
UtilService
::
generateCompactOrderNo
(
$request
->
userId
,
'Z'
);
$parm
[
'user_id'
]
=
$request
->
userId
;
$result
=
ShCourseWorkModel
::
create
(
$parm
);
ShCourse
::
where
(
'id'
,
$parm
[
'course_id'
])
->
update
([
'status'
=>
0
]);
//待提交
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
//作业列表
public
function
getShCourseWorkList
(
Request
$request
)
{
$parm
=
$request
->
param
();
$map
=
[];
$where
=
[
'is_del'
=>
0
,
'user_id'
=>
$request
->
userId
];
if
(
isset
(
$parm
[
'searchKeyWords'
])
&&
$parm
[
'searchKeyWords'
])
{
$map
[]
=
[
'title'
,
'like'
,
'%'
.
$parm
[
'searchKeyWords'
]
.
'%'
];
}
$page
=
$request
->
param
(
'page'
,
1
);
$pageSize
=
$request
->
param
(
'pageSize'
,
10
);
$list
=
ShCourseWorkModel
::
where
(
$where
)
->
where
(
$map
)
->
order
(
'createtime desc'
)
->
append
([
'course_title'
])
->
paginate
([
'page'
=>
$page
,
'list_rows'
=>
$pageSize
]);
return
$this
->
returnMsg
(
'success'
,
1
,
$list
);
}
//修改作业
public
function
editShCourseWork
(
Request
$request
)
{
$vo
=
(
new
ShCourseWorkValidate
())
->
goCheck
([
'course_id'
,
'title'
,
'content'
,
'work_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$udpatedata
=
$parm
;
unset
(
$udpatedata
[
'work_id'
]);
$udpatedata
[
'updatetime'
]
=
time
();
$result
=
ShCourseWorkModel
::
where
([
'user_id'
=>
$request
->
userId
,
'id'
=>
$parm
[
'work_id'
]])
->
update
(
$udpatedata
);
ShCourse
::
where
(
'id'
,
$parm
[
'course_id'
])
->
update
([
'status'
=>
0
]);
//待提交
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
//作业详情
public
function
detailShCourseWork
(
Request
$request
){
$vo
=
(
new
ShCourseWorkValidate
())
->
goCheck
([
'work_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$info
=
ShCourseWorkModel
::
find
(
$parm
[
'work_id'
])
->
append
([
'filelist'
]);
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$info
);
}
//删除作业
public
function
deleteShCourseWork
(
Request
$request
)
{
$vo
=
(
new
ShCourseWorkValidate
())
->
goCheck
([
'work_id'
]);
if
(
$vo
!==
true
)
{
return
$vo
;
}
$parm
=
$request
->
param
();
$where
=
[
'id'
=>
$parm
[
'work_id'
],
'user_id'
=>
$request
->
userId
];
$result
=
ShCourseWorkModel
::
where
(
$where
)
->
update
([
'is_del'
=>
1
]);
$course_id
=
ShCourseWorkModel
::
where
([
'id'
=>
$parm
[
'work_id'
]])
->
value
(
'course_id'
);
event
(
'Course'
,
[
'course_id'
=>
$course_id
,
'tasktype'
=>
'course'
,
'action'
=>
'shcourseupdate'
]);
//同步数据
return
$this
->
returnMsg
(
'操作成功'
,
1
,
$result
);
}
}
\ No newline at end of file
app/api/service/UtilService.php
View file @
833afb02
...
...
@@ -81,4 +81,22 @@ class UtilService
}
return
true
;
}
public
static
function
infoWithTags
(
$info
,
string
$modelClass
,
string
$tagIdsField
=
'tag_ids'
)
:
array
{
$allTagIds
=
explode
(
','
,
$info
[
$tagIdsField
]);;
$tags
=
[];
if
(
!
empty
(
$allTagIds
))
{
$tags
=
$modelClass
::
where
(
'is_del'
,
0
)
->
whereIn
(
'id'
,
array_unique
(
$allTagIds
))
->
field
(
'id,title'
)
->
select
()
->
toArray
();
}
$result
=
$info
->
toArray
();
$result
[
'tags'
]
=
$tags
;
return
$result
;
}
}
\ No newline at end of file
app/api/validate/CourseUserWorkValidate.php
0 → 100644
View file @
833afb02
<?php
namespace
app\api\validate
;
use
think\Validate
;
class
CourseUserWorkValidate
extends
BaseValidate
{
protected
$rule
=
[
'work_id'
=>
'require'
,
'user_work_id'
=>
'require'
,
'status'
=>
'require'
,
];
protected
$message
=
[
'work_id.require'
=>
'作业id不能为空'
,
'user_work_id.require'
=>
'作业id不能为空'
,
'status.require'
=>
'请选择考核'
];
}
\ No newline at end of file
app/api/validate/ShCourseClassCategoryValidate.php
0 → 100644
View file @
833afb02
<?php
namespace
app\api\validate
;
use
think\Validate
;
class
ShCourseClassCategoryValidate
extends
BaseValidate
{
protected
$rule
=
[
'course_id'
=>
'require'
,
'title'
=>
'require'
,
'cate_id'
=>
'require'
,
];
protected
$message
=
[
'course_id.require'
=>
'课程id不能为空'
,
'title.require'
=>
'课程名称不能为空'
,
'cate_id.require'
=>
'章节id不能为空'
,
];
}
\ No newline at end of file
app/api/validate/ShCourseWorkValidate.php
0 → 100644
View file @
833afb02
<?php
namespace
app\api\validate
;
use
think\Validate
;
class
ShCourseWorkValidate
extends
BaseValidate
{
protected
$rule
=
[
'course_id'
=>
'require'
,
'title'
=>
'require'
,
'content'
=>
'require'
,
'work_id'
=>
'require'
,
];
protected
$message
=
[
'course_id.require'
=>
'课程id不能为空'
,
'title.require'
=>
'作业标题不能为空'
,
'content.require'
=>
'作业介绍不能为空'
,
'work_id.require'
=>
'作业id不能为空'
];
}
\ No newline at end of file
app/model/CourseUserWork.php
View file @
833afb02
...
...
@@ -23,10 +23,10 @@ class CourseUserWork extends Model
* @return array
* @throws \think\db\exception\DbException
*/
public
static
function
workList
(
$userId
,
$page
=
1
,
$pageSize
=
10
)
public
static
function
workList
(
$userId
,
$page
=
1
,
$pageSize
=
10
)
{
return
self
::
where
([
'user_id'
=>
$userId
,
'is_del'
=>
0
])
->
with
([
'course'
,
'courseWork'
])
return
self
::
where
([
'user_id'
=>
$userId
,
'is_del'
=>
0
])
->
with
([
'course'
,
'courseWork'
])
->
field
(
'id,user_id,work_id,status,course_id,createtime'
)
->
paginate
([
'page'
=>
$page
,
...
...
@@ -44,7 +44,7 @@ class CourseUserWork extends Model
*/
public
static
function
workDetail
(
$id
)
{
$detail
=
self
::
where
([
'id'
=>
$id
,
'is_del'
=>
0
])
$detail
=
self
::
where
([
'id'
=>
$id
,
'is_del'
=>
0
])
->
with
([
'course'
,
'courseWork'
])
->
field
(
'id,user_id,work_id,status,course_id,createtime'
)
->
findOrEmpty
();
...
...
@@ -88,23 +88,53 @@ class CourseUserWork extends Model
* @param $attachment_ids
* @return CourseUserWork
*/
public
static
function
uploadWork
(
$workId
,
$attachment_ids
)
public
static
function
uploadWork
(
$workId
,
$attachment_ids
)
{
return
self
::
where
([
'id'
=>
$workId
,
'status'
=>
0
,
'is_del'
=>
0
])
->
update
([
'attachment_ids'
=>
$attachment_ids
,
'status'
=>
1
]);
return
self
::
where
([
'id'
=>
$workId
,
'status'
=>
0
,
'is_del'
=>
0
])
->
update
([
'attachment_ids'
=>
$attachment_ids
,
'status'
=>
1
]);
}
//关联作业
public
function
courseWork
()
{
return
$this
->
hasOne
(
CourseWork
::
class
,
'id'
,
'work_id'
)
->
where
(
'is_del'
,
0
)
->
field
(
'id,title,file_id_str'
);
return
$this
->
hasOne
(
CourseWork
::
class
,
'id'
,
'work_id'
)
->
append
([
'filelist'
])
->
where
(
'is_del'
,
0
)
->
field
(
'id,title,file_id_str'
);
}
//关联课程
public
function
course
()
{
return
$this
->
hasOne
(
Course
::
class
,
'id'
,
'course_id'
)
->
where
(
'is_del'
,
0
)
->
field
(
'id,title'
);
return
$this
->
hasOne
(
Course
::
class
,
'id'
,
'course_id'
)
->
where
(
'is_del'
,
0
)
->
field
(
'id,title'
);
}
//关联用户学校
public
function
userprofile
()
{
return
$this
->
belongsTo
(
\app\model\project\User
::
class
,
'user_id'
)
->
where
(
'is_del'
,
0
)
->
field
(
'id,username,mobile,realname'
);
}
public
function
getFilelistAttr
(
$value
,
$data
)
{
return
get_upload_file
(
$data
[
'attachment_ids'
],
'list'
);
}
public
function
getStatusTextAttr
(
$value
,
$data
)
{
switch
(
$data
[
'status'
])
{
case
1
:
$text
=
'未考核'
;
break
;
case
2
:
$text
=
'已通过考核'
;
break
;
case
3
:
$text
=
'未通过考核'
;
break
;
default
;
$text
=
'未提交'
;
}
return
$text
;
}
}
\ No newline at end of file
config/app.php
View file @
833afb02
...
...
@@ -32,5 +32,5 @@ return [
'error_message'
=>
'页面错误!请稍后再试~'
,
// 显示错误信息
'show_error_msg'
=>
false
,
'file_http_url'
=>
'http://192.168.4.
35
:8082'
,
'file_http_url'
=>
'http://192.168.4.
28
:8082'
,
];
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment