|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.ibeetl.jlw.web;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.extra.validation.BeanValidationResult;
|
|
|
|
|
import cn.hutool.extra.validation.ValidationUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import cn.jlw.Interceptor.SCoreUser;
|
|
|
|
|
import cn.jlw.validate.ValidateConfig;
|
|
|
|
|
import com.ibeetl.admin.core.annotation.Function;
|
|
|
|
@ -21,14 +24,20 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static com.ibeetl.jlw.web.query.TeacherOpenCourseChatLogQuery.STUDENT_ADD;
|
|
|
|
|
import static com.ibeetl.jlw.web.query.TeacherOpenCourseChatLogQuery.TEACHER_ADD;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开课互动 课程开课-互动-评论日志 接口
|
|
|
|
|
* 切记不要对非线程安全的静态变量进行写操作
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
@Validated
|
|
|
|
|
public class TeacherOpenCourseChatLogController{
|
|
|
|
|
|
|
|
|
|
private final Log log = LogFactory.getLog(this.getClass());
|
|
|
|
@ -177,6 +186,74 @@ public class TeacherOpenCourseChatLogController{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 教师端-学生端-添加互动消息
|
|
|
|
|
* @param teacherOpenCourseChatLogQuery
|
|
|
|
|
* @param type 1: 教师端, 其他:学生端
|
|
|
|
|
* @param result
|
|
|
|
|
* @param coreUser
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(MODEL + "/addByType.json")
|
|
|
|
|
@Function("teacherOpenCourseChatLog.add")
|
|
|
|
|
public JsonResult addByType(
|
|
|
|
|
@RequestBody TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery,
|
|
|
|
|
Integer type,
|
|
|
|
|
BindingResult result, @SCoreUser CoreUser coreUser){
|
|
|
|
|
|
|
|
|
|
Boolean isTeacherAdding = type.equals(1);
|
|
|
|
|
// 验证
|
|
|
|
|
BeanValidationResult validationResult = ValidationUtil
|
|
|
|
|
.warpValidate(teacherOpenCourseChatLogQuery, isTeacherAdding ? TEACHER_ADD.class : STUDENT_ADD.class);
|
|
|
|
|
Assert.isTrue(validationResult.isSuccess(), JSONUtil.toJsonStr(validationResult.getErrorMessages()));
|
|
|
|
|
|
|
|
|
|
// 教师身份,添加上级ID为0
|
|
|
|
|
if(isTeacherAdding) {
|
|
|
|
|
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogParentId(0L);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(result.hasErrors()){
|
|
|
|
|
return JsonResult.failMessage(result);
|
|
|
|
|
}else{
|
|
|
|
|
teacherOpenCourseChatLogQuery.setUserId(coreUser.getId());
|
|
|
|
|
teacherOpenCourseChatLogQuery.setOrgId(coreUser.getOrgId());
|
|
|
|
|
if(null == teacherOpenCourseChatLogQuery.getTeacherOpenCourseChatLogStatus()){
|
|
|
|
|
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogStatus(1);
|
|
|
|
|
}
|
|
|
|
|
return teacherOpenCourseChatLogService.add(teacherOpenCourseChatLogQuery);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 教师端-给学生打分
|
|
|
|
|
* @param teacherOpenCourseChatLogId
|
|
|
|
|
* @param studentScore
|
|
|
|
|
* @param result
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(MODEL + "/setScore.json")
|
|
|
|
|
@Function("teacherOpenCourseChatLog.add")
|
|
|
|
|
public JsonResult setScore(
|
|
|
|
|
@NotNull(message = "互动ID不能为空!")
|
|
|
|
|
Long teacherOpenCourseChatLogId,
|
|
|
|
|
@NotNull(message = "学生分数不能为空!")
|
|
|
|
|
BigDecimal studentScore, BindingResult result){
|
|
|
|
|
|
|
|
|
|
if(result.hasErrors()){
|
|
|
|
|
return JsonResult.failMessage(result);
|
|
|
|
|
}else{
|
|
|
|
|
TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery = new TeacherOpenCourseChatLogQuery();
|
|
|
|
|
teacherOpenCourseChatLogQuery.setTeacherOpenCourseChatLogId(teacherOpenCourseChatLogId);
|
|
|
|
|
teacherOpenCourseChatLogQuery.setStudentScore(studentScore);
|
|
|
|
|
String msg = teacherOpenCourseChatLogService.edit(teacherOpenCourseChatLogQuery);
|
|
|
|
|
if (StringUtils.isBlank(msg)) {
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
} else {
|
|
|
|
|
return JsonResult.failMessage("更新失败,"+msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping(MODEL + "/edit.json")
|
|
|
|
|
@Function("teacherOpenCourseChatLog.edit")
|
|
|
|
|
public JsonResult<String> update(@Validated(ValidateConfig.UPDATE.class) @RequestBody TeacherOpenCourseChatLogQuery teacherOpenCourseChatLogQuery, BindingResult result) {
|
|
|
|
|