From 9b178ba05c0fb128561756f8ced754421d2c23a1 Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Tue, 11 Oct 2022 15:37:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=A8=A1=E6=9D=BF=EF=BC=9B=202.=20=E5=BC=80?= =?UTF-8?q?=E8=AF=BE=E4=BA=92=E5=8A=A8=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/codeTemplate/java/dao.java | 1 + .../resources/codeTemplate/java/service.java | 4 + .../main/resources/codeTemplate/md/entity.md | 32 +++ .../jlw/dao/TeacherOpenCourseChatLogDao.java | 1 + .../jlw/entity/TeacherOpenCourseChatLog.java | 203 ++---------------- .../TeacherOpenCourseChatLogService.java | 35 +++ .../TeacherOpenCourseChatLogController.java | 4 +- .../sql/jlw/teacherOpenCourseChatLog.md | 80 ++++++- .../js/jlw/teacherOpenCourseChatLog/index.js | 3 +- 9 files changed, 172 insertions(+), 191 deletions(-) diff --git a/admin-core/src/main/resources/codeTemplate/java/dao.java b/admin-core/src/main/resources/codeTemplate/java/dao.java index 32690e92..9a484bbf 100644 --- a/admin-core/src/main/resources/codeTemplate/java/dao.java +++ b/admin-core/src/main/resources/codeTemplate/java/dao.java @@ -31,6 +31,7 @@ public interface ${entity.name}Dao extends BaseMapper<${entity.name}>{ int updateGivenByIds(${entity.name}Query ${entity.code}Query); List<${entity.name}> getByIds(String ids); List<${entity.name}> getValuesByQuery(${entity.name}Query ${entity.code}Query); + List<${entity.name}> getValuesByQueryNotWithPermission(${entity.name}Query ${entity.code}Query); @if(entity.includeExcel){ List>getExcelValues(${entity.name}Query ${entity.code}Query); @} diff --git a/admin-core/src/main/resources/codeTemplate/java/service.java b/admin-core/src/main/resources/codeTemplate/java/service.java index 3548f5b4..f1489358 100644 --- a/admin-core/src/main/resources/codeTemplate/java/service.java +++ b/admin-core/src/main/resources/codeTemplate/java/service.java @@ -155,6 +155,10 @@ public class ${entity.name}Service extends CoreBaseService<${entity.name}>{ return ${entity.code}Dao.getValuesByQuery(${entity.code}Query); } + public List<${entity.name}> getValuesByQueryNotWithPermission (${entity.name}Query ${entity.code}Query){ + return ${entity.code}Dao.getValuesByQueryNotWithPermission(${entity.code}Query); + } + public ${entity.name} getInfo (Long ${entity.idAttribute.name}){ ${entity.name}Query ${entity.code}Query = new ${entity.name}Query(); ${entity.code}Query.set${upperFirst(entity.idAttribute.name)}(${entity.idAttribute.name}); diff --git a/admin-core/src/main/resources/codeTemplate/md/entity.md b/admin-core/src/main/resources/codeTemplate/md/entity.md index 233a8c93..fb4fe88c 100644 --- a/admin-core/src/main/resources/codeTemplate/md/entity.md +++ b/admin-core/src/main/resources/codeTemplate/md/entity.md @@ -186,6 +186,38 @@ getValuesByQuery @} +getValuesByQueryNotWithPermission +=== + +* 根据不为空的参数进行查询(不包含权限) + + select t.* + from ${entity.tableName} t + where 1=1 + @for(attr in attrs){ + @if(null != attr.status){ + \@if(isEmpty(${attr.name}) && isEmpty(${attr.name}Plural)){ + and t.${attr.colName} != 2 + \@}else{ + \@if(!isEmpty(${attr.name})){ + and t.${attr.colName} =#${attr.name}# + \@}else if(!isEmpty(${attr.name}Plural)){ + and find_in_set(t.${attr.colName},#${attr.name}Plural#) + \@} + \@} + @}else{ + \@if(!isEmpty(${attr.name})){ + and t.${attr.colName} =#${attr.name}# + \@} + @if(attr.isChoice || attr.isOtherId){ + \@if(!isEmpty(${attr.name}Plural)){ + and find_in_set(t.${attr.colName},#${attr.name}Plural#) + \@} + @} + @} + @} + + @if(entity.includeExcel){ diff --git a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseChatLogDao.java b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseChatLogDao.java index e2a3ac8c..5a7a6fd2 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseChatLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseChatLogDao.java @@ -24,4 +24,5 @@ public interface TeacherOpenCourseChatLogDao extends BaseMapper getByIds(String ids); List getValuesByQuery(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery); + List getValuesByQueryNotWithPermission(TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery); } diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseChatLog.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseChatLog.java index 6a65061d..56cca526 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseChatLog.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseChatLog.java @@ -3,16 +3,23 @@ package com.ibeetl.jlw.entity; import com.ibeetl.admin.core.annotation.Dict; import com.ibeetl.admin.core.entity.BaseEntity; import com.ibeetl.admin.core.util.ValidateConfig; +import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; +import org.beetl.sql.fetch.annotation.Fetch; +import org.beetl.sql.fetch.annotation.FetchSql; import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.util.Date; +import java.util.List; /* * 课程开课-互动-评论日志 * gen by Spring Boot2 Admin 2022-09-18 */ +@Data +// 递归数据。最多支持1000层级,再深层级的就无法查询了 +@Fetch(level=1000) public class TeacherOpenCourseChatLog extends BaseEntity{ //课程开课--讨论-日志ID @@ -22,9 +29,15 @@ public class TeacherOpenCourseChatLog extends BaseEntity{ private Long teacherOpenCourseChatLogId ; - //上级ID + //上级ID, 默认0L 顶级:0L - private Long teacherOpenCourseChatLogParentId ; + private Long teacherOpenCourseChatLogParentId = 0L; + + @FetchSql("select * from teacher_open_course_chat_log t " + + "where t.teacher_open_course_id = #teacherOpenCourseId# " + + "and t.teacher_open_course_chat_log_parent_id = #teacherOpenCourseChatLogId# " + + "and t.teacher_open_course_chat_log_parent_id != 0") + private List children; //课程开课ID @Dict(type="teacher_open_course.teacher_open_course_title.teacher_open_course_status=1") @@ -78,190 +91,4 @@ public class TeacherOpenCourseChatLog extends BaseEntity{ private Long userId ; - public TeacherOpenCourseChatLog(){ - } - - /**课程开课--讨论-日志ID - *@return - */ - public Long getTeacherOpenCourseChatLogId(){ - return teacherOpenCourseChatLogId; - } - /**课程开课--讨论-日志ID - *@param teacherOpenCourseChatLogId - */ - public void setTeacherOpenCourseChatLogId(Long teacherOpenCourseChatLogId){ - this.teacherOpenCourseChatLogId = teacherOpenCourseChatLogId; - } - - /**上级ID - *@return - */ - public Long getTeacherOpenCourseChatLogParentId(){ - return teacherOpenCourseChatLogParentId; - } - /**上级ID - *@param teacherOpenCourseChatLogParentId - */ - public void setTeacherOpenCourseChatLogParentId(Long teacherOpenCourseChatLogParentId){ - this.teacherOpenCourseChatLogParentId = teacherOpenCourseChatLogParentId; - } - - /**课程开课ID - *@return - */ - public Long getTeacherOpenCourseId(){ - return teacherOpenCourseId; - } - /**课程开课ID - *@param teacherOpenCourseId - */ - public void setTeacherOpenCourseId(Long teacherOpenCourseId){ - this.teacherOpenCourseId = teacherOpenCourseId; - } - - /**班级ID集合 - *@return - */ - public String getSchoolClassIds(){ - return schoolClassIds; - } - /**班级ID集合 - *@param schoolClassIds - */ - public void setSchoolClassIds(String schoolClassIds){ - this.schoolClassIds = schoolClassIds; - } - - /**教师ID - *@return - */ - public Long getTeacherId(){ - return teacherId; - } - /**教师ID - *@param teacherId - */ - public void setTeacherId(Long teacherId){ - this.teacherId = teacherId; - } - - /**学生ID - *@return - */ - public Long getStudentId(){ - return studentId; - } - /**学生ID - *@param studentId - */ - public void setStudentId(Long studentId){ - this.studentId = studentId; - } - - /**讨论内容 - *@return - */ - public String getChatContent(){ - return chatContent; - } - /**讨论内容 - *@param chatContent - */ - public void setChatContent(String chatContent){ - this.chatContent = chatContent; - } - - /**关键字(多个逗号隔开) - *@return - */ - public String getKeywords(){ - return keywords; - } - /**关键字(多个逗号隔开) - *@param keywords - */ - public void setKeywords(String keywords){ - this.keywords = keywords; - } - - /**学生得分 - *@return - */ - public BigDecimal getStudentScore(){ - return studentScore; - } - /**学生得分 - *@param studentScore - */ - public void setStudentScore(BigDecimal studentScore){ - this.studentScore = studentScore; - } - - /**附件上传(仅支持图片,多个逗号隔开) - *@return - */ - public String getChatFiles(){ - return chatFiles; - } - /**附件上传(仅支持图片,多个逗号隔开) - *@param chatFiles - */ - public void setChatFiles(String chatFiles){ - this.chatFiles = chatFiles; - } - - /**状态 (1正常 2删除) - *@return - */ - public Integer getTeacherOpenCourseChatLogStatus(){ - return teacherOpenCourseChatLogStatus; - } - /**状态 (1正常 2删除) - *@param teacherOpenCourseChatLogStatus - */ - public void setTeacherOpenCourseChatLogStatus(Integer teacherOpenCourseChatLogStatus){ - this.teacherOpenCourseChatLogStatus = teacherOpenCourseChatLogStatus; - } - - /**创建时间 - *@return - */ - public Date getTeacherOpenCourseChatLogAddTime(){ - return teacherOpenCourseChatLogAddTime; - } - /**创建时间 - *@param teacherOpenCourseChatLogAddTime - */ - public void setTeacherOpenCourseChatLogAddTime(Date teacherOpenCourseChatLogAddTime){ - this.teacherOpenCourseChatLogAddTime = teacherOpenCourseChatLogAddTime; - } - - /**组织ID - *@return - */ - public Long getOrgId(){ - return orgId; - } - /**组织ID - *@param orgId - */ - public void setOrgId(Long orgId){ - this.orgId = orgId; - } - - /**用户ID - *@return - */ - public Long getUserId(){ - return userId; - } - /**用户ID - *@param userId - */ - public void setUserId(Long userId){ - this.userId = userId; - } - - } diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseChatLogService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseChatLogService.java index 4c50d0f9..0b8dd5b9 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseChatLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseChatLogService.java @@ -38,6 +38,41 @@ public class TeacherOpenCourseChatLogService extends CoreBaseService queryTreeListByCondition(PageQuery query){ +// PageQuery ret = teacherOpenCourseChatLogDao.queryByCondition(query); +// +// // 上级ID集合 +// String chatLogParentIds = ((List) ret.getList()).stream() +// .map(chatLog -> { +// // 取当前的ID,作为上级ID +// Long parentId = chatLog.getTeacherOpenCourseChatLogId(); +// if (null != parentId && 0L != parentId) { +// return String.valueOf(parentId); +// } +// return ""; +// }).filter(StringUtils::isNotBlank).collect(joining(",")); +// +// getDeepListByParentId(chatLogParentIds); +// return ret; +// } +// +// /** +// * 为了节省性能,一次性查询多个ID +// * @param teacherOpenCourseChatLogParentIds +// * @return +// */ +// public Map> getDeepListByParentId(String teacherOpenCourseChatLogParentIds) { +// +// // 查询多个上级ID +// TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery = new TeacherOpenCourseChatLogQuery(); +// teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogIdPlural(teacherOpenCourseChatLogParentIds); +// teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogStatus(1); +// List list = teacherOpenCourseChatLogDao.getValuesByQueryNotWithPermission(teacherOpenCourseChatLogQuery); +// +// return Optional.ofNullable(list).orElse(Lists.emptyList()).stream() +// .collect(groupingBy(TeacherOpenCourseChatLog::getTeacherOpenCourseChatLogParentId)); +// } + public PageQueryqueryByConditionQuery(PageQuery query){ PageQuery ret = teacherOpenCourseChatLogDao.queryByConditionQuery(query); queryListAfter(ret.getList()); diff --git a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseChatLogController.java b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseChatLogController.java index aa482f93..cc381413 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseChatLogController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TeacherOpenCourseChatLogController.java @@ -120,10 +120,12 @@ public class TeacherOpenCourseChatLogController{ return JsonResult.success(page); } -// @PostMapping(MODEL + "/treeList.json") + @PostMapping(MODEL + "/treeList.json") @Function("teacherOpenCourseChatLog.query") public JsonResult treeList(TeacherOpenCourseChatLogQuery condition, @SCoreUser CoreUser coreUser) { PageQuery page = condition.getPageQuery(); + // 只查询顶级的列表 + condition.setTeacherOpenCourseChatLogParentId(0L); teacherOpenCourseChatLogService.queryByCondition(page); return JsonResult.success(page); } diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseChatLog.md b/web/src/main/resources/sql/jlw/teacherOpenCourseChatLog.md index bf6420ce..ea7b9c94 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseChatLog.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseChatLog.md @@ -86,7 +86,7 @@ queryByCondition and find_in_set(t.user_id,#userIdPlural#) @} @if(!isEmpty(teacherOpenCourseChatLogParentId)){ - order by create_time desc + order by teacher_open_course_chat_log_add_time desc @} @@ -431,5 +431,83 @@ getValuesByQuery 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#) + @} + @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 =#keywords# + @} + @if(!isEmpty(studentScore)){ + and t.student_score =#studentScore# + @} + @if(!isEmpty(chatFiles)){ + and t.chat_files =#chatFiles# + @} + @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#) + @} + diff --git a/web/src/main/resources/static/js/jlw/teacherOpenCourseChatLog/index.js b/web/src/main/resources/static/js/jlw/teacherOpenCourseChatLog/index.js index 43974e88..c0623bfb 100644 --- a/web/src/main/resources/static/js/jlw/teacherOpenCourseChatLog/index.js +++ b/web/src/main/resources/static/js/jlw/teacherOpenCourseChatLog/index.js @@ -22,7 +22,8 @@ layui.define([ 'form', 'laydate', 'table' ], function(exports) { height : Lib.getTableHeight(1), cellMinWidth: 100, method : 'post', - url : Common.ctxPath + '/jlw/teacherOpenCourseChatLog/list.json' // 数据接口 + // url : Common.ctxPath + '/jlw/teacherOpenCourseChatLog/list.json' // 数据接口 + url : Common.ctxPath + '/jlw/teacherOpenCourseChatLog/treeList.json' // 数据接口 ,page : Lib.tablePage // 开启分页 ,toolbar: '#toolbar_teacherOpenCourseChatLog' //自定义头部左侧工具栏 ,defaultToolbar: ['filter', 'print', 'exports'] //头部右侧工具栏