diff --git a/src/main/java/com/msdw/tms/api/ExperimentalProjectControllerApi.java b/src/main/java/com/msdw/tms/api/ExperimentalProjectControllerApi.java new file mode 100644 index 0000000..4e70d46 --- /dev/null +++ b/src/main/java/com/msdw/tms/api/ExperimentalProjectControllerApi.java @@ -0,0 +1,35 @@ +package com.msdw.tms.api; + +import com.msdw.tms.common.utils.R; +import com.msdw.tms.entity.ExperimentalProjectEntity; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +@Api(value = "实验项目",tags = "实验项目") +public interface ExperimentalProjectControllerApi { + + @ApiOperation(value = "实验项目列表",notes = "实验项目列表查询") + R list(@ApiParam(name = "page", value = "页码", required = true) Integer page, + @ApiParam(name = "size", value = "每页显示的数据条数", required = true) Integer size, + @ApiParam(name = "roleId", value = "创建人角色", required = false) Integer roleId, + @ApiParam(name = "status", value = "状态:1、草稿箱 2、已发布", required = false) Integer status, + @ApiParam(name = "experimentalProjectName", value = "根据项目名称搜索内容", required = false) String experimentalProjectName); + + @ApiOperation(value = "添加实验项目",notes = "添加实验项目") + R save(ExperimentalProjectEntity experimentalProjectEntity); + + @ApiOperation(value = "修改实验项目",notes = "修改实验项目") + R update(ExperimentalProjectEntity ExperimentalProjectEntity); + + @ApiOperation(value = "删除实验项目",notes = "删除实验项目") + R delete(Integer[] ids); + + @ApiOperation(value = "根据id查询实验项目详情",notes = "根据id查询实验项目详情") + R getById(Integer id); + + @ApiOperation(value = "根据实验项目名称查询",notes = "根据实验项目名称查询") + R getExperimentalProjectName(String experimentalProjectName); + +} diff --git a/src/main/java/com/msdw/tms/controller/ExperimentalProjectController.java b/src/main/java/com/msdw/tms/controller/ExperimentalProjectController.java new file mode 100644 index 0000000..049eed6 --- /dev/null +++ b/src/main/java/com/msdw/tms/controller/ExperimentalProjectController.java @@ -0,0 +1,119 @@ +package com.msdw.tms.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.msdw.tms.api.ExperimentalProjectControllerApi; +import com.msdw.tms.api.ExperimentalTeachingControllerApi; +import com.msdw.tms.api.UserControllerApi; +import com.msdw.tms.common.utils.Constant; +import com.msdw.tms.common.utils.PageUtils; +import com.msdw.tms.common.utils.R; +import com.msdw.tms.entity.ExperimentalProjectEntity; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.UserEntity; +import com.msdw.tms.entity.vo.ExperimentalProjectEntityVO; +import com.msdw.tms.entity.vo.ExperimentalTeachingEntityVO; +import com.msdw.tms.entity.vo.UserEntityVo; +import com.msdw.tms.service.ExperimentalProjectService; +import com.msdw.tms.service.UserService; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("tms/project") +public class ExperimentalProjectController implements ExperimentalProjectControllerApi { + + @Autowired + private ExperimentalProjectService experimentalProjectService; + + /** + * 根据实验项目名称查询 + */ + @GetMapping("/getExperimentalProjectName") + public R getExperimentalProjectName(@RequestParam String experimentalProjectName) { + ExperimentalProjectEntity one = experimentalProjectService.getOne(new QueryWrapper().eq("experimental_project_name", experimentalProjectName) + .eq("isdel", Constant.IsDel.NOT_DEL)); + return R.ok().put("experimental_project_name", one); + } + + /** + * 根据id查询实验班级详情 + */ + @GetMapping("/getById/{id}") + + public R getById(@PathVariable("id") Integer id){ + ExperimentalProjectEntity et = experimentalProjectService.getById(id); + return R.ok().put("ExperimentalTeaching", et); + } +// /** +// * 根据邀请码查询 +// */ +// @GetMapping("/getInvitationCode") +// public R getInvitationCode(@RequestParam Integer invitationCode) { +// ExperimentalProjectEntity one = experimentalProjectService.getOne(new QueryWrapper().eq("invitation_code", invitationCode) +// .eq("is_del", Constant.IsDel.NOT_DEL)); +// return R.ok().put("InvitationCode", one); +// } + /** + * 查询 + */ + @GetMapping("/list") + public R list(@RequestParam Integer page, + @RequestParam Integer size, + Integer roleId,Integer status,String experimentalProjectName){ + ExperimentalProjectEntityVO vo = new ExperimentalProjectEntityVO(); + if (roleId!=null){ + vo.setRoleId(roleId); + } + if (status!=null){ + vo.setStatus(status); + } + if (experimentalProjectName!=null&&experimentalProjectName!=""){ + vo.setExperimentalProjectName(experimentalProjectName); + } + PageUtils list = experimentalProjectService.queryExperimentalProject(page,size,vo); + return R.ok().put("list",list); + } + /** + * 保存 + */ + @PostMapping("/save") + public R save(@RequestBody ExperimentalProjectEntity experimentalProjectEntity){ + experimentalProjectService.save(experimentalProjectEntity); + return R.ok(); + } + + /** + * 修改 + */ + @PostMapping("/update") + public R update(@RequestBody ExperimentalProjectEntity experimentalProjectEntity){ + experimentalProjectService.updateById(experimentalProjectEntity); + + return R.ok(); + } + + /** + * 删除 + */ + @PostMapping("/delete") + public R delete(@RequestBody Integer[] ids){ + experimentalProjectService.removeByIds(Arrays.asList(ids)); + + return R.ok(); + } + +// /** +// * 修改 +// */ +// @PostMapping("/start") +// public R start(@RequestParam Integer id){ +// experimentalProjectService.updateById(experimentalTeachingEntity); +// +// return R.ok(); +// } +} diff --git a/src/main/java/com/msdw/tms/dao/ExperimentalProjectDao.java b/src/main/java/com/msdw/tms/dao/ExperimentalProjectDao.java new file mode 100644 index 0000000..e06d2c2 --- /dev/null +++ b/src/main/java/com/msdw/tms/dao/ExperimentalProjectDao.java @@ -0,0 +1,17 @@ +package com.msdw.tms.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.msdw.tms.entity.ExperimentalProjectEntity; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ExperimentalProjectEntityVO; +import com.msdw.tms.entity.vo.ExperimentalTeachingEntityVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface ExperimentalProjectDao extends BaseMapper { + + IPage queryExperimentalProject(Page page1, @Param("exp") ExperimentalProjectEntityVO vo); +} diff --git a/src/main/java/com/msdw/tms/entity/ExperimentalProjectEntity.java b/src/main/java/com/msdw/tms/entity/ExperimentalProjectEntity.java new file mode 100644 index 0000000..033d665 --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/ExperimentalProjectEntity.java @@ -0,0 +1,82 @@ +package com.msdw.tms.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** + * + * + * @author + * @email + * @date 2020-10-14 10:36:02 + */ +@Accessors(chain = true) +@Data +@TableName("tms_experimental_project") +public class ExperimentalProjectEntity implements Serializable, Comparable { + + private static final long serialVersionUID = 1L; + + /** + * 实验项目id + */ + @TableId + private Integer id; + /** + * 实验项目名称 + */ + private String experimentalProjectName; + /** + * 项目权限(1、练习 2、考核 3、竞赛) + */ + private Integer projectPermissions; + /** + * 实验目标 + */ + private String experimentGoal; + /** + * 案例描述 + */ + private String caseDescription; + /** + * 实验提示 + */ + private String experimentTips; + /** + * 知识点 + */ + private String knowledgePoints; + /** + * 实验介绍 + */ + private String experimentIntroduction; + /** + * 创建人 + */ + private Integer roleId; + /** + * 创建时间 + */ + private String createTime; + /** + * 删除(0未删除 1已删除) + */ + private Integer isdel; + + /** + * 状态(1、草稿箱 2、发布) + */ + private Integer status; + + + @Override + public int compareTo(Object o) { + ExperimentalProjectEntity projectEntity = (ExperimentalProjectEntity) o; + return this.id - projectEntity.id; + } +} diff --git a/src/main/java/com/msdw/tms/entity/vo/ExperimentalProjectEntityVO.java b/src/main/java/com/msdw/tms/entity/vo/ExperimentalProjectEntityVO.java new file mode 100644 index 0000000..3e987cc --- /dev/null +++ b/src/main/java/com/msdw/tms/entity/vo/ExperimentalProjectEntityVO.java @@ -0,0 +1,20 @@ +package com.msdw.tms.entity.vo; + +import lombok.Data; + +/** + * 实验教学实体 + * + * @author Ning + */ +@Data +public class ExperimentalProjectEntityVO { + + //创建人角色 + private Integer roleId; + //状态 + private Integer status; + //根据实验项目名称进行搜索 + private String experimentalProjectName; + +} diff --git a/src/main/java/com/msdw/tms/service/ExperimentalProjectService.java b/src/main/java/com/msdw/tms/service/ExperimentalProjectService.java new file mode 100644 index 0000000..284449d --- /dev/null +++ b/src/main/java/com/msdw/tms/service/ExperimentalProjectService.java @@ -0,0 +1,14 @@ +package com.msdw.tms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.msdw.tms.common.utils.PageUtils; +import com.msdw.tms.entity.ExperimentalProjectEntity; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ExperimentalProjectEntityVO; +import com.msdw.tms.entity.vo.ExperimentalTeachingEntityVO; + +public interface ExperimentalProjectService extends IService { + + PageUtils queryExperimentalProject(Integer page, Integer size, ExperimentalProjectEntityVO vo); + +} diff --git a/src/main/java/com/msdw/tms/service/impl/ExperimentalProjectServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ExperimentalProjectServiceImpl.java new file mode 100644 index 0000000..1e3a6ad --- /dev/null +++ b/src/main/java/com/msdw/tms/service/impl/ExperimentalProjectServiceImpl.java @@ -0,0 +1,39 @@ +package com.msdw.tms.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.msdw.tms.common.utils.PageUtils; +import com.msdw.tms.dao.ExperimentalProjectDao; +import com.msdw.tms.dao.ExperimentalTeachingDao; +import com.msdw.tms.entity.ExperimentalProjectEntity; +import com.msdw.tms.entity.ExperimentalTeachingEntity; +import com.msdw.tms.entity.vo.ExperimentalProjectEntityVO; +import com.msdw.tms.entity.vo.ExperimentalTeachingEntityVO; +import com.msdw.tms.service.ExperimentalProjectService; +import com.msdw.tms.service.ExperimentalTeachingService; +import org.apache.poi.ss.formula.functions.T; +import org.springframework.stereotype.Service; + +@Service("experimentalProjectService") +public class ExperimentalProjectServiceImpl extends ServiceImpl implements ExperimentalProjectService { + + +// @Override +// public PageUtils queryPage(Map params) { +// +// IPage page = this.page( +// new Query().getPage(params), +// new QueryWrapper() +// ); +// return new PageUtils(page); +// } + @Override + public PageUtils queryExperimentalProject(Integer page, Integer size, ExperimentalProjectEntityVO vo) { + Page page1 = new Page<>(page, size); + ExperimentalProjectDao userDao = this.getBaseMapper(); + IPage list = userDao.queryExperimentalProject(page1, vo); + PageUtils pageUtils = new PageUtils(list); + return pageUtils; + } +} diff --git a/src/main/resources/mapper/tms/ExperimentalProjectDao.xml b/src/main/resources/mapper/tms/ExperimentalProjectDao.xml new file mode 100644 index 0000000..515550e --- /dev/null +++ b/src/main/resources/mapper/tms/ExperimentalProjectDao.xml @@ -0,0 +1,35 @@ + + + + + + + + \ No newline at end of file