You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tianze-pro/web/src/main/resources/sql/jlw/teacherOpenCourseChatLog.md

627 lines
17 KiB
Markdown

3 years ago
queryByCondition
===
* 根据不为空的参数进行分页查询
select
@pageTag(){
t.*
3 years ago
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
,(select count(1) from teacher_open_course_chat_log a
where a.teacher_open_course_chat_log_status = 1
2 years ago
and teacher_open_course_chat_log_id = #teacherOpenCourseChatLogParentId#
3 years ago
) as comment_count
@}
3 years ago
@}
from teacher_open_course_chat_log t
where 1=1
@//数据权限该sql语句功能点,如果不考虑数据权限,可以删除此行
and #function("teacherOpenCourseChatLog.query")#
@if(!isEmpty(teacherOpenCourseChatLogId)){
and t.teacher_open_course_chat_log_id =#teacherOpenCourseChatLogId#
@}
@if(!isEmpty(teacherOpenCourseChatLogIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_id,#teacherOpenCourseChatLogIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
and t.teacher_open_course_chat_log_parent_id =#teacherOpenCourseChatLogParentId#
@}
@if(!isEmpty(teacherOpenCourseChatLogParentIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_parent_id,#teacherOpenCourseChatLogParentIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseId)){
and t.teacher_open_course_id =#teacherOpenCourseId#
@}
@if(!isEmpty(teacherOpenCourseIdPlural)){
and find_in_set(t.teacher_open_course_id,#teacherOpenCourseIdPlural#)
@}
3 years ago
@if(!isEmpty(schoolClassIds)){
and t.school_class_ids =#schoolClassIds#
3 years ago
@}
@if(!isEmpty(teacherId)){
and t.teacher_id =#teacherId#
@}
@if(!isEmpty(teacherIdPlural)){
and find_in_set(t.teacher_id,#teacherIdPlural#)
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#studentIdPlural#)
@}
@if(!isEmpty(chatContent)){
and t.chat_content =#chatContent#
@}
@if(!isEmpty(keywords)){
and t.keywords like #"%"+keywords+"%"#
3 years ago
@}
@if(!isEmpty(studentScore)){
and t.student_score =#studentScore#
@}
@if(!isEmpty(chatFiles)){
and t.chat_files =#chatFiles#
@}
@if(!isEmpty(chatLogSendType)){
and find_in_set(t.chat_log_send_type, #chatLogSendType#)
@}
3 years ago
@if(isEmpty(teacherOpenCourseChatLogStatus) && isEmpty(teacherOpenCourseChatLogStatusPlural)){
and t.teacher_open_course_chat_log_status != 2
@}else{
@if(!isEmpty(teacherOpenCourseChatLogStatus)){
and t.teacher_open_course_chat_log_status =#teacherOpenCourseChatLogStatus#
@}else if(!isEmpty(teacherOpenCourseChatLogStatusPlural)){
and find_in_set(t.teacher_open_course_chat_log_status,#teacherOpenCourseChatLogStatusPlural#)
@}
@}
@if(!isEmpty(teacherOpenCourseChatLogAddTime)){
and t.teacher_open_course_chat_log_add_time =#teacherOpenCourseChatLogAddTime#
3 years ago
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(orgIdPlural)){
and find_in_set(t.org_id,#orgIdPlural#)
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(userIdPlural)){
and find_in_set(t.user_id,#userIdPlural#)
@}
3 years ago
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
3 years ago
@pageIgnoreTag(){
order by teacher_open_course_chat_log_add_time desc
@}
3 years ago
@}
@if(!isEmpty(replyStatus)){
and
@// 待回复的消息
@if(replyStatus == 1) {
NOT
@}
@if(replyStatus == 1) {
@// 这里留空,代表查询已回复的消息
@}
EXISTS (
SELECT
1
FROM
teacher_open_course_chat_log ta
WHERE
ta.teacher_open_course_chat_log_parent_id = t.teacher_open_course_chat_log_id
AND ta.teacher_open_course_chat_log_status = 1
)
@}
3 years ago
queryByConditionQuery
===
* 根据不为空的参数进行分页查询(无权限)
select
@pageTag(){
t.*
@}
from teacher_open_course_chat_log t
where 1=1
@if(!isEmpty(teacherOpenCourseChatLogId)){
and t.teacher_open_course_chat_log_id =#teacherOpenCourseChatLogId#
@}
@if(!isEmpty(teacherOpenCourseChatLogIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_id,#teacherOpenCourseChatLogIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
and t.teacher_open_course_chat_log_parent_id =#teacherOpenCourseChatLogParentId#
@}
@if(!isEmpty(teacherOpenCourseChatLogParentIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_parent_id,#teacherOpenCourseChatLogParentIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseId)){
and t.teacher_open_course_id =#teacherOpenCourseId#
@}
@if(!isEmpty(teacherOpenCourseIdPlural)){
and find_in_set(t.teacher_open_course_id,#teacherOpenCourseIdPlural#)
@}
3 years ago
@if(!isEmpty(schoolClassIds)){
and t.school_class_ids =#schoolClassIds#
3 years ago
@}
@if(!isEmpty(teacherId)){
and t.teacher_id =#teacherId#
@}
@if(!isEmpty(teacherIdPlural)){
and find_in_set(t.teacher_id,#teacherIdPlural#)
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#studentIdPlural#)
@}
@if(!isEmpty(chatContent)){
and t.chat_content =#chatContent#
@}
@if(!isEmpty(keywords)){
and t.keywords like #"%"+keywords+"%"#
3 years ago
@}
@if(!isEmpty(studentScore)){
and t.student_score =#studentScore#
@}
@if(!isEmpty(chatFiles)){
and t.chat_files =#chatFiles#
@}
@if(!isEmpty(chatLogSendType)){
and find_in_set(t.chat_log_send_type, #chatLogSendType#)
@}
3 years ago
@if(isEmpty(teacherOpenCourseChatLogStatus) && isEmpty(teacherOpenCourseChatLogStatusPlural)){
and t.teacher_open_course_chat_log_status != 2
@}else{
@if(!isEmpty(teacherOpenCourseChatLogStatus)){
and t.teacher_open_course_chat_log_status =#teacherOpenCourseChatLogStatus#
@}else if(!isEmpty(teacherOpenCourseChatLogStatusPlural)){
and find_in_set(t.teacher_open_course_chat_log_status,#teacherOpenCourseChatLogStatusPlural#)
@}
@}
@if(!isEmpty(teacherOpenCourseChatLogAddTime)){
and t.teacher_open_course_chat_log_add_time =#teacherOpenCourseChatLogAddTime#
3 years ago
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(orgIdPlural)){
and find_in_set(t.org_id,#orgIdPlural#)
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(userIdPlural)){
and find_in_set(t.user_id,#userIdPlural#)
@}
deleteTeacherOpenCourseChatLogByIds
===
3 years ago
* 批量删除(假删除)
update teacher_open_course_chat_log set teacher_open_course_chat_log_status = 2 where find_in_set(teacher_open_course_chat_log_id,#ids#)
deleteByIds
===
* 批量删除(真删除)
3 years ago
delete from teacher_open_course_chat_log where find_in_set(teacher_open_course_chat_log_id,#ids#)
getByIds
===
select * from teacher_open_course_chat_log where find_in_set(teacher_open_course_chat_log_id,#ids#)
updateGivenByIds
===
* 批量更新指定字段,无论此字段是否有值
update teacher_open_course_chat_log
set
@if(contain("teacherOpenCourseChatLogParentId",_given)){
@if(isEmpty(teacherOpenCourseChatLogParentId)){
teacher_open_course_chat_log_parent_id = null ,
@}else{
teacher_open_course_chat_log_parent_id = #teacherOpenCourseChatLogParentId# ,
@}
@}
@if(contain("teacherOpenCourseId",_given)){
@if(isEmpty(teacherOpenCourseId)){
teacher_open_course_id = null ,
@}else{
teacher_open_course_id = #teacherOpenCourseId# ,
@}
@}
3 years ago
@if(contain("schoolClassIds",_given)){
@if(isEmpty(schoolClassIds)){
school_class_ids = null ,
3 years ago
@}else{
3 years ago
school_class_ids = #schoolClassIds# ,
3 years ago
@}
@}
@if(contain("teacherId",_given)){
@if(isEmpty(teacherId)){
teacher_id = null ,
@}else{
teacher_id = #teacherId# ,
@}
@}
@if(contain("studentId",_given)){
@if(isEmpty(studentId)){
student_id = null ,
@}else{
student_id = #studentId# ,
@}
@}
@if(contain("chatContent",_given)){
@if(isEmpty(chatContent)){
chat_content = null ,
@}else{
chat_content = #chatContent# ,
@}
@}
@if(contain("keywords",_given)){
@if(isEmpty(keywords)){
keywords = null ,
@}else{
keywords = #keywords# ,
@}
@}
@if(contain("studentScore",_given)){
@if(isEmpty(studentScore)){
student_score = null ,
@}else{
student_score = #studentScore# ,
@}
@}
@if(contain("chatFiles",_given)){
@if(isEmpty(chatFiles)){
chat_files = null ,
@}else{
chat_files = #chatFiles# ,
@}
@}
@if(contain("chatLogSendType",_given)){
@if(isEmpty(chatLogSendType)){
chat_log_send_type = null ,
@}else{
chat_log_send_type = #chatLogSendType# ,
@}
@}
3 years ago
@if(contain("teacherOpenCourseChatLogStatus",_given)){
@if(isEmpty(teacherOpenCourseChatLogStatus)){
teacher_open_course_chat_log_status = null ,
3 years ago
@}else{
3 years ago
teacher_open_course_chat_log_status = #teacherOpenCourseChatLogStatus# ,
@}
@}
@if(contain("teacherOpenCourseChatLogAddTime",_given)){
@if(isEmpty(teacherOpenCourseChatLogAddTime)){
teacher_open_course_chat_log_add_time = null ,
@}else{
teacher_open_course_chat_log_add_time = #teacherOpenCourseChatLogAddTime# ,
3 years ago
@}
@}
@if(contain("orgId",_given)){
@if(isEmpty(orgId)){
org_id = null ,
@}else{
org_id = #orgId# ,
@}
@}
@if(contain("userId",_given)){
@if(isEmpty(userId)){
user_id = null ,
@}else{
user_id = #userId# ,
@}
@}
teacher_open_course_chat_log_id = teacher_open_course_chat_log_id
where find_in_set(teacher_open_course_chat_log_id,#teacherOpenCourseChatLogIdPlural#)
getTeacherOpenCourseChatLogValues
===
* 根据不为空的参数进行查询
select t.*
from teacher_open_course_chat_log t
where 1=1
@if(!isEmpty(teacherOpenCourseChatLogId)){
and t.teacher_open_course_chat_log_id =#teacherOpenCourseChatLogId#
@}
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
and t.teacher_open_course_chat_log_parent_id =#teacherOpenCourseChatLogParentId#
@}
@if(!isEmpty(teacherOpenCourseId)){
and t.teacher_open_course_id =#teacherOpenCourseId#
@}
3 years ago
@if(!isEmpty(schoolClassIds)){
and t.school_class_ids =#schoolClassIds#
3 years ago
@}
@if(!isEmpty(teacherId)){
and t.teacher_id =#teacherId#
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(chatContent)){
and t.chat_content =#chatContent#
@}
@if(!isEmpty(keywords)){
and t.keywords like #"%"+keywords+"%"#
3 years ago
@}
@if(!isEmpty(studentScore)){
and t.student_score =#studentScore#
@}
@if(!isEmpty(chatFiles)){
and t.chat_files =#chatFiles#
@}
@if(!isEmpty(chatLogSendType)){
and find_in_set(t.chat_log_send_type, #chatLogSendType#)
@}
3 years ago
@if(!isEmpty(teacherOpenCourseChatLogStatus)){
and t.teacher_open_course_chat_log_status =#teacherOpenCourseChatLogStatus#
@}else{
and t.teacher_open_course_chat_log_status != 2
@}
@if(!isEmpty(teacherOpenCourseChatLogAddTime)){
and t.teacher_open_course_chat_log_add_time =#teacherOpenCourseChatLogAddTime#
3 years ago
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
getValuesByQuery
===
* 根据不为空的参数进行查询
select t.*
from teacher_open_course_chat_log t
where 1=1 and #function("teacherOpenCourseChatLog.query")#
@if(!isEmpty(teacherOpenCourseChatLogId)){
and t.teacher_open_course_chat_log_id =#teacherOpenCourseChatLogId#
@}
@if(!isEmpty(teacherOpenCourseChatLogIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_id,#teacherOpenCourseChatLogIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
and t.teacher_open_course_chat_log_parent_id =#teacherOpenCourseChatLogParentId#
@}
@if(!isEmpty(teacherOpenCourseChatLogParentIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_parent_id,#teacherOpenCourseChatLogParentIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseId)){
and t.teacher_open_course_id =#teacherOpenCourseId#
@}
@if(!isEmpty(teacherOpenCourseIdPlural)){
and find_in_set(t.teacher_open_course_id,#teacherOpenCourseIdPlural#)
@}
@if(!isEmpty(schoolClassIds)){
and t.school_class_ids =#schoolClassIds#
@}
@if(!isEmpty(teacherId)){
and t.teacher_id =#teacherId#
@}
@if(!isEmpty(teacherIdPlural)){
and find_in_set(t.teacher_id,#teacherIdPlural#)
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#studentIdPlural#)
@}
@if(!isEmpty(chatContent)){
and t.chat_content =#chatContent#
@}
@if(!isEmpty(keywords)){
and t.keywords like #"%"+keywords+"%"#
@}
@if(!isEmpty(studentScore)){
and t.student_score =#studentScore#
@}
@if(!isEmpty(chatFiles)){
and t.chat_files =#chatFiles#
@}
@if(!isEmpty(chatLogSendType)){
and find_in_set(t.chat_log_send_type, #chatLogSendType#)
@}
@if(isEmpty(teacherOpenCourseChatLogStatus) && isEmpty(teacherOpenCourseChatLogStatusPlural)){
and t.teacher_open_course_chat_log_status != 2
@}else{
@if(!isEmpty(teacherOpenCourseChatLogStatus)){
and t.teacher_open_course_chat_log_status =#teacherOpenCourseChatLogStatus#
@}else if(!isEmpty(teacherOpenCourseChatLogStatusPlural)){
and find_in_set(t.teacher_open_course_chat_log_status,#teacherOpenCourseChatLogStatusPlural#)
@}
@}
@if(!isEmpty(teacherOpenCourseChatLogAddTime)){
and t.teacher_open_course_chat_log_add_time =#teacherOpenCourseChatLogAddTime#
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(orgIdPlural)){
and find_in_set(t.org_id,#orgIdPlural#)
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(userIdPlural)){
and find_in_set(t.user_id,#userIdPlural#)
@}
getValuesByQueryNotWithPermission
===
* 根据不为空的参数进行查询(不包含权限)
select t.*
from teacher_open_course_chat_log t
where 1=1
@if(!isEmpty(teacherOpenCourseChatLogId)){
and t.teacher_open_course_chat_log_id =#teacherOpenCourseChatLogId#
@}
@if(!isEmpty(teacherOpenCourseChatLogIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_id,#teacherOpenCourseChatLogIdPlural#)
3 years ago
@}
@if(!isEmpty(teacherOpenCourseChatLogParentId)){
and t.teacher_open_course_chat_log_parent_id =#teacherOpenCourseChatLogParentId#
@}
@if(!isEmpty(teacherOpenCourseChatLogParentIdPlural)){
and find_in_set(t.teacher_open_course_chat_log_parent_id,#teacherOpenCourseChatLogParentIdPlural#)
@}
@if(!isEmpty(teacherOpenCourseId)){
and t.teacher_open_course_id =#teacherOpenCourseId#
@}
@if(!isEmpty(teacherOpenCourseIdPlural)){
and find_in_set(t.teacher_open_course_id,#teacherOpenCourseIdPlural#)
@}
3 years ago
@if(!isEmpty(schoolClassIds)){
and t.school_class_ids =#schoolClassIds#
3 years ago
@}
@if(!isEmpty(teacherId)){
and t.teacher_id =#teacherId#
@}
@if(!isEmpty(teacherIdPlural)){
and find_in_set(t.teacher_id,#teacherIdPlural#)
@}
@if(!isEmpty(studentId)){
and t.student_id =#studentId#
@}
@if(!isEmpty(studentIdPlural)){
and find_in_set(t.student_id,#studentIdPlural#)
@}
@if(!isEmpty(chatContent)){
and t.chat_content =#chatContent#
@}
@if(!isEmpty(keywords)){
and t.keywords like #"%"+keywords+"%"#
3 years ago
@}
@if(!isEmpty(studentScore)){
and t.student_score =#studentScore#
@}
@if(!isEmpty(chatFiles)){
and t.chat_files =#chatFiles#
@}
@if(!isEmpty(chatLogSendType)){
and find_in_set(t.chat_log_send_type, #chatLogSendType#)
@}
3 years ago
@if(isEmpty(teacherOpenCourseChatLogStatus) && isEmpty(teacherOpenCourseChatLogStatusPlural)){
and t.teacher_open_course_chat_log_status != 2
@}else{
@if(!isEmpty(teacherOpenCourseChatLogStatus)){
and t.teacher_open_course_chat_log_status =#teacherOpenCourseChatLogStatus#
@}else if(!isEmpty(teacherOpenCourseChatLogStatusPlural)){
and find_in_set(t.teacher_open_course_chat_log_status,#teacherOpenCourseChatLogStatusPlural#)
@}
@}
@if(!isEmpty(teacherOpenCourseChatLogAddTime)){
and t.teacher_open_course_chat_log_add_time =#teacherOpenCourseChatLogAddTime#
3 years ago
@}
@if(!isEmpty(orgId)){
and t.org_id =#orgId#
@}
@if(!isEmpty(orgIdPlural)){
and find_in_set(t.org_id,#orgIdPlural#)
@}
@if(!isEmpty(userId)){
and t.user_id =#userId#
@}
@if(!isEmpty(userIdPlural)){
and find_in_set(t.user_id,#userIdPlural#)
@}
analysis
===
* 互动类型分析
2 years ago
SELECT
t.chat_log_send_type,
count( 1 ) AS type_count,
count( 1 ) AS people_count,
round(
avg(
ifnull( student_score, 0 ))) AS avg_score
FROM
teacher_open_course_chat_log t
where 1=1
and t.teacher_open_course_chat_log_status = 1
and t.teacher_open_course_id = #teacherOpenCourseId#
GROUP BY
t.chat_log_send_type
2 years ago
groupInfo
===
* 评论添加的类型,分组汇总
select
t.chat_log_send_type,
count(t.student_id is not null) as chat_count,
count(distinct(t.student_id)) as join_count,
round(avg(IFNULL(t.student_score, 0)), 1) as avg_score
from
teacher_open_course_chat_log t
where 1 = 1
and t.chat_log_send_type is not null
and t.teacher_open_course_id = #teacherOpenCourseId#
group by t.chat_log_send_type
2 years ago
getUnReadNum
===
2 years ago
* 根据登录身份,互动获取未读数
2 years ago
SELECT
count( 1 )
FROM
teacher_open_course_chat_log t
WHERE
1
@if(isNotEmpty(teacherOpenCourseId)) {
AND t.teacher_open_course_id = #teacherOpenCourseId#
@}
@if(isNotEmpty(studentId)) {
AND t.student_id = #studentId#
@}
@if(isNotEmpty(teacherId)) {
AND t.teacher_id = #teacherId#
@}
AND NOT EXISTS (
SELECT
1
FROM
teacher_open_course_chat_log ta
WHERE
1
@if(isNotEmpty(studentId)) {
AND t.student_id = #studentId#
@}
@if(isNotEmpty(teacherId)) {
AND t.teacher_id = #teacherId#
@}
@if(isNotEmpty(teacherOpenCourseId)) {
AND t.teacher_open_course_id = #teacherOpenCourseId#
@}
AND ta.teacher_open_course_chat_log_parent_id = teacher_open_course_chat_log_id
)