@ -1,14 +1,13 @@
package cn.xluobo.business.sc.course.service ;
package cn.xluobo.business.sc.course.service ;
import cn.hutool.core.bean.BeanUtil ;
import cn.xluobo.business.sc.course.domain.req.ReqAddScCourseCla ;
import cn.xluobo.business.sc.course.domain.req.ReqAddScCourseCla ;
import cn.xluobo.business.sc.course.domain.req.ReqSearchScCourseCla ;
import cn.xluobo.business.sc.course.domain.req.ReqSearchScCourseCla ;
import cn.xluobo.business.sc.course.domain.resp.RespBusinessChooseCourseCharge ;
import cn.xluobo.business.sc.course.domain.resp.RespBusinessChooseCourseCharge ;
import cn.xluobo.business.sc.course.domain.resp.RespCourseClaInfo ;
import cn.xluobo.business.sc.course.domain.resp.RespCourseClaInfo ;
import cn.xluobo.business.sc.course.domain.resp.cla.RespClaAllDetailInfo ;
import cn.xluobo.business.sc.course.domain.resp.cla.RespClaAllDetailInfo ;
import cn.xluobo.business.sc.course.repo.mapper.ScCourseClaMapper ;
import cn.xluobo.business.sc.course.repo.mapper.ScCourseClaMapper ;
import cn.xluobo.business.sc.course.repo.model.ScClaTime ;
import cn.xluobo.business.sc.course.repo.model.* ;
import cn.xluobo.business.sc.course.repo.model.ScCourse ;
import cn.xluobo.business.sc.course.repo.model.ScCourseCla ;
import cn.xluobo.business.sc.student.repo.mapper.ScStudentMapper ;
import cn.xluobo.business.sc.student.repo.mapper.ScStudentMapper ;
import cn.xluobo.business.sc.student.repo.model.ScStudentCourse ;
import cn.xluobo.business.sc.student.repo.model.ScStudentCourse ;
import cn.xluobo.business.sc.student.service.IScStudentCourseService ;
import cn.xluobo.business.sc.student.service.IScStudentCourseService ;
@ -23,8 +22,10 @@ import cn.xluobo.core.page.RespPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.google.common.collect.Maps ;
import com.google.common.collect.Maps ;
import com.ruoyi.common.core.domain.entity.SysDept ;
import com.ruoyi.common.core.domain.entity.SysDept ;
import com.ruoyi.common.core.domain.entity.SysUser ;
import com.ruoyi.common.core.domain.model.LoginUser ;
import com.ruoyi.common.core.domain.model.LoginUser ;
import com.ruoyi.common.utils.SecurityUtils ;
import com.ruoyi.common.utils.SecurityUtils ;
import com.ruoyi.system.service.ISysUserService ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.stereotype.Service ;
import org.springframework.stereotype.Service ;
import org.springframework.transaction.annotation.Transactional ;
import org.springframework.transaction.annotation.Transactional ;
@ -65,6 +66,9 @@ public class BusinessScCourseClaService {
@Autowired
@Autowired
private IScClaTimeService claTimeService ;
private IScClaTimeService claTimeService ;
@Autowired
private ISysUserService userService ;
/ * *
/ * *
* 查 询
* 查 询
*
*
@ -73,6 +77,8 @@ public class BusinessScCourseClaService {
* /
* /
public APIResponse searchList ( ReqSearchScCourseCla reqSearchScCourseCla ) {
public APIResponse searchList ( ReqSearchScCourseCla reqSearchScCourseCla ) {
RespPage < RespCourseClaInfo > page = new RespPage ( reqSearchScCourseCla . getPageNum ( ) , reqSearchScCourseCla . getPageSize ( ) ) ;
RespPage < RespCourseClaInfo > page = new RespPage ( reqSearchScCourseCla . getPageNum ( ) , reqSearchScCourseCla . getPageSize ( ) ) ;
String nowTenantId = SecurityUtils . getLoginUser ( ) . getNowTenantId ( ) ;
reqSearchScCourseCla . setTenantId ( nowTenantId ) ;
List < RespCourseClaInfo > claList = scCourseClaMapper . selectClaList ( reqSearchScCourseCla , page ) ;
List < RespCourseClaInfo > claList = scCourseClaMapper . selectClaList ( reqSearchScCourseCla , page ) ;
page . setRows ( claList ) ;
page . setRows ( claList ) ;
return APIResponse . toAPIResponse ( page ) ;
return APIResponse . toAPIResponse ( page ) ;
@ -91,17 +97,28 @@ public class BusinessScCourseClaService {
Map < String , Object > resultMap = Maps . newHashMap ( ) ;
Map < String , Object > resultMap = Maps . newHashMap ( ) ;
// 班级信息
// 班级信息
ScCourseCla detailInfo = scCourseClaService . getById ( claId ) ;
ScCourseCla detailInfo = scCourseClaService . getById ( claId ) ;
if ( null = = detailInfo ) {
if ( null = = detailInfo ) {
return APIResponse . toAPIResponse ( null ) ;
return APIResponse . toAPIResponse ( null ) ;
}
}
ScCourseClaVo scCourseCla = new ScCourseClaVo ( ) ;
BeanUtil . copyProperties ( detailInfo , scCourseCla ) ;
scCourseCla . setClaId ( detailInfo . getClaId ( ) . toString ( ) ) ;
scCourseCla . setCourseId ( detailInfo . getCourseId ( ) . toString ( ) ) ;
// 课程信息
// 课程信息
ScCourse scCourse = courseService . getById ( detailInfo . getCourseId ( ) ) ;
ScCourse scCourse = courseService . getById ( detailInfo . getCourseId ( ) ) ;
ScCourseVo scCourseVo = new ScCourseVo ( ) ;
BeanUtil . copyProperties ( scCourse , scCourseVo ) ;
scCourseVo . setCourseId ( scCourse . getCourseId ( ) . toString ( ) ) ;
// 是否允许变更课程,有报名不允许变更课程
// 是否允许变更课程,有报名不允许变更课程
APIBaseResponse canChangeCourse = scCourseClaService . canChangeCourse ( claId ) ;
APIBaseResponse canChangeCourse = scCourseClaService . canChangeCourse ( claId ) ;
resultMap . put ( "canChangeCourse" , canChangeCourse . isSuccess ( ) ) ;
resultMap . put ( "canChangeCourse" , canChangeCourse . isSuccess ( ) ) ;
resultMap . put ( "claInfo" , detailInfo ) ;
resultMap . put ( "claInfo" , scCourseCla ) ;
resultMap . put ( "claCourseInfo" , scCourse ) ;
resultMap . put ( "claCourseInfo" , scCourse Vo ) ;
return APIResponse . toAPIResponse ( resultMap ) ;
return APIResponse . toAPIResponse ( resultMap ) ;
}
}
@ -118,17 +135,25 @@ public class BusinessScCourseClaService {
}
}
// 班级信息
// 班级信息
ScCourseCla courseCla = scCourseClaService . getById ( claId ) ;
ScCourseCla courseCla = scCourseClaService . getById ( claId ) ;
if ( null = = courseCla ) {
if ( null = = courseCla ) {
return null ;
return null ;
}
}
ScCourseClaVo scCourseClaVo = new ScCourseClaVo ( ) ;
BeanUtil . copyProperties ( courseCla , scCourseClaVo ) ;
scCourseClaVo . setClaId ( courseCla . getClaId ( ) . toString ( ) ) ;
// 班级当前学员数量
// 班级当前学员数量
Integer studentCnt = scCourseClaService . selectStudentCnt ( claId ) ;
Integer studentCnt = scCourseClaService . selectStudentCnt ( claId ) ;
courseCla . setStudentCnt ( studentCnt ) ;
s cC ourseClaVo . setStudentCnt ( studentCnt ) ;
// 课程信息
// 课程信息
ScCourse scCourse = courseService . getById ( courseCla . getCourseId ( ) ) ;
ScCourse scCourse = courseService . getById ( courseCla . getCourseId ( ) ) ;
ScCourseVo scCourseVo = new ScCourseVo ( ) ;
BeanUtil . copyProperties ( scCourse , scCourseVo ) ;
scCourseVo . setCourseId ( scCourse . getCourseId ( ) . toString ( ) ) ;
// 课程收费信息
// 课程收费信息
List < RespBusinessChooseCourseCharge > courseChargeList = courseChargeService . courseChargeList ( scCourse . getCourseId ( ) , null ) ;
List < RespBusinessChooseCourseCharge > courseChargeList = courseChargeService . courseChargeList ( scCourse . getCourseId ( ) , null ) ;
@ -141,16 +166,16 @@ public class BusinessScCourseClaService {
// 教师
// 教师
if ( null ! = courseCla . getStaffId ( ) ) {
if ( null ! = courseCla . getStaffId ( ) ) {
Sys Staff staff = teacherService . get ById( courseCla . getStaffId ( ) ) ;
Sys User staff = userService . selectUser ById( courseCla . getStaffId ( ) ) ;
courseCla . setTeacherName ( staff . get Staff Name( ) ) ;
courseCla . setTeacherName ( staff . get Nick Name( ) ) ;
}
}
// 上课时间
// 上课时间
List < String > claTimeInfo = claTimeRuleService . selectClaTimeInfo ( claId ) ;
List < String > claTimeInfo = claTimeRuleService . selectClaTimeInfo ( claId ) ;
return RespClaAllDetailInfo . builder ( )
return RespClaAllDetailInfo . builder ( )
. courseCla ( courseCla)
. courseCla ( s cC ourseClaVo )
. course ( scCourse )
. course ( scCourse Vo )
. courseChargeList ( courseChargeList )
. courseChargeList ( courseChargeList )
. claTimeList ( claTimeInfo )
. claTimeList ( claTimeInfo )
. build ( ) ;
. build ( ) ;
@ -173,13 +198,14 @@ public class BusinessScCourseClaService {
}
}
// 教师是否存在
// 教师是否存在
Sys Staff teacher = teacherService . get ById( scCourseCla . getStaffId ( ) ) ;
Sys User teacher = userService . selectUser ById( scCourseCla . getStaffId ( ) ) ;
if ( null = = teacher ) {
if ( null = = teacher ) {
return APIResponse . toExceptionResponse ( "教师不存在,请重新选择后提交。" ) ;
return APIResponse . toExceptionResponse ( "教师不存在,请重新选择后提交。" ) ;
}
}
// 新建班级
// 新建班级
ScCourseCla cla = scCourseCla . getScCourseCla ( loginUser ) ;
ScCourseCla cla = scCourseCla . getScCourseCla ( loginUser ) ;
cla . setTeacherName ( teacher . getNickName ( ) ) ;
APIBaseResponse checkParam = cla . checkParam ( ) ;
APIBaseResponse checkParam = cla . checkParam ( ) ;
if ( ! checkParam . isSuccess ( ) ) {
if ( ! checkParam . isSuccess ( ) ) {
return APIResponse . toExceptionResponse ( checkParam . getRespMsg ( ) ) ;
return APIResponse . toExceptionResponse ( checkParam . getRespMsg ( ) ) ;
@ -213,7 +239,7 @@ public class BusinessScCourseClaService {
}
}
// 教师是否存在
// 教师是否存在
Sys Staff teacher = teacherService . get ById( scCourseCla . getStaffId ( ) ) ;
Sys User teacher = userService . selectUser ById( scCourseCla . getStaffId ( ) ) ;
if ( null = = teacher ) {
if ( null = = teacher ) {
return APIResponse . toExceptionResponse ( "教师不存在,请重新选择后提交。" ) ;
return APIResponse . toExceptionResponse ( "教师不存在,请重新选择后提交。" ) ;
}
}
@ -227,6 +253,7 @@ public class BusinessScCourseClaService {
}
}
LoginUser loginUser = SecurityUtils . getLoginUser ( ) ;
LoginUser loginUser = SecurityUtils . getLoginUser ( ) ;
scCourseCla . setTeacherName ( teacher . getNickName ( ) ) ;
scCourseCla . setLastUpdateUser ( loginUser . getUserId ( ) ) ;
scCourseCla . setLastUpdateUser ( loginUser . getUserId ( ) ) ;
scCourseCla . setLastUpdateTime ( new Date ( ) ) ;
scCourseCla . setLastUpdateTime ( new Date ( ) ) ;
boolean updateScCourseCla = scCourseClaService . updateById ( scCourseCla ) ;
boolean updateScCourseCla = scCourseClaService . updateById ( scCourseCla ) ;