From f775fae316321896d80473404cdcb7e6a4b344ff Mon Sep 17 00:00:00 2001 From: Aurox Date: Tue, 23 Nov 2021 20:03:57 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E5=88=9B=E5=BB=BATokenManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/renren/components/TokenManager.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/io/renren/components/TokenManager.java diff --git a/src/main/java/io/renren/components/TokenManager.java b/src/main/java/io/renren/components/TokenManager.java new file mode 100644 index 0000000..50bbb27 --- /dev/null +++ b/src/main/java/io/renren/components/TokenManager.java @@ -0,0 +1,34 @@ +package io.renren.components; + +import io.jsonwebtoken.*; +import org.springframework.stereotype.Component; + +import java.util.Date; + +@Component +public class TokenManager { + //token有效时长 + private static long tokenEcpiration = 24 * 60 * 60 * 1000; + //编码秘钥 + private static String tokenSignKey = "ckedu_student_"; + + //1 使用jwt根据用户名生成token + public String createToken(String username) { + String token = Jwts.builder().setSubject(username) + .setExpiration(new Date(System.currentTimeMillis() + tokenEcpiration)) + .signWith(SignatureAlgorithm.HS512, tokenSignKey).compressWith(CompressionCodecs.GZIP).compact(); + return token; + } + + //2 根据token字符串得到用户信息 + public String getUserInfoFromToken(String token) { + token = token.substring(1, token.length() - 1); + Claims claims; + try { + claims = Jwts.parser().setSigningKey(tokenSignKey).parseClaimsJws(token).getBody(); + } catch (ExpiredJwtException e) { + claims = e.getClaims(); + } + return claims.getSubject(); + } +} -- Gitee From ca4a1b93f01dac01aea74f5f3d79902b8f2dfa51 Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 24 Nov 2021 00:08:37 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E5=9B=BE=E7=89=87=E3=80=81PPT=E3=80=81?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=87=E4=BB=B6=E7=9A=84=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=EF=BC=9BOssUtils=E5=B0=81=E8=A3=85=E4=BA=86=E8=8E=B7=E5=BE=97O?= =?UTF-8?q?SS=E5=AF=B9=E8=B1=A1=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/renren/common/utils/OssUtils.java | 31 +++++ .../controller/PictureController.java | 110 +++++++++++++++++- .../generator/controller/PptController.java | 102 +++++++++++++++- .../generator/controller/VideoController.java | 101 +++++++++++++++- .../generator/service/PictureService.java | 2 + .../modules/generator/service/PptService.java | 2 + .../generator/service/VideoService.java | 2 + .../service/impl/PictureServiceImpl.java | 9 ++ .../service/impl/PptServiceImpl.java | 8 ++ .../service/impl/VideoServiceImpl.java | 8 ++ 10 files changed, 366 insertions(+), 9 deletions(-) create mode 100644 src/main/java/io/renren/common/utils/OssUtils.java diff --git a/src/main/java/io/renren/common/utils/OssUtils.java b/src/main/java/io/renren/common/utils/OssUtils.java new file mode 100644 index 0000000..8cec693 --- /dev/null +++ b/src/main/java/io/renren/common/utils/OssUtils.java @@ -0,0 +1,31 @@ +package io.renren.common.utils; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; + +public class OssUtils { + private final static String endpoint = "http://oss-cn-beijing.aliyuncs.com"; + private final static String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; + private final static String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; + private final static String path = "ckedu2.oss-cn-beijing.aliyuncs.com"; + + public static OSS getOssClient() { + return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + } + + public static String getEndpoint() { + return endpoint; + } + + public static String getAccessKeyId() { + return accessKeyId; + } + + public static String getAccessKeySecret() { + return accessKeySecret; + } + + public static String getPath() { + return path; + } +} diff --git a/src/main/java/io/renren/modules/generator/controller/PictureController.java b/src/main/java/io/renren/modules/generator/controller/PictureController.java index 1029b30..9d50fca 100644 --- a/src/main/java/io/renren/modules/generator/controller/PictureController.java +++ b/src/main/java/io/renren/modules/generator/controller/PictureController.java @@ -1,8 +1,20 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; - +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClient; +import com.aliyun.oss.OSSClientBuilder; +import io.renren.common.utils.OssUtils; +import io.renren.components.TokenManager; +import io.renren.modules.generator.entity.TeacherEntity; +import io.renren.modules.generator.service.StudentService; +import io.renren.modules.generator.service.TeacherService; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +27,9 @@ import io.renren.modules.generator.entity.PictureEntity; import io.renren.modules.generator.service.PictureService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +45,96 @@ public class PictureController { @Autowired private PictureService pictureService; + @Autowired + private TokenManager tokenManager; + + @Autowired + private TeacherService teacherService; + + private static long num = 0; + + /** + * time: 2021.11.23 + * zhaomr + * 上传图片 + * + * @param file + * @param params + * @param request + * @return + * @throws IOException + */ + @RequestMapping("/insertPicture") + public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + +// String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + + String t_id = "123213123213123"; + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "picture/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String p_number = t_id.substring(0, 3) + type + num++; + fileName += p_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + PictureEntity pictureEntity = new PictureEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + pictureEntity.setPId(uid); + pictureEntity.setPName(file.getOriginalFilename()); + + if(params.get("p_introduce") != null) + pictureEntity.setPIntroduce((String) params.get("p_introduce")); + + pictureEntity.setPNumber(p_number); + pictureEntity.setPLink(OssUtils.getPath() + fileName); + + int result = pictureService.insertPicture(pictureEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + List> maplist =new ArrayList<>(); + Map map = new HashMap<>(); + map.put("p_number", p_number); + map.put("p_link", pictureEntity.getPLink()); + maplist.add(map); + + return R.ok("导入成功!").put("data", maplist); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/PptController.java b/src/main/java/io/renren/modules/generator/controller/PptController.java index 17d9273..560b0f5 100644 --- a/src/main/java/io/renren/modules/generator/controller/PptController.java +++ b/src/main/java/io/renren/modules/generator/controller/PptController.java @@ -1,8 +1,16 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; - +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import io.renren.components.TokenManager; +import io.renren.modules.generator.entity.PictureEntity; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +23,9 @@ import io.renren.modules.generator.entity.PptEntity; import io.renren.modules.generator.service.PptService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +41,92 @@ public class PptController { @Autowired private PptService pptService; + @Autowired + private TokenManager tokenManager; + + private static long num = 0; + + /** + * time: 2021.11.23 + * zhaomr + * 上传ppt + * + * @param file + * @param params + * @param request + * @return + * @throws IOException + */ + @RequestMapping("/insertPpt") + public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "ppt/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + + String pt_number = t_id.substring(0, 3) + type + num++; + fileName += pt_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + PptEntity pptEntity = new PptEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + pptEntity.setPtId(uid); + pptEntity.setPtName(file.getOriginalFilename()); + + if(params.get("pt_introduce") != null) + pptEntity.setPtIntroduce((String) params.get("pt_introduce")); + + pptEntity.setPtNumber(pt_number); + pptEntity.setPtLink(OssUtils.getPath() + fileName); + + int result = pptService.insertPpt(pptEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + List> maplist =new ArrayList<>(); + Map map = new HashMap<>(); + map.put("pt_number", pt_number); + map.put("p_link", pptEntity.getPtLink()); + maplist.add(map); + + return R.ok("导入成功!").put("data", maplist); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/VideoController.java b/src/main/java/io/renren/modules/generator/controller/VideoController.java index 510ddaf..78f3810 100644 --- a/src/main/java/io/renren/modules/generator/controller/VideoController.java +++ b/src/main/java/io/renren/modules/generator/controller/VideoController.java @@ -1,8 +1,16 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; - +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import io.renren.components.TokenManager; +import io.renren.modules.generator.entity.PptEntity; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -15,7 +23,9 @@ import io.renren.modules.generator.entity.VideoEntity; import io.renren.modules.generator.service.VideoService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +41,91 @@ public class VideoController { @Autowired private VideoService videoService; + @Autowired + private TokenManager tokenManager; + + private static int num = 0; + + /** + * time: 2021.11.23 + * zhaomr + * 上传视频 + * + * @param file + * @param params + * @param request + * @return + * @throws IOException + */ + @RequestMapping("/insertVideo") + public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "video/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String v_number = t_id.substring(0, 3) + type + num++; + fileName += v_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + VideoEntity videoEntity = new VideoEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + videoEntity.setVId(uid); + videoEntity.setVName(file.getOriginalFilename()); + + if(params.get("v_introduce") != null) + videoEntity.setVIntroduce((String) params.get("v_introduce")); + + videoEntity.setVNumber(v_number); + videoEntity.setVLink(OssUtils.getPath() + fileName); + + int result = videoService.insertVideo(videoEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + List> maplist =new ArrayList<>(); + Map map = new HashMap<>(); + map.put("v_number", v_number); + map.put("p_link", videoEntity.getVLink()); + maplist.add(map); + + return R.ok("导入成功!").put("data", maplist); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/service/PictureService.java b/src/main/java/io/renren/modules/generator/service/PictureService.java index 45c9d34..a2d71e1 100644 --- a/src/main/java/io/renren/modules/generator/service/PictureService.java +++ b/src/main/java/io/renren/modules/generator/service/PictureService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface PictureService extends IService { PageUtils queryPage(Map params); + + int insertPicture(PictureEntity pictureEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/PptService.java b/src/main/java/io/renren/modules/generator/service/PptService.java index 7cdb777..f1e3f89 100644 --- a/src/main/java/io/renren/modules/generator/service/PptService.java +++ b/src/main/java/io/renren/modules/generator/service/PptService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface PptService extends IService { PageUtils queryPage(Map params); + + int insertPpt(PptEntity pptEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/VideoService.java b/src/main/java/io/renren/modules/generator/service/VideoService.java index 4379166..ed40fae 100644 --- a/src/main/java/io/renren/modules/generator/service/VideoService.java +++ b/src/main/java/io/renren/modules/generator/service/VideoService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface VideoService extends IService { PageUtils queryPage(Map params); + + int insertVideo(VideoEntity videoEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java index 5615cdd..9136224 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java @@ -1,5 +1,7 @@ package io.renren.modules.generator.service.impl; +import io.renren.common.exception.RRException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +18,9 @@ import io.renren.modules.generator.service.PictureService; @Service("pictureService") public class PictureServiceImpl extends ServiceImpl implements PictureService { + @Autowired + private PictureDao pictureDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +31,8 @@ public class PictureServiceImpl extends ServiceImpl i return new PageUtils(page); } + @Override + public int insertPicture(PictureEntity pictureEntity) { + return pictureDao.insert(pictureEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java index 3f2d478..9df2059 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +17,9 @@ import io.renren.modules.generator.service.PptService; @Service("pptService") public class PptServiceImpl extends ServiceImpl implements PptService { + @Autowired + private PptDao pptDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +30,8 @@ public class PptServiceImpl extends ServiceImpl implements Pp return new PageUtils(page); } + @Override + public int insertPpt(PptEntity pptEntity) { + return pptDao.insert(pptEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java index 6edfbf8..123bc42 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +17,9 @@ import io.renren.modules.generator.service.VideoService; @Service("videoService") public class VideoServiceImpl extends ServiceImpl implements VideoService { + @Autowired + private VideoDao videoDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +30,8 @@ public class VideoServiceImpl extends ServiceImpl impleme return new PageUtils(page); } + @Override + public int insertVideo(VideoEntity videoEntity) { + return videoDao.insert(videoEntity); + } } \ No newline at end of file -- Gitee From 8a962d998f59b875b497dd5f51a364ac0b548012 Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 24 Nov 2021 01:06:26 +0800 Subject: [PATCH 03/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9PictureController?= =?UTF-8?q?=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/generator/controller/PictureController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/PictureController.java b/src/main/java/io/renren/modules/generator/controller/PictureController.java index 9d50fca..c7ce73d 100644 --- a/src/main/java/io/renren/modules/generator/controller/PictureController.java +++ b/src/main/java/io/renren/modules/generator/controller/PictureController.java @@ -70,9 +70,10 @@ public class PictureController { return R.error("文件为空!"); } -// String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); - String t_id = "123213123213123"; +// 测试 +// String t_id = "123123123123"; if(StringUtils.isEmpty(t_id)) { return R.error("token不存在"); -- Gitee From 3f12c619dc2680a8f5dece44bac931e89be8a81c Mon Sep 17 00:00:00 2001 From: Aurox Date: Fri, 26 Nov 2021 00:02:39 +0800 Subject: [PATCH 04/22] =?UTF-8?q?ActivemodelController=E7=9A=84=E7=BC=96?= =?UTF-8?q?=E5=86=99=20=E6=97=A2=E7=9B=B8=E5=85=B3Service=E7=9A=84?= =?UTF-8?q?=E4=B9=A6=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActivemodelController.java | 523 ++++++++++++++++-- .../controller/AnswerController.java | 82 ++- .../generator/entity/ActivemodelEntity.java | 2 +- .../generator/entity/ClassesEntity.java | 4 + .../generator/service/ActionmodelService.java | 21 + .../generator/service/ActivemodelService.java | 39 ++ .../generator/service/AnswerService.java | 21 + .../generator/service/ClassesService.java | 29 + .../generator/service/FeetbackService.java | 11 + .../generator/service/PictureService.java | 2 + .../generator/service/QuestionService.java | 10 + .../generator/service/StudentService.java | 11 + .../generator/service/TeacherService.java | 2 + .../service/impl/ActionmodelServiceImpl.java | 18 +- .../service/impl/ActivemodelServiceImpl.java | 45 +- .../service/impl/AnswerServiceImpl.java | 16 + .../service/impl/ClassesServiceImpl.java | 63 ++- .../service/impl/FeetbackServiceImpl.java | 9 +- .../service/impl/PictureServiceImpl.java | 24 + .../service/impl/QuestionServiceImpl.java | 7 + .../service/impl/StudentServiceImpl.java | 9 + .../service/impl/TeacherServiceImpl.java | 11 + .../mapper/generator/ActivemodelDao.xml | 2 +- .../resources/mapper/generator/ClassesDao.xml | 1 + 24 files changed, 896 insertions(+), 66 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java index d1237bb..e89cd3c 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java @@ -1,10 +1,11 @@ package io.renren.modules.generator.controller; +import java.io.IOException; import java.util.*; -import io.renren.modules.generator.entity.ActionmodelEntity; -import io.renren.modules.generator.entity.QuestionEntity; -import io.renren.modules.generator.service.ActionmodelService; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.convert.MapToPropertiesConverter; @@ -14,11 +15,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.ActivemodelEntity; -import io.renren.modules.generator.service.ActivemodelService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; /** @@ -33,81 +34,525 @@ import io.renren.common.utils.R; public class ActivemodelController { @Autowired private ActivemodelService activemodelService; + @Autowired private ActionmodelService actionmodelService; + @Autowired + private ClassesService classesService; + + @Autowired + private StudentService studentService; + + @Autowired + private QuestionService questionService; + + @Autowired + private AnswerService answerService; + + @Autowired + private FeetbackService feetbackService; + + @Autowired + private PictureService pictureService; + //2021 11/20 接口类型: "读" 测试人:ZhangShiYu //根据单元的id获取该单元所有的活动 @RequestMapping("/getAllActive") - public R getAllActive(@RequestParam Map params){ + public R getAllActive(@RequestParam Map params) { Object unit_id = params.get("unit_id"); - if (unit_id==null) + if (unit_id == null) return R.error("传递字段缺少"); List allActiveModel = activemodelService.getAllActiveModel(unit_id.toString()); - if (allActiveModel==null) + if (allActiveModel == null) return R.error("没有这个单元"); - return R.ok().put("active_list",allActiveModel); + return R.ok().put("active_list", allActiveModel); } //2021 11/21 接口类型: "读" 测试人:ZhangShiYu //根据活动的id获取该活动下的所有的板块以及板块的题目 @RequestMapping("/getAll") - public R getAllActionAndQuestion(@RequestParam Map params){ + public R getAllActionAndQuestion(@RequestParam Map params) { //获取活动id Object a_id = params.get("a_id"); - if (a_id==null) + if (a_id == null) return R.error("传递字段缺少"); //根据活动id查询该活动下的所有的板块实体 List allActionByAId = actionmodelService.getAllActionByAId(a_id.toString()); //创建一个Map数组 - ArrayList> arrayList=new ArrayList<>(); + ArrayList> arrayList = new ArrayList<>(); //遍历板块实体 for (ActionmodelEntity actionmodelEntity : allActionByAId) { //创建一个小Map - Map map1=new HashMap<>(); + Map map1 = new HashMap<>(); //首先把板块实体放入小Map里面 - map1.put("act",actionmodelEntity); + map1.put("act", actionmodelEntity); //根据板块实体去查该板块所有的题目 List allQuestionByActId = actionmodelService.getAllQuestionByActId(actionmodelEntity.getActionId()); - List> maps=new ArrayList<>(); + List> maps = new ArrayList<>(); for (QuestionEntity questionEntity : allQuestionByActId) { - Map map=new HashMap<>(); - map.put("qtitle",questionEntity.getQTitle());//问题标题 - map.put("qid",questionEntity.getQId());//问题id - map.put("qtype",questionEntity.getQType());//问题类型 - map.put("qpictureid",questionEntity.getQPicnumbers());//问题图片id - map.put("qnumber",questionEntity.getQNumber());//问题题号 - map.put("needbackexplore",questionEntity.getQIsallowreturnexplore());//是否需要回到探究 - map.put("multiple",questionEntity.getQIsmutiplecommit());//是否可以重复提交 - map.put("ischeckanswer",questionEntity.getQIscheckanswer());//是否可以查看答案正误 - if (questionEntity.getQType().equals("2")||questionEntity.getQType().equals("3")) - map.put("choice",questionEntity.getQOption().split(",,"));//分割开选项变成数组 - else{ + Map map = new HashMap<>(); + map.put("qtitle", questionEntity.getQTitle());//问题标题 + map.put("qid", questionEntity.getQId());//问题id + map.put("qtype", questionEntity.getQType());//问题类型 + map.put("qpictureid", questionEntity.getQPicnumbers());//问题图片id + map.put("qnumber", questionEntity.getQNumber());//问题题号 + map.put("needbackexplore", questionEntity.getQIsallowreturnexplore());//是否需要回到探究 + map.put("multiple", questionEntity.getQIsmutiplecommit());//是否可以重复提交 + map.put("ischeckanswer", questionEntity.getQIscheckanswer());//是否可以查看答案正误 + if (questionEntity.getQType().equals("2") || questionEntity.getQType().equals("3")) + map.put("choice", questionEntity.getQOption().split(",,"));//分割开选项变成数组 + else { ArrayList arrayList1 = new ArrayList<>(); arrayList1.add(questionEntity.getQOption()); - map.put("choice",arrayList1); + map.put("choice", arrayList1); } maps.add(map);//放入 } //把题目放入小Map里面 - map1.put("question_list",maps); + map1.put("question_list", maps); //把小map放入Map数组里面 arrayList.add(map1); } //返回Map数组 - return R.ok().put("info",arrayList); + return R.ok().put("info", arrayList); + + } + + /** + * 2021.11.24 + * zhaomr + * 新建活动 + * + * @param params 请求参数 + * @param request HttpServletRequest + * @return R + */ + @RequestMapping("/insertActive") + public R insertActive(@RequestParam Map params, HttpServletRequest request) { + String act_name = (String) params.get("act_name"); + String act_introduce = (String) params.get("act_introduce"); + String act_picNumber = (String) params.get("act_picNumber"); + + //此值应该通过token来获得还是通过参数获得 + String act_uid = (String) params.get("act_uid"); + + if (act_name == null || act_uid == null) return R.error("缺少参数!"); + + String uuid = UUID.randomUUID().toString().replace("-", "").trim(); + + if (StringUtils.isEmpty(uuid)) return R.error("uuid生成失败"); + + if(activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); + + ActivemodelEntity activemodelEntity = new ActivemodelEntity(); + + activemodelEntity.setActId(uuid); + activemodelEntity.setActName(act_name); + activemodelEntity.setActIntroduce(act_introduce); + //如果未传入picNumber 应该给一个默认值 + //可以在这里加一个判断,也可以前端通过ajax请求来获得一个默认值 直接传给picNumber + activemodelEntity.setActPicnumber(act_picNumber); + + activemodelEntity.setActUid(act_uid); + + int result = activemodelService.insertActive(activemodelEntity); + + if (result <= 0) return R.error("导入数据库失z败!"); + else { + return R.ok("新建成功!"); + } + } + + /** + * 2021.11.24 + * zhaomr + * 根据id删除活动 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/deleteById") + public R deleteById(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + + if (act_id == null) return R.error("缺少参数!"); + + int result = activemodelService.deleteById(act_id); + + if (result == 0) return R.error("删除失败!该活动不存在或操作数据库失败失败!"); + else { + return R.ok("删除成功"); + } + } + + /** + * 2021.11.21 + * zhaomr + * 更新活动的信息 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/updateActiveModel") + public R updateActiveModel(@RequestParam Map params) { + String act_name = (String) params.get("act_name"); + String act_introduce = (String) params.get("act_introduce"); + String act_picNumber = (String) params.get("act_picNumber"); + String act_id = (String) params.get("act_id"); + + if (act_name == null || act_id == null) return R.error("缺少参数!"); + + ActivemodelEntity activemodelEntity = activemodelService.getById(act_id); + + if(activemodelEntity == null) return R.error("修改失败!该活动不存在"); + + activemodelEntity.setActName(act_name); + activemodelEntity.setActPicnumber(act_picNumber); + activemodelEntity.setActIntroduce(act_introduce); + + int result = activemodelService.update(activemodelEntity); + + if (result == 0) return R.error("修改失败!导入数据库失败!"); + + return R.ok("修改成功!"); + } + + /** + * 2021.11.24 + * zhaomr + * 更改班级的开放状态 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/updateClassesOpen") + public R updateClassesOpen(@RequestParam Map params) { + String c_number = (String) params.get("c_number"); + String act_id = (String) params.get("act_id"); + + if (c_number == null || act_id == null) return R.error("缺少参数!"); + + ClassesEntity classesEntity = classesService.getByNumber(c_number); + + if(classesEntity == null) return R.error("更改失败!该班级未创建"); + + classesEntity.setCAid(act_id); + + int result = classesService.update(classesEntity); + + if(result == 0) return R.error("更改失败!导入数据库异常"); + + return R.ok("更改成功!"); + } + + /** + * 2021.11.24 + * zhaomr + * 评价作业 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/evaluateHomework") + public R evaluateHomework(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + //当前页数 + String pn = (String) params.get("pn"); + //每页记录数 + String ps = (String) params.get("ps"); + + String classNumber = (String) params.get("c_number"); + + if (act_id == null) return R.error("缺少参数!"); + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + List studentEntityList = new ArrayList<>(); + + if (classNumber == null) { + List classesEntityList = classesService.getByCAid(act_id); + + if (classesEntityList == null) return R.error("当前活动没有班级!"); + + for (ClassesEntity classesEntity : classesEntityList) { + List nowList = studentService.getBySTclass(classesEntity.getCId()); + + if(nowList != null) + studentEntityList.addAll(nowList); + } + } else { + ClassesEntity classesEntity = classesService.getByNumber(classNumber); + studentEntityList = studentService.getBySTclass(classesEntity.getCId()); + } + + if (studentEntityList.size() == 0) return R.error("该班级没有学生!"); + + ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, "5"); + + if(actionmodelEntity == null) return R.error("该动作未创建!"); + + String actionId = actionmodelEntity.getActionId(); + + //解释模块所有问题 + List questionEntityList = questionService.getByActionId(actionId); + + if(questionEntityList == null) return R.error("该动作内还未添加题目"); + + QuestionEntity questionEntity = questionEntityList.get(1); + + List> mapList = new ArrayList<>(); + + for (StudentEntity studentEntity : studentEntityList) { + Map map = new HashMap<>(); + + map.put("id", studentEntity.getSId()); + map.put("action_id", actionId); + map.put("username", studentEntity.getSUsername()); + map.put("class", studentEntity.getSTclassnumber()); + map.put("sid", studentEntity.getSSid()); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(studentEntity.getSId(), questionEntity.getQId()); + + if (answerEntity == null) { + map.put("state", "false"); + map.put("submitTime", "none"); + map.put("feetTime", "none"); + map.put("score", "none"); + } else { + map.put("state", "true"); + map.put("submitTime", answerEntity.getASubtime()); + + FeetbackEntity feetbackEntity = feetbackService.getByActionIdAndSId(actionId, studentEntity.getSId()); + + if (feetbackEntity == null) { + map.put("feetTime", "none"); + map.put("score", "none"); + } else { + map.put("feetTime", feetbackEntity.getFeetTime()); + + String level = feetbackEntity.getFeetLevel(); + int score = Integer.parseInt(level); + + map.put("score", score > 5 ? score : score * 20); + } + } + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); } + + /** + * 2021.11.25 + * zhaomr + * 批阅题目 + * + * @param params 传入参数 + * @return R + */ + @RequestMapping("/remark") + public R remark(@RequestParam Map params) { + String s_id = (String) params.get("s_id"); + String action_id = (String) params.get("action_id"); + + if (s_id == null || action_id == null) return R.error("缺少参数!"); + + //不用再判断这个是否为空,因为只有在进入批阅题目的裂变之后才能进入这个方法,所以一定已经创建 + List questionEntityList = questionService.getByActionId(action_id); + + List> mapList = new ArrayList<>(); + + for (QuestionEntity questionEntity : questionEntityList) { + Map map = new HashMap<>(); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(s_id, questionEntity.getQId()); + map.put("title", questionEntity.getQTitle()); + map.put("type", questionEntity.getQType()); + map.put("option", questionEntity.getQOption()); + map.put("standardAnserwer", questionEntity.getQStandardanserwer()); + + if (answerEntity == null) map.put("context", "none"); + else { + map.put("context", answerEntity.getAContext()); + + FeetbackEntity feetbackEntity = feetbackService.getByActionIdAndSId(action_id, s_id); + + if(feetbackEntity != null) { + map.put("score", feetbackEntity.getFeetLevel()); + map.put("feetContext", feetbackEntity.getFeetContent()); + } + } + + if (questionEntity.getQPicnumbers() != null) { + String link = ""; + + String picnumbers = questionEntity.getQPicnumbers(); + + int i = picnumbers.indexOf(",,"); + + if (i == -1) { + PictureEntity pictureEntity = pictureService.getByNumber(picnumbers); + + link = pictureEntity.getPLink(); + } else { + String picnumber = picnumbers.substring(0, i); + + PictureEntity pictureEntity = pictureService.getByNumber(picnumber); + + link += pictureEntity.getPLink(); + + while (i != -1) { + int k = i; + i = picnumbers.indexOf(",,", i + 1); + + if (i == -1) picnumber = picnumbers.substring(k + 2); + else picnumber = picnumbers.substring(k + 2, i); + + pictureEntity = pictureService.getByNumber(picnumber); + link += ",," + pictureEntity.getPLink(); + } + } + + map.put("link", link); + } + + mapList.add(map); + } + + return R.ok("加载成功").put("data", mapList); + } + + /** + * 2021.11.25 + * zhaomr + * 查询不同动作的问题的回答情况 + * + * @param params 参数列表 + * @return R + */ + //可不可以在调用这个请求的时候将之后可能用到的信息一起传给前端 + //之后可能会查看正确人员和错误人员的列表,能不能在这个方法中统一传出 + //反思模块要查的东西不一样 不确定 !!! + @RequestMapping("/selectCompletion") + private R selectCompletion(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + String action_number = (String) params.get("action_number"); + //当前是第几页 + String pn = (String) params.get("pn"); + //每页记录数 + String ps = (String) params.get("ps"); + + if (act_id == null) return R.error("缺少参数!"); + + if (action_number == null) action_number = "1"; + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + System.out.println("act_id:" + act_id + "action_number:" + action_number); + + //actionmodelService为空 + ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, action_number); + + List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); + + List> mapList = new ArrayList<>(); + + for (QuestionEntity questionEntity : questionEntityList) { + Map map = new HashMap<>(); + + map.put("title", questionEntity.getQTitle()); + + List answerEntityList = answerService.getByQId(questionEntity.getQId()); + + int num = 0; + + for (AnswerEntity answerEntity : answerEntityList) + if("true".equals(answerEntity.getAIstrue())) num++; + + map.put("successPeople", num); + map.put("failPeople", answerEntityList.size() - num); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + + @RequestMapping("/selectAllCompletion") + public R selectAllCompletion(@RequestParam Map params) { + String act_id = (String) params.get("act_id"); + //当前页数 + String pn = (String) params.get("pn"); + //每页记录数 + String ps = (String) params.get("ps"); + + String classNumber = (String) params.get("c_number"); + + if (act_id == null) return R.error("缺少参数!"); + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + List studentEntityList = new ArrayList<>(); + + if (classNumber == null) { + List classesEntityList = classesService.getByCAid(act_id); + + if (classesEntityList == null) return R.error("当前活动没有班级!"); + + for (ClassesEntity classesEntity : classesEntityList) { + List nowList = studentService.getBySTclass(classesEntity.getCId()); + + if(nowList != null) + studentEntityList.addAll(nowList); + } + } else { + ClassesEntity classesEntity = classesService.getByNumber(classNumber); + studentEntityList = studentService.getBySTclass(classesEntity.getCId()); + } + + if (studentEntityList.size() == 0) return R.error("该班级没有学生!"); + + List> mapList = new ArrayList<>(); + + for (StudentEntity studentEntity : studentEntityList) { + Map map = new HashMap<>(); + + map.put("id", studentEntity.getSId()); + map.put("name", studentEntity.getSName()); + map.put("class", studentEntity.getSTclassnumber()); + map.put("sid", studentEntity.getSSid()); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + /** * 列表 */ @RequestMapping("/list") @RequiresPermissions("generator:activemodel:list") - public R list(@RequestParam Map params){ + public R list(@RequestParam Map params) { PageUtils page = activemodelService.queryPage(params); return R.ok().put("page", page); @@ -119,8 +564,8 @@ public class ActivemodelController { */ @RequestMapping("/info/{actId}") @RequiresPermissions("generator:activemodel:info") - public R info(@PathVariable("actId") String actId){ - ActivemodelEntity activemodel = activemodelService.getById(actId); + public R info(@PathVariable("actId") String actId) { + ActivemodelEntity activemodel = activemodelService.getById(actId); return R.ok().put("activemodel", activemodel); } @@ -130,8 +575,8 @@ public class ActivemodelController { */ @RequestMapping("/save") @RequiresPermissions("generator:activemodel:save") - public R save(@RequestBody ActivemodelEntity activemodel){ - activemodelService.save(activemodel); + public R save(@RequestBody ActivemodelEntity activemodel) { + activemodelService.save(activemodel); return R.ok(); } @@ -141,8 +586,8 @@ public class ActivemodelController { */ @RequestMapping("/update") @RequiresPermissions("generator:activemodel:update") - public R update(@RequestBody ActivemodelEntity activemodel){ - activemodelService.updateById(activemodel); + public R update(@RequestBody ActivemodelEntity activemodel) { + activemodelService.updateById(activemodel); return R.ok(); } @@ -152,8 +597,8 @@ public class ActivemodelController { */ @RequestMapping("/delete") @RequiresPermissions("generator:activemodel:delete") - public R delete(@RequestBody String[] actIds){ - activemodelService.removeByIds(Arrays.asList(actIds)); + public R delete(@RequestBody String[] actIds) { + activemodelService.removeByIds(Arrays.asList(actIds)); return R.ok(); } diff --git a/src/main/java/io/renren/modules/generator/controller/AnswerController.java b/src/main/java/io/renren/modules/generator/controller/AnswerController.java index db0c79b..77e9396 100644 --- a/src/main/java/io/renren/modules/generator/controller/AnswerController.java +++ b/src/main/java/io/renren/modules/generator/controller/AnswerController.java @@ -1,8 +1,11 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; +import java.util.*; +import io.renren.modules.generator.entity.ActionmodelEntity; +import io.renren.modules.generator.entity.QuestionEntity; +import io.renren.modules.generator.service.ActionmodelService; +import io.renren.modules.generator.service.QuestionService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -32,6 +35,12 @@ public class AnswerController { @Autowired private AnswerService answerService; + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private QuestionService questionService; + //根据问题id和学生id和回答内容插入学生的答案(多选题需要在前端以,,分割) @RequestMapping("/insertAnswer") public R insertAnswer(@RequestParam Map params){ @@ -47,6 +56,75 @@ public class AnswerController { return R.error("插入失败,问题id不存在"); } + + /** + * 2021.11.25 + * zhaomr + * 获得某个学生这个活动中的全部答题情况 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/selectOneStudentQuestions") + public R selectOneStudentQuestions(@RequestParam Map params) { + String sId = (String) params.get("s_id"); + String actId = (String) params.get("act_id"); + + if(sId == null || actId == null) return R.error("缺少参数"); + + List actionmodelEntityList = actionmodelService.getByActId(actId); + + List>> arrayList = new ArrayList<>(); + + for (ActionmodelEntity actionmodelEntity : actionmodelEntityList) { + List> mapList = new ArrayList<>(); + + List questionEntities = questionService.getByActionId(actionmodelEntity.getActionId()); + + if(questionEntities.size() == 0) continue; + + //如果是解释板块的话 只展示客观题 + if("5".equals(actionmodelEntity.getActionNumber())) { + Map map = new HashMap<>(); + + QuestionEntity questionEntity = questionEntities.get(0); + map.put("title", questionEntity.getQTitle()); + map.put("option", questionEntity.getQOption()); + map.put("standardAnserwer", questionEntity.getQStandardanserwer()); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(sId, questionEntity.getQId()); + + if(answerEntity == null) map.put("status", "该学生还未回答该题"); + else { + map.put("context", answerEntity.getAContext()); + map.put("istrue", answerEntity.getAIstrue()); + } + + mapList.add(map); + }else { + for (QuestionEntity questionEntity : questionEntities) { + Map map = new HashMap<>(); + + map.put("title", questionEntity.getQTitle()); + map.put("option", questionEntity.getQOption()); + map.put("standardAnserwer", questionEntity.getQStandardanserwer()); + + AnswerEntity answerEntity = answerService.getBySIdAndQId(sId, questionEntity.getQId()); + + if(answerEntity == null) map.put("status", "该学生还未回答该题"); + else { + map.put("context", answerEntity.getAContext()); + map.put("istrue", answerEntity.getAIstrue()); + } + mapList.add(map); + } + } + + arrayList.add(mapList); + } + + return R.ok("查询成功!").put("data", arrayList); + } /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java b/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java index 05e0663..3250da1 100644 --- a/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java @@ -55,7 +55,7 @@ public class ActivemodelEntity implements Serializable { /** * 活动开放的班级组 */ - private String actClassList; +// private String actClassList; /** * 活动开放的班级组 diff --git a/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java b/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java index ef59bb8..7afce57 100644 --- a/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java @@ -40,5 +40,9 @@ public class ClassesEntity implements Serializable { * 课程id */ private String cMid; + /** + * 活动id + */ + private String cAid; } diff --git a/src/main/java/io/renren/modules/generator/service/ActionmodelService.java b/src/main/java/io/renren/modules/generator/service/ActionmodelService.java index ea62f27..65a1206 100644 --- a/src/main/java/io/renren/modules/generator/service/ActionmodelService.java +++ b/src/main/java/io/renren/modules/generator/service/ActionmodelService.java @@ -25,5 +25,26 @@ public interface ActionmodelService extends IService { PageUtils queryPage(Map params); + + /** + * 2021.11.24 + * zhaomr + * 根据活动id和动作号来查找 + * + * @param action_actid 活动id + * @param action_number 动作号 + * @return ActionmodelEntity + */ + ActionmodelEntity getByActIdAndNumber(String action_actid, String action_number); + + /** + * 2021.11.25 + * zhaomr + * 根据活动id查找其下所有动作 + * + * @param actId 活动id + * @return List + */ + List getByActId(String actId); } diff --git a/src/main/java/io/renren/modules/generator/service/ActivemodelService.java b/src/main/java/io/renren/modules/generator/service/ActivemodelService.java index e4ebeaf..4810e60 100644 --- a/src/main/java/io/renren/modules/generator/service/ActivemodelService.java +++ b/src/main/java/io/renren/modules/generator/service/ActivemodelService.java @@ -22,5 +22,44 @@ public interface ActivemodelService extends IService { //根据单元id获得所有的活动实体对象 List getAllActiveModel(String unitId); + /** + * 2021.11.24 + * zhaomr + * 插入活动 + * + * @param activemodelEntity 活动实体 + * @return 影响行数 + */ + int insertActive(ActivemodelEntity activemodelEntity); + + /** + * 2021.11.24 + * zhaomr + * 根据id删除 + * + * @param act_id 活动id + * @return 影响行数 + */ + int deleteById(String act_id); + + /** + * 2021.11.24 + * zhaomr + * 更新活动 + * + * @param activemodelEntity 活动实体 + * @return 影响行数 + */ + int update(ActivemodelEntity activemodelEntity); + + /** + * 2021.11.25 + * zhaomr + * 根据name查找 + * + * @param act_name + * @return + */ + ActivemodelEntity getByName(String act_name); } diff --git a/src/main/java/io/renren/modules/generator/service/AnswerService.java b/src/main/java/io/renren/modules/generator/service/AnswerService.java index 0388eaa..9299682 100644 --- a/src/main/java/io/renren/modules/generator/service/AnswerService.java +++ b/src/main/java/io/renren/modules/generator/service/AnswerService.java @@ -27,5 +27,26 @@ public interface AnswerService extends IService { Boolean insertAnswer(String qId,String sId,String context); PageUtils queryPage(Map params); + + /** + * 2021.11.24 + * zhaomr + * 根据学生id和问题id查找回答 + * + * @param sId 学生id + * @param qId 问题id + * @return AnswerEntity + */ + AnswerEntity getBySIdAndQId(String sId, String qId); + + /** + * 2021.11.25 + * zhaomr + * 根据问题id查找回答 + * + * @param qId 问题id + * @return List + */ + List getByQId(String qId); } diff --git a/src/main/java/io/renren/modules/generator/service/ClassesService.java b/src/main/java/io/renren/modules/generator/service/ClassesService.java index b33239e..b62a738 100644 --- a/src/main/java/io/renren/modules/generator/service/ClassesService.java +++ b/src/main/java/io/renren/modules/generator/service/ClassesService.java @@ -57,5 +57,34 @@ public interface ClassesService extends IService { //根据班级id获得所有的课程实体对象 List getAllClassModel(String classId); + /** + * 2021.11.24 + * zhaomr + * 根据班号查询班级 + * + * @param c_number 班号 + * @return ClassesEntity + */ + ClassesEntity getByNumber(String c_number); + + /** + * 2021.11.24 + * zhaomr + * 查询这个活动下所有班级 + * + * @param cAid 活动id + * @return List + */ + List getByCAid(String cAid); + + /** + * 2021.11.24 + * zhaomr + * 修改班级信息 + * + * @param classesEntity 班级实体 + * @return int 影响行数 + */ + int update(ClassesEntity classesEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/FeetbackService.java b/src/main/java/io/renren/modules/generator/service/FeetbackService.java index c99dc95..713ac88 100644 --- a/src/main/java/io/renren/modules/generator/service/FeetbackService.java +++ b/src/main/java/io/renren/modules/generator/service/FeetbackService.java @@ -33,5 +33,16 @@ public interface FeetbackService extends IService { //根据反馈id和学生id将此反馈标志为学生已经查看 Boolean changeStateOfFeet(String fId,String sId); + + /** + * 2021.11.24 + * zhaomr + * 根据动作id和学生id查找 + * + * @param actionId 动作id + * @param sId 学生id + * @return FeetbackEntity + */ + FeetbackEntity getByActionIdAndSId(String actionId, String sId); } diff --git a/src/main/java/io/renren/modules/generator/service/PictureService.java b/src/main/java/io/renren/modules/generator/service/PictureService.java index a2d71e1..e681fd0 100644 --- a/src/main/java/io/renren/modules/generator/service/PictureService.java +++ b/src/main/java/io/renren/modules/generator/service/PictureService.java @@ -18,5 +18,7 @@ public interface PictureService extends IService { PageUtils queryPage(Map params); int insertPicture(PictureEntity pictureEntity); + + PictureEntity getByNumber(String pNumber); } diff --git a/src/main/java/io/renren/modules/generator/service/QuestionService.java b/src/main/java/io/renren/modules/generator/service/QuestionService.java index 0534e19..5b3df37 100644 --- a/src/main/java/io/renren/modules/generator/service/QuestionService.java +++ b/src/main/java/io/renren/modules/generator/service/QuestionService.java @@ -20,5 +20,15 @@ public interface QuestionService extends IService { //根据板块id获取该板块所有的问题 List getAllQuestion(String act_id); + + /** + * 2021.11.24 + * zhaomr + * 根据动作id获得该动作下所有问题 + * + * @param actionId 动作id + * @return List + */ + List getByActionId(String actionId); } diff --git a/src/main/java/io/renren/modules/generator/service/StudentService.java b/src/main/java/io/renren/modules/generator/service/StudentService.java index a16a7de..bb717cf 100644 --- a/src/main/java/io/renren/modules/generator/service/StudentService.java +++ b/src/main/java/io/renren/modules/generator/service/StudentService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.generator.entity.StudentEntity; +import java.util.List; import java.util.Map; /** @@ -32,5 +33,15 @@ public interface StudentService extends IService { * @return */ boolean deleteStudentById(String s_id); + + /** + * 2021.11.24 + * zhaomr + * 通过班级id查找所有学生 + * + * @param cTclass 班级id + * @return List + */ + List getBySTclass(String cTclass); } diff --git a/src/main/java/io/renren/modules/generator/service/TeacherService.java b/src/main/java/io/renren/modules/generator/service/TeacherService.java index b6ed290..218941d 100644 --- a/src/main/java/io/renren/modules/generator/service/TeacherService.java +++ b/src/main/java/io/renren/modules/generator/service/TeacherService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface TeacherService extends IService { PageUtils queryPage(Map params); + + TeacherEntity getByUN(String username); } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java index 38e095e..8890135 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import io.renren.modules.generator.dao.QuestionDao; import io.renren.modules.generator.entity.QuestionEntity; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +21,6 @@ import io.renren.modules.generator.service.ActionmodelService; @Service("actionmodelService") public class ActionmodelServiceImpl extends ServiceImpl implements ActionmodelService { - @Autowired ActionmodelDao actionmodelDao; @@ -58,4 +58,20 @@ public class ActionmodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("action_actid", action_actid); + queryWrapper.eq("action_number", action_number); + + return actionmodelDao.selectOne(queryWrapper); + } + + @Override + public List getByActId(String actId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("action_actid", actId); + + return actionmodelDao.selectList(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java index 1e641fa..a5f62a8 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java @@ -19,7 +19,6 @@ import io.renren.modules.generator.service.ActivemodelService; @Service("activemodelService") public class ActivemodelServiceImpl extends ServiceImpl implements ActivemodelService { - @Autowired ActivemodelDao activemodelDao; @@ -44,6 +43,50 @@ public class ActivemodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("act_name", act_name); + + return activemodelDao.selectOne(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java index 34ddc3f..3f70234 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java @@ -174,4 +174,20 @@ public class AnswerServiceImpl extends ServiceImpl impl return new PageUtils(page); } + @Override + public AnswerEntity getBySIdAndQId(String sId, String qId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("a_sid", sId); + queryWrapper.eq("a_qid", qId); + + return answerDao.selectOne(queryWrapper); + } + + @Override + public List getByQId(String qId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("a_qid", qId); + + return answerDao.selectList(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java index 3ad8b86..ad5eaf6 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ClassesServiceImpl.java @@ -28,10 +28,10 @@ public class ClassesServiceImpl extends ServiceImpl i @Autowired private ClassesDao classesDao; - ClassesDao classesDao; @Autowired ClassmodelDao classmodelDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -48,7 +48,7 @@ public class ClassesServiceImpl extends ServiceImpl i * @param cMid 课程id * @param cNumber 班号(班级名称) * @param cIntroduce 班级简介 - * int x 判断班级名称(班号)是否唯一,若班级名称不唯一(int x==1)返回false + * int x 判断班级名称(班号)是否唯一,若班级名称不唯一(int x==1)返回false * @return */ @Override @@ -57,8 +57,8 @@ public class ClassesServiceImpl extends ServiceImpl i QueryWrapper queryWrapper = new QueryWrapper<>(); QueryWrapper c_number = queryWrapper.eq("c_number", cNumber); ClassesEntity classes1 = classesDao.selectOne(c_number); - x = classes1==null?0:1; - if(x==0){ + x = classes1 == null ? 0 : 1; + if (x == 0) { ClassesEntity classes = new ClassesEntity(); UUID.randomUUID().toString(); classes.setCId(UUID.randomUUID().toString()); @@ -66,7 +66,7 @@ public class ClassesServiceImpl extends ServiceImpl i classes.setCIntroduce(cIntroduce); classes.setCMid(cMid); int insert = classesDao.insert(classes); - return insert>0?true:false; + return insert > 0 ? true : false; } return false; } @@ -93,43 +93,42 @@ public class ClassesServiceImpl extends ServiceImpl i * @return */ @Override - public boolean updateClassNumberById(String cid,String cNumber) { + public boolean updateClassNumberById(String cid, String cNumber) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); UpdateWrapper set = updateWrapper.eq("c_id", cid).set("c_number", cNumber); int update = classesDao.update(null, updateWrapper); - return update>0?true:false; + return update > 0 ? true : false; } /** - * 通过班级表里的班级id去修改班级简介 + * 通过班级表里的班级id去删除班级 * * @param cid - * @param cIntroduce * @return */ @Override - public boolean updateClassIntroduceById(String cid, String cIntroduce) { + public boolean deleteClassById(String cid) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - UpdateWrapper set = updateWrapper.eq("c_id", cid).set("c_introduce", cIntroduce); - int update = classesDao.update(null, updateWrapper); - return update>0?true:false; + UpdateWrapper c_id = updateWrapper.eq("c_id", cid); + int delete = classesDao.delete(c_id); + return delete > 0 ? true : false; } /** - * 通过班级表里的班级id去删除班级 + * 通过班级表里的班级id去修改班级简介 * * @param cid + * @param cIntroduce * @return */ @Override - public boolean deleteClassById(String cid) { + public boolean updateClassIntroduceById(String cid, String cIntroduce) { UpdateWrapper updateWrapper = new UpdateWrapper<>(); - UpdateWrapper c_id = updateWrapper.eq("c_id", cid); - int delete = classesDao.delete(c_id); - return delete>0?true:false; + UpdateWrapper set = updateWrapper.eq("c_id", cid).set("c_introduce", cIntroduce); + int update = classesDao.update(null, updateWrapper); + return update > 0 ? true : false; } -} //根据班级id获取所有的课程对象 如果班级不存在返回null @Override public List getAllClassModel(String classId) { @@ -151,4 +150,30 @@ public class ClassesServiceImpl extends ServiceImpl i return arrayList; } + /** + * 通过班号查找班级 + * + * @param c_number + * @return + */ + @Override + public ClassesEntity getByNumber(String c_number) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("c_number", c_number); + + return classesDao.selectOne(queryWrapper); + } + + @Override + public List getByCAid(String cAid) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("c_aid", cAid); + + return classesDao.selectList(queryWrapper); + } + + @Override + public int update(ClassesEntity classesEntity) { + return classesDao.updateById(classesEntity); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java index 9ad6cda..c56ea94 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java @@ -96,7 +96,12 @@ public class FeetbackServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("feet_actionid", actionId); + queryWrapper.eq("feet_sid", sId); - - + return feetbackDao.selectOne(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java index 9136224..0aef48d 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java @@ -31,8 +31,32 @@ public class PictureServiceImpl extends ServiceImpl i return new PageUtils(page); } + /** + * 2021.11.23 + * zhaomr + * 上传图片 + * + * @param pictureEntity 图片实体 + * @return 影响行数 + */ @Override public int insertPicture(PictureEntity pictureEntity) { return pictureDao.insert(pictureEntity); } + + /** + * 2021.11.25 + * zhaomr + * 根据图片号找照片 + * + * @param pNumber 图片号 + * @return 图片实体 + */ + @Override + public PictureEntity getByNumber(String pNumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("p_number", pNumber); + + return pictureDao.selectOne(queryWrapper); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java index 84918b7..fe4da6e 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java @@ -40,4 +40,11 @@ public class QuestionServiceImpl extends ServiceImpl getByActionId(String actionId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("q_actionId", actionId); + + return questionDao.selectList(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java index c988563..cc2a23b 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/StudentServiceImpl.java @@ -3,6 +3,8 @@ package io.renren.modules.generator.service.impl; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.List; import java.util.Map; import java.util.UUID; @@ -72,4 +74,11 @@ public class StudentServiceImpl extends ServiceImpl i return i>0?true:false; } + @Override + public List getBySTclass(String cTclass) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("s_tclass", cTclass); + + return studentDao.selectList(queryWrapper); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java index 38d6a7d..db87fcb 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/TeacherServiceImpl.java @@ -1,5 +1,6 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +17,9 @@ import io.renren.modules.generator.service.TeacherService; @Service("teacherService") public class TeacherServiceImpl extends ServiceImpl implements TeacherService { + @Autowired + private TeacherDao teacherDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +30,11 @@ public class TeacherServiceImpl extends ServiceImpl i return new PageUtils(page); } + @Override + public TeacherEntity getByUN(String username) { + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("s_username",username); + TeacherEntity entity = teacherDao.selectOne(wrapper); + return entity; + } } \ No newline at end of file diff --git a/src/main/resources/mapper/generator/ActivemodelDao.xml b/src/main/resources/mapper/generator/ActivemodelDao.xml index 77dd9f2..09f3f6c 100644 --- a/src/main/resources/mapper/generator/ActivemodelDao.xml +++ b/src/main/resources/mapper/generator/ActivemodelDao.xml @@ -13,6 +13,6 @@ - + diff --git a/src/main/resources/mapper/generator/ClassesDao.xml b/src/main/resources/mapper/generator/ClassesDao.xml index e6c08ca..396999c 100644 --- a/src/main/resources/mapper/generator/ClassesDao.xml +++ b/src/main/resources/mapper/generator/ClassesDao.xml @@ -10,6 +10,7 @@ + -- Gitee From ce632cc44c91dc71acef22ef6ba4428064c04a69 Mon Sep 17 00:00:00 2001 From: Aurox Date: Fri, 26 Nov 2021 18:48:22 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E8=A1=A5=E5=85=85activemodelController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 9 +- .../controller/ActivemodelController.java | 17 ++- .../generator/util/OssUploadService.java | 113 ------------------ .../generator/utils/OssUploadService.java | 113 ------------------ src/main/resources/application-dev.yml | 2 +- src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 2 +- 7 files changed, 25 insertions(+), 233 deletions(-) delete mode 100644 src/main/java/io/renren/modules/generator/util/OssUploadService.java delete mode 100644 src/main/java/io/renren/modules/generator/utils/OssUploadService.java diff --git a/pom.xml b/pom.xml index e9f3ec5..78aa7d7 100644 --- a/pom.xml +++ b/pom.xml @@ -40,7 +40,7 @@ 2.8.5 1.2.72 4.1.1 - 1.18.4 + 1.18.20 /work/renren @@ -75,6 +75,8 @@ aliyun-sdk-oss 3.10.2 + + @@ -93,6 +95,9 @@ + + + javax.xml.bind jaxb-api @@ -306,6 +311,7 @@ org.springframework.boot spring-boot-maven-plugin + 2.2.6.RELEASE true @@ -314,6 +320,7 @@ org.apache.maven.plugins maven-surefire-plugin + 2.12.4 true diff --git a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java index e89cd3c..d303a0e 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java @@ -144,12 +144,12 @@ public class ActivemodelController { if (act_name == null || act_uid == null) return R.error("缺少参数!"); + if(activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); + String uuid = UUID.randomUUID().toString().replace("-", "").trim(); if (StringUtils.isEmpty(uuid)) return R.error("uuid生成失败"); - if(activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); - ActivemodelEntity activemodelEntity = new ActivemodelEntity(); activemodelEntity.setActId(uuid); @@ -163,7 +163,7 @@ public class ActivemodelController { int result = activemodelService.insertActive(activemodelEntity); - if (result <= 0) return R.error("导入数据库失z败!"); + if (result <= 0) return R.error("导入数据库失败!"); else { return R.ok("新建成功!"); } @@ -212,6 +212,8 @@ public class ActivemodelController { if(activemodelEntity == null) return R.error("修改失败!该活动不存在"); + if(activemodelService.getByName(act_name) != null) return R.error("修改失败!该活动名已存在"); + activemodelEntity.setActName(act_name); activemodelEntity.setActPicnumber(act_picNumber); activemodelEntity.setActIntroduce(act_introduce); @@ -256,6 +258,7 @@ public class ActivemodelController { * zhaomr * 评价作业 * + * * @param params 请求参数 * @return R */ @@ -493,6 +496,14 @@ public class ActivemodelController { return R.ok("查询成功!").put("pageUtil", pageUtil); } + /** + * 2021.11.25 + * zhaomr + * 查询所有学生的答题情况 + * + * @param params 请求参数 + * @return R + */ @RequestMapping("/selectAllCompletion") public R selectAllCompletion(@RequestParam Map params) { String act_id = (String) params.get("act_id"); diff --git a/src/main/java/io/renren/modules/generator/util/OssUploadService.java b/src/main/java/io/renren/modules/generator/util/OssUploadService.java deleted file mode 100644 index 28caa15..0000000 --- a/src/main/java/io/renren/modules/generator/util/OssUploadService.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.renren.modules.generator.util; - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClient; -import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.model.PutObjectRequest; -import io.renren.modules.oss.entity.SysOssEntity; -import org.springframework.web.multipart.MultipartFile; - -import java.io.*; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.UUID; - -//阿里云文件上传工具类 -public class OssUploadService { - - //测试 - public static void main(String[] args) { - String uploadFile= uploadFileByFile(new File("C:\\Users\\张世宇\\Desktop\\开发需求.txt")); - System.out.println(uploadFile); - } - - public static String uploadFileByFile(File multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= new FileInputStream(multipartFile); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getName(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } - - public static String uploadFileByMultipartFile(MultipartFile multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= multipartFile.getInputStream(); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getOriginalFilename(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } -} diff --git a/src/main/java/io/renren/modules/generator/utils/OssUploadService.java b/src/main/java/io/renren/modules/generator/utils/OssUploadService.java deleted file mode 100644 index 9cece6c..0000000 --- a/src/main/java/io/renren/modules/generator/utils/OssUploadService.java +++ /dev/null @@ -1,113 +0,0 @@ -package io.renren.modules.generator.utils; - -import com.aliyun.oss.OSS; -import com.aliyun.oss.OSSClient; -import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.model.PutObjectRequest; -import io.renren.modules.oss.entity.SysOssEntity; -import org.springframework.web.multipart.MultipartFile; - -import java.io.*; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.UUID; - -//阿里云文件上传工具类 -public class OssUploadService { - - //测试 - public static void main(String[] args) { - String uploadFile= uploadFileByFile(new File("C:\\Users\\张世宇\\Desktop\\开发需求.txt")); - System.out.println(uploadFile); - } - - public static String uploadFileByFile(File multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= new FileInputStream(multipartFile); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getName(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } - - public static String uploadFileByMultipartFile(MultipartFile multipartFile){ - - // yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。 - String endpoint = "oss-cn-beijing.aliyuncs.com"; - // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 - String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; - String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - String BUCKETNAME="ckedu2"; - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); - try { - // 获取文件上传的流 - InputStream inputStream= multipartFile.getInputStream(); - - //构建日期目录 - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); - String datePath = dateFormat.format(new Date()); - - //获取文件名 - String originname=multipartFile.getOriginalFilename(); - String filename= UUID.randomUUID().toString(); - String suffix = originname.substring(originname.lastIndexOf(".")); - String newName=filename + suffix; - String fileUrl= datePath+"/"+newName; - // 创建PutObjectRequest对象。 - // 依次填写Bucket名称(例如examplebucket)和Object完整路径(例如exampledir/exampleobject.txt)。Object完整路径中不能包含Bucket名称。 - // PutObjectRequest putObjectRequest = new PutObjectRequest(BUCKETNAME, fileUrl, new ByteArrayInputStream(content.getBytes())); - - // 如果需要上传时设置存储类型和访问权限,请参考以下示例代码。 - // ObjectMetadata metadata = new ObjectMetadata(); - // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); - // metadata.setObjectAcl(CannedAccessControlList.Private); - // putObjectRequest.setMetadata(metadata); - // 上传文件 - ossClient.putObject(BUCKETNAME,fileUrl,inputStream); - return "https://"+BUCKETNAME+"."+endpoint+"/"+fileUrl; - }catch (Exception e){ - e.printStackTrace(); - return "fail"; - }finally { - // 关闭OSSClient。 - ossClient.shutdown(); - } - } -} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index c8a6571..ed756c1 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a374b00..922bd52 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index a374b00..922bd52 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 -- Gitee From f79ea12900b28c6ae88c27ff8c74d2bf4f78184d Mon Sep 17 00:00:00 2001 From: Aurox Date: Sun, 28 Nov 2021 20:19:54 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E8=A1=A5=E5=85=85activemodelController?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActivemodelController.java | 96 +++++++++++++++++-- 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java index d303a0e..6811ea4 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java @@ -7,6 +7,7 @@ import io.renren.modules.generator.entity.*; import io.renren.modules.generator.service.*; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.convert.MapToPropertiesConverter; import org.springframework.web.bind.annotation.PathVariable; @@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -244,7 +246,11 @@ public class ActivemodelController { if(classesEntity == null) return R.error("更改失败!该班级未创建"); - classesEntity.setCAid(act_id); + if(classesEntity.getCAid().equals(act_id)) { + classesEntity.setCAid(""); + }else { + classesEntity.setCAid(act_id); + } int result = classesService.update(classesEntity); @@ -293,6 +299,9 @@ public class ActivemodelController { } } else { ClassesEntity classesEntity = classesService.getByNumber(classNumber); + + if(classesEntity == null) return R.error("该班级不存在"); + studentEntityList = studentService.getBySTclass(classesEntity.getCId()); } @@ -371,7 +380,7 @@ public class ActivemodelController { if (s_id == null || action_id == null) return R.error("缺少参数!"); - //不用再判断这个是否为空,因为只有在进入批阅题目的裂变之后才能进入这个方法,所以一定已经创建 + //不用再判断这个是否为空,因为只有在进入批阅题目的界面之后才能进入这个方法,所以一定已经创建 List questionEntityList = questionService.getByActionId(action_id); List> mapList = new ArrayList<>(); @@ -444,11 +453,8 @@ public class ActivemodelController { * @param params 参数列表 * @return R */ - //可不可以在调用这个请求的时候将之后可能用到的信息一起传给前端 - //之后可能会查看正确人员和错误人员的列表,能不能在这个方法中统一传出 - //反思模块要查的东西不一样 不确定 !!! @RequestMapping("/selectCompletion") - private R selectCompletion(@RequestParam Map params) { + public R selectCompletion(@RequestParam Map params) { String act_id = (String) params.get("act_id"); String action_number = (String) params.get("action_number"); //当前是第几页 @@ -464,11 +470,10 @@ public class ActivemodelController { if (ps == null) ps = "10"; - System.out.println("act_id:" + act_id + "action_number:" + action_number); - - //actionmodelService为空 ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, action_number); + if(actionmodelEntity == null) return R.error("该动作还未创建"); + List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); List> mapList = new ArrayList<>(); @@ -485,6 +490,7 @@ public class ActivemodelController { for (AnswerEntity answerEntity : answerEntityList) if("true".equals(answerEntity.getAIstrue())) num++; + map.put("q_id", questionEntity.getQId()); map.put("successPeople", num); map.put("failPeople", answerEntityList.size() - num); @@ -558,6 +564,77 @@ public class ActivemodelController { return R.ok("查询成功!").put("pageUtil", pageUtil); } + + @RequestMapping("/getSuccessStudent") + public R getSuccessStudent(@RequestParam Map params) { + String q_id = (String) params.get("q_id"); + String pn = (String) params.get("pn"); + String ps = (String) params.get("ps"); + + if (q_id == null) return R.error("缺少参数!"); + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + List> mapList = new ArrayList<>(); + + List answerEntityList = answerService.getByQId(q_id); + + + for (AnswerEntity answerEntity : answerEntityList) + if("true".equals(answerEntity.getAIstrue())) { + Map map = new HashMap<>(); + + StudentEntity studentEntity = studentService.getById(answerEntity.getASid()); + + map.put("name", studentEntity.getSName()); + map.put("classNumber", studentEntity.getSTclassnumber()); + map.put("studentNumber", studentEntity.getSSid()); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + + @RequestMapping("/getFailStudent") + public R getFailStudent(@RequestParam Map params) { + String q_id = (String) params.get("q_id"); + String pn = (String) params.get("pn"); + String ps = (String) params.get("ps"); + + if (q_id == null) return R.error("缺少参数!"); + + if (pn == null) pn = "1"; + + if (ps == null) ps = "10"; + + List> mapList = new ArrayList<>(); + + List answerEntityList = answerService.getByQId(q_id); + + + for (AnswerEntity answerEntity : answerEntityList) + if("false".equals(answerEntity.getAIstrue())) { + Map map = new HashMap<>(); + + StudentEntity studentEntity = studentService.getById(answerEntity.getASid()); + + map.put("name", studentEntity.getSName()); + map.put("classNumber", studentEntity.getSTclassnumber()); + map.put("studentNumber", studentEntity.getSSid()); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功!").put("pageUtil", pageUtil); + } + /** * 列表 */ @@ -569,7 +646,6 @@ public class ActivemodelController { return R.ok().put("page", page); } - /** * 信息 */ -- Gitee From dbf248aa0df3be34a15f3b8f73caa3acf659a10c Mon Sep 17 00:00:00 2001 From: Aurox Date: Mon, 29 Nov 2021 23:10:26 +0800 Subject: [PATCH 07/22] =?UTF-8?q?QuesionController=E3=80=81=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E7=B1=BB=E7=9A=84=E7=BB=86=E8=8A=82=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/renren/common/utils/OssUtils.java | 2 +- .../controller/ActionmodelController.java | 14 +- .../controller/ActivemodelController.java | 125 +++++++++++++----- .../controller/PictureController.java | 89 +++++++++++-- .../generator/controller/PptController.java | 82 +++++++++++- .../controller/QuestionController.java | 61 +++++++++ .../controller/StudentController.java | 1 + .../controller/UnitmodelController.java | 86 ++++++++++++ .../generator/controller/VideoController.java | 82 +++++++++++- .../generator/service/ActionmodelService.java | 3 + .../generator/service/AnswerService.java | 10 ++ .../generator/service/FeetbackService.java | 10 ++ .../generator/service/PictureService.java | 2 + .../modules/generator/service/PptService.java | 2 + .../generator/service/QuestionService.java | 20 +++ .../generator/service/ResourcesService.java | 32 +++++ .../generator/service/TextService.java | 2 + .../generator/service/UnitmodelService.java | 40 ++++++ .../generator/service/VideoService.java | 2 + .../generator/service/VideologService.java | 2 + .../service/impl/ActionmodelServiceImpl.java | 8 ++ .../service/impl/ActivemodelServiceImpl.java | 75 ++++++++++- .../service/impl/AnswerServiceImpl.java | 10 ++ .../service/impl/FeetbackServiceImpl.java | 9 ++ .../service/impl/PictureServiceImpl.java | 19 +++ .../service/impl/PptServiceImpl.java | 19 +++ .../service/impl/QuestionServiceImpl.java | 14 ++ .../service/impl/ResourcesServiceImpl.java | 64 ++++++++- .../service/impl/TextServiceImpl.java | 10 ++ .../service/impl/UnitmodelServiceImpl.java | 48 ++++++- .../service/impl/VideoServiceImpl.java | 20 +++ .../service/impl/VideologServiceImpl.java | 14 ++ 32 files changed, 900 insertions(+), 77 deletions(-) diff --git a/src/main/java/io/renren/common/utils/OssUtils.java b/src/main/java/io/renren/common/utils/OssUtils.java index 8cec693..8e113b4 100644 --- a/src/main/java/io/renren/common/utils/OssUtils.java +++ b/src/main/java/io/renren/common/utils/OssUtils.java @@ -7,7 +7,7 @@ public class OssUtils { private final static String endpoint = "http://oss-cn-beijing.aliyuncs.com"; private final static String accessKeyId = "LTAI5tDF24ysrBBSaHfk7uNi"; private final static String accessKeySecret = "H3YolcFdB1Tiy0LTrMa7fXJ3CVZW10"; - private final static String path = "ckedu2.oss-cn-beijing.aliyuncs.com"; + private final static String path = "ckedu2.oss-cn-beijing.aliyuncs.com/"; public static OSS getOssClient() { return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); diff --git a/src/main/java/io/renren/modules/generator/controller/ActionmodelController.java b/src/main/java/io/renren/modules/generator/controller/ActionmodelController.java index 5334461..e925ea7 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActionmodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActionmodelController.java @@ -8,6 +8,7 @@ import io.renren.modules.generator.dao.ActionmodelDao; import io.renren.modules.generator.entity.ActivemodelEntity; import io.renren.modules.generator.entity.QuestionEntity; import io.renren.modules.generator.entity.UnitmodelEntity; +import io.renren.modules.generator.service.FeetbackService; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -142,6 +143,7 @@ public class ActionmodelController { if(actionmodelService.deleteOption(que_id,answer,option)){ return R.ok(); } + return R.error("插入选项失败"); } @@ -171,10 +173,8 @@ public class ActionmodelController { } } - //如果是问答模块,需要的信息更多 - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("action_id",action_id); - ActionmodelEntity actionmodelEntity = actionmodelDao.selectOne(updateWrapper); + ActionmodelEntity actionmodelEntity = actionmodelService.getByActionId(action_id); + String actionName = actionmodelEntity.getActionName(); if(actionName.equals("问答板块") && (q_isAllowReturnExplore==null ||q_isCheckAnswer == null ||q_isMutipleCommit == null)){ return R.error("问答题请求参数缺少"); @@ -227,10 +227,8 @@ public class ActionmodelController { } } - //如果是问答模块,需要的信息更多 - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("action_id",action_id); - ActionmodelEntity actionmodelEntity = actionmodelDao.selectOne(updateWrapper); + ActionmodelEntity actionmodelEntity = actionmodelService.getByActionId(action_id); + String actionName = actionmodelEntity.getActionName(); if(actionName.equals("问答板块") && (q_isAllowReturnExplore==null ||q_isCheckAnswer == null ||q_isMutipleCommit == null)){ return R.error("问答题请求参数缺少"); diff --git a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java index 6811ea4..0e35321 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java @@ -10,6 +10,8 @@ import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.convert.MapToPropertiesConverter; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -58,6 +60,11 @@ public class ActivemodelController { @Autowired private PictureService pictureService; + @Autowired + private UnitmodelService unitmodelService; + + + //2021 11/20 接口类型: "读" 测试人:ZhangShiYu //根据单元的id获取该单元所有的活动 @RequestMapping("/getAllActive") @@ -135,18 +142,19 @@ public class ActivemodelController { * @param request HttpServletRequest * @return R */ + @Transactional @RequestMapping("/insertActive") public R insertActive(@RequestParam Map params, HttpServletRequest request) { String act_name = (String) params.get("act_name"); String act_introduce = (String) params.get("act_introduce"); String act_picNumber = (String) params.get("act_picNumber"); - - //此值应该通过token来获得还是通过参数获得 String act_uid = (String) params.get("act_uid"); if (act_name == null || act_uid == null) return R.error("缺少参数!"); - if(activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); + if (activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); + + if(unitmodelService.getById(act_uid) == null) return R.error("单元未创建"); String uuid = UUID.randomUUID().toString().replace("-", "").trim(); @@ -166,15 +174,51 @@ public class ActivemodelController { int result = activemodelService.insertActive(activemodelEntity); if (result <= 0) return R.error("导入数据库失败!"); - else { - return R.ok("新建成功!"); + + List s = new ArrayList<>(); + s.add(""); + s.add("预习板块"); + s.add("预测板块"); + s.add("探究板块"); + s.add("问答板块"); + s.add("解释板块"); + s.add("测评板块"); + s.add("反思板块"); + s.add("反馈板块"); + + for (int i = 1; i < 9; i++) { + ActionmodelEntity actionmodelEntity = new ActionmodelEntity(); + + String uUid = UUID.randomUUID().toString().replace("-", "").trim(); + + if (StringUtils.isEmpty(uUid)) { + //手动事物回滚 + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("uuids生成失败"); + } + + actionmodelEntity.setActionId(uUid); + actionmodelEntity.setActionActid(uuid); + actionmodelEntity.setActionNumber(i + ""); + actionmodelEntity.setActionName(s.get(i)); + + int res = actionmodelService.addAction(actionmodelEntity); + + if (res <= 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("动作新建失败!"); + } } + + return R.ok("新建成功!").put("act_id", uuid); } /** * 2021.11.24 * zhaomr * 根据id删除活动 + * 删除要有关联性,要连带删除 question、answer、feetback、resources + * 在Service层实现 * * @param params 请求参数 * @return R @@ -187,10 +231,9 @@ public class ActivemodelController { int result = activemodelService.deleteById(act_id); - if (result == 0) return R.error("删除失败!该活动不存在或操作数据库失败失败!"); - else { - return R.ok("删除成功"); - } + if (result == 0) return R.error("删除失败!该活动不存在或资源不存在或操作数据库失败失败!"); + + return R.ok("删除成功"); } /** @@ -212,9 +255,9 @@ public class ActivemodelController { ActivemodelEntity activemodelEntity = activemodelService.getById(act_id); - if(activemodelEntity == null) return R.error("修改失败!该活动不存在"); + if (activemodelEntity == null) return R.error("修改失败!该活动不存在"); - if(activemodelService.getByName(act_name) != null) return R.error("修改失败!该活动名已存在"); + if (activemodelService.getByName(act_name) != null) return R.error("修改失败!该活动名已存在"); activemodelEntity.setActName(act_name); activemodelEntity.setActPicnumber(act_picNumber); @@ -244,17 +287,17 @@ public class ActivemodelController { ClassesEntity classesEntity = classesService.getByNumber(c_number); - if(classesEntity == null) return R.error("更改失败!该班级未创建"); + if (classesEntity == null) return R.error("更改失败!该班级未创建"); - if(classesEntity.getCAid().equals(act_id)) { + if (classesEntity.getCAid().equals(act_id)) { classesEntity.setCAid(""); - }else { + } else { classesEntity.setCAid(act_id); } int result = classesService.update(classesEntity); - if(result == 0) return R.error("更改失败!导入数据库异常"); + if (result == 0) return R.error("更改失败!导入数据库异常"); return R.ok("更改成功!"); } @@ -264,7 +307,6 @@ public class ActivemodelController { * zhaomr * 评价作业 * - * * @param params 请求参数 * @return R */ @@ -294,13 +336,13 @@ public class ActivemodelController { for (ClassesEntity classesEntity : classesEntityList) { List nowList = studentService.getBySTclass(classesEntity.getCId()); - if(nowList != null) + if (nowList != null) studentEntityList.addAll(nowList); } } else { ClassesEntity classesEntity = classesService.getByNumber(classNumber); - if(classesEntity == null) return R.error("该班级不存在"); + if (classesEntity == null) return R.error("该班级不存在"); studentEntityList = studentService.getBySTclass(classesEntity.getCId()); } @@ -309,14 +351,14 @@ public class ActivemodelController { ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, "5"); - if(actionmodelEntity == null) return R.error("该动作未创建!"); + if (actionmodelEntity == null) return R.error("该动作未创建!"); String actionId = actionmodelEntity.getActionId(); //解释模块所有问题 List questionEntityList = questionService.getByActionId(actionId); - if(questionEntityList == null) return R.error("该动作内还未添加题目"); + if (questionEntityList == null) return R.error("该动作内还未添加题目"); QuestionEntity questionEntity = questionEntityList.get(1); @@ -400,7 +442,7 @@ public class ActivemodelController { FeetbackEntity feetbackEntity = feetbackService.getByActionIdAndSId(action_id, s_id); - if(feetbackEntity != null) { + if (feetbackEntity != null) { map.put("score", feetbackEntity.getFeetLevel()); map.put("feetContext", feetbackEntity.getFeetContent()); } @@ -472,7 +514,7 @@ public class ActivemodelController { ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(act_id, action_number); - if(actionmodelEntity == null) return R.error("该动作还未创建"); + if (actionmodelEntity == null) return R.error("该动作还未创建"); List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); @@ -488,7 +530,7 @@ public class ActivemodelController { int num = 0; for (AnswerEntity answerEntity : answerEntityList) - if("true".equals(answerEntity.getAIstrue())) num++; + if ("true".equals(answerEntity.getAIstrue())) num++; map.put("q_id", questionEntity.getQId()); map.put("successPeople", num); @@ -536,7 +578,7 @@ public class ActivemodelController { for (ClassesEntity classesEntity : classesEntityList) { List nowList = studentService.getBySTclass(classesEntity.getCId()); - if(nowList != null) + if (nowList != null) studentEntityList.addAll(nowList); } } else { @@ -565,6 +607,14 @@ public class ActivemodelController { } + /** + * 2021.11.28 + * zhaomr + * 查询回答正确的学生 + * + * @param params 请求参数 + * @return R + */ @RequestMapping("/getSuccessStudent") public R getSuccessStudent(@RequestParam Map params) { String q_id = (String) params.get("q_id"); @@ -581,25 +631,32 @@ public class ActivemodelController { List answerEntityList = answerService.getByQId(q_id); - for (AnswerEntity answerEntity : answerEntityList) - if("true".equals(answerEntity.getAIstrue())) { - Map map = new HashMap<>(); + if ("true".equals(answerEntity.getAIstrue())) { + Map map = new HashMap<>(); - StudentEntity studentEntity = studentService.getById(answerEntity.getASid()); + StudentEntity studentEntity = studentService.getById(answerEntity.getASid()); - map.put("name", studentEntity.getSName()); - map.put("classNumber", studentEntity.getSTclassnumber()); - map.put("studentNumber", studentEntity.getSSid()); + map.put("name", studentEntity.getSName()); + map.put("classNumber", studentEntity.getSTclassnumber()); + map.put("studentNumber", studentEntity.getSSid()); - mapList.add(map); - } + mapList.add(map); + } PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); return R.ok("查询成功!").put("pageUtil", pageUtil); } + /** + * 2021.11.28 + * zhaomr + * 查询所有回答错误的学生 + * + * @param params 请求参数 + * @return R + */ @RequestMapping("/getFailStudent") public R getFailStudent(@RequestParam Map params) { String q_id = (String) params.get("q_id"); @@ -618,7 +675,7 @@ public class ActivemodelController { for (AnswerEntity answerEntity : answerEntityList) - if("false".equals(answerEntity.getAIstrue())) { + if ("false".equals(answerEntity.getAIstrue())) { Map map = new HashMap<>(); StudentEntity studentEntity = studentService.getById(answerEntity.getASid()); diff --git a/src/main/java/io/renren/modules/generator/controller/PictureController.java b/src/main/java/io/renren/modules/generator/controller/PictureController.java index c7ce73d..c5b8773 100644 --- a/src/main/java/io/renren/modules/generator/controller/PictureController.java +++ b/src/main/java/io/renren/modules/generator/controller/PictureController.java @@ -11,20 +11,19 @@ import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClientBuilder; import io.renren.common.utils.OssUtils; import io.renren.components.TokenManager; -import io.renren.modules.generator.entity.TeacherEntity; -import io.renren.modules.generator.service.StudentService; -import io.renren.modules.generator.service.TeacherService; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.PictureEntity; -import io.renren.modules.generator.service.PictureService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; import org.springframework.web.multipart.MultipartFile; @@ -49,7 +48,16 @@ public class PictureController { private TokenManager tokenManager; @Autowired - private TeacherService teacherService; + private ResourcesService resourcesService; + + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private ActivemodelService activemodelService; + + @Autowired + private UnitmodelService unitmodelService; private static long num = 0; @@ -58,18 +66,48 @@ public class PictureController { * zhaomr * 上传图片 * - * @param file - * @param params - * @param request - * @return - * @throws IOException + * @param file 文件名 + * @param params 上传参数 + * @param request HttpServletRequest + * @return R + * @throws IOException I/O异常 */ + @Transactional @RequestMapping("/insertPicture") public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { if(file.isEmpty()) { return R.error("文件为空!"); } + String p_introduce = (String) params.get("p_introduce"); + String mid = (String) params.get("mid"); + String unitid = (String) params.get("unitid"); + String actid = (String) params.get("actid"); + String actionid = (String) params.get("actionid"); + + if(mid == null && unitid == null && actid == null && actionid == null) return R.error("缺少参数"); + + if(actionid != null) { + if(actid == null) { + ActionmodelEntity actionmodelEntity = actionmodelService.getByActionId(actionid); + actid = actionmodelEntity.getActionActid(); + } + } + + if(actid != null) { + if(unitid == null) { + ActivemodelEntity activemodelEntity = activemodelService.getById(actid); + unitid = activemodelEntity.getActUid(); + } + } + + if(unitid != null) { + if(mid == null) { + UnitmodelEntity unitmodelEntity = unitmodelService.getById(unitid); + mid = unitmodelEntity.getUClassid(); + } + } + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); // 测试 @@ -113,8 +151,8 @@ public class PictureController { pictureEntity.setPId(uid); pictureEntity.setPName(file.getOriginalFilename()); - if(params.get("p_introduce") != null) - pictureEntity.setPIntroduce((String) params.get("p_introduce")); + if(p_introduce != null) + pictureEntity.setPIntroduce(p_introduce); pictureEntity.setPNumber(p_number); pictureEntity.setPLink(OssUtils.getPath() + fileName); @@ -126,6 +164,31 @@ public class PictureController { if(result == 0) { return R.error("导入数据库失败"); }else{ + ResourcesEntity resourcesEntity = new ResourcesEntity(); + + String uUid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uUid)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("添加失败!uuid生成失败!"); + } + + resourcesEntity.setResourcesId(uUid); + resourcesEntity.setResourcesActid(actid); + resourcesEntity.setResourcesActionid(actionid); + resourcesEntity.setResourcesMid(mid); + resourcesEntity.setResourcesRid(uid); + resourcesEntity.setResourcesType("2"); + resourcesEntity.setResourcesUnitid(unitid); + resourcesEntity.setResourcesRnumber(p_number); + + int res = resourcesService.insertResource(resourcesEntity); + + if(res == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("导入数据库失败!"); + } + List> maplist =new ArrayList<>(); Map map = new HashMap<>(); map.put("p_number", p_number); diff --git a/src/main/java/io/renren/modules/generator/controller/PptController.java b/src/main/java/io/renren/modules/generator/controller/PptController.java index 560b0f5..c2cbef9 100644 --- a/src/main/java/io/renren/modules/generator/controller/PptController.java +++ b/src/main/java/io/renren/modules/generator/controller/PptController.java @@ -9,18 +9,19 @@ import java.util.*; import com.aliyun.oss.OSS; import io.renren.common.utils.OssUtils; import io.renren.components.TokenManager; -import io.renren.modules.generator.entity.PictureEntity; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.PptEntity; -import io.renren.modules.generator.service.PptService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; import org.springframework.web.multipart.MultipartFile; @@ -44,6 +45,18 @@ public class PptController { @Autowired private TokenManager tokenManager; + @Autowired + private ResourcesService resourcesService; + + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private ActivemodelService activemodelService; + + @Autowired + private UnitmodelService unitmodelService; + private static long num = 0; /** @@ -57,12 +70,42 @@ public class PptController { * @return * @throws IOException */ + @Transactional @RequestMapping("/insertPpt") - public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + public R insertPpt(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { if(file.isEmpty()) { return R.error("文件为空!"); } + String pt_introduce = (String) params.get("pt_introduce"); + String mid = (String) params.get("mid"); + String unitid = (String) params.get("unitid"); + String actid = (String) params.get("actid"); + String actionid = (String) params.get("actionid"); + + if(mid == null && unitid == null && actid == null && actionid == null) return R.error("缺少参数"); + + if(actionid != null) { + if(actid == null) { + ActionmodelEntity actionmodelEntity = actionmodelService.getByActionId(actionid); + actid = actionmodelEntity.getActionActid(); + } + } + + if(actid != null) { + if(unitid == null) { + ActivemodelEntity activemodelEntity = activemodelService.getById(actid); + unitid = activemodelEntity.getActUid(); + } + } + + if(unitid != null) { + if(mid == null) { + UnitmodelEntity unitmodelEntity = unitmodelService.getById(unitid); + mid = unitmodelEntity.getUClassid(); + } + } + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); if(StringUtils.isEmpty(t_id)) { @@ -104,8 +147,8 @@ public class PptController { pptEntity.setPtId(uid); pptEntity.setPtName(file.getOriginalFilename()); - if(params.get("pt_introduce") != null) - pptEntity.setPtIntroduce((String) params.get("pt_introduce")); + if(pt_introduce != null) + pptEntity.setPtIntroduce(pt_introduce); pptEntity.setPtNumber(pt_number); pptEntity.setPtLink(OssUtils.getPath() + fileName); @@ -117,10 +160,35 @@ public class PptController { if(result == 0) { return R.error("导入数据库失败"); }else{ + ResourcesEntity resourcesEntity = new ResourcesEntity(); + + String uUid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uUid)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("添加失败!uuid生成失败!"); + } + + resourcesEntity.setResourcesId(uUid); + resourcesEntity.setResourcesActid(actid); + resourcesEntity.setResourcesActionid(actionid); + resourcesEntity.setResourcesMid(mid); + resourcesEntity.setResourcesRid(uid); + resourcesEntity.setResourcesType("3"); + resourcesEntity.setResourcesUnitid(unitid); + resourcesEntity.setResourcesRnumber(pt_number); + + int res = resourcesService.insertResource(resourcesEntity); + + if(res == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("导入数据库失败!"); + } + List> maplist =new ArrayList<>(); Map map = new HashMap<>(); map.put("pt_number", pt_number); - map.put("p_link", pptEntity.getPtLink()); + map.put("pt_link", pptEntity.getPtLink()); maplist.add(map); return R.ok("导入成功!").put("data", maplist); diff --git a/src/main/java/io/renren/modules/generator/controller/QuestionController.java b/src/main/java/io/renren/modules/generator/controller/QuestionController.java index adf17fb..a0d5246 100644 --- a/src/main/java/io/renren/modules/generator/controller/QuestionController.java +++ b/src/main/java/io/renren/modules/generator/controller/QuestionController.java @@ -31,6 +31,67 @@ public class QuestionController { @Autowired private QuestionService questionService; + /** + * 2021.11.28 + * zhaomr + * 更新问题 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/updateQuestion") + public R updateQuestion(@RequestParam Map params) { + String q_id = (String) params.get("q_id"); + String q_title = (String) params.get("q_title"); + String q_type = (String) params.get("q_type"); + String q_option = (String) params.get("q_option"); + String q_standardAnserwer = (String) params.get("q_standardAnserwer"); + String q_picNumbers = (String) params.get("q_picNumbers"); + String q_isMutipleCommit = (String) params.get("q_isMutipleCommit"); + String q_isCheckAnswer = (String) params.get("q_isCheckAnswer"); + String q_isAllowReturnExplore = (String) params.get("q_isAllowReturnExplore"); + + if (q_id == null) return R.error("缺少参数"); + + if(q_title == null && q_type == null && q_option == null && q_standardAnserwer == null + && q_picNumbers == null && q_isMutipleCommit == null && q_isCheckAnswer == null && q_isAllowReturnExplore == null) + return R.error("缺少参数"); + + QuestionEntity questionEntity = questionService.getById(q_id); + + if(questionEntity == null) return R.error("问题未找到!"); + + if(q_title != null) + questionEntity.setQTitle(q_title); + + if(q_type != null) + questionEntity.setQType(q_type); + + if(q_option != null) + questionEntity.setQOption(q_option); + + if(q_standardAnserwer != null) + questionEntity.setQStandardanserwer(q_standardAnserwer); + + if(q_picNumbers != null) + questionEntity.setQPicnumbers(q_picNumbers); + + if(q_isMutipleCommit != null) + questionEntity.setQIsmutiplecommit(q_isMutipleCommit); + + if(q_isCheckAnswer != null) + questionEntity.setQIscheckanswer(q_isCheckAnswer); + + if(q_isAllowReturnExplore != null) + questionEntity.setQIsallowreturnexplore(q_isAllowReturnExplore); + + int result = questionService.updateQuestion(questionEntity); + + if(result == 0) return R.error("更改失败!操作数据库失败"); + + return R.ok("修改成功!"); + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/StudentController.java b/src/main/java/io/renren/modules/generator/controller/StudentController.java index ba4e822..839e199 100644 --- a/src/main/java/io/renren/modules/generator/controller/StudentController.java +++ b/src/main/java/io/renren/modules/generator/controller/StudentController.java @@ -63,6 +63,7 @@ public class StudentController { return R.ok(); return R.error("删除失败"); } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java b/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java index b5f255a..c55ddc3 100644 --- a/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java @@ -3,7 +3,11 @@ package io.renren.modules.generator.controller; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.UUID; +import io.renren.modules.generator.entity.ActivemodelEntity; +import io.renren.modules.generator.service.ClassmodelService; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; @@ -32,6 +36,9 @@ public class UnitmodelController { @Autowired private UnitmodelService unitmodelService; + @Autowired + private ClassmodelService classmodelService; + //2021 11/20 接口类型: "读" 测试人:ZhangShiYu //根据课程id获取所有的单元对象实体 @RequestMapping("/getAllUnit") @@ -43,6 +50,85 @@ public class UnitmodelController { return R.ok().put("unitList",allUnit); } + /** + * 2021.11.29 + * zhaomr + * 新建单元 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/insertUnit") + public R insertUnit(@RequestParam Map params) { + String u_classid = (String) params.get("u_classid"); + String u_name = (String) params.get("u_name"); + String u_picNumber = (String) params.get("u_picNumber"); + String u_introduce = (String) params.get("u_introduce"); + + if(u_classid == null || u_name == null) return R.error("缺少参数"); + + if (unitmodelService.getByName(u_name) != null) return R.error("新增失败!单元名已存在"); + + if(classmodelService.getById(u_classid) == null) return R.error("新增失败!课程未创建!"); + + String uuid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uuid)) return R.error("新建失败!uuid生成失败"); + + UnitmodelEntity unitmodelEntity = new UnitmodelEntity(); + + unitmodelEntity.setUClassid(u_classid); + unitmodelEntity.setUId(uuid); + unitmodelEntity.setUName(u_name); + unitmodelEntity.setUPicnumber(u_picNumber); + unitmodelEntity.setUIntroduce(u_introduce); + + int result = unitmodelService.insertUnit(unitmodelEntity); + + if(result == 0) return R.error("新建失败!操作数据库失败"); + + return R.ok("新建成功!").put("u_id", uuid); + } + + @RequestMapping("/updateUnit") + public R updateUnit(@RequestParam Map params) { + String u_name = (String) params.get("u_name"); + String u_introduce = (String) params.get("u_introduce"); + String u_picNumber = (String) params.get("u_picNumber"); + String u_id = (String) params.get("u_id"); + + if (u_name == null || u_id == null) return R.error("缺少参数!"); + + UnitmodelEntity unitmodelEntity = unitmodelService.getById(u_id); + + if (unitmodelEntity == null) return R.error("修改失败!该单元不存在"); + + if (unitmodelService.getByName(u_name) != null) return R.error("修改失败!该单元名已存在"); + + unitmodelEntity.setUName(u_name); + unitmodelEntity.setUPicnumber(u_picNumber); + unitmodelEntity.setUIntroduce(u_introduce); + + int result = unitmodelService.update(unitmodelEntity); + + if (result == 0) return R.error("修改失败!导入数据库失败!"); + + return R.ok("修改成功!"); + } + + @RequestMapping("/deleteById") + public R deleteById(@RequestParam Map params) { + String u_id = (String) params.get("u_id"); + + if(u_id == null) return R.error("缺少参数"); + + int result = unitmodelService.deleteById(u_id); + + if(result == 0) return R.error("删除失败!该单元未创建或资源不存在或操作数据库失败"); + + return R.ok("删除成功"); + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/VideoController.java b/src/main/java/io/renren/modules/generator/controller/VideoController.java index 78f3810..d2e7a52 100644 --- a/src/main/java/io/renren/modules/generator/controller/VideoController.java +++ b/src/main/java/io/renren/modules/generator/controller/VideoController.java @@ -9,18 +9,19 @@ import java.util.*; import com.aliyun.oss.OSS; import io.renren.common.utils.OssUtils; import io.renren.components.TokenManager; -import io.renren.modules.generator.entity.PptEntity; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.VideoEntity; -import io.renren.modules.generator.service.VideoService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; import org.springframework.web.multipart.MultipartFile; @@ -44,6 +45,18 @@ public class VideoController { @Autowired private TokenManager tokenManager; + @Autowired + private ResourcesService resourcesService; + + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private ActivemodelService activemodelService; + + @Autowired + private UnitmodelService unitmodelService; + private static int num = 0; /** @@ -57,12 +70,42 @@ public class VideoController { * @return * @throws IOException */ + @Transactional @RequestMapping("/insertVideo") - public R insertPicture(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + public R insertVideo(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { if(file.isEmpty()) { return R.error("文件为空!"); } + String v_introduce = (String) params.get("v_introduce"); + String mid = (String) params.get("mid"); + String unitid = (String) params.get("unitid"); + String actid = (String) params.get("actid"); + String actionid = (String) params.get("actionid"); + + if(mid == null && unitid == null && actid == null && actionid == null) return R.error("缺少参数"); + + if(actionid != null) { + if(actid == null) { + ActionmodelEntity actionmodelEntity = actionmodelService.getByActionId(actionid); + actid = actionmodelEntity.getActionActid(); + } + } + + if(actid != null) { + if(unitid == null) { + ActivemodelEntity activemodelEntity = activemodelService.getById(actid); + unitid = activemodelEntity.getActUid(); + } + } + + if(unitid != null) { + if(mid == null) { + UnitmodelEntity unitmodelEntity = unitmodelService.getById(unitid); + mid = unitmodelEntity.getUClassid(); + } + } + String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); if(StringUtils.isEmpty(t_id)) { @@ -103,8 +146,8 @@ public class VideoController { videoEntity.setVId(uid); videoEntity.setVName(file.getOriginalFilename()); - if(params.get("v_introduce") != null) - videoEntity.setVIntroduce((String) params.get("v_introduce")); + if(v_introduce != null) + videoEntity.setVIntroduce(v_introduce); videoEntity.setVNumber(v_number); videoEntity.setVLink(OssUtils.getPath() + fileName); @@ -116,10 +159,35 @@ public class VideoController { if(result == 0) { return R.error("导入数据库失败"); }else{ + ResourcesEntity resourcesEntity = new ResourcesEntity(); + + String uUid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uUid)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("添加失败!uuid生成失败!"); + } + + resourcesEntity.setResourcesId(uUid); + resourcesEntity.setResourcesActid(actid); + resourcesEntity.setResourcesActionid(actionid); + resourcesEntity.setResourcesMid(mid); + resourcesEntity.setResourcesRid(uid); + resourcesEntity.setResourcesType("1"); + resourcesEntity.setResourcesUnitid(unitid); + resourcesEntity.setResourcesRnumber(v_number); + + int res = resourcesService.insertResource(resourcesEntity); + + if(res == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("导入数据库失败!"); + } + List> maplist =new ArrayList<>(); Map map = new HashMap<>(); map.put("v_number", v_number); - map.put("p_link", videoEntity.getVLink()); + map.put("v_link", videoEntity.getVLink()); maplist.add(map); return R.ok("导入成功!").put("data", maplist); diff --git a/src/main/java/io/renren/modules/generator/service/ActionmodelService.java b/src/main/java/io/renren/modules/generator/service/ActionmodelService.java index 0443b89..ad84613 100644 --- a/src/main/java/io/renren/modules/generator/service/ActionmodelService.java +++ b/src/main/java/io/renren/modules/generator/service/ActionmodelService.java @@ -83,5 +83,8 @@ public interface ActionmodelService extends IService { * @return List */ List getByActId(String actId); + + + ActionmodelEntity getByActionId(String action_id); } diff --git a/src/main/java/io/renren/modules/generator/service/AnswerService.java b/src/main/java/io/renren/modules/generator/service/AnswerService.java index 9299682..fe4adb1 100644 --- a/src/main/java/io/renren/modules/generator/service/AnswerService.java +++ b/src/main/java/io/renren/modules/generator/service/AnswerService.java @@ -48,5 +48,15 @@ public interface AnswerService extends IService { * @return List */ List getByQId(String qId); + + /** + * 2021.11.28 + * zhaomr + * 根据问题id删除回答 + * + * @param qId 问题id + * @return 是否成功 + */ + int deleteByQid(String qId); } diff --git a/src/main/java/io/renren/modules/generator/service/FeetbackService.java b/src/main/java/io/renren/modules/generator/service/FeetbackService.java index 713ac88..55c1430 100644 --- a/src/main/java/io/renren/modules/generator/service/FeetbackService.java +++ b/src/main/java/io/renren/modules/generator/service/FeetbackService.java @@ -44,5 +44,15 @@ public interface FeetbackService extends IService { * @return FeetbackEntity */ FeetbackEntity getByActionIdAndSId(String actionId, String sId); + + /** + * 2021.11.28 + * zhaomr + * 根据活动id删除反馈 + * + * @param act_id 活动id + * @return int 影响行数 + */ + int deleteByActId(String act_id); } diff --git a/src/main/java/io/renren/modules/generator/service/PictureService.java b/src/main/java/io/renren/modules/generator/service/PictureService.java index e681fd0..0a33e7b 100644 --- a/src/main/java/io/renren/modules/generator/service/PictureService.java +++ b/src/main/java/io/renren/modules/generator/service/PictureService.java @@ -20,5 +20,7 @@ public interface PictureService extends IService { int insertPicture(PictureEntity pictureEntity); PictureEntity getByNumber(String pNumber); + + int deleteByIdAndLink(String p_id, String p_link); } diff --git a/src/main/java/io/renren/modules/generator/service/PptService.java b/src/main/java/io/renren/modules/generator/service/PptService.java index f1e3f89..fa5cba3 100644 --- a/src/main/java/io/renren/modules/generator/service/PptService.java +++ b/src/main/java/io/renren/modules/generator/service/PptService.java @@ -18,5 +18,7 @@ public interface PptService extends IService { PageUtils queryPage(Map params); int insertPpt(PptEntity pptEntity); + + int deleteByIdAndLink(String pt_id, String pt_link); } diff --git a/src/main/java/io/renren/modules/generator/service/QuestionService.java b/src/main/java/io/renren/modules/generator/service/QuestionService.java index 5b3df37..1276b42 100644 --- a/src/main/java/io/renren/modules/generator/service/QuestionService.java +++ b/src/main/java/io/renren/modules/generator/service/QuestionService.java @@ -30,5 +30,25 @@ public interface QuestionService extends IService { * @return List */ List getByActionId(String actionId); + + /** + * 2021.11.28 + * zhaomr + * 根据动作id删除 + * + * @param actionId 动作id + * @return int 影响行数 + */ + int deleteByActionId(String actionId); + + /** + * 2021.11.28 + * zhaomr + * 修改问题 + * + * @param questionEntity + * @return + */ + int updateQuestion(QuestionEntity questionEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/ResourcesService.java b/src/main/java/io/renren/modules/generator/service/ResourcesService.java index db0c1e5..74caaaa 100644 --- a/src/main/java/io/renren/modules/generator/service/ResourcesService.java +++ b/src/main/java/io/renren/modules/generator/service/ResourcesService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.generator.entity.ResourcesEntity; +import java.util.List; import java.util.Map; /** @@ -16,5 +17,36 @@ import java.util.Map; public interface ResourcesService extends IService { PageUtils queryPage(Map params); + + /** + * 2021.11.28 + * zhaomr + * 新增资源 + * + * @param resourcesEntity 资源实体 + * @return int 影响行数 + */ + int insertResource(ResourcesEntity resourcesEntity); + + /** + * 2021.11.28 + * zhaomr + * 删除资源 + * + * @param resourcesEntity 资源实体 + * @return 影响行数 + */ + int deleteResource(ResourcesEntity resourcesEntity); + + /** + * 2021.11.28 + * zhaomr + * 根据相应id查找 + * + * @param id id + * @param type 表示时哪个id(需要与数据表中的值对应) + * @return List + */ + List getBySomeId(String id, String type); } diff --git a/src/main/java/io/renren/modules/generator/service/TextService.java b/src/main/java/io/renren/modules/generator/service/TextService.java index b2837ac..feb47e3 100644 --- a/src/main/java/io/renren/modules/generator/service/TextService.java +++ b/src/main/java/io/renren/modules/generator/service/TextService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface TextService extends IService { PageUtils queryPage(Map params); + + int deleteById(String text_id); } diff --git a/src/main/java/io/renren/modules/generator/service/UnitmodelService.java b/src/main/java/io/renren/modules/generator/service/UnitmodelService.java index 13fb6fb..06be48c 100644 --- a/src/main/java/io/renren/modules/generator/service/UnitmodelService.java +++ b/src/main/java/io/renren/modules/generator/service/UnitmodelService.java @@ -20,5 +20,45 @@ public interface UnitmodelService extends IService { //根据课程id获取所有的单元 List getAllUnit(String courseId); + + /** + * 2021.11.29 + * zhaomr + * 根据name查找单元 + * + * @param u_name 单元名称 + * @return 单元实体 + */ + UnitmodelEntity getByName(String u_name); + + /** + * 2021.11.29 + * zhaomr + * 新建单元 + * + * @param unitmodelEntity 单元实体 + * @return int 影响行数 + */ + int insertUnit(UnitmodelEntity unitmodelEntity); + + /** + * 2021.11.29 + * zhaomr + * 更新单元 + * + * @param unitmodelEntity 单元实体 + * @return int 影响行数 + */ + int update(UnitmodelEntity unitmodelEntity); + + /** + * 2021.11.29 + * zhaomr + * 根据id删除单元 需要关联删除其下的所有活动 + * + * @param u_id 单元id + * @return + */ + int deleteById(String u_id); } diff --git a/src/main/java/io/renren/modules/generator/service/VideoService.java b/src/main/java/io/renren/modules/generator/service/VideoService.java index ed40fae..fb5e681 100644 --- a/src/main/java/io/renren/modules/generator/service/VideoService.java +++ b/src/main/java/io/renren/modules/generator/service/VideoService.java @@ -18,5 +18,7 @@ public interface VideoService extends IService { PageUtils queryPage(Map params); int insertVideo(VideoEntity videoEntity); + + int deleteByIdAndLink(String v_id, String v_link); } diff --git a/src/main/java/io/renren/modules/generator/service/VideologService.java b/src/main/java/io/renren/modules/generator/service/VideologService.java index b7bf733..816aed1 100644 --- a/src/main/java/io/renren/modules/generator/service/VideologService.java +++ b/src/main/java/io/renren/modules/generator/service/VideologService.java @@ -16,5 +16,7 @@ import java.util.Map; public interface VideologService extends IService { PageUtils queryPage(Map params); + + int deleteByVNumber(String resourcesRnumber); } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java index 55dc1ec..6f588dc 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java @@ -417,4 +417,12 @@ public class ActionmodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("action_id", action_id); + + return actionmodelDao.selectOne(queryWrapper); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java index a5f62a8..a28b838 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java @@ -1,6 +1,9 @@ package io.renren.modules.generator.service.impl; -import io.renren.modules.generator.service.ActionmodelService; +import io.renren.common.utils.R; +import io.renren.modules.generator.dao.ActionmodelDao; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -13,14 +16,29 @@ import io.renren.common.utils.PageUtils; import io.renren.common.utils.Query; import io.renren.modules.generator.dao.ActivemodelDao; -import io.renren.modules.generator.entity.ActivemodelEntity; -import io.renren.modules.generator.service.ActivemodelService; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; @Service("activemodelService") public class ActivemodelServiceImpl extends ServiceImpl implements ActivemodelService { @Autowired - ActivemodelDao activemodelDao; + private ActivemodelDao activemodelDao; + + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private QuestionService questionService; + + @Autowired + private AnswerService answerService; + + @Autowired + private FeetbackService feetbackService; + + @Autowired + private ResourcesService resourcesService; @Override public PageUtils queryPage(Map params) { @@ -64,9 +82,56 @@ public class ActivemodelServiceImpl extends ServiceImpl actionmodelEntityList = actionmodelService.getByActId(act_id); + + for (ActionmodelEntity actionmodelEntity : actionmodelEntityList) { + List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); + int res = questionService.deleteByActionId(actionmodelEntity.getActionId()); + + if(res != questionEntityList.size()) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return 0; + } + + for (QuestionEntity questionEntity : questionEntityList) { + List answerEntityList = answerService.getByQId(questionEntity.getQId()); + int rs = answerService.deleteByQid(questionEntity.getQId()); + + if(rs != answerEntityList.size()) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return 0; + } + } + + boolean flag = actionmodelService.deleteAction(actionmodelEntity.getActionId()); + + if(!flag) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return 0; + } + } + + feetbackService.deleteByActId(act_id); + + List resourcesEntities = resourcesService.getBySomeId(act_id, "Resources_actid"); + + for (ResourcesEntity resourcesEntity : resourcesEntities) { + int rs = resourcesService.deleteResource(resourcesEntity); + + if(rs == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return 0; + } + } + + return result; } /** diff --git a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java index 3f70234..b73474e 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java @@ -7,6 +7,7 @@ import io.renren.modules.generator.entity.QuestionEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.rmi.MarshalledObject; import java.util.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -31,6 +32,7 @@ public class AnswerServiceImpl extends ServiceImpl impl @Autowired QuestionDao questionDao; + //根据学生id和板块id获取该板块此学生最新的作答情况 按照题号排序 @Override public List getLastestAnswer(String sId, String actId) { @@ -190,4 +192,12 @@ public class AnswerServiceImpl extends ServiceImpl impl return answerDao.selectList(queryWrapper); } + + @Override + public int deleteByQid(String qId) { + Map map = new HashMap<>(); + map.put("a_qid", qId); + + return answerDao.deleteByMap(map); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java index c56ea94..f693408 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java @@ -7,6 +7,7 @@ import io.renren.modules.generator.entity.ActivemodelEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -104,4 +105,12 @@ public class FeetbackServiceImpl extends ServiceImpl map = new HashMap<>(); + map.put("feet_actid", act_id); + + return feetbackDao.deleteByMap(map); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java index 0aef48d..c05206f 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java @@ -1,6 +1,8 @@ package io.renren.modules.generator.service.impl; +import com.aliyun.oss.OSS; import io.renren.common.exception.RRException; +import io.renren.common.utils.OssUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; @@ -59,4 +61,21 @@ public class PictureServiceImpl extends ServiceImpl i return pictureDao.selectOne(queryWrapper); } + + @Override + public int deleteByIdAndLink(String p_id, String p_link) { + OSS ossClient = OssUtils.getOssClient(); + String bucketName = "ckedu2"; + String fileName = "picture/" + p_link.substring(OssUtils.getPath().length() + 1); + + if(!ossClient.doesObjectExist(bucketName, fileName)) return 0; + + ossClient.deleteObject(bucketName, fileName); + + if(ossClient.doesObjectExist(bucketName, fileName)) return 0; + + ossClient.shutdown(); + + return pictureDao.deleteById(p_id); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java index 9df2059..1ba04b4 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java @@ -1,5 +1,7 @@ package io.renren.modules.generator.service.impl; +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; @@ -34,4 +36,21 @@ public class PptServiceImpl extends ServiceImpl implements Pp public int insertPpt(PptEntity pptEntity) { return pptDao.insert(pptEntity); } + + @Override + public int deleteByIdAndLink(String pt_id, String pt_link) { + OSS ossClient = OssUtils.getOssClient(); + String bucketName = "ckedu2"; + String fileName = "ppt/" + pt_link.substring(OssUtils.getPath().length() + 1); + + if(!ossClient.doesObjectExist(bucketName, fileName)) return 0; + + ossClient.deleteObject(bucketName, fileName); + + if(ossClient.doesObjectExist(bucketName, fileName)) return 0; + + ossClient.shutdown(); + + return pptDao.deleteById(pt_id); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java index fe4da6e..104c50e 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java @@ -3,6 +3,7 @@ package io.renren.modules.generator.service.impl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.HashMap; import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -47,4 +48,17 @@ public class QuestionServiceImpl extends ServiceImpl map = new HashMap<>(); + map.put("q_actionId", actionId); + + return questionDao.deleteByMap(map); + } + + @Override + public int updateQuestion(QuestionEntity questionEntity) { + return questionDao.updateById(questionEntity); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ResourcesServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ResourcesServiceImpl.java index 05b80eb..3c4c997 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ResourcesServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ResourcesServiceImpl.java @@ -1,6 +1,16 @@ package io.renren.modules.generator.service.impl; +import com.baomidou.mybatisplus.core.conditions.Wrapper; +import com.sun.corba.se.spi.ior.ObjectKey; +import io.renren.modules.generator.entity.PictureEntity; +import io.renren.modules.generator.entity.PptEntity; +import io.renren.modules.generator.entity.VideoEntity; +import io.renren.modules.generator.service.*; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -10,12 +20,30 @@ import io.renren.common.utils.Query; import io.renren.modules.generator.dao.ResourcesDao; import io.renren.modules.generator.entity.ResourcesEntity; -import io.renren.modules.generator.service.ResourcesService; +import org.springframework.transaction.annotation.Transactional; @Service("resourcesService") public class ResourcesServiceImpl extends ServiceImpl implements ResourcesService { + @Autowired + private ResourcesDao resourcesDao; + + @Autowired + private VideoService videoService; + + @Autowired + private PictureService pictureService; + + @Autowired + private TextService textService; + + @Autowired + private PptService pptService; + + @Autowired + private VideologService videologService; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +54,38 @@ public class ResourcesServiceImpl extends ServiceImpl getBySomeId(String id, String type) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(type, id); + + return resourcesDao.selectList(queryWrapper); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/TextServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/TextServiceImpl.java index 08bf62b..b356384 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/TextServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/TextServiceImpl.java @@ -1,5 +1,8 @@ package io.renren.modules.generator.service.impl; +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -16,6 +19,9 @@ import io.renren.modules.generator.service.TextService; @Service("textService") public class TextServiceImpl extends ServiceImpl implements TextService { + @Autowired + private TextDao textDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +32,8 @@ public class TextServiceImpl extends ServiceImpl implements return new PageUtils(page); } + @Override + public int deleteById(String text_id) { + return textDao.deleteById(text_id); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java index c081fa3..a060051 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java @@ -1,5 +1,8 @@ package io.renren.modules.generator.service.impl; +import io.renren.common.utils.R; +import io.renren.modules.generator.entity.ActivemodelEntity; +import io.renren.modules.generator.service.ActivemodelService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -14,13 +17,18 @@ import io.renren.common.utils.Query; import io.renren.modules.generator.dao.UnitmodelDao; import io.renren.modules.generator.entity.UnitmodelEntity; import io.renren.modules.generator.service.UnitmodelService; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; @Service("unitmodelService") public class UnitmodelServiceImpl extends ServiceImpl implements UnitmodelService { @Autowired - UnitmodelDao unitmodelDao; + private UnitmodelDao unitmodelDao; + + @Autowired + private ActivemodelService activemodelService; @Override public PageUtils queryPage(Map params) { @@ -41,4 +49,42 @@ public class UnitmodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("u_name", u_name); + + return unitmodelDao.selectOne(queryWrapper); + } + + @Override + public int insertUnit(UnitmodelEntity unitmodelEntity) { + return unitmodelDao.insert(unitmodelEntity); + } + + @Override + public int update(UnitmodelEntity unitmodelEntity) { + return unitmodelDao.updateById(unitmodelEntity); + } + + @Transactional + @Override + public int deleteById(String u_id) { + int result = unitmodelDao.deleteById(u_id); + + if(result == 0) return 0; + + List activemodelEntityList = activemodelService.getAllActiveModel(u_id); + + for (ActivemodelEntity activemodelEntity : activemodelEntityList) { + int res = activemodelService.deleteById(activemodelEntity.getActId()); + + if(res == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return 0; + } + } + + return result; + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java index 123bc42..c93e106 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java @@ -1,5 +1,8 @@ package io.renren.modules.generator.service.impl; +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import io.renren.modules.generator.service.VideologService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Map; @@ -34,4 +37,21 @@ public class VideoServiceImpl extends ServiceImpl impleme public int insertVideo(VideoEntity videoEntity) { return videoDao.insert(videoEntity); } + + @Override + public int deleteByIdAndLink(String v_id, String v_link) { + OSS ossClient = OssUtils.getOssClient(); + String bucketName = "ckedu2"; + String fileName = "video/" + v_link.substring(OssUtils.getPath().length() + 1); + + if(!ossClient.doesObjectExist(bucketName, fileName)) return 0; + + ossClient.deleteObject(bucketName, fileName); + + if(ossClient.doesObjectExist(bucketName, fileName)) return 0; + + ossClient.shutdown(); + + return videoDao.deleteById(v_id); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java index e15cebf..c1eef71 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java @@ -1,6 +1,9 @@ package io.renren.modules.generator.service.impl; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.util.HashMap; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -16,6 +19,9 @@ import io.renren.modules.generator.service.VideologService; @Service("videologService") public class VideologServiceImpl extends ServiceImpl implements VideologService { + @Autowired + private VideologDao videologDao; + @Override public PageUtils queryPage(Map params) { IPage page = this.page( @@ -26,4 +32,12 @@ public class VideologServiceImpl extends ServiceImpl map = new HashMap<>(); + map.put("videolog_vnumber", resourcesRnumber); + + return videologDao.deleteByMap(map); + } } \ No newline at end of file -- Gitee From 558862fda7785376b9cf3887dff0c3caeb565082 Mon Sep 17 00:00:00 2001 From: Aurox Date: Mon, 29 Nov 2021 16:03:37 +0000 Subject: [PATCH 08/22] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20.idea?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .idea/.keep diff --git a/.idea/.keep b/.idea/.keep new file mode 100644 index 0000000..e69de29 -- Gitee From a576f81f93e730a389521652ddc5cebb7a67015c Mon Sep 17 00:00:00 2001 From: Aurox Date: Mon, 29 Nov 2021 16:05:14 +0000 Subject: [PATCH 09/22] =?UTF-8?q?.idea=E5=86=85=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++++++++ .idea/compiler.xml | 21 +++++++++++++++++++++ .idea/encodings.xml | 6 ++++++ .idea/jarRepositories.xml | 25 +++++++++++++++++++++++++ .idea/misc.xml | 12 ++++++++++++ .idea/runConfigurations.xml | 10 ++++++++++ .idea/vcs.xml | 6 ++++++ 7 files changed, 88 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..5adbc3e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..63e9001 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..dfaf1c0 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d5cd614 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file -- Gitee From 47d58080e202b417f4f074901a4fc3ae277d8803 Mon Sep 17 00:00:00 2001 From: Aurox Date: Mon, 29 Nov 2021 16:06:23 +0000 Subject: [PATCH 10/22] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20.i?= =?UTF-8?q?dea?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 -------- .idea/.keep | 0 .idea/compiler.xml | 21 --------------------- .idea/encodings.xml | 6 ------ .idea/jarRepositories.xml | 25 ------------------------- .idea/misc.xml | 12 ------------ .idea/runConfigurations.xml | 10 ---------- .idea/vcs.xml | 6 ------ 8 files changed, 88 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/.keep delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.keep b/.idea/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 5adbc3e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 63e9001..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index dfaf1c0..0000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index d5cd614..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file -- Gitee From 0fc559a7106af0255743358383986adcf435142c Mon Sep 17 00:00:00 2001 From: Aurox Date: Tue, 30 Nov 2021 01:38:02 +0800 Subject: [PATCH 11/22] =?UTF-8?q?StudentController=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E6=9F=A5=E6=89=BE=E5=AD=A6=E7=94=9F=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StudentController.java | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/StudentController.java b/src/main/java/io/renren/modules/generator/controller/StudentController.java index 839e199..ac1cf75 100644 --- a/src/main/java/io/renren/modules/generator/controller/StudentController.java +++ b/src/main/java/io/renren/modules/generator/controller/StudentController.java @@ -1,7 +1,6 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.Map; +import java.util.*; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -16,6 +15,7 @@ import io.renren.modules.generator.service.StudentService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import javax.management.ObjectName; /** @@ -64,6 +64,47 @@ public class StudentController { return R.error("删除失败"); } + /** + * 2021.11.30 + * zhaomr + * 通过课程id获得学生列表 + * + * @param params 请求参数 + * @return R + */ + @RequestMapping("/getBySTclass") + public R getBySTclass(@RequestParam Map params) { + String s_tclass = (String) params.get("s_tclass"); + String pn = (String) params.get("pn"); + String ps = (String) params.get("ps"); + + if(s_tclass == null) return R.error("缺少参数"); + + if(pn == null) pn = "1"; + + if(ps == null) ps = "10"; + + List studentEntityList = studentService.getBySTclass(s_tclass); + + List> mapList = new ArrayList<>(); + + for (StudentEntity studentEntity : studentEntityList) { + Map map = new HashMap<>(); + + map.put("s_sid", studentEntity.getSSid()); + map.put("s_username", studentEntity.getSUsername()); + map.put("s_name", studentEntity.getSName()); + map.put("s_tclassNumber", studentEntity.getSTclassnumber()); + map.put("s_tid", studentEntity.getSTid()); + + mapList.add(map); + } + + PageUtils pageUtil = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功").put("pagUtil", pageUtil); + } + /** * 列表 */ -- Gitee From 00dfc41837ba42461165537527bc48b9b0c049dd Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 15 Dec 2021 01:27:51 +0800 Subject: [PATCH 12/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OperatelogController.java | 90 +++++++++ .../modules/generator/dao/OperatelogDao.java | 17 ++ .../generator/entity/ActionmodelEntity.java | 14 +- .../generator/entity/ActivemodelEntity.java | 10 +- .../generator/entity/AnswerEntity.java | 10 +- .../generator/entity/ClassesEntity.java | 14 +- .../generator/entity/ClassmodelEntity.java | 10 +- .../generator/entity/FeetbackEntity.java | 10 +- .../generator/entity/OperatelogEntity.java | 40 ++++ .../generator/entity/PictureEntity.java | 10 +- .../modules/generator/entity/PptEntity.java | 10 +- .../generator/entity/QuestionEntity.java | 10 +- .../generator/entity/ResourcesEntity.java | 10 +- .../generator/entity/StudentEntity.java | 22 ++- .../generator/entity/TeacherEntity.java | 10 +- .../modules/generator/entity/TextEntity.java | 10 +- .../modules/generator/entity/TimeEntity.java | 10 +- .../generator/entity/UnitmodelEntity.java | 10 +- .../modules/generator/entity/VideoEntity.java | 10 +- .../generator/entity/VideologEntity.java | 10 +- .../generator/service/OperatelogService.java | 20 ++ .../service/impl/OperatelogServiceImpl.java | 29 +++ .../mapper/generator/ActionmodelDao.xml | 2 + .../mapper/generator/ActivemodelDao.xml | 1 + .../resources/mapper/generator/AnswerDao.xml | 1 + .../resources/mapper/generator/ClassesDao.xml | 2 + .../mapper/generator/ClassmodelDao.xml | 1 + .../mapper/generator/FeetbackDao.xml | 1 + .../mapper/generator/OperatelogDao.xml | 15 ++ .../resources/mapper/generator/PictureDao.xml | 1 + .../resources/mapper/generator/PptDao.xml | 1 + .../mapper/generator/QuestionDao.xml | 1 + .../mapper/generator/ResourcesDao.xml | 1 + .../resources/mapper/generator/StudentDao.xml | 4 + .../resources/mapper/generator/TeacherDao.xml | 1 + .../resources/mapper/generator/TextDao.xml | 1 + .../resources/mapper/generator/TimeDao.xml | 1 + .../mapper/generator/UnitmodelDao.xml | 1 + .../resources/mapper/generator/VideoDao.xml | 1 + .../mapper/generator/VideologDao.xml | 1 + .../generator/operatelog-add-or-update.vue | 102 ++++++++++ .../views/modules/generator/operatelog.vue | 175 ++++++++++++++++++ 42 files changed, 649 insertions(+), 51 deletions(-) create mode 100644 src/main/java/io/renren/modules/generator/controller/OperatelogController.java create mode 100644 src/main/java/io/renren/modules/generator/dao/OperatelogDao.java create mode 100644 src/main/java/io/renren/modules/generator/entity/OperatelogEntity.java create mode 100644 src/main/java/io/renren/modules/generator/service/OperatelogService.java create mode 100644 src/main/java/io/renren/modules/generator/service/impl/OperatelogServiceImpl.java create mode 100644 src/main/resources/mapper/generator/OperatelogDao.xml create mode 100644 src/main/resources/src/views/modules/generator/operatelog-add-or-update.vue create mode 100644 src/main/resources/src/views/modules/generator/operatelog.vue diff --git a/src/main/java/io/renren/modules/generator/controller/OperatelogController.java b/src/main/java/io/renren/modules/generator/controller/OperatelogController.java new file mode 100644 index 0000000..286eda4 --- /dev/null +++ b/src/main/java/io/renren/modules/generator/controller/OperatelogController.java @@ -0,0 +1,90 @@ +package io.renren.modules.generator.controller; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import io.renren.modules.generator.entity.OperatelogEntity; +import io.renren.modules.generator.service.OperatelogService; +import io.renren.common.utils.PageUtils; +import io.renren.common.utils.R; + + + +/** + * 操作记录表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 + */ +@RestController +@RequestMapping("generator/operatelog") +public class OperatelogController { + @Autowired + private OperatelogService operatelogService; + + /** + * 列表 + */ + @RequestMapping("/list") + @RequiresPermissions("generator:operatelog:list") + public R list(@RequestParam Map params){ + PageUtils page = operatelogService.queryPage(params); + + return R.ok().put("page", page); + } + + + /** + * 信息 + */ + @RequestMapping("/info/{opId}") + @RequiresPermissions("generator:operatelog:info") + public R info(@PathVariable("opId") String opId){ + OperatelogEntity operatelog = operatelogService.getById(opId); + + return R.ok().put("operatelog", operatelog); + } + + /** + * 保存 + */ + @RequestMapping("/save") + @RequiresPermissions("generator:operatelog:save") + public R save(@RequestBody OperatelogEntity operatelog){ + operatelogService.save(operatelog); + + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + @RequiresPermissions("generator:operatelog:update") + public R update(@RequestBody OperatelogEntity operatelog){ + operatelogService.updateById(operatelog); + + return R.ok(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + @RequiresPermissions("generator:operatelog:delete") + public R delete(@RequestBody String[] opIds){ + operatelogService.removeByIds(Arrays.asList(opIds)); + + return R.ok(); + } + +} diff --git a/src/main/java/io/renren/modules/generator/dao/OperatelogDao.java b/src/main/java/io/renren/modules/generator/dao/OperatelogDao.java new file mode 100644 index 0000000..da9d8ca --- /dev/null +++ b/src/main/java/io/renren/modules/generator/dao/OperatelogDao.java @@ -0,0 +1,17 @@ +package io.renren.modules.generator.dao; + +import io.renren.modules.generator.entity.OperatelogEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 操作记录表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 + */ +@Mapper +public interface OperatelogDao extends BaseMapper { + +} diff --git a/src/main/java/io/renren/modules/generator/entity/ActionmodelEntity.java b/src/main/java/io/renren/modules/generator/entity/ActionmodelEntity.java index f827d83..a3cbba9 100644 --- a/src/main/java/io/renren/modules/generator/entity/ActionmodelEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ActionmodelEntity.java @@ -11,9 +11,9 @@ import lombok.Data; * 动作表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("actionmodel") @@ -57,5 +57,13 @@ public class ActionmodelEntity implements Serializable { * ppt编号 */ private String actionPptnumber; + /** + * 是否必须解释 + */ + private String isMustexplain; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java b/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java index 0ab49ba..4f4b6b3 100644 --- a/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ActivemodelEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 活动表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("activemodel") @@ -52,5 +52,9 @@ public class ActivemodelEntity implements Serializable { * 视频编号 */ private String actVideonumber; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/AnswerEntity.java b/src/main/java/io/renren/modules/generator/entity/AnswerEntity.java index 4408df0..a4dfd88 100644 --- a/src/main/java/io/renren/modules/generator/entity/AnswerEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/AnswerEntity.java @@ -11,9 +11,9 @@ import lombok.Data; * 提交记录表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("answer") @@ -57,5 +57,9 @@ public class AnswerEntity implements Serializable { * 所得分数 */ private String aGetlevel; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java b/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java index ef59bb8..c49852c 100644 --- a/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ClassesEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 班级表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("classes") @@ -40,5 +40,13 @@ public class ClassesEntity implements Serializable { * 课程id */ private String cMid; + /** + * 活动id + */ + private String cAid; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/ClassmodelEntity.java b/src/main/java/io/renren/modules/generator/entity/ClassmodelEntity.java index 37ece80..9958371 100644 --- a/src/main/java/io/renren/modules/generator/entity/ClassmodelEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ClassmodelEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 课程表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("classmodel") @@ -48,5 +48,9 @@ public class ClassmodelEntity implements Serializable { * 图片编号 */ private String classVideonumber; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/FeetbackEntity.java b/src/main/java/io/renren/modules/generator/entity/FeetbackEntity.java index c744aae..274d961 100644 --- a/src/main/java/io/renren/modules/generator/entity/FeetbackEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/FeetbackEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 反馈表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("feetback") @@ -64,5 +64,9 @@ public class FeetbackEntity implements Serializable { * 反馈是否已被学生查看 */ private String feetIsview; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/OperatelogEntity.java b/src/main/java/io/renren/modules/generator/entity/OperatelogEntity.java new file mode 100644 index 0000000..1a4334f --- /dev/null +++ b/src/main/java/io/renren/modules/generator/entity/OperatelogEntity.java @@ -0,0 +1,40 @@ +package io.renren.modules.generator.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 操作记录表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 + */ +@Data +@TableName("operatelog") +public class OperatelogEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 操作id + */ + @TableId + private String opId; + /** + * 操作类型 + */ + private String opType; + /** + * 操作人id(只能由老师来操作) + */ + private String opPeopleid; + /** + * 操作时间 + */ + private Date opTime; + +} diff --git a/src/main/java/io/renren/modules/generator/entity/PictureEntity.java b/src/main/java/io/renren/modules/generator/entity/PictureEntity.java index a73b30d..4e0d2c1 100644 --- a/src/main/java/io/renren/modules/generator/entity/PictureEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/PictureEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 图片资源表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("picture") @@ -40,5 +40,9 @@ public class PictureEntity implements Serializable { * 图片编号 */ private String pNumber; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/PptEntity.java b/src/main/java/io/renren/modules/generator/entity/PptEntity.java index 7256e34..cf9135c 100644 --- a/src/main/java/io/renren/modules/generator/entity/PptEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/PptEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * PPT资源表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("ppt") @@ -40,5 +40,9 @@ public class PptEntity implements Serializable { * ppt介绍 */ private String ptIntroduce; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/QuestionEntity.java b/src/main/java/io/renren/modules/generator/entity/QuestionEntity.java index 874dc4b..f88fca9 100644 --- a/src/main/java/io/renren/modules/generator/entity/QuestionEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/QuestionEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 问题表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("question") @@ -65,5 +65,9 @@ public class QuestionEntity implements Serializable { * 回答错误是否需要返回探究 */ private String qIsallowreturnexplore; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/ResourcesEntity.java b/src/main/java/io/renren/modules/generator/entity/ResourcesEntity.java index 7311811..42c816b 100644 --- a/src/main/java/io/renren/modules/generator/entity/ResourcesEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/ResourcesEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 资源记录表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("resources") @@ -60,5 +60,9 @@ public class ResourcesEntity implements Serializable { * 下载次数 */ private Integer resourcesDownloadtimes; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/StudentEntity.java b/src/main/java/io/renren/modules/generator/entity/StudentEntity.java index 8ac364f..ffe16f2 100644 --- a/src/main/java/io/renren/modules/generator/entity/StudentEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/StudentEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 学生表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("student") @@ -52,5 +52,21 @@ public class StudentEntity implements Serializable { * 任课教师id */ private String sTid; + /** + * 学生性别, 1表示男,2表示女 + */ + private String sGender; + /** + * 学生生日 + */ + private Date sBirthday; + /** + * 学生年龄 + */ + private Integer sAge; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/TeacherEntity.java b/src/main/java/io/renren/modules/generator/entity/TeacherEntity.java index f86e9fe..29dc707 100644 --- a/src/main/java/io/renren/modules/generator/entity/TeacherEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/TeacherEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 教师表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("teacher") @@ -52,5 +52,9 @@ public class TeacherEntity implements Serializable { * 教师电话号码 */ private String tTelephone; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/TextEntity.java b/src/main/java/io/renren/modules/generator/entity/TextEntity.java index ddd5d59..c2e9d38 100644 --- a/src/main/java/io/renren/modules/generator/entity/TextEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/TextEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 文本资源表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("text") @@ -36,5 +36,9 @@ public class TextEntity implements Serializable { * 文本编号 */ private String textNumber; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/TimeEntity.java b/src/main/java/io/renren/modules/generator/entity/TimeEntity.java index 6cb777b..075c5f3 100644 --- a/src/main/java/io/renren/modules/generator/entity/TimeEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/TimeEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 时间记录表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:46 */ @Data @TableName("time") @@ -56,5 +56,9 @@ public class TimeEntity implements Serializable { * 时间说明:进入为哪个模块下的哪个单元哪个活动哪个动作 */ private String tIntroduce; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/UnitmodelEntity.java b/src/main/java/io/renren/modules/generator/entity/UnitmodelEntity.java index b478781..35af3d3 100644 --- a/src/main/java/io/renren/modules/generator/entity/UnitmodelEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/UnitmodelEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 单元表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 */ @Data @TableName("unitmodel") @@ -52,5 +52,9 @@ public class UnitmodelEntity implements Serializable { * 视频编号 */ private String uVideonumber; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/VideoEntity.java b/src/main/java/io/renren/modules/generator/entity/VideoEntity.java index 7884ac3..3fbb043 100644 --- a/src/main/java/io/renren/modules/generator/entity/VideoEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/VideoEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 视频资源表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 */ @Data @TableName("video") @@ -40,5 +40,9 @@ public class VideoEntity implements Serializable { * 视频介绍 */ private String vIntroduce; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/entity/VideologEntity.java b/src/main/java/io/renren/modules/generator/entity/VideologEntity.java index 70c1261..176fbc7 100644 --- a/src/main/java/io/renren/modules/generator/entity/VideologEntity.java +++ b/src/main/java/io/renren/modules/generator/entity/VideologEntity.java @@ -10,9 +10,9 @@ import lombok.Data; /** * 视频记录表 * - * @author durunsheng - * @email 1026873984@qq.com - * @date 2021-11-20 16:36:43 + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 */ @Data @TableName("videolog") @@ -48,5 +48,9 @@ public class VideologEntity implements Serializable { * 退出时间 */ private Date videologOuttime; + /** + * 是否删除 + */ + private String isDelete; } diff --git a/src/main/java/io/renren/modules/generator/service/OperatelogService.java b/src/main/java/io/renren/modules/generator/service/OperatelogService.java new file mode 100644 index 0000000..9ab872b --- /dev/null +++ b/src/main/java/io/renren/modules/generator/service/OperatelogService.java @@ -0,0 +1,20 @@ +package io.renren.modules.generator.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import io.renren.common.utils.PageUtils; +import io.renren.modules.generator.entity.OperatelogEntity; + +import java.util.Map; + +/** + * 操作记录表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-15 01:02:45 + */ +public interface OperatelogService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/src/main/java/io/renren/modules/generator/service/impl/OperatelogServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/OperatelogServiceImpl.java new file mode 100644 index 0000000..6ef19b2 --- /dev/null +++ b/src/main/java/io/renren/modules/generator/service/impl/OperatelogServiceImpl.java @@ -0,0 +1,29 @@ +package io.renren.modules.generator.service.impl; + +import org.springframework.stereotype.Service; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import io.renren.common.utils.PageUtils; +import io.renren.common.utils.Query; + +import io.renren.modules.generator.dao.OperatelogDao; +import io.renren.modules.generator.entity.OperatelogEntity; +import io.renren.modules.generator.service.OperatelogService; + + +@Service("operatelogService") +public class OperatelogServiceImpl extends ServiceImpl implements OperatelogService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/src/main/resources/mapper/generator/ActionmodelDao.xml b/src/main/resources/mapper/generator/ActionmodelDao.xml index 347192d..99abe33 100644 --- a/src/main/resources/mapper/generator/ActionmodelDao.xml +++ b/src/main/resources/mapper/generator/ActionmodelDao.xml @@ -14,6 +14,8 @@ + + diff --git a/src/main/resources/mapper/generator/ActivemodelDao.xml b/src/main/resources/mapper/generator/ActivemodelDao.xml index 7dbaa89..96e06a2 100644 --- a/src/main/resources/mapper/generator/ActivemodelDao.xml +++ b/src/main/resources/mapper/generator/ActivemodelDao.xml @@ -13,6 +13,7 @@ + diff --git a/src/main/resources/mapper/generator/AnswerDao.xml b/src/main/resources/mapper/generator/AnswerDao.xml index c1f0d49..2930218 100644 --- a/src/main/resources/mapper/generator/AnswerDao.xml +++ b/src/main/resources/mapper/generator/AnswerDao.xml @@ -14,6 +14,7 @@ + diff --git a/src/main/resources/mapper/generator/ClassesDao.xml b/src/main/resources/mapper/generator/ClassesDao.xml index e6c08ca..4276554 100644 --- a/src/main/resources/mapper/generator/ClassesDao.xml +++ b/src/main/resources/mapper/generator/ClassesDao.xml @@ -10,6 +10,8 @@ + + diff --git a/src/main/resources/mapper/generator/ClassmodelDao.xml b/src/main/resources/mapper/generator/ClassmodelDao.xml index c3c7ca6..55bd667 100644 --- a/src/main/resources/mapper/generator/ClassmodelDao.xml +++ b/src/main/resources/mapper/generator/ClassmodelDao.xml @@ -12,6 +12,7 @@ + diff --git a/src/main/resources/mapper/generator/FeetbackDao.xml b/src/main/resources/mapper/generator/FeetbackDao.xml index 9d6eba4..8ea23ea 100644 --- a/src/main/resources/mapper/generator/FeetbackDao.xml +++ b/src/main/resources/mapper/generator/FeetbackDao.xml @@ -16,6 +16,7 @@ + diff --git a/src/main/resources/mapper/generator/OperatelogDao.xml b/src/main/resources/mapper/generator/OperatelogDao.xml new file mode 100644 index 0000000..6b8fed2 --- /dev/null +++ b/src/main/resources/mapper/generator/OperatelogDao.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/generator/PictureDao.xml b/src/main/resources/mapper/generator/PictureDao.xml index 965e0e8..5def332 100644 --- a/src/main/resources/mapper/generator/PictureDao.xml +++ b/src/main/resources/mapper/generator/PictureDao.xml @@ -10,6 +10,7 @@ + diff --git a/src/main/resources/mapper/generator/PptDao.xml b/src/main/resources/mapper/generator/PptDao.xml index 42ff802..801f717 100644 --- a/src/main/resources/mapper/generator/PptDao.xml +++ b/src/main/resources/mapper/generator/PptDao.xml @@ -10,6 +10,7 @@ + diff --git a/src/main/resources/mapper/generator/QuestionDao.xml b/src/main/resources/mapper/generator/QuestionDao.xml index 7a40c28..752d308 100644 --- a/src/main/resources/mapper/generator/QuestionDao.xml +++ b/src/main/resources/mapper/generator/QuestionDao.xml @@ -16,6 +16,7 @@ + diff --git a/src/main/resources/mapper/generator/ResourcesDao.xml b/src/main/resources/mapper/generator/ResourcesDao.xml index e66cac0..82ab6d7 100644 --- a/src/main/resources/mapper/generator/ResourcesDao.xml +++ b/src/main/resources/mapper/generator/ResourcesDao.xml @@ -15,6 +15,7 @@ + diff --git a/src/main/resources/mapper/generator/StudentDao.xml b/src/main/resources/mapper/generator/StudentDao.xml index 02185f6..2da99cc 100644 --- a/src/main/resources/mapper/generator/StudentDao.xml +++ b/src/main/resources/mapper/generator/StudentDao.xml @@ -13,6 +13,10 @@ + + + + diff --git a/src/main/resources/mapper/generator/TeacherDao.xml b/src/main/resources/mapper/generator/TeacherDao.xml index 561d598..1b5511e 100644 --- a/src/main/resources/mapper/generator/TeacherDao.xml +++ b/src/main/resources/mapper/generator/TeacherDao.xml @@ -13,6 +13,7 @@ + diff --git a/src/main/resources/mapper/generator/TextDao.xml b/src/main/resources/mapper/generator/TextDao.xml index c546054..8c01861 100644 --- a/src/main/resources/mapper/generator/TextDao.xml +++ b/src/main/resources/mapper/generator/TextDao.xml @@ -9,6 +9,7 @@ + diff --git a/src/main/resources/mapper/generator/TimeDao.xml b/src/main/resources/mapper/generator/TimeDao.xml index 15bd10d..30c0cab 100644 --- a/src/main/resources/mapper/generator/TimeDao.xml +++ b/src/main/resources/mapper/generator/TimeDao.xml @@ -14,6 +14,7 @@ + diff --git a/src/main/resources/mapper/generator/UnitmodelDao.xml b/src/main/resources/mapper/generator/UnitmodelDao.xml index f34fd91..ff1855e 100644 --- a/src/main/resources/mapper/generator/UnitmodelDao.xml +++ b/src/main/resources/mapper/generator/UnitmodelDao.xml @@ -13,6 +13,7 @@ + diff --git a/src/main/resources/mapper/generator/VideoDao.xml b/src/main/resources/mapper/generator/VideoDao.xml index 9d64ee7..912db1a 100644 --- a/src/main/resources/mapper/generator/VideoDao.xml +++ b/src/main/resources/mapper/generator/VideoDao.xml @@ -10,6 +10,7 @@ + diff --git a/src/main/resources/mapper/generator/VideologDao.xml b/src/main/resources/mapper/generator/VideologDao.xml index 0f2c5ff..dd9ea97 100644 --- a/src/main/resources/mapper/generator/VideologDao.xml +++ b/src/main/resources/mapper/generator/VideologDao.xml @@ -12,6 +12,7 @@ + diff --git a/src/main/resources/src/views/modules/generator/operatelog-add-or-update.vue b/src/main/resources/src/views/modules/generator/operatelog-add-or-update.vue new file mode 100644 index 0000000..cc93671 --- /dev/null +++ b/src/main/resources/src/views/modules/generator/operatelog-add-or-update.vue @@ -0,0 +1,102 @@ + + + diff --git a/src/main/resources/src/views/modules/generator/operatelog.vue b/src/main/resources/src/views/modules/generator/operatelog.vue new file mode 100644 index 0000000..b93a532 --- /dev/null +++ b/src/main/resources/src/views/modules/generator/operatelog.vue @@ -0,0 +1,175 @@ + + + -- Gitee From 2641c08162ebb07c2caaf3ce3ad4f6a5e38d75f9 Mon Sep 17 00:00:00 2001 From: Aurox Date: Fri, 24 Dec 2021 13:44:47 +0800 Subject: [PATCH 13/22] =?UTF-8?q?=E6=8C=89=E7=85=A7=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=E4=B8=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ActivemodelController.java | 213 +++++++++++++++--- .../controller/ClassmodelController.java | 158 ++++++++++--- .../controller/PictureController.java | 16 +- .../generator/controller/PptController.java | 19 +- .../controller/ResourcesController.java | 157 ++++++++++++- .../generator/controller/TextController.java | 146 +++++++++++- .../controller/UnitmodelController.java | 96 +++++--- .../generator/controller/VideoController.java | 18 +- .../generator/service/AnswerService.java | 11 + .../generator/service/ClassmodelService.java | 30 +++ .../generator/service/PictureService.java | 19 ++ .../modules/generator/service/PptService.java | 12 + .../generator/service/QuestionService.java | 8 + .../generator/service/TextService.java | 4 + .../generator/service/VideoService.java | 12 + .../generator/service/VideologService.java | 21 ++ .../service/impl/ActionmodelServiceImpl.java | 10 +- .../service/impl/ActivemodelServiceImpl.java | 71 +----- .../service/impl/AnswerServiceImpl.java | 7 + .../service/impl/ClassmodelServiceImpl.java | 32 ++- .../service/impl/FeetbackServiceImpl.java | 22 +- .../service/impl/PictureServiceImpl.java | 19 +- .../service/impl/PptServiceImpl.java | 17 +- .../service/impl/QuestionServiceImpl.java | 7 + .../service/impl/ResourcesServiceImpl.java | 34 +-- .../service/impl/TextServiceImpl.java | 18 +- .../service/impl/UnitmodelServiceImpl.java | 23 +- .../service/impl/VideoServiceImpl.java | 18 +- .../service/impl/VideologServiceImpl.java | 16 ++ src/main/resources/application-dev.yml | 2 +- 30 files changed, 970 insertions(+), 266 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java index 0e35321..ea71734 100644 --- a/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ActivemodelController.java @@ -1,8 +1,14 @@ package io.renren.modules.generator.controller; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; import java.util.*; +import com.aliyun.oss.OSS; +import com.aliyun.oss.model.DeleteObjectsRequest; +import com.aliyun.oss.model.DeleteObjectsResult; +import io.renren.common.utils.OssUtils; import io.renren.modules.generator.entity.*; import io.renren.modules.generator.service.*; import org.apache.commons.lang.StringUtils; @@ -25,6 +31,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; +import static com.aliyun.oss.internal.OSSConstants.URL_ENCODING; + /** * 活动表 @@ -34,7 +42,7 @@ import javax.servlet.http.HttpServletRequest; * @date 2021-11-20 16:36:43 */ @RestController -@RequestMapping("generator/activemodel") +@RequestMapping("generator/active") public class ActivemodelController { @Autowired private ActivemodelService activemodelService; @@ -63,21 +71,76 @@ public class ActivemodelController { @Autowired private UnitmodelService unitmodelService; + @Autowired + private ResourcesController resourcesController; + @Autowired + private ResourcesService resourcesService; - //2021 11/20 接口类型: "读" 测试人:ZhangShiYu - //根据单元的id获取该单元所有的活动 - @RequestMapping("/getAllActive") + /** + * 2021 11/20 接口类型: "读" 测试人:ZhangShiYu + * 根据单元的id获取该单元所有的活动 + *

+ * 2021.12.17 zhaomr 修改 + */ + @RequestMapping("/list") public R getAllActive(@RequestParam Map params) { - Object unit_id = params.get("unit_id"); - if (unit_id == null) - return R.error("传递字段缺少"); - List allActiveModel = activemodelService.getAllActiveModel(unit_id.toString()); + String unit_id = (String) params.get("id"); + String pn = (String) params.get("page"); + String ps = (String) params.get("limit"); + + if (unit_id == null) return R.error("缺少参数!"); + if (pn == null) pn = "1"; + if (ps == null) ps = "10"; + + List allActiveModel = activemodelService.getAllActiveModel(unit_id); + + List> mapList = new ArrayList<>(); + + for (ActivemodelEntity activemodelEntity : allActiveModel) { + Map map = new HashMap<>(); + + List classesEntityList = classesService.getByCAid(activemodelEntity.getActId()); + + ActionmodelEntity actionmodelEntity = actionmodelService.getByActIdAndNumber(activemodelEntity.getActId(), "8"); + + List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); + + map.put("id", activemodelEntity.getActId()); + map.put("name", activemodelEntity.getActName()); + List> mapList1 = new ArrayList<>(); - if (allActiveModel == null) - return R.error("没有这个单元"); + for (ClassesEntity classesEntity : classesEntityList) { + Map map1 = new HashMap<>(); + + map1.put("classNumber", classesEntity.getCNumber()); + + List studentEntityList = studentService.getBySTclass(classesEntity.getCId()); + + int sum = studentEntityList.size(); + int num = 0; + + if (questionEntityList != null) { + for (StudentEntity studentEntity : studentEntityList) { + AnswerEntity answerEntity = answerService.getBySIdAndQId(studentEntity.getSId(), questionEntityList.get(0).getQId()); + + if (answerEntity != null) num++; + } + }else num = sum; + + map1.put("num", num); + map1.put("sum", sum); + + mapList1.add(map1); + } - return R.ok().put("active_list", allActiveModel); + map.put("classinfo", mapList1); + mapList.add(map); + } + + PageUtils pageUtils = new PageUtils(mapList, mapList.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok().put("pageUtils", pageUtils); } //2021 11/21 接口类型: "读" 测试人:ZhangShiYu @@ -143,18 +206,18 @@ public class ActivemodelController { * @return R */ @Transactional - @RequestMapping("/insertActive") + @RequestMapping("/add") public R insertActive(@RequestParam Map params, HttpServletRequest request) { - String act_name = (String) params.get("act_name"); - String act_introduce = (String) params.get("act_introduce"); - String act_picNumber = (String) params.get("act_picNumber"); - String act_uid = (String) params.get("act_uid"); + String act_name = (String) params.get("name"); + String act_introduce = (String) params.get("remake"); + String act_picNumber = (String) params.get("img"); + String act_uid = (String) params.get("id"); if (act_name == null || act_uid == null) return R.error("缺少参数!"); if (activemodelService.getByName(act_name) != null) return R.error("活动名已存在"); - if(unitmodelService.getById(act_uid) == null) return R.error("单元未创建"); + if (unitmodelService.getById(act_uid) == null) return R.error("单元未创建"); String uuid = UUID.randomUUID().toString().replace("-", "").trim(); @@ -223,15 +286,92 @@ public class ActivemodelController { * @param params 请求参数 * @return R */ - @RequestMapping("/deleteById") + @Transactional + @RequestMapping("/delete") public R deleteById(@RequestParam Map params) { - String act_id = (String) params.get("act_id"); + String act_id = (String) params.get("id"); if (act_id == null) return R.error("缺少参数!"); - int result = activemodelService.deleteById(act_id); + if (activemodelService.deleteById(act_id) == 0) return R.error("删除失败!该活动不存在或操作数据库失败失败!"); + + List actionmodelEntityList = actionmodelService.getByActId(act_id); + + for (ActionmodelEntity actionmodelEntity : actionmodelEntityList) { + List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); - if (result == 0) return R.error("删除失败!该活动不存在或资源不存在或操作数据库失败失败!"); + for (QuestionEntity questionEntity : questionEntityList) { + List answerEntityList = answerService.getByQId(questionEntity.getQId()); + + for (AnswerEntity answerEntity : answerEntityList) { + if (answerService.deleteByEntity(answerEntity) == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("删除失败!操作数据库失败!"); + } + } + + if (questionService.deleteByEntity(questionEntity) == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("删除失败!操作数据库失败!"); + } + } + + if (!actionmodelService.deleteAction(actionmodelEntity.getActionId())) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("删除失败!操作数据库失败!"); + } + } + + if (feetbackService.deleteByActId(act_id) == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("删除失败!操作数据库失败!"); + } + + List resourcesEntities = resourcesService.getBySomeId(act_id, "Resources_actid"); + + for (ResourcesEntity resourcesEntity : resourcesEntities) { + Map map = new HashMap<>(); + map.put("resourcesEntity", resourcesEntity); + R r = resourcesController.deleteResource(map); + + if (r.get("code").toString().equals("500")) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error(r.get("msg").toString()); + } + } + + OSS ossClient = OssUtils.getOssClient(); + String bucketName = "ckedu2"; + List fileNames = new ArrayList<>(); + + for (ResourcesEntity resourcesEntity : resourcesEntities) { + Map map = new HashMap<>(); + map.put("resourcesEntity", resourcesEntity); + R r = resourcesController.getResourceLink(map); + + String link = r.get("data").toString(); + + String fileName = link.substring(OssUtils.getPath().length()); + fileNames.add(fileName); + } + + DeleteObjectsResult deleteObjectsResult = ossClient.deleteObjects(new DeleteObjectsRequest(bucketName).withKeys(fileNames).withEncodingType(URL_ENCODING).withQuiet(true)); + List deletedObjects = deleteObjectsResult.getDeletedObjects(); + + if (deletedObjects.size() != 0) { + List list = new ArrayList<>(); + + try { + for (String obj : deletedObjects) { + String deleteObj = URLDecoder.decode(obj, "UTF-8"); + list.add(deleteObj); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return R.ok("删除成功!部分OSS数据删除失败需手动删除").put("data", list); + } return R.ok("删除成功"); } @@ -244,14 +384,15 @@ public class ActivemodelController { * @param params 请求参数 * @return R */ - @RequestMapping("/updateActiveModel") + @RequestMapping("/update") public R updateActiveModel(@RequestParam Map params) { - String act_name = (String) params.get("act_name"); - String act_introduce = (String) params.get("act_introduce"); - String act_picNumber = (String) params.get("act_picNumber"); - String act_id = (String) params.get("act_id"); + String act_name = (String) params.get("name"); + String act_introduce = (String) params.get("remake"); + String act_picNumber = (String) params.get("img"); + String act_id = (String) params.get("id"); - if (act_name == null || act_id == null) return R.error("缺少参数!"); + if (act_name == null || act_id == null || act_introduce == null || act_picNumber == null) + return R.error("缺少参数!"); ActivemodelEntity activemodelEntity = activemodelService.getById(act_id); @@ -278,14 +419,14 @@ public class ActivemodelController { * @param params 请求参数 * @return R */ - @RequestMapping("/updateClassesOpen") + @RequestMapping("/openClass") public R updateClassesOpen(@RequestParam Map params) { - String c_number = (String) params.get("c_number"); - String act_id = (String) params.get("act_id"); + String c_id = (String) params.get("c_id"); + String act_id = (String) params.get("a_id"); - if (c_number == null || act_id == null) return R.error("缺少参数!"); + if (c_id == null || act_id == null) return R.error("缺少参数!"); - ClassesEntity classesEntity = classesService.getByNumber(c_number); + ClassesEntity classesEntity = classesService.getById(c_id); if (classesEntity == null) return R.error("更改失败!该班级未创建"); @@ -695,7 +836,7 @@ public class ActivemodelController { /** * 列表 */ - @RequestMapping("/list") + @RequestMapping("/list_old") @RequiresPermissions("generator:activemodel:list") public R list(@RequestParam Map params) { PageUtils page = activemodelService.queryPage(params); @@ -717,7 +858,7 @@ public class ActivemodelController { /** * 保存 */ - @RequestMapping("/save") + @RequestMapping("/save_old") @RequiresPermissions("generator:activemodel:save") public R save(@RequestBody ActivemodelEntity activemodel) { activemodelService.save(activemodel); @@ -728,7 +869,7 @@ public class ActivemodelController { /** * 修改 */ - @RequestMapping("/update") + @RequestMapping("/update_old") @RequiresPermissions("generator:activemodel:update") public R update(@RequestBody ActivemodelEntity activemodel) { activemodelService.updateById(activemodel); @@ -739,7 +880,7 @@ public class ActivemodelController { /** * 删除 */ - @RequestMapping("/delete") + @RequestMapping("/delete_old") @RequiresPermissions("generator:activemodel:delete") public R delete(@RequestBody String[] actIds) { activemodelService.removeByIds(Arrays.asList(actIds)); diff --git a/src/main/java/io/renren/modules/generator/controller/ClassmodelController.java b/src/main/java/io/renren/modules/generator/controller/ClassmodelController.java index 8656d86..ef2dd4f 100644 --- a/src/main/java/io/renren/modules/generator/controller/ClassmodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/ClassmodelController.java @@ -1,12 +1,16 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; +import io.renren.modules.generator.entity.ActivemodelEntity; import io.renren.modules.generator.entity.ClassesEntity; +import io.renren.modules.generator.entity.UnitmodelEntity; +import io.renren.modules.generator.service.UnitmodelService; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -28,11 +32,16 @@ import io.renren.common.utils.R; * @date 2021-11-20 16:36:43 */ @RestController -@RequestMapping("generator/classmodel") +@RequestMapping("generator/course") public class ClassmodelController { @Autowired private ClassmodelService classmodelService; + @Autowired + private UnitmodelService unitmodelService; + + @Autowired + private UnitmodelController unitmodelController; //根据课程课程名简介图片链接 //2021 11/20 接口类型:"写" 测试人:冯坤 @@ -54,15 +63,39 @@ public class ClassmodelController { //课程id //2021 11/20 接口类型:"写" 测试人:冯坤 //根据课程的id删除课程 - @RequestMapping("/deleteCourse") + @Transactional + @RequestMapping("/delete") public R deleteCourse(@RequestParam Map map){ - Object c_id = map.get("c_id"); - if (c_id==null) + Object c_id = map.get("id"); + + if (c_id == null) return R.error("请求参数缺少"); - if (classmodelService.deleteCourse(c_id.toString())) - return R.ok(); - return R.error("课程不存在"); + + if (!classmodelService.deleteCourse(c_id.toString())) + return R.error("课程不存在或操作数据库失败"); + + List unitmodelEntityList = unitmodelService.getAllUnit((String) c_id); + + for (UnitmodelEntity unitmodelEntity : unitmodelEntityList) { + Map hashMap = new HashMap<>(); + hashMap.put("u_id", unitmodelEntity.getUId()); + + R r = unitmodelController.deleteById(hashMap); + + //有错误 不进 并且进unitcontroller里缺少参数 + if("500".equals(r.get("code").toString())) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + + if(r.get("data") == null) + return R.error(r.get("msg").toString()); + else + return R.error(r.get("msg").toString()).put("data", r.get("data")); + } + } + + return R.ok("删除成功"); } + //课程id //2021 11/20 接口类型:"读" 测试人:冯坤 //根据课程查询所有参与此课程的班级对象集合 @@ -77,11 +110,84 @@ public class ClassmodelController { } return R.ok().put("classes",classes); } + + @RequestMapping("/add") + public R insertCourse(@RequestParam Map params) { + String class_name = (String) params.get("name"); + String class_picNumber = (String) params.get("img"); + String class_introduce = (String) params.get("remake"); + + if(class_name == null) return R.error("缺少参数"); + + if (classmodelService.getByName(class_name) != null) return R.error("新增失败!课程名已存在"); + + String uuid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uuid)) return R.error("新建失败!uuid生成失败"); + + ClassmodelEntity classmodelEntity = new ClassmodelEntity(); + + classmodelEntity.setClassId(uuid); + classmodelEntity.setClassName(class_name); + classmodelEntity.setClassPicnumber(class_picNumber); + classmodelEntity.setClassIntroduce(class_introduce); + + int result = classmodelService.insertClassModel(classmodelEntity); + + if(result == 0) return R.error("新建失败!操作数据库失败"); + + return R.ok("新建成功!").put("class_id", uuid); + } + /** - * 列表 + * 2021.12.16 + * zhaomr + * 更新班级信息 + * + * @param params 参数列表 + * @return R */ + @RequestMapping("/update") + public R updateCourse(@RequestParam Map params) { + String class_name = (String) params.get("class_name"); + String class_picNumber = (String) params.get("img"); + String class_introduce = (String) params.get("remake"); + String class_id = (String) params.get("course_id"); + + if(class_id == null || class_name == null || class_introduce == null || class_picNumber == null) + return R.error("更新失败!缺少参数!"); + + ClassmodelEntity classmodelEntity = classmodelService.getById(class_id); + classmodelEntity.setClassName(class_name); + classmodelEntity.setClassPicnumber(class_picNumber); + classmodelEntity.setClassIntroduce(class_introduce); + + int res = classmodelService.updateCourse(classmodelEntity); + + if(res == 0) return R.error("更新失败!操作数据库失败!"); + return R.ok("更新成功!"); + } + @RequestMapping("/list") - @RequiresPermissions("generator:classmodel:list") + public R getAllCourse(@RequestParam Map params) { + String pn = (String) params.get("page"); + String ps = (String) params.get("limit"); + + if(pn == null) pn = "1"; + if(ps == null) ps = "10"; + + List list = classmodelService.getAll(); + + PageUtils pageUtils = new PageUtils(list, list.size(), Integer.parseInt(ps), Integer.parseInt(pn)); + + return R.ok("查询成功").put("pageUtils", pageUtils); + } + + /** + * 列表 + */ + @RequestMapping("/list_old") + @RequiresPermissions("teacher:course:list") public R list(@RequestParam Map params){ PageUtils page = classmodelService.queryPage(params); @@ -93,18 +199,18 @@ public class ClassmodelController { * 信息 */ @RequestMapping("/info/{classId}") - @RequiresPermissions("generator:classmodel:info") + @RequiresPermissions("teacher:course:info") public R info(@PathVariable("classId") String classId){ ClassmodelEntity classmodel = classmodelService.getById(classId); - return R.ok().put("classmodel", classmodel); + return R.ok().put("clsssmodel", classmodel); } /** * 保存 */ @RequestMapping("/save") - @RequiresPermissions("generator:classmodel:save") + @RequiresPermissions("teacher:course:save") public R save(@RequestBody ClassmodelEntity classmodel){ classmodelService.save(classmodel); @@ -114,25 +220,11 @@ public class ClassmodelController { /** * 修改 */ - @RequestMapping("/update") - @RequiresPermissions("generator:classmodel:update") - public R update(@RequestBody ClassmodelEntity classmodel){ - classmodelService.updateById(classmodel); - classmodelService.alterCourseName(classmodel.getClassId(),classmodel.getClassName()); - classmodelService.alterCourseIntroduce(classmodel.getClassId(),classmodel.getClassIntroduce()); - classmodelService.alterCoursePicture(classmodel.getClassId(),classmodel.getClassPicnumber()); - return R.ok(); - } - - /** - * 删除 - */ - @RequestMapping("/delete") - @RequiresPermissions("generator:classmodel:delete") - public R delete(@RequestBody String[] classIds){ - classmodelService.removeByIds(Arrays.asList(classIds)); + @RequestMapping("/update_old") + @RequiresPermissions("teacher:course:update") + public R update(@RequestBody String[] classIds){ + classmodelService.removeByIds(Arrays.asList(classIds)); return R.ok(); } - } diff --git a/src/main/java/io/renren/modules/generator/controller/PictureController.java b/src/main/java/io/renren/modules/generator/controller/PictureController.java index c5b8773..838b8da 100644 --- a/src/main/java/io/renren/modules/generator/controller/PictureController.java +++ b/src/main/java/io/renren/modules/generator/controller/PictureController.java @@ -59,8 +59,6 @@ public class PictureController { @Autowired private UnitmodelService unitmodelService; - private static long num = 0; - /** * time: 2021.11.23 * zhaomr @@ -79,7 +77,7 @@ public class PictureController { return R.error("文件为空!"); } - String p_introduce = (String) params.get("p_introduce"); + String p_introduce = (String) params.get("introduce"); String mid = (String) params.get("mid"); String unitid = (String) params.get("unitid"); String actid = (String) params.get("actid"); @@ -129,8 +127,10 @@ public class PictureController { ips = new FileInputStream(file1); file1.deleteOnExit(); + int num = pictureService.getAllNum(); + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); - String p_number = t_id.substring(0, 3) + type + num++; + String p_number = t_id.substring(0, 3) + type + num; fileName += p_number + "." + type; OSS ossClient = OssUtils.getOssClient(); @@ -189,13 +189,7 @@ public class PictureController { return R.error("导入数据库失败!"); } - List> maplist =new ArrayList<>(); - Map map = new HashMap<>(); - map.put("p_number", p_number); - map.put("p_link", pictureEntity.getPLink()); - maplist.add(map); - - return R.ok("导入成功!").put("data", maplist); + return R.ok("导入成功!").put("url", pictureEntity.getPLink()); } } diff --git a/src/main/java/io/renren/modules/generator/controller/PptController.java b/src/main/java/io/renren/modules/generator/controller/PptController.java index c2cbef9..41d7592 100644 --- a/src/main/java/io/renren/modules/generator/controller/PptController.java +++ b/src/main/java/io/renren/modules/generator/controller/PptController.java @@ -57,8 +57,6 @@ public class PptController { @Autowired private UnitmodelService unitmodelService; - private static long num = 0; - /** * time: 2021.11.23 * zhaomr @@ -77,7 +75,7 @@ public class PptController { return R.error("文件为空!"); } - String pt_introduce = (String) params.get("pt_introduce"); + String pt_introduce = (String) params.get("introduce"); String mid = (String) params.get("mid"); String unitid = (String) params.get("unitid"); String actid = (String) params.get("actid"); @@ -108,6 +106,8 @@ public class PptController { String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); +// String t_id = "12323143243"; + if(StringUtils.isEmpty(t_id)) { return R.error("token不存在"); } @@ -124,9 +124,10 @@ public class PptController { ips = new FileInputStream(file1); file1.deleteOnExit(); - type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + int num = pptService.getAllNum(); - String pt_number = t_id.substring(0, 3) + type + num++; + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String pt_number = t_id.substring(0, 3) + type + num; fileName += pt_number + "." + type; OSS ossClient = OssUtils.getOssClient(); @@ -185,13 +186,7 @@ public class PptController { return R.error("导入数据库失败!"); } - List> maplist =new ArrayList<>(); - Map map = new HashMap<>(); - map.put("pt_number", pt_number); - map.put("pt_link", pptEntity.getPtLink()); - maplist.add(map); - - return R.ok("导入成功!").put("data", maplist); + return R.ok("导入成功!").put("url", pptEntity.getPtLink()); } } diff --git a/src/main/java/io/renren/modules/generator/controller/ResourcesController.java b/src/main/java/io/renren/modules/generator/controller/ResourcesController.java index a15dc50..ae7ca73 100644 --- a/src/main/java/io/renren/modules/generator/controller/ResourcesController.java +++ b/src/main/java/io/renren/modules/generator/controller/ResourcesController.java @@ -1,21 +1,36 @@ package io.renren.modules.generator.controller; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Map; +import com.aliyun.oss.OSS; +import com.google.common.io.LittleEndianDataOutputStream; +import io.renren.common.utils.OssUtils; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.ResourcesEntity; -import io.renren.modules.generator.service.ResourcesService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import org.w3c.dom.stylesheets.LinkStyle; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +46,144 @@ public class ResourcesController { @Autowired private ResourcesService resourcesService; + @Autowired + private VideoService videoService; + + @Autowired + private VideologService videologService; + + @Autowired + private PictureService pictureService; + + @Autowired + private PptService pptService; + + @Autowired + private TextService textService; + + @Autowired + private PictureController pictureController; + + @Autowired + private PptController pptController; + + @Autowired + private VideoController videoController; + + @Autowired + private TextController textController; + + @Transactional + @RequestMapping("deleteResource") + public R deleteResource(@RequestParam Map prams) { + ResourcesEntity resourcesEntity = (ResourcesEntity) prams.get("resourcesEntity"); + + if(resourcesService.deleteResource(resourcesEntity) == 0) { + return R.error("删除失败!该资源不存在或操作数据库失败!"); + } + + String type = resourcesEntity.getResourcesType(); + String id = resourcesEntity.getResourcesRid(); + int rs = 0; + + if(("1").equals(type)) { + VideoEntity videoEntity = videoService.getById(id); + rs = videoService.deleteByEntity(videoEntity); + + if(rs != 0) { + List videologEntityList = videologService.getByVNumber(resourcesEntity.getResourcesRnumber()); + + for (VideologEntity videologEntity : videologEntityList) { + if(videologService.deleteByEntity(videologEntity) == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("删除失败!操作数据库失败!"); + } + } + } + }else if("2".equals(type)){ + PictureEntity pictureEntity = pictureService.getById(id); + rs = pictureService.deleteByEntity(pictureEntity); + }else if("3".equals(type)) { + PptEntity pptEntity = pptService.getById(id); + rs = pptService.deleteByEntity(pptEntity); + }else { + rs = textService.deleteById(id); + } + + if(rs == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("删除失败!操作数据库失败!"); + } + + return R.ok("删除成功!"); + } + + @RequestMapping("/getResourceLink") + public R getResourceLink(@RequestParam Map params) { + ResourcesEntity resourcesEntity = (ResourcesEntity) params.get("resourcesEntity"); + String type = resourcesEntity.getResourcesType(); + String id = resourcesEntity.getResourcesRid(); + String link = ""; + + if(("1").equals(type)) { + link = videoService.getById(id).getVLink(); + }else if("2".equals(type)){ + link = pictureService.getById(id).getPLink(); + }else if("3".equals(type)) { + link = pptService.getById(id).getPtLink(); + } + + return R.ok("查询成功!").put("data", link); + } + + @RequestMapping("/upload") + public R insertResource(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String mid = (String) params.get("mid"); + String unitid = (String) params.get("unitid"); + String actid = (String) params.get("actid"); + String actionid = (String) params.get("actionid"); + + List pictureType = new ArrayList<>(Arrays.asList("png", "jpg", "raw", "gif", "jpeg", "svg", "swf", "psd", "tiff", "webp", "bmp", "pdf")); + List videoType = new ArrayList<>(Arrays.asList("mp4", "mov", "m4v", "avi", "dat", "mkv", "flv", "vob", "3gp", "mvb", "wmv", "asf", "asx")); + List pptType = new ArrayList<>(Arrays.asList("xlsx", "xls", "xlsm", "xlsb", "xltx", "xltm", "xlam", "xla")); + List textType = new ArrayList<>(Arrays.asList("txt", "word")); + + if(mid == null && unitid == null && actid == null && actionid == null) return R.error("缺少参数"); + +// String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + +// 测试 + String t_id = "123123123123"; + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + R r = null; + + if(pictureType.contains(type)) { + r = pictureController.insertPicture(file, params, request); + }else if(videoType.contains(type)) { + r = videoController.insertVideo(file, params, request); + }else if(pptType.contains(type)) { + r = pptController.insertPpt(file, params, request); + }else if(textType.contains(type)) { + r = textController.insertText(file, params, request); + }else{ + return R.error("传入文件格式不正确!"); + } + + if(r.get("code").toString().equals("500")) + return R.error(r.get("msg").toString()); + + return R.ok(r.get("msg").toString()).put("url", r.get("url")); + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/TextController.java b/src/main/java/io/renren/modules/generator/controller/TextController.java index ee23be7..c6bb128 100644 --- a/src/main/java/io/renren/modules/generator/controller/TextController.java +++ b/src/main/java/io/renren/modules/generator/controller/TextController.java @@ -1,21 +1,33 @@ package io.renren.modules.generator.controller; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.Arrays; import java.util.Map; +import java.util.UUID; +import com.aliyun.oss.OSS; +import io.renren.common.utils.OssUtils; +import io.renren.modules.generator.entity.*; +import io.renren.modules.generator.service.*; +import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import io.renren.modules.generator.entity.TextEntity; -import io.renren.modules.generator.service.TextService; import io.renren.common.utils.PageUtils; import io.renren.common.utils.R; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.annotation.MultipartConfig; +import javax.servlet.http.HttpServletRequest; /** @@ -31,6 +43,136 @@ public class TextController { @Autowired private TextService textService; + @Autowired + private ActionmodelService actionmodelService; + + @Autowired + private ActivemodelService activemodelService; + + @Autowired + private UnitmodelService unitmodelService; + + @Autowired + private ResourcesService resourcesService; + + @RequestMapping("/add") + public R insertText(@RequestParam(value = "file") MultipartFile file, @RequestParam Map params, HttpServletRequest request) throws IOException { + if(file.isEmpty()) { + return R.error("文件为空!"); + } + + String mid = (String) params.get("mid"); + String unitid = (String) params.get("unitid"); + String actid = (String) params.get("actid"); + String actionid = (String) params.get("actionid"); + + if(mid == null && unitid == null && actid == null && actionid == null) return R.error("缺少参数"); + + if(actionid != null) { + if(actid == null) { + ActionmodelEntity actionmodelEntity = actionmodelService.getByActionId(actionid); + actid = actionmodelEntity.getActionActid(); + } + } + + if(actid != null) { + if(unitid == null) { + ActivemodelEntity activemodelEntity = activemodelService.getById(actid); + unitid = activemodelEntity.getActUid(); + } + } + + if(unitid != null) { + if(mid == null) { + UnitmodelEntity unitmodelEntity = unitmodelService.getById(unitid); + mid = unitmodelEntity.getUClassid(); + } + } + +// String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); + +// 测试 + String t_id = "123123123123"; + + if(StringUtils.isEmpty(t_id)) { + return R.error("token不存在"); + } + + String bucketName = "ckedu2"; + String fileName = "text/"; + String type = ""; + + // MultipartFile转FileInputStream + InputStream ips = null; + File file1 = null; + file1 = File.createTempFile("temp", null); + file.transferTo(file1); + ips = new FileInputStream(file1); + file1.deleteOnExit(); + + int num = textService.getAllNum(); + + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); + String text_number = t_id.substring(0, 3) + type + num; + fileName += text_number + "." + type; + + OSS ossClient = OssUtils.getOssClient(); + + if (!ossClient.doesBucketExist(bucketName)) { + return R.error("bucket未创建"); + } + + ossClient.putObject(bucketName, fileName, ips); + + TextEntity textEntity = new TextEntity(); + + //生成uuid + String uid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uid)) return R.error("添加失败!uuid生成失败"); + + textEntity.setTextId(uid); + textEntity.setTextContent(file.getOriginalFilename()); + + textEntity.setTextNumber(text_number); + + int result = textService.insertText(textEntity); + + ossClient.shutdown(); + + if(result == 0) { + return R.error("导入数据库失败"); + }else{ + ResourcesEntity resourcesEntity = new ResourcesEntity(); + + String uUid = UUID.randomUUID().toString().replace("-", "").trim(); + + if(StringUtils.isEmpty(uUid)) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("添加失败!uuid生成失败!"); + } + + resourcesEntity.setResourcesId(uUid); + resourcesEntity.setResourcesActid(actid); + resourcesEntity.setResourcesActionid(actionid); + resourcesEntity.setResourcesMid(mid); + resourcesEntity.setResourcesRid(uid); + resourcesEntity.setResourcesType("4"); + resourcesEntity.setResourcesUnitid(unitid); + resourcesEntity.setResourcesRnumber(text_number); + + int res = resourcesService.insertResource(resourcesEntity); + + if(res == 0) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return R.error("导入数据库失败!"); + } + + //还需要向前端传入url + return R.ok("导入成功!"); + } + } + /** * 列表 */ diff --git a/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java b/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java index c55ddc3..a36138e 100644 --- a/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java +++ b/src/main/java/io/renren/modules/generator/controller/UnitmodelController.java @@ -1,15 +1,15 @@ package io.renren.modules.generator.controller; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.util.*; import io.renren.modules.generator.entity.ActivemodelEntity; +import io.renren.modules.generator.service.ActivemodelService; import io.renren.modules.generator.service.ClassmodelService; import org.apache.commons.lang.StringUtils; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -31,7 +31,7 @@ import io.renren.common.utils.R; * @date 2021-11-20 16:36:43 */ @RestController -@RequestMapping("generator/unitmodel") +@RequestMapping("generator/unit") public class UnitmodelController { @Autowired private UnitmodelService unitmodelService; @@ -39,15 +39,33 @@ public class UnitmodelController { @Autowired private ClassmodelService classmodelService; - //2021 11/20 接口类型: "读" 测试人:ZhangShiYu - //根据课程id获取所有的单元对象实体 - @RequestMapping("/getAllUnit") + @Autowired + private ActivemodelService activemodelService; + + @Autowired + private ActivemodelController activemodelController; + + /** + * 2021 11/20 接口类型: "读" 测试人:ZhangShiYu + * 根据课程id获取所有的单元对象实体 + * 2021.12.17 zhaomr 修改 + */ + + @RequestMapping("/list") public R getAllUnit(@RequestParam Map params){ - Object course_id = params.get("course_id"); - if (course_id==null) - return R.error("传递字段缺少"); + Object course_id = params.get("id"); + Object pn = params.get("page"); + Object ps = params.get("limit"); + + if (course_id==null) return R.error("缺少参数!"); + if(pn == null) pn = "1"; + if(ps == null) ps = "10"; + List allUnit = unitmodelService.getAllUnit(course_id.toString()); - return R.ok().put("unitList",allUnit); + + PageUtils pageUtils = new PageUtils(allUnit, allUnit.size(), Integer.parseInt(ps.toString()), Integer.parseInt(pn.toString())); + + return R.ok().put("unitList",pageUtils); } /** @@ -58,12 +76,12 @@ public class UnitmodelController { * @param params 请求参数 * @return R */ - @RequestMapping("/insertUnit") + @RequestMapping("/add") public R insertUnit(@RequestParam Map params) { - String u_classid = (String) params.get("u_classid"); - String u_name = (String) params.get("u_name"); - String u_picNumber = (String) params.get("u_picNumber"); - String u_introduce = (String) params.get("u_introduce"); + String u_classid = (String) params.get("id"); + String u_name = (String) params.get("name"); + String u_picNumber = (String) params.get("img"); + String u_introduce = (String) params.get("remake"); if(u_classid == null || u_name == null) return R.error("缺少参数"); @@ -90,14 +108,15 @@ public class UnitmodelController { return R.ok("新建成功!").put("u_id", uuid); } - @RequestMapping("/updateUnit") + @RequestMapping("/update") public R updateUnit(@RequestParam Map params) { - String u_name = (String) params.get("u_name"); - String u_introduce = (String) params.get("u_introduce"); - String u_picNumber = (String) params.get("u_picNumber"); - String u_id = (String) params.get("u_id"); + String u_name = (String) params.get("name"); + String u_introduce = (String) params.get("remake"); + String u_picNumber = (String) params.get("img"); + String u_id = (String) params.get("id"); - if (u_name == null || u_id == null) return R.error("缺少参数!"); + if (u_name == null || u_id == null || u_picNumber == null || u_introduce == null) + return R.error("缺少参数!"); UnitmodelEntity unitmodelEntity = unitmodelService.getById(u_id); @@ -116,9 +135,10 @@ public class UnitmodelController { return R.ok("修改成功!"); } - @RequestMapping("/deleteById") + @Transactional + @RequestMapping("/delete") public R deleteById(@RequestParam Map params) { - String u_id = (String) params.get("u_id"); + String u_id = (String) params.get("id"); if(u_id == null) return R.error("缺少参数"); @@ -126,13 +146,31 @@ public class UnitmodelController { if(result == 0) return R.error("删除失败!该单元未创建或资源不存在或操作数据库失败"); + List activemodelEntityList = activemodelService.getAllActiveModel(u_id); + + for (ActivemodelEntity activemodelEntity : activemodelEntityList) { + Map map = new HashMap<>(); + map.put("act_id", activemodelEntity.getActId()); + + R r = activemodelController.deleteById(map); + + if(r.get("code").toString().equals("500")) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + + if(r.get("data") == null) + return R.error(r.get("msg").toString()); + else + return R.error(r.get("msg").toString()).put("data", r.get("data")); + } + } + return R.ok("删除成功"); } /** * 列表 */ - @RequestMapping("/list") + @RequestMapping("/list_old") @RequiresPermissions("generator:unitmodel:list") public R list(@RequestParam Map params){ PageUtils page = unitmodelService.queryPage(params); @@ -155,7 +193,7 @@ public class UnitmodelController { /** * 保存 */ - @RequestMapping("/save") + @RequestMapping("/save_old") @RequiresPermissions("generator:unitmodel:save") public R save(@RequestBody UnitmodelEntity unitmodel){ unitmodelService.save(unitmodel); @@ -166,7 +204,7 @@ public class UnitmodelController { /** * 修改 */ - @RequestMapping("/update") + @RequestMapping("/update_old") @RequiresPermissions("generator:unitmodel:update") public R update(@RequestBody UnitmodelEntity unitmodel){ unitmodelService.updateById(unitmodel); @@ -177,7 +215,7 @@ public class UnitmodelController { /** * 删除 */ - @RequestMapping("/delete") + @RequestMapping("/delete_old") @RequiresPermissions("generator:unitmodel:delete") public R delete(@RequestBody String[] uIds){ unitmodelService.removeByIds(Arrays.asList(uIds)); diff --git a/src/main/java/io/renren/modules/generator/controller/VideoController.java b/src/main/java/io/renren/modules/generator/controller/VideoController.java index d2e7a52..d61c5e6 100644 --- a/src/main/java/io/renren/modules/generator/controller/VideoController.java +++ b/src/main/java/io/renren/modules/generator/controller/VideoController.java @@ -57,8 +57,6 @@ public class VideoController { @Autowired private UnitmodelService unitmodelService; - private static int num = 0; - /** * time: 2021.11.23 * zhaomr @@ -77,7 +75,7 @@ public class VideoController { return R.error("文件为空!"); } - String v_introduce = (String) params.get("v_introduce"); + String v_introduce = (String) params.get("introduce"); String mid = (String) params.get("mid"); String unitid = (String) params.get("unitid"); String actid = (String) params.get("actid"); @@ -108,6 +106,8 @@ public class VideoController { String t_id = tokenManager.getUserInfoFromToken(request.getHeader("token")); +// String t_id = "12345435"; + if(StringUtils.isEmpty(t_id)) { return R.error("token不存在"); } @@ -124,8 +124,10 @@ public class VideoController { ips = new FileInputStream(file1); file1.deleteOnExit(); + int num = videoService.getAllNum(); + type = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1); - String v_number = t_id.substring(0, 3) + type + num++; + String v_number = t_id.substring(0, 3) + type + num; fileName += v_number + "." + type; OSS ossClient = OssUtils.getOssClient(); @@ -184,13 +186,7 @@ public class VideoController { return R.error("导入数据库失败!"); } - List> maplist =new ArrayList<>(); - Map map = new HashMap<>(); - map.put("v_number", v_number); - map.put("v_link", videoEntity.getVLink()); - maplist.add(map); - - return R.ok("导入成功!").put("data", maplist); + return R.ok("导入成功!").put("url", videoEntity.getVLink()); } } diff --git a/src/main/java/io/renren/modules/generator/service/AnswerService.java b/src/main/java/io/renren/modules/generator/service/AnswerService.java index fe4adb1..706b501 100644 --- a/src/main/java/io/renren/modules/generator/service/AnswerService.java +++ b/src/main/java/io/renren/modules/generator/service/AnswerService.java @@ -3,6 +3,7 @@ package io.renren.modules.generator.service; import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.generator.entity.AnswerEntity; +import io.renren.modules.generator.entity.QuestionEntity; import java.util.List; import java.util.Map; @@ -58,5 +59,15 @@ public interface AnswerService extends IService { * @return 是否成功 */ int deleteByQid(String qId); + + /** + * 2021.12.16 + * zhaomr + * 根据实体删除 + * + * @param answerEntity 问题实体 + * @return int 影响行数 + */ + int deleteByEntity(AnswerEntity answerEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/ClassmodelService.java b/src/main/java/io/renren/modules/generator/service/ClassmodelService.java index b969c0a..1f9187f 100644 --- a/src/main/java/io/renren/modules/generator/service/ClassmodelService.java +++ b/src/main/java/io/renren/modules/generator/service/ClassmodelService.java @@ -35,5 +35,35 @@ public interface ClassmodelService extends IService { * @return */ List getClasses(String cid); + + /** + * 根据课程名称查找课程 + * @param class_name 课程名 + * @return ClassModelEntity + */ + ClassmodelEntity getByName(String class_name); + + /** + * 新增课程 + * @param classmodelEntity 课程实体 + * @return int 影响行数 + */ + int insertClassModel(ClassmodelEntity classmodelEntity); + + /** + * 更新课程 + * @param classmodelEntity 更新课程 + * @return int 影响行数 + */ + int updateCourse(ClassmodelEntity classmodelEntity); + + /** + * 2021.12.16 + * zhaomr + * 获得所有课程 + * @return List + */ + List getAll(); + } diff --git a/src/main/java/io/renren/modules/generator/service/PictureService.java b/src/main/java/io/renren/modules/generator/service/PictureService.java index 0a33e7b..22b4d8b 100644 --- a/src/main/java/io/renren/modules/generator/service/PictureService.java +++ b/src/main/java/io/renren/modules/generator/service/PictureService.java @@ -22,5 +22,24 @@ public interface PictureService extends IService { PictureEntity getByNumber(String pNumber); int deleteByIdAndLink(String p_id, String p_link); + + /** + * 2021.12.16 + * zhaomr + * 查询所有图片总记录数 + * + * @return int 总记录数 + */ + int getAllNum(); + + /** + * 2021.12.16 + * zhaomr + * 根据实体删除图片 + * + * @param pictureEntity 图片实体 + * @return int 影响行数 + */ + int deleteByEntity(PictureEntity pictureEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/PptService.java b/src/main/java/io/renren/modules/generator/service/PptService.java index fa5cba3..9be2d3a 100644 --- a/src/main/java/io/renren/modules/generator/service/PptService.java +++ b/src/main/java/io/renren/modules/generator/service/PptService.java @@ -20,5 +20,17 @@ public interface PptService extends IService { int insertPpt(PptEntity pptEntity); int deleteByIdAndLink(String pt_id, String pt_link); + + int getAllNum(); + + /** + * 2021.12.16 + * zhaomr + * 根据实体删除ppt + * + * @param pptEntity ppt实体 + * @return int 影响行数 + */ + int deleteByEntity(PptEntity pptEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/QuestionService.java b/src/main/java/io/renren/modules/generator/service/QuestionService.java index 1276b42..f80409d 100644 --- a/src/main/java/io/renren/modules/generator/service/QuestionService.java +++ b/src/main/java/io/renren/modules/generator/service/QuestionService.java @@ -50,5 +50,13 @@ public interface QuestionService extends IService { * @return */ int updateQuestion(QuestionEntity questionEntity); + + /** + * 2021.12.16 + * zhaomr + * @param questionEntity 问题实体 + * @return int 影响行数 + */ + int deleteByEntity(QuestionEntity questionEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/TextService.java b/src/main/java/io/renren/modules/generator/service/TextService.java index feb47e3..c4021f8 100644 --- a/src/main/java/io/renren/modules/generator/service/TextService.java +++ b/src/main/java/io/renren/modules/generator/service/TextService.java @@ -18,5 +18,9 @@ public interface TextService extends IService { PageUtils queryPage(Map params); int deleteById(String text_id); + + int getAllNum(); + + int insertText(TextEntity textEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/VideoService.java b/src/main/java/io/renren/modules/generator/service/VideoService.java index fb5e681..6ae48cf 100644 --- a/src/main/java/io/renren/modules/generator/service/VideoService.java +++ b/src/main/java/io/renren/modules/generator/service/VideoService.java @@ -20,5 +20,17 @@ public interface VideoService extends IService { int insertVideo(VideoEntity videoEntity); int deleteByIdAndLink(String v_id, String v_link); + + int getAllNum(); + + /** + * 2021.12.16 + * zhaomr + * 根据实体删除视频 + * + * @param videoEntity 视频实体 + * @return int 影响行数 + */ + int deleteByEntity(VideoEntity videoEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/VideologService.java b/src/main/java/io/renren/modules/generator/service/VideologService.java index 816aed1..7af8afe 100644 --- a/src/main/java/io/renren/modules/generator/service/VideologService.java +++ b/src/main/java/io/renren/modules/generator/service/VideologService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import io.renren.common.utils.PageUtils; import io.renren.modules.generator.entity.VideologEntity; +import java.util.List; import java.util.Map; /** @@ -18,5 +19,25 @@ public interface VideologService extends IService { PageUtils queryPage(Map params); int deleteByVNumber(String resourcesRnumber); + + /** + * 2021.12.16 + * zhaomr + * 根据视频号查找记录 + * + * @param resourcesRnumber 视频号 + * @return List 视频日志表集合 + */ + List getByVNumber(String resourcesRnumber); + + /** + * 2021.12.16 + * zhaomr + * 根据视频号记录实体查找 + * + * @param videologEntity 视频日志实体 + * @return int 影响行数 + */ + int deleteByEntity(VideologEntity videologEntity); } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java index 6f588dc..beba2e9 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActionmodelServiceImpl.java @@ -70,10 +70,12 @@ public class ActionmodelServiceImpl extends ServiceImpl updateWrapper=new UpdateWrapper<>(); - updateWrapper.eq("action_id",action_id); - int delete = actionmodelDao.delete(updateWrapper); - if(delete==1){ + ActionmodelEntity actionmodelEntity = actionmodelDao.selectById(action_id); + actionmodelEntity.setIsDelete("true"); + + int res = actionmodelDao.updateById(actionmodelEntity); + + if(res == 1){ return true; } return false; diff --git a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java index a28b838..62a750e 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ActivemodelServiceImpl.java @@ -25,21 +25,6 @@ public class ActivemodelServiceImpl extends ServiceImpl params) { IPage page = this.page( @@ -55,10 +40,9 @@ public class ActivemodelServiceImpl extends ServiceImpl getAllActiveModel(String unitId) { QueryWrapper queryWrapper=new QueryWrapper<>(); queryWrapper.eq("act_uid",unitId); - List activemodelEntities = activemodelDao.selectList(queryWrapper); - if (activemodelEntities==null) - return null; - return activemodelEntities; + queryWrapper.eq("is_delete", "false"); + + return activemodelDao.selectList(queryWrapper); } /** @@ -82,56 +66,13 @@ public class ActivemodelServiceImpl extends ServiceImpl actionmodelEntityList = actionmodelService.getByActId(act_id); + activemodelEntity.setIsDelete("true"); - for (ActionmodelEntity actionmodelEntity : actionmodelEntityList) { - List questionEntityList = questionService.getByActionId(actionmodelEntity.getActionId()); - int res = questionService.deleteByActionId(actionmodelEntity.getActionId()); - - if(res != questionEntityList.size()) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return 0; - } - - for (QuestionEntity questionEntity : questionEntityList) { - List answerEntityList = answerService.getByQId(questionEntity.getQId()); - int rs = answerService.deleteByQid(questionEntity.getQId()); - - if(rs != answerEntityList.size()) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return 0; - } - } - - boolean flag = actionmodelService.deleteAction(actionmodelEntity.getActionId()); - - if(!flag) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return 0; - } - } - - feetbackService.deleteByActId(act_id); - - List resourcesEntities = resourcesService.getBySomeId(act_id, "Resources_actid"); - - for (ResourcesEntity resourcesEntity : resourcesEntities) { - int rs = resourcesService.deleteResource(resourcesEntity); - - if(rs == 0) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return 0; - } - } - - return result; + return activemodelDao.updateById(activemodelEntity); } /** diff --git a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java index b73474e..cd4b0fc 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/AnswerServiceImpl.java @@ -200,4 +200,11 @@ public class AnswerServiceImpl extends ServiceImpl impl return answerDao.deleteByMap(map); } + + @Override + public int deleteByEntity(AnswerEntity answerEntity) { + answerEntity.setIsDelete("true"); + + return answerDao.updateById(answerEntity); + } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/ClassmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/ClassmodelServiceImpl.java index 3cf5107..47aa7a2 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/ClassmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/ClassmodelServiceImpl.java @@ -77,9 +77,11 @@ public class ClassmodelServiceImpl extends ServiceImpl updateWrapper=new UpdateWrapper<>(); - updateWrapper.eq("class_id",cid); - int delete = classmodelDao.delete(updateWrapper); + ClassmodelEntity classmodelEntity = classmodelDao.selectById(cid); + + classmodelEntity.setIsDelete("true"); + + int delete = classmodelDao.updateById(classmodelEntity); if(delete==1){ return true; } @@ -103,5 +105,29 @@ public class ClassmodelServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("class_name", class_name); + + return classmodelDao.selectOne(queryWrapper); + } + + @Override + public int insertClassModel(ClassmodelEntity classmodelEntity) { + return classmodelDao.insert(classmodelEntity); + } + + @Override + public int updateCourse(ClassmodelEntity classmodelEntity) { + return classmodelDao.updateById(classmodelEntity); + } + + @Override + public List getAll() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_delete", "false"); + return classmodelDao.selectList(queryWrapper); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java index f693408..d2c96e4 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/FeetbackServiceImpl.java @@ -108,9 +108,25 @@ public class FeetbackServiceImpl extends ServiceImpl map = new HashMap<>(); - map.put("feet_actid", act_id); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("feet_actid", act_id); + + List feetbackEntities = feetbackDao.selectList(queryWrapper); + + int res = 0; + + for (FeetbackEntity feetbackEntity : feetbackEntities) { + feetbackEntity.setIsDelete("true"); + + int i = feetbackDao.updateById(feetbackEntity); + + if(i == 0) return 0; + + res++; + } + + if(feetbackEntities.size() == 0) return 1; - return feetbackDao.deleteByMap(map); + return res; } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java index c05206f..eafde74 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PictureServiceImpl.java @@ -1,10 +1,10 @@ package io.renren.modules.generator.service.impl; import com.aliyun.oss.OSS; -import io.renren.common.exception.RRException; import io.renren.common.utils.OssUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -66,7 +66,7 @@ public class PictureServiceImpl extends ServiceImpl i public int deleteByIdAndLink(String p_id, String p_link) { OSS ossClient = OssUtils.getOssClient(); String bucketName = "ckedu2"; - String fileName = "picture/" + p_link.substring(OssUtils.getPath().length() + 1); + String fileName = p_link.substring(OssUtils.getPath().length()); if(!ossClient.doesObjectExist(bucketName, fileName)) return 0; @@ -78,4 +78,19 @@ public class PictureServiceImpl extends ServiceImpl i return pictureDao.deleteById(p_id); } + + @Override + public int getAllNum() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_delete", false); + + return pictureDao.selectCount(queryWrapper); + } + + @Override + public int deleteByEntity(PictureEntity pictureEntity) { + pictureEntity.setIsDelete("true"); + + return pictureDao.updateById(pictureEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java index 1ba04b4..07ddd18 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/PptServiceImpl.java @@ -41,7 +41,7 @@ public class PptServiceImpl extends ServiceImpl implements Pp public int deleteByIdAndLink(String pt_id, String pt_link) { OSS ossClient = OssUtils.getOssClient(); String bucketName = "ckedu2"; - String fileName = "ppt/" + pt_link.substring(OssUtils.getPath().length() + 1); + String fileName = pt_link.substring(OssUtils.getPath().length()); if(!ossClient.doesObjectExist(bucketName, fileName)) return 0; @@ -53,4 +53,19 @@ public class PptServiceImpl extends ServiceImpl implements Pp return pptDao.deleteById(pt_id); } + + @Override + public int getAllNum() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_delete", false); + + return pptDao.selectCount(queryWrapper); + } + + @Override + public int deleteByEntity(PptEntity pptEntity) { + pptEntity.setIsDelete("true"); + + return pptDao.updateById(pptEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java index 104c50e..a495055 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/QuestionServiceImpl.java @@ -61,4 +61,11 @@ public class QuestionServiceImpl extends ServiceImpl params) { IPage page = this.page( @@ -61,24 +46,9 @@ public class ResourcesServiceImpl extends ServiceImpl implements @Override public int deleteById(String text_id) { - return textDao.deleteById(text_id); + TextEntity textEntity = textDao.selectById(text_id); + textEntity.setIsDelete("true"); + + return textDao.updateById(textEntity); + } + + @Override + public int getAllNum() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_delete", false); + + return textDao.selectCount(queryWrapper); + } + + @Override + public int insertText(TextEntity textEntity) { + return textDao.insert(textEntity); } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java index a060051..6f51325 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/UnitmodelServiceImpl.java @@ -45,8 +45,9 @@ public class UnitmodelServiceImpl extends ServiceImpl getAllUnit(String courseId) { QueryWrapper queryWrapper=new QueryWrapper<>(); queryWrapper.eq("u_classid",courseId); - List unitmodelEntities = unitmodelDao.selectList(queryWrapper); - return unitmodelEntities; + queryWrapper.eq("is_delete", "false"); + + return unitmodelDao.selectList(queryWrapper); } @Override @@ -67,24 +68,12 @@ public class UnitmodelServiceImpl extends ServiceImpl activemodelEntityList = activemodelService.getAllActiveModel(u_id); + UnitmodelEntity unitmodelEntity = unitmodelDao.selectById(u_id); - for (ActivemodelEntity activemodelEntity : activemodelEntityList) { - int res = activemodelService.deleteById(activemodelEntity.getActId()); + unitmodelEntity.setIsDelete("true"); - if(res == 0) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return 0; - } - } - - return result; + return unitmodelDao.updateById(unitmodelEntity); } } diff --git a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java index c93e106..4fc14e6 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/VideoServiceImpl.java @@ -2,6 +2,7 @@ package io.renren.modules.generator.service.impl; import com.aliyun.oss.OSS; import io.renren.common.utils.OssUtils; +import io.renren.modules.generator.entity.PictureEntity; import io.renren.modules.generator.service.VideologService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -42,7 +43,7 @@ public class VideoServiceImpl extends ServiceImpl impleme public int deleteByIdAndLink(String v_id, String v_link) { OSS ossClient = OssUtils.getOssClient(); String bucketName = "ckedu2"; - String fileName = "video/" + v_link.substring(OssUtils.getPath().length() + 1); + String fileName = v_link.substring(OssUtils.getPath().length()); if(!ossClient.doesObjectExist(bucketName, fileName)) return 0; @@ -54,4 +55,19 @@ public class VideoServiceImpl extends ServiceImpl impleme return videoDao.deleteById(v_id); } + + @Override + public int getAllNum() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_delete", false); + + return videoDao.selectCount(queryWrapper); + } + + @Override + public int deleteByEntity(VideoEntity videoEntity) { + videoEntity.setIsDelete("true"); + + return videoDao.updateById(videoEntity); + } } \ No newline at end of file diff --git a/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java index c1eef71..63e434d 100644 --- a/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java +++ b/src/main/java/io/renren/modules/generator/service/impl/VideologServiceImpl.java @@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -40,4 +41,19 @@ public class VideologServiceImpl extends ServiceImpl getByVNumber(String resourcesRnumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("videolog_vnumber", resourcesRnumber); + + return videologDao.selectList(queryWrapper); + } + + @Override + public int deleteByEntity(VideologEntity videologEntity) { + videologEntity.setIsDelete("true"); + + return videologDao.updateById(videologEntity); + } } \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index ed756c1..8d8ae06 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -3,7 +3,7 @@ spring: type: com.alibaba.druid.pool.DruidDataSource druid: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/ckedu_2nn?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:mysql://localhost:3306/ckedu_2?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: 123456 initial-size: 10 -- Gitee From cff26b1b7cd938ece9edde4e5d17ea4338f7e6e1 Mon Sep 17 00:00:00 2001 From: Aurox Date: Fri, 24 Dec 2021 14:02:51 +0800 Subject: [PATCH 14/22] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=99=E5=B8=88?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TeacherregisterController.java | 90 ++++++++ .../generator/dao/TeacherregisterDao.java | 17 ++ .../entity/TeacherregisterEntity.java | 60 +++++ .../service/TeacherregisterService.java | 20 ++ .../impl/TeacherregisterServiceImpl.java | 29 +++ .../mapper/generator/TeacherregisterDao.xml | 20 ++ .../teacherregister-add-or-update.vue | 147 +++++++++++++ .../modules/generator/teacherregister.vue | 205 ++++++++++++++++++ 8 files changed, 588 insertions(+) create mode 100644 src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java create mode 100644 src/main/java/io/renren/modules/generator/dao/TeacherregisterDao.java create mode 100644 src/main/java/io/renren/modules/generator/entity/TeacherregisterEntity.java create mode 100644 src/main/java/io/renren/modules/generator/service/TeacherregisterService.java create mode 100644 src/main/java/io/renren/modules/generator/service/impl/TeacherregisterServiceImpl.java create mode 100644 src/main/resources/mapper/generator/TeacherregisterDao.xml create mode 100644 src/main/resources/src/views/modules/generator/teacherregister-add-or-update.vue create mode 100644 src/main/resources/src/views/modules/generator/teacherregister.vue diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java new file mode 100644 index 0000000..36fe7f7 --- /dev/null +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -0,0 +1,90 @@ +package io.renren.modules.generator.controller; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import io.renren.modules.generator.entity.TeacherregisterEntity; +import io.renren.modules.generator.service.TeacherregisterService; +import io.renren.common.utils.PageUtils; +import io.renren.common.utils.R; + + + +/** + * 教师注册表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-24 13:23:35 + */ +@RestController +@RequestMapping("generator/teacherregister") +public class TeacherregisterController { + @Autowired + private TeacherregisterService teacherregisterService; + + /** + * 列表 + */ + @RequestMapping("/list") + @RequiresPermissions("generator:teacherregister:list") + public R list(@RequestParam Map params){ + PageUtils page = teacherregisterService.queryPage(params); + + return R.ok().put("page", page); + } + + + /** + * 信息 + */ + @RequestMapping("/info/{trId}") + @RequiresPermissions("generator:teacherregister:info") + public R info(@PathVariable("trId") String trId){ + TeacherregisterEntity teacherregister = teacherregisterService.getById(trId); + + return R.ok().put("teacherregister", teacherregister); + } + + /** + * 保存 + */ + @RequestMapping("/save") + @RequiresPermissions("generator:teacherregister:save") + public R save(@RequestBody TeacherregisterEntity teacherregister){ + teacherregisterService.save(teacherregister); + + return R.ok(); + } + + /** + * 修改 + */ + @RequestMapping("/update") + @RequiresPermissions("generator:teacherregister:update") + public R update(@RequestBody TeacherregisterEntity teacherregister){ + teacherregisterService.updateById(teacherregister); + + return R.ok(); + } + + /** + * 删除 + */ + @RequestMapping("/delete") + @RequiresPermissions("generator:teacherregister:delete") + public R delete(@RequestBody String[] trIds){ + teacherregisterService.removeByIds(Arrays.asList(trIds)); + + return R.ok(); + } + +} diff --git a/src/main/java/io/renren/modules/generator/dao/TeacherregisterDao.java b/src/main/java/io/renren/modules/generator/dao/TeacherregisterDao.java new file mode 100644 index 0000000..2eafc50 --- /dev/null +++ b/src/main/java/io/renren/modules/generator/dao/TeacherregisterDao.java @@ -0,0 +1,17 @@ +package io.renren.modules.generator.dao; + +import io.renren.modules.generator.entity.TeacherregisterEntity; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 教师注册表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-24 13:23:35 + */ +@Mapper +public interface TeacherregisterDao extends BaseMapper { + +} diff --git a/src/main/java/io/renren/modules/generator/entity/TeacherregisterEntity.java b/src/main/java/io/renren/modules/generator/entity/TeacherregisterEntity.java new file mode 100644 index 0000000..d24e4af --- /dev/null +++ b/src/main/java/io/renren/modules/generator/entity/TeacherregisterEntity.java @@ -0,0 +1,60 @@ +package io.renren.modules.generator.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +/** + * 教师注册表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-24 13:23:35 + */ +@Data +@TableName("teacherregister") +public class TeacherregisterEntity implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 教师注册表id + */ + @TableId + private String trId; + /** + * 教师姓名 + */ + private String trName; + /** + * 教师用户名 + */ + private String trUsername; + /** + * 教师密码 + */ + private String trPassword; + /** + * 教师学校名称 + */ + private String trSchool; + /** + * 教师邮箱 + */ + private String trEmail; + /** + * 教师电话 + */ + private String trTelephone; + /** + * 是否通过 + */ + private String isPass; + /** + * 是否删除 + */ + private String isDelete; + +} diff --git a/src/main/java/io/renren/modules/generator/service/TeacherregisterService.java b/src/main/java/io/renren/modules/generator/service/TeacherregisterService.java new file mode 100644 index 0000000..b938829 --- /dev/null +++ b/src/main/java/io/renren/modules/generator/service/TeacherregisterService.java @@ -0,0 +1,20 @@ +package io.renren.modules.generator.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import io.renren.common.utils.PageUtils; +import io.renren.modules.generator.entity.TeacherregisterEntity; + +import java.util.Map; + +/** + * 教师注册表 + * + * @author zhaomr + * @email zzmr6180@163.com + * @date 2021-12-24 13:23:35 + */ +public interface TeacherregisterService extends IService { + + PageUtils queryPage(Map params); +} + diff --git a/src/main/java/io/renren/modules/generator/service/impl/TeacherregisterServiceImpl.java b/src/main/java/io/renren/modules/generator/service/impl/TeacherregisterServiceImpl.java new file mode 100644 index 0000000..1123a0e --- /dev/null +++ b/src/main/java/io/renren/modules/generator/service/impl/TeacherregisterServiceImpl.java @@ -0,0 +1,29 @@ +package io.renren.modules.generator.service.impl; + +import org.springframework.stereotype.Service; +import java.util.Map; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import io.renren.common.utils.PageUtils; +import io.renren.common.utils.Query; + +import io.renren.modules.generator.dao.TeacherregisterDao; +import io.renren.modules.generator.entity.TeacherregisterEntity; +import io.renren.modules.generator.service.TeacherregisterService; + + +@Service("teacherregisterService") +public class TeacherregisterServiceImpl extends ServiceImpl implements TeacherregisterService { + + @Override + public PageUtils queryPage(Map params) { + IPage page = this.page( + new Query().getPage(params), + new QueryWrapper() + ); + + return new PageUtils(page); + } + +} \ No newline at end of file diff --git a/src/main/resources/mapper/generator/TeacherregisterDao.xml b/src/main/resources/mapper/generator/TeacherregisterDao.xml new file mode 100644 index 0000000..998384e --- /dev/null +++ b/src/main/resources/mapper/generator/TeacherregisterDao.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/src/views/modules/generator/teacherregister-add-or-update.vue b/src/main/resources/src/views/modules/generator/teacherregister-add-or-update.vue new file mode 100644 index 0000000..3aee148 --- /dev/null +++ b/src/main/resources/src/views/modules/generator/teacherregister-add-or-update.vue @@ -0,0 +1,147 @@ + + + diff --git a/src/main/resources/src/views/modules/generator/teacherregister.vue b/src/main/resources/src/views/modules/generator/teacherregister.vue new file mode 100644 index 0000000..c7a122d --- /dev/null +++ b/src/main/resources/src/views/modules/generator/teacherregister.vue @@ -0,0 +1,205 @@ + + + -- Gitee From 587350b689ceb202d2e45ec46fc4ec43681f4018 Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 21:39:06 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=99=E5=B8=88?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/generator/controller/TeacherregisterController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 36fe7f7..10b1bc1 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -31,6 +31,8 @@ public class TeacherregisterController { @Autowired private TeacherregisterService teacherregisterService; + + /** * 列表 */ -- Gitee From a8240f35049d0a5dea2d99b9ca7dbfc450b1b93b Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:04:10 +0800 Subject: [PATCH 16/22] test --- .../generator/controller/TeacherregisterController.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 10b1bc1..05a028b 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -20,7 +20,6 @@ import io.renren.common.utils.R; /** * 教师注册表 - * * @author zhaomr * @email zzmr6180@163.com * @date 2021-12-24 13:23:35 @@ -31,8 +30,6 @@ public class TeacherregisterController { @Autowired private TeacherregisterService teacherregisterService; - - /** * 列表 */ @@ -44,7 +41,6 @@ public class TeacherregisterController { return R.ok().put("page", page); } - /** * 信息 */ -- Gitee From 7a6ed3218cd28ef3bac6b552e06c130eeb40ab96 Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:12:17 +0800 Subject: [PATCH 17/22] test1 --- .../generator/controller/TeacherregisterController.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 05a028b..45a6b00 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -30,6 +30,13 @@ public class TeacherregisterController { @Autowired private TeacherregisterService teacherregisterService; + @RequestMapping("/test") + public R test1(@RequestParam Map params) { + System.out.println("test"); + + return R.ok("test"); + } + /** * 列表 */ -- Gitee From f66dc0f0d67ccb72ab592f3a17189f12993f968e Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:13:44 +0800 Subject: [PATCH 18/22] test2 --- .../modules/generator/controller/TeacherregisterController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 45a6b00..3fa197c 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -32,7 +32,7 @@ public class TeacherregisterController { @RequestMapping("/test") public R test1(@RequestParam Map params) { - System.out.println("test"); + System.out.println("test2"); return R.ok("test"); } -- Gitee From 82f9415f175558c8769ebee90b62bb4fc3245324 Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:14:50 +0800 Subject: [PATCH 19/22] test --- .../modules/generator/controller/TeacherregisterController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 3fa197c..69c939c 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -45,6 +45,8 @@ public class TeacherregisterController { public R list(@RequestParam Map params){ PageUtils page = teacherregisterService.queryPage(params); + System.out.println("123"); + return R.ok().put("page", page); } -- Gitee From 5a2299ffea9f993135d1f145b624421b0b47a84d Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:15:22 +0800 Subject: [PATCH 20/22] test3 --- .../modules/generator/controller/TeacherregisterController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 3fa197c..9fa46cd 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -32,7 +32,7 @@ public class TeacherregisterController { @RequestMapping("/test") public R test1(@RequestParam Map params) { - System.out.println("test2"); + System.out.println("test3"); return R.ok("test"); } -- Gitee From fe5aa324abe02d2b8f54241e131dd114d5fbffdc Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:34:49 +0800 Subject: [PATCH 21/22] test4 --- .../generator/controller/TeacherregisterController.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 91e8d0e..93c82ff 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -32,7 +32,7 @@ public class TeacherregisterController { @RequestMapping("/test") public R test1(@RequestParam Map params) { - System.out.println("test3"); + System.out.println("test4"); return R.ok("test"); } @@ -45,8 +45,6 @@ public class TeacherregisterController { public R list(@RequestParam Map params){ PageUtils page = teacherregisterService.queryPage(params); - System.out.println("123"); - return R.ok().put("page", page); } -- Gitee From dba5b49144b785b60b0a64796328f27c20e0a21b Mon Sep 17 00:00:00 2001 From: Aurox Date: Wed, 12 Jan 2022 22:36:24 +0800 Subject: [PATCH 22/22] testOver --- .../generator/controller/TeacherregisterController.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java index 93c82ff..05a028b 100644 --- a/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java +++ b/src/main/java/io/renren/modules/generator/controller/TeacherregisterController.java @@ -30,13 +30,6 @@ public class TeacherregisterController { @Autowired private TeacherregisterService teacherregisterService; - @RequestMapping("/test") - public R test1(@RequestParam Map params) { - System.out.println("test4"); - - return R.ok("test"); - } - /** * 列表 */ -- Gitee