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/java/com/ibeetl/jlw/service/TeacherOpenCourseHandsOnSim...

173 lines
9.2 KiB
Java

package com.ibeetl.jlw.service;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.TeacherOpenCourseHandsOnSimulationTasksDao;
import com.ibeetl.jlw.entity.TaskTypeParam;
import com.ibeetl.jlw.entity.TeacherOpenCourseHandsOnSimulationTasks;
import com.ibeetl.jlw.entity.TeacherOpenCourseHandsOnSimulationTasksFile;
import com.ibeetl.jlw.web.query.TeacherOpenCourseHandsOnSimulationTasksFileQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseHandsOnSimulationTasksQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
import java.util.List;
/**
* 教师开课-课程实操任务 Service
* 当分布式ID开启后请勿使用insert(*,true)
*/
@Service
@Transactional
@Validated
public class TeacherOpenCourseHandsOnSimulationTasksService extends CoreBaseService<TeacherOpenCourseHandsOnSimulationTasks>{
@Autowired private TeacherOpenCourseHandsOnSimulationTasksDao teacherOpenCourseHandsOnSimulationTasksDao;
@Autowired private TeacherOpenCourseHandsOnSimulationTasksFileService teacherOpenCourseHandsOnSimulationTasksFileService;
public PageQuery<TeacherOpenCourseHandsOnSimulationTasks>queryByCondition(PageQuery query){
PageQuery ret = teacherOpenCourseHandsOnSimulationTasksDao.queryByCondition(query);
queryListAfter(ret.getList());
return ret;
}
public PageQuery<TeacherOpenCourseHandsOnSimulationTasks>queryByConditionQuery(PageQuery query){
PageQuery ret = teacherOpenCourseHandsOnSimulationTasksDao.queryByConditionQuery(query);
queryListAfter(ret.getList());
return ret;
}
public void deleteByList(List list){
String ids = "";
ToolUtils.deleteNullList(list);
for(int i=0;null != list && i<list.size();i++){
ids += list.get(i).toString()+(i==list.size()-1?"":",");
}
if(StringUtils.isNotBlank(ids)){
teacherOpenCourseHandsOnSimulationTasksDao.deleteTeacherOpenCourseHandsOnSimulationTasksByIds(ids);
}
}
public void deleteTeacherOpenCourseHandsOnSimulationTasks(String ids){
try {
teacherOpenCourseHandsOnSimulationTasksDao.deleteTeacherOpenCourseHandsOnSimulationTasksByIds(ids);
} catch (Exception e) {
throw new PlatformException("批量删除教师开课-课程实操任务失败", e);
}
}
public String addAll(TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
String msg = "";
List<TeacherOpenCourseHandsOnSimulationTasks> teacherOpenCourseHandsOnSimulationTasksList = new ArrayList<>();
try {
teacherOpenCourseHandsOnSimulationTasksList = JSON.parseArray(teacherOpenCourseHandsOnSimulationTasksQuery.getTeacherOpenCourseHandsOnSimulationTasksJsonStr(), TeacherOpenCourseHandsOnSimulationTasks.class);
} catch (Exception e) {
try {
teacherOpenCourseHandsOnSimulationTasksList.add(JSONObject.parseObject(teacherOpenCourseHandsOnSimulationTasksQuery.getTeacherOpenCourseHandsOnSimulationTasksJsonStr(), TeacherOpenCourseHandsOnSimulationTasks.class));
} catch (Exception e1) {}
}
ToolUtils.deleteNullList(teacherOpenCourseHandsOnSimulationTasksList);
if(null != teacherOpenCourseHandsOnSimulationTasksList && teacherOpenCourseHandsOnSimulationTasksList.size()>0){
for(int i=0;i<teacherOpenCourseHandsOnSimulationTasksList.size();i++){
TeacherOpenCourseHandsOnSimulationTasks teacherOpenCourseHandsOnSimulationTasks = teacherOpenCourseHandsOnSimulationTasksList.get(i);
teacherOpenCourseHandsOnSimulationTasks.setUserId(teacherOpenCourseHandsOnSimulationTasksQuery.getUserId());
teacherOpenCourseHandsOnSimulationTasks.setOrgId(teacherOpenCourseHandsOnSimulationTasksQuery.getOrgId());
}
insertBatch(teacherOpenCourseHandsOnSimulationTasksList);
}
return msg;
}
public JsonResult add(TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
String msg = "";
TeacherOpenCourseHandsOnSimulationTasks teacherOpenCourseHandsOnSimulationTasks = teacherOpenCourseHandsOnSimulationTasksQuery.pojo();
teacherOpenCourseHandsOnSimulationTasksDao.insert(teacherOpenCourseHandsOnSimulationTasks);
teacherOpenCourseHandsOnSimulationTasksQuery.setTaskId(teacherOpenCourseHandsOnSimulationTasks.getTaskId());
List<TeacherOpenCourseHandsOnSimulationTasksFileQuery> teacherOpenCourseHandsOnSimulationTasksFiles = teacherOpenCourseHandsOnSimulationTasksQuery.getTeacherOpenCourseHandsOnSimulationTasksFile();
if (CollectionUtils.isNotEmpty(teacherOpenCourseHandsOnSimulationTasksFiles)) {
for (TeacherOpenCourseHandsOnSimulationTasksFileQuery teacherOpenCourseHandsOnSimulationTasksFile : teacherOpenCourseHandsOnSimulationTasksFiles) {
teacherOpenCourseHandsOnSimulationTasksFile.setTeacherOpenCourseId(teacherOpenCourseHandsOnSimulationTasks.getTeacherOpenCourseId());
teacherOpenCourseHandsOnSimulationTasksFile.setHandsOnId(teacherOpenCourseHandsOnSimulationTasks.getHandsOnId());
teacherOpenCourseHandsOnSimulationTasksFile.setTaskId(teacherOpenCourseHandsOnSimulationTasks.getTaskId());
teacherOpenCourseHandsOnSimulationTasksFileService.add(teacherOpenCourseHandsOnSimulationTasksFile);
}
}
JsonResult jsonResult = new JsonResult();
jsonResult.setData(teacherOpenCourseHandsOnSimulationTasks.getTaskId());//自增的ID丢进去
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
jsonResult.setMsg(msg);
return jsonResult;
}
public String edit(TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
String msg = "";
TeacherOpenCourseHandsOnSimulationTasks teacherOpenCourseHandsOnSimulationTasks = teacherOpenCourseHandsOnSimulationTasksQuery.pojo();
teacherOpenCourseHandsOnSimulationTasksDao.updateTemplateById(teacherOpenCourseHandsOnSimulationTasks);
return msg;
}
public String updateGivenByIds(TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
String msg = "";
if(StringUtils.isNotBlank(teacherOpenCourseHandsOnSimulationTasksQuery.get_given())){
boolean flag = teacherOpenCourseHandsOnSimulationTasksDao.updateGivenByIds(teacherOpenCourseHandsOnSimulationTasksQuery) > 0;
if(!flag){
msg = "更新指定参数失败";
}
}else{
msg = "指定参数为空";
}
return msg;
}
public List<TeacherOpenCourseHandsOnSimulationTasks> getValues (Object paras){
return sqlManager.select(SqlId.of("jlw.teacherOpenCourseHandsOnSimulationTasks.getTeacherOpenCourseHandsOnSimulationTasksValues"), TeacherOpenCourseHandsOnSimulationTasks.class, paras);
}
public List<TeacherOpenCourseHandsOnSimulationTasks> getValuesByQuery (TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
return teacherOpenCourseHandsOnSimulationTasksDao.getValuesByQuery(teacherOpenCourseHandsOnSimulationTasksQuery);
}
public List<TeacherOpenCourseHandsOnSimulationTasks> getValuesByQueryNotWithPermission (TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
return teacherOpenCourseHandsOnSimulationTasksDao.getValuesByQueryNotWithPermission(teacherOpenCourseHandsOnSimulationTasksQuery);
}
public TeacherOpenCourseHandsOnSimulationTasks getInfo (Long taskId){
TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery = new TeacherOpenCourseHandsOnSimulationTasksQuery();
teacherOpenCourseHandsOnSimulationTasksQuery.setTaskId(taskId);
List<TeacherOpenCourseHandsOnSimulationTasks> list = teacherOpenCourseHandsOnSimulationTasksDao.getValuesByQuery(teacherOpenCourseHandsOnSimulationTasksQuery);
if(null != list && list.size()>0){
return list.get(0);
}else{
return null;
}
}
public TeacherOpenCourseHandsOnSimulationTasks getInfo (TeacherOpenCourseHandsOnSimulationTasksQuery teacherOpenCourseHandsOnSimulationTasksQuery){
List<TeacherOpenCourseHandsOnSimulationTasks> list = teacherOpenCourseHandsOnSimulationTasksDao.getValuesByQuery(teacherOpenCourseHandsOnSimulationTasksQuery);
if(null != list && list.size()>0){
return list.get(0);
}else{
return null;
}
}
public List<TaskTypeParam> getTaskTypeParam(String teacherOpenCourseId) {
return null;
}
}