From f775fae316321896d80473404cdcb7e6a4b344ff Mon Sep 17 00:00:00 2001 From: Aurox Date: Tue, 23 Nov 2021 20:03:57 +0800 Subject: [PATCH 1/5] =?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 2/5] =?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 3/5] =?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 4/5] =?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 5/5] =?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