From 616300740ebce6df406eee84e7fa7c21828fb024 Mon Sep 17 00:00:00 2001 From: mzh820631607 Date: Tue, 22 Sep 2020 18:33:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E5=AE=9E=E9=AA=8C=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/msdw/tms/api/ClassTeachingApi.java | 12 +++ .../controller/ClassTeachingController.java | 82 +++++++++++++++++++ .../controller/ProjectRecordController.java | 68 --------------- .../com/msdw/tms/dao/ClassTeachingDao.java | 15 ++++ .../entity/ExperimentalTeachingEntity.java | 49 +++++++++++ .../msdw/tms/entity/vo/ClassTeachingVo.java | 11 +++ .../msdw/tms/entity/vo/ProjectRecordVo.java | 12 +-- .../tms/service/ClassTeachingService.java | 12 +++ .../impl/ClassTeachingServiceImpl.java | 35 ++++++++ .../resources/mapper/tms/ClassTeachingDao.xml | 14 ++++ 10 files changed, 237 insertions(+), 73 deletions(-) create mode 100644 src/main/java/com/msdw/tms/api/ClassTeachingApi.java create mode 100644 src/main/java/com/msdw/tms/controller/ClassTeachingController.java create mode 100644 src/main/java/com/msdw/tms/dao/ClassTeachingDao.java create mode 100644 src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java create mode 100644 src/main/java/com/msdw/tms/entity/vo/ClassTeachingVo.java create mode 100644 src/main/java/com/msdw/tms/service/ClassTeachingService.java create mode 100644 src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java create mode 100644 src/main/resources/mapper/tms/ClassTeachingDao.xml diff --git a/src/main/java/com/msdw/tms/api/ClassTeachingApi.java b/src/main/java/com/msdw/tms/api/ClassTeachingApi.java new file mode 100644 index 0000000..555b316 --- /dev/null +++ b/src/main/java/com/msdw/tms/api/ClassTeachingApi.java @@ -0,0 +1,12 @@ +package com.msdw.tms.api; + +import com.msdw.tms.common.utils.R; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Api(value = "用户端班级实验", tags = "用户端班级实验信息") +public interface ClassTeachingApi { + @ApiOperation(value = "通过邀请码进入实验",notes = "通过邀请码进入实验") + R joinPractice(Integer invitationCode,Integer isCode,Integer projectId); +} diff --git a/src/main/java/com/msdw/tms/controller/ClassTeachingController.java b/src/main/java/com/msdw/tms/controller/ClassTeachingController.java new file mode 100644 index 0000000..a1d4798 --- /dev/null +++ b/src/main/java/com/msdw/tms/controller/ClassTeachingController.java @@ -0,0 +1,82 @@ +package com.msdw.tms.controller; + +import com.msdw.tms.api.ClassTeachingApi; +import com.msdw.tms.common.utils.PageUtils; +import com.msdw.tms.common.utils.R; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ProjectRecordVo; +import com.msdw.tms.service.ClassTeachingService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("tms/classTech") +public class ClassTeachingController implements ClassTeachingApi { + + @Autowired + private ClassTeachingService classTeachingService; + + /** + * 用户端查看班级实验列表 + * @param page + * @param size + * @param month + * @param startTime + * @param endTime + * @param status + * @param condition + * @return + */ + @GetMapping("user/Record") + public R queryTestRecord(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer month,@RequestParam String startTime,@RequestParam String endTime, + @RequestParam String condition, @RequestParam Integer status){ + ProjectRecordVo recordVo = new ProjectRecordVo(); + ExperimentalTeachingEntity entity = new ExperimentalTeachingEntity(); + + if (status!=0) {//不限定实验状态 + recordVo.setStatus(status); + } + if(!StringUtils.isEmpty(condition)){ + recordVo.setCondition(condition); + } + if(!StringUtils.isEmpty(month)) { + recordVo.setMonth(month); + }else { + if(!StringUtils.isEmpty(startTime)) { + recordVo.setStartTime(startTime); + }if(!StringUtils.isEmpty(endTime)) { + recordVo.setEndTime(endTime); + } + } + PageUtils page1 = classTeachingService.queryClassRecord(page,size,recordVo); + return R.ok().put("page", page1); + } + + /** + * 通过邀请码进入实验 + * @param + * @return + */ + @Override + @PostMapping("/joinPractice") + public R joinPractice(@RequestBody Integer invitationCode, Integer isCode, Integer projectId){ + ExperimentalTeachingEntity entity = new ExperimentalTeachingEntity(); + if (isCode==0){ + if (invitationCode!=null){ + entity.setIsCode(isCode).setProjectId(projectId); + ExperimentalTeachingEntity result= classTeachingService.queryInvitationcode(entity); + Integer code = result.getInvitationCode(); + if (invitationCode.equals(code)==true){ + return R.ok(); + }else{ + return R.error("邀请码错误,验证失败!!!"); + } + }else{ + return R.error(400,"邀请码格式错误!!!"); + } + }else{ + return R.error("输入有误,无需邀请码"); + } + } +} diff --git a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java index 2b07bea..f840f79 100644 --- a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java +++ b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java @@ -50,74 +50,6 @@ public class ProjectRecordController implements ProjectRcordControllerApi { return R.ok().put("page", page1); } -// /** -// * 用户端查看班级实验列表 -// * @param page -// * @param size -// * @param month -// * @param startTime -// * @param endTime -// * @param experimentStartus -// * @param condition -// * @return -// */ -// @GetMapping("user/Record") -// public R userList(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Integer month,@RequestParam String startTime,@RequestParam String endTime, -// @RequestParam String condition, @RequestParam Integer experimentStartus){ -// ProjectRecordVo recordVo = new ProjectRecordVo(); -// if (experimentStartus==0){//不限定 -// if(!StringUtils.isEmpty(month)) { -// recordVo.setMonth(month); -// }if(!StringUtils.isEmpty(startTime)) { -// recordVo.setStartTime(startTime); -// }if(!StringUtils.isEmpty(endTime)) { -// recordVo.setEndTime(endTime); -// }if(!StringUtils.isEmpty(condition)){ -// recordVo.setCondition(condition); -// } -// PageUtils page1 = projectRecordService.queryUserRecord(page,size,recordVo); -// }if (experimentStartus==1){//实验未发布 -// recordVo.setProjectstate(1); -// if(!StringUtils.isEmpty(condition)){ -// recordVo.setCondition(condition); -// } -// PageUtils page1 = projectRecordService.queryUserRecord(page,size,recordVo); -// }if (experimentStartus==2){//实验进行中 -// if(!StringUtils.isEmpty(month)) { -// recordVo.setMonth(month); -// }if(!StringUtils.isEmpty(condition)){ -// recordVo.setCondition(condition); -// } -// recordVo.setStartTime(startTime); -// recordVo.setEndtime(null); -// PageUtils page1 = projectRecordService.queryUserRecord(page,size,recordVo); -// }if (experimentStartus==3){//实验已完成 -// if(!StringUtils.isEmpty(month)) { -// recordVo.setMonth(month); -// }if(!StringUtils.isEmpty(startTime)){ -// recordVo.setStartTime(startTime); -// }if(!StringUtils.isEmpty(endTime)) { -// recordVo.setEndTime(endTime); -// }if(!StringUtils.isEmpty(condition)){ -// recordVo.setCondition(condition); -// } -// PageUtils page1 = projectRecordService.queryUserRecord(page,size,recordVo); -// } -// if(!StringUtils.isEmpty(month)) { -// recordVo.setMonth(month); -// }if(!StringUtils.isEmpty(startTime)) { -// recordVo.setStartTime(startTime); -// }if(!StringUtils.isEmpty(endTime)) { -// recordVo.setEndTime(endTime); -// }if(!StringUtils.isEmpty(condition)){ -// recordVo.setCondition(condition); -// } -// PageUtils page1 = projectRecordService.queryUserRecord(page,size,recordVo); -// -// -// return R.ok().put("page", page1); -// } - /** * 用户实验记录 * @param page diff --git a/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java b/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java new file mode 100644 index 0000000..2c4c815 --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java @@ -0,0 +1,15 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ProjectRecordVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface ClassTeachingDao { + ExperimentalTeachingEntity queryInvitationCode(ExperimentalTeachingEntity experimentEntity); + + IPage getByClassRecord(Page page1, @Param("cla") ProjectRecordVo recordVo); +} diff --git a/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java b/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java new file mode 100644 index 0000000..b84e107 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java @@ -0,0 +1,49 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 实验教学实体 + * + * @author Ning + */ +@Data +@TableName("tms_experimental_teaching") +@Accessors(chain = true) +public class ExperimentalTeachingEntity { + + //实验教学主键ID + @TableId + private Integer id; + //实验班级名称 + private String experimentalClassName; + //实验名称 + private String experimentalName; + //绑定项目id + private Integer projectId; + //绑定项目名称 + private String projectName; + //实验人数 + private Integer experimentalNumber; + //实验时长 + private String experimentDuration; + //发布类型 + private Integer type; + //启动时间 + private String startTime; + //结束时间 + private String stopTime; + //状态 + private Integer status; + //邀请码 +// private String invitationCode; + private Integer invitationCode; + //是否启用邀请码 + private Integer isCode; + //绑定用户Id + private Integer userId; + +} diff --git a/src/main/java/com/msdw/tms/entity/vo/ClassTeachingVo.java b/src/main/java/com/msdw/tms/entity/vo/ClassTeachingVo.java new file mode 100644 index 0000000..4d1dd07 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/vo/ClassTeachingVo.java @@ -0,0 +1,11 @@ +package com.msdw.tms.entity.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +@Data +@Accessors(chain = true) +public class ClassTeachingVo { + + +} diff --git a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java index 87bce36..99c08fa 100644 --- a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java @@ -2,10 +2,12 @@ package com.msdw.tms.entity.vo; import com.msdw.tms.entity.ProjectRecordEntity; import lombok.Data; +import lombok.experimental.Accessors; import java.io.Serializable; @Data +@Accessors(chain = true) public class ProjectRecordVo extends ProjectRecordEntity implements Serializable { /** @@ -56,9 +58,13 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable * 待评分 */ private Integer tobescored; - /** 记录状态(0 未修改,1 已修改)*/ + /** 记录状态(0 未修改,1 已修改)*/ private Integer recordState; // =====================================记录实验项目信息 + /** + * 实验状态(1待开始 2进行中 3已结束) + */ + private Integer status; // /** // * 班级实验状态,0 不限,1 未发布,2 进行中,3 已完成 // */ @@ -88,8 +94,4 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable // * 实验提示 // */ // private String projecttips; -// /** -// * 实验状态(0已发布 1未发布) -// */ -// private Integer projectstate; } diff --git a/src/main/java/com/msdw/tms/service/ClassTeachingService.java b/src/main/java/com/msdw/tms/service/ClassTeachingService.java new file mode 100644 index 0000000..f56b0d7 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ClassTeachingService.java @@ -0,0 +1,12 @@ +package com.msdw.tms.service; + +import com.msdw.tms.common.utils.PageUtils; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ProjectRecordVo; + +public interface ClassTeachingService { + + ExperimentalTeachingEntity queryInvitationcode(ExperimentalTeachingEntity experimentalTeachingEntity); + + PageUtils queryClassRecord(Integer page, Integer size, ProjectRecordVo recordVo); +} diff --git a/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java new file mode 100644 index 0000000..2456b85 --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java @@ -0,0 +1,35 @@ +package com.msdw.tms.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.msdw.tms.common.utils.Constant; +import com.msdw.tms.common.utils.PageUtils; +import com.msdw.tms.dao.ClassTeachingDao; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ProjectRecordVo; +import com.msdw.tms.service.ClassTeachingService; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ClassTeachingServiceImpl implements ClassTeachingService { + + @Autowired + private ClassTeachingDao classMapper; + @Override + public ExperimentalTeachingEntity queryInvitationcode(ExperimentalTeachingEntity experimentEntity) { + ExperimentalTeachingEntity ex = classMapper.queryInvitationCode(experimentEntity); + return ex; + } + + @Override + public PageUtils queryClassRecord(Integer page, Integer size, ProjectRecordVo recordVo) { + //分页对象 + Page page1 = new Page<>(page, size); + recordVo.setIsdel(Constant.IsDel.NOT_DEL.getType()); + IPage schoolRecord = this.classMapper.getByClassRecord(page1, recordVo); + PageUtils pageUtils = new PageUtils(schoolRecord); + return pageUtils; + } +} diff --git a/src/main/resources/mapper/tms/ClassTeachingDao.xml b/src/main/resources/mapper/tms/ClassTeachingDao.xml new file mode 100644 index 0000000..cec2eee --- /dev/null +++ b/src/main/resources/mapper/tms/ClassTeachingDao.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file